这里到完全的属性组

master
20300 2024-03-06 21:03:30 +08:00
parent d0108ad2ef
commit 7456f75612
2 changed files with 41 additions and 12 deletions

View File

@ -38,3 +38,10 @@ export function insertAttributeGroup(attributeGroupReq) {
data: attributeGroupReq
})
}
export function deleteAttributeById(groupId) {
return request({
url: '/product/attributeGroup/deleteAttributeById?groupId='+groupId,
method: 'get'
})
}

View File

@ -60,11 +60,11 @@
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
type="danger"
@click="handleEdit(scope.$index, scope.row)">删除</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
@click="handleDelete(scope.$index, scope.row)">修改</el-button>
</template>
</el-table-column>
</el-table>
@ -113,7 +113,7 @@
<script>
//jsjsjson,
//import from ',
import {getAttributeGroupList, list, insertAttributeGroup} from "@/api/product/attribute";
import {getAttributeGroupList, list, insertAttributeGroup, deleteAttributeById} from "@/api/product/attribute";
import attribute from "@/views/product/attribute/index.vue";
export default {
@ -137,6 +137,7 @@ export default {
attributeQueryName: "",
//
attributeList: [],
attr:{}
};
},
@ -157,6 +158,7 @@ export default {
this.attributeList = res.data
this.attributeList.forEach(
attribute => {
attribute.checked = false
this.attributeGroupReq.selectAttributeList.forEach(
attributeReq =>{
if (attribute.id == attributeReq.id){
@ -169,7 +171,6 @@ export default {
)
}
)
},
//
reset() {
@ -180,21 +181,35 @@ export default {
},
//
handleClose(attribute){
console.log(this.attributeGroupList)
debugger
this.attributeList.forEach(attr => {
this.attributeList = this.attributeList.filter(attr => {
if (attr.id == attribute.id){
attr.checked = false
}
return attr
})
this.attributeGroupReq.selectAttributeList = this.attributeGroupReq.selectAttributeList.filter(item => item!=attribute);
},
//
updateAttribute(attribute) {
if (this.attributeGroupReq.selectAttributeList.includes(attribute)){
this.attributeGroupReq.selectAttributeList = this.attributeGroupReq.selectAttributeList.filter(item => item !== attribute)
const isExit = this.attributeGroupReq.selectAttributeList.findIndex(item => item.id == attribute.id);
if (isExit != -1){
console.log("1")
this.attributeGroupReq.selectAttributeList = this.attributeGroupReq.selectAttributeList.filter(item => item.id != attribute.id)
this.attributeList = this.attributeList.filter(attr => {
if (attr.id == attribute.id){
console.log(attr.id,attribute.id)
attr.checked = false
}
return attr
})
}else{
console.log("2")
this.attributeList = this.attributeList.filter(attr => {
if (attr.id == attribute.id){
attr.checked = true
}
return attr
})
this.attributeGroupReq.selectAttributeList.push(attribute)
}
},
@ -209,6 +224,12 @@ export default {
},
handleEdit(index, row) {
console.log(index, row);
deleteAttributeById(row.id).then(
res => {
console.log(res)
this.getAttributeGroupList()
}
)
},
queryAttributeList(){
this.isOpenAddAttributeGroup = true
@ -220,6 +241,7 @@ export default {
},
insertAttributeGroup() {
console.log(this.attributeGroupReq)
this.attributeGroupReq.attributeGroupId = this.attributeGroupReq.id
insertAttributeGroup(this.attributeGroupReq).then(
res => {
this.reset();