Forráskód Böngészése

采购单 上次缺货功能

chenrui 3 éve
szülő
commit
fd54d2efc4

+ 20 - 1
src/api/purchaseDetail.js

@@ -51,4 +51,23 @@ export const purchaseUpdateWarehouse = (params) => {
     data: params,
     data: params,
     method: 'post'
     method: 'post'
   })
   })
-}
+}
+//  采购 详情 上次缺货 列表 分页
+export const purchaseDetailCancelList = (params) => {
+  const url = `/purchaseDetail/queryCancelPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  采购 详情 上次缺货 列表 分页
+export const purchaseDetailCancelSave = (params) => {
+  return axios({
+    url: '/purchaseDetail/saveCancelProduct',
+    data: params,
+    method: 'post'
+  })
+}

+ 45 - 46
src/views/purchasingManagement/purchaseOrder/edit.vue

@@ -109,7 +109,7 @@
                 :rowKey="(record) => record.id"
                 :rowKey="(record) => record.id"
                 :columns="columns"
                 :columns="columns"
                 :data="loadData"
                 :data="loadData"
-                :scroll="{ x: 1190, y:300 }"
+                :scroll="{ x: 950, y:300 }"
                 :defaultLoadData="false"
                 :defaultLoadData="false"
                 bordered>
                 bordered>
                 <!-- 采购数量 -->
                 <!-- 采购数量 -->
@@ -142,11 +142,7 @@
       <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
       <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
         <a-collapse :activeKey="['1']">
         <a-collapse :activeKey="['1']">
           <a-collapse-panel key="1">
           <a-collapse-panel key="1">
-            <template slot="header">
-              已选产品
-              <!-- <a-button size="small" class="import-btn" id="purchaseOrderEdit-import-btn" @click.stop="handleImport">导入明细</a-button> -->
-            </template>
-            <!-- 已选产品 -->
+            <template slot="header">已选产品</template>
             <div>
             <div>
               <!-- 总计 -->
               <!-- 总计 -->
               <a-alert type="info" style="margin-bottom:10px">
               <a-alert type="info" style="margin-bottom:10px">
@@ -181,6 +177,7 @@
                   </a-col>
                   </a-col>
                   <a-col :span="6">
                   <a-col :span="6">
                     <div style="float:right;overflow: hidden;">
                     <div style="float:right;overflow: hidden;">
+                      <a-button size="small" type="primary" class="button-info" id="purchaseOrderEdit-import-btn" @click="handleOutStock">上次缺货</a-button>
                       <a-button size="small" id="purchaseOrderEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
                       <a-button size="small" id="purchaseOrderEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
                     </div>
                     </div>
                   </a-col>
                   </a-col>
@@ -194,7 +191,7 @@
                 :rowKey="(record) => record.id"
                 :rowKey="(record) => record.id"
                 :columns="chooseColumns"
                 :columns="chooseColumns"
                 :data="chooseLoadData"
                 :data="chooseLoadData"
-                :scroll="{ x: 1070, y: 300 }"
+                :scroll="{ x: 830, y: 300 }"
                 bordered>
                 bordered>
                 <!-- 采购数量 -->
                 <!-- 采购数量 -->
                 <template slot="storageQuantity" slot-scope="text, record">
                 <template slot="storageQuantity" slot-scope="text, record">
@@ -235,10 +232,10 @@
         @click="handleSubmit"
         @click="handleSubmit"
         style="padding: 0 60px;">提交</a-button>
         style="padding: 0 60px;">提交</a-button>
     </div>
     </div>
-    <!-- 选择基本信息弹框 -->
-    <basic-info-modal ref="baseInfo" :openModal="openModal" @ok="handleOk" @cancel="openModal=false" />
     <!-- 导入产品 -->
     <!-- 导入产品 -->
     <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
     <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
+    <!-- 上次缺货 -->
+    <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
     <!-- 打印 -->
     <!-- 打印 -->
     <div id="print"></div>
     <div id="print"></div>
   </div>
   </div>
@@ -247,19 +244,18 @@
 <script>
 <script>
 import moment from 'moment'
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
-import basicInfoModal from './basicInfoModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
 import ImportGuideModal from './importGuideModal.vue'
+import outStockModal from './outStockModal.vue'
 import ProductType from '../../common/productType.js'
 import ProductType from '../../common/productType.js'
 import ProductBrand from '../../common/productBrand.js'
 import ProductBrand from '../../common/productBrand.js'
 import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseDetailBatchInsert, purchaseDetailExport } from '@/api/purchase'
 import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseDetailBatchInsert, purchaseDetailExport } from '@/api/purchase'
-import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount } from '@/api/purchaseDetail'
+import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
 import { productListPurchase } from '@/api/product'
 import { productListPurchase } from '@/api/product'
 export default {
 export default {
-  components: { STable, VSelect, basicInfoModal, ProductType, ProductBrand, ImportGuideModal },
+  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal },
   data () {
   data () {
     return {
     return {
       spinning: false,
       spinning: false,
-      openModal: false, // 选择基本信息弹框是否显示
       detail: null, // 详细信息
       detail: null, // 详细信息
       subLoading: false,
       subLoading: false,
       // 选择产品
       // 选择产品
@@ -277,14 +273,14 @@ export default {
       disabled: false, //  查询、重置按钮是否可操作
       disabled: false, //  查询、重置按钮是否可操作
       // 表头
       // 表头
       columns: [
       columns: [
-        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
+        { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
+        { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' }, sorter: true },
         { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '原厂编码', dataIndex: 'origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '箱/单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '采购单价', dataIndex: 'purchasePrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? ('¥' + text) : '--') }, fixed: 'right' },
-        { title: '采购数量', dataIndex: 'qty', scopedSlots: { customRender: 'storageQuantity' }, width: 150, align: 'center', fixed: 'right' },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
+        { title: '原厂编码', dataIndex: 'origCode', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '箱/单位', dataIndex: 'unit', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '采购单价', dataIndex: 'purchasePrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') }, fixed: 'right' },
+        { title: '采购数量', dataIndex: 'qty', scopedSlots: { customRender: 'storageQuantity' }, width: 100, align: 'center', fixed: 'right' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
       ],
       ],
       // 加载数据方法 必须为 Promise 对象
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
       loadData: parameter => {
@@ -310,14 +306,14 @@ export default {
       purchaseDisabled: false, //  查询、重置按钮是否可操作
       purchaseDisabled: false, //  查询、重置按钮是否可操作
       // 表头
       // 表头
       chooseColumns: [
       chooseColumns: [
-        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 220, align: 'center', sorter: true },
+        { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
+        { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 180, align: 'center', sorter: true },
         { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '采购单价', dataIndex: 'discountedPrice', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
-        { title: '采购数量', scopedSlots: { customRender: 'storageQuantity' }, width: 150, align: 'center' },
-        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '采购金额', dataIndex: 'discountedAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
+        { title: '采购单价', dataIndex: 'discountedPrice', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '采购数量', scopedSlots: { customRender: 'storageQuantity' }, width: 100, align: 'center' },
+        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '采购金额', dataIndex: 'discountedAmount', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
       ],
       ],
       // 加载数据方法 必须为 Promise 对象
       // 加载数据方法 必须为 Promise 对象
       chooseLoadData: parameter => {
       chooseLoadData: parameter => {
@@ -339,7 +335,9 @@ export default {
       },
       },
       localDataSource: [],
       localDataSource: [],
       printerType: 'NEEDLE', //  打印机类型
       printerType: 'NEEDLE', //  打印机类型
-      openGuideModal: false //  导入产品引导
+      openGuideModal: false, //  导入产品引导
+      openOutStockModal: false,
+      paramsData: null
     }
     }
   },
   },
   methods: {
   methods: {
@@ -357,17 +355,6 @@ export default {
         }
         }
       })
       })
     },
     },
-    //  基本信息编辑成功
-    handleOk (data) {
-      this.openModal = false
-      this.getOrderDetail()
-    },
-    //  编辑基本信息
-    handleEditInfo () {
-      this.openModal = true
-      this.$refs.baseInfo.setData(this.detail)
-    },
-    // ---已选产品-----
     // 删除产品
     // 删除产品
     handleDel (row) {
     handleDel (row) {
       const _this = this
       const _this = this
@@ -405,11 +392,6 @@ export default {
         this.handleAdd(record, 1)
         this.handleAdd(record, 1)
       }
       }
     },
     },
-    //  导入明细
-    handleImport () {
-      console.log(333)
-    },
-    // ---------产品库--------
     filterOption (input, option) {
     filterOption (input, option) {
       return (
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
@@ -473,7 +455,6 @@ export default {
         this.addLoading = false
         this.addLoading = false
       })
       })
     },
     },
-    // ------------产品库 end --------
     //  提交
     //  提交
     handleSubmit () {
     handleSubmit () {
       const _this = this
       const _this = this
@@ -500,6 +481,25 @@ export default {
         }
         }
       })
       })
     },
     },
+    // 上次缺货
+    handleOutStock () {
+      // 校验是否存在历史采购单,且上次采购存在缺货产品
+      purchaseDetailCancelList({ pageNo: 1, pageSize: 5 }).then(res => {
+        if (res.status == 200) {
+          this.paramsData = {
+            purchaseBillSn: this.$route.params.sn,
+            purchaseBillNo: this.detail && this.detail.purchaseBillNo ? this.detail.purchaseBillNo : undefined
+          }
+          this.openOutStockModal = true
+        }
+      })
+    },
+    // 上次缺货 导入成功
+    hanldeOkOutStock () {
+      this.$refs.purchaseTable.refresh(true)
+      this.paramsData = null
+      this.openOutStockModal = false
+    },
     // 打印预览/快捷打印
     // 打印预览/快捷打印
     handlePrint (type) {
     handlePrint (type) {
       const _this = this
       const _this = this
@@ -563,7 +563,6 @@ export default {
   },
   },
   beforeRouteEnter (to, from, next) {
   beforeRouteEnter (to, from, next) {
     next(vm => {
     next(vm => {
-      vm.openModal = false
       vm.getOrderDetail()
       vm.getOrderDetail()
     })
     })
   }
   }

+ 244 - 0
src/views/purchasingManagement/purchaseOrder/outStockModal.vue

@@ -0,0 +1,244 @@
+<template>
+  <a-modal
+    centered
+    class="outStock-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="上次采购缺货产品明细"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="800">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <div class="outStock-con">
+        <div>
+          <p style="font-weight: bold;">当前已选:{{ selectedRowKeys.length }}个</p>
+          <!-- 列表 -->
+          <s-table
+            class="sTable"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.productSn"
+            :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onChange, onSelect: onSelectChange, onSelectAll: onSelectAllChange }"
+            :data="loadData"
+            :columns="columns"
+            :scroll="{ y: 450 }"
+            bordered>
+          </s-table>
+        </div>
+        <!-- 按钮 -->
+        <div class="btn-con">
+          <a-button
+            type="primary"
+            id="outStock-save"
+            size="large"
+            class="button-primary"
+            @click="handleSave"
+            style="padding: 0 36px;">加入本次采购</a-button>
+          <a-button
+            id="outStock-cancel"
+            size="large"
+            class="button-cancel"
+            @click="isShow=false"
+            style="padding: 0 60px;margin-left: 15px;">取消</a-button>
+        </div>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { STable } from '@/components'
+import { purchaseDetailCancelList, purchaseDetailCancelSave } from '@/api/purchaseDetail'
+export default {
+  name: 'OutStockModal',
+  components: { STable },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    paramsData: {
+      type: Object,
+      default: () => {
+        return {}
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 20 }
+      },
+      disabled: false, //  查询、重置按钮是否可操作
+      columns: [
+        { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '上次采购数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '上次缺货数量', dataIndex: 'cancelQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        return purchaseDetailCancelList(parameter).then(res => {
+          const data = res.data
+          this.disabled = false
+          return data
+        })
+      },
+      selectedRowKeys: [],
+      selectedRows: [],
+      spinning: false
+    }
+  },
+  methods: {
+    // 保存
+    handleSave () {
+      const _this = this
+      if (this.selectedRowKeys.length < 1) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      const params = {
+        confirm: false,
+        purchaseBillSn: this.paramsData.purchaseBillSn,
+        purchaseBillNo: this.paramsData.purchaseBillNo,
+        purchaseBillDetailEntityList: this.selectedRows
+      }
+      purchaseDetailCancelSave(params).then(res => {
+        if (res.status == 200 && res.data) {
+          let content = ''
+          if ((res.data.productSizeRepeat != res.data.productSize) && (res.data.productSizeRepeat != 0)) {
+            content = `您已经选择 ${res.data.productSize} 个产品,其中 ${res.data.productSizeRepeat} 个产品已经存在于采购单中。本次只会加入不重复的产品,上次缺货数量将作为本次采购数量。确认加入本次采购吗?`
+            this.confirmFun(content)
+          } else if (res.data.productSizeRepeat == res.data.productSize) {
+            content = `抱歉,您选择的 ${res.data.productSize} 个产品,采购单中已经全部存在,无需加入!`
+            this.$info({
+              title: '提示',
+              content: content,
+              okText: '好的',
+              centered: true,
+              onOk () {
+                _this.selectedRowKeys = []
+                _this.selectedRows = []
+              }
+            })
+          } else {
+            content = `您已经选择 ${res.data.productSize} 个产品,上次缺货数量将作为本次采购数量。确认加入本次采购吗?`
+            this.confirmFun(content)
+          }
+        }
+      })
+    },
+    confirmFun (content) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: content,
+        okText: '确认加入',
+        cancelText: '重新选择',
+        centered: true,
+        closable: true,
+        onOk () {
+          _this.spinning = true
+          const params = {
+            confirm: true,
+            purchaseBillSn: _this.paramsData.purchaseBillSn,
+            purchaseBillNo: _this.paramsData.purchaseBillNo,
+            purchaseBillDetailEntityList: _this.selectedRows
+          }
+          purchaseDetailCancelSave(params).then(res => {
+            if (res.status == 200) {
+              _this.$emit('ok')
+              _this.isShow = false
+              _this.spinning = false
+            } else {
+              _this.spinning = false
+            }
+          })
+        },
+        onCancel () {
+          _this.selectedRowKeys = []
+          _this.selectedRows = []
+        }
+      })
+    },
+    onChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+    },
+    onSelectChange (record, selected, selectedRows, nativeEvent) {
+      const _this = this
+      if (selected) { //  选择
+        this.selectedRows.push(record)
+      } else { //  取消
+        const arrId = []
+        this.selectedRows.map((item, index) => {
+          if (item.productSn == record.productSn) {
+            arrId.push(index)
+          }
+        })
+        arrId.map((item, index) => {
+          _this.selectedRows = _this.selectedRows.slice(item, item + 1)
+        })
+      }
+    },
+    // 本页全选/取消全选
+    onSelectAllChange (selected, selectedRows, changeRows) {
+      const _this = this
+      if (this.type != 'supplier') { //  供应商增加产品
+        if (selected) { //  选择
+          this.selectedRows = [...this.selectedRows, ...changeRows]
+        } else { //  取消
+          const arrId = []
+          this.selectedRows.map((item, index) => {
+            this.selectedRows.map((subItem, ind) => {
+              if (item.productSn == subItem.productSn) {
+                arrId.push(index)
+              }
+            })
+          })
+          arrId.map((item, index) => {
+            _this.selectedRows = _this.selectedRows.slice(item, item + 1)
+          })
+        }
+      }
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.selectedRowKeys = []
+        this.selectedRows = []
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .outStock-modal{
+    .outStock-con{
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>