Procházet zdrojové kódy

fix: 修复发票管理表格显示及按钮重复点击问题

liujt před 4 měsíci
rodič
revize
623de66b67

+ 5 - 2
src/views/bpm/handleTask/components/financialManage/invoiceManage/components/detailDialog.vue

@@ -332,7 +332,10 @@
             width: 150,
             prop: 'paymentRatio',
             label: '比例',
-            align: 'center'
+            align: 'center',
+            formatter: (row) => {
+              return row.paymentRatio ? row.paymentRatio + '%' : ''
+            }
           },
           {
             width: 170,
@@ -355,7 +358,7 @@
           {
             width: 160,
             prop: 'invoiceAmount',
-            label: '开票金额',
+            label: '本次开票金额',
             align: 'center',
             // slot: 'invoiceAmount',
             fixed: 'right'

+ 130 - 22
src/views/bpm/handleTask/components/financialManage/invoiceManage/components/tableInfoNew.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <el-tabs type="border-card">
+    <!-- <el-tabs type="border-card">
       <el-tab-pane :label="item.key" v-for="(item, idx) in tableForm.detailList" :key="idx">
         <el-form :ref="'form' + idx" :model="tableForm">
           <ele-pro-table
@@ -76,8 +76,80 @@
           </ele-pro-table>
         </el-form>
       </el-tab-pane>
-    </el-tabs>
-    
+    </el-tabs> -->
+    <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>本次开票合计:{{ totalAmountTotalPrice }}</span>
+        </template>
+        
+        <template v-slot:invoiceAmount="scope">
+        <el-form-item
+          style="width: 100%;"
+          :prop="'detailList.' + scope.$index + '.invoiceAmount'"
+          :rules="[
+            {
+              required: true,
+              message: '请输入开票金额',
+              trigger: 'blur'
+            },
+            {
+              validator: (rule, value, callback) => {
+                if (value === undefined || value === null || value === '') {
+                  callback('请输入开票金额');
+                } else if (parseFloat(value) < 0 || parseFloat(value) > scope.row.defaultAmountTotalPrice) {
+                  callback('开票金额不能小于0且小于等于本次开票合计');  
+                } else {
+                  callback();
+                }
+              },
+              trigger: 'blur'
+            }
+          ]"
+        > 
+          <span v-if="dialogType === 'view'"> {{ scope.row.invoiceAmount }}</span>
+          <el-input v-else v-model="scope.row.invoiceAmount" type="number" @input="(val) => invoiceAmountChange(val, scope.row, scope.$index)"></el-input>
+        </el-form-item>
+      </template>
+
+      <template v-slot:taxRate="scope">
+        <el-form-item
+          style="width: 100%;"
+          :prop="'detailList.' + scope.$index + '.taxRate'"
+          :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'
+            }
+          ]"
+        > 
+          <span v-if="dialogType === 'view'"> {{ scope.row.taxRate }}</span>
+          <el-input v-else v-model="scope.row.taxRate" type="number" @input="getNotaxSinglePrice(scope.row, 0, scope.$index)" style="width: 80%;"></el-input>%
+        </el-form-item>
+      </template>
+
+      </ele-pro-table>
+    </el-form>
   </div>
 </template>
 <script>
@@ -192,8 +264,8 @@
           {
             minWidth: 150,
             prop: 'invoiceAmount',
-            label: '开票金额',
-            slot: 'invoiceAmount',
+            label: '本次开票金额',
+            // slot: 'invoiceAmount',
             align: 'center'
           },
           {
@@ -207,12 +279,12 @@
             prop: 'taxRate',
             label: '税率',
             align: 'center',
-            slot: 'taxRate',
-            // formatter: (_row, _column, cellValue) => {
-            //   return _row.taxRate
-            //     ? _row.taxRate+'%'
-            //     : '';
-            // },
+            // slot: 'taxRate',
+            formatter: (_row, _column, cellValue) => {
+              return _row.taxRate
+                ? _row.taxRate+'%'
+                : '';
+            },
           },
           {
             minWidth: 100,
@@ -338,15 +410,48 @@
   },
     methods: {
       convertToArrayFormat(data) {
-          return Object.keys(data.productMap).map(key => {
-            console.log('key', key);
-              const paymentItem = data.receiptPayments?.filter(item => item?.relatedOrderNo == key)|| [];
-              return {
-                  key: key,
-                  amountTotalPrice: paymentItem.length ? paymentItem.reduce((acc, cur) => acc + cur.invoiceAmount, 0) : 0,
-                  details: data.productMap[key] || []
-              };
+          const result = [];
+          Object.keys(data.productMap).forEach(key => {
+            console.log('key!!!', key);
+            const paymentItem = data.receiptPayments?.filter(item => item?.relatedOrderNo == key) || [];
+            console.log('paymentItem', paymentItem);
+            const amountTotalPrice = paymentItem.length ? paymentItem.reduce((acc, cur) => acc + cur.invoiceAmount, 0) : 0;
+            const defaultAmountTotalPrice = paymentItem.length ? paymentItem.reduce((acc, cur) => acc + cur.unInvoiceAmount, 0) : 0;
+            const details = data.productMap[key] || [];
+            
+            details.forEach(detail => {
+              result.push({
+                key: key,
+                amountTotalPrice: amountTotalPrice,
+                defaultAmountTotalPrice: defaultAmountTotalPrice,
+                ...detail,
+                invoiceAmount: '',
+              });
+            });
           });
+          
+          // Allocate defaultAmountTotalPrice to invoiceAmount for each key group
+          const uniqueKeys = [...new Set(result.map(item => item.key))];
+          uniqueKeys.forEach(key => {
+            const sameKeyItems = result.filter(item => item.key === key);
+            if (sameKeyItems.length > 0) {
+              const defaultAmountTotalPrice = parseFloat(sameKeyItems[0].defaultAmountTotalPrice) || 0;
+              let remainingTotal = defaultAmountTotalPrice;
+              
+              sameKeyItems.forEach(item => {
+                if (remainingTotal <= 0) {
+                  item.invoiceAmount = 0;
+                } else {
+                  const unInvoiceAmount = parseFloat(item.unInvoiceAmount) || 0;
+                  const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
+                  item.invoiceAmount = allocateAmount.toFixed(2);
+                  remainingTotal -= allocateAmount;
+                }
+              });
+            }
+          });
+          
+          return result;
       },
       // 校验发票金额
       invoiceAmountChange(val, item, idx, index) {
@@ -425,9 +530,12 @@
         this.setSelectData(row);
       },
       putValue(data) {
-        console.log('tableInfoNew putValue', data);
-        data.detailList = this.convertToArrayFormat(data);
-        this.tableForm = data;
+        let tempData = JSON.parse(JSON.stringify(data));
+        console.log('tableInfoNew putValue', tempData);
+        tempData.detailList = this.convertToArrayFormat(tempData);
+        console.log('data.detailList', data.detailList);
+        this.tableForm = tempData;
+        console.log('tableInfoNew putValue~~~', this.tableForm);
       },
       setValue(data) {
         data.detailList = this.convertToArrayFormat(data);

+ 1 - 1
src/views/bpm/handleTask/components/purchaseOrder/detailDialog.vue

@@ -253,7 +253,7 @@
     </el-tabs>
 
     <headerTitle
-        title="款计划"
+        title="款计划"
         style="margin-top: 30px"
       ></headerTitle>
       <PaymentCollectionPlan

+ 3 - 0
src/views/bpm/handleTask/components/saleOrder/returnGoods/submit.vue

@@ -22,6 +22,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="handleAudit(1)"
         v-if="outInData.verifyStatus == 2 || !['warehouseManager'].includes(taskDefinitionKey)"
         >通过
@@ -30,6 +31,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="storemanApprove"
         v-if="
           (['storemanApprove'].includes(taskDefinitionKey) &&
@@ -42,6 +44,7 @@
         icon="el-icon-circle-close"
         type="danger"
         size="mini"
+        v-click-once
         @click="handleAudit(0)"
         v-if="
           !((['starter'].includes(taskDefinitionKey) &&

+ 3 - 0
src/views/bpm/handleTask/components/saleOrder/saleReturnGoods/submit.vue

@@ -22,6 +22,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="handleAudit(1)"
         v-if="taskDefinitionKey != 'storemanApprove'"
         >通过
@@ -30,6 +31,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="storemanApprove"
         v-if="
           taskDefinitionKey == 'storemanApprove' && activeComp == 'inoutBound'
@@ -40,6 +42,7 @@
         icon="el-icon-circle-close"
         type="danger"
         size="mini"
+        v-click-once
         @click="approveTaskWithVariables(0)"
         v-if="
           !['starter'].includes(taskDefinitionKey) &&

+ 3 - 0
src/views/bpm/handleTask/components/salesServiceManagement/recycle/submit.vue

@@ -22,6 +22,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="handleAudit(1)"
         v-if="taskDefinitionKey != 'storemanApprove'"
         >通过
@@ -30,6 +31,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="storemanApprove"
         v-if="taskDefinitionKey == 'storemanApprove'"
         >申请入库
@@ -38,6 +40,7 @@
         icon="el-icon-circle-close"
         type="danger"
         size="mini"
+        v-click-once
         @click="approveTaskWithVariables(0)"
         >驳回
       </el-button>

+ 3 - 0
src/views/bpm/handleTask/components/salesServiceManagement/return/submit.vue

@@ -22,6 +22,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="handleAudit(1)"
         v-if="taskDefinitionKey != 'storemanApprove'"
         >通过
@@ -30,6 +31,7 @@
         icon="el-icon-edit-outline"
         type="success"
         size="mini"
+        v-click-once
         @click="storemanApprove"
         v-if="taskDefinitionKey == 'storemanApprove'"
         >申请入库
@@ -38,6 +40,7 @@
         icon="el-icon-circle-close"
         type="danger"
         size="mini"
+        v-click-once
         @click="approveTaskWithVariables(0)"
         >驳回
       </el-button>