Browse Source

2023.12.19 - 添加订单选择导出

GuYun-D 1 year ago
parent
commit
a5305b58ca
1 changed files with 17 additions and 3 deletions
  1. 17 3
      src/views/order/pending/index.vue

+ 17 - 3
src/views/order/pending/index.vue

@@ -13,6 +13,7 @@
       <!-- 搜索 -->
       <div class="formSearch">
         <el-form :inline="true" :model="formInline" class="demo-form-inline">
+
           <el-form-item>
             <div>
               <el-input v-model="formInline.search" placeholder="请输入内容">
@@ -51,7 +52,10 @@
       <!-- 表格 -->
       <div class="tableBox">
         <el-table ref="multipleTable" v-loading="tableLoading" :data="tableData" border stripe
-          :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" tooltip-effect="dark" style="width: 100%">
+          @selection-change="handleSelectOrder" :header-cell-style="{ background: '#EEF3FF', color: '#333333' }"
+          tooltip-effect="dark" style="width: 100%">
+          <el-table-column type="selection" width="55">
+          </el-table-column>
           <el-table-column label="订单id" width="150">
             <template slot-scope="scope">{{ scope.row.orderId }}</template>
           </el-table-column>
@@ -133,7 +137,8 @@ export default {
       exportExcelVisible: false,
       form: {},
       exportTemplate: 1, // excel导出模版
-      exportExcelLoading: false
+      exportExcelLoading: false,
+      selectOrderIds: []
     }
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
@@ -184,6 +189,11 @@ export default {
       this.tableLoading = false
     },
 
+    // 选择订单
+    handleSelectOrder(e) {
+      this.selectOrderIds = e
+    },
+
     // 导出订单
     async orderDataExport() {
       this.$message({
@@ -192,7 +202,9 @@ export default {
       })
       try {
         this.exportExcelLoading = true
-        const res = await orderExport({ ...this.formInline, templateType: this.exportTemplate })
+        const exportExcelParams = { ...this.formInline, templateType: this.exportTemplate }
+        !!this.selectOrderIds.length && (exportExcelParams.orderIds = this.selectOrderIds.map(item => item.orderId))
+        const res = await orderExport(exportExcelParams)
         if (!res) {
           return
         }
@@ -216,6 +228,8 @@ export default {
           message: '导出成功',
           type: 'success'
         })
+        this.selectOrderIds = []
+      this.$refs.multipleTable.clearSelection()
       } catch (error) {
         this.$message({
           message: '导出失败',