这里到完全的属性组
parent
d0108ad2ef
commit
7456f75612
|
@ -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'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -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>
|
||||||
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等),
|
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等),
|
||||||
//例如: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();
|
||||||
|
|
Loading…
Reference in New Issue