Przeglądaj źródła

import compoent

david 2 lat temu
rodzic
commit
a6082ea089

+ 11 - 0
src/api/shop.js

@@ -96,6 +96,17 @@ export function orderDecList(query) {
   })
 }
 
+// 外部商城订单列表
+export function orderShopList(query) {
+  return request({
+    url: '/v1/shop/order-shop-list',
+    method: 'get',
+    data: query,
+    params: query
+  })
+}
+
+
 
 
 

+ 19 - 0
src/api/upload.js

@@ -14,3 +14,22 @@ export function upload(data) {
     data
   })
 }
+
+
+// 上传excel,报单订单——分页导入excel文件到待导入数据的表中
+export function apiImportOrderDecToExcelTable(path, data) {
+  return request({
+    url: '/v1/'+path,
+    method: 'post',
+    data
+  })
+}
+
+// 上传execl,报单订单导入完成标记
+export function apiImportOrderDec(path, data) {
+  return request({
+    url: '/v1/'+path,
+    method: 'post',
+    data
+  })
+}

+ 232 - 0
src/components/ExcelUploader/index.vue

@@ -0,0 +1,232 @@
+<template>
+    <div class="leo-excel-uploader">
+      <el-upload
+          class="excel-uploader-box"
+          v-show="uploaderShow"
+          :action="uploaderRequestUrl"
+          name="file"
+          :headers="uploaderHeaders"
+          :data="uploaderFormData"
+          :show-file-list="false"
+          :before-upload="uploaderHandleBefore"
+          :on-success="uploaderHandleSuccess"
+          :disabled="uploaderDisabled"
+          v-loading="uploaderLoading"
+      >
+        <el-button type="primary">{{uploadBtnTitle}}</el-button>
+      </el-upload>
+      <el-dialog
+          title="进度提示"
+          :visible.sync="dialogVisible"
+          :close-on-click-modal="false"
+          :close-on-press-escape="false"
+          :show-close="false"
+          width="30%">
+        <el-progress :percentage="importPercent"></el-progress>
+      </el-dialog>
+    </div>
+  </template>
+  
+  <script>
+    import { getToken, apiImportOrderDecToExcelTable, apiImportOrderDec } from '@/api/upload'
+    export default {
+      name: 'LeoExcelUploader',
+      props: {
+        uploadBtnTitle: {
+          type: String,
+          default: 'Upload',
+        },
+        requestUploadRoute: {
+          type: String,
+          required: true,
+        },
+        requestImportToExcelTableRoute: {
+          type: String,
+          required: true,
+        },
+        requestImportExcelTableToDataRoute: {
+          type: String,
+          required: true,
+        },
+        importRowCount: {
+          required: true,
+        },
+        uploaderSuccessCanChange: {
+          type: Boolean,
+          default: true,
+        },
+        otherParams: {
+          type: Object,
+          default: {},
+        },
+        finishCallbackFunc: {
+          type:Function,
+          default:null,
+        },
+        excelOption: {
+          type: String,
+        },
+      },
+      data() {
+        return {
+          uploaderShow: true,
+          uploaderLoading: false,
+          uploaderFormData: {
+            'uploadToken': '',
+            'excelOption': this.excelOption,
+          },
+          uploaderRequestUrl: `${this.requestUploadRoute}`,
+          importRequestUrl: `${this.requestImportRoute}`,
+          uploaderHeaders: {
+            'Device-Type': 'pc',
+            'Suppress-Response-Code': '1',
+            'Authorization': '',
+          },
+          uploaderDisabled: false,
+          successImageUrl: null,
+          dialogVisible: false,
+          importPercent: 0,
+        }
+      },
+      methods: {
+        uploaderHandleBefore() {
+          if (!this.importRowCount || this.importRowCount <= 1) {
+            this.$message({
+              message: '请填写文件总行数,并且总行数大于1',
+              type: 'warning'
+            })
+            return false;
+          }
+          const auth_token = localStorage.accessToken
+          this.uploaderHeaders.Authorization = 'Bearer  ' + auth_token
+          return new Promise((resolve, reject) => {
+            getToken().then(response => {
+              this.uploaderFormData.uploadToken = response.data
+              this.uploaderLoading = true
+              resolve(true)
+            }).catch(() => {
+              this.uploaderLoading = true
+              this.$message({
+                message: err,
+                type: 'error'
+              })
+              reject(false)
+            })
+          })
+        },
+        uploaderHandleSuccess(response, file) {
+          if (response.success) {
+            this.$message({
+              message: 'Successful',
+              type: 'success'
+            })
+            // 显示进度框
+            this.dialogVisible = true
+            this.importPercent = 0
+            // 导入excel
+            this.importToExcelTable(response.data.excelImportId, 1, 1000)
+  
+            if (!this.uploaderSuccessCanChange) {
+              this.uploaderShow = false
+              this.uploaderDisabled = true
+              this.uploaderLoading = false
+            }
+            this.$emit('on-success', response.data)
+          } else {
+            this.$message({
+              message: response.data,
+              type: 'warning'
+            })
+            this.uploaderLoading = false
+          }
+        },
+        importToExcelTable(excelImportId, startRow = 0, limit = 1000) {
+          let _this = this
+          let importRowCount = Number.parseInt(_this.importRowCount)
+          let postParams = {
+            excelImportId: excelImportId,
+            rowCount: importRowCount,
+            startRow: startRow,
+            limit: limit > importRowCount ? importRowCount : limit,
+          }
+          for (let key in _this.otherParams ) {
+            postParams[key] = _this.otherParams[key]
+          }
+
+          apiImportOrderDecToExcelTable(_this.requestImportToExcelTableRoute, postParams).then(response => {
+            if (!response.data.finish) {
+              // 完成一次的进度占50%的多少
+              let percent = parseInt(startRow / importRowCount * 50)
+              if (_this.importPercent + percent >= 50) {
+                _this.importPercent = 50
+              } else {
+                if (_this.importPercent + percent >= 100) {
+                  _this.importPercent = 100
+                } else {
+                  _this.importPercent += percent
+                }
+              }
+              _this.importToExcelTable(excelImportId, startRow + limit, limit)
+            } else {
+              _this.importPercent = 50
+              _this.importExcelTableToData(excelImportId, 0, 2)
+            }
+          }).catch(err => {
+            _this.importPercent = 0
+            _this.dialogVisible = false
+            _this.uploaderLoading = false
+            this.$message({
+              message: err,
+              type: 'error'
+            })
+          })
+        },
+        importExcelTableToData(excelImportId, offset = 0, limit = 100) {
+          let _this = this
+          let postParams = {
+            excelImportId: excelImportId,
+            offset: offset,
+            limit: limit,
+          }
+          for (let key in this.otherParams ) {
+            postParams[key] = this.otherParams[key]
+          }
+          apiImportOrderDec(_this.requestImportExcelTableToDataRoute, postParams).then(response => {
+            if (!response.data.finish) {
+              let percent = Number.parseInt(offset / _this.importRowCount * 50)
+              if (_this.importPercent + percent >= 100) {
+                _this.importPercent = 100
+              } else {
+                _this.importPercent += percent
+              }
+              _this.importExcelTableToData(excelImportId, offset + limit, limit)
+            } else {
+              _this.importPercent = 100
+              _this.dialogVisible = false
+              _this.uploaderLoading = false
+              if( _this.finishCallbackFunc !== null ) {
+                _this.finishCallbackFunc()
+              }
+              _this.$message({
+                message: '导入完成',
+                type: 'success'
+              })
+            }
+          }).catch(err=>{
+            _this.importPercent = 0
+            _this.dialogVisible = false
+            _this.uploaderLoading = false
+            this.$message({
+              message: err,
+              type: 'error'
+            })
+          })
+        }
+      }
+    }
+  </script>
+  
+  <style scoped>
+  
+  </style>
+  

+ 5 - 0
src/router/index.js

@@ -167,6 +167,11 @@ export const constantRoutes = [
         component: () => import('@/views/shop/order-dec-list'),
         name: 'shop_order_dec-list',
       },
+      {
+        path: '/shop/order-shop-list', // 外部商城订单列表
+        component: () => import('@/views/shop/order-shop-list'),
+        name: 'shop_order_shop-list',
+      },
     ]
   },
   {

+ 9 - 15
src/views/shop/order-dec-list.vue

@@ -39,8 +39,8 @@
             <el-input v-model="excelForm.rowCount"></el-input>
           </el-form-item>
           <el-form-item>
-            <!-- <leo-excel-uploader
-                    :request-upload-route="`file/upload-excel`"
+            <leo-excel-uploader
+                    :request-upload-route="`v1/file/upload-excel`"
                     :request-import-to-excel-table-route="`shop/import-order-dec-to-excel-table`"
                     :request-import-excel-table-to-data-route="`shop/import-order-dec`"
                     :import-row-count="excelForm.rowCount"
@@ -49,9 +49,8 @@
                     excel-option="addUser"
                     upload-btn-title="Excel import"
                     style="float: left;"
-            ></leo-excel-uploader> -->
+            ></leo-excel-uploader>
             <!-- Excel导入 -->
-            <!--          <el-button type="primary" @click="handleExcel" style="float: left; margin-left: 10px;">下载模板</el-button>-->
           </el-form-item>
         </el-form>
       </el-dialog>
@@ -62,15 +61,14 @@
       import tool from '@/utils/tool'
       import FilterUser from '@/components/FilterUser'
       import permission from '@/utils/permission'
-    //   import LeoExcelUploader from '@/components/ExcelUploader'
+      import LeoExcelUploader from '@/components/ExcelUploader'
       import Pagination from '@/components/Pagination'
       import filterHelper from '@/utils/filterHelper'
-    //   import {CDN_BASE_URL} from "@/utils/config";
-    import { orderDecList } from '@/api/shop'
+      import { orderDecList } from '@/api/shop'
   
       export default {
           name: 'shop_order_dec-list',
-          components: {FilterUser, Pagination},
+          components: {FilterUser, Pagination, LeoExcelUploader},
           mounted() {
             this.initData()
             this.getData()
@@ -147,13 +145,6 @@
                         type: 'error'
                     })
                   })
-                //   network.getPageData(this, 'shop/order-dec-list', page, pageSize, filterData, response => {
-                //       this.filterTypes = response.filterTypes
-                //       this.allData = response
-                //   })
-              },
-              handleExcel() {
-                  window.open(CDN_BASE_URL + `/files/order-dec-import.xlsx`)
               },
               handleImport() {
                   this.importDialogVisible = true
@@ -167,5 +158,8 @@
   </script>
   
   <style scoped>
+  /deep/ .el-dialog__body .el-input {
+    width: 100% !important;
+  }
   </style>
   

+ 174 - 0
src/views/shop/order-shop-list.vue

@@ -0,0 +1,174 @@
+<template>
+    <div v-loading="loading">
+      <div class="white-box">
+        <div class="filter-box">
+          <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
+        </div>
+        <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;"
+                  @selection-change="handleSelectionChange"
+                  :height="tool.getTableHeight()">
+          <el-table-column type="selection" width="70" v-if="tableHeaders"></el-table-column>
+          <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
+            <template slot-scope="scope">
+              <template v-if="scope.row[tableHeader.index].other.tag" >
+                <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
+              </template>
+              <template v-else>
+                <div v-html="scope.row[tableHeader.index].value"></div>
+              </template>
+            </template>
+          </el-table-column>
+        </el-table>
+        <div class="white-box-footer">
+          <el-button type="success" size="small" @click="handleImport" v-show="permission.hasPermission(`shop/order-shop-list-import`)">Order import<!-- 订单导入 --></el-button>
+  
+          <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
+                      @current-change="handleCurrentChange"></pagination>
+        </div>
+      </div>
+      <el-dialog title="Order import" :visible.sync="importDialogVisible" width="50%"><!-- 订单导入 -->
+        <el-form ref="form" :model="excelForm" style="width: 100%;" class="form-page">
+          <el-form-item label="Current import order date"><!-- 当前导入订单日期 -->
+            <el-date-picker  v-model="excelForm.orderDay" type="date" placeholder="Select date"  value-format="yyyy-MM-dd"><!-- 选择日期 -->
+            </el-date-picker>
+          </el-form-item>
+          <el-form-item label="Current import order type"><!-- 当前导入订单类型 -->
+            <el-select v-model="excelForm.orderType" placeholder="Please select order type" style="width: 400px;"><!-- 请选择订单类型 -->
+              <el-option label="Resale order" value="cash" :key="1"></el-option><!-- 复销订单 -->
+              <el-option label="Points order" value="point" :key="2"></el-option><!-- 积分订单 -->
+            </el-select>
+          </el-form-item>
+          <el-form-item v-show="false" label="Current import order periods"><!-- 当前导入订单期数 -->
+            <el-input v-model="excelForm.periodNum"></el-input>
+          </el-form-item>
+          <el-form-item label="Total rows of Excel file"><!-- Excel 文件总行数 -->
+            <el-input v-model="excelForm.rowCount"></el-input>
+          </el-form-item>
+          <el-form-item>
+            <leo-excel-uploader
+              :request-upload-route="`v1/file/upload-excel`"
+              :request-import-to-excel-table-route="`shop/import-order-shop-to-excel-table`"
+              :request-import-excel-table-to-data-route="`shop/import-order-shop`"
+              :import-row-count="excelForm.rowCount"
+              :other-params="excelForm"
+              :finish-callback-func="uploadFinishFunc"
+              excel-option="addUser"
+              upload-btn-title="Excel import"
+              style="float: left;"
+            ></leo-excel-uploader><!-- Excel导入 -->
+            </el-form-item>
+        </el-form>
+      </el-dialog>
+    </div>
+  </template>
+  
+  <script>
+    import tool from '@/utils/tool'
+    import FilterUser from '@/components/FilterUser'
+    import permission from '@/utils/permission'
+    import LeoExcelUploader from '@/components/ExcelUploader'
+    import Pagination from '@/components/Pagination'
+    import filterHelper from '@/utils/filterHelper'
+    import { orderShopList } from '@/api/shop'
+  
+    export default {
+      name: 'shop_order_shop-list',
+      components: {FilterUser, Pagination, LeoExcelUploader},
+      mounted() {
+        this.initData()
+        this.getData()
+      },
+      data() {
+        return {
+          tableHeaders: null,
+          tableData: null,
+          tableHeight: window.innerHeight - 310,
+          loading: true,
+          multipleSelection: [],
+          currentPage: 1,
+          totalPages: 1,
+          totalCount: 1,
+          pageSize: 20,
+          tool: tool,
+          permission: permission,
+          filterTypes: null,
+          filterModel: {},
+          dialogDeliveryVisible: false,
+          deliveryForm: {
+            sn: '',
+            expressCompany: '',
+            orderTrackNo: '',
+          },
+          excelForm: {
+            rowCount: 0,
+            orderType: '',
+            periodNum: 0,
+            orderDay: 0,
+          },
+          importDialogVisible:false,
+        }
+      },
+      methods: {
+        handleSelectionChange(val) {
+          this.multipleSelection = val
+        },
+        handleCurrentChange(page) {
+          this.getData(page, this.pageSize)
+        },
+        handleSizeChange(pageSize) {
+          this.getData(this.currentPage, pageSize)
+        },
+        handleFilterUser(filterData) {
+          filterHelper.handleFilterUser(this, filterData)
+        },
+        initData(){
+          let myDate = new Date();
+          let thisYear = myDate.getFullYear();
+          let thisMonth = myDate.getMonth() + 1 < 10 ? '0' + (myDate.getMonth() + 1) : myDate.getMonth() + 1
+          let thisDate = myDate.getDate() < 10 ? '0' + (myDate.getDate()) : myDate.getDate()
+          this.excelForm.orderDay = thisYear + '-' + thisMonth + '-' + thisDate
+        },
+        getData(page, pageSize) {
+          let filterData = this.filterModel
+          let vueObj=this
+          const paramsData = Object.assign({
+            page: (page === null || page == undefined) ? 1 : page,
+            pageSize: (pageSize === null || pageSize == undefined) ? vueObj.pageSize : pageSize
+            }, filterData)
+            orderShopList(paramsData).then(response => {
+                vueObj.tableHeaders = response.data.columnsShow ? response.data.columnsShow : []
+                vueObj.tableData = response.data.list
+                vueObj.filterTypes = response.data.filterTypes
+                vueObj.currentPage = page
+                vueObj.totalPages = parseInt(response.data.totalPages)
+                vueObj.totalCount = parseInt(response.data.totalCount)
+                vueObj.pageSize = pageSize
+                this.loading = false
+            }).catch(err => {
+                this.loading = false
+                this.$message({
+                    message: err,
+                    type: 'error'
+                })
+            })
+        },
+        handleImport() {
+          this.importDialogVisible = true
+        },
+        uploadFinishFunc(){
+          this.importDialogVisible = false
+          this.getData()
+        }
+      }
+    }
+  </script>
+  
+  <style scoped>
+  /deep/ .el-dialog__body .el-input {
+    width: 100% !important;
+  }
+  /deep/ .el-dialog__body .el-select {
+    width: 100% !important;
+  }
+  </style>
+  

+ 1 - 1
vue.config.js

@@ -39,7 +39,7 @@ module.exports = {
     },
     proxy: {
       [process.env.VUE_APP_BASE_API]:{
-        target:"http://172.19.124.45:9970",
+        target:"http://172.27.219.80:9970",
         changeOrigin:true,
         pathRewrite:{
           ["^" + process.env.VUE_APP_BASE_API] : ""