فهرست منبع

作废流程添加开票金额列

lijt 1 سال پیش
والد
کامیت
d6d5d5a0a0
1فایلهای تغییر یافته به همراه71 افزوده شده و 3 حذف شده
  1. 71 3
      src/views/modules/cw/invoice/InvoiceFormTaskInvalid.vue

+ 71 - 3
src/views/modules/cw/invoice/InvoiceFormTaskInvalid.vue

@@ -11,6 +11,7 @@
       <el-row  :gutter="15">
         <vxe-table
           border
+          :footer-method="footerMethod2"
           show-overflow
           show-footer
           ref="baseTable"
@@ -20,9 +21,10 @@
           @cell-click=""
           @edit-closed=""
           highlight-current-row
+          :edit-rules="tableRules"
           :edit-config="{trigger: 'click', mode: 'cell', showStatus: true, autoClear: true, icon: '-'}"
         >
-          <vxe-table-column field="programName" align="center" title="项目名称" :edit-render="{}">
+          <vxe-table-column field="programName" align="center" title="项目名称555" :edit-render="{}">
             <template v-slot:edit="scope">
               <el-input @focus="openProgramPageForm(scope.$rowIndex)" placeholder="请填写项目名称" :readonly="true" v-model="scope.row.programName"/>
             </template>
@@ -37,6 +39,11 @@
               <el-input :readonly="true" placeholder="请填写项目编号" v-model="scope.row.programNo"/>
             </template>
           </vxe-table-column>
+          <vxe-table-column field="account" align="center" title="发票金额(元)" :edit-render="{}">
+            <template v-slot:edit="scope">
+              <el-input :readonly="true" placeholder="请填写发票金额" v-model="scope.row.account" @blur="scope.row.account = twoDecimalPlaces(scope.row.account)" maxlength="15"/>
+            </template>
+          </vxe-table-column>
           <!--          <vxe-table-column field="clientName" title="委托方" :edit-render="{}">-->
           <!--            <template v-slot:edit="scope">-->
           <!--              <el-input :readonly="true" placeholder="请填写委托方" v-model="scope.row.clientName"/>-->
@@ -566,6 +573,7 @@
   import WorkClientForm from '../workClientInfo/WorkClientChooseRadio'
   import SelectUserTree from '@/views/modules/utils/treeUserSelect'
   import SelectTree from '@/components/treeSelect/treeSelect.vue'
+  import XEUtils from 'xe-utils'
   export default {
     props: {
       businessId: {
@@ -583,11 +591,17 @@
     },
     data () {
       return {
+        tableRules: {
+          account: [
+            { required: true, message: '请填写发票金额' }
+          ]
+        },
         title: '',
         method: '',
         visible: false,
         loading: false,
         inputForm: {
+          actualPrice: '',
           id: '',
           financeInvoiceBaseDTOList: [],
           programName: '',
@@ -688,6 +702,7 @@
       init (method, id) {
         this.method = method
         this.inputForm = {
+          actualPrice: '',
           id: '',
           financeInvoiceBaseDTOList: [],
           programName: '',
@@ -779,7 +794,8 @@
               this.inputForm.financeInvoiceDetailDTOList.push({
                 code: '',
                 number: '',
-                account: this.inputForm.account,
+                account: this.inputForm.actualPrice,
+                // account: this.inputForm.account,
                 rate: '',
                 amount: '',
                 tax: '',
@@ -837,6 +853,7 @@
           this.loading = false
           throw new Error()
         }
+        this.inputForm.account = this.inputForm.actualPrice
         if (status === 'save') {
           // 暂存
           // this.inputForm.status = '1'
@@ -1183,7 +1200,8 @@
       // 获取发票金额,放到开票明细中第一条数据
       getTotalAccount () {
         if (!this.commonJS.isEmpty(this.inputForm.account)) {
-          this.financeInvoiceDetailDTOList.push({account: this.inputForm.account})
+          this.financeInvoiceDetailDTOList.push({account: this.inputForm.actualPrice})
+          // this.financeInvoiceDetailDTOList.push({account: this.inputForm.account})
         }
       },
       async updateStatusById (type, callback) {
@@ -1239,7 +1257,57 @@
             })
           }
         }
+      },
+    footerMethod2 ({ columns, data }) {
+      const footerData = [
+        columns.map((column, columnIndex) => {
+          if (columnIndex === 0) {
+            return '发票金额汇总(元)'
+          }
+          if (['account'].includes(column.property)) {
+            // eslint-disable-next-line no-undef
+            this.inputForm.actualPrice = XEUtils.sum(data, column.property)
+            return XEUtils.sum(data, column.property)
+          }
+          if (['actualPrice'].includes(column.property)) {
+            // eslint-disable-next-line no-undef
+            this.inputForm.actualPrice = XEUtils.sum(data, column.property)
+            return XEUtils.sum(data, column.property)
+          }
+          return null
+        })
+      ]
+      console.log('actualPrice', this.inputForm.actualPrice)
+      return footerData
+    },
+    twoDecimalPlaces (num) {
+      let str = num.toString()
+      var len1 = str.substr(0, 1)
+      var len2 = str.substr(1, 1)
+      // eslint-disable-next-line eqeqeq
+      if (str.length > 1 && len1 == 0 && len2 != '.') {
+        str = str.substr(1, 1)
       }
+      // eslint-disable-next-line eqeqeq
+      if (len1 == '.') {
+        str = ''
+      }
+      // eslint-disable-next-line eqeqeq
+      if (str.indexOf('.') != -1) {
+        var str_ = str.substr(str.indexOf('.') + 1)
+        // eslint-disable-next-line eqeqeq
+        if (str_.indexOf('.') != -1) {
+          str = str.substr(0, str.indexOf('.') + str_.indexOf('.') + 1)
+        }
+        if (str_.length > 2) {
+          this.$message.warning(`金额小数点后只能输入两位,请正确输入!`)
+          return (str = '')
+        }
+      }
+      // eslint-disable-next-line no-useless-escape
+      str = str.replace(/[^\d^\.]+/g, '') // 保留数字和小数点
+      return str
+    }
     }
   }
 </script>