Skip to content

Commit 4ef0bfc

Browse files
committed
mall:code review 商品模块的代码
1 parent 6f8b984 commit 4ef0bfc

File tree

3 files changed

+77
-213
lines changed

3 files changed

+77
-213
lines changed

src/api/mall/product/spu.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,3 @@ export function getSpuPage(query) {
4242
params: query
4343
})
4444
}
45-
46-
// 导出商品spu Excel
47-
export function exportSpuExcel(query) {
48-
return request({
49-
url: '/product/spu/export-excel',
50-
method: 'get',
51-
params: query,
52-
responseType: 'blob'
53-
})
54-
}

src/views/mall/product/spu/index.vue

Lines changed: 32 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,51 @@
11
<template>
22
<div class="app-container">
33
<!-- 搜索工作栏 -->
4-
<el-form
5-
:model="queryParams"
6-
ref="queryForm"
7-
size="small"
8-
:inline="true"
9-
v-show="showSearch"
10-
label-width="68px"
11-
>
4+
<!-- TODO @Luowenfeng:参考界面;https://v5.niuteam.cn/shop/goods/lists.html
5+
商品名称、商品编码、商品分类、商品品牌
6+
商品销量、商品价格
7+
-->
8+
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
129
<el-form-item label="商品名称" prop="name">
13-
<el-input
14-
v-model="queryParams.name"
15-
placeholder="请输入商品名称"
16-
clearable
17-
@keyup.enter.native="handleQuery"
18-
/>
10+
<el-input v-model="queryParams.name" placeholder="请输入商品名称" clearable @keyup.enter.native="handleQuery"/>
1911
</el-form-item>
2012
<el-form-item label="分类id" prop="categoryId">
21-
<el-input
22-
v-model="queryParams.categoryId"
23-
placeholder="请输入分类id"
24-
clearable
25-
@keyup.enter.native="handleQuery"
26-
/>
13+
<el-input v-model="queryParams.categoryId" placeholder="请输入分类id" clearable @keyup.enter.native="handleQuery"/>
2714
</el-form-item>
2815
<el-form-item label="状态" prop="status">
29-
<el-select
30-
v-model="queryParams.status"
31-
placeholder="请选择上下架状态"
32-
clearable
33-
size="small"
34-
>
16+
<el-select v-model="queryParams.status" placeholder="请选择上下架状态" clearable size="small">
3517
<el-option label="请选择字典生成" value="" />
3618
<el-option label="上架" value="0" />
3719
<el-option label="下架" value="1" />
3820
</el-select>
3921
</el-form-item>
4022
<el-form-item label="创建时间">
41-
<el-date-picker
42-
v-model="dateRangeCreateTime"
43-
style="width: 240px"
44-
value-format="yyyy-MM-dd"
45-
type="daterange"
46-
range-separator="-"
47-
start-placeholder="开始日期"
48-
end-placeholder="结束日期"
49-
/>
23+
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
24+
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/>
5025
</el-form-item>
5126
<el-form-item>
52-
<el-button type="primary" icon="el-icon-search" @click="handleQuery"
53-
>搜索</el-button
54-
>
27+
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
5528
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
5629
</el-form-item>
5730
</el-form>
5831

5932
<!-- 操作工具栏 -->
6033
<el-row :gutter="10" class="mb8">
6134
<el-col :span="1.5">
62-
<el-button
63-
type="primary"
64-
plain
65-
icon="el-icon-plus"
66-
size="mini"
67-
@click="handleAdd"
68-
v-hasPermi="['product:spu:create']"
69-
>新增
70-
</el-button>
35+
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
36+
v-hasPermi="['product:spu:create']">新增</el-button>
7137
</el-col>
72-
<el-col :span="1.5">
73-
<el-button
74-
type="warning"
75-
plain
76-
icon="el-icon-download"
77-
size="mini"
78-
@click="handleExport"
79-
:loading="exportLoading"
80-
v-hasPermi="['product:spu:export']"
81-
>导出
82-
</el-button>
83-
</el-col>
84-
<right-toolbar
85-
:showSearch.sync="showSearch"
86-
@queryTable="getList"
87-
></right-toolbar>
38+
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
8839
</el-row>
8940

9041
<!-- 列表 -->
9142
<el-table v-loading="loading" :data="list">
43+
<!--
44+
TODO @Luowenfeng:参考界面;
45+
https://v5.niuteam.cn/shop/goods/lists.html
46+
1. 字段:商品信息、价格、库存、销量、排序、创建时间、状态、操作;
47+
2. tab 分成全部、销售中、仓库中、预警中
48+
-->
9249
<el-table-column label="主键" align="center" prop="id" />
9350
<el-table-column label="商品名称" align="center" prop="name" />
9451
<el-table-column label="分类id" align="center" prop="categoryId" />
@@ -111,50 +68,23 @@
11168
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
11269
</template>
11370
</el-table-column>
114-
<el-table-column
115-
label="创建时间"
116-
align="center"
117-
prop="createTime"
118-
width="180"
119-
>
71+
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
12072
<template slot-scope="scope">
12173
<span>{{ parseTime(scope.row.createTime) }}</span>
12274
</template>
12375
</el-table-column>
124-
<el-table-column
125-
label="操作"
126-
align="center"
127-
class-name="small-padding fixed-width"
128-
>
76+
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
12977
<template slot-scope="scope">
130-
<el-button
131-
size="mini"
132-
type="text"
133-
icon="el-icon-edit"
134-
@click="handleUpdate(scope.row)"
135-
v-hasPermi="['product:spu:update']"
136-
>修改
137-
</el-button>
138-
<el-button
139-
size="mini"
140-
type="text"
141-
icon="el-icon-delete"
142-
@click="handleDelete(scope.row)"
143-
v-hasPermi="['product:spu:delete']"
144-
>删除
145-
</el-button>
78+
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
79+
v-hasPermi="['product:spu:update']">修改</el-button>
80+
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
81+
v-hasPermi="['product:spu:delete']">删除</el-button>
14682
</template>
14783
</el-table-column>
14884
</el-table>
14985
<!-- 分页组件 -->
150-
<pagination
151-
v-show="total > 0"
152-
:total="total"
153-
:page.sync="queryParams.pageNo"
154-
:limit.sync="queryParams.pageSize"
155-
@pagination="getList"
156-
/>
157-
86+
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
87+
@pagination="getList"/>
15888

15989
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body destroy-on-close :close-on-click-modal="false" >
16090
<save @closeDialog="closeDialog" :type="dialogType" :obj="dialogObj" v-if="open" />
@@ -166,13 +96,15 @@
16696
import {
16797
deleteSpu,
16898
getSpuPage,
169-
exportSpuExcel,
17099
} from "@/api/mall/product/spu";
171100
172101
import Editor from "@/components/Editor";
173102
import ImageUpload from "@/components/ImageUpload";
174103
import save from "./save";
175104
105+
// 1. TODO @Luowenfeng:商品的添加、修改,走一个单独的页面,不走弹窗;https://v5.niuteam.cn/shop/goods/addgoods.html
106+
// 2. TODO
107+
176108
export default {
177109
name: "Spu",
178110
components: {
@@ -306,27 +238,7 @@ export default {
306238
this.$modal.msgSuccess("删除成功");
307239
})
308240
.catch(() => {});
309-
},
310-
/** 导出按钮操作 */
311-
handleExport() {
312-
// 处理查询参数
313-
let params = { ...this.queryParams };
314-
params.pageNo = undefined;
315-
params.pageSize = undefined;
316-
this.addBeginAndEndTime(params, this.dateRangeCreateTime, "createTime");
317-
// 执行导出
318-
this.$modal
319-
.confirm("是否确认导出所有商品spu数据项?")
320-
.then(() => {
321-
this.exportLoading = true;
322-
return exportSpuExcel(params);
323-
})
324-
.then((response) => {
325-
this.$download.excel(response, "商品spu.xls");
326-
this.exportLoading = false;
327-
})
328-
.catch(() => {});
329-
},
241+
}
330242
},
331243
};
332244
</script>

0 commit comments

Comments
 (0)