2204A-Ui (属性组 商品规格 品类信息 状态按钮 状态修改)

main
笨蛋 2024-11-16 06:26:58 +08:00
parent cede467f24
commit 508c213c4c
4 changed files with 69 additions and 7 deletions

View File

@ -34,6 +34,14 @@ export function updateRule(data) {
data: data data: data
}) })
} }
// 修改规格 状态
export function updateRuleInfoState(wyzRuleInfoSaveReq) {
return request({
url: '/product/ruleAttr/ruleInfoStateReq',
method: 'put',
data: wyzRuleInfoSaveReq
})
}
// 删除商品规格 // 删除商品规格
export function delRule(id) { export function delRule(id) {

View File

@ -81,6 +81,7 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="状态" align="center" prop="states"> <el-table-column label="状态" align="center" prop="states">
<template slot-scope="scope"> <template slot-scope="scope">
<el-switch <el-switch
@ -92,7 +93,6 @@
inactive-text="否" inactive-text="否"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949"> inactive-color="#ff4949">
></el-switch> ></el-switch>
</template> </template>
</el-table-column> </el-table-column>

View File

@ -68,7 +68,7 @@
<image-preview :src="scope.row.image" :width="50" :height="50"/> <image-preview :src="scope.row.image" :width="50" :height="50"/>
</template> </template>
</el-table-column> </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"> <el-table-column label="是否启用" align="center" prop="start">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/> <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/>
@ -84,8 +84,10 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['product:category:edit']" v-hasPermi="['product:category:edit']"
>修改</el-button> >修改</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-plus" icon="el-icon-plus"
@ -263,7 +265,21 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
listCategory(this.queryParams).then(response => { 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; this.loading = false;
}); });
}, },

View File

@ -65,6 +65,7 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" /> <el-table-column label="主键" align="center" prop="id" />
<el-table-column label="规格名称" align="center" prop="name" /> <el-table-column label="规格名称" align="center" prop="name" />
<el-table-column label="规格属性名" align="center" prop="name" > <el-table-column label="规格属性名" align="center" prop="name" >
<template slot-scope="scope"> <template slot-scope="scope">
<el-row v-for="ruleAttr in scope.row.ruleAttrList"><span>{{ruleAttr.name}}</span></el-row> <el-row v-for="ruleAttr in scope.row.ruleAttrList"><span>{{ruleAttr.name}}</span></el-row>
@ -74,14 +75,30 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-row v-for="ruleAttr in scope.row.ruleAttrList"><span>{{ruleAttr.valueList.toString()}}</span></el-row> <el-row v-for="ruleAttr in scope.row.ruleAttrList"><span>{{ruleAttr.valueList.toString()}}</span></el-row>
</template> </template>
</el-table-column> </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
v-model="scope.row.status"
@change="stateRuleButton(scope.row,scope.row.status)"
active-value="Y"
inactive-value="N"
active-text="是"
inactive-text="否"
active-color="#13ce66"
inactive-color="#ff4949">
></el-switch>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
:disabled=loading
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@ -165,12 +182,18 @@
</template> </template>
<script> <script>
import { listRule, getRule, delRule, addRule, updateRule } from "@/api/product/rule"; import { listRule, getRule, delRule, addRule, updateRule ,updateRuleInfoState} from '@/api/product/rule'
export default { export default {
name: "Rule", name: "Rule",
data() { data() {
return { return {
wyzRuleInfoSaveReq :{
id: null,
states: null,
},
// //
loading: true, loading: true,
// //
@ -212,13 +235,28 @@ export default {
valueList: null, valueList: null,
}, },
ruleAddFormStatus: false, ruleAddFormStatus: false,
addRulePropertyValue: null addRulePropertyValue: null,
//
}; };
}, },
created() { created() {
this.getList(); this.getList();
}, },
methods: { methods: {
//
stateRuleButton(row,status){
this.wyzRuleInfoSaveReq.id=row.id
this.wyzRuleInfoSaveReq.states=status
alert(this.wyzRuleInfoSaveReq.id)
alert(this.wyzRuleInfoSaveReq.states)
updateRuleInfoState(this.wyzRuleInfoSaveReq).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
},
removeRule(index){ removeRule(index){
this.form.ruleAttrList.splice(index, 1); this.form.ruleAttrList.splice(index, 1);
}, },