chenrui 11 ヶ月 前
コミット
8575fcfbe1

+ 142 - 0
src/api/purchase.js

@@ -0,0 +1,142 @@
+import { axios } from '@/utils/request'
+
+//  采购入库 列表  分页
+export const purchaseList = (params) => {
+  const url = `/purchase/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+
+//  采购入库 列表合计
+export const purchasePageCount = (params) => {
+  return axios({
+    url: '/purchase/queryPageCount',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表合计')
+    }
+  })
+}
+//  采购入库 列表 取消
+export const purchaseCancel = (params) => {
+  const url = `/purchase/cancel/${params.sn}`
+  return axios({
+    url: url,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('取消')
+    }
+  })
+}
+
+// 采购入库 明细列表 分页
+export const purchaseDetailPageList = (params) => {
+  const url = `/purchase/queryDetailPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('列表查询')
+    }
+  })
+}
+//  采购入库 明细列表合计
+export const queryDetailCount = (params) => {
+  const url = `/purchase/queryBySn/${params.sn}`
+  return axios({
+    url: url,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('明细合计')
+    }
+  })
+}
+// 新增/编辑 采购入库详情
+export const savePurchaseDetail = (params) => {
+  return axios({
+    url: '/purchase/saveDetail',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('新增/编辑')
+    }
+  })
+}
+// 编辑基础信息
+export const detailBaseSave = (params) => {
+  return axios({
+    url: '/purchase/setSupplierInfo',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('基础信息编辑')
+    }
+  })
+}
+//  优惠活动 保存
+export const promoRuleSave = (params) => {
+  return axios({
+    url: '/promoRule/save',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('新增/编辑')
+    }
+  })
+}
+//  优惠活动 删除
+export const promoRuleDel = (params) => {
+  const url = `/promoRule/delete/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get',
+    headers: {
+      'module': encodeURIComponent('删除')
+    }
+  })
+}
+//  优惠活动 详情
+export const promoRuleDetail = (params) => {
+  const url = `/promoRule/findBySn/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get',
+    headers: {
+      'module': encodeURIComponent('详情')
+    }
+  })
+}
+//  优惠活动 详情  包含规则
+export const promoRuleDetailD = (params) => {
+  const url = `/promoRule/findDetailBySn/${params.sn}`
+  return axios({
+    url: url,
+    method: 'get',
+    headers: {
+      'module': encodeURIComponent('详情')
+    }
+  })
+}
+//  促销规则  获取可导入和不可导入列表数据
+export const promoRuleGoods = (params) => {
+  return axios({
+    url: '/promoRule/parseGoods',
+    data: params,
+    method: 'post',
+    headers: {
+      'module': encodeURIComponent('选择产品')
+    }
+  })
+}

+ 24 - 54
src/views/purchasingManagement/purchaseReceipt/addModal.vue

@@ -46,18 +46,17 @@
             @change="changeWarehouseCascade"
             placeholder="请选择仓位"
             :allowClear="false"
-            style="width: 50%;"
-            v-model="form.warehouseLocationSn">
-            <a-select-option v-for="item in warehouseCascadeData" :value="item.sn">
+            v-model="form.warehouseLocationSn"
+            style="width: 50%;">
+            <a-select-option v-for="item in warehouseCascadeData" :value="item.warehouseLocationSn">
               {{ item.name }}
             </a-select-option>
           </a-select>
         </a-form-model-item>
         <a-form-model-item label="成本价">
           <span style="margin-right:20px;">{{ form.productCost ? toThousands(form.productCost) : '--' }}</span>
-          <a-checkbox v-if="productCost||isGift" :disabled="!!itemSn" v-model="isGift">是否为赠品</a-checkbox>
         </a-form-model-item>
-        <a-form-model-item label="数量" prop="productQty">
+        <a-form-model-item label="采购数量" prop="productQty">
           <a-input-number
             id="bulkWarehousingOrder-product-productQty"
             ref="productQty"
@@ -65,7 +64,7 @@
             :precision="0"
             :min="1"
             :max="99999999"
-            placeholder="请输入"
+            placeholder="请输入采购数量"
             style="width: 50%;margin-right:20px;" /><span>个</span>
         </a-form-model-item>
         <div class="btn-cont">
@@ -83,7 +82,7 @@ import { VSelect } from '@/components'
 import debounce from 'lodash/debounce'
 import { supplierProductList } from '@/api/supplier'
 import { warehouseCascadeList } from '@/api/warehouse'
-import { sparePartsSaveDetail, sparePartsDetailD } from '@/api/spareParts'
+import { savePurchaseDetail } from '@/api/purchase'
 export default {
   name: 'BulkWarehousingOrderBasicInfoModal',
   mixins: [commonMixin],
@@ -186,7 +185,7 @@ export default {
     // 详情
     getDetail () {
       this.spinning = true
-      sparePartsDetailD({ sn: this.itemSn }).then(res => {
+      sparePartsDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
           const data = res.data
           this.form = Object.assign(this.form, data)
@@ -204,32 +203,18 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
+          form.supplierSn = this.nowData.supplierSn
           form.sparePartsSn = this.nowData.sparePartsSn
           form.sparePartsNo = this.nowData.sparePartsNo
-          form.supplierSn = this.nowData.supplierSn
-          form.giftFlag = this.isGift ? 1 : 0
-          if (!_this.itemSn) {
-            delete form.id
-            delete form.sparePartsDetailSn
-            if (!this.productCost) {
-              _this.$message.warning('该产品没有设置成本价!')
-              return false
-            }
-          }
+          form.warehouseSn = this.nowData.warehouseSn
           _this.spinning = true
-          sparePartsSaveDetail(form).then(res => {
+          savePurchaseDetail(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
                 _this.$emit('ok', res.data)
                 _this.spinning = false
-                if (!_this.itemSn) {
-                  _this.resetData()
-                  _this.$refs.productQty.blur()
-                  _this.$refs.productSn.focus()
-                } else {
-                  _this.isShow = false
-                }
+                _this.isShow = false
               })
             } else {
               _this.spinning = false
@@ -250,26 +235,19 @@ export default {
       const _this = this
       warehouseCascadeList({}).then(res => {
         if (res.status == 200) {
-          // 默认仓库
-          const defSn = this.isShowWarehouse ? this.nowData.warehouseSn : this.defWarehouse && this.defWarehouse.warehouseSn
-          _this.form.warehouseSn = defSn
-          _this.warehouseSnBackups = defSn
-          const data = res.data.find(item => item.warehouseSn == defSn)
-          console.log(data.warehouseLocationList)
-          if (data && data.warehouseLocationList) {
-            data.warehouseLocationList.map(subItem => {
-              subItem.sn = subItem.warehouseLocationSn
-              if (subItem.defaultFlag == 1) {
-                _this.form.warehouseLocationSn = subItem.warehouseLocationSn
-                _this.warehouseLocationSnBackups = subItem.warehouseLocationSn
-              }
-            })
-            this.warehouseCascadeData = data.warehouseLocationList
+          const data = res.data
+          var pos = data.findIndex(item => _this.nowData.warehouseSn === item.warehouseSn)
+          if (pos != -1) {
+            if (data[pos].warehouseLocationList && data[pos].warehouseLocationList.length > 0) {
+              _this.warehouseCascadeData = data[pos].warehouseLocationList
+              _this.form.warehouseLocationSn = data[pos].warehouseLocationList[0].warehouseLocationSn
+            } else {
+              _this.warehouseCascadeData = []
+              _this.form.warehouseLocationSn = undefined
+            }
           } else {
-            this.warehouseCascadeData = []
+            _this.warehouseCascadeData = []
           }
-        } else {
-          this.warehouseCascadeData = []
         }
       })
     },
@@ -288,6 +266,7 @@ export default {
       }
       this.productCost = ''
       this.isGift = false
+      this.itemSn = ''
     }
   },
   watch: {
@@ -299,9 +278,7 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.resetData()
-        this.warehouseSnBackups = ''
-        this.warehouseLocationSnBackups = ''
+        // this.resetData()
       } else {
         this.getWarehouseCascade()
       }
@@ -310,13 +287,6 @@ export default {
       if (this.isShow && newValue) {
         this.getDetail()
       }
-    },
-    isGift (newValue, oldValue) {
-      if (newValue) {
-        this.form.productCost = 0
-      } else {
-        this.form.productCost = this.productCost
-      }
     }
   }
 }

+ 74 - 68
src/views/purchasingManagement/purchaseReceipt/basicInfoModal.vue

@@ -17,25 +17,46 @@
         :label-col="formItemLayout.labelCol"
         :wrapper-col="formItemLayout.wrapperCol" >
         <a-form-model-item label="供应商名称" prop="supplierSn">
-          <supplier v-model="form.supplierSn" isPermission :disabledFlag="itemSn?true:false" placeholder="请输入供应商名称"></supplier>
+          <supplier v-model="form.supplierSn" isPermission placeholder="请输入供应商名称"></supplier>
         </a-form-model-item>
-        <a-form-model-item label="入库仓库" prop="warehouseSn" v-show="isShowWarehouse">
-          <warehouse
-            v-model="form.warehouseSn"
+        <a-form-model-item label="仓库仓位" prop="warehouseSn">
+          <a-select
+            v-if="warehouseCascadeData && warehouseCascadeData.length>0"
             id="purchaseReturn-basicInfo-warehouseSn"
-            :disabled="itemSn?true:false"
-            isPermission
-            placeholder="请选择退货仓库"
-          />
+            @change="changeWarehouse"
+            placeholder="请选择仓库"
+            :allowClear="false"
+            v-model="form.warehouseSn"
+            style="width: 49%;margin-right:1%;">
+            <a-select-option
+              v-for="
+                item
+                  in
+                    warehouseCascadeData"
+              :value="item.warehouseSn">
+              {{ item.name }}
+            </a-select-option>
+          </a-select>
+          <a-select
+            id="purchaseReturn-basicInfo-warehouseLocationSn"
+            placeholder="请选择仓位"
+            :allowClear="false"
+            v-model="form.warehouseLocationSn"
+            :disabled="!cascadeList"
+            style="width: 50%;">
+            <a-select-option v-for="con in cascadeList" :value="con.warehouseLocationSn">
+              {{ con.name }}
+            </a-select-option>
+          </a-select>
         </a-form-model-item>
         <a-form-model-item label="客户名称" >
-          <span>客户名称</span>
+          <span>{{ itemData.dealerName||'--' }}</span>
         </a-form-model-item>
         <a-form-model-item label="关联单号" >
-          <span>关联单号</span>
+          <span>{{ itemData.lockBizNo||'--' }}</span>
         </a-form-model-item>
         <a-form-model-item label="备注">
-          <span>--</span>
+          <span>{{ itemData.bizRemark||'--' }}</span>
         </a-form-model-item>
       </a-form-model>
       <div class="btn-cont">
@@ -48,14 +69,17 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
-import { VSelect, Upload } from '@/components'
+// 组件
+import { VSelect } from '@/components'
 import supplier from '@/views/common/supplier.js'
 import warehouse from '@/views/common/chooseWarehouse.js'
-import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+// 接口
+import { savePurchaseDetail } from '@/api/purchase'
+import { warehouseCascadeList } from '@/api/warehouse'
 export default {
-  name: 'PurchaseReturnBasicInfoModal',
+  name: 'PurchaseReceiptBasicInfoModal',
   mixins: [commonMixin],
-  components: { VSelect, Upload, supplier, warehouse },
+  components: { VSelect, supplier, warehouse },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -64,6 +88,10 @@ export default {
     itemSn: {
       type: [Number, String],
       default: ''
+    },
+    itemData: {
+      type: Object,
+      default: () => {}
     }
   },
   data () {
@@ -74,50 +102,59 @@ export default {
         labelCol: { span: 5 },
         wrapperCol: { span: 16 }
       },
+      warehouseCascadeData: [], // 仓库仓位级联列表
+      cascadeList: null, // 仓位列表
       form: {
         supplierSn: undefined, // 供应商
-        returnReason: '', // 退货原因
-        explainInfo: '', // 补充说明
-        warehouseSn: undefined,
-        attachmentList: '',
-        grabFlag: 1
+        warehouseSn: undefined, // 仓库
+        warehouseLocationSn: undefined // 仓位
       },
-      attachList: [], // 附件
       rules: {
         supplierSn: [
           { required: true, message: '请选择供应商名称', trigger: 'change' }
         ],
-        returnReason: [
-          { required: true, message: '请选择退货原因', trigger: 'change' }
-        ],
-        warehouseSn: [{ required: true, message: '请选择退货仓库', trigger: 'change' }],
-        grabFlag: [{ required: true, message: '请选择是否抓单', trigger: 'change' }]
-      },
-      attachAction: process.env.VUE_APP_API_BASE_URL + '/uploadGetFileInfo'
+        warehouseSn: [{ required: true, message: '请选择入库仓库', trigger: 'change' }]
+      }
     }
   },
   methods: {
-    //  附件上传
-    changeAttach (file) {
-      this.attachList = JSON.parse(file)
-      this.attachList.map(item => {
-        item.fileType = item.extName
+    //  获取仓库仓位  级联列表
+    getWarehouseCascade () {
+      const _this = this
+      warehouseCascadeList({}).then(res => {
+        if (res.status == 200) {
+          this.warehouseCascadeData = res.data
+        } else {
+          this.warehouseCascadeData = []
+        }
       })
     },
+    // 仓库 change
+    changeWarehouse (val) {
+      const pos = this.warehouseCascadeData.findIndex(item => item.warehouseSn === val)
+      if (pos != -1) {
+        this.cascadeList = this.warehouseCascadeData[pos].warehouseLocationList || null
+        this.form.warehouseLocationSn = (this.cascadeList && this.cascadeList.length > 0) ? this.cascadeList[0].warehouseLocationSn : undefined
+      }
+    },
     //  保存
     handleSave () {
       const _this = this
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
-          form.attachmentList = _this.attachList
+          if (!form.warehouseLocationSn) {
+            _this.$message.warning('请选择仓位')
+            return
+          }
+          form.sparePartsSn = _this.itemSn
           _this.spinning = true
-          sparePartsReturnSave(form).then(res => {
+          savePurchaseDetail(form).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               setTimeout(() => {
                 _this.isShow = false
-                _this.$emit('ok', res.data)
+                _this.$emit('ok')
                 _this.spinning = false
               }, 1000)
             } else {
@@ -128,29 +165,6 @@ export default {
           return false
         }
       })
-    },
-    // 获取编辑详情
-    getDetail () {
-      sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
-        if (res.status == 200) {
-          const resultObj = res.data
-          this.attachList = resultObj.attachmentList
-          const obj = {
-            supplierSn: resultObj.supplierSn,
-            returnReason: resultObj.returnReason, // 退货原因
-            explainInfo: resultObj.explainInfo, // 补充说明
-            warehouseSn: resultObj.warehouseSn,
-            sparePartsReturnSn: this.itemSn,
-            grabFlag: Number(resultObj.grabFlag)
-          }
-          this.$nextTick(() => {
-            this.$refs.attachList.setFileList(this.attachList)
-          })
-          this.form = { ...this.form, ...obj }
-        } else {
-          this.detailsData = null
-        }
-      })
     }
   },
   watch: {
@@ -162,19 +176,11 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
-        this.attachList = []
-        this.supplierName = null
         this.$nextTick(() => {
-          this.$refs.attachList.setFileList('')
           this.$refs.ruleForm.resetFields()
         })
       } else {
-        if (this.itemSn) {
-          this.getDetail()
-        } else {
-          // 默认仓库
-          this.form.warehouseSn = this.isShowWarehouse ? undefined : this.defWarehouse && this.defWarehouse.warehouseSn
-        }
+        this.getWarehouseCascade()
       }
     }
   }

+ 81 - 79
src/views/purchasingManagement/purchaseReceipt/edit.vue

@@ -8,8 +8,8 @@
             <a-icon type="left" />
             返回列表
           </a>
-          <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailsData&&detailsData.sparePartsReturnNo }}</span>
-          <span style="margin: 0 10px;color: #666;">供应商:{{ detailsData && detailsData.supplier && detailsData.supplier.supplierName }}</span>
+          <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailsData&&detailsData.sparePartsNo }}</span>
+          <span style="margin: 0 10px;color: #666;">供应商:{{ detailsData&&detailsData.supplierName ||'--' }}</span>
           <a-button type="link" size="small" id="purchaseReceiptEdit-showDetail-btn" class="button-default" @click="showDetail=!showDetail">
             <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
           </a-button>
@@ -18,19 +18,19 @@
       <a-card size="small" :bordered="false" class="purchaseReceiptEdit-cont" v-show="showDetail">
         <div slot="title">
           <span>基础信息</span>
-          <div style="cursor:pointer;color: #00aaff;float:right;" id="purchaseReceiptEdit-btn" @click.stop="handleEditBase" >
+          <div style="cursor:pointer;color: #00aaff;float:right;" id="purchaseReceiptEdit-btn" @click.stop="handleEditBase" v-if="!detailsData&&detailsData.supplierName">
             <a-icon type="edit" /> 编辑基础信息
           </div>
         </div>
         <a-descriptions size="small" :column="4" style="margin-bottom: 10px;">
-          <a-descriptions-item label="客户名称">{{ (detailsData && detailsData.sparePartsReturnNo) || '--' }}</a-descriptions-item>
-          <a-descriptions-item label="收货地址">{{ (detailsData && detailsData.sparePartsReturnNo) || '--' }}</a-descriptions-item>
-          <a-descriptions-item label="收货人">{{ (detailsData && detailsData.supplier && detailsData.supplier.supplierName) || '--' }}</a-descriptions-item>
-          <a-descriptions-item label="收货电话">{{ (detailsData && detailsData.returnReasonDictValue) || '--' }}</a-descriptions-item>
-          <a-descriptions-item label="业务状态">{{ detailsData&&detailsData.warehouseName || '--' }}</a-descriptions-item>
-          <a-descriptions-item label="备注">{{ detailsData&&detailsData.grabFlag =='0'?'否':'是' }}</a-descriptions-item>
-          <a-descriptions-item label="关联单号">{{ (detailsData && detailsData.explainInfo) || '--' }}</a-descriptions-item>
-          <a-descriptions-item label="销售类型">{{ (detailsData && detailsData.explainInfo) || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="客户名称">{{ (detailsData && detailsData.dealerName) || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="收货地址">{{ (detailsData && detailsData.shippingAddr) || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="收货人">{{ (detailsData &&detailsData.consigneeName) || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="收货电话">{{ (detailsData && detailsData.consigneeTel) || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="业务状态">{{ detailsData&&detailsData.stateDictValue || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="备注">{{ detailsData&&detailsData.bizRemark || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="关联单号">{{ (detailsData && detailsData.lockBizNo) || '--' }}</a-descriptions-item>
+          <a-descriptions-item label="销售类型">{{ (detailsData && detailsData.purchaseFlowType)?detailsData.purchaseFlowType==='DIRECT'?'直购':'平台购':'--' }}</a-descriptions-item>
         </a-descriptions>
       </a-card>
       <a-card size="small" :bordered="false" class="purchaseReceiptEdit-cont">
@@ -53,7 +53,7 @@
           </div>
         </div>
         <div class="showBtn">
-          <a-button id="purchaseReceiptEdit-add" type="primary" class="button-warning" @click="handleAdd">新增产品</a-button>
+          <a-button id="purchaseReceiptEdit-add" type="primary" class="button-warning" @click="handleAddEdit">新增产品</a-button>
           <a-button id="purchaseReceiptEdit-ex" class="button-warning" @click="handleImport">导入产品</a-button>
           <a-button
             v-if="$hasPermissions('B_sparePartsBatchAudit')"
@@ -64,8 +64,8 @@
             @click="handleThirdQty">第三方库存</a-button>
           <a-alert type="info">
             <div slot="message" class="total-bar">
-              <span>采购数量:{{ statisticsObj && (statisticsObj.qty || statisticsObj.qty == 0) ? statisticsObj.qty : '--' }};</span>
-              <span v-if="$hasPermissions('B_purchaseReturnEdit_costPrice')">采购金额:{{ statisticsObj && statisticsObj.totalCost || statisticsObj.totalCost == 0 ? statisticsObj.totalCost : '--' }};</span>
+              <span>采购数量:{{ statisticsObj && (statisticsObj.productTotalQty || statisticsObj.productTotalQty == 0) ? statisticsObj.productTotalQty : '--' }};</span>
+              <span v-if="$hasPermissions('B_purchaseReturnEdit_costPrice')">采购金额:{{ statisticsObj && statisticsObj.productTotalCost || statisticsObj.productTotalCost == 0 ? statisticsObj.productTotalCost : '--' }};</span>
             </div>
           </a-alert>
         </div>
@@ -79,7 +79,7 @@
           :defaultLoadData="false"
           bordered>
           <!--申请退货数量 -->
-          <template slot="qty" slot-scope="text, record">
+          <!-- <template slot="qty" slot-scope="text, record">
             <a-input-number
               id="purchaseReceiptEdit-qty"
               size="small"
@@ -91,14 +91,14 @@
               style="width: 100%;"
               @blur="e => onCellBlur(e.target.value, record)"
             />
-          </template>
+          </template> -->
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
             <a-button
               size="small"
               type="link"
               v-if="$hasPermissions('B_purchaseReturnEdit')"
-              @click="handleEdit(record)"
+              @click="handleAddEdit(record)"
               class="button-info"
               id="purchaseReceiptEdit-edit-btn">编辑</a-button>
             <a-button
@@ -123,11 +123,23 @@
         id="purchaseReceiptEdit-submit">提交</a-button>
     </div>
     <!-- 新增弹窗-->
-    <add-modal v-drag :openModal="openAddModal" @ok="handleOk" @close="openAddModal=false" />
+    <add-modal
+      v-drag
+      :itemSn="itemSn"
+      :openModal="openAddModal"
+      :nowData="detailsData"
+      @ok="handleOk"
+      @close="openAddModal=false" />
     <!-- 导入弹窗 -->
     <importGuideModal :openModal="openGuideModal" :params="{sparePartsSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
     <!-- 编辑基础信息弹窗 -->
-    <basic-info-modal v-drag :openModal="openBasicInfoModal" :itemSn="sparePartsReturnSn" @ok="getBasicsData" @close="openBasicInfoModal = false" />
+    <basic-info-modal
+      v-drag
+      :openModal="openBasicInfoModal"
+      :itemData="itemObj"
+      :itemSn="sparePartsSn"
+      @ok="getBasicsData"
+      @close="openBasicInfoModal = false" />
   </div>
 </template>
 
@@ -140,15 +152,8 @@ import basicInfoModal from './basicInfoModal.vue'
 import importGuideModal from './importGuideModal.vue'
 
 // 接口
-import {
-  sparePartsReturnQueryPage,
-  queryPageCount,
-  sparePartsReturnDetailDelete,
-  sparePartsReturnDetailSave,
-  sparePartsReturnSubmit,
-  sparePartsReturnInfo,
-  sparePartsReturnDetailSaveBatch
-} from '@/api/sparePartsReturn'
+import { sparePartsPageCount } from '@/api/spareParts'
+import { purchaseDetailPageList, queryDetailCount } from '@/api/purchase'
 import { getThirdStockQty } from '@/api/salesNew'
 export default {
   name: 'PurchaseReturnEdit',
@@ -166,6 +171,7 @@ export default {
 
       isInster: false, // 是否正在添加产品
       addMoreLoading: false, // 防止多次添加  加载状态
+      loading: false,
 
       // 查询参数
       productForm: {
@@ -174,14 +180,15 @@ export default {
       },
       statisticsObj: null, // 统计明细
 
-      sparePartsReturnSn: null,
+      sparePartsSn: null, // 采购入库sn
+      itemObj: null, // 基础信息弹窗信息
       sparePartsReturnNo: null,
       chooseList: [],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        this.productForm.sparePartsReturnSn = this.sparePartsReturnSn
+        this.productForm.sparePartsSn = this.sparePartsSn
         // 获取列表数据  有分页
-        return sparePartsReturnQueryPage(Object.assign(parameter, this.productForm)).then(res => {
+        return purchaseDetailPageList(Object.assign(parameter, this.productForm)).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -195,7 +202,6 @@ export default {
           return data
         })
       },
-
       grabFlag: undefined // 备注
     }
   },
@@ -207,7 +213,7 @@ export default {
         { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
         {
           title: '产品编码',
-          dataIndex: 'product.code',
+          dataIndex: 'productCode',
           width: '18%',
           align: 'center',
           customRender: function (text) {
@@ -216,7 +222,7 @@ export default {
         },
         {
           title: '产品名称',
-          dataIndex: 'product.name',
+          dataIndex: 'productName',
           width: '25%',
           align: 'left',
           customRender: function (text) {
@@ -226,7 +232,7 @@ export default {
         },
         {
           title: '单位',
-          dataIndex: 'product.unit',
+          dataIndex: 'unit',
           align: 'center',
           width: '6%',
           customRender: function (text) {
@@ -235,8 +241,8 @@ export default {
         },
         { title: '采购数量', align: 'center', width: '13%', scopedSlots: { customRender: 'qty' } },
         {
-          title: '库存数量',
-          dataIndex: 'stockBatchNo',
+          title: '第三方库存',
+          dataIndex: 'productQty',
           align: 'center',
           width: '10%',
           customRender: function (text) {
@@ -263,26 +269,26 @@ export default {
         },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ]
-      if (this.$hasPermissions('B_purchaseReturnEdit_costPrice')) {
-        arr.splice(6, 0, {
-          title: '退货单价',
-          dataIndex: 'cost',
-          width: '8%',
-          align: 'right',
-          customRender: function (text) {
-            return text || text == 0 ? _this.toThousands(text, 2) : '--'
-          }
-        })
-        arr.splice(8, 0, {
-          title: '采购金额',
-          dataIndex: 'totalCost',
-          width: '8%',
-          align: 'right',
-          customRender: function (text) {
-            return text || text == 0 ? _this.toThousands(text, 2) : '--'
-          }
-        })
-      }
+      // if (this.$hasPermissions('B_purchaseReturnEdit_costPrice')) {
+      //   arr.splice(6, 0, {
+      //     title: '退货单价',
+      //     dataIndex: 'cost',
+      //     width: '8%',
+      //     align: 'right',
+      //     customRender: function (text) {
+      //       return text || text == 0 ? _this.toThousands(text, 2) : '--'
+      //     }
+      //   })
+      //   arr.splice(8, 0, {
+      //     title: '采购金额',
+      //     dataIndex: 'totalCost',
+      //     width: '8%',
+      //     align: 'right',
+      //     customRender: function (text) {
+      //       return text || text == 0 ? _this.toThousands(text, 2) : '--'
+      //     }
+      //   })
+      // }
       return arr
     }
   },
@@ -294,20 +300,26 @@ export default {
       }
       getThirdStockQty(params).then(res => {
         if (res.status == 200) {
-
+          this.resetTable(true)
         }
       })
     },
     // 编辑基础信息
     handleEditBase () {
+      this.itemObj = { dealerName: this.detailsData.dealerName, lockBizNo: this.detailsData.lockBizNo, bizRemark: this.detailsData.bizRemark }
       this.openBasicInfoModal = true
     },
     //  返回
     handleBack () {
       this.$router.push({ name: 'purchaseReceiptList', query: { closeLastOldTab: true } })
     },
-    // 新增产品
-    handleAdd () {
+    // 新增/编辑产品
+    handleAddEdit (row) {
+      if (this.detailsData && !this.detailsData.supplierName) {
+        this.$message.warning('供应商不能为空,请先变价基础信息!')
+        return
+      }
+      this.itemSn = (row && row.sparePartsDetailSn) ? row.sparePartsDetailSn : null
       this.openAddModal = true
     },
     // 导入产品
@@ -350,10 +362,10 @@ export default {
       this.$refs.table.refresh(flag)
     },
     //  重置
-    resetSearchForm (flag) {
+    resetSearchForm () {
       this.productForm.productName = ''
       this.productForm.productCode = ''
-      this.$refs.table.refresh(!!flag)
+      this.$refs.table.refresh(true)
     },
     saveMoreProduct (data) {
       if (this.addMoreLoading) {
@@ -439,46 +451,36 @@ export default {
     },
     // 初始化
     pageInit () {
-      this.supplierSn = this.$route.query.sn
-      this.sparePartsReturnSn = this.$route.query.returnSn
-      this.sparePartsReturnNo = this.$route.query.no
+      this.sparePartsSn = this.$route.query.sn
       this.getStatisticsData()
       this.getBasicsData()
-      this.resetSearchForm(true)
+      this.$nextTick(() => {
+        this.resetSearchForm()
+      })
     },
     getChooseList () {
       this.$refs.partQuery.pageInit(this.supplierSn, this.sparePartsReturnSn, this.detailsData ? this.detailsData.warehouseSn : undefined, this.detailsData.grabFlag)
     },
     // 获取页面统计数据
     getStatisticsData () {
-      this.getBasicsData(true)
-      queryPageCount({ sparePartsReturnSn: this.sparePartsReturnSn }).then(res => {
+      sparePartsPageCount({ sparePartsSn: this.sparePartsSn }).then(res => {
         if (res.status == 200) {
           if (res.data) {
-            res.data.totalCost = res.data && (res.data.totalCost || res.data.totalCost == 0) ? this.toThousands(res.data.totalCost, 2) : '--'
             this.statisticsObj = res.data
           } else {
             this.statisticsObj = null
           }
-        } else {
-          this.statisticsObj = null
         }
       })
     },
     // 获取基础信息
-    getBasicsData (flag) {
-      sparePartsReturnInfo({ sn: this.sparePartsReturnSn }).then(res => {
+    getBasicsData () {
+      queryDetailCount({ sn: this.sparePartsSn }).then(res => {
         if (res.status == 200) {
           this.detailsData = res.data
         } else {
           this.detailsData = null
         }
-        const _this = this
-        if (!flag) {
-          this.$nextTick(() => {
-            _this.getChooseList()
-          })
-        }
       })
     }
   },

+ 33 - 19
src/views/purchasingManagement/purchaseReceipt/list.vue

@@ -75,10 +75,10 @@
         <!-- 统计数据 -->
         <div class="tongji-bar">
           总单数:<strong>{{ totalData&&(totalData.totalRecord || totalData.totalRecord==0) ? totalData.totalRecord : '--' }}</strong>;
-          总款数:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
-          总采购数量:<strong>{{ totalData&&(totalData.totalQty || totalData.totalQty==0) ? totalData.totalQty : '--' }}</strong>;
-          <span>总采购金额:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>;</span>
-          <span>已完结金额:<strong>{{ totalData&&(totalData.totalAmount || totalData.totalAmount==0) ? toThousands(totalData.totalAmount) : '--' }}</strong>;</span>
+          总款数:<strong>{{ totalData&&(totalData.productTotalCategory || totalData.productTotalCategory==0) ? totalData.productTotalCategory : '--' }}</strong>;
+          总采购数量:<strong>{{ totalData&&(totalData.productTotalQty || totalData.productTotalQty==0) ? totalData.productTotalQty : '--' }}</strong>;
+          <span>总采购金额:<strong>{{ totalData&&(totalData.productTotalCost || totalData.productTotalCost==0) ? toThousands(totalData.productTotalCost) : '--' }}</strong>;</span>
+          <span>已完结金额:<strong>{{ totalData&&(totalData.finishProductTotalCost || totalData.finishProductTotalCost==0) ? toThousands(totalData.finishProductTotalCost) : '--' }}</strong>;</span>
         </div>
         <!-- 列表 -->
         <s-table
@@ -94,9 +94,9 @@
           :defaultLoadData="false"
           bordered>
           <!-- 采购退货单号 -->
-          <template slot="sparePartsReturnNo" slot-scope="text, record">
-            <span v-if="$hasPermissions('B_purchaseReturnDetail')" id="purchaseReceiptList-detail-btn" class="link-bule" @click="handleDetail(record)">{{ record.sparePartsReturnNo }}</span>
-            <span v-else>{{ record.sparePartsReturnNo }}</span>
+          <template slot="purchaseReceiptNo" slot-scope="text, record">
+            <span v-if="$hasPermissions('B_purchaseReturnDetail')" id="purchaseReceiptList-detail-btn" class="link-bule" @click="handleDetail(record)">{{ record.sparePartsNo }}</span>
+            <span v-else>{{ record.sparePartsNo }}</span>
           </template>
           <!-- 操作 -->
           <!-- state 待提交 WAIT_SUBMIT 待审核 WAIT_AUDIT 已完结 FINISH 审核不通过 AUDIT_REJECT -->
@@ -174,7 +174,7 @@ import reviewModal from './reviewModal.vue'
 import detailModal from './detailModal.vue'
 import uploadVoucherModal from './uploadVoucherModal.vue'
 // 接口
-import { sparePartsReturnList, sparePartsReturnDelete } from '@/api/sparePartsReturn'
+import { purchaseList, purchasePageCount, purchaseCancel } from '@/api/purchase'
 export default {
   name: 'PurchaseReceiptList',
   mixins: [commonMixin],
@@ -189,6 +189,7 @@ export default {
       queryParam: {
         beginDate: undefined,
         endDate: undefined,
+
         sparePartsReturnNo: undefined,
         supplierSn: undefined,
         returnReason: undefined,
@@ -204,11 +205,14 @@ export default {
       loadData: parameter => {
         this.disabled = true
         this.spinning = true
+        const params = Object.assign(parameter, this.queryParam)
         // 获取列表数据 有分页
-        return sparePartsReturnList(Object.assign(parameter, this.queryParam)).then(res => {
+        return purchaseList(params).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
+            // 获取统计数据
+            this.getCount(params)
             // 计算列表序号
             const no = (data.pageNo - 1) * data.pageSize
             for (var i = 0; i < data.list.length; i++) {
@@ -228,17 +232,17 @@ export default {
       const arr = [
         { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '采购单号', scopedSlots: { customRender: 'sparePartsReturnNo' }, width: '9%', align: 'center' },
-        { title: '提交时间', dataIndex: 'auditDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '供应商名称', dataIndex: 'supplier.supplierName', align: 'left', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '采购单号', scopedSlots: { customRender: 'purchaseReceiptNo' }, width: '9%', align: 'center' },
+        { title: '提交时间', dataIndex: 'updateDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '供应商名称', dataIndex: 'shippingAddr', align: 'left', width: '14%', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '采购数量', dataIndex: 'totalQty', width: '8%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '采购金额', dataIndex: 'totalCost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } },
         { title: '入库仓库', dataIndex: 'returnReasonDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '关联单号', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '客户名称', dataIndex: 'returnReasonDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '业务状态', dataIndex: 'returnReasonDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '关联单号', dataIndex: 'relationNo', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '客户名称', dataIndex: 'supplierName', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '业务状态', dataIndex: 'stateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '供应商状态', dataIndex: 'returnReasonDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '备注', dataIndex: 'returnReasonDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '备注', dataIndex: 'remark', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
       ]
       // if (this.$hasPermissions('M_purchaseReturnList_costPrice')) { //  售价权限
@@ -253,9 +257,19 @@ export default {
       this.queryParam.beginDate = date[0]
       this.queryParam.endDate = date[1]
     },
+    // 获取统计数据
+    getCount (params) {
+      purchasePageCount(params).then(res => {
+        if (res.status == 200 && res.data) {
+          this.totalData = res.data
+        } else {
+          this.totalData = null
+        }
+      })
+    },
     //  编辑
     handleEdit (row) {
-      this.$router.push({ name: 'purchaseReceiptEdit', query: { returnSn: row.sparePartsReturnSn, no: row.sparePartsReturnNo, sn: row.supplierSn } })
+      this.$router.push({ name: 'purchaseReceiptEdit', query: { sn: row.sparePartsSn } })
     },
     // 审核
     handleCheck (row) {
@@ -280,11 +294,11 @@ export default {
       const _this = this
       this.$confirm({
         title: '提示',
-        content: '删除后不可恢复,确定要进行删除吗?',
+        content: '确认取消吗?取消后不可恢复?',
         centered: true,
         onOk () {
           _this.spinning = true
-          sparePartsReturnDelete({ sn: row.sparePartsReturnSn }).then(res => {
+          purchaseCancel({ sn: row.sparePartsSn }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$refs.table.refresh()