Browse Source

Merge branch 'master' of http://159.75.201.17:3000/zwq/tuanfeng-pc-admin

aliyun0758874076 1 year ago
parent
commit
3bf6f3d12d
3 changed files with 80 additions and 41 deletions
  1. 1 1
      src/utils/request.js
  2. 75 36
      src/views/order/pending/index.vue
  3. 4 4
      vue.config.js

+ 1 - 1
src/utils/request.js

@@ -17,7 +17,7 @@ axios.defaults.timeout = 30000
 const service = axios.create({
   baseURL, // url = base url + request url
   // withCredentials: true, // send cookies when cross-domain requests
-  timeout: 5000 // request timeout
+  timeout: 30000 // request timeout
 })
 
 export const uploadUrl = `${baseURL}/file/upload`

+ 75 - 36
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="请输入内容">
@@ -39,24 +40,22 @@
             </el-select>
           </el-form-item> -->
           <el-form-item label="下单时间">
-            <el-date-picker
-              v-model="formInline.dates" type="daterange" range-separator="至" start-placeholder="开始日期"
-              end-placeholder="结束日期"
-            />
+            <el-date-picker v-model="formInline.dates" type="daterange" range-separator="至" start-placeholder="开始日期"
+              end-placeholder="结束日期" />
           </el-form-item>
           <el-form-item>
             <el-button type="primary" plain @click="search">查询</el-button>
-            <el-button type="success" plain @click="orderDataExport">导出订单</el-button>
+            <el-button type="success" plain @click="exportExcelVisible = true">导出订单</el-button>
           </el-form-item>
         </el-form>
       </div>
       <!-- 表格 -->
       <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%"
-        >
+        <el-table ref="multipleTable" v-loading="tableLoading" :data="tableData" border stripe
+          @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>
@@ -86,17 +85,27 @@
           </el-table-column>
         </el-table>
         <div class="fenye">
-          <el-pagination
-            :current-page="formInline.page" :page-sizes="[10, 20, 50, 100]" :page-size="10"
+          <el-pagination :current-page="formInline.page" :page-sizes="[10, 20, 50, 100]" :page-size="10"
             layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
-            @current-change="handleCurrentChange"
-          />
+            @current-change="handleCurrentChange" />
         </div>
       </div>
     </div>
     <el-dialog title="订单详情" :visible.sync="detailVisible" width="74%" center :close-on-click-modal="false">
       <OrderDetail :detail-row="form" @cancel="cancel" />
     </el-dialog>
+
+    <el-dialog title="选择导出模版" :visible.sync="exportExcelVisible" center :close-on-click-modal="false">
+      <el-radio-group v-model="exportTemplate">
+        <el-radio :label="1">平台订单</el-radio>
+        <el-radio :label="2">胖子发货订单</el-radio>
+      </el-radio-group>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="exportExcelVisible = false">取 消</el-button>
+        <el-button type="primary" @click="orderDataExport" :loading="exportExcelLoading">{{ exportExcelLoading ?
+          '导出中...' : '确认导出' }}</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -118,13 +127,18 @@ export default {
         dates: [], // 下单时间数组
         page: 1,
         shopName: '',
-        pageSize: 10
+        pageSize: 10,
+        templateType: 1
       },
       total: 1,
       tableData: [],
       tableLoading: false,
       detailVisible: false,
-      form: {}
+      exportExcelVisible: false,
+      form: {},
+      exportTemplate: 1, // excel导出模版
+      exportExcelLoading: false,
+      selectOrderIds: []
     }
   },
   // 生命周期 - 挂载完成(可以访问DOM元素)
@@ -174,31 +188,56 @@ export default {
       this.total = res.data.total
       this.tableLoading = false
     },
+
+    // 选择订单
+    handleSelectOrder(e) {
+      this.selectOrderIds = e
+    },
+
     // 导出订单
     async orderDataExport() {
       this.$message({
         message: '数据导出中,请勿重复操作!',
         type: 'success'
       })
-      const res = await orderExport(this.formInline)
-      if (!res) {
-        return
-      }
-      const blob = new Blob([ res ], { type: 'application/vnd.ms-excel' })
-      const fileName = '订单数据明细表.xls'
-      if ('download' in document.createElement('a')) {
-        // 非IE下载
-        const elink = document.createElement('a')
-        elink.download = fileName
-        elink.style.display = 'none'
-        elink.href = URL.createObjectURL(blob)
-        document.body.appendChild(elink)
-        elink.click()
-        URL.revokeObjectURL(elink.href) // 释放URL 对象
-        document.body.removeChild(elink)
-      } else {
-        // IE10+下载
-        navigator.msSaveBlob(blob, fileName)
+      try {
+        this.exportExcelLoading = true
+        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
+        }
+        const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
+        const fileName = '订单数据明细表.xls'
+        if ('download' in document.createElement('a')) {
+          // 非IE下载
+          const elink = document.createElement('a')
+          elink.download = fileName
+          elink.style.display = 'none'
+          elink.href = URL.createObjectURL(blob)
+          document.body.appendChild(elink)
+          elink.click()
+          URL.revokeObjectURL(elink.href) // 释放URL 对象
+          document.body.removeChild(elink)
+        } else {
+          // IE10+下载
+          navigator.msSaveBlob(blob, fileName)
+        }
+        this.$message({
+          message: '导出成功',
+          type: 'success'
+        })
+        this.selectOrderIds = []
+      this.$refs.multipleTable.clearSelection()
+      } catch (error) {
+        this.$message({
+          message: '导出失败',
+          type: 'error'
+        })
+      } finally {
+        this.exportExcelLoading = false
+        this.exportExcelVisible = false
       }
     }
   }
@@ -210,6 +249,6 @@ export default {
 @import url("../../../styles/elDialog.scss");
 
 .tab_show {
-	padding-left: 30px;
+  padding-left: 30px;
 }
 </style>

+ 4 - 4
vue.config.js

@@ -50,8 +50,8 @@ module.exports = {
         }
       },
       '/adminapi': {
-        target: 'https://nsadminapi.tuanfengkeji.cn', // 测试
-        // target: 'http://192.168.0.91:9103', // 平台端
+        // target: 'https://nsadminapi.tuanfengkeji.cn', // 测试
+        target: 'http://192.168.0.91:9103', // 平台端
         // target: 'http://192.168.0.91:9003', // 商家端
         changeOrigin: true,
         pathRewrite: {
@@ -59,8 +59,8 @@ module.exports = {
         }
       },
       '/': {
-        target: 'https://nsadminapi.tuanfengkeji.cn', // 测试
-        // target: 'http://192.168.0.91:9103', // 平台端
+        // target: 'https://nsadminapi.tuanfengkeji.cn', // 测试
+        target: 'http://192.168.0.91:9103', // 平台端
         // target: 'http://192.168.0.91:9003', // 商家端
         changeOrigin: true
       }