ソースを参照

销售退货 退货单价可编辑

chenrui 3 年 前
コミット
0a8ea3c93a

+ 33 - 6
src/views/salesManagement/salesReturn/salesReturnEdit.vue

@@ -49,7 +49,20 @@
               :min="0"
               :max="999999"
               placeholder="请输入"
-              @blur="e => onCellBlur(e.target.value, record)"
+              @blur="e => onCellBlur(e.target.value, record, 'qty')"
+              style="width: 100%;" />
+          </template>
+          <!-- 退货单价 -->
+          <template slot="price" slot-scope="text, record">
+            <a-input-number
+              id="salesReturn-price"
+              size="small"
+              v-model="record.price"
+              :precision="2"
+              :min="0"
+              :max="999999"
+              placeholder="请输入"
+              @blur="e => onCellBlur(e.target.value, record, 'price')"
               style="width: 100%;" />
           </template>
           <!-- 退货原因 -->
@@ -123,7 +136,7 @@ export default {
         { title: '产品编码', dataIndex: 'productEntity.code', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '退货数量', dataIndex: 'qty', align: 'center', width: 100, scopedSlots: { customRender: 'qty' } },
-        { title: '退货单价', dataIndex: 'price', align: 'center', width: 80, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货单价', dataIndex: 'price', align: 'center', width: 80, scopedSlots: { customRender: 'price' } },
         { title: '单位', dataIndex: 'productEntity.unit', align: 'center', width: 60, customRender: function (text) { return text || '--' } },
         { title: '退货小计', align: 'center', dataIndex: 'totalAmount', width: 80, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '退货原因', dataIndex: 'remark', align: 'center', width: 200, scopedSlots: { customRender: 'remark' } },
@@ -141,6 +154,7 @@ export default {
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
             data.list[i].qtyBackups = data.list[i].qty
+            data.list[i].priceBackups = data.list[i].price
           }
           this.disabled = false
           this.chooseLoadData = data.list
@@ -155,13 +169,22 @@ export default {
       this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
     },
     // 已选产品  blur
-    onCellBlur (val, record) {
+    onCellBlur (val, record, type) {
+      let valBackups
+      if (type) {
+        if (type == 'qty') {
+          valBackups = record.qtyBackups
+        } else if (type == 'price') {
+          valBackups = record.priceBackups
+        }
+      }
       //  光标移出,值发生改变再调用编辑接口
-      if (val && val != record.qtyBackups) {
+      if (val && val != valBackups) {
         this.spinning = true
         salesReturnDetailUpdateQty({
           salesReturnDetailSn: record.salesReturnDetailSn,
-          qty: record.qty
+          qty: record.qty,
+          price: record.price
         }).then(res => {
           if (res.status == 200) {
             this.resetSearchForm(true)
@@ -172,7 +195,11 @@ export default {
           }
         })
       } else {
-        record.qty = record.qtyBackups
+        if (type == 'qty') {
+          record.qty = valBackups
+        } else if (type == 'price') {
+          record.price = valBackups
+        }
       }
     },
     // 修改退货原因

+ 48 - 16
src/views/salesManagement/salesReturn/salesReturnGrabEdit.vue

@@ -35,7 +35,7 @@
           :rowKey="(record) => record.id"
           :columns="columns"
           :data="loadData"
-          :scroll="{ x: 1130, y: 300 }"
+          :scroll="{ x: 1270, y: 300 }"
           bordered>
           <!-- 本次退货数量 -->
           <template slot="qty" slot-scope="text, record">
@@ -47,7 +47,20 @@
               :min="0"
               :max="999999"
               placeholder="请输入"
-              @blur="e => onCellBlur(e.target.value, record)"
+              @blur="e => onCellBlur(e.target.value, record, 'qty')"
+              style="width: 100%;" />
+          </template>
+          <!-- 退货单价 -->
+          <template slot="price" slot-scope="text, record">
+            <a-input-number
+              id="salesReturn-price"
+              size="small"
+              v-model="record.price"
+              :precision="2"
+              :min="0"
+              :max="999999"
+              placeholder="请输入"
+              @blur="e => onCellBlur(e.target.value, record, 'price')"
               style="width: 100%;" />
           </template>
           <!-- 退货原因 -->
@@ -118,12 +131,12 @@ export default {
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', align: 'center', width: 70 },
-        { title: '采购单号', dataIndex: 'purchaseBillNo', align: 'center', width: 120, customRender: function (text) { return text || '--' } },
+        { title: '采购单号', dataIndex: 'purchaseBillNo', align: 'center', width: 180, customRender: function (text) { return text || '--' } },
         { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '产品名称', dataIndex: 'productEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '剩余可退数量', dataIndex: 'refundableQty', align: 'center', width: 100, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '本次退货数量', dataIndex: 'qty', align: 'center', width: 100, scopedSlots: { customRender: 'qty' } },
-        { title: '退货单价', dataIndex: 'price', align: 'center', width: 80, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货单价', dataIndex: 'price', align: 'center', width: 100, scopedSlots: { customRender: 'price' } },
         { title: '单位', dataIndex: 'productEntity.unit', align: 'center', width: 60, customRender: function (text) { return text || '--' } },
         { title: '退货小计', align: 'center', width: 80, dataIndex: 'totalAmount', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '退货原因', dataIndex: 'remark', align: 'center', width: 200, scopedSlots: { customRender: 'remark' } },
@@ -141,6 +154,7 @@ export default {
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
             data.list[i].qtyBackups = data.list[i].qty
+            data.list[i].priceBackups = data.list[i].price
           }
           this.disabled = false
           this.chooseLoadData = data.list
@@ -155,29 +169,47 @@ export default {
       this.$router.push({ path: '/salesManagement/salesReturn/list', query: { closeLastOldTab: true } })
     },
     // 已选产品  blur
-    onCellBlur (val, record) {
+    onCellBlur (val, record, type) {
+      let valBackups
+      if (type) {
+        if (type == 'qty') {
+          valBackups = record.qtyBackups
+        } else if (type == 'price') {
+          valBackups = record.priceBackups
+        }
+      }
       //  光标移出,值发生改变再调用编辑接口
-      if (val && val != record.qtyBackups) {
+      if (val && val != valBackups) {
         if (Number(record.qty) > Number(record.refundableQty)) {
           this.$message.info('本次退货数量不可大于剩余可退数量')
           record.qty = record.qtyBackups
+          record.price = record.priceBackups
         } else {
           this.spinning = true
-          salesReturnDetailUpdateQty({
+          const params = {
             salesReturnDetailSn: record.salesReturnDetailSn,
-            qty: record.qty
-          }).then(res => {
-            if (res.status == 200) {
-              this.resetSearchForm(true)
-              this.$message.success(res.message)
-            }
-            this.spinning = false
-          })
+            qty: record.qty,
+            price: record.price
+          }
+          this.setFun(params)
         }
       } else {
-        record.qty = record.qtyBackups
+        if (type == 'qty') {
+          record.qty = valBackups
+        } else if (type == 'price') {
+          record.price = valBackups
+        }
       }
     },
+    setFun (params) {
+      salesReturnDetailUpdateQty(params).then(res => {
+        if (res.status == 200) {
+          this.resetSearchForm(true)
+          this.$message.success(res.message)
+        }
+        this.spinning = false
+      })
+    },
     // 修改退货原因
     updateRemark (row) {
       this.spinning = true