chenrui 11 ヶ月 前
コミット
7065560290

+ 198 - 0
src/views/purchasingManagement/purchaseReceipt/basicInfoModal.vue

@@ -0,0 +1,198 @@
+<template>
+  <a-modal
+    centered
+    class="purchaseReturn-basicInfo-modal"
+    :footer="null"
+    :maskClosable="false"
+    :title="itemSn?'编辑':'新增'"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="800">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="purchaseReturn-basicInfo-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :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>
+        </a-form-model-item>
+        <a-form-model-item label="入库仓库" prop="warehouseSn" v-show="isShowWarehouse">
+          <warehouse
+            v-model="form.warehouseSn"
+            id="purchaseReturn-basicInfo-warehouseSn"
+            :disabled="itemSn?true:false"
+            isPermission
+            placeholder="请选择退货仓库"
+          />
+        </a-form-model-item>
+        <a-form-model-item label="客户名称" >
+          <span>客户名称</span>
+        </a-form-model-item>
+        <a-form-model-item label="关联单号" >
+          <span>关联单号</span>
+        </a-form-model-item>
+        <a-form-model-item label="备注">
+          <span>--</span>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button id="purchaseReturn-basicInfo-modal-back" @click="isShow = false">取消</a-button>
+        <a-button style="margin-left: 15px;" type="primary" id="purchaseReturn-modal-save" @click="handleSave">确定</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { VSelect, Upload } from '@/components'
+import supplier from '@/views/common/supplier.js'
+import warehouse from '@/views/common/chooseWarehouse.js'
+import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
+export default {
+  name: 'PurchaseReturnBasicInfoModal',
+  mixins: [commonMixin],
+  components: { VSelect, Upload, supplier, warehouse },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      spinning: false,
+      formItemLayout: {
+        labelCol: { span: 5 },
+        wrapperCol: { span: 16 }
+      },
+      form: {
+        supplierSn: undefined, // 供应商
+        returnReason: '', // 退货原因
+        explainInfo: '', // 补充说明
+        warehouseSn: undefined,
+        attachmentList: '',
+        grabFlag: 1
+      },
+      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'
+    }
+  },
+  methods: {
+    //  附件上传
+    changeAttach (file) {
+      this.attachList = JSON.parse(file)
+      this.attachList.map(item => {
+        item.fileType = item.extName
+      })
+    },
+    //  保存
+    handleSave () {
+      const _this = this
+      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) {
+              _this.$message.success(res.message)
+              setTimeout(() => {
+                _this.isShow = false
+                _this.$emit('ok', res.data)
+                _this.spinning = false
+              }, 1000)
+            } else {
+              _this.spinning = false
+            }
+          })
+        } else {
+          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: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    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
+        }
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .purchaseReturn-basicInfo-modal{
+    .ant-modal-body {
+      padding: 40px 40px 24px;
+    }
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+    .ant-form-item:nth-child(5){
+      margin-bottom: 0px !important;
+    }
+  }
+
+</style>

+ 538 - 0
src/views/purchasingManagement/purchaseReceipt/edit.vue

@@ -0,0 +1,538 @@
+<template>
+  <div class="salesReturnEdit-wrap">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-page-header :ghost="false" :backIcon="false" class="salesReturnEdit-back">
+        <!-- 自定义的二级文字标题 -->
+        <template slot="subTitle">
+          <a id="salesReturnEdit-back-btn" href="javascript:;" @click="handleBack">
+            <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>
+          <a-button type="link" size="small" class="button-default" @click="showDetail=!showDetail">
+            <a-icon :type="showDetail ? 'eye-invisible' : 'eye'"/> {{ showDetail?'隐藏':'查看' }}信息
+          </a-button>
+        </template>
+      </a-page-header>
+      <a-card size="small" :bordered="false" class="salesReturnEdit-cont" v-show="showDetail">
+        <div slot="title">
+          <span>基础信息</span>
+          <div style="cursor:pointer;color: #00aaff;float:right;" @click.stop="handleEditBase" >
+            <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>
+      </a-card>
+      <a-card size="small" :bordered="false" class="salesReturnEdit-cont">
+        <div class="table-page-search-wrapper" style="display:flex;align-items: center;justify-content: space-between;">
+          <div style="flex-grow:1;">
+            <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+              <a-row :gutter="15">
+                <a-col :md="6" :sm="24">
+                  <a-form-item label="产品编码"><a-input v-model.trim="productForm.productCode" allowClear placeholder="请输入产品编码" /></a-form-item>
+                </a-col>
+                <a-col :md="6" :sm="24">
+                  <a-form-item label="产品名称"><a-input v-model.trim="productForm.productName" allowClear placeholder="请输入产品名称" /></a-form-item>
+                </a-col>
+                <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
+                  <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
+                  <a-button style="margin-left: 5px" @click="resetSearchForm">重置</a-button>
+                </a-col>
+              </a-row>
+            </a-form>
+          </div>
+        </div>
+        <div>
+          <a-alert style="margin-bottom: 10px;" type="info">
+            <div slot="message" class="total-bar">
+              <div v-if="statisticsObj">
+                <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>
+              </div>
+            </div>
+          </a-alert>
+        </div>
+        <s-table
+          class="sTable"
+          ref="table"
+          size="small"
+          :rowKey="(record) => record.id"
+          :columns="columns"
+          :data="loadData"
+          :defaultLoadData="false"
+          :scroll="{ y: 300 }"
+          bordered>
+          <!--申请退货数量 -->
+          <template slot="qty" slot-scope="text, record">
+            <a-input-number
+              id="salesReturn-qty"
+              size="small"
+              v-model="record.qty"
+              :precision="0"
+              :min="1"
+              :max="record.qty"
+              placeholder="请输入"
+              style="width: 100%;"
+              @blur="e => onCellBlur(e.target.value, record)"
+            />
+          </template>
+          <!-- 操作 -->
+          <template slot="action" slot-scope="text, record">
+            <a-button
+              size="small"
+              type="link"
+              v-if="$hasPermissions('B_purchaseReturnEdit')"
+              @click="handleEdit(record)"
+              class="button-info"
+              id="purchaseReceiptList-edit-btn">编辑</a-button>
+            <a-button
+              size="small"
+              type="link"
+              :loading="delLoading"
+              class="button-error"
+              @click="handleDel(record)"
+              id="salesReturn-Del">删除</a-button>
+          </template>
+        </s-table>
+      </a-card>
+    </a-spin>
+    <div class="affix-cont">
+      <a-button
+        size="large"
+        style="padding: 0 60px;"
+        :disabled="spinning"
+        type="primary"
+        class="button-primary"
+        @click="beforeSubmit"
+        id="salesReturn-handleSubmit">提交</a-button>
+    </div>
+    <!-- 选择审核人员 -->
+    <chooseDepartUserModal ref="chooseDepart" :openModal="openDepartUserModal" @close="openDepartUserModal = false" @submit="handleSubmit"></chooseDepartUserModal>
+    <!-- 编辑基础信息弹窗 -->
+    <basic-info-modal v-drag :openModal="openBasicInfoModal" :itemSn="sparePartsReturnSn" @ok="getBasicsData" @close="openModal = false" />
+  </div>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { STable, VSelect } from '@/components'
+// import queryPart from './queryPart.vue'
+import basicInfoModal from './basicInfoModal.vue'
+// import chooseDepartUserModal from './chooseDepartUserModal.vue'
+import {
+  sparePartsReturnQueryPage,
+  queryPageCount,
+  sparePartsReturnDetailDelete,
+  sparePartsReturnDetailSave,
+  sparePartsReturnSubmit,
+  sparePartsReturnInfo,
+  sparePartsReturnDetailSaveBatch
+} from '@/api/sparePartsReturn'
+export default {
+  name: 'PurchaseReturnEdit',
+  mixins: [commonMixin],
+  components: { STable, VSelect, basicInfoModal },
+  data () {
+    return {
+      spinning: false,
+      isInster: false, // 是否正在添加产品
+      openDepartUserModal: false, // 审核人员弹窗
+      delLoading: false,
+      showDetail: false,
+      productForm: {
+        productName: '',
+        productCode: '',
+        sparePartsNo: '',
+        orderBy: 'sprd.CREATE_DATE DESC'
+      },
+      sparePartsReturnSn: null,
+      sparePartsReturnNo: null,
+      chooseList: [],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.productForm.sparePartsReturnSn = this.sparePartsReturnSn
+        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
+            }
+          }
+          this.chooseList = data.list
+          return data
+        })
+      },
+      openBasicInfoModal: false, // 修改基础信息弹窗
+      statisticsObj: null, // 统计明细
+      detailsData: null, // 基础信息数据
+      addMoreLoading: false, // 批量添加动画
+      grabFlag: undefined
+    }
+  },
+  computed: {
+    columns () {
+      const _this = this
+      const arr = [
+        { title: '序号', dataIndex: 'no', align: 'center', width: '4%' },
+        {
+          title: '入库单号',
+          dataIndex: 'sparePartsNo',
+          width: '18%',
+          align: 'center',
+          customRender: function (text) {
+            return text || '--'
+          }
+        },
+        {
+          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: 'stockBatchNo',
+          align: 'center',
+          width: '10%',
+          customRender: function (text) {
+            return text || '--'
+          }
+        },
+        { title: '申请退货数量', align: 'center', width: '13%', scopedSlots: { customRender: 'qty' } },
+        { 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) : '--'
+          }
+        })
+      }
+      return arr
+    }
+  },
+  methods: {
+    // 编辑基础信息
+    handleEditBase () {
+      this.openBasicInfoModal = true
+    },
+    //  返回
+    handleBack () {
+      this.$router.push({ path: `/purchasingManagement/purchaseReturn/list`, query: { closeLastOldTab: true } })
+    },
+    // 删除所选产品
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '确认要删除吗?',
+        centered: true,
+        closable: true,
+        onOk () {
+          _this.delLoading = true
+          _this.spinning = true
+          sparePartsReturnDetailDelete({ detailSn: row.sparePartsReturnDetailSn })
+            .then(res => {
+              if (res.status == 200) {
+                _this.resetTable(false)
+                _this.getStatisticsData()
+                _this.getChooseList()
+                _this.$refs.partQuery.refreshLength()
+              }
+              _this.$message.info(res.message)
+              _this.delLoading = false
+              _this.spinning = false
+            })
+            .catch(err => {
+              _this.delLoading = false
+            })
+        }
+      })
+    },
+    resetTable (flag) {
+      this.$refs.table.refresh(flag)
+    },
+    //  重置
+    resetSearchForm (flag) {
+      this.productForm.productName = ''
+      this.productForm.productCode = ''
+      this.productForm.sparePartsNo = ''
+      this.$refs.table.refresh(!!flag)
+    },
+    // 已选产品  blur
+    onCellBlur (val, record) {
+      if (val * 1 > record.putQty * 1) {
+        this.$message.warning('申请退货数量不能大于入库数量!')
+        this.$refs.table.refresh(true)
+        return
+      }
+      const ajax_data = {
+        sparePartsReturnSn: this.sparePartsReturnSn,
+        sparePartsReturnNo: this.sparePartsReturnNo,
+        sparePartsDetailSn: record.sparePartsDetailSn,
+        productSn: record.productSn,
+        sparePartsReturnDetailSn: record.sparePartsReturnDetailSn,
+        stockDetailSn: record.stockDetailSn,
+        productCode: record.productCode,
+        putQty: record.putQty, // 入库数量
+        returnedQty: record.returnedQty, // 已退数量
+        qty: val, // 申退数量
+        cost: record.cost, // 成本
+        stockBatchNo: record.stockBatchNo, // 批次号
+        warehouseSn: record.warehouseSn, // 仓库sn
+        warehouseLocationSn: record.warehouseLocationSn, // 仓位sn
+        sparePartsNo: record.sparePartsNo,
+        sparePartsSn: record.sparePartsSn
+      }
+      this.saveEdit(ajax_data)
+    },
+    // 添加或修改产品
+    saveProduct (row) {
+      if (this.isInster) {
+        // 防止多次添加产品
+        return
+      }
+      this.isInster = true
+      const paramsData = {
+        sparePartsReturnSn: this.sparePartsReturnSn,
+        sparePartsReturnNo: this.sparePartsReturnNo,
+        sparePartsDetailSn: row.sparePartsDetailSn,
+        productSn: row.productSn,
+        stockDetailSn: row.stockDetailSn,
+        productCode: row.productCode,
+        putQty: row.productQty, // 入库数量
+        returnedQty: row.returnedQty, // 已退数量
+        qty: row.qty, // 申退数量
+        cost: row.productCost, // 成本
+        stockBatchNo: row.sparePartsBatchNo, // 批次号
+        warehouseSn: row.warehouseSn, // 仓库sn
+        warehouseLocationSn: row.warehouseLocationSn, // 仓位sn
+        sparePartsNo: row.sparePartsNo,
+        sparePartsSn: row.sparePartsSn
+      }
+      this.saveEdit(paramsData)
+    },
+    saveMoreProduct (data) {
+      if (this.addMoreLoading) {
+        // 防止多次添加产品
+        return
+      }
+      this.addMoreLoading = true
+      var ajax_data = []
+      data.forEach(item => {
+        const obj = {
+          sparePartsReturnSn: this.sparePartsReturnSn,
+          sparePartsReturnNo: this.sparePartsReturnNo,
+          sparePartsDetailSn: item.sparePartsDetailSn,
+          productSn: item.productSn,
+          stockDetailSn: item.stockDetailSn,
+          productCode: item.productCode,
+          putQty: item.productQty, // 入库数量
+          returnedQty: item.returnedQty, // 已退数量
+          qty: item.qty, // 申退数量
+          cost: item.productCost, // 成本
+          stockBatchNo: item.sparePartsBatchNo, // 批次号
+          warehouseSn: item.warehouseSn, // 仓库sn
+          warehouseLocationSn: item.warehouseLocationSn, // 仓位sn
+          sparePartsNo: item.sparePartsNo,
+          sparePartsSn: item.sparePartsSn
+        }
+        ajax_data.push(obj)
+      })
+      this.saveMore(ajax_data)
+    },
+    saveEdit (params) {
+      this.spinning = true
+      sparePartsReturnDetailSave(params).then(res => {
+        if (res.status == 200) {
+          this.getStatisticsData()
+          this.$refs.table.refresh(true)
+          this.getChooseList()
+        }
+        this.isInster = false
+        this.spinning = false
+        this.addMoreLoading = false
+      }).catch(err => {
+        this.isInster = false
+      })
+    },
+    saveMore (params) {
+      this.spinning = true
+      sparePartsReturnDetailSaveBatch(params)
+        .then(res => {
+          if (res.status == 200) {
+            this.getStatisticsData()
+            this.getChooseList()
+            this.$refs.table.refresh(true)
+            this.$refs.partQuery.refreshLength()
+          }
+          this.isInster = false
+          this.spinning = false
+          this.addMoreLoading = false
+        })
+        .catch(err => {
+          this.isInster = false
+          this.addMoreLoading = false
+          this.spinning = false
+        })
+    },
+    beforeSubmit () {
+      if (this.chooseList.length > 0) {
+        this.openDepartUserModal = true
+      } else {
+        this.$message.warning('请先添加要退货的产品!')
+      }
+    },
+    // 提交采购退货
+    handleSubmit (data) {
+      this.spinning = true
+      sparePartsReturnSubmit({ sparePartsReturnSn: this.sparePartsReturnSn, ...data }).then(res => {
+        if (res.status == 200) {
+          this.handleBack()
+          this.$message.success(res.message)
+        }
+        this.spinning = false
+      })
+    },
+    pageInit () {
+      this.supplierSn = this.$route.query.sn
+      this.sparePartsReturnSn = this.$route.query.returnSn
+      this.sparePartsReturnNo = this.$route.query.no
+      this.getStatisticsData()
+      this.getBasicsData()
+      this.resetSearchForm(true)
+    },
+    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 => {
+        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 => {
+        if (res.status == 200) {
+          this.detailsData = res.data
+        } else {
+          this.detailsData = null
+        }
+        const _this = this
+        if (!flag) {
+          this.$nextTick(() => {
+            _this.getChooseList()
+          })
+        }
+      })
+    }
+  },
+  mounted () {
+    if (!this.$store.state.app.isNewTab) {
+      // 页签刷新时调用
+      this.pageInit()
+    }
+  },
+  activated () {
+    // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
+    if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
+      this.pageInit()
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
+  }
+}
+</script>
+
+<style lang="less">
+.salesReturnEdit-wrap {
+  position: relative;
+  height: 100%;
+  padding-bottom: 51px;
+  box-sizing: border-box;
+  > .ant-spin-nested-loading {
+    overflow-y: scroll;
+    height: 100%;
+  }
+  .salesReturnEdit-cont {
+    margin-top: 6px;
+    .ant-divider-horizontal {
+      margin: 10px 0 24px;
+    }
+    .total-bar {
+      display: flex;
+      align-items: center;
+      justify-content: space-between;
+      > div {
+        &:last-child {
+          display: flex;
+          align-items: center;
+          justify-content: space-between;
+          > div {
+            padding: 0 10px;
+          }
+        }
+      }
+    }
+  }
+}
+</style>

+ 377 - 0
src/views/purchasingManagement/purchaseReceipt/list.vue

@@ -0,0 +1,377 @@
+<template>
+  <div>
+    <a-card size="small" :bordered="false" class="searchBoxNormal">
+      <!-- 搜索条件 -->
+      <div ref="tableSearch" class="table-page-search-wrapper">
+        <a-form layout="inline" id="purchaseReceiptList-form" @keyup.enter.native="$refs.table.refresh(true)">
+          <a-row :gutter="15">
+            <a-col :md="6" :sm="24">
+              <a-form-item label="创建时间">
+                <rangeDate ref="rangeDate" id="purchaseReceiptList-time" @change="dateChange" />
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-item label="采购单号">
+                <a-input id="purchaseReceiptList-sparePartsNo" v-model.trim="queryParam.sparePartsNo" allowClear placeholder="请输入采购单号"/>
+              </a-form-item>
+            </a-col>
+            <a-col :md="6" :sm="24">
+              <a-form-item label="供应商名称">
+                <supplier id="purchaseReceiptList-supplierSn" v-model="queryParam.supplierSn" isPermission placeholder="请输入供应商名称"></supplier>
+              </a-form-item>
+            </a-col>
+            <template v-if="advanced">
+              <a-col :md="6" :sm="24">
+                <a-form-item label="客户名称">
+                  <custList ref="custList" id="purchaseReceiptList-buyerSn" @change="custChange"></custList>
+                </a-form-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-item label="业务状态">
+                  <v-select
+                    v-model="queryParam.state"
+                    ref="state"
+                    id="purchaseReceiptList-state"
+                    code="SPARE_PARTS_RETURN_STATE"
+                    placeholder="请选择审核状态"
+                    allowClear
+                  ></v-select>
+                </a-form-item>
+              </a-col>
+              <a-col :md="6" :sm="24">
+                <a-form-item label="关联单号">
+                  <a-input id="purchaseReceiptList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入关联单号"/>
+                </a-form-item>
+              </a-col>
+            </template>
+            <a-col :md="6" :sm="24">
+              <span class="table-page-search-submitButtons">
+                <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseReceiptList-refresh">查询</a-button>
+                <a-button style="margin-left: 10px" @click="resetSearchForm()" :disabled="disabled" id="purchaseReceiptList-reset">重置</a-button>
+                <a @click="advanced=!advanced" style="margin-left: 8px">
+                  {{ advanced ? '收起' : '展开' }}
+                  <a-icon :type="advanced ? 'up' : 'down'"/>
+                </a>
+              </span>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+    </a-card>
+    <a-card size="small" :bordered="false" class="purchaseReceiptList-wrap">
+      <a-spin :spinning="spinning" tip="Loading...">
+        <!-- 操作按钮 -->
+        <div class="table-operator">
+          <a-button v-if="$hasPermissions('B_purchaseReturnAdd')" id="purchaseReceiptList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
+          <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>
+          </div>
+        </div>
+        <!-- 列表 -->
+        <s-table
+          class="sTable fixPagination"
+          ref="table"
+          :style="{ height: tableHeight+70+'px' }"
+          size="small"
+          :rowKey="(record) => record.sparePartsReturnNo"
+          :columns="columns"
+          :data="loadData"
+          :pageSize="30"
+          :scroll="{ y: tableHeight }"
+          :defaultLoadData="false"
+          bordered>
+          <!-- 采购退货单号 -->
+          <template slot="sparePartsReturnNo" slot-scope="text, record">
+            <span v-if="$hasPermissions('B_purchaseReturnDetail')" class="link-bule" @click="handleDetail(record)">{{ record.sparePartsReturnNo }}</span>
+            <span v-else>{{ record.sparePartsReturnNo }}</span>
+          </template>
+          <!-- 操作 -->
+          <!-- state 待提交 WAIT_SUBMIT 待审核 WAIT_AUDIT 已完结 FINISH 审核不通过 AUDIT_REJECT -->
+          <template slot="action" slot-scope="text, record">
+            <a-button
+              size="small"
+              type="link"
+              v-if="$hasPermissions('B_purchaseReturnEdit')"
+              @click="handleEdit(record)"
+              class="button-info"
+              id="purchaseReceiptList-edit-btn">编辑</a-button>
+            <a-button
+              size="small"
+              type="link"
+              v-if="$hasPermissions('B_purchaseReturnDel')"
+              @click="handleDel(record)"
+              class="button-error"
+              id="purchaseReceiptList-del-btn">取消</a-button>
+          </template>
+        </s-table>
+      </a-spin>
+      <!-- 新增、详情弹窗-->
+      <add-modal v-drag :openModal="openModal" @ok="handleOk" @close="openModal=false" />
+      <detailModal v-drag :openModal="openDetailModal" :itemSn="itemSn" @close="closeDetailModal" />
+      <!-- 导出提示框 -->
+      <reportModal :visible="showExport" @close="showExport=false"></reportModal>
+      <!-- 审核进度弹窗 -->
+      <reviewProgressModal v-drag :itemSn="itemSnSh" :auditTime="auditTime" :openModal="openReviewModal" @close="openReviewModal=false"></reviewProgressModal>
+    </a-card>
+  </div>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { STable, VSelect } from '@/components'
+import rangeDate from '@/views/common/rangeDate.vue'
+import custList from '@/views/common/custList.vue'
+import reportModal from '@/views/common/reportModal.vue'
+import { hdExportExcel } from '@/libs/exportExcel'
+import supplier from '@/views/common/supplier.js'
+import warehouse from '@/views/common/chooseWarehouse.js'
+import { sparePartsReturnList, sparePartsReturnDelete, sparePartsReturnExportDetail, againSubmit } from '@/api/sparePartsReturn'
+export default {
+  name: 'PurchaseReceiptList',
+  mixins: [commonMixin],
+  components: { STable, supplier, VSelect, reportModal, custList, rangeDate, warehouse },
+  data () {
+    return {
+      spinning: false,
+      disabled: false, //  查询、重置按钮是否可操作
+      openModal: false, // 新增弹框是否显示
+      openDetailModal: false, // 详情弹窗
+      openReviewModal: false, // 审核进度弹窗
+      showExport: false,
+      exportLoading: false,
+      advanced: true,
+      tableHeight: 0,
+      // 查询参数
+      queryParam: {
+        beginDate: undefined,
+        endDate: undefined,
+        sparePartsReturnNo: undefined,
+        supplierSn: undefined,
+        returnReason: undefined,
+        warehouseSn: undefined, // 仓库
+        state: undefined
+      },
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        return sparePartsReturnList(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
+        })
+      },
+      itemSnSh: null,
+      itemSn: null, // 采购退货SN
+      auditTime: null, // 审核时间
+      totalData: null
+    }
+  },
+  computed: {
+    columns () {
+      const _this = this
+      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: '采购数量', 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: 'returnReasonDictValue', 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')) { //  售价权限
+        arr.splice(7, 0, { title: '采购金额', dataIndex: 'totalCost', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } })
+      }
+      return arr
+    }
+  },
+  methods: {
+    // 创建时间
+    dateChange (date) {
+      this.queryParam.beginDate = date[0]
+      this.queryParam.endDate = date[1]
+    },
+    //  导出
+    handleExport () {
+      const _this = this
+      _this.$store.state.app.curActionPermission = 'B_purchaseReturnExport'
+      _this.exportLoading = true
+      _this.spinning = true
+      hdExportExcel(sparePartsReturnExportDetail, _this.queryParam, '采购退货', function () {
+        _this.exportLoading = false
+        _this.spinning = false
+        _this.showExport = true
+        _this.$store.state.app.curActionPermission = ''
+      })
+    },
+    //  新增
+    handleAdd () {
+      this.openModal = true
+    },
+    //  基本信息  保存
+    handleOk (row) {
+      this.$router.push({ name: 'purchaseReturnAdd', query: { returnSn: row.sparePartsReturnSn, no: row.sparePartsReturnNo, sn: row.supplierSn } })
+    },
+    //  编辑
+    handleEdit (row) {
+      this.$router.push({ name: 'purchaseReceiptEdit', query: { returnSn: row.sparePartsReturnSn, no: row.sparePartsReturnNo, sn: row.supplierSn } })
+    },
+    // 审核进度
+    handleSH (row) {
+      this.itemSnSh = row.sparePartsReturnSn
+      this.auditTime = row.submitDate
+      const _this = this
+      _this.$nextTick(() => {
+        _this.openReviewModal = true
+      })
+    },
+    // 再次提交
+    handleResubmit (row) {
+      const _this = this
+      this.$confirm({
+        title: '操作提示',
+        content: '系统将自动生成一个新的采购退货单,新单据中的产品申退数量将以最大可用库存为准,最大可用库存为0时,系统将强制删除已选的对应产品。您可以对新单据进行编辑、提交等操作,原单据保持不变,确认操作吗?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          againSubmit({ sparePartsReturnSn: 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.sparePartsReturnSn
+      const _this = this
+      _this.$nextTick(() => {
+        _this.openDetailModal = true
+      })
+    },
+    // 关闭采购退货详情弹框
+    closeDetailModal () {
+      this.itemSn = null
+      this.openDetailModal = false
+    },
+    //  删除
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '删除后不可恢复,确定要进行删除吗?',
+        centered: true,
+        onOk () {
+          _this.spinning = true
+          sparePartsReturnDelete({ 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
+            }
+          })
+        }
+      })
+    },
+    custChange (obj) {
+      this.queryParam.buyerSn = obj.key
+    },
+    //  重置
+    resetSearchForm () {
+      this.queryParam = {
+        beginDate: undefined,
+        endDate: undefined,
+        sparePartsReturnNo: undefined,
+        supplierSn: undefined,
+        returnReason: undefined,
+        warehouseSn: undefined, // 仓库
+        state: undefined
+      }
+      this.$refs.custList.resetForm()
+      this.$refs.rangeDate.resetDate()
+      this.$refs.table.refresh(true)
+    },
+    pageInit () {
+      const _this = this
+      this.$nextTick(() => { // 页面渲染完成后的回调
+        _this.setTableH()
+      })
+      this.openModal = false
+      this.openDetailModal = false
+      this.itemSn = null
+      this.rowSelectionInfo = null
+      this.$refs.table.clearTable()
+    },
+    setTableH () {
+      const tableSearchH = this.$refs.tableSearch.offsetHeight
+      this.tableHeight = window.innerHeight - tableSearchH - 240
+    }
+  },
+  watch: {
+    advanced (newValue, oldValue) {
+      const _this = this
+      this.$nextTick(() => { // 页面渲染完成后的回调
+        _this.setTableH()
+      })
+    },
+    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时,需同时更改表格高度
+      this.setTableH()
+    }
+  },
+  mounted () {
+    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
+      this.pageInit()
+      this.resetSearchForm()
+    }
+  },
+  activated () {
+    // 如果是新页签打开,则重置当前页面
+    if (this.$store.state.app.isNewTab) {
+      this.pageInit()
+      this.resetSearchForm()
+    }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+      this.$refs.table.refresh()
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
+  }
+}
+</script>
+<style lang="less" scoped>
+  .purchaseReceiptList-wrap{
+    .table-operator{
+      display:flex;
+      align-items:center;
+    }
+
+  }
+</style>