Explorar el Código

feat: 发票管理新增关联信息数量可修改

liujt hace 9 meses
padre
commit
923499d060

+ 9 - 0
src/views/financialManage/invoiceManage/components/addOrEditDialog.vue

@@ -789,6 +789,15 @@
           if (this.form.sourceType != 4 || this.form.sourceType != 5) {
           if (this.form.sourceType != 4 || this.form.sourceType != 5) {
             tableData = await this.$refs.table.getTableValidate();
             tableData = await this.$refs.table.getTableValidate();
           }
           }
+          // 校验表格数据
+          const tableValid = await new Promise((resolve) => {
+            this.$refs.table.validateForm((valid) => {
+              resolve(valid);
+            });
+          });
+          if (!tableValid) {
+            return;
+          }
           this.form.link = tableData.link;
           this.form.link = tableData.link;
           this.form.detailList = tableData.detailList;
           this.form.detailList = tableData.detailList;
           const API =
           const API =

+ 68 - 14
src/views/financialManage/invoiceManage/components/tableInfo.vue

@@ -1,16 +1,48 @@
 <template>
 <template>
   <div>
   <div>
-    <ele-pro-table
-      ref="table"
-      :needPage="false"
-      :columns="columns"
-      :datasource="tableForm.detailList"
-      row-key="id"
-    >
-      <template v-slot:toolbar>
-        <span>已开票金额:{{ invoiceAmount }}</span>
+    <el-form ref="form" :model="tableForm">
+      <ele-pro-table
+        ref="table"
+        :needPage="false"
+        :columns="columns"
+        :datasource="tableForm.detailList"
+        row-key="id"
+        class="time-form"
+      >
+        <template v-slot:toolbar>
+          <span>已开票金额:{{ invoiceAmount }}</span>
+        </template>
+        
+        <template v-slot:totalCount="scope">
+        <el-form-item
+          style="width: 100%;"
+          :prop="'detailList.' + scope.$index + '.totalCount'"
+          :rules="[
+            {
+              required: true,
+              message: '请输入数量',
+              trigger: 'blur'
+            },
+            {
+              validator: (rule, value, callback) => {
+                if (value === undefined || value === null || value === '') {
+                  callback('请输入数量');
+                } else if (parseFloat(value) <= 0) {
+                  callback('数量必须大于0');
+                } else {
+                  callback();
+                }
+              },
+              trigger: 'blur'
+            }
+          ]"
+        >
+          <el-input v-model="scope.row.totalCount" type="number" @input="updateTotalPrice(scope.row)"></el-input>
+        </el-form-item>
       </template>
       </template>
-    </ele-pro-table>
+
+      </ele-pro-table>
+    </el-form>
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
@@ -115,11 +147,11 @@
           // },
           // },
 
 
           {
           {
-            width: 80,
+            width: 100,
             prop: 'totalCount',
             prop: 'totalCount',
             label: '数量',
             label: '数量',
             slot: 'totalCount',
             slot: 'totalCount',
-            align: 'center'
+            align: 'center',
           },
           },
 
 
           {
           {
@@ -207,7 +239,7 @@
             label: '采购退货',
             label: '采购退货',
             value: '21'
             value: '21'
           }
           }
-        ]
+        ],
       };
       };
     },
     },
     mounted() {
     mounted() {
@@ -273,6 +305,12 @@
           link: []
           link: []
         };
         };
       },
       },
+      // 当数量变化时更新金额
+      updateTotalPrice(row) {
+        if (row.totalCount && row.singlePrice) {
+          row.totalPrice = (parseFloat(row.totalCount) * parseFloat(row.singlePrice)).toFixed(2);
+        }
+      },
       getTableValidate() {
       getTableValidate() {
         return new Promise((resolve, reject) => {
         return new Promise((resolve, reject) => {
           if (
           if (
@@ -283,6 +321,18 @@
           resolve(this.tableForm);
           resolve(this.tableForm);
         });
         });
       },
       },
+      validateForm(callback) {
+        //开始表单校验
+        this.$refs.form.validate((valid, obj) => {
+          if (obj) {
+            let messages = Object.keys(obj).map((key) => obj[key][0]);
+            if (messages.length > 0) {
+              this.$message.warning(messages[0].message);
+            }
+          }
+          callback(valid);
+        });
+      },
       setSelectData(val) {
       setSelectData(val) {
         this.tableForm.link = [{}];
         this.tableForm.link = [{}];
         this.$set(this.tableForm.link[0], 'linkId', val.id);
         this.$set(this.tableForm.link[0], 'linkId', val.id);
@@ -296,4 +346,8 @@
   };
   };
 </script>
 </script>
 
 
-<style scoped lang="scss"></style>
+<style scoped lang="scss">
+.time-form .el-form-item {
+  margin-bottom: 0 !important;
+}
+</style>