whj 1 rok temu
rodzic
commit
7c49f011d1

+ 36 - 17
src/views/purchase/purchase-order-page/modules/BaseForm.vue

@@ -223,12 +223,19 @@
         :columns="columns"
         tableLayout="auto"
         rowKey="id"
+        :scroll="{ x: 1500 }"
       >
-        <template slot="ftaxprice" slot-scope="text, record">
-          <a-input-number v-model="record.ftaxprice" :step="0.0001" />
+        <template slot="iexchrate" slot-scope="text, record">
+          <a-input-number v-model="record.iexchrate" :step="0.01" />
+        </template>
+        <template slot="funitprice" slot-scope="text, record" >
+          <a-input-number v-model="record.funitprice" :step="0.0001" @blur="computeTax(record,1)" />
+        </template>
+        <template slot="fmoney" slot-scope="text, record">
+          <a-input-number v-model="record.fmoney" :step="0.01" @blur="computeTax(record,2)" />
         </template>
         <template slot="num" slot-scope="text, record">
-          <a-input-number v-model="record.num" />
+          <a-input-number v-model="record.num" :min="1" @blur="computeTax(record,1)" />
         </template>
         <template slot="ipertaxrate" slot-scope="text, record">
           <a-input-number
@@ -323,10 +330,16 @@ export default {
           scopedSlots: { customRender: 'cbmemo' }
         },
         {
-          title: '单价',
-          dataIndex: 'ftaxprice',
+          title: '汇率',
+          dataIndex: 'iexchrate',
+          width: 150,
+          scopedSlots: { customRender: 'iexchrate' }
+        },
+        {
+          title: '本币无税单价',
+          dataIndex: 'funitprice',
           width: 150,
-          scopedSlots: { customRender: 'ftaxprice' }
+          scopedSlots: { customRender: 'funitprice' }
         },
         {
           title: '申请数量',
@@ -341,13 +354,11 @@ export default {
           scopedSlots: { customRender: 'ipertaxrate' }
         },
         {
-          title: '价税合计',
-          dataIndex: 'iorisum',
+          title: '本币价税合计',
+          dataIndex: 'fmoney',
           width: 150,
-          customRender: (text, record, index) => {
-            record.iorisum = this.computeTax(record.ftaxprice, record.num, record.ipertaxrate)
-            return record.iorisum
-          }
+          scopedSlots: { customRender: 'fmoney' }
+
         },
         {
           title: '操作',
@@ -387,9 +398,16 @@ export default {
     this.soMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SO_TYPE)
   },
   methods: {
-    computeTax (ftaxprice, num, ipertaxrate) {
-      const data = (ftaxprice * [num * (1 + ipertaxrate * 0.01)]).toFixed(2)
-      return isNaN(data) ? 0 : data
+    computeTax (record, type) {
+      if (type === 1) {
+        console.log(record)
+        const data = (record.funitprice * record.num).toFixed(2)
+        record.fmoney = isNaN(data) ? 0 : data
+      } else {
+        const data = (record.fmoney / record.num).toFixed(2)
+        record.funitprice = isNaN(data) ? 0 : data
+      }
+      this.$forceUpdate()
     },
     disabledDate (current) {
       // Can not select days before today and today
@@ -474,11 +492,11 @@ export default {
         values.needDate = values.needDate ? this.BaseTool.Date.formatter(values.needDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
         values.planGetDate = values.planGetDate ? this.BaseTool.Date.formatter(values.planGetDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
         values.detailDTOS = this.data.map(item => {
-          if (!item.ftaxprice) {
+          if (!item.funitprice) {
             status++
             this.$message.error('请填写' + item.spareName + '单价')
           }
-          item.ftaxprice = (+item.ftaxprice).toFixed(4)
+          item.funitprice = (+item.funitprice).toFixed(4)
           item.ipertaxrate = (+item.ipertaxrate).toFixed(2)
           return item
         })
@@ -520,6 +538,7 @@ export default {
           const selectData = this.BaseTool.Object.copy(rows[i])
           selectData.storeNum = selectData.num
           selectData.num = 1
+          selectData.iexchrate = 1
           selectData.ipertaxrate = 13
           data.push(selectData)
         }