From 3ac279c9df7181c9f21d35a689a321b990b87b22 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 08 六月 2026 17:42:33 +0800
Subject: [PATCH] aaa
---
company_admin/src/views/business/goods.vue | 339 +++++++++++++++++++++++++++++--------------------------
1 files changed, 179 insertions(+), 160 deletions(-)
diff --git a/company_admin/src/views/business/goods.vue b/company_admin/src/views/business/goods.vue
index 1b081e2..c7109ef 100644
--- a/company_admin/src/views/business/goods.vue
+++ b/company_admin/src/views/business/goods.vue
@@ -63,12 +63,13 @@
<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>
- <!-- <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">鍒犻櫎</el-button></li> -->
+ <el-button type="danger" :loading="isWorking.export" @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:goods:delete']">鎵归噺鍒犻櫎</el-button>
</ul>
<el-table
v-loading="isWorking.search"
@@ -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"
@@ -151,163 +153,180 @@
<selectProduct ref="selectProduct" @success="handlePageChange" @result="search"/>
</TableLayout>
</template>
-
- <script>
- import BaseTable from '@/components/base/BaseTable'
- import TableLayout from '@/layouts/TableLayout'
- 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'
- export default {
- name: 'Goods',
- extends: BaseTable,
- components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct },
- data () {
- return {
- // 鎼滅储
- searchForm: {
- id: '',
- name: '',
- status: '',
- categoryId: '',
- brandId: '',
- type: ''
- },
- ids: '',
- categoryList: [],
- brandList: [],
- statusList: [
- { name: '鍚敤', id: 0 },
- { name: '绂佺敤', id: 1 }
- ],
- typeList: [
- { name: '鑷缓', id: 0 },
- { name: '鎷夊彇', id: 1 }
- ]
- }
- },
- created () {
- this.config({
- module: '鍟嗗搧',
- api: '/business/goods',
- 'field.id': 'id',
- 'field.main': 'name'
- })
- this.search()
- this.getbrand()
- this.getcategory()
- },
- methods: {
- handleSelectionChange(e) {
- let arr = e.map(item => item.id)
- this.ids = arr.join(',')
- console.log(this.ids)
+<script>
+import BaseTable from '@/components/base/BaseTable'
+import TableLayout from '@/layouts/TableLayout'
+import Pagination from '@/components/common/Pagination'
+import OperaGoodsWindow from '@/components/business/OperaGoodsWindow'
+import selectProduct from '@/components/business/selectProduct'
+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,
+ components: { TableLayout, Pagination, OperaGoodsWindow, selectProduct },
+ data () {
+ return {
+ // 鎼滅储
+ searchForm: {
+ id: '',
+ name: '',
+ status: '',
+ categoryId: '',
+ brandId: '',
+ type: ''
},
- // 鎵归噺涓婁笅鏋�
- bulkOperation(type) {
- if (!this.ids) {
- this.$message.warning({ message: '鑷冲皯閫夋嫨涓�椤瑰唴瀹�' })
- return
- }
- batchUpdateDisableById({
- ids: this.ids,
- status: type
- }).then(res => {
- this.$message.success({ message: res })
- this.search()
- })
- },
- downloadFile() {
- exportDoc({})
- .then(response => {
- this.download(response)
- })
- .catch(e => {
- this.$tip.apiFailed(e)
- })
- },
- 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)
- })
- },
- changeStatus(item) {
- updateDisableById({
- id: item.id,
- status: item.status
- }).then(res => {
- this.$tip.apiSuccess('鏇存柊鎴愬姛')
- }).finally(() => {
- // this.search()
- })
- },
- turnNum (nums) {
- for(let i=0;i<nums.length;i++){
- nums[i] = parseInt(nums[i])
- }
- return nums;
- },
- getbrand() {
- brand({})
- .then(res => {
- this.brandList = res
- })
- },
- getcategory() {
- category({})
- .then(res => {
- this.categoryList = res
- })
- }
+ ids: '',
+ categoryList: [],
+ brandList: [],
+ statusList: [
+ { name: '鍚敤', id: 0 },
+ { name: '绂佺敤', id: 1 }
+ ],
+ typeList: [
+ { name: '鑷缓', id: 0 },
+ { name: '鎷夊彇', id: 1 }
+ ],
+ uploading: false
}
+ },
+ created () {
+ this.config({
+ module: '鍟嗗搧',
+ api: '/business/goods',
+ 'field.id': 'id',
+ 'field.main': 'name'
+ })
+ this.search()
+ this.getbrand()
+ this.getcategory()
+ },
+ methods: {
+ // handleSelectionChange(e) {
+ // let arr = e.map(item => item.id)
+ // this.ids = arr.join(',')
+ // console.log(this.ids)
+ // },
+ // 鎵归噺涓婁笅鏋�
+ bulkOperation (type) {
+ if (this.tableData.selectedRows.length === 0) {
+ // if (!this.ids) {
+ this.$message.warning({ message: '鑷冲皯閫夋嫨涓�椤瑰唴瀹�' })
+ return
+ }
+ const idList = this.tableData.selectedRows.map(item => item.id)
+ batchUpdateDisableById({
+ ids: idList.join(','),
+ status: type
+ }).then(res => {
+ this.$message.success({ message: res })
+ this.handlePageChange()
+ })
+ },
+ 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";
+ },
+ pickImportFile () {
+ hasUnfinishedTask()
+ .then(res => {
+ if (res) {
+ this.$message.warning('褰撳墠瀛樺湪鏈畬鎴愮殑瀵煎叆浠诲姟锛岃绛夊緟瀹屾垚鍚庡啀鎻愪氦')
+ return
+ }
+ this.$refs.upload.click()
+ })
+ .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)
+ .then(res => {
+ let obj = {
+ id: res.id,
+ name: res.name,
+ categoryId: res.categoryId,
+ subCategoryId: res.subCategoryId != null ? res.subCategoryId : '',
+ 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, response: { data: { imgaddr: item.fileurl, imgname: item.name } } })
+ })
+ }
+ this.$refs.operaGoodsWindow.open('缂栬緫鍟嗗搧', obj)
+ })
+ },
+ changeStatus(item) {
+ updateDisableById({
+ id: item.id,
+ status: item.status
+ }).then(res => {
+ this.$tip.apiSuccess('鏇存柊鎴愬姛')
+ }).finally(() => {
+ this.search()
+ }).catch(err => {
+ this.$message.warning({ message: err.message })
+ })
+ },
+ turnNum (nums) {
+ for(let i=0;i<nums.length;i++){
+ nums[i] = parseInt(nums[i])
+ }
+ return nums;
+ },
+ getbrand() {
+ brand({})
+ .then(res => {
+ this.brandList = res
+ })
+ },
+ getcategory() {
+ category({})
+ .then(res => {
+ this.categoryList = res
+ })
+ }
}
- </script>
-
\ No newline at end of file
+}
+</script>
\ No newline at end of file
--
Gitblit v1.9.3