master
2812875475 2024-03-03 10:27:22 +08:00
parent cb57edddd1
commit 6874ae2edc
10 changed files with 658 additions and 96 deletions

View File

@ -12,7 +12,7 @@ export function listAttributeGroup(query) {
// 查询商品属性组详细 // 查询商品属性组详细
export function getAttributeGroup(id) { export function getAttributeGroup(id) {
return request({ return request({
url: '/product/attributeGroup/' + id, url: '/product/attributeGroup/getInfo?id='+ id,
method: 'get' method: 'get'
}) })
} }

View File

@ -17,6 +17,15 @@ export function getCategory(id) {
}) })
} }
//通过父类id 查询品类详情
export function parentCategoryCommon(id) {
return request({
url: '/product/category/parentCategoryCommon/' + id,
method: 'get'
})
}
// 新增品类信息 // 新增品类信息
export function addCategory(data) { export function addCategory(data) {
return request({ return request({

View File

@ -0,0 +1,157 @@
<template>
<el-row>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>选择属性关联关系</span>
</div>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>已选择属性</span>
</div>
<el-row>
<el-col :span="2" v-for="(attribute, index) in checkedAttributeList">
<el-tag
style="margin: 5px 10px"
:key="attribute.name"
closable @close="removeChecked(index)">
{{ attribute.name }}
</el-tag>
</el-col>
</el-row>
</el-card>
<el-divider></el-divider>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>未选属性</span>
</div>
<el-row>
<el-form :inline="true" :model="attributeQuery" class="demo-form-inline">
<el-form-item label="属性编码">
<el-input v-model="attributeQuery.code" placeholder="属性编码"></el-input>
</el-form-item>
<el-form-item label="属性名称">
<el-input v-model="attributeQuery.name" placeholder="属性名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryAttribute"></el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col style="padding: 5px 10px" :span="3" v-for="attribute in attributeList">
<el-checkbox
v-model="attributeIdList"
:key="attribute.id"
:value="attribute.id"
:label="attribute.id"
@change="checkedAttribute(attribute)"
border>{{ attribute.name }}
</el-checkbox>
</el-col>
</el-row>
<pagination
v-show="total>0"
:total="total"
:page.sync="attributeQuery.pageNum"
:limit.sync="attributeQuery.pageSize"
@pagination="queryAttribute"
/>
</el-card>
</el-card>
</el-row>
</template>
<script>
import {listAttribute} from "@/api/product/attribute";
export default {
name: "CheckAttribute",
props: {
value: {
type: Array,
default: []
},
checkedList: {
type: Array,
default: null
}
},
watch: {
value: {
handler(val) {
if (val.toString() !== this.attributeIdList.toString()){
this.attributeIdList = val;
this.checkedAttributeList = []
}
},
immediate: true,
},
checkedList: {
handler(val){
if (val !== undefined && val.length > 0){
this.checkedAttributeList = val;
this.attributeIdList = this.checkedAttributeList.map(checked => checked.id);
}
},
immediate: true
}
},
data() {
return {
attributeIdList: [],
checkedAttributeList: [],
attributeQuery: {
pageNum: 1,
pageSize: 10,
code: null,
name: null
},
attributeTotal: 0,
attributeList: [],
total: 0,
}
},
created() {
this.queryAttribute();
},
methods: {
/**
* 选中值触发方法
*/
checkedAttribute(attribute) {
let isCheck = this.attributeIdList.indexOf(attribute.id) > -1;
if (isCheck) {
this.checkedAttributeList.push(attribute);
} else {
//
this.checkedAttributeList.splice(
this.checkedAttributeList.indexOf(attribute), 1
)
}
this.$emit("input", this.attributeIdList);
},
/**
* 删除选中值
* @param index
*/
removeChecked(index) {
this.checkedAttributeList.splice(index, 1);
this.attributeIdList.splice(index, 1);
},
/**
* 查询属性
*/
queryAttribute() {
listAttribute(this.attributeQuery).then(response => {
this.attributeList = response.data.rows;
this.total = response.data.total;
});
},
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,157 @@
<template>
<el-row>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>选择属性关联关系</span>
</div>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>已选择属性</span>
</div>
<el-row>
<el-col :span="2" v-for="(attributeGroup, index) in checkedAttributeGroupList">
<el-tag
style="margin: 5px 10px"
:key="attributeGroup.name"
closable @close="removeChecked(index)">
{{ attributeGroup.name }}
</el-tag>
</el-col>
</el-row>
</el-card>
<el-divider></el-divider>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>未选属性</span>
</div>
<el-row>
<el-form :inline="true" :model="attributeGroupQuery" class="demo-form-inline">
<el-form-item label="属性编码">
<el-input v-model="attributeGroupQuery.code" placeholder="属性编码"></el-input>
</el-form-item>
<el-form-item label="属性名称">
<el-input v-model="attributeGroupQuery.name" placeholder="属性名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryAttributeGroup"></el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col style="padding: 5px 10px" :span="3" v-for="attributeGroup in attributeGroupList">
<el-checkbox
v-model="attributeGroupIdList"
:key="attributeGroup.id"
:value="attributeGroup.id"
:label="attributeGroup.id"
@change="checkedAttributeGroup(attributeGroup)"
border>{{ attributeGroup.name }}
</el-checkbox>
</el-col>
</el-row>
<pagination
v-show="total>0"
:total="total"
:page.sync="attributeGroupQuery.pageNum"
:limit.sync="attributeGroupQuery.pageSize"
@pagination="queryAttributeGroup"
/>
</el-card>
</el-card>
</el-row>
</template>
<script>
import {listAttributeGroup} from "@/api/product/attributeGroup";
export default {
name: "CheckAttributeGroup",
props: {
value: {
type: Array,
default: []
},
checkedList: {
type: Array,
default: null
}
},
watch: {
value: {
handler(val) {
if (val.toString() !== this.attributeGroupIdList.toString()){
this.attributeGroupIdList = val;
this.checkedAttributeGroupList = []
}
},
immediate: true,
},
checkedList: {
handler(val){
if (val !== undefined && val.length > 0){
this.checkedAttributeGroupList = val;
this.attributeGroupIdList = this.checkedAttributeGroupList.map(checked => checked.id);
}
},
immediate: true
}
},
data() {
return {
attributeGroupIdList: [],
checkedAttributeGroupList: [],
attributeGroupQuery: {
pageNum: 1,
pageSize: 10,
code: null,
name: null
},
attributeGroupTotal: 0,
attributeGroupList: [],
total: 0,
}
},
created() {
this.queryAttributeGroup();
},
methods: {
/**
* 选中值触发方法
*/
checkedAttributeGroup(attributeGroup) {
let isCheck = this.attributeGroupIdList.indexOf(attributeGroup.id) > -1;
if (isCheck) {
this.checkedAttributeGroupList.push(attributeGroup);
} else {
//
this.checkedAttributeGroupList.splice(
this.checkedAttributeGroupList.indexOf(attributeGroup), 1
)
}
this.$emit("input", this.attributeGroupIdList);
},
/**
* 删除选中值
* @param index
*/
removeChecked(index) {
this.checkedAttributeGroupList.splice(index, 1);
this.attributeGroupIdList.splice(index, 1);
},
/**
* 查询属性
*/
queryAttributeGroup() {
listAttributeGroup(this.attributeGroupQuery).then(response => {
this.attributeGroupList = response.data.rows;
this.total = response.data.total;
});
},
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,157 @@
<template>
<el-row>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>选择品牌关联关系</span>
</div>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>已选择品牌</span>
</div>
<el-row>
<el-col :span="2" v-for="(brand, index) in checkedBrandList">
<el-tag
style="margin: 5px 10px"
:key="brand.nam"
closable @close="removeChecked(index)">
{{ brand.nam }}
</el-tag>
</el-col>
</el-row>
</el-card>
<el-divider></el-divider>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>未选品牌</span>
</div>
<el-row>
<el-form :inline="true" :model="brandQuery" class="demo-form-inline">
<el-form-item label="品牌编码">
<el-input v-model="brandQuery.code" placeholder="品牌编码"></el-input>
</el-form-item>
<el-form-item label="品牌名称">
<el-input v-model="brandQuery.nam" placeholder="品牌名称"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="queryBrand"></el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<el-col style="padding: 5px 10px" :span="3" v-for="brand in brandList">
<el-checkbox
v-model="brandIdList"
:key="brand.id"
:value="brand.id"
:label="brand.id"
@change="checkedBrand(brand)"
border>{{ brand.nam }}
</el-checkbox>
</el-col>
</el-row>
<pagination
v-show="total>0"
:total="total"
:page.sync="brandQuery.pageNum"
:limit.sync="brandQuery.pageSize"
@pagination="queryBrand"
/>
</el-card>
</el-card>
</el-row>
</template>
<script>
import {listBrand} from "@/api/product/brand";
export default {
nam: "CheckBrand",
props: {
value: {
type: Array,
default: []
},
checkedList: {
type: Array,
default: null
}
},
watch: {
value: {
handler(val) {
if (val.toString() !== this.brandIdList.toString()){
this.brandIdList = val;
this.checkedBrandList = []
}
},
immediate: true,
},
checkedList: {
handler(val){
if (val !== undefined && val.length > 0){
this.checkedBrandList = val;
this.brandIdList = this.checkedBrandList.map(checked => checked.id);
}
},
immediate: true
}
},
data() {
return {
brandIdList: [],
checkedBrandList: [],
brandQuery: {
pageNum: 1,
pageSize: 10,
code: null,
nam: null
},
brandTotal: 0,
brandList: [],
total: 0,
}
},
created() {
this.queryBrand();
},
methods: {
/**
* 选中值触发方法
*/
checkedBrand(brand) {
let isCheck = this.brandIdList.indexOf(brand.id) > -1;
if (isCheck) {
this.checkedBrandList.push(brand);
} else {
//
this.checkedBrandList.splice(
this.checkedBrandList.indexOf(brand), 1
)
}
this.$emit("input", this.brandIdList);
},
/**
* 删除选中值
* @param index
*/
removeChecked(index) {
this.checkedBrandList.splice(index, 1);
this.brandIdList.splice(index, 1);
},
/**
* 查询品牌
*/
queryBrand() {
listBrand(this.brandQuery).then(response => {
this.brandList = response.data.rows;
this.total = response.data.total;
});
},
}
}
</script>
<style scoped>
</style>

View File

@ -38,6 +38,17 @@ import VueMeta from 'vue-meta'
// 字典数据组件 // 字典数据组件
import DictData from '@/components/DictData' import DictData from '@/components/DictData'
// 属性选择
import Attribute from "@/components/Attribute/index.vue";
// 品牌选择
import Brand from "@/components/Brand/index.vue";
// 品牌选择
import AttributeGroup from "@/components/AttributeGroup/index.vue";
// 全局方法挂载 // 全局方法挂载
Vue.prototype.getDicts = getDicts Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey Vue.prototype.getConfigKey = getConfigKey
@ -48,6 +59,9 @@ Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download Vue.prototype.download = download
Vue.prototype.handleTree = handleTree Vue.prototype.handleTree = handleTree
Vue.component('Attribute', Attribute)
Vue.component('Brand', Brand)
Vue.component('AttributeGroup', AttributeGroup)
// 全局组件挂载 // 全局组件挂载
Vue.component('DictTag', DictTag) Vue.component('DictTag', DictTag)

View File

@ -1,5 +1,8 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="属性编码" prop="code"> <el-form-item label="属性编码" prop="code">
<el-input <el-input
@ -178,6 +181,7 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
/** 查询商品属性列表 */ /** 查询商品属性列表 */
getList() { getList() {
this.loading = true; this.loading = true;

View File

@ -80,7 +80,6 @@
<el-table-column type="selection" width="55" align="center"/> <el-table-column type="selection" width="55" align="center"/>
<el-table-column label="主键" align="center" prop="id"/> <el-table-column label="主键" align="center" prop="id"/>
<el-table-column label="属性名" align="center" prop="name"/> <el-table-column label="属性名" align="center" prop="name"/>
<el-table-column label="属性组" align="center" prop="attributeIds"/>
<el-table-column label="组内属性" align="center" prop="attributeInfoList" > <el-table-column label="组内属性" align="center" prop="attributeInfoList" >
<template slot-scope="scope"> <template slot-scope="scope">
@ -103,7 +102,7 @@
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['product:attributeGroup:edit']" v-hasPermi="['product:attributeGroup:query']"
>修改 >修改
</el-button> </el-button>
<el-button <el-button
@ -134,6 +133,9 @@
<!-- 添加或修改商品属性组对话框 --> <!-- 添加或修改商品属性组对话框 -->
<el-dialog :title="title" :visible.sync="open" width="80%" append-to-body > <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body >
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<!--属性名 状态-->
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="属性名" prop="name"> <el-form-item label="属性名" prop="name">
@ -154,24 +156,24 @@
</el-col> </el-col>
</el-row> </el-row>
<!--备注-->
<el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
<el-row> <el-row>
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>已选属性</span> <span>已选属性</span>
</div> </div>
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<el-col :span="2" v-for="(item ,index) in attributeList"> <el-col :span="2" v-for="(item ,index) in attributeList">
<el-tag <el-tag
v-if="attributeids.indexOf(item.id) > -1" v-if="attributeIdList.indexOf(item.id) > -1"
style="margin: 5px 10px" style="margin: 5px 10px"
:key="item.name" :key="item.name"
closable @close="handleClose(index)"> closable @close="handleClose(index)">
@ -179,17 +181,14 @@
</el-tag> </el-tag>
</el-col> </el-col>
</div> </div>
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix">
<span>未选属性</span>
</div>
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>未选属性</span>
</div>
<div slot="header" class="clearfix">
<el-form :inline="true" :model="attribute" class="demo-form-inline"> <el-form :inline="true" :model="attribute" class="demo-form-inline">
<el-form-item label="属性编码"> <el-form-item label="属性编码">
<el-input v-model="attribute.code" placeholder="属性编码"></el-input> <el-input v-model="attribute.code" placeholder="属性编码"></el-input>
@ -208,7 +207,7 @@
<el-col style="padding: 5px 10px" :span="3" v-for="item in attributeList"> <el-col style="padding: 5px 10px" :span="3" v-for="item in attributeList">
<el-checkbox <el-checkbox
v-model="attributeids" v-model="attributeIdList"
:key="item.id" :key="item.id"
:value="item.id" :value="item.id"
:label="item.id" :label="item.id"
@ -224,7 +223,7 @@
:limit.sync="attribute.pageSize" :limit.sync="attribute.pageSize"
@pagination="getList1" @pagination="getList1"
/> />
{{ attributeids }} {{ attributeIdList }}
</el-card> </el-card>
@ -262,7 +261,7 @@ export default {
], ],
attributeTotal: 0, attributeTotal: 0,
attributeList: [], attributeList: [],
attributeids: [], attributeIdList: [],
attribute: { attribute: {
pageNum: 1, pageNum: 1,
pageSize: 6, pageSize: 6,
@ -322,7 +321,7 @@ export default {
}); });
}, },
handleClose(index) { handleClose(index) {
this.attributeids.splice(this.attributeids.indexOf(index), 1) this.attributeIdList.splice(this.attributeIdList.indexOf(index), 1)
}, },
/** 查询商品属性列表 */ /** 查询商品属性列表 */
getList1() { getList1() {
@ -335,7 +334,6 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
listAttributeGroup(this.queryParams).then(response => { listAttributeGroup(this.queryParams).then(response => {
console.log(response)
this.attributeGroupList = response.data.rows; this.attributeGroupList = response.data.rows;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
@ -357,7 +355,7 @@ export default {
createTime: null, createTime: null,
updateBy: null, updateBy: null,
updateTime: null, updateTime: null,
attributeids:null, attributeIdList:null,
attributeIds:null, attributeIds:null,
}; };
this.resetForm("form"); this.resetForm("form");
@ -389,11 +387,8 @@ export default {
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids
getAttributeGroup(id).then(response => { getAttributeGroup(id).then(response => {
console.log(response)
this.form = response.data; this.form = response.data;
let str = response.data.attributeIds; this.attributeIdList=response.data.attributeIdList
this.attributeids = str.split(',').map(Number);
console.log(this.form)
this.open = true; this.open = true;
this.title = "修改商品属性组"; this.title = "修改商品属性组";
}); });
@ -403,8 +398,7 @@ export default {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.id != null) { if (this.form.id != null) {
let str = this.attributeids.join(','); this.form.attributeIdList=this.attributeIdList
this.form.attributeIds=str
updateAttributeGroup(this.form).then(response => { updateAttributeGroup(this.form).then(response => {
console.log(this.form) console.log(this.form)
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
@ -412,18 +406,18 @@ export default {
this.getList(); this.getList();
this.reset(); this.reset();
this.form.attributeIds='' this.form.attributeIds=''
this.attributeids=[] this.attributeIdList=[]
}); });
} else { } else {
let str = this.attributeids.join(',');
this.form.attributeIds=str this.form.attributeIdList=this.attributeIdList
addAttributeGroup(this.form).then(response => { addAttributeGroup(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
this.reset(); this.reset();
this.form.attributeIds='' this.form.attributeIds=''
this.attributeids=[] this.attributeIdList=[]
}); });
} }
} }

View File

@ -10,12 +10,14 @@
/> />
</el-form-item> </el-form-item>
<el-form-item label="是否启用" prop="start"> <el-form-item label="是否启用" prop="start">
<el-input <el-select v-model="queryParams.start" placeholder="请选择是否启用" clearable>
v-model="queryParams.start" <el-option
placeholder="请输入是否启用" v-for="dict in dict.type.sys_yes_no"
clearable :key="dict.value"
@keyup.enter.native="handleQuery" :label="dict.label"
/> :value="dict.value"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
@ -73,8 +75,16 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" /> <el-table-column label="主键" align="center" prop="id" />
<el-table-column label="品牌名称" align="center" prop="nam" /> <el-table-column label="品牌名称" align="center" prop="nam" />
<el-table-column label="LOGO" align="center" prop="logo" /> <el-table-column label="LOGO" align="center" prop="logo" width="100">
<el-table-column label="是否启用" align="center" prop="start" /> <template slot-scope="scope">
<image-preview :src="scope.row.logo" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="是否启用" align="center" prop="start">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/>
</template>
</el-table-column>
<el-table-column label="介绍" align="center" prop="introduction" /> <el-table-column label="介绍" align="center" prop="introduction" />
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@ -112,10 +122,16 @@
<el-input v-model="form.nam" placeholder="请输入品牌名称" /> <el-input v-model="form.nam" placeholder="请输入品牌名称" />
</el-form-item> </el-form-item>
<el-form-item label="LOGO" prop="logo"> <el-form-item label="LOGO" prop="logo">
<el-input v-model="form.logo" type="textarea" placeholder="请输入内容" /> <image-upload v-model="form.logo"/>
</el-form-item> </el-form-item>
<el-form-item label="是否启用" prop="start"> <el-form-item label="是否启用" prop="start">
<el-input v-model="form.start" placeholder="请输入是否启用" /> <el-radio-group v-model="form.start">
<el-radio
v-for="dict in dict.type.sys_yes_no"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="介绍" prop="introduction"> <el-form-item label="介绍" prop="introduction">
<el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" />
@ -137,6 +153,7 @@ import { listBrand, getBrand, delBrand, addBrand, updateBrand } from "@/api/prod
export default { export default {
name: "Brand", name: "Brand",
dicts: ['sys_yes_no'],
data() { data() {
return { return {
// //
@ -177,7 +194,7 @@ export default {
{ required: true, message: "LOGO不能为空", trigger: "blur" } { required: true, message: "LOGO不能为空", trigger: "blur" }
], ],
start: [ start: [
{ required: true, message: "是否启用不能为空", trigger: "blur" } { required: true, message: "是否启用不能为空", trigger: "change" }
], ],
createBy: [ createBy: [
{ required: true, message: "创建人不能为空", trigger: "blur" } { required: true, message: "创建人不能为空", trigger: "blur" }

View File

@ -26,7 +26,7 @@
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -40,7 +40,8 @@
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['product:category:add']" v-hasPermi="['product:category:add']"
>新增</el-button> >新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
@ -49,7 +50,8 @@
icon="el-icon-sort" icon="el-icon-sort"
size="mini" size="mini"
@click="toggleExpandAll" @click="toggleExpandAll"
>展开/折叠</el-button> >展开/折叠
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -62,20 +64,20 @@
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
<el-table-column label="品牌名称" prop="name" /> <el-table-column label="品牌名称" prop="name"/>
<el-table-column label="图片" align="center" prop="image" width="100"> <el-table-column label="图片" align="center" prop="image" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<image-preview :src="scope.row.image" :width="50" :height="50"/> <image-preview :src="scope.row.image" :width="50" :height="50"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="父级品类" align="center" prop="parentId" /> <el-table-column label="父级品类" align="center" prop="parentId"/>
<el-table-column label="是否启用" align="center" prop="start"> <el-table-column label="是否启用" align="center" prop="start">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/> <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.start"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="介绍" align="center" prop="introduction" /> <el-table-column label="介绍" align="center" prop="introduction"/>
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -84,54 +86,82 @@
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['product:category:edit']" v-hasPermi="['product:category:edit']"
>修改</el-button> >修改
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-plus" icon="el-icon-plus"
@click="handleAdd(scope.row)" @click="handleAdd(scope.row)"
v-hasPermi="['product:category:add']" v-hasPermi="['product:category:add']"
>新增</el-button> >新增
</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['product:category:remove']" v-hasPermi="['product:category:remove']"
>删除</el-button> >删除
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 添加或修改品类信息对话框 --> <!-- 添加或修改品类信息对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="父级品类" prop="parentId">
<treeselect v-model="form.parentId" :options="categoryOptions" :normalizer="normalizer" placeholder="请选择父级品类" />
</el-form-item>
<el-form-item label="品牌名称" prop="name"> <el-row>
<el-input v-model="form.name" placeholder="请输入品牌名称" /> <el-col :span="12">
</el-form-item> <el-form-item label="父级品类" prop="parentId">
<el-form-item label="图片" prop="image"> <treeselect v-model="form.parentId" :options="categoryOptions" :normalizer="normalizer"
<image-upload v-model="form.image"/> placeholder="请选择父级品类"/>
</el-form-item> </el-form-item>
<el-form-item label="品牌名称" prop="name">
<el-input v-model="form.name" placeholder="请输入品牌名称"/>
</el-form-item>
<el-form-item label="图片" prop="image">
<image-upload v-model="form.image"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态" prop="states">
<el-radio-group v-model="form.start">
<el-radio
v-for="dict in dict.type.sys_yes_no"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="介绍" prop="introduction">
<el-input v-model="form.introduction" type="textarea" placeholder="请输入内容"/>
</el-form-item>
<el-form-item label="备注">
<editor v-model="form.remark" :min-height="80"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-tabs value="">
<el-tab-pane label="商品属性" name="attribute">
<Attribute v-model="form.attributeIdList" :checked-list="attributeInfoList"/>
</el-tab-pane>
<el-tab-pane label="商品属性组" name="attributeGroup">
<AttributeGroup v-model="form.attributeGroupIdList" :checked-list="attributeGroupList"/>
</el-tab-pane>
<el-tab-pane label="商品品牌" name="band">
<Brand v-model="form.brandIdList" :checked-list="brandInfoList"/>
</el-tab-pane>
</el-tabs>
</el-row>
<el-form-item label="状态" prop="states">
<el-radio-group v-model="form.start">
<el-radio
v-for="dict in dict.type.sys_yes_no"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="介绍" prop="introduction">
<el-input v-model="form.introduction" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="备注">
<editor v-model="form.remark" :min-height="192"/>
</el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@ -142,7 +172,14 @@
</template> </template>
<script> <script>
import { listCategory, getCategory, delCategory, addCategory, updateCategory } from "@/api/product/category"; import {
listCategory,
getCategory,
delCategory,
addCategory,
updateCategory,
parentCategoryCommon
} 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";
@ -183,26 +220,45 @@ export default {
// //
rules: { rules: {
name: [ name: [
{ required: true, message: "品牌名称不能为空", trigger: "blur" } {required: true, message: "品牌名称不能为空", trigger: "blur"}
], ],
image: [ image: [
{ required: true, message: "图片不能为空", trigger: "blur" } {required: true, message: "图片不能为空", trigger: "blur"}
], ],
parentId: [ parentId: [
{ required: true, message: "父级品类不能为空", trigger: "blur" } {required: true, message: "父级品类不能为空", trigger: "blur"}
], ],
start: [ start: [
{ required: true, message: "是否启用不能为空", trigger: "blur" } {required: true, message: "是否启用不能为空", trigger: "blur"}
], ],
createBy: [ createBy: [
{ required: true, message: "创建人不能为空", trigger: "blur" } {required: true, message: "创建人不能为空", trigger: "blur"}
], ],
createTime: [ createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" } {required: true, message: "创建时间不能为空", trigger: "blur"}
], ],
} },
attributeInfoList: [],
brandInfoList: [],
attributeGroupList: [],
}; };
}, },
watch: {
'form.parentId': {
handler(val) {
if (val !== undefined && val !== 0) {
parentCategoryCommon(val).then(
response => {
this.attributeInfoList = response.data.attributeInfoList;
this.attributeGroupList = response.data.attributeGroupList;
this.brandInfoList = response.data.brandInfoList;
}
)
}
},
immediate: true
}
},
created() { created() {
this.getList(); this.getList();
}, },
@ -226,11 +282,11 @@ export default {
children: node.children children: node.children
}; };
}, },
/** 查询品类信息下拉树结构 */ /** 查询品类信息下拉树结构 */
getTreeselect() { getTreeselect() {
listCategory().then(response => { listCategory().then(response => {
this.categoryOptions = []; this.categoryOptions = [];
const data = { id: 0, name: '顶级节点', children: [] }; const data = {id: 0, name: '顶级节点', children: []};
data.children = this.handleTree(response.data, "id", "parentId"); data.children = this.handleTree(response.data, "id", "parentId");
this.categoryOptions.push(data); this.categoryOptions.push(data);
}); });
@ -248,12 +304,7 @@ export default {
image: null, image: null,
parentId: null, parentId: null,
start: null, start: null,
introduction: null, introduction: null
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@ -311,6 +362,7 @@ export default {
}); });
} else { } else {
addCategory(this.form).then(response => { addCategory(this.form).then(response => {
console.log(this.form)
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
@ -321,12 +373,13 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$modal.confirm('是否确认删除品类信息编号为"' + row.id + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除品类信息编号为"' + row.id + '"的数据项?').then(function () {
return delCategory(row.id); return delCategory(row.id);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {}); }).catch(() => {
});
} }
} }
}; };