Browse Source

bug修改优化

喻文俊 3 years ago
parent
commit
e9e0d1ff8e

+ 1 - 1
src/router/index.js

@@ -49,7 +49,7 @@ export const constantRoutes = [
   },
   {
     path: '/login',
-    component: () => import(/* webpackChunkName: "login" */ '@/views/login/index'),
+    component: () => import(/* webpackChunkName: "static/js/login" */ '@/views/login/index'),
     hidden: true
   },
   {

+ 50 - 2
src/utils/tools.js

@@ -52,8 +52,47 @@ export function debounce(func, wait, immediate = false) {
  * @returns hash字符串
  */
 export function createHash(hashLength) {
-  if (!hashLength || typeof (Number(hashLength)) !== 'number') { return }
-  var ar = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
+  if (!hashLength || typeof Number(hashLength) !== 'number') {
+    return
+  }
+  var ar = [
+    '1',
+    '2',
+    '3',
+    '4',
+    '5',
+    '6',
+    '7',
+    '8',
+    '9',
+    '0',
+    'a',
+    'b',
+    'c',
+    'd',
+    'e',
+    'f',
+    'g',
+    'h',
+    'i',
+    'j',
+    'k',
+    'l',
+    'm',
+    'n',
+    'o',
+    'p',
+    'q',
+    'r',
+    's',
+    't',
+    'u',
+    'v',
+    'w',
+    'x',
+    'y',
+    'z'
+  ]
   var hs = []
   var hl = Number(hashLength)
   var al = ar.length
@@ -62,3 +101,12 @@ export function createHash(hashLength) {
   }
   return hs.join('')
 }
+
+// 通过a标签下载文件
+export function downLoadWithATag(href) {
+  const downLink = document.createElement('a')
+  downLink.href = href
+  downLink.style.display = 'none'
+  downLink.setAttribute('download', true)
+  downLink.click()
+}

+ 8 - 10
src/views/authentic/auth/index.vue

@@ -35,6 +35,7 @@
       <el-button v-if="userIdentity === 2 || proxyInfo!==null" icon="el-icon-edit" type="primary" @click="handleShowEditDialog('添加品牌授权')">添加品牌授权</el-button>
       <el-button icon="el-icon-upload" type="primary" @click="improtDialogVisible = true">导入</el-button>
       <el-button icon="el-icon-document" type="primary" @click="handleExportExcel">导出</el-button>
+      <el-button icon="el-icon-document-copy" type="primary" @click="downLoadExportExcel">获取导入模板</el-button>
     </div>
     <!-- 表格区域 -->
     <el-table
@@ -175,7 +176,7 @@ import { fecthAuthList, saveBrandAuth, changeAuthStatus, removeAuth, authImportE
 import Pagination from '@/components/Pagination' // secondary package based on el-pagination
 import { mapGetters } from 'vuex'
 import { formatDate } from '@/utils'
-import { debounce } from '@/utils/tools'
+import { debounce, downLoadWithATag } from '@/utils/tools'
 export default {
   name: 'ComplexTable',
   components: { Pagination, FileUpload },
@@ -278,6 +279,11 @@ export default {
       }
     },
 
+    // 下载模板
+    downLoadExportExcel() {
+      downLoadWithATag(`${process.env.VUE_APP_BASE_API}/download/file?ossName=%E6%AD%A3%E5%93%81%E8%81%94%E7%9B%9F%E6%9C%BA%E6%9E%84%E3%80%81%E5%95%86%E5%93%81%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx&fileName=%E6%AD%A3%E5%93%81%E8%81%94%E7%9B%9F%E6%9C%BA%E6%9E%84%E3%80%81%E5%95%86%E5%93%81%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx`)
+    },
+
     // 导出为Excel
     async handleExportExcel() {
       const text = await this.$confirm('确认导出所有授权机构的数据吗?', '提示', {
@@ -289,15 +295,7 @@ export default {
       })
       if (text !== 'confirm') return
       // 使用a链接下载
-      const downLink = document.createElement('a')
-      downLink.href = `${process.env.VUE_APP_BASE_API}/auth/export/excel?authUserId=${this.authUserId}`
-      downLink.style.display = 'none'
-      downLink.setAttribute('download', true)
-      downLink.click()
-      // const res = await authExportExcel({
-      //   authUserId: this.authUserId
-      // })
-      // console.log(res)
+      downLoadWithATag(`${process.env.VUE_APP_BASE_API}/auth/export/excel?authUserId=${this.authUserId}`)
     },
 
     // 导入Excel 并提交

+ 2 - 1
src/views/authentic/helper/document.vue

@@ -336,7 +336,8 @@ export default {
 
     // 预览
     handlePreview(row) {
-      openWindow(row.fileUrl, '', `${row.fileModuleType}-教程`, 800, 460)
+      const url = `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(row.fileUrl)}`
+      openWindow(url, '', `${row.fileModuleType}-教程`, 800, 460)
     },
 
     // 关闭添加对话框

+ 1 - 1
src/views/authentic/supplier/add.vue

@@ -460,7 +460,7 @@ export default {
           this.supplierBrands.push(shopInfo)
         } else {
         // 修改的
-          this.supplierBrands.splice(this.currentIndex, shopInfo)
+          this.supplierBrands.splice(this.currentIndex, 1, shopInfo)
         }
         this.addExcludeBrand(shopInfo.brandId)
         shopInfo.isNew = false

+ 3 - 1
src/views/authentic/supplier/edit.vue

@@ -499,6 +499,7 @@ export default {
     },
     // 添加品牌
     handleAddBrand() {
+      console.log(this.formData2)
       this.dialogLoading = true
       // 如果声明类型为4,并且文件id为空或null,则需要先上传文件再保存
       if (this.formData2.statementType === 4 && (this.formData2.statementFileId === '' || this.formData2.statementFileId === null)) {
@@ -514,13 +515,14 @@ export default {
         if (!valid) {
           return
         }
+
         // 如果是新增的
         const shopInfo = this.clone(this.formData2)
         if (shopInfo.isNew) {
           this.supplierBrands.push(shopInfo)
         } else {
         // 修改的
-          this.supplierBrands.splice(this.currentIndex, shopInfo)
+          this.supplierBrands.splice(this.currentIndex, 1, shopInfo)
         }
         this.addExcludeBrand(shopInfo.brandId)
         shopInfo.isNew = false