第三次优化

master
‘mahaoran’ 2024-11-16 09:34:18 +08:00
parent 24ffae079e
commit 246109ddca
5 changed files with 156 additions and 22 deletions

View File

@ -49,3 +49,11 @@ export function delAttributeGroup(id) {
method: 'delete'
})
}
// 修改状态
export function updStatus(states,id) {
return request({
url: '/product/attributeGroup/updStatus?states=' + states+"&&"+'id='+id,
method: 'put'
})
}

View File

@ -42,3 +42,18 @@ export function delRule(id) {
method: 'delete'
})
}
// 修改状态
export function updStatus(status,id) {
return request({
url: '/product/rule/updStatus?status=' + status+"&&"+'id='+id,
method: 'put'
})
}
export function have(id) {
return request({
url: '/product/rule/have?id=' + id,
method: 'get'
})
}

View File

@ -83,7 +83,19 @@
</el-table-column>
<el-table-column label="状态" align="center" prop="states">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.states"/>
<el-switch
style="display: block"
v-model="scope.row.states"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="是"
active-value="Y"
inactive-value="N"
inactive-text="否"
@change="updStatus(scope.row)"
>
</el-switch>
<!-- <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.states"/>-->
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
@ -152,7 +164,7 @@
</template>
<script>
import { listAttributeGroup, getAttributeGroup, delAttributeGroup, addAttributeGroup, updateAttributeGroup,updAttributeGroup } from "@/api/product/attributeGroup";
import { listAttributeGroup, getAttributeGroup, delAttributeGroup, addAttributeGroup, updateAttributeGroup,updStatus } from "@/api/product/attributeGroup";
export default {
name: "AttributeGroup",
@ -202,6 +214,20 @@ export default {
},
methods: {
/**
* 修改状态
*/
updStatus(row){
updStatus(row.states,row.id).then(
res=>{
if(res.code==200){
this.$modal.msgSuccess("修改成功");
}
}
)
},
/** 查询属性组列表 */
getList() {
this.loading = true;

View File

@ -68,7 +68,7 @@
<image-preview :src="scope.row.image" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="父级品类" align="center" prop="parentId" />
<el-table-column label="父级品类" align="center" prop="parentIds" />
<el-table-column label="是否启用" align="center" prop="start">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/>
@ -153,7 +153,7 @@
<CheckAttribute v-model="form.attributeIdList" :checked-list="attributeInfoList"/>
</el-tab-pane>
<el-tab-pane label="商品属性组" name="attributeGroup">
<CheckAttributeGroup v-model="form.attributeGroupIdList" :checked-list="attributeGroupList"/>
<CheckAttributeGroup v-model="form.attributeGroupIdList" :checked-list="form.attributeGroupList"/>
</el-tab-pane>
<el-tab-pane label="商品品牌" name="brand">
<CheckBrand v-model="form.brandIdList" :checked-list="brandInfoList"/>
@ -269,7 +269,21 @@ export default {
getList() {
this.loading = true;
listCategory(this.queryParams).then(response => {
this.categoryList = this.handleTree(response.data, "id", "parentId");
const idToName = response.data.reduce((acc, node) => {
acc[node.id] = node.name;
return acc;
}, {});
console.log(idToName);
const updatedTreeData = response.data.map(node => {
// parentId null
const parentName = node.parentId !== null ? idToName[node.parentId] : null;
console.log(parentName);
return {
...node,
parentIds: parentName
};
});
this.categoryList = this.handleTree(updatedTreeData, "id", "parentId");
this.loading = false;
});
},

View File

@ -77,7 +77,24 @@
</template>
</el-table-column>
<el-table-column label="规格状态" align="center" prop="status" />
<el-table-column label="规格状态" align="center" prop="status" >
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="是"
active-value="Y"
inactive-value="N"
inactive-text="否"
@change="updStatus(scope.row)"
>
</el-switch>
<!-- <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.states"/>-->
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
@ -116,6 +133,20 @@
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="默认状态" prop="status">
<el-switch
style="display: block"
v-model="form.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="是"
active-value="Y"
inactive-value="N"
inactive-text="否"
disabled
>
</el-switch>
</el-form-item>
<el-row v-for="(ruleAttr, index) in form.ruleAttrList">
<el-row style="margin: 20px 0">
<el-tag
@ -165,12 +196,14 @@
</template>
<script>
import { listRule, getRule, delRule, addRule, updateRule } from "@/api/product/rule";
import { listRule, getRule, delRule, addRule, updateRule,updStatus ,have} from "@/api/product/rule";
export default {
name: "Rule",
data() {
return {
status:"",
//
loading: true,
//
@ -219,6 +252,20 @@ export default {
this.getList();
},
methods: {
/**
* 修改状态
*/
updStatus(row){
updStatus(row.status,row.id).then(
res=>{
if(res.code==200){
this.$modal.msgSuccess("修改成功");
}
}
)
},
removeRule(index){
this.form.ruleAttrList.splice(index, 1);
},
@ -285,7 +332,7 @@ export default {
this.ruleAddFormStatus = false;
},
/** 查询商品规格列表 */
getList() {
getList(row) {
this.loading = true;
listRule(this.queryParams).then(response => {
this.ruleList = response.data.rows;
@ -331,15 +378,27 @@ export default {
this.open = true;
this.title = "添加商品规格";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getRule(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改商品规格";
});
have(row.id).then(
res=>{
if(res.code==400){
this.$modal.msgSuccess(res.msg);
}else{
this.reset();
const id = row.id || this.ids
getRule(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改商品规格";
});
}
},
)
},
/** 提交按钮 */
submitForm() {
@ -363,13 +422,25 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除商品规格编号为"' + ids + '"的数据项?').then(function() {
return delRule(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
have(row.id).then(
res=> {
this.reset();
if (res.code == 400) {
this.$modal.msgSuccess(res.msg);
}else{
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除商品规格编号为"' + ids + '"的数据项?').then(function() {
return delRule(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
)
},
/** 导出按钮操作 */
handleExport() {