lilei пре 2 година
родитељ
комит
a5b6ec7a7a

+ 2 - 2
src/api/salesReturn.js

@@ -63,7 +63,7 @@ export const salesReturnPay = (params) => {
 //  销售退货 打印预览
 export const salesReturnPrint = (params) => {
   return axios.request({
-    url: `/salesReturn/print/${params.sn}/${params.status}`,
+    url: `/salesReturn/print/${params.sn}/${params.priceType}`,
     method: 'get',
     responseType: 'blob'
   })
@@ -72,7 +72,7 @@ export const salesReturnPrint = (params) => {
 //  销售退货 导出
 export const salesReturnExport = (params) => {
   return axios.request({
-    url: `/salesReturn/export/${params.sn}/${params.status}`,
+    url: `/salesReturn/export/${params.sn}/${params.priceType}`,
     method: 'get',
     responseType: 'blob'
   })

+ 20 - 8
src/views/salesReturnManagement/salesReturn/detail.vue

@@ -105,8 +105,8 @@
         </a-tabs>
       </a-card>
     </a-spin>
-    <!-- 打印 -->
-    <div id="print"></div>
+    <!-- 打印导出 -->
+    <print-modal :openModal="openModal" :itemData="detailData" :nowType="nowType" @ok="handleOk" @close="openModal=false" />
   </div>
 </template>
 
@@ -115,16 +115,18 @@ import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import { printFun, exportExcel } from '@/libs/JGPrint.js'
 import auditDetail from '@/views/common/auditDetail.vue'
+import printModal from './printModal.vue'
 import { salesReturnDetail, salesReturnChangeLogList, salesReturnPrint, salesReturnExport } from '@/api/salesReturn'
 import { salesReturnDetailList } from '@/api/salesReturnDetail'
 export default {
   name: 'SalesReturnDetail',
   mixins: [commonMixin],
-  components: { STable, VSelect, auditDetail },
+  components: { STable, VSelect, auditDetail, printModal },
   data () {
     return {
       spinning: false,
       disabled: false,
+      openModal: false,
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         this.disabled = true
@@ -145,6 +147,7 @@ export default {
       },
       chooseLoadData: [],
       detailData: null, //  详情数据
+      nowType: '',
       visibleAudit: false,
       spinningAudit: false,
       curTab: 1,
@@ -231,19 +234,28 @@ export default {
     },
     // 打印预览/快捷打印
     handlePrint (type) {
-      const _this = this
       const a = ['WAIT_CUSTOMER_SERVICE_CONFIRM', 'WAIT_FINANCIAL_AUDIT', 'FINANCIAL_REJECT', 'FINISH'].find(item => item == this.detailData.billStatus)
-      const status = a ? 'SALES_RETURN_AMOUNT' : 'SALES_RETURN_REASON'
-      const params = { sn: this.$route.params.sn, status: status }
+      this.nowType = type
+      // 选择是否导出价格
+      if (a) {
+        this.openModal = true
+      } else {
+        this.handleOk({ priceType: 'SALES_RETURN_REASON' })
+      }
+    },
+    // 确定打印或预览
+    handleOk (objs) {
+      const _this = this
+      const params = { sn: this.$route.params.sn, priceType: objs.priceType }
       _this.spinning = true
       // 导出
-      if (type == 'export') {
+      if (this.nowType == 'export') {
         exportExcel(salesReturnExport, params, '销售退货', function () {
           _this.spinning = false
         })
       } else {
         // 打印或预览
-        printFun(salesReturnPrint, params, type, '销售退货', () => {
+        printFun(salesReturnPrint, params, this.nowType, '销售退货', () => {
           _this.spinning = false
         })
       }

+ 122 - 0
src/views/salesReturnManagement/salesReturn/printModal.vue

@@ -0,0 +1,122 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    class="sales-print-type-modal"
+    :title="modalTit"
+    v-model="isShow"
+    @cancel="isShow=false"
+    :width="600">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="sales-print-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="销售退货单号">{{ itemData&&itemData.salesReturnBillNo || '--' }}</a-form-model-item>
+        <a-form-model-item label="销售退货对象">{{ itemData&&itemData.buyerName || '--' }}</a-form-model-item>
+        <a-form-model-item label="退货价格" prop="priceType">
+          <a-radio-group v-model="form.priceType">
+            <a-radio value="SALES_RETURN_AMOUNT">{{ nowType=='export' ? '导出' : '打印' }}</a-radio>
+            <a-radio value="SALES_RETURN">不{{ nowType=='export' ? '导出' : '打印' }}</a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button id="sales-print-back" @click="handleCancel">取消</a-button>
+        <a-button type="primary" id="sales-print-save" @click="handleSave()" style="margin-left: 15px;">确定</a-button>
+      </div>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+export default {
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemData: {
+      type: Object,
+      default: () => {
+        return null
+      }
+    },
+    nowType: {
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      form: {
+        priceType: undefined
+      },
+      rules: {
+        priceType: [{ required: true, message: '请选择退货价格', trigger: 'change' }]
+      },
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 }
+      },
+      spinning: false,
+      typeList: []
+    }
+  },
+  computed: {
+    modalTit () {
+      return this.nowType == 'export' ? '导出Excel' : '销售退货打印'
+    }
+  },
+  methods: {
+    // 确认
+    handleSave () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          const obj = {
+            priceType: _this.form.priceType
+          }
+          _this.$emit('ok', obj)
+          _this.isShow = false
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 取消选择分类
+    handleCancel () {
+      this.isShow = false
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .sales-print-type-modal{
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>