|
@@ -102,21 +102,21 @@ new Vue({
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '名称不能为空',
|
|
message: '名称不能为空',
|
|
- trigger: ['blur','change']
|
|
|
|
|
|
+ trigger: ['blur', 'change']
|
|
}],
|
|
}],
|
|
// 产品别名
|
|
// 产品别名
|
|
alias: [{
|
|
alias: [{
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '别名不能为空',
|
|
message: '别名不能为空',
|
|
- trigger: ['blur','change']
|
|
|
|
|
|
+ trigger: ['blur', 'change']
|
|
}],
|
|
}],
|
|
// 产品概述
|
|
// 产品概述
|
|
discription: [{
|
|
discription: [{
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '概述不能为空',
|
|
message: '概述不能为空',
|
|
- trigger: ['blur','change']
|
|
|
|
|
|
+ trigger: ['blur', 'change']
|
|
}],
|
|
}],
|
|
// 产品图片
|
|
// 产品图片
|
|
image: [{
|
|
image: [{
|
|
@@ -159,35 +159,40 @@ new Vue({
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '品牌不能为空',
|
|
message: '品牌不能为空',
|
|
- trigger: ['change','blur']
|
|
|
|
|
|
+ trigger: ['change', 'blur']
|
|
}],
|
|
}],
|
|
// 产地
|
|
// 产地
|
|
producePlace: [{
|
|
producePlace: [{
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '产地不能为空',
|
|
message: '产地不能为空',
|
|
- trigger: ['change','blur']
|
|
|
|
|
|
+ trigger: ['change', 'blur']
|
|
}],
|
|
}],
|
|
|
|
+
|
|
// 上市时间
|
|
// 上市时间
|
|
marketTime: [{
|
|
marketTime: [{
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '上市时间不能为空',
|
|
message: '上市时间不能为空',
|
|
- trigger: ['change','blur']
|
|
|
|
|
|
+ trigger: ['change', 'blur'],
|
|
|
|
+ pattern: {
|
|
|
|
+ reg: /^\d{4}/g,
|
|
|
|
+ regMessage: '时间格式不正确,年月日请以"-"连接'
|
|
|
|
+ },
|
|
}],
|
|
}],
|
|
// 公司/厂商
|
|
// 公司/厂商
|
|
company: [{
|
|
company: [{
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: '公司/厂商不能为空',
|
|
message: '公司/厂商不能为空',
|
|
- trigger: ['change','blur']
|
|
|
|
|
|
+ trigger: ['change', 'blur']
|
|
}],
|
|
}],
|
|
// NMPA认证时间
|
|
// NMPA认证时间
|
|
nmpaTime: [{
|
|
nmpaTime: [{
|
|
type: 'string',
|
|
type: 'string',
|
|
required: true,
|
|
required: true,
|
|
message: 'NMPA认证时间不能为空',
|
|
message: 'NMPA认证时间不能为空',
|
|
- trigger: ['change','blur']
|
|
|
|
|
|
+ trigger: ['change', 'blur']
|
|
}],
|
|
}],
|
|
// 产品认证
|
|
// 产品认证
|
|
authImageList: [{
|
|
authImageList: [{
|
|
@@ -229,7 +234,7 @@ new Vue({
|
|
type: 'array',
|
|
type: 'array',
|
|
required: true,
|
|
required: true,
|
|
message: '常见问题不能为空',
|
|
message: '常见问题不能为空',
|
|
- trigger: ['change','blur'],
|
|
|
|
|
|
+ trigger: ['change', 'blur'],
|
|
valid: ['question', 'answer']
|
|
valid: ['question', 'answer']
|
|
}],
|
|
}],
|
|
// 产品类别
|
|
// 产品类别
|
|
@@ -241,7 +246,7 @@ new Vue({
|
|
}],
|
|
}],
|
|
// 产品状态
|
|
// 产品状态
|
|
status: [{
|
|
status: [{
|
|
- type: 'number',
|
|
|
|
|
|
+ type: 'number',
|
|
required: true,
|
|
required: true,
|
|
message: '状态不能为空',
|
|
message: '状态不能为空',
|
|
trigger: 'change'
|
|
trigger: 'change'
|
|
@@ -270,7 +275,7 @@ new Vue({
|
|
},
|
|
},
|
|
|
|
|
|
// 初始化表单数据
|
|
// 初始化表单数据
|
|
- initFormData(formData){
|
|
|
|
|
|
+ initFormData(formData) {
|
|
console.log(formData);
|
|
console.log(formData);
|
|
// 初始化this.formData
|
|
// 初始化this.formData
|
|
for (var key in this.formData) {
|
|
for (var key in this.formData) {
|
|
@@ -284,18 +289,18 @@ new Vue({
|
|
this.formData.nmpaTime = dateFormat(new Date(this.formData.nmpaTime), 'yyyy-MM-dd');
|
|
this.formData.nmpaTime = dateFormat(new Date(this.formData.nmpaTime), 'yyyy-MM-dd');
|
|
|
|
|
|
// 初始化图片列表 imageList authImageList displayImageList
|
|
// 初始化图片列表 imageList authImageList displayImageList
|
|
- this.imageList = this.initPreviewImageList([formData.image], { name: '授权图片' });
|
|
|
|
- this.authImageList = this.initPreviewImageList(formData.authImageList, { name: '授权图片' });
|
|
|
|
- this.displayImageList = this.initPreviewImageList(formData.displayImageList, { name: '效果图' });
|
|
|
|
|
|
+ this.imageList = this.initPreviewImageList([formData.image], {name: '授权图片'});
|
|
|
|
+ this.authImageList = this.initPreviewImageList(formData.authImageList, {name: '授权图片'});
|
|
|
|
+ this.displayImageList = this.initPreviewImageList(formData.displayImageList, {name: '效果图'});
|
|
},
|
|
},
|
|
|
|
|
|
// 初始化图片
|
|
// 初始化图片
|
|
- initPreviewImageList(imageList, options){
|
|
|
|
- if(!options){
|
|
|
|
|
|
+ initPreviewImageList(imageList, options) {
|
|
|
|
+ if (!options) {
|
|
options.name = '图片'
|
|
options.name = '图片'
|
|
}
|
|
}
|
|
|
|
|
|
- return imageList.map(function(item){
|
|
|
|
|
|
+ return imageList.map(function (item) {
|
|
return {
|
|
return {
|
|
name: options.name,
|
|
name: options.name,
|
|
url: item
|
|
url: item
|
|
@@ -309,13 +314,13 @@ new Vue({
|
|
this.productId = localStorage.getItem('productId');
|
|
this.productId = localStorage.getItem('productId');
|
|
localStorage.removeItem('productId');
|
|
localStorage.removeItem('productId');
|
|
|
|
|
|
- if(!this.productId) return;
|
|
|
|
|
|
+ if (!this.productId) return;
|
|
|
|
|
|
const that = this;
|
|
const that = this;
|
|
- SupplierApi.GetShopBaikeProductForm({ productId: this.productId }, function(res){
|
|
|
|
- if(res.code === 0){
|
|
|
|
|
|
+ SupplierApi.GetShopBaikeProductForm({productId: this.productId}, function (res) {
|
|
|
|
+ if (res.code === 0) {
|
|
that.initFormData(res.data);
|
|
that.initFormData(res.data);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
CAIMEI.dialog('获取产品数据失败', false);
|
|
CAIMEI.dialog('获取产品数据失败', false);
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
that.handleBack();
|
|
that.handleBack();
|
|
@@ -334,15 +339,15 @@ new Vue({
|
|
questionList: JSON.stringify(this.formData.questionList)
|
|
questionList: JSON.stringify(this.formData.questionList)
|
|
};
|
|
};
|
|
|
|
|
|
- if(this.productId) params.productId = this.productId;
|
|
|
|
|
|
+ if (this.productId) params.productId = this.productId;
|
|
|
|
|
|
- SupplierApi.ShopBaikeProductSave(params, function(res){
|
|
|
|
- if(res.code === 0) {
|
|
|
|
|
|
+ SupplierApi.ShopBaikeProductSave(params, function (res) {
|
|
|
|
+ if (res.code === 0) {
|
|
CAIMEI.dialog('保存成功', false);
|
|
CAIMEI.dialog('保存成功', false);
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
that.handleBack();
|
|
that.handleBack();
|
|
}, 2000);
|
|
}, 2000);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
CAIMEI.Alert(res.msg, '确认', false)
|
|
CAIMEI.Alert(res.msg, '确认', false)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -360,72 +365,71 @@ new Vue({
|
|
console.log(this.formData);
|
|
console.log(this.formData);
|
|
const that = this;
|
|
const that = this;
|
|
// that.saveFormData();
|
|
// that.saveFormData();
|
|
- this.validFormData(this.formData, this.rules).then(res=>{
|
|
|
|
|
|
+ this.validFormData(this.formData, this.rules).then(res => {
|
|
that.saveFormData()
|
|
that.saveFormData()
|
|
- }).catch(()=>{
|
|
|
|
|
|
+ }).catch(() => {
|
|
CAIMEI.dialog('必填项不能为空', false)
|
|
CAIMEI.dialog('必填项不能为空', false)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
// 上传封面图片
|
|
// 上传封面图片
|
|
- handleUploadProductImage(files){
|
|
|
|
- this.uploadImage(files[0]).then(res=>{
|
|
|
|
|
|
+ handleUploadProductImage(files) {
|
|
|
|
+ this.uploadImage(files[0]).then(res => {
|
|
this.formData.image = res;
|
|
this.formData.image = res;
|
|
- this.imageList.push({ url: res , name: '封面'})
|
|
|
|
- }).catch(err=>{
|
|
|
|
|
|
+ this.imageList.push({url: res, name: '封面'})
|
|
|
|
+ }).catch(err => {
|
|
console.log(err)
|
|
console.log(err)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
// 删除上传的封面图片
|
|
// 删除上传的封面图片
|
|
- handleRemoveProductImage(){
|
|
|
|
|
|
+ handleRemoveProductImage() {
|
|
this.formData.image = ''
|
|
this.formData.image = ''
|
|
},
|
|
},
|
|
|
|
|
|
// 上传授权图片
|
|
// 上传授权图片
|
|
- handleUploadAuthImage(files){
|
|
|
|
|
|
+ handleUploadAuthImage(files) {
|
|
const that = this;
|
|
const that = this;
|
|
files.forEach(function (file) {
|
|
files.forEach(function (file) {
|
|
- if(file.type){
|
|
|
|
|
|
+ if (file.type) {
|
|
// resultFiles 是 input 中选中的文件列表
|
|
// resultFiles 是 input 中选中的文件列表
|
|
// insertImgFn 是获取图片 url 后,插入到编辑器的方法
|
|
// insertImgFn 是获取图片 url 后,插入到编辑器的方法
|
|
that.uploadImage(file).then(function (res) {
|
|
that.uploadImage(file).then(function (res) {
|
|
that.formData.authImageList.push(res);
|
|
that.formData.authImageList.push(res);
|
|
- that.authImageList.push({ url: res, name: '图片' })
|
|
|
|
|
|
+ that.authImageList.push({url: res, name: '图片'})
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
// 删除上传的授权图片
|
|
// 删除上传的授权图片
|
|
- handleRemoveAuthImage(index){
|
|
|
|
- this.formData.authImageList.splice(index, 1);
|
|
|
|
- this.authImageList.splice(index, 1);
|
|
|
|
- console.log(this.formData.authImageList);
|
|
|
|
- console.log(this.authImageList);
|
|
|
|
|
|
+ handleRemoveAuthImage(index) {
|
|
|
|
+ this.formData.authImageList.splice(index, 1);
|
|
|
|
+ this.authImageList.splice(index, 1);
|
|
|
|
+ console.log(this.formData.authImageList);
|
|
|
|
+ console.log(this.authImageList);
|
|
},
|
|
},
|
|
|
|
|
|
// 上传效果展示图片
|
|
// 上传效果展示图片
|
|
- handleUploadDisplayImageList(files){
|
|
|
|
|
|
+ handleUploadDisplayImageList(files) {
|
|
const that = this;
|
|
const that = this;
|
|
files.forEach(function (file) {
|
|
files.forEach(function (file) {
|
|
- if(file.type){
|
|
|
|
|
|
+ if (file.type) {
|
|
// resultFiles 是 input 中选中的文件列表
|
|
// resultFiles 是 input 中选中的文件列表
|
|
// insertImgFn 是获取图片 url 后,插入到编辑器的方法
|
|
// insertImgFn 是获取图片 url 后,插入到编辑器的方法
|
|
that.uploadImage(file).then(function (res) {
|
|
that.uploadImage(file).then(function (res) {
|
|
that.formData.displayImageList.push(res);
|
|
that.formData.displayImageList.push(res);
|
|
- that.displayImageList.push({ url: res, name: '图片' })
|
|
|
|
|
|
+ that.displayImageList.push({url: res, name: '图片'})
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
// 删除上传的效果展示图片
|
|
// 删除上传的效果展示图片
|
|
- handleRemoveDisplayImageList(index){
|
|
|
|
- this.formData.displayImageList.splice(index, 1);
|
|
|
|
- this.displayImageList.splice(index, 1);
|
|
|
|
|
|
+ handleRemoveDisplayImageList(index) {
|
|
|
|
+ this.formData.displayImageList.splice(index, 1);
|
|
|
|
+ this.displayImageList.splice(index, 1);
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
// 上传图片
|
|
// 上传图片
|
|
uploadImage: function uploadImage(file) {
|
|
uploadImage: function uploadImage(file) {
|
|
var formData = new FormData();
|
|
var formData = new FormData();
|