|
@@ -80,7 +80,9 @@ const app = new Vue({
|
|
|
// seo关键词
|
|
|
seo: '',
|
|
|
// 产品链接
|
|
|
- link: ''
|
|
|
+ productLink: '',
|
|
|
+ // 空缺数量
|
|
|
+ emptyNum: ''
|
|
|
},
|
|
|
rules: {
|
|
|
// 产品名称
|
|
@@ -94,7 +96,7 @@ const app = new Vue({
|
|
|
// 产品参数
|
|
|
paramList: [{required: true, validator: validateParamList, trigger: 'change'}],
|
|
|
// 产品链接
|
|
|
- link: [{required: true, message: '产品链接不能为空', trigger: ['change', 'blur']}]
|
|
|
+ productLink: [{required: true, message: '产品链接不能为空', trigger: ['change', 'blur']}],
|
|
|
// // 产品优点
|
|
|
// advantage: [{required: true, message: '产品优点不能为空', trigger: 'change'}],
|
|
|
// // 产品缺点
|
|
@@ -123,8 +125,8 @@ const app = new Vue({
|
|
|
// displayImageList: [{required: true, message: '请上传效果展示图片', trigger: 'change'}],
|
|
|
// // 常见问题
|
|
|
// questionList: [{required: true, validator: validateQuestionList, trigger: 'change'}],
|
|
|
- // // 产品类别
|
|
|
- // typeId: [{required: true, message: '请选择产品类别', trigger: 'change'}],
|
|
|
+ // 产品类别
|
|
|
+ typeId: [{required: true, message: '请选择产品类别', trigger: 'change'}],
|
|
|
// // 产品状态
|
|
|
// status: [{required: true, message: '请选择产品状态', trigger: 'change'}],
|
|
|
},
|
|
@@ -193,25 +195,87 @@ const app = new Vue({
|
|
|
this.socrllToErrorInput()
|
|
|
return
|
|
|
}
|
|
|
- this.saveFormData()
|
|
|
+ this.formData.emptyNum = this.validateEmptyParams(this.formData)
|
|
|
+ if( this.formData.emptyNum> 0){
|
|
|
+ this.$confirm('您还剩余' + this.formData.emptyNum + '项未完善,将会导致用户对您产品/仪器的认识度不够,确认是否提交?', '提示', {
|
|
|
+ confirmButtonText: '是',
|
|
|
+ cancelButtonText: '否'
|
|
|
+ }).then(() => {
|
|
|
+ this.saveFormData()
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
+ // 校验空参数个数
|
|
|
+ validateEmptyParams(params){
|
|
|
+ const keys = Object.keys(params)
|
|
|
+ console.log(params)
|
|
|
+ let count = 0
|
|
|
+ keys.forEach(key => {
|
|
|
+ if(typeof params[key] === "string"){
|
|
|
+ if(params[key] === '' || params[key].trim().length <= 0){
|
|
|
+ count ++
|
|
|
+ }
|
|
|
+ }else if(typeof params[key] === 'number'){
|
|
|
+ console.log(key)
|
|
|
+ }else if(typeof params[key] === 'object'){
|
|
|
+ if(params[key] instanceof Array){
|
|
|
+ if(params[key].length <= 0){
|
|
|
+ count ++
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(params[key] === null){
|
|
|
+ count ++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(typeof params[key] === 'undefined'){
|
|
|
+ count ++
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return count;
|
|
|
+ },
|
|
|
// 保存表单数据
|
|
|
saveFormData() {
|
|
|
const that = this;
|
|
|
+
|
|
|
const params = {
|
|
|
...this.formData,
|
|
|
shopId: this.shopId,
|
|
|
commodityType: this.commodityType,
|
|
|
paramList: JSON.stringify(this.paramList),
|
|
|
questionList: JSON.stringify(this.questionList),
|
|
|
- marketTime: dateFormat(this.formData.marketTime, 'yyyy-MM-dd'),
|
|
|
- nmpaTime: dateFormat(this.formData.nmpaTime, 'yyyy-MM-dd'),
|
|
|
+ // marketTime: dateFormat(this.formData.marketTime, 'yyyy-MM-dd'),
|
|
|
+ // nmpaTime: dateFormat(this.formData.nmpaTime, 'yyyy-MM-dd'),
|
|
|
authImageList: this.authImageList.map(image => (image.response ? image.response.data : image.url)),
|
|
|
displayImageList: this.displayImageList.map(image => (image.response ? image.response.data : image.url))
|
|
|
};
|
|
|
|
|
|
+ debugger
|
|
|
+
|
|
|
+ console.log(params);
|
|
|
+
|
|
|
+ /* 处理时间 */
|
|
|
+ if(this.formData.marketTime){
|
|
|
+ if(this.marketTimeType === 'year'){
|
|
|
+ params.marketTime = dateFormat(this.formData.marketTime, 'yyyy')
|
|
|
+ }else if(this.marketTimeType === 'month'){
|
|
|
+ params.marketTime = dateFormat(this.formData.marketTime, 'yyyy-MM')
|
|
|
+ }else{
|
|
|
+ params.marketTime = dateFormat(this.formData.marketTime, 'yyyy-MM-dd')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 处理时间 */
|
|
|
+ if(this.formData.nmpaTimeType){
|
|
|
+ if(this.nmpaTimeType === 'year'){
|
|
|
+ params.nmpaTime = dateFormat(this.formData.nmpaTime, 'yyyy')
|
|
|
+ }else if(this.marketTimeType === 'month'){
|
|
|
+ params.nmpaTime = dateFormat(this.formData.nmpaTime, 'yyyy-MM')
|
|
|
+ }else{
|
|
|
+ params.nmpaTime = dateFormat(this.formData.nmpaTime, 'yyyy-MM-dd')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (this.productId) params.productId = this.productId;
|
|
|
console.log(params);
|
|
|
SupplierApi.ShopBaikeProductSave(params, function (res) {
|