From 9c0da9844a0ce229c832ea2a8a11be9633f437de Mon Sep 17 00:00:00 2001 From: fanfan Date: Fri, 12 Apr 2024 14:39:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=9C=80=E6=B1=82=E5=8F=8Abu?= =?UTF-8?q?g=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/goods/index.js | 12 ++ src/components/Table/GoodsItem/GoodsItem.vue | 49 +++--- src/config/router.config.js | 6 + src/views/goods/Index.vue | 98 ++++++++++- src/views/goods/modify.vue | 170 +++++++++++++++++++ 5 files changed, 303 insertions(+), 32 deletions(-) create mode 100644 src/views/goods/modify.vue diff --git a/src/api/goods/index.js b/src/api/goods/index.js index 21b7676..0d58849 100644 --- a/src/api/goods/index.js +++ b/src/api/goods/index.js @@ -11,6 +11,7 @@ const api = { delete: '/goods/delete', state: '/goods/state', dataList:'store/platformList', + exportData:'/goods/import', } // 列表记录 @@ -107,3 +108,14 @@ export function getDataList (data) { data: data }) } +/** + * 导出 + * @param {*} data + */ +export function exportData (data) { + return axios({ + url: api.exportData, + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/src/components/Table/GoodsItem/GoodsItem.vue b/src/components/Table/GoodsItem/GoodsItem.vue index b01aebd..c8accf6 100644 --- a/src/components/Table/GoodsItem/GoodsItem.vue +++ b/src/components/Table/GoodsItem/GoodsItem.vue @@ -6,17 +6,19 @@
-

{{ dataObj.title }}

+ +

{{ dataObj.title }}

-

{{ dataObj.subtitle }}

+

+ {{ dataObj.subtitle }} +

- {{ props.value.name }} + + {{ props.value.name }}
@@ -34,28 +36,29 @@ export default { // 商品信息 data: PropTypes.object.def({}), // 副标题颜色 - subTitleColor: PropTypes.bool.def(false) + subTitleColor: PropTypes.bool.def(false), }, computed: { - dataObj () { - return Object.assign({ - image: '', - imageAlt: '', - title: '', - subtitle: '', - goodsProps: [], - titleWidth: 200 - }, this.$props.data) - } + dataObj() { + return Object.assign( + { + image: '', + imageAlt: '', + title: '', + subtitle: '', + goodsProps: [], + titleWidth: 200, + }, + this.$props.data + ) + }, }, - data () { + data() { return { - isEmpty + isEmpty, } }, - methods: { - - } + methods: {}, } diff --git a/src/config/router.config.js b/src/config/router.config.js index 06fd31c..16a9db1 100644 --- a/src/config/router.config.js +++ b/src/config/router.config.js @@ -252,6 +252,12 @@ export const asyncRouterMap = [ meta: { title: '编辑商品', keepAlive: false, permission: ['/goods/update'] }, hidden: true, }, + { + path: '/goods/modify', + component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/modify'), + meta: { title: '批量修改', keepAlive: false, permission: ['/goods/modify'] }, + hidden: true, + }, { path: '/goods/copy', component: () => import(/* webpackChunkName: "goods" */ '@/views/goods/Copy'), diff --git a/src/views/goods/Index.vue b/src/views/goods/Index.vue index 21221d2..5b98181 100644 --- a/src/views/goods/Index.vue +++ b/src/views/goods/Index.vue @@ -34,6 +34,22 @@ + +
+ - + +
+
+ +
+ - + +
+
搜索 @@ -59,6 +75,12 @@ @click="handleImport()" >批量导入 + 导出 + 批量修改
上架 @@ -87,8 +109,11 @@ - -

{{ text }}

+ + {{ + text + }} +

{{ text }}

@@ -119,70 +144,91 @@ import * as GoodsApi from '@/api/goods' import { ContentHeader, STable } from '@/components' import CategoryModel from '@/common/model/Category' +import store from '../../store' // 表格表头 const columns = [ { title: '商品ID', dataIndex: 'goods_id', - width: '100px', + width: '80px', sorter: true, }, { title: '渠道', - width: '60px', + width: '50px', dataIndex: 'channel_name', }, { title: '商品编号', dataIndex: 'goods_no', - width: '120px', + width: '100px', }, { title: '商品图片', + width: '100px', dataIndex: 'goods_image', scopedSlots: { customRender: 'goods_image' }, }, { title: '商品名称', dataIndex: 'goods_name', - width: '302px', + width: '260px', scopedSlots: { customRender: 'goods_name' }, }, { title: '商品价格', + width: '90px', dataIndex: 'goods_price_min', scopedSlots: { customRender: 'goods_price_min' }, sorter: true, }, { title: '成本价', - dataIndex: 'cost_price', - scopedSlots: { customRender: 'cost_price' }, + width: '80px', + dataIndex: 'cost_price_min', + scopedSlots: { customRender: 'cost_price_min' }, + sorter: true, + }, + { + title: '利润', + width: '80px', + dataIndex: 'profit', + sorter: true, + }, + { + title: '利润率', + width: '80px', + dataIndex: 'profit_rate', sorter: true, + scopedSlots: { customRender: 'profit_rate' }, }, { title: '总销量', + width: '80px', dataIndex: 'sales_actual', sorter: true, }, { title: '库存总量', + width: '90px', dataIndex: 'stock_total', sorter: true, }, { title: '状态', + width: '60px', dataIndex: 'status', scopedSlots: { customRender: 'status' }, }, { title: '排序', + width: '80px', dataIndex: 'sort', sorter: true, }, { title: '添加时间', - width: '180px', + width: '130px', dataIndex: 'create_time', sorter: true, }, @@ -265,6 +311,40 @@ export default { }, }, methods: { + // 批量修改 + handleModify() { + this.$router.push('/goods/modify') + }, + // 导出 + handleExport(goodsIds) { + const formData = this.searchForm.getFieldsValue() + this.isLoading = true + var index = window.publicConfig.BASE_API.indexOf('?') + var resolve = window.publicConfig.BASE_API.substring(0, index) + let params = + '&goodsName=' + + (formData.goodsName || '') + + '&goodsNo=' + + (formData.goodsNo || '') + + '&goods_price_max=' + + (formData.goods_price_max || '') + + '&goods_price_min=' + + (formData.goods_price_min || '') + + '&profit_rate_max=' + + (formData.profit_rate_max || '') + + '&profit_rate_min=' + + (formData.profit_rate_min || '') + + '&categoryId=' + + (this.queryParam.categoryId || '') + + '&channel=' + + this.queryParam.channel + + '&goodsIds=' + + goodsIds + + '&Access-Token=' + + store.getters.token + console.log(params) + window.open(resolve + '?s=/admin/goods/export' + params) + }, getChannel(val) { this.queryParam.channel = val }, diff --git a/src/views/goods/modify.vue b/src/views/goods/modify.vue new file mode 100644 index 0000000..fe1159b --- /dev/null +++ b/src/views/goods/modify.vue @@ -0,0 +1,170 @@ + + + +