Procházet zdrojové kódy

集团SKU导入excel

lxf před 1 rokem
rodič
revize
16f71d17ce

+ 13 - 9
.env.development

@@ -4,16 +4,20 @@ ENV = 'development'
 # 尔泓/开发环境
 VUE_APP_BASE_API = '/api'
 
-VUE_APP_ACTION_URL='http://www.printmat.cn:8181/api/blade-resource/local/file/upload'
+# VUE_APP_ACTION_URL='http://www.printmat.cn:8181/api/blade-resource/local/file/upload'
+# VUE_APP_EXPRESSAGE_URL='http://www.printmat.cn:8181/api/saas-production/saas/production/expressagereconciliation/save'
+# VUE_APP_ACTION_PRODUCT_URL='http://www.printmat.cn:8181/api/saas-group/saas/group/product/excel/product/import'
+# VUE_APP_IMG_URL='http://www.printmat.cn:8181/file'
+# VUE_APP_FILE_PREFIX='ftp://www.printmat.cn/'
+# VUE_APP_MESSAGE_URL='ws://www.printmat.cn:8181/api'
+
+VUE_APP_ACTION_URL='http://192.168.1.164/api/blade-resource/local/file/upload'
+VUE_APP_EXPRESSAGE_URL='http://192.168.1.164/api/saas-production/saas/production/expressagereconciliation/save'
+VUE_APP_ACTION_PRODUCT_URL='http://192.168.1.164/api/saas-group/saas/group/product/excel/product/import'
+VUE_APP_IMG_URL='http://192.168.1.164/file'
+VUE_APP_FILE_PREFIX='ftp://192.168.1.89/'
+VUE_APP_MESSAGE_URL='ws://192.168.1.164/api'
 
-VUE_APP_EXPRESSAGE_URL='http://www.printmat.cn:8181/api/saas-production/saas/production/expressagereconciliation/save'
-
-VUE_APP_IMG_URL='http://www.printmat.cn:8181/file'
-
-VUE_APP_FILE_PREFIX='ftp://www.printmat.cn/'
-
-VUE_APP_MESSAGE_URL='ws://www.printmat.cn:8181/api'
-# VUE_APP_MESSAGE_URL='ws://192.168.1.164/api'
 
 VUE_APP_TIME = 3000000
 

+ 2 - 0
.env.staging

@@ -10,6 +10,8 @@ VUE_APP_ACTION_URL='http://192.168.1.164/api/blade-resource/local/file/upload'
 
 VUE_APP_EXPRESSAGE_URL='http://192.168.1.164/api/saas-production/saas/production/expressagereconciliation/save'
 
+VUE_APP_ACTION_PRODUCT_URL='http://192.168.1.164/api/saas-group/saas/group/product/excel/product/import'
+
 VUE_APP_IMG_URL='http://192.168.1.164/file'
 
 VUE_APP_FILE_PREFIX='ftp://192.168.1.89/'

+ 9 - 0
src/api/shengde/group/order/orderManagement.js

@@ -44,3 +44,12 @@ export function versionListCount(data) {
     data: data,
   })
 }
+
+// 还原版本
+export function backupVersion(params) {
+  return request({
+    url: '/saas/group/version/backupVersion',
+    method: 'get',
+    params: params,
+  })
+}

+ 179 - 7
src/views/shengde/product/groupSKU/index.vue

@@ -27,8 +27,10 @@
       </el-form>
 
       <el-row :gutter="10" style="margin-bottom: 10px" v-if="!userInfo.subsidiaryId">
-        <el-col :span="5">
-          <el-button type="primary" size="small" @click="handleAdd">添加产品</el-button>
+        <el-col :span="24">
+          <el-button type="primary" size="mini" @click="handleAdd">添加产品</el-button>
+          <!-- <el-button type="primary" size="mini" @click="importExcel" v-db-click>导入Excel</el-button>
+          <el-button type="primary" size="mini" @click="historyManagement" v-db-click>导入历史管理</el-button> -->
         </el-col>
       </el-row>
 
@@ -112,6 +114,85 @@
     <el-dialog v-if="openDetails" :visible.sync="openDetails" width="98%" append-to-body>
       <ProductDetails :rowData="rowData" @clickCancel="clickCancelDetails"></ProductDetails>
     </el-dialog>
+
+    <!-- 导入SKU  -->
+    <el-dialog title="导入SKU" v-if="openImportExcel" :visible.sync="openImportExcel" style="margin-top: 15vh" width="30%" append-to-body>
+      <div
+        v-loading="loadingStatus"
+        element-loading-text="导入中,请稍后"
+        element-loading-spinner="el-icon-loading"
+        element-loading-background="rgba(0, 0, 0, 0.2)"
+      >
+        <el-row :gutter="10" style="margin-bottom: 15px">
+          <el-col :span="1.5">
+            <el-upload
+              class="upload-demo"
+              :action="actionProduct"
+              :headers="{ 'Blade-Auth': 'bearer ' + token }"
+              :show-file-list="false"
+              :before-upload="beforeUpload"
+              :on-progress="excelProgress"
+              :on-success="excelSuccess"
+              :on-error="excelError"
+              accept=".xlsx"
+            >
+              <el-button type="primary" size="mini">导入文件</el-button>
+            </el-upload>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-tooltip placement="bottom" effect="light">
+              <div slot="content">
+                <div v-html="getStyle(errMsg)" style="max-height: 500px; overflow: auto; line-height: normal"></div>
+              </div>
+              <div style="cursor: pointer; color: #940819; overflow: hidden; white-space: nowrap; text-overflow: ellipsis">{{ errMsg }}</div>
+            </el-tooltip>
+          </el-col>
+        </el-row>
+        <div style="width: 100%; text-align: center; padding-top: 16px">
+          <el-button @click="openImportExcel = false">取 消</el-button>
+        </div>
+      </div>
+    </el-dialog>
+
+    <!-- SKU导入历史  -->
+    <el-dialog title="SKU导入历史" v-if="openHistory" :visible.sync="openHistory" width="40%" style="margin-top: 15vh" append-to-body>
+      <div
+        v-loading="loadingVersion"
+        element-loading-text="还原版本中,请稍后"
+        element-loading-spinner="el-icon-loading"
+        element-loading-background="rgba(0, 0, 0, 0.2)"
+      >
+        <el-table
+          :data="historyList"
+          :cell-style="{ padding: '0' }"
+          :row-style="{ height: '35px' }"
+          header-row-class-name="tableHeader"
+          v-loading="loadingHistory"
+          border
+        >
+          <el-table-column label="版本时间" align="center" prop="createTime" />
+          <el-table-column label="导入人" align="center" prop="userName" />
+          <el-table-column label="操作" align="center" width="100" fixed="right">
+            <template slot-scope="scope">
+              <el-button type="text" @click="restoreVersion(scope.row)" v-db-click>还原版本</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <pagination
+          v-show="historyTotal > 0"
+          :total="historyTotal"
+          :page.sync="queryParamsTwo.pageNum"
+          :limit.sync="queryParamsTwo.pageSize"
+          @pagination="getHistoryList"
+        />
+        <div style="width: 100%; text-align: center; padding-top: 16px">
+          <el-button type="primary" @click="openHistory = false">确 定</el-button>
+        </div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -121,6 +202,7 @@ import { del } from '@/api/product/customProductLibrary'
 import { mapGetters } from 'vuex'
 import Product from './product'
 import ProductDetails from './details'
+import { versionList, versionListCount, backupVersion } from '@/api/shengde/group/order/orderManagement.js'
 
 export default {
   name: 'groupSKU',
@@ -158,16 +240,26 @@ export default {
       fileData: [],
       rowData: {},
       openDetails: false,
-      // brandName: [],
+      openImportExcel: false,
+      actionProduct: process.env.VUE_APP_ACTION_PRODUCT_URL,
+      loadingStatus: false,
+      openHistory: false,
+      loadingHistory: false,
+      queryParamsTwo: {
+        pageNum: 1,
+        pageSize: 10,
+        model: '1',
+      },
+      historyList: [],
+      historyTotal: 0,
+      loadingVersion: false,
     }
   },
-  created() {
-    // this.brandName = this.dictData.filter((item) => item.code === 'brand_name')[0].children
-  },
+  created() {},
   mounted() {
     this.getList()
   },
-  computed: mapGetters(['dictData', 'userInfo']),
+  computed: mapGetters(['dictData', 'userInfo', 'token']),
   methods: {
     handleNodeClick(data) {
       this.queryParams.pageNum = 1
@@ -265,6 +357,86 @@ export default {
     openFile(path) {
       window.open(path)
     },
+    importExcel() {
+      this.errMsg = ''
+      this.openImportExcel = true
+    },
+    getStyle(text) {
+      if (text) {
+        return text.replace(/\n|\r\n/g, '<br>')
+      } else {
+        return ''
+      }
+    },
+    beforeUpload(file) {
+      this.errMsg = ''
+      const isLt50M = file.size / 1024 / 1024 < 50
+      if (!isLt50M) {
+        this.$message.error('上传文件大小不能超过50MB!')
+      }
+      return isLt50M
+    },
+    excelProgress() {
+      this.loadingStatus = true
+    },
+    excelSuccess(msg) {
+      if (msg && msg.data) {
+        this.msgSuccess('文件导入成功: ' + msg.data)
+      } else {
+        this.msgSuccess('文件导入成功')
+      }
+      this.loadingStatus = false
+      this.openImportExcel = false
+      this.getList()
+    },
+    excelError(err) {
+      var res = JSON.parse(err.message)
+      this.errMsg = '导入失败: ' + res.msg
+      this.loadingStatus = false
+    },
+    historyManagement() {
+      this.historyTotal = 0
+      this.historyList = []
+      this.queryParamsTwo = {
+        pageNum: 1,
+        pageSize: 10,
+        model: '1',
+      }
+      this.loadingVersion = false
+      this.openHistory = true
+      this.getHistoryList()
+    },
+    getHistoryList() {
+      this.loadingHistory = true
+      versionList(this.queryParamsTwo).then(
+        (res) => {
+          this.historyList = res.data.data.list
+          this.loadingHistory = false
+        },
+        (err) => {
+          console.log('versionList:' + err)
+          this.loadingHistory = false
+        }
+      )
+      versionListCount(this.queryParamsTwo).then((res) => {
+        this.historyTotal = res.data.data.count
+      })
+    },
+    restoreVersion(row) {
+      this.loadingVersion = true
+      backupVersion({ id: row.id }).then(
+        (res) => {
+          this.msgSuccess('版本还原成功')
+          this.loadingVersion = false
+          this.openHistory = false
+          this.getList()
+        },
+        (err) => {
+          console.log('backupVersion: ' + err)
+          this.loadingVersion = false
+        }
+      )
+    },
   },
 }
 </script>

+ 84 - 2
src/views/shengde/product/management/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div v-loading="loadingStatus" element-loading-text="获取数据中,请稍后" element-loading-background="rgba(0, 0, 0, 0.2)">
+  <div>
     <el-row style="padding-top: 0">
       <el-col :span="24">
         <el-card style="height: calc(100vh - 110px)" class="scroll">
@@ -29,9 +29,10 @@
           </el-form>
 
           <el-row :gutter="10" style="margin-bottom: 10px" v-show="showSearch">
-            <el-col :span="5">
+            <el-col :span="24">
               <el-button type="primary" size="mini" @click="handleAdd" v-if="!userInfo.subsidiaryId">添加产品</el-button>
               <el-button type="primary" size="mini" @click="handleSynchronization" v-db-click>SKU同步</el-button>
+              <!-- <el-button type="primary" size="mini" @click="importExcel" v-db-click>导入Excel</el-button> -->
             </el-col>
           </el-row>
 
@@ -203,6 +204,47 @@
         </div>
       </el-form>
     </el-dialog>
+
+    <!-- 导入SKU  -->
+    <el-dialog title="导入SKU" v-if="openImportExcel" :visible.sync="openImportExcel" style="margin-top: 15vh" width="30%" append-to-body>
+      <div
+        v-loading="loadingStatus"
+        element-loading-text="导入中,请稍后"
+        element-loading-spinner="el-icon-loading"
+        element-loading-background="rgba(0, 0, 0, 0.2)"
+      >
+        <el-row :gutter="10" style="margin-bottom: 15px">
+          <el-col :span="1.5">
+            <el-upload
+              class="upload-demo"
+              :action="actionProduct"
+              :headers="{ 'Blade-Auth': 'bearer ' + token }"
+              :show-file-list="false"
+              :before-upload="beforeUpload"
+              :on-progress="excelProgress"
+              :on-success="excelSuccess"
+              :on-error="excelError"
+              accept=".xls"
+            >
+              <el-button type="primary" size="mini">导入文件</el-button>
+            </el-upload>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-tooltip placement="bottom" effect="light">
+              <div slot="content">
+                <div v-html="getStyle(errMsg)" style="max-height: 500px; overflow: auto; line-height: normal"></div>
+              </div>
+              <div style="cursor: pointer; color: #940819; overflow: hidden; white-space: nowrap; text-overflow: ellipsis">{{ errMsg }}</div>
+            </el-tooltip>
+          </el-col>
+        </el-row>
+        <div style="width: 100%; text-align: center; padding-top: 16px">
+          <el-button @click="openImportExcel = false">取 消</el-button>
+        </div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -286,6 +328,9 @@ export default {
         spec_code: [{ required: true, message: '请输入SKU品号', trigger: 'blur' }],
       },
       loadingSynchronizationStatus: false,
+      errMsg: '',
+      openImportExcel: false,
+      actionProduct: process.env.VUE_APP_ACTION_PRODUCT_URL,
     }
   },
   created() {
@@ -495,6 +540,43 @@ export default {
         }
       })
     },
+    importExcel() {
+      this.errMsg = ''
+      this.openImportExcel = true
+    },
+    getStyle(text) {
+      if (text) {
+        return text.replace(/\n|\r\n/g, '<br>')
+      } else {
+        return ''
+      }
+    },
+    beforeUpload(file) {
+      this.errMsg = ''
+      const isLt50M = file.size / 1024 / 1024 < 50
+      if (!isLt50M) {
+        this.$message.error('上传文件大小不能超过50MB!')
+      }
+      return isLt50M
+    },
+    excelProgress() {
+      this.loadingStatus = true
+    },
+    excelSuccess(msg) {
+      if (msg && msg.data) {
+        this.msgSuccess('文件导入成功: ' + msg.data)
+      } else {
+        this.msgSuccess('文件导入成功')
+      }
+      this.loadingStatus = false
+      this.openImportExcel = false
+      this.getList()
+    },
+    excelError(err) {
+      var res = JSON.parse(err.message)
+      this.errMsg = '导入失败: ' + res.msg
+      this.loadingStatus = false
+    },
   },
 }
 </script>