这里到完全的属性组

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