Browse Source

下推详情加导出excel

chenrui 3 years ago
parent
commit
a106fc0bd6

+ 11 - 0
src/api/dispatch.js

@@ -81,3 +81,14 @@ export const dispatchDetailType = (params) => {
     method: 'get'
     method: 'get'
   })
   })
 }
 }
+// 下推 详情  导出Excel
+export const dispatchDetailExcel = params => {
+  const url = `/dispatch/excel/${params.printType}`
+  delete params.printType
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post',
+    responseType: 'blob'
+  })
+}

+ 29 - 3
src/views/salesManagement/pushOrderManagement/detail.vue

@@ -6,6 +6,13 @@
           <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
           <a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
         </template>
         </template>
         <template slot="extra" v-if="$hasPermissions('B_dispatchPrint')">
         <template slot="extra" v-if="$hasPermissions('B_dispatchPrint')">
+          <a-button
+            key="3"
+            type="primary"
+            class="button-warning"
+            id="purchaseOrderDetail-export-btn"
+            :disabled="localDataSource.length==0"
+            @click="openExcelModal=true">导出Excel</a-button>
           <a-button
           <a-button
             key="2"
             key="2"
             type="primary"
             type="primary"
@@ -79,6 +86,8 @@
     </a-spin>
     </a-spin>
     <!-- 分类打印 -->
     <!-- 分类打印 -->
     <choose-type-modal :openModal="openModal" :outBizSubSn="outBizSubSn" @ok="handleOk" @close="openModal=false" />
     <choose-type-modal :openModal="openModal" :outBizSubSn="outBizSubSn" @ok="handleOk" @close="openModal=false" />
+    <!-- 导出Excel -->
+    <export-excel-modal :openModal="openExcelModal" :itemData="detailData" @ok="handleExcelOk" @close="openExcelModal=false" />
     <!-- 打印 -->
     <!-- 打印 -->
     <div id="print"></div>
     <div id="print"></div>
   </div>
   </div>
@@ -87,10 +96,12 @@
 <script>
 <script>
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import chooseTypeModal from './chooseTypeModal.vue'
 import chooseTypeModal from './chooseTypeModal.vue'
-import { dispatchDetaillList, dispatchFindBySn, dispatchDetailPrint } from '@/api/dispatch'
+import exportExcelModal from './exportExcelModal.vue'
+import { hdExportExcel } from '@/libs/exportExcel'
+import { dispatchDetaillList, dispatchFindBySn, dispatchDetailPrint, dispatchDetailExcel } from '@/api/dispatch'
 export default {
 export default {
   name: 'SalesDetail',
   name: 'SalesDetail',
-  components: { STable, VSelect, chooseTypeModal },
+  components: { STable, VSelect, chooseTypeModal, exportExcelModal },
   props: {
   props: {
     outBizSubSn: { //  有值则为弹框,无值则为页面
     outBizSubSn: { //  有值则为弹框,无值则为页面
       type: [Number, String],
       type: [Number, String],
@@ -146,7 +157,8 @@ export default {
       detailData: null, //  详情数据
       detailData: null, //  详情数据
       openModal: false,
       openModal: false,
       localDataSource: [],
       localDataSource: [],
-      nowPrintType: '' //  当前打印类型
+      nowPrintType: '', //  当前打印类型
+      openExcelModal: false
     }
     }
   },
   },
   methods: {
   methods: {
@@ -164,6 +176,18 @@ export default {
         }
         }
       })
       })
     },
     },
+    // 导出Excel
+    handleExcelOk(priceType){
+      const _this = this
+      const params = {
+        dispatchBillSn: this.outBizSubSn || this.$route.params.sn,
+        printType: priceType
+      }
+      this.spinning = true
+      hdExportExcel(dispatchDetailExcel, params, '产品导出', function () {
+        _this.spinning = false
+      })
+    },
     // 分类选择
     // 分类选择
     handleOk (obj) {
     handleOk (obj) {
       this.requestFun(obj)
       this.requestFun(obj)
@@ -214,6 +238,7 @@ export default {
   },
   },
   mounted () {
   mounted () {
     if (!this.$store.state.app.isNewTab || this.outBizSubSn) { // 页签刷新 或 为弹框时调用
     if (!this.$store.state.app.isNewTab || this.outBizSubSn) { // 页签刷新 或 为弹框时调用
+      console.log(222)
       this.$refs.table.refresh(true)
       this.$refs.table.refresh(true)
       this.getDetail()
       this.getDetail()
     }
     }
@@ -221,6 +246,7 @@ export default {
   activated () {
   activated () {
     // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
     // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
     if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
     if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
+      console.log(111)
       this.$refs.table.refresh(true)
       this.$refs.table.refresh(true)
       this.getDetail()
       this.getDetail()
     }
     }

+ 109 - 0
src/views/salesManagement/pushOrderManagement/exportExcelModal.vue

@@ -0,0 +1,109 @@
+<template>
+  <a-modal
+    centered
+    :footer="null"
+    :maskClosable="false"
+    class="export-excel-modal"
+    title="导出Excel"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="600">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <a-form-model
+        id="export-excel-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="销售单号">{{ itemData&&itemData.salesBillNo || '--' }}</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="DISPATCH_BILL_PRICE">导出</a-radio>
+            <a-radio value="DISPATCH_BILL">不导出</a-radio>
+          </a-radio-group>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="export-excel-save" @click="handleSave()">导出</a-button>
+        <a-button id="export-excel-back" @click="handleCancel" 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
+      }
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      form: {
+        priceType: undefined
+      },
+      rules: {
+        priceType: [{ required: true, message: '请选择产品售价', trigger: 'change' }]
+      },
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 18 }
+      },
+      spinning: false
+    }
+  },
+  methods: {
+    // 确认
+    handleSave (isPrint) {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          _this.$emit('ok', _this.form.priceType)
+          _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">
+  .export-excel-modal{
+    .btn-cont {
+      text-align: center;
+      margin: 35px 0 10px;
+    }
+  }
+</style>