Browse Source

采购退货

chenrui 2 years ago
parent
commit
963e6e3960

+ 48 - 26
src/views/purchasingManagement/purchaseReturn/addModal.vue

@@ -23,12 +23,14 @@
             v-model="form.sparePartsNo"
             :showSearch="true"
             option-filter-prop="children"
-            :filter-option="filterOption">
-            <a-select-option v-for="item in supplierList" :key="item.supplierSn" :value="item.supplierSn" :disabled="item.enableFlag==0">{{ item.supplierName }}</a-select-option>
+            :filter-option="filterOption"
+            @change="handleSupplierName">
+            <a-select-option v-for="item in receiptNoList" :key="item.id" :value="item.sparePartsNo">{{ item.sparePartsNo }}</a-select-option>
           </a-select>
         </a-form-model-item>
         <a-form-model-item label="供应商名称" prop="supplierSn">
-          <span>--</span>
+          <span v-if="!supplierName">--</span>
+          <span>{{ supplierName }}</span>
         </a-form-model-item>
         <a-form-model-item label="退货原因" prop="returnReason">
           <v-select
@@ -74,11 +76,10 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { VSelect, Upload } from '@/components'
-import { supplierAllList } from '@/api/supplier'
-import { sparePartsSave } from '@/api/spareParts'
+import { sparePartsList } from '@/api/spareParts'
 import { sparePartsReturnSave } from '@/api/sparePartsReturn'
 export default {
-  name: 'purchaseReturnBasicInfoModal',
+  name: 'PurchaseReturnBasicInfoModal',
   mixins: [commonMixin],
   components: { VSelect, Upload },
   props: {
@@ -96,12 +97,15 @@ export default {
         wrapperCol: { span: 16 }
       },
       form: {
-        sparePartsNo:undefined,//入库单号
+        sparePartsNo: undefined, // 入库单号
         supplierSn: undefined, // 供应商
-        returnReason:'',//退货原因
-        explainInfo: '' ,// 补充说明
-       attachmentList:undefined
+        returnReason: '', // 退货原因
+        explainInfo: '', // 补充说明
+        attachmentList: '',
+        sparePartsSn: undefined,
+        sparePartsBatchNo: undefined
       },
+      attachList: [],
       rules: {
         sparePartsNo: [
           { required: true, message: '请选择入库单号', trigger: 'change' }
@@ -111,17 +115,21 @@ export default {
         ],
         returnReason: [
           { required: true, message: '请选择退货原因', trigger: 'change' }
-        ],
-       
+        ]
+
       },
-      supplierList: [] //  供应商  下拉数据
+      receiptNoList: [], //  入库单号  下拉数据
+      page: 1,
+      pageSize: 20,
+      attachAction: process.env.VUE_APP_API_BASE_URL + '/uploadGetFileInfo',
+      supplierName: null
     }
   },
   methods: {
     //  附件上传
     changeAttach (file) {
-      this.form.attachmentList = JSON.parse(file)
-      this.form.attachmentList.map(item => {
+      this.attachList = JSON.parse(file)
+      this.attachList.map(item => {
         item.fileType = item.extName
       })
     },
@@ -133,6 +141,7 @@ export default {
       this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const form = JSON.parse(JSON.stringify(_this.form))
+          form.attachmentList = _this.attachList
           _this.spinning = true
           sparePartsReturnSave(form).then(res => {
             if (res.status == 200) {
@@ -147,7 +156,6 @@ export default {
             }
           })
         } else {
-          console.log('error submit!!')
           return false
         }
       })
@@ -157,19 +165,31 @@ export default {
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
     },
-    // 供应商下拉数据
-    getSupplierList (val) {
-      supplierAllList().then(res => {
+    // 入库单号下拉数据
+    getReceiptNoList (val) {
+      sparePartsList({ pageNo: this.page, pageSize: this.pageSize }).then(res => {
         if (res.status == 200) {
-          this.supplierList = res.data
-          if (val) { //  需将新增加的供应商回填,即不需要用户再选一下
-            this.form.supplierSn = this.supplierList[0].supplierSn
-            this.$refs.ruleForm.clearValidate('supplierSn')
-          }
+          this.receiptNoList = res.data.list
+          // if (val) { //  需将新增加的入库单号回填,即不需要用户再选一下
+          //   this.form.supplierSn = this.receiptNoList[0].supplierSn
+          //   this.$refs.ruleForm.clearValidate('supplierSn')
+          // }
         } else {
-          this.supplierList = []
+          this.receiptNoList = []
         }
       })
+    },
+    // 入库单号 -> 供应商名称等信息
+    handleSupplierName (e) {
+      const pos = this.receiptNoList.findIndex(item => { return item.sparePartsNo == e })
+      this.supplierName = this.receiptNoList[pos].supplierName
+      const obj = {
+        sparePartsSn: this.receiptNoList[pos].sparePartsSn,
+        sparePartsNo: e,
+        supplierSn: this.receiptNoList[pos].supplierSn,
+        sparePartsBatchNo: this.receiptNoList[pos].sparePartsBatchNo
+      }
+      Object.assign(this.form, obj)
     }
   },
   watch: {
@@ -181,9 +201,11 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+        this.attachList = []
+        this.supplierName = null
         this.$refs.ruleForm.resetFields()
       } else {
-        this.getSupplierList()
+        this.getReceiptNoList()
       }
     }
   }

+ 0 - 12
src/views/purchasingManagement/purchaseReturn/chooseDepartUserModal.vue

@@ -81,17 +81,12 @@ export default {
         wrapperCol: { span: 16 }
       },
       form: {
-        salesReturnType: undefined,
         applyPersonSn: undefined,
         approvers: [], // 审批人
         ccList: [] // 抄送人
       },
       attachList: [],
-      attachAction: process.env.VUE_APP_API_BASE_URL + '/uploadGetFileInfo',
       rules: {
-        salesReturnType: [
-          { required: true, message: '请选择退货类型', trigger: 'change' }
-        ],
         applyPersonSn: [
           { required: true, message: '请选择申请人员', trigger: 'change' }
         ],
@@ -108,13 +103,6 @@ export default {
         this.$refs.ruleForm.validateField(['applyPersonSn'])
       })
     },
-    //  附件上传
-    changeAttach (file) {
-      this.attachList = JSON.parse(file)
-      this.attachList.map(item => {
-        item.fileType = item.extName
-      })
-    },
     updateUser () {
       this.uploading = true
       this.$refs.departUserApp.updateDeptUser()

+ 9 - 7
src/views/purchasingManagement/purchaseReturn/detailModal.vue

@@ -21,7 +21,7 @@
       <!-- 退货金额 -->
       <a-alert type="info" style="margin-bottom:10px">
         <div slot="message">
-          <span>退货金额 <strong>{{ (statisticsObj && (statisticsObj.returnAmount || statisticsObj.returnAmount==0)) ? toThousands(statisticsObj.returnAmount) : '--' }}</strong></span>
+          <span>退货金额:<strong>{{ statisticsObj.totalCost }}</strong></span>
         </div>
       </a-alert>
       <s-table
@@ -48,7 +48,7 @@
 <script>
 import { STable } from '@/components'
 import { sparePartsReturnQueryPage, queryPageCount } from '@/api/sparePartsReturn'
-import { toThousands } from '@/libs/tools.js'
+import { toFixedDecimal } from '@/libs/tools.js'
 export default {
   name: 'ConfirmationDetailModal',
   components: { STable },
@@ -96,12 +96,12 @@ export default {
       const arr = [
         { title: '序号', dataIndex: 'no', width: '7%', align: 'center' },
         { title: '产品编码', dataIndex: 'productCode', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'productName', width: '45%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '单位', dataIndex: 'putQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '产品名称', dataIndex: 'product.name', width: '45%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '单位', dataIndex: 'product.unit', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
         { title: '入库数量', dataIndex: 'putQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '退货单价', dataIndex: 'putCost', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '申请退货数量', dataIndex: 'putQty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '退货金额', dataIndex: 'putCost', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
+        { title: '退货单价', dataIndex: 'cost', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '申请退货数量', dataIndex: 'qty', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '退货金额', dataIndex: 'totalCost', width: '14%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
       ]
       return arr
     },
@@ -122,7 +122,9 @@ export default {
     getStatisticsData () {
       queryPageCount({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
+          res.data.totalCost =(res.data&&(res.data.totalCost ||res.data.totalCost==0))  ? toFixedDecimal(res.data.totalCost,2):'--'
           this.statisticsObj = res.data
+          
         } else {
           this.statisticsObj = null
         }

+ 27 - 20
src/views/purchasingManagement/purchaseReturn/list.vue

@@ -104,13 +104,6 @@
         </template>
         <!-- 操作 -->
         <template slot="action" slot-scope="text, record">
-          <a-button
-            size="small"
-            type="link"
-            class="button-warning"
-            v-if="record.state == 'WAIT_AUDIT'"
-            @click="openReviewModal = true"
-            id="allocateBillList-examine-btn">审核</a-button>
           <a-button
             size="small"
             type="link"
@@ -136,7 +129,7 @@
             size="small"
             type="link"
             v-if="record.state == 'NOAGREE_AUDIT'"
-            @click="handleEdit(record)"
+            @click="handleResubmit(record)"
             class="button-info"
             id="bulkWarehousingOrderList-edit-btn">再次提交</a-button>
           <a-button
@@ -155,8 +148,6 @@
     <sparePartsDetailModal v-drag :openModal="openWarehousingDetailModal" :itemSn="warehousingSn" @close="closeWarehousingDetailModal" />
     <!-- 导出提示框 -->
     <reportModal :visible="showExport" @close="showExport=false"></reportModal>
-    <!-- 选择审核人员 -->
-    <chooseDepartUserModal v-drag :openModal="openDepartUserModal" @close="openDepartUserModal=false" @submit="handleSubmit"></chooseDepartUserModal>
     <!-- 审核进度弹窗 -->
     <reviewProgressModal v-drag :openModal="openReviewModal" @close="openReviewModal=false"></reviewProgressModal>
   </a-card>
@@ -174,7 +165,7 @@ import reviewProgressModal from './reviewProgressModal.vue'
 import reportModal from '@/views/common/reportModal.vue'
 import { hdExportExcel } from '@/libs/exportExcel'
 import { toFixedDecimal } from '@/libs/tools.js'
-import { sparePartsReturnList, sparePartsReturnDelete, sparePartsReturnSave, sparePartsAudit, sparePartsDetailExport } from '@/api/sparePartsReturn'
+import { sparePartsReturnList, sparePartsReturnDelete, sparePartsAudit, sparePartsDetailExport, againSubmit } from '@/api/sparePartsReturn'
 export default {
   name: 'PurchaseReturnList',
   mixins: [commonMixin],
@@ -211,7 +202,6 @@ export default {
         { title: '审核状态', dataIndex: 'stateDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '9%', align: 'center' }
       ],
-      openDepartUserModal: false,
       loading: false,
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
@@ -266,15 +256,36 @@ export default {
     },
     //  基本信息  保存
     handleOk (row) {
-      this.$router.push({ path: `/purchasingManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsSn}` })
+      this.$router.push({ path: `/purchasingManagement/purchaseReturn/add/${row.sparePartsReturnSn}/${row.sparePartsNo}` })
     },
     //  编辑
     handleEdit (row) {
-      this.$router.push({ path: `/purchasingManagement/purchaseReturn/purchaseReturnDeatil` })
+      this.$router.push({ path: `/purchasingManagement/purchaseReturn/edit/${row.sparePartsReturnSn}/${row.sparePartsNo}` })
+    },
+    // 再次提交
+    handleResubmit (row) {
+      const _this = this
+      this.$confirm({
+        title: '操作提示',
+        content: '系统将自动生成一个新的采购退货单,新单据中的产品申退数量将以最大可用库存为准,最大可用库存为0时,系统将强制删除已选的对应产品。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          againSubmit({ sn: row.sparePartsReturnSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+              _this.spinning = false
+            } else {
+              _this.spinning = false
+            }
+          })
+        }
+      })
     },
     //  采购退货详情
     handleDetail (row) {
-      this.itemSn = row.sparePartsReturnNo
+      this.itemSn = row.sparePartsReturnSn
       this.openDetailModal = true
     },
     // 入库单详情
@@ -301,7 +312,7 @@ export default {
         centered: true,
         onOk () {
           _this.spinning = true
-          sparePartsReturnDelete({ sn: row.sparePartsReturnNo }).then(res => {
+          sparePartsReturnDelete({ sn: row.sparePartsReturnSn }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
               _this.$refs.table.refresh()
@@ -380,10 +391,6 @@ export default {
       const tableSearchH = this.$refs.tableSearch.offsetHeight
       this.tableHeight = window.innerHeight - tableSearchH - 235
     },
-    handleAuditModalShow (row) {
-      this.auditInfo = row
-      this.openDepartUserModal = true
-    },
     // 提交
     handleSubmit (data) {
 

+ 93 - 80
src/views/purchasingManagement/purchaseReturn/purchaseReturnDeatil.vue

@@ -26,17 +26,16 @@
         </a-collapse>
       </a-card>
       <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
-        <!-- 查询配件列表 -->
-        <div>已入库产品信息</div>
-        <a-divider />
+        <!-- <div>已入库产品信息</div>
+        <a-divider /> -->
         <queryPart ref="partQuery" :newLoading="isInster" @add="saveProduct"></queryPart>
       </a-card>
       <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
         <a-alert style="margin-bottom: 10px;" type="info">
           <div slot="message" class="total-bar">
-            <div>
-              <span>申请退货数量:{{ ordeDetail&&(ordeDetail.totalInitialQty || ordeDetail.totalInitialQty==0) ? ordeDetail.totalInitialQty : '--' }};</span>
-              <span v-if="$hasPermissions('B_isShowPrice')">退货金额:{{ ordeDetail&&(ordeDetail.totalAmount || ordeDetail.totalAmount==0) ? ordeDetail.totalAmount : '--' }}元;</span>
+            <div v-if="statisticsObj">
+              <span>申请退货数量:{{ (statisticsObj.returnedQty || statisticsObj.returnedQty==0) ? statisticsObj.returnedQty : '--' }};</span>
+              <span>退货金额:{{ statisticsObj.totalCost }}元;</span>
             </div>
           </div>
         </a-alert>
@@ -73,23 +72,20 @@
           :defaultLoadData="false"
           :scroll="{ y: 300 }"
           bordered>
-          <!-- 本次退货数量 -->
-          <template slot="qty" slot-scope="text, record">
+          <!--申请退货数量 -->
+          <template slot="returnQty" slot-scope="text, record">
             <a-input-number
               id="salesReturn-qty"
               size="small"
-              v-model="record.initialQty"
+              v-model="record.returnedQty"
               :precision="0"
               :min="0"
-              :max="999999"
+              :max="record.returnedQty"
               placeholder="请输入"
-              @blur="e => onCellBlur(e.target.value, record, 'qty')"
-              style="width: 100%;" />
-          </template>
-          <!-- 退货原因 -->
-          <template slot="returnReason" slot-scope="text, record">
-            <returnReason v-model="record.returnReason" @blur="updateReason(record)"></returnReason>
+              style="width: 100%;"
+               @blur="e => onCellBlur(e.target.value, record, 'qty')"/>
           </template>
+          
           <!-- 操作 -->
           <template slot="action" slot-scope="text, record">
             <a-button
@@ -110,11 +106,11 @@
         :disabled="spinning"
         type="primary"
         class="button-primary"
-        @click="beforeSubmit()"
+        @click="beforeSubmit"
         id="salesReturn-handleSubmit">提交</a-button>
     </div>
     <!-- 选择审核人员 -->
-    <!-- <chooseDepartUserModal ref="chooseDepart" :openModal="openDepartUserModal" @close="openDepartUserModal=false" @submit="handleSubmit"></chooseDepartUserModal> -->
+    <chooseDepartUserModal ref="chooseDepart" :openModal="openDepartUserModal" @close="openDepartUserModal=false" @submit="handleSubmit"></chooseDepartUserModal>
     <!-- 导入产品 -->
     <!-- <importGuideModal :openModal="openGuideModal" :params="{salesReturnBillSn: $route.params.sn}" @close="closeGuideModel" @ok="hanldeOk" /> -->
     <!-- 批量设置退货原因 -->
@@ -140,7 +136,7 @@ import queryPart from './queryPart.vue'
 import addModal from './addModal.vue'
 import commonModal from '@/views/common/commonModal.vue'
 import EditableCell from '@/views/common/editInput.js'
-// import chooseDepartUserModal from './chooseDepartUserModal.vue'
+import chooseDepartUserModal from './chooseDepartUserModal.vue'
 import returnReason from '@/views/common/returnReason'
 import {
   salesReturnDetail,
@@ -157,8 +153,10 @@ import {
   salesReturnDetailUpdateReason,
   salesReturnDetailSetReason
 } from '@/api/salesReturnDetail'
+import { sparePartsReturnQueryPage, queryPageCount,sparePartsReturnDetailDelete,sparePartsReturnDetailSave,sparePartsReturnSubmit} from '@/api/sparePartsReturn'
+import { toFixedDecimal } from '@/libs/tools.js'
 export default {
-  name: 'PurchaseReturnDeatil',
+  name: 'purchaseReturnEdit',
   mixins: [commonMixin],
   components: {
     STable,
@@ -167,7 +165,8 @@ export default {
     returnReason,
     commonModal,
     queryPart,
-    addModal
+    addModal,
+    chooseDepartUserModal
   },
   data () {
     return {
@@ -183,29 +182,38 @@ export default {
       // 已选产品
       dataSource: [],
       productForm: {
-        salesReturnBillSn: '',
+        sn: '',
         productName: '',
         productCode: ''
       },
       chooseLoadData: [],
+      columns :[
+        { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
+        { title: '产品编码', dataIndex: 'product.code', width: '18%', align: 'center', customRender: function (text) { return text || '--' }},
+        { title: '产品名称', dataIndex: 'product.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '单位', dataIndex: 'product.unit', align: 'center', width: '6%', customRender: function (text) { return text || '--' }},
+        { title: '退货单价', dataIndex: 'cost', align: 'center', width: '8%',customRender: function (text) { return text || '--' }},
+        { title: '申请退货数量', align: 'center', width: '13%', scopedSlots: { customRender: 'returnQty' }},
+        { title: '退款金额', dataIndex: 'totalCost', align: 'center', width: '13%',  customRender: function (text) { return text || '--' }},
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
+      ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        // 查询总计
-        this.productForm.salesReturnBillSn = '481487002858102784'
-        return salesReturnDetailList(Object.assign(parameter, this.productForm)).then(res => {
+        this.productForm.sn = this.$route.params.returnSn;
+        return sparePartsReturnQueryPage(Object.assign(parameter, this.productForm)).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
-              data.list[i].qtyBackups = data.list[i].initialQty
-              data.list[i].returnReasonBackups = data.list[i].returnReason
+              // data.list[i].qtyBackups = data.list[i].initialQty
+              // data.list[i].returnReasonBackups = data.list[i].returnReason
             }
             this.disabled = false
-            this.chooseLoadData = data.list
-            this.total = res.data.count
+            // this.chooseLoadData = data.list
+            // this.total = res.data.count
           }
           return data
         })
@@ -215,7 +223,8 @@ export default {
       rowSelectionInfo: null,
       plReturnReason: '',
       showPlModal: false,
-      openModal: false
+      openModal: false,
+      statisticsObj:null
     }
   },
   watch: {
@@ -228,23 +237,6 @@ export default {
   computed: {
     selNums () {
       return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
-    },
-    columns () {
-      const arr = [
-        { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
-        { title: '产品编码', dataIndex: 'productEntity.code', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'productEntity.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '单位', dataIndex: 'productEntity.unit', align: 'center', width: '6%', customRender: function (text) { return text || '--' } },
-        { title: '退货单价', dataIndex: 'initialQty', align: 'center', width: '8%', scopedSlots: { customRender: 'qty' } },
-        { title: '申请退款数量', dataIndex: 'returnReason', align: 'center', width: '13%', scopedSlots: { customRender: 'returnReason' } },
-        { title: '退款金额', dataIndex: 'returnReason', align: 'center', width: '13%', scopedSlots: { customRender: 'returnReason' } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
-      ]
-      // if (this.$hasPermissions('B_isShowPrice')) { //  售价权限
-      //   arr.splice(4, 0, { title: '参考退货单价', dataIndex: 'price', align: 'center', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
-      //   arr.splice(7, 0, { title: '参考退货金额', align: 'center', dataIndex: 'totalAmount', width: '8%', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
-      // }
-      return arr
     }
   },
   methods: {
@@ -344,7 +336,7 @@ export default {
         this.ordeDetail = res.data || null
       })
     },
-    // 删除产品
+    // 删除所选产品
     handleDel (row) {
       const _this = this
       this.$confirm({
@@ -355,7 +347,7 @@ export default {
         onOk () {
           _this.delLoading = true
           _this.spinning = true
-          salesReturnDetailDel({ salesReturnDetailSn: row.salesReturnDetailSn }).then(res => {
+          sparePartsReturnDetailDelete({ detailSn: row.sparePartsReturnDetailSn }).then(res => {
             if (res.status == 200) {
               _this.resetTable(false)
             }
@@ -368,60 +360,69 @@ export default {
     },
     resetTable (flag) {
       this.$refs.table.refresh(flag)
-      this.getOrderDetail()
+      // this.getOrderDetail()
     },
     //  重置
     resetSearchForm (flag) {
       this.productForm.productName = ''
       this.productForm.productCode = ''
       this.$refs.table.refresh(!!flag)
-      this.getOrderDetail()
+      // this.getOrderDetail()
     },
     // 添加或修改产品
     saveProduct (row) {
-      // 防止多次添加产品
-      if (this.isInster) {
+      if (this.isInster) {// 防止多次添加产品
         return
       }
       this.isInster = true
-      const params = {
-        'salesReturnBillSn': this.orderSn,
-        'salesReturnBillNo': this.ordeDetail.salesReturnBillNo,
-        'price': row.productPrice,
-        'cost': row.lastStockCost,
-        'returnReason': row.returnReason,
-        'productSn': row.productSn,
-        'initialQty': row.qty
+      const paramsData = {
+        'sparePartsReturnSn': this.orderSn,
+        'sparePartsReturnNo': this.ordeDetail.salesReturnBillNo,
+        'sparePartsDetailSn': row.productPrice,
+        'productSn': row.lastStockCost,
+        'productCode': row.returnReason,
+        'putQty': row.productSn,
+        'returnedQty': row.qty,
+        'qty': row.qty,
+        'cost': row.qty,
+        'stockBatchNo': row.qty,
+        'warehouseSn': row.qty,
+        'warehouseLocationSn': row.qty
       }
       this.spinning = true
-      salesReturnDetailInsert(params).then(res => {
+      this.saveEdit(paramsData);
+    },
+    saveEdit(params){
+      sparePartsReturnDetailSave(params).then(res => {
         if (res.status == 200) {
           this.resetSearchForm(true)
-          this.$message.success(res.message)
+          // this.$message.success(res.message)
         }
         this.isInster = false
         this.spinning = false
       })
     },
+    
     beforeSubmit () {
-      if (this.total) {
-        const hasKong = this.chooseLoadData.find(item => !item.returnReason)
-        if (hasKong) {
-          this.$message.warning('请输入退货原因!')
-        } else {
-          this.openDepartUserModal = true
-          if (this.ordeDetail.billStatus == 'AUDIT_REJECT') {
-            this.$refs.chooseDepart.getDetail(this.ordeDetail)
-          }
-        }
-      } else {
-        this.$message.warning('请添加产品!')
-      }
+       this.openDepartUserModal = true
+      // if (this.total) {
+      //   const hasKong = this.chooseLoadData.find(item => !item.returnReason)
+      //   if (hasKong) {
+      //     this.$message.warning('请输入退货原因!')
+      //   } else {
+      //     this.openDepartUserModal = true
+      //     if (this.ordeDetail.billStatus == 'AUDIT_REJECT') {
+      //       this.$refs.chooseDepart.getDetail(this.ordeDetail)
+      //     }
+      //   }
+      // } else {
+      //   this.$message.warning('请添加产品!')
+      // }
     },
     // 提交销售退货
     handleSubmit (data) {
       this.spinning = true
-      salesReturnSubmit({ salesReturnBillSn: this.orderSn, ...data }).then(res => {
+      sparePartsReturnSubmit({ sparePartsReturnSn: this.sparePartsReturnSn, ...data }).then(res => {
         if (res.status == 200) {
           this.handleBack()
           this.$message.success(res.message)
@@ -460,16 +461,28 @@ export default {
       }
     },
     pageInit () {
-      this.orderSn = this.$route.params.sn
-      this.buyerSn = this.$route.params.buyerSn
+      this.sparePartsNo = this.$route.params.no
+      this.sparePartsReturnSn = this.$route.params.returnSn
       this.resetSearchForm(true)
-      this.$refs.partQuery.pageInit(this.buyerSn, 0)
+      this.$refs.partQuery.pageInit(this.sparePartsNo, 0)
+    },
+    getStatisticsData () {
+      queryPageCount({ sn: this.$route.params.returnSn }).then(res => {
+        if (res.status == 200) {
+          res.data.totalCost =(res.data&&(res.data.totalCost ||res.data.totalCost==0))  ? toFixedDecimal(res.data.totalCost,2):'--'
+          this.statisticsObj = res.data
+        } else {
+          this.statisticsObj = null
+        }
+      })
     }
   },
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
       this.pageInit()
     }
+    // 获取页面统计数据
+    this.getStatisticsData();
   },
   activated () {
     // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面

+ 18 - 52
src/views/purchasingManagement/purchaseReturn/queryPart.vue

@@ -71,15 +71,6 @@
           <returnReason v-model="record.returnReason"></returnReason>
         </div>
       </template>
-      <span slot="customTitle">
-        操作
-        <a-popover>
-          <template slot="content">
-            双击列表配件可快速选中添加
-          </template>
-          <a-icon type="question-circle" theme="twoTone" />
-        </a-popover>
-      </span>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
         <a-button
@@ -97,7 +88,7 @@
 </template>
 
 <script>
-import { queryStockProductPage } from '@/api/stock'
+import { queryDetailStockPage } from '@/api/spareParts'
 import returnReason from '@/views/common/returnReason'
 import { STable, VSelect } from '@/components'
 export default {
@@ -117,19 +108,30 @@ export default {
   },
   data () {
     return {
-      buyerSn: '',
+      buyerNo: '',
       priceType: '',
       queryParam: { //  查询条件
         productName: '', // 产品名称
         productCode: '' //  产品编码
       },
       disabled: false, //  查询、重置按钮是否可操作
-      columns: [],
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
+        { title: '产品编码', dataIndex: 'productCode', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '产品名称', dataIndex: 'productName', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '入库单价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
+        { title: '入库数量', dataIndex: 'qty', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '已退数量', dataIndex: 'qty', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '最大可退数量', dataIndex: 'qty', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '申请退货数量', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
+        { slots: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
+      ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
-        this.queryParam.dealerSn = this.buyerSn
-        return queryStockProductPage(Object.assign(parameter, this.queryParam)).then(res => {
+        this.queryParam.sparePartsNo = this.buyerNo
+        return queryDetailStockPage(Object.assign(parameter, this.queryParam)).then(res => {
           let data
           if (res.status == 200) {
             data = res.data
@@ -147,50 +149,14 @@ export default {
     }
   },
   methods: {
-    // 双击列表选择配件
-    handleClickRow (record) {
-      const _this = this
-      return {
-        on: {
-          dblclick: (event) => {
-            event.stopPropagation()
-            if (record.productPrice) {
-              _this.$emit('add', record)
-            }
-          }
-        }
-      }
-    },
     //  重置
     resetSearchForm () {
       this.queryParam.productName = ''
       this.queryParam.productCode = ''
       this.$refs.table.refresh(true)
     },
-    pageInit (buyerSn) {
-      this.buyerSn = buyerSn
-      const arr = [
-        { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
-        { title: '产品编码', dataIndex: 'productCode', width: '24%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'productName', width: '27%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '入库单价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
-        { title: '入库数量', dataIndex: 'qty', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
-        { title: '已退数量', dataIndex: 'qty', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
-        { title: '最大可退数量', dataIndex: 'qty', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
-        { title: '申请退货数量', dataIndex: 'qty', width: '9%', align: 'center', scopedSlots: { customRender: 'qty' } },
-        { slots: { title: 'customTitle' }, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
-      ]
-      // let i = 5
-      // if (this.$hasPermissions('B_isShowPrice') && this.isShowPrice) { //  售价权限
-      //   arr.splice(4, 0, { title: '当前售价', dataIndex: 'productPrice', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
-      //   i = 6
-      // }
-      // // 实收数量是否显示
-      // if (this.showReceiveQty) {
-      //   arr.splice(i, 0, { title: '仓库实收数量', dataIndex: 'receiveQty', width: '9%', align: 'center', scopedSlots: { customRender: 'receiveQty' } })
-      // }
-      this.columns = arr
+    pageInit (buyerNo) {
+      this.buyerNo = buyerNo
       this.resetSearchForm()
     },
     // 选择配件