From d9c96d153bb5ed761da76f29d715c755f7b5dd32 Mon Sep 17 00:00:00 2001
From: Mr.Zhang <710666463@qq.com>
Date: 星期二, 19 九月 2023 10:24:05 +0800
Subject: [PATCH] 平台端bug

---
 platform/src/components/business/selectProduct.vue    |    2 
 platform/public/template/goods_import_modle.xlsx      |    0 
 platform/src/components/common/UploadImage.vue        |    2 
 platform/package.json                                 |    2 
 platform/src/components/business/OperaGoodsWindow.vue |  325 ++++++---------------------
 platform/src/api/business/goods.js                    |    4 
 platform/src/components/common/ImportButton.vue       |   37 +++
 platform/.env.development                             |    3 
 platform/src/views/business/goods.vue                 |   87 +-----
 platform/.env.staging                                 |    7 
 platform/src/components/common/ImportWindow.vue       |  205 +++++++++++++++++
 platform/vue.config.js                                |    9 
 12 files changed, 356 insertions(+), 327 deletions(-)

diff --git a/platform/.env.development b/platform/.env.development
index 6ddd836..f98212e 100644
--- a/platform/.env.development
+++ b/platform/.env.development
@@ -1,9 +1,10 @@
 # 寮�鍙戠幆澧冮厤缃�
 NODE_ENV = 'development'
 
+VUE_APP_CONTEXT_PATH = ''
 VUE_APP_API_PREFIX = '/api'
 
 # 浠诲悍
 # VUE_APP_API = 'http://192.168.0.15:10017/'
 # 鐒︽澗
-VUE_APP_API = 'http://192.168.0.35:10011'
+VUE_APP_API = 'http://192.168.0.36:10011'
diff --git a/platform/.env.staging b/platform/.env.staging
index bd33547..44d070b 100644
--- a/platform/.env.staging
+++ b/platform/.env.staging
@@ -1,2 +1,9 @@
 # 娴嬭瘯鐜閰嶇疆
 NODE_ENV = 'production'
+
+VUE_APP_CONTEXT_PATH = '/preselect_admin'
+VUE_APP_API_PREFIX = '/preselect_admin_interface'
+
+
+# https://dmtest.ahapp.net/preselect_admin_interface/doc.html
+VUE_APP_API = 'https://dmtest.ahapp.net/preselect_admin_interface'
diff --git a/platform/package.json b/platform/package.json
index 523d8c4..bc7b751 100644
--- a/platform/package.json
+++ b/platform/package.json
@@ -5,7 +5,7 @@
   "scripts": {
     "serve": "vue-cli-service serve",
     "build": "vue-cli-service build",
-    "build:staging": "vue-cli-service build --mode staging",
+    "build:dev": "vue-cli-service build --mode staging",
     "lint": "vue-cli-service lint",
     "fix": "eslint --ext .js,.vue src --fix"
   },
diff --git a/platform/public/template/goods_import_modle.xlsx b/platform/public/template/goods_import_modle.xlsx
new file mode 100644
index 0000000..84a9c9a
--- /dev/null
+++ b/platform/public/template/goods_import_modle.xlsx
Binary files differ
diff --git a/platform/src/api/business/goods.js b/platform/src/api/business/goods.js
index b8f9191..1ae02b3 100644
--- a/platform/src/api/business/goods.js
+++ b/platform/src/api/business/goods.js
@@ -30,7 +30,7 @@
 
 // 淇敼
 export function updateById (data) {
-  return request.post('/business/baseGoods/updateById', data)
+  return request.post('/business/baseGoods/update', data)
 }
 
 // 鍒犻櫎
@@ -62,5 +62,5 @@
 
 // 鏍规嵁ID鏌ヨ
 export function queryById (id) {
-  return request.get(`business/baseGoods/${id}`)
+  return request.get(`/business/baseGoods/${id}`)
 }
\ No newline at end of file
diff --git a/platform/src/components/business/OperaGoodsWindow.vue b/platform/src/components/business/OperaGoodsWindow.vue
index d2d1ef9..d0275ba 100644
--- a/platform/src/components/business/OperaGoodsWindow.vue
+++ b/platform/src/components/business/OperaGoodsWindow.vue
@@ -1,94 +1,46 @@
 <template>
-  <GlobalWindow
-    :title="title"
-    :visible.sync="visible"
-    :confirm-working="isWorking"
-    @confirm="confirm"
-    width="800px"
-  >
+  <GlobalWindow :title="title" :visible.sync="visible" :confirm-working="isWorking" @confirm="confirm" width="800px"
+    v-loading="isUploading">
     <el-form :model="form" ref="form" label-width="120px" :rules="rules">
       <div style="font-size: 18px;font-weight: bold;">鍩烘湰淇℃伅</div>
       <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
-        <el-input v-model="form.name" maxlength="50" placeholder="璇疯緭鍏ュ晢鍝佸悕绉帮紝涓嶈秴杩�50涓瓧" v-trim/>
+        <el-input v-model="form.name" maxlength="50" placeholder="璇疯緭鍏ュ晢鍝佸悕绉帮紝涓嶈秴杩�50涓瓧" v-trim />
       </el-form-item>
       <el-form-item label="鍟嗗搧鍝佺墝" prop="brandId">
         <el-select v-model="form.brandId" placeholder="璇烽�夋嫨锛屽崟閫�">
-          <el-option
-            v-for="item in brandList"
-            :key="item.id"
-            :label="item.name"
-            :value="item.id">
+          <el-option v-for="item in brandList()" :key="item.id" :label="item.name" :value="item.id">
           </el-option>
         </el-select>
       </el-form-item>
       <el-form-item label="鍟嗗搧绫诲埆" prop="categoryId">
-        <!-- @change="changeCategory(form.categoryId)" -->
-        <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨锛屽崟閫�">
-          <el-option
-            v-for="item in categoryList"
-            :key="item.id"
-            :label="item.name"
-            :value="item.id">
+        <el-select v-model="form.categoryId" placeholder="璇烽�夋嫨锛屽崟閫�" @change="categorySelect">
+          <el-option v-for="item in categoryList()" :key="item.id" :label="item.name" :value="item.id">
           </el-option>
         </el-select>
       </el-form-item>
-      <!-- <el-form-item :label="name1" prop="attrFirstIds" v-if="name1">
-        <el-select v-model="form.attrFirstIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
-          <el-option
-            v-for="item in form.attrFirstList"
-            :key="item.id"
-            :label="item.name"
-            :value="item.id">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item :label="name2" prop="attrSecodIds" v-if="name2">
-        <el-select v-model="form.attrSecodIds" multiple placeholder="璇烽�夋嫨锛屾敮鎸佸閫�">
-          <el-option
-            v-for="item in form.attrSecodList"
-            :key="item.id"
-            :label="item.name"
-            :value="item.id">
-          </el-option>
-        </el-select>
-      </el-form-item> -->
       <el-form-item label="鎸囧浠凤紙鍏冿級" prop="zdPrice">
-        <el-input v-model="form.zdPrice" @input="priceCHANEG(form.zdPrice, 1)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
+        <el-input v-model="form.zdPrice" @input="priceCHANEG(form.zdPrice, 1)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓"
+          v-trim />
       </el-form-item>
       <el-form-item label="鍏ユ墜浠凤紙鍏冿級" prop="price">
-        <el-input v-model="form.price" @input="priceCHANEG(form.price, 2)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓" v-trim/>
+        <el-input v-model="form.price" @input="priceCHANEG(form.price, 2)" type="number" placeholder="寤鸿褰曞叆鏁存暟锛屽崟浣嶅厓"
+          v-trim />
       </el-form-item>
       <el-form-item label="鍟嗗搧涓诲浘">
-        <el-upload
-          :action="action"
-          :file-list="form.ztList"
-          :data="{ folder: 'goods_img' }"
-          list-type="picture-card"
-          :limit="1"
-          :on-success="fileSuccess"
-          :on-exceed="exceed"
-          :on-remove="handleRemove">
-          <i class="el-icon-plus"></i>
-          <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�140*140px</div>
-        </el-upload>
+        <UploadAvatarImage :file="{ 'imgurlfull': form.imgfullurl, 'imgurl': form.imgurl }" :uploadData="uploadData"
+          tipsLabel="" @uploadSuccess="uploadReverseSuccess" @uploadEnd="isUploading = false"
+          @uploadBegin="isUploading = true" />
+        鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�140px*140px
       </el-form-item>
-  <el-form-item label="鍟嗗搧鍥剧墖">
-        <el-upload
-          :action="action"
-          :file-list="form.files"
-          :multiple="true"
-          :data="{ folder: 'goods_img' }"
-          list-type="picture-card"
-          :on-success="fileSuccess1"
-          :on-remove="handleRemove1">
-          <i class="el-icon-plus"></i>
-          <div slot="tip" class="el-upload__tip">鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�600*600px</div>
-        </el-upload>
+      <el-form-item label="鍟嗗搧鍥剧墖">
+        <UploadImage :fileList="form.multifileList" :uploadData="uploadData" @beginUpload="isUploading = true" @endUpload="isUploading = false" />
+        鍙兘涓婁紶鍥剧墖鏍煎紡锛宲ng鏍煎紡锛屽缓璁昂瀵�600*600px
       </el-form-item>
-      <template v-if="form.goodsParamList && form.goodsParamList.length > 0">
-        <div style="font-size: 18px;font-weight: bold;">鍙傛暟灞炴�у�奸厤缃� <span style="font-size: 13px; font-weight: 500;">鎸夐渶閰嶇疆褰撳墠鍟嗗搧鐨勪骇鍝佸弬鏁板�硷紝鍗曚釜鍙傛暟鍊间笉瓒呰繃30涓瓧</span></div>
-        <el-form-item :label="item.name" v-for="(item, index) in form.goodsParamList" :key="index">
-          <el-input v-model="item.val" maxlength="30" type="text" placeholder="璇疯緭鍏�" v-trim/>
+      <template v-if="form.baseGoodsParamList && form.baseGoodsParamList.length > 0">
+        <div style="font-size: 18px;font-weight: bold;">鍙傛暟灞炴�у�奸厤缃� <span
+            style="font-size: 13px; font-weight: 500;">鎸夐渶閰嶇疆褰撳墠鍟嗗搧鐨勪骇鍝佸弬鏁板�硷紝鍗曚釜鍙傛暟鍊间笉瓒呰繃30涓瓧</span></div>
+        <el-form-item :label="item.name" v-for="(item, index) in form.baseGoodsParamList" :key="index">
+          <el-input v-model="item.val" maxlength="30" type="text" placeholder="璇疯緭鍏�" v-trim />
         </el-form-item>
       </template>
     </el-form>
@@ -98,18 +50,21 @@
 <script>
 import BaseOpera from '@/components/base/BaseOpera'
 import GlobalWindow from '@/components/common/GlobalWindow'
-import { baseCategory,brand } from '@/api/system/common.js'
-import {  create, updateById, companyCreate, companyUpdateById } from '@/api/business/goods.js'
+import UploadAvatarImage from '@/components/common/UploadAvatarImage.vue'
+import UploadImage from '@/components/common/UploadImage.vue'
+import { baseCategory, brand } from '@/api/system/common.js'
+import { companyCreate, companyUpdateById } from '@/api/business/goods.js'
 export default {
   name: 'OperaGoodsWindow',
   extends: BaseOpera,
-  components: { GlobalWindow },
-  data () {
+  components: { GlobalWindow, UploadAvatarImage, UploadImage },
+  data() {
     return {
       action: process.env.VUE_APP_API_PREFIX + '/public/upload',
       name1: '',
       name2: '',
       // 琛ㄥ崟鏁版嵁
+      isUploading: false,
       form: {
         id: null,
         name: '',
@@ -117,17 +72,13 @@
         brandId: '',
         zdPrice: '',
         price: '',
-        attrFirstIds: [],
-        attrFirstNames: '',
-        attrSecodIds: [],
-        attrSecodNames: '',
         imgurl: '',
+        imgfullurl: '',
         multifileList: [],
-        files: [],
-        ztList: [],
-        goodsParamList: [],
-        attrFirstList: [],
-        attrSecodList: []
+        baseGoodsParamList: [],
+      },
+      uploadData: {
+        folder: 'goods_img'
       },
       // 楠岃瘉瑙勫垯
       rules: {
@@ -147,77 +98,42 @@
           { required: true, message: '涓嶈兘涓虹┖', trigger: 'blur' }
         ]
       },
-      options: [],
-      categoryList: [],
-      brandList: []
+      options: []
     }
   },
-  created () {
+  inject: ['categoryList', 'brandList'],
+  created() {
     this.config({
       api: '/business/goods',
       'field.id': 'id'
     })
-    this.getbrand()
-    this.getcategory()
-  },
-  watch: {
-    'form.categoryId': {
-      immediate: true,
-      handler(news, old) {
-        if (news) {
-          this.name1 = ''
-          this.name2 = ''
-          if (old) {
-            this.form.attrFirstIds = []
-            this.form.attrSecodIds = []
-            this.form.goodsParamList = []
-          }
-          this.categoryList.forEach(item => {
-            if (item.id === news) {
-              this.name1 = item.attrFirst
-              this.name2 = item.attrSecond
-              this.form.attrFirstList = item.attrFirstList.length > 0 ? item.attrFirstList : []
-              this.form.attrSecodList = item.attrSecondList.length > 0 ? item.attrSecondList : []
-              this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
-              this.form.goodsParamList.forEach(item => {
-                item.pramaId = item.id
-              })
-              console.log(this.form.goodsParamList)
-            }
-          })
-          this.getcategory(1)
-        }
-      }
-    },
-    visible: {
-      handler(news, old) {
-        if (!news) {
-          this.name1 = ''
-          this.name2 = ''
-          this.form = {
-            id: null,
-            name: '',
-            categoryId: '',
-            brandId: '',
-            zdPrice: '',
-            price: '',
-            attrFirstIds: [],
-            attrFirstNames: '',
-            attrSecodIds: [],
-            attrSecodNames: '',
-            imgurl: '',
-            multifileList: [],
-            files: [],
-            ztList: [],
-            goodsParamList: [],
-            attrFirstList: [],
-            attrSecodList: []
-          }
-        }
-      }
-    }
+    // this.getbrand()
+    // this.getcategory()
   },
   methods: {
+    open(title, target) {
+      this.title = title
+      this.visible = true
+      // 鏂板缓
+      if (target == null) {
+        this.$nextTick(() => {
+          this.$refs.form.resetFields()
+          this.form.multifileList = []
+          this.form.baseGoodsParamList = []
+          this.form[this.configData['field.id']] = null
+        })
+        return
+      }
+      // 缂栬緫
+      this.$nextTick(() => {
+        for (const key in this.form) {
+          this.form[key] = target[key]
+        }
+        this.form.multifileList.forEach(item => {
+          item.url = item.filefullurl
+        })
+      })
+    },
     priceCHANEG(val, type) {
       if (!/^[1-9]+[0-9]*$/.test(val)) {
         this.$message.warning('鍙兘杈撳叆姝f暣鏁�')
@@ -228,115 +144,20 @@
         }
       }
     },
-    confirm() {
-      this.$refs.form.validate((valid) => {
-        if (valid) {
-          if (this.form.attrFirstIds.length > 0) {
-            let arr = []
-            this.form.attrFirstIds.forEach(element => {
-              this.form.attrFirstList.forEach(item => {
-                if (element === item.id) {
-                  arr.push(item.name)
-                }
-              })
-            })
-            this.form.attrFirstNames = arr.join(',')
-            this.form.attrFirstIds = this.form.attrFirstIds.join(',')
-          } else {
-            this.form.attrFirstNames = ''
-            this.form.attrFirstIds = ''
-          }
-          if (this.form.attrSecodIds.length > 0) {
-            let arr = []
-            this.form.attrSecodIds.forEach(element => {
-              this.form.attrSecodList.forEach(item => {
-                if (element === item.id) {
-                  arr.push(item.name)
-                }
-              })
-            })
-            this.form.attrSecodNames = arr.join(',')
-            this.form.attrSecodIds = this.form.attrSecodIds.join(',')
-          } else {
-            this.form.attrSecodNames = ''
-            this.form.attrSecodIds = ''
-          }
-          if (!this.form.id) {
-            companyCreate({...this.form, type: 0})
-              .then(() => {
-                this.visible = false
-                this.$tip.apiSuccess('鏂板缓鎴愬姛')
-                this.$emit('success')
-              })
-              .catch(e => {
-                this.$tip.apiFailed(e)
-              })
-              .finally(() => {
-                this.isWorking = false
-              })
-          } else {
-            companyUpdateById({...this.form, type: 0})
-              .then(() => {
-                this.visible = false
-                this.$tip.apiSuccess('缂栬緫鎴愬姛')
-                this.$emit('success')
-              })
-              .catch(e => {
-                this.$tip.apiFailed(e)
-              })
-              .finally(() => {
-                this.isWorking = false
-              })
-          }
-        } else {
-          return false;
+    categorySelect(v) {
+      this.categoryList().forEach(item => {
+        if (item.id === v) {
+          this.form.baseGoodsParamList = JSON.parse(JSON.stringify(item.baseCateParamList))
+          this.form.baseGoodsParamList.forEach(item => {
+            item.pramaId = item.id
+          })
         }
-      });
-    },
-    exceed() {
-      this.$message.warning({
-        message: '鍙兘涓婁紶涓�涓浘鏍�'
       })
     },
-    fileSuccess1(response, file, fileList) {
-      this.form.files = fileList
-      this.form.multifileList.push({ fileurl: response.data.imgaddr, name: response.data.imgname, url: response.data.url })
-    },
-    handleRemove1(file, fileList) {
-      this.form.files = fileList
-      this.form.multifileList = fileList
-    },
-    fileSuccess(response) {
-      this.form.ztList.push({ imgaddr: response.data.imgaddr, url: response.data.url })
-      this.form.imgurl = response.data.imgaddr
-    },
-    handleRemove() {
-      this.form.ztList = []
-      this.form.imgurl = ''
-    },
-      getbrand() {
-        brand({status:0})
-          .then(res => {
-            this.brandList = res
-          })
-      },
-      getcategory(type) {
-        baseCategory({status:0 , type:1})
-          .then(res => {
-            this.categoryList = res
-            if (type === 1) {
-              this.categoryList.forEach(item => {
-                if (item.id === this.form.categoryId) {
-                  this.form.goodsParamList = JSON.parse(JSON.stringify(item.paramList))
-                  this.form.goodsParamList.forEach(item => {
-                    item.pramaId = item.id
-                  })
-                  console.log(this.form.goodsParamList)
-                }
-              })
-            }
-          })
-      }
+    uploadReverseSuccess(file) {
+      this.form.imgurl = file.imgurl;
+      this.form.imgfullurl = file.imgurlfull;
+    }
   }
 }
 </script>
diff --git a/platform/src/components/business/selectProduct.vue b/platform/src/components/business/selectProduct.vue
index 8137bca..d3702aa 100644
--- a/platform/src/components/business/selectProduct.vue
+++ b/platform/src/components/business/selectProduct.vue
@@ -62,7 +62,7 @@
     },
     created() {
       this.config({
-        api: '/business/anchor',
+        api: '/business/goods',
         'field.id': 'id'
       })
     },
diff --git a/platform/src/components/common/ImportButton.vue b/platform/src/components/common/ImportButton.vue
new file mode 100644
index 0000000..f9a64cb
--- /dev/null
+++ b/platform/src/components/common/ImportButton.vue
@@ -0,0 +1,37 @@
+<template>
+  <div class="import-button">
+    <el-button type="primary" @click="$refs.importWindow.open(text)">{{text}}</el-button>
+    <ImportWindow :action="action" :template-path="templatePath" :template-name="templateName" ref="importWindow" @success="handleSuccess"/>
+  </div>
+</template>
+
+<script>
+import ImportWindow from './ImportWindow'
+export default {
+  name: 'ImportButton',
+  components: { ImportWindow },
+  props: {
+    // 鎸夐挳鏂囨
+    text: {
+      default: '瀵煎叆'
+    },
+    // 妯$増鍦板潃
+    templatePath: {
+      required: true
+    },
+    // 涓嬭浇鍚庣殑妯$増鏂囦欢鍚嶇О
+    templateName: {
+      required: true
+    },
+    // 瀵煎叆鎺ュ彛鍦板潃
+    action: {
+      required: true
+    }
+  },
+  methods: {
+    handleSuccess () {
+      this.$emit('success')
+    }
+  }
+}
+</script>
diff --git a/platform/src/components/common/ImportWindow.vue b/platform/src/components/common/ImportWindow.vue
new file mode 100644
index 0000000..f25033c
--- /dev/null
+++ b/platform/src/components/common/ImportWindow.vue
@@ -0,0 +1,205 @@
+<template>
+  <el-dialog
+    width="500px"
+    :title="title"
+    :visible.sync="visible"
+    append-to-body
+    custom-class="eva-dialog import-window"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    :show-close="false"
+  >
+    <el-form>
+      <el-form-item>
+        <el-upload
+          drag
+          :show-file-list="false"
+          action="none"
+          accept=".xlsx, .xls"
+          :before-upload="handleBeforeUpload"
+        >
+          <template v-if="form.file == null">
+            <i class="el-icon-upload"></i>
+            <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+          </template>
+          <template v-else>
+            <i class="el-icon-files"></i>
+            <div class="el-upload__text">{{form.file.name}}<em></em></div>
+          </template>
+        </el-upload>
+      </el-form-item>
+    </el-form>
+    
+    <div slot="footer" class="import-window__footer">
+      <!-- <div class="sync-exists">
+        <el-checkbox v-model="form.sync"/><span>鍚屾宸插瓨鍦ㄧ殑鏁版嵁</span>
+      </div> -->
+      <div class="opera">
+        <a href=""></a>
+        <el-button type="text" icon="el-icon-download" @click="downloadTemplate">涓嬭浇妯$増</el-button>
+        <el-button @click="cancel">{{cancelText}}</el-button>
+        <el-button type="primary" @click="confirm" :loading="isWorking">{{confirmText}}</el-button>
+      </div>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+import request from '@/utils/request'
+export default {
+  name: 'ImportWindow',
+  props: {
+    // 瀵煎叆鎺ュ彛鍦板潃
+    action: {
+      required: true
+    },
+    // 纭鎸夐挳鏂囨
+    confirmText: {
+      type: String,
+      default: '瀵煎叆'
+    },
+    
+    // 鍙栨秷鎸夐挳鏂囨
+    cancelText: {
+      type: String,
+      default: '鍙栨秷'
+    },
+    // 妯$増鍦板潃
+    templatePath: {
+      required: true
+    },
+    // 涓嬭浇鍚庣殑妯$増鏂囦欢鍚嶇О
+    templateName: {
+      required: true
+    }
+  },
+  data () {
+    return {
+      visible: false,
+      isWorking: false,
+      title: '瀵煎叆鏁版嵁',
+      form: {
+        sync: false,
+        file: false,
+        categoryId: ''
+      }
+    }
+  },
+  methods: {
+    /**
+     * 鎵撳紑绐楀彛
+     *
+     * @param title 绐楀彛鏍囬
+     */
+    open (title) {
+      this.visible = true
+      this.title = title
+      this.form.sync = false
+      this.form.file = null
+    },
+    /**
+     * 纭畾瀵煎叆
+     */
+    confirm () {
+      if (this.form.file == null) {
+        this.$message.warning('璇烽�夋嫨鏂囦欢')
+        return
+      }
+      this.isWorking = true
+      const param = new FormData()
+      param.set('file', this.form.file)
+      request.post(this.action, param, {
+        headers: {
+          'Content-Type': 'multipart/form-data;charset=UTF-8'
+        }
+      })
+        .then(() => {
+          this.$message.success('瀵煎叆鎴愬姛')
+          this.visible = false
+          this.$emit('success')
+        })
+        .catch(e => {
+          this.$message.error(e)
+        })
+        .finally(() => {
+          this.isWorking = false
+        })
+    },
+    /**
+     * 鍙栨秷
+     */
+    cancel () {
+      this.visible = false
+    },
+    /**
+     * 涓嬭浇妯$増
+     */
+    downloadTemplate () {
+      const link = document.createElement('a')
+      link.setAttribute('download', this.templateName) //涓嬭浇鐨勬枃浠跺悕
+      // console.log(`window.location.origin`, window.location.origin);
+      // console.log(`process.env.VUE_APP_CONTEXT_PATH`, process.env.VUE_APP_CONTEXT_PATH);
+      // console.log(`this.templatePath`, this.templatePath);
+      link.href = `${window.location.origin}${process.env.VUE_APP_CONTEXT_PATH}${this.templatePath}`  //鏂囦欢url
+      link.click()
+    },
+    /**
+     * 鏂囦欢涓婁紶鍓嶅瓨鍌ㄤ笂浼犵殑鏂囦欢
+     *
+     * @param file 闇�瀵煎叆鐨勬枃浠�
+     */
+    handleBeforeUpload (file) {
+      this.form.file = file
+      return false
+    }
+  }
+}
+</script>
+
+<style lang="scss">
+@import "../../assets/style/variables";
+.import-window {
+  .el-upload {
+    width: 100%;
+    .el-upload-dragger {
+      width: 100%;
+      .el-icon-upload, .el-icon-files {
+        font-size: 67px;
+        color: #C0C4CC;
+        margin: 40px 0 16px;
+        line-height: 50px;
+      }
+    }
+  }
+  .import-window__footer {
+    display: flex;
+    .sync-exists {
+      width: 200px;
+      flex-shrink: 0;
+      text-align: left;
+      font-size: 13px;
+      display: flex;
+      align-items: center;
+      .el-checkbox {
+        margin-right: 10px;
+      }
+      & > * {
+        vertical-align: middle;
+      }
+    }
+    .opera {
+      flex-grow: 1;
+      a {
+        font-size: 12px;
+        margin-right: 10px;
+        text-decoration: none;
+        .el-icon-download {
+          font-size: 15px;
+          position: relative;
+          top: 2px;
+        }
+      }
+    }
+  }
+}
+</style>
diff --git a/platform/src/components/common/UploadImage.vue b/platform/src/components/common/UploadImage.vue
index 67ccb8a..d2ab4df 100644
--- a/platform/src/components/common/UploadImage.vue
+++ b/platform/src/components/common/UploadImage.vue
@@ -59,7 +59,7 @@
   },
   data() {
     return {
-      uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/uploadLocal',
+      uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/upload',
       
       realList: [],
       srcList: [],
diff --git a/platform/src/views/business/goods.vue b/platform/src/views/business/goods.vue
index 8992e61..b7f8046 100644
--- a/platform/src/views/business/goods.vue
+++ b/platform/src/views/business/goods.vue
@@ -1,6 +1,6 @@
 
 <template>
-  <TableLayout :permissions="['business:goods:query']">
+  <TableLayout :permissions="['business:basegoods:query']">
     <!-- 鎼滅储琛ㄥ崟 -->
     <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
       <el-form-item label="鍟嗗搧鍚嶇О" prop="name">
@@ -37,15 +37,17 @@
     </el-form>
     <!-- 琛ㄦ牸鍜屽垎椤� -->
     <template v-slot:table-wrap>
-      <ul class="toolbar" v-permissions="['business:goods:create', 'business:goods:delete']">
-        <li><el-button type="primary" @click="$refs.operaGoodsWindow.open('鏂板缓鍟嗗搧')" icon="el-icon-plus"
-            v-permissions="['business:goods:create']">鏂板缓</el-button></li>
+      <ul class="toolbar" v-permissions="['business:basegoods:create', 'business:basegoods:delete']">
+        <li v-permissions="['business:basegoods:create']">
+          <el-button type="primary" @click="$refs.operaGoodsWindow.open('鏂板缓鍟嗗搧')" icon="el-icon-plus">鏂板缓</el-button>
+        </li>
         <!-- <el-button type="primary" :loading="isWorking.export"
           @click="$refs.selectProduct.open('閫夋嫨骞冲彴鍟嗗搧')">閫夋嫨骞冲彴鍟嗗搧</el-button> -->
-        <el-button type="primary" :loading="isWorking.export" v-permissions="['business:goods:exportExcel']"
-          @click="importFile">瀵煎叆</el-button>
-        <el-button type="primary" :loading="isWorking.export" @click="downloadFile">涓嬭浇妯℃澘</el-button>
-
+        <li v-permissions="['business:basegoods:exportExcel']">
+          <ImportButton text="瀵煎叆" template-name="goods_import_modle.xlsx"
+            template-path="/template/goods_import_modle.xlsx" action="/business/baseGoods/importExcel"
+            @success="search" />
+        </li>
         <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(0)">鎵归噺涓婃灦</el-button>
         <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(1)">鎵归噺涓嬫灦</el-button>
         <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">鍒犻櫎</el-button></li> -->
@@ -77,17 +79,16 @@
             </el-switch>
           </template>
         </el-table-column>
-        <el-table-column v-if="containPermissions(['business:goods:update', 'business:goods:delete'])" label="鎿嶄綔"
+        <el-table-column v-if="containPermissions(['business:basegoods:update', 'business:basegoods:delete'])" label="鎿嶄綔"
           min-width="120" fixed="right">
           <template slot-scope="{row}">
             <el-button type="text" @click="edit(row.id)" icon="el-icon-edit"
-              v-permissions="['business:goods:update']">缂栬緫</el-button>
+              v-permissions="['business:basegoods:update']">缂栬緫</el-button>
             <el-button type="text" @click="deleteById(row)" icon="el-icon-delete"
-              v-permissions="['business:goods:delete']">鍒犻櫎</el-button>
+              v-permissions="['business:basegoods:delete']">鍒犻櫎</el-button>
           </template>
         </el-table-column>
       </el-table>
-      <input type="file" ref="upload" style="display: none;" @change="uplaodFile" />
       <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination">
       </pagination>
     </template>
@@ -104,12 +105,13 @@
 import Pagination from '@/components/common/Pagination'
 import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
 import selectProduct from '@/components/business/selectProduct'
+import ImportButton from '@/components/common/ImportButton'
 import { brand, baseCategory, importExcel } from '@/api/system/common.js'
 import { updateStatus, queryById, exportDoc } from '@/api/business/goods.js'
 export default {
   name: 'Goods',
   extends: BaseTable,
-  components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct },
+  components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct, ImportButton },
   data() {
     return {
       // 鎼滅储
@@ -130,6 +132,12 @@
       ]
     }
   },
+  provide() {
+    return {
+      brandList: () => this.brandList,
+      categoryList: () => this.categoryList
+    }
+  },
   created() {
     this.config({
       module: '鍟嗗搧',
@@ -146,7 +154,6 @@
       let arr = e.map(item => item.id)
       this.ids = arr.join(',')
       this.idList = arr;
-      console.log(this.ids)
     },
     // 鎵归噺涓婁笅鏋�
     bulkOperation(type) {
@@ -175,52 +182,10 @@
     rowStyle() {
       return "text-align:center";
     },
-    importFile() {
-      this.$refs.upload.click()
-    },
-    uplaodFile(e) {
-      const FORMDATE = new FormData()
-      FORMDATE.append('file', e.target.files[0])
-      // 璇锋眰鎺ュ彛
-      importExcel(FORMDATE)
-        .then(res => {
-          console.log(res)
-          this.search()
-        })
-        .catch((err) => {
-          this.$message.error(err.message)
-        })
-      this.$refs.upload.value = null
-    },
     edit(id) {
       queryById(id)
         .then(res => {
-          let obj = {
-            id: res.id,
-            name: res.name,
-            categoryId: res.categoryId,
-            brandId: res.brandId,
-            zdPrice: res.zdPrice,
-            price: res.price,
-            attrFirstIds: res.attrFirstIds ? this.turnNum(res.attrFirstIds.split(',')) : [],
-            attrFirstNames: res.attrFirstNames,
-            attrSecodIds: res.attrSecodIds ? this.turnNum(res.attrSecodIds.split(',')) : [],
-            attrSecodNames: res.attrSecodNames,
-            imgurl: res.imgurl,
-            multifileList: [],
-            files: [],
-            ztList: res.imgurl ? [{ url: res.prefixUrl + res.imgurl }] : [],
-            pzList: [],
-            attrFirstList: [],
-            attrSecodList: []
-          }
-          if (res.multifileList.length > 0) {
-            res.multifileList.forEach(item => {
-              obj.multifileList.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl })
-              obj.files.push({ fileurl: item.fileurl, name: item.name, url: res.prefixUrl + item.fileurl })
-            })
-          }
-          this.$refs.operaGoodsWindow.open('缂栬緫鍟嗗搧', obj)
+          this.$refs.operaGoodsWindow.open('缂栬緫鍟嗗搧', res)
         })
     },
     changeStatus(item) {
@@ -233,14 +198,8 @@
         // this.search()
       })
     },
-    turnNum(nums) {
-      for (let i = 0; i < nums.length; i++) {
-        nums[i] = parseInt(nums[i])
-      }
-      return nums;
-    },
     getbrand() {
-      brand({type:1})
+      brand({ type: 1 })
         .then(res => {
           this.brandList = res
         })
diff --git a/platform/vue.config.js b/platform/vue.config.js
index 1b17444..e26acf4 100644
--- a/platform/vue.config.js
+++ b/platform/vue.config.js
@@ -1,9 +1,8 @@
-// 璇︾粏閰嶇疆璇峰弬鑰僪ttps://cli.vuejs.org/zh/config/#vue-config-js
-// const outputDir = process.env.VUE_APP_CONTEXT_PATH.substring(1, process.env.VUE_APP_CONTEXT_PATH.length - 1)
-// outputDir === '/' ? 'dist' : outputDir
+
+const outputDir = process.env.VUE_APP_CONTEXT_PATH.substring(1, process.env.VUE_APP_CONTEXT_PATH.length)
 module.exports = {
-  publicPath: process.env.VUE_APP_CONTEXT_PATH,
-  outputDir: 'dist',
+  publicPath: './',
+  outputDir: outputDir,
   assetsDir: 'static',
   lintOnSave: false,
   devServer: {

--
Gitblit v1.9.3