chenrui 1 gadu atpakaļ
vecāks
revīzija
b369c97cb9

+ 32 - 17
src/views/purchasingManagement/purchaseOrder/edit.vue

@@ -205,7 +205,7 @@
                   </a-col>
                   <a-col :span="6">
                     <div style="float:right;overflow: hidden;">
-                      <a-button v-if="!isDealerUp" type="primary" class="button-primary" id="purchaseOrderEdit-import-btn" @click="handleOutStock">上次缺货</a-button>
+                      <a-button v-if="!isDealerUp" type="primary" class="button-primary" id="purchaseOrderEdit-import-btn" @click="handleOutStock">导入缺货</a-button>
                       <a-button id="purchaseOrderEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
                     </div>
                   </a-col>
@@ -265,9 +265,17 @@
     <!-- 导入产品 -->
     <importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOks" />
     <!-- 上次缺货 -->
-    <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
+    <outStockModal
+      ref="outStock"
+      :paramsSn="$route.params.sn"
+      :openModal="openOutStockModal"
+      :chooseData="chooseData"
+      @close="openOutStockModal=false"
+      @ok="hanldeOkOutStock" />
     <!-- 选择地址 -->
     <choose-address-modal :openModal="openAddrModal" @ok="handleAddrOk" @close="openAddrModal=false" />
+    <!-- 导入缺货 -->
+    <outStockListModal ref="outStockList" :openModal="openOutStockListModal" @close="openOutStockListModal=false" @ok="hanldeOkOutStockList"></outStockListModal>
   </div>
 </template>
 
@@ -276,18 +284,19 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import ImportGuideModal from './importGuideModal.vue'
 import outStockModal from './outStockModal.vue'
+import outStockListModal from './outStockListModal.vue'
 import chooseAddressModal from '@/views/common/receivingAddress/chooseAddressModal.vue'
 import ProductType from '../../common/productType.js'
 import ProductBrand from '../../common/productBrand.js'
 import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseDetailExport, purchaseDetailAddress } from '@/api/purchase'
-import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
+import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCancelList } from '@/api/purchaseDetail'
 import { productListPurchase } from '@/api/product'
 import defImg from '@/assets/def_img@2x.png'
 import Print from '@/views/common/print.vue'
 import { hdPrint } from '@/libs/JGPrint'
 export default {
   name: 'PurchaseEdit',
-  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print, chooseAddressModal },
+  components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print, chooseAddressModal, outStockListModal },
   mixins: [commonMixin],
   data () {
     return {
@@ -352,10 +361,12 @@ export default {
         })
       },
       localDataSource: [],
+      chooseData: [],
       openGuideModal: false, //  导入产品引导
       openOutStockModal: false,
       paramsData: null,
-      openAddrModal: false // 选择地址弹框是否显示
+      openAddrModal: false, // 选择地址弹框是否显示
+      openOutStockListModal: false
     }
   },
   computed: {
@@ -543,17 +554,21 @@ export default {
       this.$refs.purchaseTable.refresh(true)
       this.getOrderDetail()
     },
-    // 上次缺货
+    // 导入缺货
     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
-        }
+      this.openOutStockListModal = true
+      const _this = this
+      _this.$nextTick(() => {
+        _this.$refs.outStockList.resetSearchForm()
+      })
+    },
+    hanldeOkOutStockList (con) {
+      const _this = this
+      _this.openOutStockListModal = false
+      _this.openOutStockModal = true
+      _this.chooseData = con
+      _this.$nextTick(() => {
+        _this.$refs.outStock.resetSearchForm()
       })
     },
     //  地址保存
@@ -578,10 +593,10 @@ export default {
     handlePicDetail (row) {
       this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
     },
-    // 上次缺货 导入成功
+    // 导入缺货 导入成功
     hanldeOkOutStock () {
       this.$refs.purchaseTable.refresh(true)
-      this.paramsData = null
+      this.chooseData = null
       this.openOutStockModal = false
     },
     // 打印预览/快捷打印

+ 1 - 1
src/views/purchasingManagement/purchaseOrder/list.vue

@@ -322,7 +322,7 @@ export default {
     },
     // 获取供应商数据
     getSupperList () {
-      queryReturnSupplierList({}).then(res => {
+      queryReturnSupplierList().then(res => {
         if (res.status == 200) {
           this.supplierList = res.data
         } else {

+ 207 - 0
src/views/purchasingManagement/purchaseOrder/outStockListModal.vue

@@ -0,0 +1,207 @@
+<template>
+  <a-modal
+    centered
+    class="outStock-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="导入缺货"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="860">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <div class="outStock-con">
+        <div>
+          <div ref="tableSearch" class="table-page-search-wrapper">
+            <a-form layout="inline" @keyup.enter.native="searchForm">
+              <a-row type="flex" :gutter="12" justify="start">
+                <a-col :md="10" :sm="24">
+                  <a-form-model-item label="创建时间" prop="time">
+                    <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
+                  </a-form-model-item>
+                </a-col>
+                <a-col :md="8" :sm="24">
+                  <a-form-item label="采购单号">
+                    <a-input id="outStockList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
+                  </a-form-item>
+                </a-col>
+                <a-col flex="auto">
+                  <a-button type="primary" @click="searchForm" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
+                  <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
+                </a-col>
+              </a-row>
+            </a-form>
+          </div>
+          <!-- <p style="font-weight: bold;">当前已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys?rowSelectionInfo.selectedRowKeys.length:0 }}个</p> -->
+          <!-- 列表 -->
+          <s-table
+            class="sTable"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.purchaseBillSn"
+            rowKeyName="purchaseBillSn"
+            :row-selection="{ columnWidth: 40 }"
+            @rowSelection="rowSelectionFun"
+            :data="loadData"
+            :columns="columns"
+            :scroll="{ y: 450 }"
+            bordered>
+          </s-table>
+        </div>
+        <!-- 按钮 -->
+        <div class="btn-con">
+          <a-button
+            id="outStock-cancel"
+            size="large"
+            class="button-cancel"
+            @click="isShow=false"
+            style="padding: 0 30px;margin-right: 30px;">取消</a-button>
+          <a-button
+            type="primary"
+            id="outStock-save"
+            size="large"
+            class="button-primary"
+            @click="handleSave"
+            style="padding: 0 30px;">确定</a-button>
+        </div>
+      </div>
+      </div></a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { STable } from '@/components'
+import { outOfStockList } from '@/api/oos'
+import ProductType from '../../common/productType.js'
+import ProductBrand from '../../common/productBrand.js'
+import rangeDate from '@/views/common/rangeDate.vue'
+import getDate from '@/libs/getDate.js'
+export default {
+  name: 'OutStockModal',
+  components: { STable, ProductType, ProductBrand, rangeDate, getDate },
+  mixins: [commonMixin],
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    paramsData: {
+      type: Object,
+      default: () => {
+        return {}
+      }
+    }
+  },
+  data () {
+    const _this = this
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 20 }
+      },
+      disabled: false, //  查询、重置按钮是否可操作
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
+        { title: '创建时间', dataIndex: 'createDate', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '采购单号', dataIndex: 'purchaseBillNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '缺货款数', dataIndex: 'totalCategory', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '缺货数量', dataIndex: 'totalQty', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '缺货金额', dataIndex: 'totalAmount', width: '16%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        return outOfStockList(Object.assign(parameter, this.queryParam)).then(res => {
+          let data
+          if (res.status == 200) {
+            data = res.data
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+            }
+            this.disabled = false
+          }
+          this.spinning = false
+          return data
+        })
+      },
+      spinning: false,
+      rowSelectionInfo: null,
+      time: [
+        getDate.getCurrMonthDays().starttime,
+        getDate.getCurrMonthDays().endtime
+      ],
+      queryParam: { //  查询条件
+        purchaseBillNo: '',
+        beginDate: getDate.getCurrMonthDays().starttime,
+        endDate: getDate.getCurrMonthDays().endtime
+      }
+    }
+  },
+  methods: {
+    //  时间  change
+    dateChange (date) {
+      this.queryParam.beginDate = date[0]
+      this.queryParam.endDate = date[1]
+    },
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 保存
+    handleSave () {
+      const _this = this
+      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      _this.$emit('ok', this.rowSelectionInfo.selectedRowKeys)
+    },
+    searchForm () {
+      this.$refs.table.refresh(true)
+    },
+    resetSearchForm () {
+      this.$refs.rangeDate.resetDate(this.time)
+      this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
+      this.queryParam.endDate = getDate.getCurrMonthDays().endtime
+      this.queryParam.purchaseBillNo = ''
+      this.$refs.table.refresh(true)
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$refs.table.clearSelected() // 清空表格选中项
+        this.$emit('close')
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .outStock-modal{
+    .outStock-con{
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 50 - 86
src/views/purchasingManagement/purchaseOrder/outStockModal.vue

@@ -4,24 +4,29 @@
     class="outStock-modal"
     :footer="null"
     :maskClosable="false"
-    :title="title"
+    title="采购缺货产品明细"
     v-model="isShow"
     @cancel="isShow=false"
-    :width="800">
+    :width="900">
     <a-spin :spinning="spinning" tip="Loading...">
       <div class="outStock-con">
         <div>
           <div ref="tableSearch" class="table-page-search-wrapper">
             <a-form layout="inline" @keyup.enter.native="searchForm">
               <a-row :gutter="15">
+                <a-col :md="8" :sm="24">
+                  <a-form-item label="采购单号">
+                    <a-input id="productInfoList-purchaseBillNo" v-model.trim="queryParam.dealerProduct.purchaseBillNo" placeholder="请输入采购单号" allowClear />
+                  </a-form-item>
+                </a-col>
                 <a-col :md="8" :sm="24">
                   <a-form-item label="产品编码">
-                    <a-input id="productInfoList-code" v-model.trim="queryParam.dealerProductEntity.code" allowClear placeholder="请输入产品编码"/>
+                    <a-input id="productInfoList-code" v-model.trim="queryParam.dealerProduct.code" allowClear placeholder="请输入产品编码"/>
                   </a-form-item>
                 </a-col>
                 <a-col :md="8" :sm="24">
                   <a-form-item label="产品名称">
-                    <a-input id="productInfoList-name" v-model.trim="queryParam.dealerProductEntity.name" allowClear placeholder="请输入产品名称"/>
+                    <a-input id="productInfoList-name" v-model.trim="queryParam.dealerProduct.name" allowClear placeholder="请输入产品名称"/>
                   </a-form-item>
                 </a-col>
                 <a-col :md="8" :sm="24">
@@ -31,7 +36,7 @@
                 </a-col>
                 <a-col :md="8" :sm="24">
                   <a-form-item label="产品品牌">
-                    <ProductBrand id="productInfoList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.dealerProductEntity.productBrandSn"></ProductBrand>
+                    <ProductBrand id="productInfoList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.dealerProduct.productBrandSn"></ProductBrand>
                     </a-select>
                   </a-form-item>
                 </a-col>
@@ -55,6 +60,7 @@
             :data="loadData"
             :columns="columns"
             :scroll="{ y: 450 }"
+            :defaultLoadData="false"
             bordered>
           </s-table>
         </div>
@@ -82,7 +88,8 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { STable } from '@/components'
-import { purchaseDetailCancelList, purchaseDetailCancelSave } from '@/api/purchaseDetail'
+import { outOfStockDetailList } from '@/api/oos'
+import { importOosDetail } from '@/api/purchaseDetail'
 import ProductType from '../../common/productType.js'
 import ProductBrand from '../../common/productBrand.js'
 export default {
@@ -94,57 +101,61 @@ export default {
       type: Boolean,
       default: false
     },
+    paramsSn: {
+      type: String,
+      default: ''
+    },
     chooseData: {
       type: Array,
       default: () => {
         return []
       }
-    },
-    paramsData: {
-      type: Object,
-      default: () => {
-        return {}
-      }
     }
   },
   data () {
+    const _this = this
     return {
-      isShow: this.openModal, //  是否打开弹框
+      isShow: _this.openModal, //  是否打开弹框
       formItemLayout: {
         labelCol: { span: 4 },
         wrapperCol: { span: 20 }
       },
       disabled: false, //  查询、重置按钮是否可操作
       columns: [
-        { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '32%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '上次采购数量', dataIndex: 'qty', width: '18%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '上次缺货数量', dataIndex: 'cancelQty', width: '18%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
+        { title: '采购单号', dataIndex: 'purchaseBillNo', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productCode', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '缺货数量', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '缺货金额', dataIndex: 'totalAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '单位', dataIndex: 'unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
       ],
-      title: '',
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
-        return purchaseDetailCancelList(Object.assign(parameter, this.queryParam)).then(res => {
+        this.queryParam.purchaseBillSnList = this.chooseData
+        return outOfStockDetailList(Object.assign(parameter, this.queryParam)).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+            }
             this.disabled = false
           }
           this.spinning = false
-          const purchaseBillNo = data && data.list.length > 0 ? data.list[0].purchaseBillNo : '--'
-          this.title = '上次采购缺货产品明细(采购单号:' + purchaseBillNo + ')'
           return data
         })
       },
       spinning: false,
       rowSelectionInfo: null,
       productType: [],
-      dataList: [],
       queryParam: { //  查询条件
-        dealerProductEntity: {
+        purchaseBillSnList: undefined,
+        dealerProduct: {
+          purchaseBillNo: '',
           code: '', //  产品编码
           name: '', //  产品名称
           productBrandSn: undefined, //  产品品牌
@@ -158,9 +169,9 @@ export default {
   methods: {
     //  产品分类  change
     changeProductType (val, opt) {
-      this.queryParam.dealerProductEntity.productTypeSn1 = val[0] ? val[0] : ''
-      this.queryParam.dealerProductEntity.productTypeSn2 = val[1] ? val[1] : ''
-      this.queryParam.dealerProductEntity.productTypeSn3 = val[2] ? val[2] : ''
+      this.queryParam.dealerProduct.productTypeSn1 = val[0] ? val[0] : ''
+      this.queryParam.dealerProduct.productTypeSn2 = val[1] ? val[1] : ''
+      this.queryParam.dealerProduct.productTypeSn3 = val[2] ? val[2] : ''
     },
     // 表格选中项
     rowSelectionFun (obj) {
@@ -171,67 +182,19 @@ export default {
       const _this = this
       if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
         this.$message.warning('请在列表勾选后再进行操作!')
-        return
-      }
-      const params = {
-        confirm: false,
-        purchaseBillSn: this.paramsData.purchaseBillSn,
-        purchaseBillNo: this.paramsData.purchaseBillNo,
-        purchaseBillDetailEntityList: this.rowSelectionInfo && this.rowSelectionInfo.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.$refs.table.clearSelected() // 清空表格选中项
-              }
-            })
-          } else {
-            content = `您已经选择 ${res.data.productSize} 个产品,上次缺货数量将作为本次采购数量。确认加入本次采购吗?`
-            this.confirmFun(content)
-          }
+      const arr = []
+      _this.rowSelectionInfo.selectedRows.forEach(item => {
+        const obj = {
+          productSn: item.productSn,
+          productCode: item.productCode,
+          qty: item.qty
         }
+        arr.push(obj)
       })
-    },
-    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.rowSelectionInfo && _this.rowSelectionInfo.selectedRows
-          }
-          purchaseDetailCancelSave(params).then(res => {
-            if (res.status == 200) {
-              _this.$emit('ok')
-              _this.isShow = false
-              _this.spinning = false
-            } else {
-              _this.spinning = false
-            }
-          })
-        },
-        onCancel () {
-          _this.$refs.table.clearSelected() // 清空表格选中项
+      importOosDetail({ purchaseBillSn: _this.paramsSn, arr }).then(res => {
+        if (res.status == 200) {
+          _this.$emit('ok')
         }
       })
     },
@@ -240,6 +203,7 @@ export default {
     },
     resetSearchForm () {
       const info = {
+        purchaseBillNo: '',
         productBrandSn: undefined,
         code: '', //  产品编码
         name: '', //  产品名称
@@ -247,8 +211,8 @@ export default {
         productTypeSn2: '', //  产品二级分类
         productTypeSn3: '' //  产品三级分类
       }
-      Object.assign(this.queryParam.dealerProductEntity, info)
       this.productType = []
+      Object.assign(this.queryParam.dealerProduct, info)
       this.$refs.table.refresh(true)
     }
   },

+ 33 - 18
src/views/purchasingManagement/purchaseOrderNew/edit.vue

@@ -25,7 +25,7 @@
                 <a-icon type="shopping" /> 购物车
               </a-menu-item>
               <a-menu-item key="2" v-if="!isDealerUp">
-                <a-icon type="funnel-plot" />上次缺货
+                <a-icon type="funnel-plot" />导入缺货
               </a-menu-item>
               <a-menu-item key="1">
                 <a-icon type="import" />导入产品
@@ -117,7 +117,7 @@
                 height: '60px',
               }"
             >
-              <span slot="description"> 暂无产品 </span>
+              <span slot="description">暂无产品</span>
               <a-button type="primary" class="button-error" @click="openChooseProduct=true"><a-icon type="plus" />立即添加产品</a-button>
             </a-empty>
           </div>
@@ -163,8 +163,16 @@
       @close="openChooseProduct=false"
       @add="handleAdd"
     ></chooseProductModal>
+    <!-- 导入缺货 -->
+    <outStockListModal ref="outStockList" :openModal="openOutStockListModal" @close="openOutStockListModal=false" @ok="hanldeOkOutStockList"></outStockListModal>
     <!-- 上次缺货 -->
-    <outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
+    <outStockModal
+      ref="outStock"
+      :paramsSn="$route.params.sn"
+      :chooseData="chooseData"
+      :openModal="openOutStockModal"
+      @close="openOutStockModal=false"
+      @ok="hanldeOkOutStock" />
     <!-- 购物车 -->
     <shopingCatModal :showModal="openShopCatModal" :paramsData="paramsData" @close="openShopCatModal=false" @ok="getOrderDetail(false, true)"></shopingCatModal>
 
@@ -177,9 +185,10 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import ImportGuideModal from './importGuideModal.vue'
 import outStockModal from './outStockModal.vue'
+import outStockListModal from './outStockListModal.vue'
 import chooseAddressModal from '@/views/common/receivingAddress/chooseAddressModal.vue'
 import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseDetailExport, purchaseDetailAddress } from '@/api/purchase'
-import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
+import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel } from '@/api/purchaseDetail'
 // 选择产品
 import chooseProductModal from './chooseProductModal.vue'
 // 打印
@@ -227,7 +236,7 @@ const actionComp = {
 
 export default {
   name: 'PurchaseEdit',
-  components: { STable, VSelect, ImportGuideModal, outStockModal, PrintPanel, chooseAddressModal, chooseProductModal, shopingCatModal },
+  components: { STable, VSelect, ImportGuideModal, outStockModal, PrintPanel, chooseAddressModal, chooseProductModal, shopingCatModal, outStockListModal },
   mixins: [commonMixin],
   data () {
     return {
@@ -251,10 +260,12 @@ export default {
       },
       purchaseDisabled: false, //  查询、重置按钮是否可操作
       localDataSource: [],
+      chooseData: [],
       openGuideModal: false, //  导入产品引导
       openOutStockModal: false,
       paramsData: null,
-      openAddrModal: false // 选择地址弹框是否显示
+      openAddrModal: false, // 选择地址弹框是否显示
+      openOutStockListModal: false // 导入缺货
     }
   },
   computed: {
@@ -267,7 +278,7 @@ export default {
         { title: '序号', key: 'a', field: 'no', width: '5%', align: 'center', operationColumn: false },
         { title: '产品编码', key: 'b', field: 'productCode', width: '10%', align: 'center', operationColumn: false },
         { title: '产品名称', key: 'c', field: 'productName', width: '25%', align: 'center', operationColumn: false, ellipsis: { showTitle: true } },
-        { title: '原厂编码', key: 'q', field: 'productOrgCode', width: '15%', align: 'center',operationColumn: false },
+        { title: '原厂编码', key: 'q', field: 'productOrgCode', width: '15%', align: 'center', operationColumn: false },
         { title: '可用库存', key: 'j', field: 'currentStockQty', width: '10%', align: 'center', operationColumn: false },
         { title: '采购数量',
           key: 'd',
@@ -463,16 +474,10 @@ export default {
     },
     // 上次缺货
     handleOutStock () {
-      // 校验是否存在历史采购单,且上次采购存在缺货产品
-      purchaseDetailCancelList({ pageNo: 1, pageSize: 5 }).then(res => {
-        if (res.status == 200) {
-          const purchaseBillNo = res.data && res.data.list && res.data.list[0].purchaseBillNo || '--'
-          this.paramsData = {
-            purchaseBillSn: this.$route.params.sn,
-            purchaseBillNo: purchaseBillNo
-          }
-          this.openOutStockModal = true
-        }
+      this.openOutStockListModal = true
+      const _this = this
+      _this.$nextTick(() => {
+        _this.$refs.outStockList.resetSearchForm()
       })
     },
     //  地址保存
@@ -493,10 +498,20 @@ export default {
         }
       })
     },
+    // 选择缺货列表  打开上次缺货列表
+    hanldeOkOutStockList (con) {
+      const _this = this
+      _this.openOutStockListModal = false
+      _this.openOutStockModal = true
+      _this.chooseData = con
+      _this.$nextTick(() => {
+        _this.$refs.outStock.resetSearchForm()
+      })
+    },
     // 上次缺货 导入成功
     hanldeOkOutStock () {
       this.getOrderDetail(false, true, true)
-      this.paramsData = null
+      this.chooseData = null
       this.openOutStockModal = false
     },
     // 打印预览/快捷打印

+ 207 - 0
src/views/purchasingManagement/purchaseOrderNew/outStockListModal.vue

@@ -0,0 +1,207 @@
+<template>
+  <a-modal
+    centered
+    class="outStock-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="导入缺货"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="860">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <div class="outStock-con">
+        <div>
+          <div ref="tableSearch" class="table-page-search-wrapper">
+            <a-form layout="inline" @keyup.enter.native="searchForm">
+              <a-row type="flex" :gutter="12" justify="start">
+                <a-col :md="10" :sm="24">
+                  <a-form-model-item label="创建时间" prop="time">
+                    <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
+                  </a-form-model-item>
+                </a-col>
+                <a-col :md="8" :sm="24">
+                  <a-form-item label="采购单号">
+                    <a-input id="outStockList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
+                  </a-form-item>
+                </a-col>
+                <a-col flex="auto">
+                  <a-button type="primary" @click="searchForm" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
+                  <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
+                </a-col>
+              </a-row>
+            </a-form>
+          </div>
+          <!-- <p style="font-weight: bold;">当前已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys?rowSelectionInfo.selectedRowKeys.length:0 }}个</p> -->
+          <!-- 列表 -->
+          <s-table
+            class="sTable"
+            ref="table"
+            size="small"
+            :rowKey="(record) => record.purchaseBillSn"
+            rowKeyName="purchaseBillSn"
+            :row-selection="{ columnWidth: 40 }"
+            @rowSelection="rowSelectionFun"
+            :data="loadData"
+            :columns="columns"
+            :scroll="{ y: 450 }"
+            bordered>
+          </s-table>
+        </div>
+        <!-- 按钮 -->
+        <div class="btn-con">
+          <a-button
+            id="outStock-cancel"
+            size="large"
+            class="button-cancel"
+            @click="isShow=false"
+            style="padding: 0 30px;margin-right: 30px;">取消</a-button>
+          <a-button
+            type="primary"
+            id="outStock-save"
+            size="large"
+            class="button-primary"
+            @click="handleSave"
+            style="padding: 0 30px;">确定</a-button>
+        </div>
+      </div>
+      </div></a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { STable } from '@/components'
+import { outOfStockList } from '@/api/oos'
+import ProductType from '../../common/productType.js'
+import ProductBrand from '../../common/productBrand.js'
+import rangeDate from '@/views/common/rangeDate.vue'
+import getDate from '@/libs/getDate.js'
+export default {
+  name: 'OutStockModal',
+  components: { STable, ProductType, ProductBrand, rangeDate, getDate },
+  mixins: [commonMixin],
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    chooseData: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    paramsData: {
+      type: Object,
+      default: () => {
+        return {}
+      }
+    }
+  },
+  data () {
+    const _this = this
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 4 },
+        wrapperCol: { span: 20 }
+      },
+      disabled: false, //  查询、重置按钮是否可操作
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
+        { title: '创建时间', dataIndex: 'createDate', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '采购单号', dataIndex: 'purchaseBillNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '缺货款数', dataIndex: 'totalCategory', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '缺货数量', dataIndex: 'totalQty', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '缺货金额', dataIndex: 'totalAmount', width: '16%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        return outOfStockList(Object.assign(parameter, this.queryParam)).then(res => {
+          let data
+          if (res.status == 200) {
+            data = res.data
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+            }
+            this.disabled = false
+          }
+          this.spinning = false
+          return data
+        })
+      },
+      spinning: false,
+      rowSelectionInfo: null,
+      time: [
+        getDate.getCurrMonthDays().starttime,
+        getDate.getCurrMonthDays().endtime
+      ],
+      queryParam: { //  查询条件
+        purchaseBillNo: '',
+        beginDate: getDate.getCurrMonthDays().starttime,
+        endDate: getDate.getCurrMonthDays().endtime
+      }
+    }
+  },
+  methods: {
+    //  时间  change
+    dateChange (date) {
+      this.queryParam.beginDate = date[0]
+      this.queryParam.endDate = date[1]
+    },
+    // 表格选中项
+    rowSelectionFun (obj) {
+      this.rowSelectionInfo = obj || null
+    },
+    // 保存
+    handleSave () {
+      const _this = this
+      if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+        this.$message.warning('请在列表勾选后再进行操作!')
+        return
+      }
+      _this.$emit('ok', this.rowSelectionInfo.selectedRowKeys)
+    },
+    searchForm () {
+      this.$refs.table.refresh(true)
+    },
+    resetSearchForm () {
+      this.$refs.rangeDate.resetDate(this.time)
+      this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
+      this.queryParam.endDate = getDate.getCurrMonthDays().endtime
+      this.queryParam.purchaseBillNo = ''
+      this.$refs.table.refresh(true)
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$refs.table.clearSelected() // 清空表格选中项
+        this.$emit('close')
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .outStock-modal{
+    .outStock-con{
+      .btn-con{
+        text-align: center;
+        margin: 30px 0 20px;
+        .button-cancel{
+          font-size: 12px;
+        }
+      }
+    }
+  }
+</style>

+ 37 - 82
src/views/purchasingManagement/purchaseOrderNew/outStockModal.vue

@@ -1,7 +1,7 @@
 <template>
   <a-drawer
     :zIndex="zIndex"
-    :title="title"
+    title="采购缺货产品明细"
     placement="right"
     :visible="isShow"
     :width="width"
@@ -16,6 +16,11 @@
           <div ref="searchBox" class="table-page-search-wrapper">
             <a-form layout="inline" @keyup.enter.native="searchForm">
               <a-row type="flex" :gutter="12" justify="start">
+                <a-col flex="auto">
+                  <a-form-item label="采购单号">
+                    <a-input id="productInfoList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" placeholder="请输入采购单号" allowClear />
+                  </a-form-item>
+                </a-col>
                 <a-col flex="auto">
                   <a-form-item label="产品编码">
                     <a-input id="productInfoList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
@@ -77,7 +82,8 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { STable } from '@/components'
-import { purchaseDetailCancelList, purchaseDetailCancelSave } from '@/api/purchaseDetail'
+import { outOfStockDetailList } from '@/api/oos'
+import { importOosDetail } from '@/api/purchaseDetail'
 import ProductType from '../../common/productType.js'
 import ProductBrand from '../../common/productBrand.js'
 export default {
@@ -89,18 +95,16 @@ export default {
       type: Boolean,
       default: false
     },
+    paramsSn: {
+      type: String,
+      default: ''
+    },
     chooseData: {
       type: Array,
       default: () => {
         return []
       }
     },
-    paramsData: {
-      type: Object,
-      default: () => {
-        return {}
-      }
-    },
     width: {
       type: [String, Number],
       default: '70%'
@@ -111,6 +115,7 @@ export default {
     }
   },
   data () {
+    const _this = this
     return {
       isShow: this.openModal, //  是否打开弹框
       tableHeight: 0,
@@ -120,21 +125,26 @@ export default {
       },
       disabled: false, //  查询、重置按钮是否可操作
       columns: [
-        { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '240px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
-        { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '上次采购数量', dataIndex: 'qty', width: '180px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '上次缺货数量', dataIndex: 'cancelQty', width: '180px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '80px', align: 'center', customRender: function (text) { return text || '--' } }
+        { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
+        { title: '采购单号', dataIndex: 'purchaseBillNo', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品编码', dataIndex: 'productCode', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '缺货数量', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '缺货金额', dataIndex: 'totalAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
+        { title: '单位', dataIndex: 'unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
       ],
-      title: '',
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
-        return purchaseDetailCancelList(Object.assign(parameter, { dealerProductEntity: this.queryParam })).then(res => {
+        return outOfStockDetailList(Object.assign(parameter, { purchaseBillSnList: this.chooseData, dealerProduct: this.queryParam })).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
+            const no = (data.pageNo - 1) * data.pageSize
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+            }
             this.disabled = false
           }
           this.spinning = false
@@ -145,6 +155,7 @@ export default {
       rowSelectionInfo: null,
       productType: [],
       queryParam: { //  查询条件
+        purchaseBillNo: '',
         code: '', //  产品编码
         name: '', //  产品名称
         productBrandSn: undefined, //  产品品牌
@@ -176,75 +187,19 @@ export default {
       const _this = this
       if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
         this.$message.warning('请在列表勾选后再进行操作!')
-        return
       }
-      const rows = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
-      const list = []
-      rows.map(item => {
-        list.push({
-          cancelQty: item.cancelQty,
-          qty: item.qty,
+      const arr = []
+      _this.rowSelectionInfo.selectedRows.forEach(item => {
+        const obj = {
           productSn: item.productSn,
-          price: item.price
-        })
-      })
-
-      const params = {
-        confirm: false,
-        purchaseBillSn: this.paramsData.purchaseBillSn,
-        purchaseBillNo: this.paramsData.purchaseBillNo,
-        purchaseBillDetailEntityList: list
-      }
-      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, params)
-          } else if (res.data.productSizeRepeat == res.data.productSize) {
-            content = `抱歉,您选择的 ${res.data.productSize} 个产品,采购单中已经全部存在,无需加入!`
-            this.$info({
-              title: '提示',
-              content: content,
-              okText: '好的',
-              centered: true,
-              zIndex: 1100,
-              onOk () {
-                _this.$refs.table.clearSelected() // 清空表格选中项
-              }
-            })
-          } else {
-            content = `您已经选择 ${res.data.productSize} 个产品,上次缺货数量将作为本次采购数量。确认加入本次采购吗?`
-            this.confirmFun(content, params)
-          }
+          productCode: item.productCode,
+          qty: item.qty
         }
+        arr.push(obj)
       })
-    },
-    confirmFun (content, params) {
-      const _this = this
-      this.$confirm({
-        title: '提示',
-        content: content,
-        okText: '确认加入',
-        cancelText: '重新选择',
-        centered: true,
-        closable: true,
-        zIndex: 1100,
-        onOk () {
-          _this.spinning = true
-          params.confirm = true
-          purchaseDetailCancelSave(params).then(res => {
-            if (res.status == 200) {
-              _this.$emit('ok')
-              _this.isShow = false
-              _this.spinning = false
-            } else {
-              _this.spinning = false
-            }
-          })
-        },
-        onCancel () {
-          _this.$refs.table.clearSelected() // 清空表格选中项
+      importOosDetail({ purchaseBillSn: _this.paramsSn, arr }).then(res => {
+        if (res.status == 200) {
+          _this.$emit('ok')
         }
       })
     },
@@ -257,6 +212,7 @@ export default {
     },
     resetSearchForm () {
       this.queryParam = {
+        purchaseBillNo: '',
         productBrandSn: undefined,
         code: '', //  产品编码
         name: '', //  产品名称
@@ -285,7 +241,6 @@ export default {
           this.setTableH()
         }, 200)
         this.resetSearchForm()
-        this.title = '上次采购缺货产品明细(采购单号:' + this.paramsData.purchaseBillNo + ')'
       }
     }
   }
@@ -306,6 +261,6 @@ export default {
         padding: 10px 0;
       }
     }
-   
+
   }
 </style>