117 lines
3.1 KiB
Vue
117 lines
3.1 KiB
Vue
<template>
|
||
<div>
|
||
<el-row>
|
||
<el-card class="box-card">
|
||
<div>
|
||
<span>选择属性组关联关系</span>
|
||
</div>
|
||
<el-card class="box-card" style="height: 150px;">
|
||
<div>
|
||
<span>已选属性组</span>
|
||
</div>
|
||
<el-col>
|
||
<el-tag
|
||
v-for="attributeGroup in selectAttributeGroupList"
|
||
:key="attributeGroup.name"
|
||
closable
|
||
type="success"
|
||
@close="handleClose(attributeGroup)">
|
||
{{attributeGroup.name}}
|
||
</el-tag>
|
||
</el-col>
|
||
</el-card>
|
||
<el-card class="box-card" style="height: 150px;">
|
||
<div>
|
||
<span>可选属性组</span>
|
||
</div>
|
||
<el-col>
|
||
<el-checkbox
|
||
v-for="attributeGroup in attributeGroupList"
|
||
v-model="selectAttributeGroupList"
|
||
:label="attributeGroup"
|
||
:key="attributeGroup.id">
|
||
{{attributeGroup.name}}</el-checkbox>
|
||
</el-col>
|
||
</el-card>
|
||
</el-card>
|
||
</el-row>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等),
|
||
//例如:import 《组件名称》 from '《组件路径》,
|
||
import {getBrandList} from "@/api/product/brand";
|
||
import {getAttributeGroupList} from "@/api/product/attribute";
|
||
|
||
export default {
|
||
name: 'CheckAttributeGroup',
|
||
//import引入的组件需要注入到对象中才能使用"
|
||
components: {},
|
||
props: {},
|
||
data() {
|
||
//这里存放数据"
|
||
|
||
return {
|
||
//所有brandList
|
||
attributeGroupList: [],
|
||
//已选中brand属性
|
||
selectAttributeGroupList: [
|
||
],
|
||
//父类选中的brand属性
|
||
parentSelectAttributeGroupList: []
|
||
};
|
||
},
|
||
//计算属性 类似于data概念",
|
||
computed: {},
|
||
//监控data中的数据变化",
|
||
watch: {
|
||
selectAttributeGroupList: {
|
||
handler(newVal, oldVal){
|
||
this.setAttributeGroupListToParent(newVal)
|
||
}
|
||
}
|
||
},
|
||
//方法集合",
|
||
methods: {
|
||
setAttributeGroupListToParent(newVal) {
|
||
this.$emit("setCheckAttributeList", newVal)
|
||
},
|
||
handleClose(tag) {
|
||
this.selectAttributeGroupList.splice(this.selectAttributeGroupList.indexOf(tag), 1);
|
||
},
|
||
getAttributeGroupList() {
|
||
getAttributeGroupList(0).then(
|
||
res => {
|
||
this.attributeGroupList = res.data
|
||
}
|
||
)
|
||
}
|
||
},
|
||
//生命周期 - 创建完成(可以访问当前this实例)",
|
||
created() {
|
||
this.getAttributeGroupList()
|
||
},
|
||
//生命周期 - 挂载完成(可以访问DOM元素)",
|
||
mounted() {
|
||
},
|
||
beforeCreate() {
|
||
}, //生命周期 - 创建之前",
|
||
beforeMount() {
|
||
}, //生命周期 - 挂载之前",
|
||
beforeUpdate() {
|
||
}, //生命周期 - 更新之前",
|
||
updated() {
|
||
}, //生命周期 - 更新之后",
|
||
beforeDestroy() {
|
||
}, //生命周期 - 销毁之前",
|
||
destroyed() {
|
||
}, //生命周期 - 销毁完成",
|
||
activated() {
|
||
} //如果页面有keep-alive缓存功能,这个函数会触发",
|
||
};
|
||
</script>
|
||
<style scoped>
|
||
|
||
</style>
|