Parcourir la source

设置成本价

lilei il y a 3 ans
Parent
commit
f6b8d02699

+ 18 - 0
src/api/checkWarehouse.js

@@ -19,6 +19,24 @@ export const checkWarehouseSave = (params) => {
     method: 'post'
   })
 }
+
+// 查询没有成本价的产品
+export const queryStockProductCostNull = (params) => {
+  return axios({
+    url: '/checkWarehouse/queryStockProductCostNull',
+    data: params,
+    method: 'post'
+  })
+}
+// 设置成本价
+export const stockWarnSaveBatch = (params) => {
+  return axios({
+    url: '/stockWarn/saveBatch',
+    data: params,
+    method: 'post'
+  })
+}
+
 //  库存盘点  校验是否有未完结的盘点单
 export const checkWarehouseValidate = (params) => {
   return axios({

+ 18 - 8
src/views/financialManagement/inventoryCheckAudit/list.vue

@@ -56,7 +56,7 @@
             v-if="record.state=='WAIT_FINANCE_AUDIT' && $hasPermissions('B_inventoryCheckAuditAudit')"
             type="link"
             class="button-primary"
-            @click="handleExamine(record, true)"
+            @click="handleOk(record, true)"
             id="warehousingAudit-adopt-btn">通过</a-button>
           <a-button
             size="small"
@@ -72,7 +72,7 @@
     <!-- 详情 -->
     <inventoryChecking-detail-modal :openModal="openDetailModal" :itemSn="itemSn" @close="handleDetailClose" />
     <!-- 设置成本价 -->
-    <setPriceModal ref="setPriceModal" :openModal="openCostPriceModal" @close="openCostPriceModal=false"></setPriceModal>
+    <setPriceModal ref="setPriceModal" @ok="handleOk" :openModal="openCostPriceModal" @close="openCostPriceModal=false"></setPriceModal>
   </a-card>
 </template>
 
@@ -83,7 +83,7 @@ import rangeDate from '@/views/common/rangeDate.vue'
 import stateIcon from '@/views/common/stateIcon'
 import inventoryCheckingDetailModal from '@/views/inventoryManagement/inventoryChecking/detailModal.vue'
 import setPriceModal from './setPriceModal.vue'
-import { checkWarehouseAuditList, checkWarehouseFinanceAudit, checkWarehouseReInventory } from '@/api/checkWarehouse'
+import { checkWarehouseAuditList, checkWarehouseFinanceAudit, checkWarehouseReInventory, queryStockProductCostNull } from '@/api/checkWarehouse'
 export default {
   name: 'InventoryCheckingList',
   components: { STable, VSelect, rangeDate, inventoryCheckingDetailModal, stateIcon, setPriceModal },
@@ -135,7 +135,7 @@ export default {
       },
       productTotal: null,
       openDetailModal: false,
-      openCostPriceModal: true,
+      openCostPriceModal: false,
       itemSn: null
     }
   },
@@ -154,6 +154,18 @@ export default {
       this.itemSn = null
       this.openDetailModal = false
     },
+    handleOk (row, type) {
+      queryStockProductCostNull({ checkWarehouseSn: row.checkWarehouseSn }).then(res => {
+        console.log(res)
+        // 设置成本价
+        if (res.data.length) {
+          // 如果有盈亏的产品,没有最近一次入库成本价,需要设置成本价
+          this.setCostPrice(res.data, row)
+        } else {
+          this.handleExamine(row, type)
+        }
+      })
+    },
     //  审核
     handleExamine (row, type) {
       const _this = this
@@ -168,8 +180,6 @@ export default {
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
               _this.spinning = false
-              // 如果有盈亏的产品,没有最近一次入库成本价,需要设置成本价
-              _this.setCostPrice(res.data)
             } else {
               _this.spinning = false
             }
@@ -178,10 +188,10 @@ export default {
       })
     },
     // 设置成本价
-    setCostPrice (data) {
+    setCostPrice (data, row) {
       this.openCostPriceModal = true
       this.$nextTick(() => {
-        this.$refs.setPriceModal.setData(data)
+        this.$refs.setPriceModal.setData(data, row)
       })
     },
     // 重盘

+ 20 - 12
src/views/financialManagement/inventoryCheckAudit/setPriceModal.vue

@@ -18,7 +18,7 @@
           class="sTable fixPagination"
           ref="table"
           size="small"
-          :rowKey="(record) => record.id"
+          :rowKey="(record,index) => record.id +'-'+ index"
           :columns="columns"
           :data-source="list"
           :scroll="{ y:400 }"
@@ -28,8 +28,8 @@
             <a-input-number
               style="width: 100%;"
               size="small"
-              v-model="record.costPrice"
-              :precision="0"
+              v-model="record.lastStockCost"
+              :precision="2"
               :min="0"
               :max="999999"
               placeholder="请输入成本价"
@@ -47,6 +47,7 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
+import { stockWarnSaveBatch } from '@/api/checkWarehouse'
 export default {
   name: 'SettleModal',
   components: {},
@@ -66,11 +67,8 @@ export default {
       spinning: false,
       confirmLoading: false,
       isShow: this.openModal, //  是否打开弹框
-      list: [
-        { productCode: '12323-2344', productName: '撒地方就了啊手动阀' },
-        { productCode: 'A-sdf', productName: '反对敢死队风格' },
-        { productCode: '1bb-2344', productName: '撒打发稍等' }
-      ],
+      row: null,
+      list: [],
       // 表头
       columns: [
         { title: '产品编码', dataIndex: 'productCode', width: '30%', align: 'center', customRender: function (text) { return ((text || text != ' ') ? text : '--') } },
@@ -83,20 +81,30 @@ export default {
     //  保存
     handleSubmit (e) {
       const _this = this
-      const hasEmpty = this.list.filter(item => !item.costPrice && item.costPrice != 0)
+      const hasEmpty = this.list.filter(item => !item.lastStockCost && item.lastStockCost != 0)
       if (hasEmpty.length) {
         this.$message.info('成本价不能为空!')
         return
       }
-      _this.isShow = false
-      _this.$emit('ok', this.list)
+      const params = []
+      this.list.map(item => {
+        params.push({
+          'id': item.id,
+          'lastStockCost': item.lastStockCost
+        })
+      })
+      stockWarnSaveBatch(params).then(res => {
+        _this.isShow = false
+        _this.$emit('ok', _this.row, true)
+      })
     },
     cancel () {
       this.isShow = false
     },
     // 编辑信息
-    setData (data) {
+    setData (data, row) {
       this.list = data
+      this.row = row
     }
   },
   watch: {

+ 1 - 1
src/views/inventoryManagement/inventoryChecking/selfDisk.vue

@@ -90,7 +90,7 @@
           class="sTable"
           ref="table"
           size="small"
-          :rowKey="(record) => record.productSn"
+          :rowKey="(record,index) => record.productSn +'-'+ index"
           rowKeyName="productSn"
           :row-selection="{ columnWidth: 40 }"
           @rowSelection="rowSelectionFun"