Skip to content

Commit 44e8631

Browse files
committed
feature(商品添加): 规格调整连带商品调整
1 parent e2854cc commit 44e8631

File tree

6 files changed

+228
-155
lines changed

6 files changed

+228
-155
lines changed

src/api/mall/product/property.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ export function getPropertyPage(query) {
4343
})
4444
}
4545

46+
// 获得规格名称列表
47+
export function getPropertyList(query) {
48+
return request({
49+
url: '/product/property/list',
50+
method: 'get',
51+
params: query
52+
})
53+
}
54+
55+
// 获得规格名称列表
56+
export function getPropertyListAndValue(query) {
57+
return request({
58+
url: '/product/property/listAndValue',
59+
method: 'get',
60+
params: query
61+
})
62+
}
63+
64+
4665
// 导出规格名称 Excel
4766
export function exportPropertyExcel(query) {
4867
return request({
@@ -52,3 +71,49 @@ export function exportPropertyExcel(query) {
5271
responseType: 'blob'
5372
})
5473
}
74+
75+
// ------------------------ 规格名称值 -------------------
76+
77+
// 获得规格名称值分页
78+
export function getPropertyValuePage(query) {
79+
return request({
80+
url: '/product/property/value/page',
81+
method: 'get',
82+
params: query
83+
})
84+
}
85+
86+
// 获得规格名称值
87+
export function getPropertyValue(id) {
88+
return request({
89+
url: '/product/property/value/get?id=' + id,
90+
method: 'get'
91+
})
92+
}
93+
94+
95+
// 创建规格名称值
96+
export function createPropertyValue(data) {
97+
return request({
98+
url: '/product/property/value/create',
99+
method: 'post',
100+
data: data
101+
})
102+
}
103+
104+
// 更新规格名称值
105+
export function updatePropertyValue(data) {
106+
return request({
107+
url: '/product/property/value/update',
108+
method: 'put',
109+
data: data
110+
})
111+
}
112+
113+
// 删除规格名称
114+
export function deletePropertyValue(id) {
115+
return request({
116+
url: '/product/property/value/delete?id=' + id,
117+
method: 'delete'
118+
})
119+
}

src/api/mall/product/spu.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ export function getSpu(id) {
3434
})
3535
}
3636

37+
// 获得商品spu详情
38+
export function getSpuDetail(id) {
39+
return request({
40+
url: '/product/spu/get/detail?id=' + id,
41+
method: 'get'
42+
})
43+
}
44+
3745
// 获得商品spu分页
3846
export function getSpuPage(query) {
3947
return request({

src/router/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ export const constantRoutes = [
9696
meta: {title: '字典数据', icon: '', activeMenu: '/system/dict'}
9797
}
9898
]
99+
}, {
100+
path: '/property',
101+
component: Layout,
102+
hidden: true,
103+
children: [{
104+
path: 'value/:propertyId(\\d+)',
105+
component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
106+
name: 'PropertyValue',
107+
meta: {title: '规格数据', icon: '', activeMenu: '/mall/property'}
108+
}
109+
]
99110
}, {
100111
path: '/job',
101112
component: Layout,

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

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<el-form-item label="规格名称" prop="name">
77
<el-input v-model="queryParams.name" placeholder="请输入规格名称" clearable @keyup.enter.native="handleQuery"/>
88
</el-form-item>
9-
<el-form-item label="开启状态" prop="status">
9+
<el-form-item label="状态" prop="status">
1010
<el-select v-model="queryParams.status" placeholder="请选择开启状态" clearable size="small">
1111
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
1212
:key="dict.value" :label="dict.label" :value="dict.value"/>
@@ -33,12 +33,14 @@
3333

3434
<!-- 列表 -->
3535
<el-table v-loading="loading" :data="list">
36-
<el-table-column label="规格名称" align="center" prop="name" />
37-
<el-table-column label="规格名称" align="center" prop="propertyValueList">
36+
<el-table-column label="规格id" align="center" prop="id" />
37+
<el-table-column label="规格名称" align="center" :show-overflow-tooltip="true">
3838
<template slot-scope="scope">
39-
<span>{{formatList(scope.row.propertyValueList)}}</span>
39+
<router-link :to="'/property/value/' + scope.row.id" class="link-type">
40+
<span>{{ scope.row.name }}</span>
41+
</router-link>
4042
</template>
41-
</el-table-column>
43+
</el-table-column>
4244
<el-table-column label="开启状态" align="center" prop="status">
4345
<template slot-scope="scope">
4446
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
@@ -49,6 +51,7 @@
4951
<span>{{ parseTime(scope.row.createTime) }}</span>
5052
</template>
5153
</el-table-column>
54+
<el-table-column label="备注" align="center" prop="left" />
5255
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
5356
<template slot-scope="scope">
5457
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
@@ -65,6 +68,9 @@
6568
<!-- 对话框(添加 / 修改) -->
6669
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
6770
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
71+
<el-form-item label="规格id" prop="id" v-if="form.id != null">
72+
<el-input v-model="form.id" disabled />
73+
</el-form-item>
6874
<el-form-item label="规格名称" prop="name">
6975
<el-input v-model="form.name" placeholder="请输入规格名称" />
7076
</el-form-item>
@@ -75,26 +81,9 @@
7581
</el-radio>
7682
</el-radio-group>
7783
</el-form-item>
78-
<el-form-item label="属性值">
79-
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="addPropertyValue()">添加</el-button>
84+
<el-form-item label="备注" prop="remark">
85+
<el-input v-model="form.remark" placeholder="备注" />
8086
</el-form-item>
81-
<el-form-item
82-
v-for="(domain, index) in form.propertyValueList"
83-
:key="domain.key"
84-
:prop="'propertyValueList.' + index + '.name'"
85-
:rules="{
86-
required: true, message: '属性值不能为空', trigger: 'blur'
87-
}"
88-
>
89-
<el-row>
90-
<el-col :span="18">
91-
<el-input v-model="domain.name" size="mini"></el-input>
92-
</el-col>
93-
<el-col :span="6">
94-
<el-button style="margin-left: 20px;" size="mini" @click.prevent="removePropertyValue(domain)">删除</el-button>
95-
</el-col>
96-
</el-row>
97-
</el-form-item>
9887
</el-form>
9988
<div slot="footer" class="dialog-footer">
10089
<el-button type="primary" @click="submitForm">确 定</el-button>
@@ -139,12 +128,17 @@ export default {
139128
form: {
140129
name:'',
141130
status:'',
142-
propertyValueList: [{
143-
name: ''
144-
}],
131+
remark:"",
132+
id: null,
145133
},
146134
// 表单校验
147135
rules: {
136+
name: [
137+
{ required: true, message: "规格不能为空", trigger: "blur" }
138+
],
139+
status: [
140+
{ required: true, message: "状态不能为空", trigger: "blur" }
141+
]
148142
}
149143
};
150144
},
@@ -170,12 +164,10 @@ export default {
170164
/** 表单重置 */
171165
reset() {
172166
this.form = {
173-
id: undefined,
174-
name: undefined,
175-
status: undefined,
176-
propertyValueList: [{
177-
name: ''
178-
}]
167+
name:'',
168+
status:'',
169+
remark:"",
170+
id: null,
179171
};
180172
this.resetForm("form");
181173
},
@@ -253,27 +245,6 @@ export default {
253245
this.exportLoading = false;
254246
}).catch(() => {});
255247
},
256-
removePropertyValue(item) {
257-
var index = this.form.propertyValueList.indexOf(item)
258-
if (index !== -1) {
259-
this.form.propertyValueList.splice(index, 1)
260-
}
261-
},
262-
addPropertyValue() {
263-
this.form.propertyValueList.push({
264-
name: ''
265-
});
266-
},
267-
formatList(list) {
268-
let str = ''
269-
for (var i = 0; i < list.length; i++) {
270-
str += list[i].name;
271-
if(i != list.length-1){
272-
str+="/";
273-
}
274-
}
275-
return str
276-
}
277248
}
278249
};
279250
</script>

0 commit comments

Comments
 (0)