Compare commits

...

2 Commits

Author SHA1 Message Date
20300 d0108ad2ef 前段属性组的添加,列表,修改 2024-03-05 21:02:39 +08:00
20300 e23e466eb3 前段属性列表 2024-03-01 14:58:40 +08:00
4 changed files with 490 additions and 1 deletions

View File

@ -0,0 +1,40 @@
import request from '@/utils/request'
// 查询属性列表
export function list(name) {
return request({
url: '/product/attributeInfo/list?name='+name,
method: 'get'
})
}
//新增属性
export function insertAttribute(attribute) {
return request({
url: '/product/attributeInfo/insertAttribute',
method: 'post',
data: attribute
})
}
//删除属性
export function deleteById(attributeInfoId) {
return request({
url: '/product/attributeInfo/deleteAttributeById?attributeInfoId='+attributeInfoId,
method: 'get'
})
}
//获取属性组列表
export function getAttributeGroupList(attributeName) {
return request({
url: '/product/attributeGroup/getAttributeGroupList?attributeName='+attributeName,
method: 'get'
})
}
export function insertAttributeGroup(attributeGroupReq) {
return request({
url: '/product/attributeGroup/insertAttributeGroup',
method: 'post',
data: attributeGroupReq
})
}

View File

@ -73,7 +73,7 @@ service.interceptors.request.use(config => {
// 响应拦截器
service.interceptors.response.use(res => {
debugger
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 获取错误信息

View File

@ -0,0 +1,257 @@
<template>
<div>
<el-table
:data="attributeGroupList"
style="width: 100%">
<el-table-column
label="属性组编号"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px" >{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column
label="属性组名称"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px" >{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column
label="下辖属性"
width="180">
<template slot-scope="scope">
<el-row>
<el-col v-for="attribute in scope.row.attributeInfos">
<el-tag
:key="attribute.id"
type="">
{{attribute.name}}
</el-tag>
</el-col>
</el-row>
</template>
</el-table-column>
<el-table-column
label="备注"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px" >{{ scope.row.remark }}</span>
</template>
</el-table-column>
<el-table-column
label="创建时间"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px" value-format="yyyy-MM-dd HH:dd:ss">{{ scope.row.createTime }}</span>
</template>
</el-table-column>
<el-table-column
label="创建人"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px" >{{ scope.row.createBy }}</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-button
size="mini"
type="danger"
@click="queryAttributeList">新增</el-button>
<el-dialog title="收货地址" :visible.sync="isOpenAddAttributeGroup">
<el-form :model="attributeGroupReq">
<el-form-item label="属性组名称" :label-width="formLabelWidth">
<el-input v-model="attributeGroupReq.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="备注" :label-width="formLabelWidth">
<el-input v-model="attributeGroupReq.remark" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="已选属性" :label-width="formLabelWidth">
<el-tag
v-for="attribute in attributeGroupReq.selectAttributeList"
v-model="attributeGroupReq.selectAttributeList"
:key="attribute.id"
closable
:disable-transitions="false"
@close="handleClose(attribute)">
{{attribute.name}}
</el-tag>
</el-form-item>
</el-form>
<br>
<span>可选属性</span>
<div>
<el-checkbox @change="updateAttribute(attribute)"
style="margin-left: 10px"
v-for="attribute in attributeList"
:key="attribute.id"
v-model="attribute.checked"
:label="attribute.name" border></el-checkbox>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="isOpenAddAttributeGroup = false"> </el-button>
<el-button type="primary" @click="insertAttributeGroup"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
//jsjsjson,
//import from ',
import {getAttributeGroupList, list, insertAttributeGroup} from "@/api/product/attribute";
import attribute from "@/views/product/attribute/index.vue";
export default {
name: "attributeGroup",
//import使"
components: {},
props: {},
data() {
//"
return {
attributeName:"",
attributeGroupList: [],
isOpenAddAttributeGroup: false,
formLabelWidth: "120px",
//
attributeGroupReq: {
//
selectAttributeList: []
},
attributeQueryName: "",
//
attributeList: [],
};
},
// data",
computed: {},
//data",
watch: {},
//",
methods: {
//
handleDelete(index, row) {
this.isOpenAddAttributeGroup = true
console.log(index, row);
this.attributeGroupReq = row
this.attributeGroupReq.selectAttributeList = row.attributeInfos
list(this.attributeQueryName).then(
res => {
this.attributeList = res.data
this.attributeList.forEach(
attribute => {
this.attributeGroupReq.selectAttributeList.forEach(
attributeReq =>{
if (attribute.id == attributeReq.id){
console.log("六六六")
attribute.checked = true
}
}
)
}
)
}
)
},
//
reset() {
this.attributeGroupReq = {
selectAttributeList: []
},
this.attributeList =[]
},
//
handleClose(attribute){
console.log(this.attributeGroupList)
debugger
this.attributeList.forEach(attr => {
if (attr.id == attribute.id) {
attr.checked = false
}
})
this.attributeGroupReq.selectAttributeList = this.attributeGroupReq.selectAttributeList.filter(item => item!=attribute);
},
//
updateAttribute(attribute) {
if (this.attributeGroupReq.selectAttributeList.includes(attribute)){
this.attributeGroupReq.selectAttributeList = this.attributeGroupReq.selectAttributeList.filter(item => item !== attribute)
}else{
this.attributeGroupReq.selectAttributeList.push(attribute)
}
},
//
getAttributeGroupList(){
getAttributeGroupList(this.attributeName).then(
res => {
console.log(res);
this.attributeGroupList = res.data
}
)
},
handleEdit(index, row) {
console.log(index, row);
},
queryAttributeList(){
this.isOpenAddAttributeGroup = true
list(this.attributeQueryName).then(
res => {
this.attributeList = res.data
}
)
},
insertAttributeGroup() {
console.log(this.attributeGroupReq)
insertAttributeGroup(this.attributeGroupReq).then(
res => {
this.reset();
this.getAttributeGroupList()
this.isOpenAddAttributeGroup = false
}
)
}
},
// - 访this",
created() {
this.getAttributeGroupList()
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>

View File

@ -0,0 +1,192 @@
<template>
<div>
<el-table
:data="attributeList"
style="width: 100%">
<el-table-column
label="创建日期"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px"
value-format="yyyy-MM-dd HH:mm:ss">{{ scope.row.createTime }}</span>
</template>
</el-table-column>
<el-table-column
label="创建人"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px"
value-format="yyyy-MM-dd HH:mm:ss">{{ scope.row.createBy }}</span>
</template>
</el-table-column>
<el-table-column
label="属性编号"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px"
value-format="yyyy-MM-dd HH:mm:ss">{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column
label="属性名称"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px"
value-format="yyyy-MM-dd HH:mm:ss">{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column
label="属性描述"
width="180">
<template slot-scope="scope">
<i class="el-icon-time"></i>
<span style="margin-left: 10px"
value-format="yyyy-MM-dd HH:mm:ss">{{ scope.row.remark }}</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.$index, scope.row)" v-hasPermi="['product:attribute:update']">修改</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)" v-hasPermi="['product:attribute:delete']">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-button size="mini" type="primary" @click="openAdd = true" v-hasPermi="['product:attribute:add']"></el-button>
<el-dialog title="属性信息" :visible.sync="openAdd">
<el-form :model="addAttribute">
<el-form-item label="属性名称" :label-width="formLabelWidth">
<el-input v-model="addAttribute.name" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="属性备注" :label-width="formLabelWidth">
<el-input v-model="addAttribute.remark" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelInsert"> </el-button>
<el-button type="primary" @click="insertAttribute"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
//jsjsjson,
//import from ',
import {deleteById, insertAttribute, list} from "@/api/product/attribute";
export default {
name: 'attribute',
//import使"
components: {},
props: {},
data() {
//"
return {
formLabelWidth: '120px',
//
attributeName: "",
//
attributeList: [],
//
addAttribute: {
name: '',
remark: ''
},
//
openAdd: false
};
},
// data",
computed: {},
//data",
watch: {},
//",
methods: {
//
handleEdit(index, row) {
console.log(index, row);
this.addAttribute["name"] = row.name
this.addAttribute["remark"] = row.remark
this.addAttribute["id"] = row.id
this.openAdd = true
},
//
handleDelete(index, row) {
deleteById(row.id).then(
res=>{
console.log(res)
this.getAttributeList()
}
)
console.log(index, row);
},
//
getAttributeList(){
list(this.attributeName).then(
res => {
this.attributeList = res.data
console.log(res)
}
)
},
//
insertAttribute(){
insertAttribute(this.addAttribute).then(
this.getAttributeList
)
this.addAttribute["name"] = ""
this.addAttribute["remark"] = ""
this.addAttribute["id"] = ""
this.openAdd = false
},
//
cancelInsert(){
this.openAdd = false
this.addAttribute = {}
},
},
// - 访this",
created() {
this.getAttributeList()
},
// - 访DOM",
mounted() {
},
beforeCreate() {
}, // - ",
beforeMount() {
}, // - ",
beforeUpdate() {
}, // - ",
updated() {
}, // - ",
beforeDestroy() {
}, // - ",
destroyed() {
}, // - ",
activated() {
} //keep-alive",
};
</script>
<style scoped>
</style>