构建了半半成品的组件,明天要筛选值

master
20300 2024-03-07 21:24:37 +08:00
parent 29f7d2bb11
commit d928f8fe55
3 changed files with 267 additions and 0 deletions

View File

@ -0,0 +1,9 @@
import request from '@/utils/request'
export function getCategoryList(likeName) {
return request({
url: '/product/category/getCategoryList',
method: 'get',
data: likeName
})
}

View File

@ -0,0 +1,102 @@
<template>
<div>
<el-row>
<el-card class="box-card">
<div>
<span>选择属性关联关系</span>
</div>
<el-card class="box-card">
<div>
<span>已选属性</span>
</div>
<el-col>
<el-tag
v-for="brand in selectBrandIdList"
:key="brand.name"
closable
type="success">
{{brand.name}}
</el-tag>
</el-col>
</el-card>
<el-card class="box-card">
<div>
<span>可选属性</span>
</div>
<el-col>
<el-checkbox
v-for="brand in brandList"
v-model="selectBrandIdList"
:label="brand"
:key="brand.id">
{{brand.name}}</el-checkbox>
</el-col>
</el-card>
</el-card>
</el-row>
</div>
</template>
<script>
//jsjsjson,
//import from ',
import {getBrandList} from "@/api/product/brand";
export default {
name: 'CheckBrand',
//import使"
components: {},
props: {},
data() {
//"
return {
//brandList
brandList: [],
//brand
selectBrandIdList: [
],
//brand
parentSelectBrandList: []
};
},
// data",
computed: {},
//data",
watch: {},
//",
methods: {
getBrandList() {
getBrandList("").then(
res => {
this.brandList = res.data
}
)
}
},
// - 访this",
created() {
this.getBrandList()
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>

View File

@ -0,0 +1,156 @@
<template>
<div>
<el-button size="mini" type="primary" @click="isInsertCategory=true"></el-button>
<el-dialog title="新增品类" :visible.sync="isInsertCategory" width="80%" append-to-body>
<el-form :model="insertCategoryReq">
<el-row>
<el-col :span="12" >
<el-form-item label="父级品类" prop="parentId">
<treeselect v-model="categoryList.parentId" :options="categoryOptions" :normalizer="normalizer"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="品类名称" :label-width="100">
<el-input v-model="insertCategoryReq.name"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="图片上传" :label-width="120">
<upload-pic ref="uploadPic" @handle-image-url="handleImageUrl"></upload-pic>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="品类简介" :label-width="100">
<el-input v-model="insertCategoryReq.introduction"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="isInsertCategory = false"> </el-button>
<el-button type="primary" @click="isInsertCategory = false"> </el-button>
</div>
</el-dialog>
<check-brand></check-brand>
</div>
</template>
<script>
//jsjsjson,
//import from ',
import {getCategoryList} from "@/api/product/category";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import UploadPic from "@/views/product/upload/uploadPic.vue";
import CheckBrand from "@/components/CheckBrand/index.vue";
export default {
//import使"
components: {Treeselect,UploadPic,CheckBrand},
props: {},
data() {
//"
return {
//
likeName: "",
isInsertCategory: false,
formLabelWidth: 120,
categoryOptions: [],
//
categoryList: [],
//
insertCategoryReq: {
id: null,
name: "",
image: "",
parentId: null,
introduction: "",
brandIdList: [],
attributeIdList: [],
attributeGroupList: []
},
//,,,
brandList: [],
attributeList: [],
attributeGroupList: [],
//,
selectBrandList: [],
selectAttributeList: [],
selectAttributeGroupList: [],
//: ,,,
//,,,id,
//,,
parentSelectBrandList: [],
parentSelectAttributeList: [],
parentSelectAttributeGroupList: []
};
},
// data",
computed: {},
//data",
watch: {},
//",
methods: {
handleImageUrl() {
const imageUrl = this.$refs.uploadPic.imageUrl;
this.insertCategoryReq.image = imageUrl
console.log("获取到的图片地址:", imageUrl);
},
/** 转换品类信息数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children
};
},
/** 查询品类信息下拉树结构 */
getTreeSelect() {
getCategoryList(this.likeName).then(response => {
this.categoryOptions = [];
const data = { id: 0, name: '顶级节点', children: [] };
data.children = this.handleTree(response.data, "id", "parentId");
this.categoryOptions.push(data);
});
},
getCategoryList() {
getCategoryList(this.likeName).then(
res => {
this.categoryList = res.data
}
)
}
},
// - 访this",
created() {
this.getTreeSelect()
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>