Ver Fonte

fix:商品信息单位

maliang há 1 mês atrás
pai
commit
1fc1084a13
1 ficheiros alterados com 73 adições e 63 exclusões
  1. 73 63
      jshERP-web/src/views/material/modules/MaterialModal.vue

+ 73 - 63
jshERP-web/src/views/material/modules/MaterialModal.vue

@@ -663,7 +663,7 @@ export default {
             disabled: true,
             defaultValue: '',
             placeholder: '请输入${title}',
-            validateRules: [{ required: true, message: '${title}不能为空' }],
+            // validateRules: [{ required: true, message: '${title}不能为空' }],
           },
           {
             title: '多属性',
@@ -1087,69 +1087,69 @@ export default {
                 }
               }
             }
-            if (!formData.unit) {
-              //此时为多单位
-              // if (formData.meList.length < 2) {
-              //   this.$message.warning('多单位的商品条码行数至少要有两行,请再新增一行条码信息!')
-              //   return
-              // }
-              if (formData.meList[0].commodityUnit != basicUnit) {
-                this.$message.warning(
-                  '条码之后的单位填写有误,单位【' +
-                    formData.meList[0].commodityUnit +
-                    '】请修改为【' +
-                    basicUnit +
-                    '】!'
-                )
-                return
-              }
-              if (formData.meList[1].commodityUnit != otherUnit) {
-                this.$message.warning(
-                  '条码之后的单位填写有误,单位【' +
-                    formData.meList[1].commodityUnit +
-                    '】请修改为【' +
-                    otherUnit +
-                    '】!'
-                )
-                return
-              }
-            }
+            // if (!formData.unit) {
+            //   // 此时为多单位
+            //   if (formData.meList.length < 2) {
+            //     this.$message.warning('多单位的商品条码行数至少要有两行,请再新增一行条码信息!')
+            //     return
+            //   }
+            //   if (formData.meList[0].commodityUnit != basicUnit) {
+            //     this.$message.warning(
+            //       '条码之后的单位填写有误,单位【' +
+            //         formData.meList[0].commodityUnit +
+            //         '】请修改为【' +
+            //         basicUnit +
+            //         '】!'
+            //     )
+            //     return
+            //   }
+            //   if (formData.meList[1].commodityUnit != otherUnit) {
+            //     this.$message.warning(
+            //       '条码之后的单位填写有误,单位【' +
+            //         formData.meList[1].commodityUnit +
+            //         '】请修改为【' +
+            //         otherUnit +
+            //         '】!'
+            //     )
+            //     return
+            //   }
+            // }
             let skuCount = 0
             for (let i = 0; i < formData.meList.length; i++) {
-              let commodityUnit = formData.meList[i].commodityUnit
-              if (formData.unit) {
-                if (commodityUnit != formData.unit) {
-                  this.$message.warning(
-                    '条码之后的单位填写有误,单位【' + commodityUnit + '】请修改为【' + formData.unit + '】!'
-                  )
-                  return
-                }
-              } else if (formData.unitId) {
-                if (
-                  commodityUnit != basicUnit &&
-                  commodityUnit != otherUnit &&
-                  commodityUnit != otherUnitTwo &&
-                  commodityUnit != otherUnitThree
-                ) {
-                  let warnInfo =
-                    '条码之后的单位填写有误,单位【' +
-                    commodityUnit +
-                    '】请修改为【' +
-                    basicUnit +
-                    '】或【' +
-                    otherUnit +
-                    '】'
-                  if (otherUnitTwo) {
-                    warnInfo += '或【' + otherUnitTwo + '】'
-                  }
-                  if (otherUnitThree) {
-                    warnInfo += '或【' + otherUnitThree + '】'
-                  }
-                  warnInfo += '!'
-                  this.$message.warning(warnInfo)
-                  return
-                }
-              }
+              // let commodityUnit = formData.meList[i].commodityUnit
+              // if (formData.unit) {
+              //   if (commodityUnit != formData.unit) {
+              //     this.$message.warning(
+              //       '条码之后的单位填写有误,单位【' + commodityUnit + '】请修改为【' + formData.unit + '】!'
+              //     )
+              //     return
+              //   }
+              // } else if (formData.unitId) {
+              //   if (
+              //     commodityUnit != basicUnit &&
+              //     commodityUnit != otherUnit &&
+              //     commodityUnit != otherUnitTwo &&
+              //     commodityUnit != otherUnitThree
+              //   ) {
+              //     let warnInfo =
+              //       '条码之后的单位填写有误,单位【' +
+              //       commodityUnit +
+              //       '】请修改为【' +
+              //       basicUnit +
+              //       '】或【' +
+              //       otherUnit +
+              //       '】'
+              //     if (otherUnitTwo) {
+              //       warnInfo += '或【' + otherUnitTwo + '】'
+              //     }
+              //     if (otherUnitThree) {
+              //       warnInfo += '或【' + otherUnitThree + '】'
+              //     }
+              //     warnInfo += '!'
+              //     this.$message.warning(warnInfo)
+              //     return
+              //   }
+              // }
               if (formData.sku) {
                 skuCount++
               }
@@ -1411,7 +1411,17 @@ export default {
     },
     onAdded(event) {
       const { row, target } = event
-      target.setValues([{ rowKey: row.id, values: { barCode: '', commodityUnit: '' } }])
+      let formUnit = ''
+      // 勾选多单位
+      if(this.unitChecked){
+        const obj = this.unitList.find(item => item.id === this.form.getFieldValue('unitId'))
+        if(obj){
+          formUnit = obj.basicUnit
+        }
+      }else{
+        formUnit = this.form.getFieldValue('unit')
+      }
+      target.setValues([{ rowKey: row.id, values: { barCode: '', commodityUnit: formUnit } }])
     },
     onDeleted(value) {
       this.meDeleteIdList = value