From cf2da3b2a63840888815c6a81cbd7948faf93533 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 08 六月 2026 17:41:15 +0800
Subject: [PATCH] aaa

---
 company_admin/src/views/business/goods.vue |   57 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/company_admin/src/views/business/goods.vue b/company_admin/src/views/business/goods.vue
index ee35be5..c7109ef 100644
--- a/company_admin/src/views/business/goods.vue
+++ b/company_admin/src/views/business/goods.vue
@@ -63,8 +63,9 @@
         <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>
           <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="uploading" v-permissions="['business:goodsImportTask:create']" @click="pickImportFile">鎻愪氦寮傛瀵煎叆</el-button>
           <el-button type="primary" :loading="isWorking.export" @click="downloadFile">涓嬭浇妯℃澘</el-button>
+          <el-button type="primary" plain v-permissions="['business:goodsImportTask:query']" @click="$router.push('/business/goodsImportTask')">瀵煎叆浠诲姟</el-button>
 
           <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(0)">鎵归噺涓婃灦</el-button>
           <el-button type="primary" :loading="isWorking.export" @click="bulkOperation(1)">鎵归噺涓嬫灦</el-button>
@@ -98,6 +99,7 @@
           </el-table-column>
           <el-table-column prop="brandName" label="鍝佺墝" min-width="100px"></el-table-column>
           <el-table-column prop="categoryName" label="绫诲埆" min-width="100px"></el-table-column>
+          <el-table-column prop="subCategoryName" label="浜岀骇绫诲埆" min-width="100px"></el-table-column>
           <el-table-column prop="categoryName" label="绫诲瀷" min-width="100px">
             <template slot-scope="{row}">
               <span v-if="row.type == 0">鑷缓</span>
@@ -137,7 +139,7 @@
             </template>
           </el-table-column>
         </el-table>
-        <input type="file" ref="upload" style="display: none;" @change="uplaodFile" />
+        <input type="file" ref="upload" accept=".xlsx,.xls" style="display: none;" @change="uploadImportFile" />
         <pagination
           @size-change="handleSizeChange"
           @current-change="handlePageChange"
@@ -157,8 +159,9 @@
 import Pagination from '@/components/common/Pagination'
 import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
 import selectProduct from '@/components/business/selectProduct'
-import { brand, category, importExcel } from '@/api/system/common.js'
-import { updateDisableById, queryById, exportDoc, batchUpdateDisableById } from '@/api/business/goods.js'
+import { brand, category } from '@/api/system/common.js'
+import { updateDisableById, queryById, batchUpdateDisableById } from '@/api/business/goods.js'
+import { exportImportTemplate, importExcelAsync, hasUnfinishedTask } from '@/api/business/goodsImportTask'
 export default {
   name: 'Goods',
   extends: BaseTable,
@@ -184,7 +187,8 @@
       typeList: [
         { name: '鑷缓', id: 0 },
         { name: '鎷夊彇', id: 1 }
-      ]
+      ],
+      uploading: false
     }
   },
   created () {
@@ -220,34 +224,46 @@
         this.handlePageChange()
       })
     },
-    downloadFile() {
-      exportDoc({})
+    downloadFile () {
+      this.isWorking.export = true
+      exportImportTemplate({})
         .then(response => {
           this.download(response)
         })
         .catch(e => {
           this.$tip.apiFailed(e)
         })
+        .finally(() => {
+          this.isWorking.export = false
+        })
     },
     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)
+    pickImportFile () {
+      hasUnfinishedTask()
         .then(res => {
-          console.log(res)
-          this.search()
+          if (res) {
+            this.$message.warning('褰撳墠瀛樺湪鏈畬鎴愮殑瀵煎叆浠诲姟锛岃绛夊緟瀹屾垚鍚庡啀鎻愪氦')
+            return
+          }
+          this.$refs.upload.click()
         })
-        .catch ((err) => {
-          this.$message.error(err.message)
-        })
+        .catch(e => this.$tip.apiFailed(e))
+    },
+    uploadImportFile (e) {
+      const file = e.target.files && e.target.files[0]
       this.$refs.upload.value = null
+      if (!file) return
+      const formData = new FormData()
+      formData.append('file', file)
+      this.uploading = true
+      importExcelAsync(formData)
+        .then(() => {
+          this.$message.success('瀵煎叆浠诲姟宸叉彁浜わ紝璇峰墠寰�銆屽鍏ヤ换鍔°�嶆煡鐪嬭繘搴�')
+        })
+        .catch(err => this.$message.error(err.message || '鎻愪氦澶辫触'))
+        .finally(() => { this.uploading = false })
     },
     edit(id) {
       queryById(id)
@@ -256,6 +272,7 @@
             id: res.id,
             name: res.name,
             categoryId: res.categoryId,
+            subCategoryId: res.subCategoryId != null ? res.subCategoryId : '',
             brandId: res.brandId,
             zdPrice: res.zdPrice,
             price: res.price,

--
Gitblit v1.9.3