品类新增,但是该了请求方法,需要改变id

master
20300 2024-03-08 21:30:21 +08:00
parent d928f8fe55
commit ed06a40cea
9 changed files with 344 additions and 32 deletions

View File

@ -1,8 +1,8 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询属性列表 // 查询属性列表
export function list(name) { export function list(attributeId) {
return request({ return request({
url: '/product/attributeInfo/list?name='+name, url: '/product/attributeInfo/list?attributeId='+attributeId,
method: 'get' method: 'get'
}) })
} }
@ -24,9 +24,9 @@ export function deleteById(attributeInfoId) {
}) })
} }
//获取属性组列表 //获取属性组列表
export function getAttributeGroupList(attributeName) { export function getAttributeGroupList(attributeGroupId) {
return request({ return request({
url: '/product/attributeGroup/getAttributeGroupList?attributeName='+attributeName, url: '/product/attributeGroup/getAttributeGroupList?attributeGroupId='+attributeGroupId,
method: 'get' method: 'get'
}) })
} }

View File

@ -8,9 +8,9 @@ export function insertBrand(brandInfo) {
}) })
} }
export function getBrandList(likeName) { export function getBrandList(brandId) {
return request({ return request({
url: '/product/brandInfo/getBrandList?likeName='+likeName, url: '/product/brandInfo/getBrandList?brandId='+brandId,
method: 'get' method: 'get'
}) })
} }

View File

@ -7,3 +7,12 @@ export function getCategoryList(likeName) {
data: likeName data: likeName
}) })
} }
export function insertCategory(insertCategoryReq) {
return request({
url: '/product/category/insertCategory',
method: 'post',
data: insertCategoryReq
})
}

View File

@ -0,0 +1,115 @@
<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="attribute in selectAttributeList"
:key="attribute.name"
closable
type="success"
@close="handleClose(attribute)">
{{attribute.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="attribute in attributeList"
v-model="selectAttributeList"
:label="attribute"
:key="attribute.id">
{{attribute.name}}</el-checkbox>
</el-col>
</el-card>
</el-card>
</el-row>
</div>
</template>
<script>
//jsjsjson,
//import from ',
import {list} from "@/api/product/attribute";
export default {
name: 'CheckAttribute',
//import使"
components: {},
props: {},
data() {
//"
return {
//brandList
attributeList: [],
//brand
selectAttributeList: [
],
//brand
parentSelectAttributeList: []
};
},
// data",
computed: {},
//data",
watch: {
selectAttributeList: {
handler(newVal, oldVal){
this.setAttributeListToParent(newVal);
}
}
},
//",
methods: {
setAttributeListToParent(newVal) {
this.$emit("setCheckAttributeList", newVal)
},
handleClose(tag) {
this.selectAttributeList.splice(this.selectAttributeList.indexOf(tag), 1);
},
getAttributeList() {
list(0).then(
res => {
this.attributeList = res.data
}
)
}
},
// - 访this",
created() {
this.getAttributeList()
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>

View File

@ -0,0 +1,116 @@
<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>
//jsjsjson,
//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>

View File

@ -3,30 +3,31 @@
<el-row> <el-row>
<el-card class="box-card"> <el-card class="box-card">
<div> <div>
<span>选择属性关联关系</span> <span>选择品牌关联关系</span>
</div> </div>
<el-card class="box-card"> <el-card class="box-card" style="height: 150px;">
<div> <div>
<span>已选属性</span> <span>已选品牌</span>
</div> </div>
<el-col> <el-col>
<el-tag <el-tag
v-for="brand in selectBrandIdList" v-for="brand in selectBrandList"
:key="brand.name" :key="brand.name"
closable closable
type="success"> type="success"
@close="handleClose(brand)">
{{brand.name}} {{brand.name}}
</el-tag> </el-tag>
</el-col> </el-col>
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card" style="height: 150px;">
<div> <div>
<span>可选属性</span> <span>可选品牌</span>
</div> </div>
<el-col> <el-col>
<el-checkbox <el-checkbox
v-for="brand in brandList" v-for="brand in brandList"
v-model="selectBrandIdList" v-model="selectBrandList"
:label="brand" :label="brand"
:key="brand.id"> :key="brand.id">
{{brand.name}}</el-checkbox> {{brand.name}}</el-checkbox>
@ -54,7 +55,7 @@ export default {
//brandList //brandList
brandList: [], brandList: [],
//brand //brand
selectBrandIdList: [ selectBrandList: [
], ],
//brand //brand
parentSelectBrandList: [] parentSelectBrandList: []
@ -63,11 +64,24 @@ export default {
// data", // data",
computed: {}, computed: {},
//data", //data",
watch: {}, watch: {
selectBrandList: {
handler(newVal, oldVal) {
this.setBrandListToParent(newVal)
}
}
},
//", //",
methods: { methods: {
//
setBrandListToParent(newVal) {
this.$emit("setCheckBrandList",newVal)
},
handleClose(tag) {
this.selectBrandList.splice(this.selectBrandList.indexOf(tag), 1);
},
getBrandList() { getBrandList() {
getBrandList("").then( getBrandList(0).then(
res => { res => {
this.brandList = res.data this.brandList = res.data
} }

View File

@ -3,7 +3,7 @@ export const formConf = {
formModel: 'formData', formModel: 'formData',
size: 'medium', size: 'medium',
labelPosition: 'right', labelPosition: 'right',
labelWidth: 100, labelWidth: "100",
formRules: 'rules', formRules: 'rules',
gutter: 15, gutter: 15,
disabled: false, disabled: false,

View File

@ -1,64 +1,85 @@
<template> <template>
<div> <div>
<el-button size="mini" type="primary" @click="isInsertCategory=true"></el-button> <el-button size="mini" type="primary" @click="isInsertCategory=true"></el-button>
<el-dialog title="新增品类" :visible.sync="isInsertCategory" width="80%" append-to-body> <el-dialog title="新增品类" :visible.sync="isInsertCategory" width="80%" append-to-body>
<el-form :model="insertCategoryReq"> <el-form :model="insertCategoryReq">
<el-row> <el-row>
<el-col :span="12" > <el-col :span="12" >
{{insertCategoryReq.parentId}}
<el-form-item label="父级品类" prop="parentId"> <el-form-item label="父级品类" prop="parentId">
<treeselect v-model="categoryList.parentId" :options="categoryOptions" :normalizer="normalizer"/> <treeselect v-model="insertCategoryReq.parentId" :options="categoryOptions" :normalizer="normalizer"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="品类名称" :label-width="100"> <el-form-item label="品类名称" :label-width="formLabelWidth">
<el-input v-model="insertCategoryReq.name"></el-input> <el-input v-model="insertCategoryReq.name"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="图片上传" :label-width="120"> <el-form-item label="图片上传" :label-width=formLabelWidth>
<upload-pic ref="uploadPic" @handle-image-url="handleImageUrl"></upload-pic> <upload-pic ref="uploadPic" @handle-image-url="handleImageUrl"></upload-pic>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="品类简介" :label-width="100"> <el-form-item label="品类简介" :label-width=formLabelWidth>
<el-input v-model="insertCategoryReq.introduction"></el-input> <el-input v-model="insertCategoryReq.introduction"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col :span="24">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="品牌管理" name="first">
<check-brand @setCheckBrandList="getCheckBrandList"></check-brand>
</el-tab-pane>
<el-tab-pane label="属性组管理" name="second">
<check-attribute-group @setCheckAttributeList="getCheckAttributeGroupList"></check-attribute-group>
</el-tab-pane>
<el-tab-pane label="属性管理" name="third">
<check-attribute @setCheckAttributeList="getCheckAttributeList"></check-attribute>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="isInsertCategory = false"> </el-button> <el-button @click="isInsertCategory = false"> </el-button>
<el-button type="primary" @click="isInsertCategory = false"> </el-button> <el-button type="primary" @click="insertCategory"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<check-brand></check-brand>
</div> </div>
</template> </template>
<script> <script>
//jsjsjson, //jsjsjson,
//import from ', //import from ',
import {getCategoryList} from "@/api/product/category"; import {getCategoryList, insertCategory} from "@/api/product/category";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import UploadPic from "@/views/product/upload/uploadPic.vue"; import UploadPic from "@/views/product/upload/uploadPic.vue";
import CheckBrand from "@/components/CheckBrand/index.vue"; import CheckBrand from "@/components/CheckBrand/index.vue";
import CheckAttributeGroup from "@/components/CheckAttributeGroup/index.vue";
import CheckAttribute from "@/components/CheckAttribute/index.vue";
export default {
export default {
//import使" //import使"
components: {Treeselect,UploadPic,CheckBrand}, components: {Treeselect,UploadPic,CheckBrand,CheckAttributeGroup, CheckAttribute},
props: {}, props: {},
data() { data() {
//" //"
return { return {
activeName: 'second',
// //
likeName: "", likeName: "",
isInsertCategory: false, isInsertCategory: false,
formLabelWidth: 120, formLabelWidth: "120",
categoryOptions: [], categoryOptions: [],
// //
categoryList: [], categoryList: [],
@ -69,8 +90,8 @@ import CheckBrand from "@/components/CheckBrand/index.vue";
image: "", image: "",
parentId: null, parentId: null,
introduction: "", introduction: "",
brandIdList: [], brandList: [],
attributeIdList: [], attributeList: [],
attributeGroupList: [] attributeGroupList: []
}, },
//,,, //,,,
@ -93,8 +114,45 @@ import CheckBrand from "@/components/CheckBrand/index.vue";
computed: {}, computed: {},
//data", //data",
watch: {}, watch: {},
//", //",likeName
methods: { methods: {
//
insertCategory() {
insertCategory(this.insertCategoryReq).then(
res => {
console.log(res)
this.isInsertCategory = false
this.insertCategoryReq = {
id: null,
name: "",
image: "",
parentId: null,
introduction: "",
brandList: [],
attributeList: [],
attributeGroupList: []
}
}
)
console.log(this.insertCategoryReq)
},
//
getCheckAttributeGroupList(checkAttributeGroupList) {
this.insertCategoryReq.attributeGroupList = checkAttributeGroupList
},
//
getCheckAttributeList(checkAttributeList){
this.insertCategoryReq.attributeList = checkAttributeList
},
//:
getCheckBrandList(checkBrandList){
this.insertCategoryReq.brandList = checkBrandList
console.log("获取到的品牌:",this.selectBrandList)
},
handleClick(tab, event) {
console.log(tab, event);
},
handleImageUrl() { handleImageUrl() {
const imageUrl = this.$refs.uploadPic.imageUrl; const imageUrl = this.$refs.uploadPic.imageUrl;
this.insertCategoryReq.image = imageUrl this.insertCategoryReq.image = imageUrl

View File

@ -173,7 +173,7 @@ export default {
inputComponents, inputComponents,
selectComponents, selectComponents,
layoutComponents, layoutComponents,
labelWidth: 100, labelWidth: "100",
drawingList: drawingDefault, drawingList: drawingDefault,
drawingData: {}, drawingData: {},
activeId: drawingDefault[0].formId, activeId: drawingDefault[0].formId,