规格属性添加
parent
821fb4aacc
commit
0311f3bf35
|
@ -1,176 +1,156 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<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>
|
<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>
|
<el-row>
|
||||||
|
<el-col :span="2" v-for="(attribute, index) in checkedAttributeList">
|
||||||
<!-- <el-row>-->
|
<el-tag
|
||||||
<!-- <el-tag>标签一</el-tag>-->
|
style="margin: 5px 10px"
|
||||||
<!-- <el-tag type="success">标签二</el-tag>-->
|
:key="attribute.name"
|
||||||
<!-- <el-tag type="info">标签三</el-tag>-->
|
closable @close="removeChecked(index)">
|
||||||
<!-- <el-tag type="warning">标签四</el-tag>-->
|
{{ attribute.name }}
|
||||||
<!-- <el-tag type="danger">标签五</el-tag>-->
|
</el-tag>
|
||||||
<!-- </el-row>-->
|
</el-col>
|
||||||
<el-row>
|
</el-row>
|
||||||
<el-col :span="2" v-for="(attribute, index) in checkedAttributeList">
|
</el-card>
|
||||||
<el-tag
|
<el-divider></el-divider>
|
||||||
style="margin: 5px 10px"
|
<el-card class="box-card">
|
||||||
:key="attribute.name"
|
<div slot="header" class="clearfix">
|
||||||
closable @close="removeChecked(index)">
|
<span>未选属性</span>
|
||||||
{{attribute.name}}
|
</div>
|
||||||
</el-tag>
|
<el-row>
|
||||||
</el-col>
|
<el-form :inline="true" :model="attributeQuery" class="demo-form-inline">
|
||||||
|
<el-form-item label="属性编码">
|
||||||
|
<el-input v-model="attributeQuery.code" placeholder="属性编码"></el-input>
|
||||||
</el-row>
|
</el-form-item>
|
||||||
|
<el-form-item label="属性名称">
|
||||||
</el-card>
|
<el-input v-model="attributeQuery.name" placeholder="属性名称"></el-input>
|
||||||
|
</el-form-item>
|
||||||
<el-divider></el-divider>
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="queryAttribute">查询</el-button>
|
||||||
<el-card class="box-card">
|
</el-form-item>
|
||||||
<div slot="header" class="clearfix">
|
</el-form>
|
||||||
<span>未选属性</span>
|
</el-row>
|
||||||
</div>
|
<el-row>
|
||||||
|
<el-col style="padding: 5px 10px" :span="3" v-for="attribute in attributeList">
|
||||||
<el-row>
|
<el-checkbox
|
||||||
<el-form :inline="true" :model="attributeQuery" class="demo-form-inline">
|
v-model="attributeIdList"
|
||||||
<el-form-item label="屬性編碼">
|
:key="attribute.id"
|
||||||
<el-input v-model="attributeQuery.code" placeholder="屬性編碼"></el-input>
|
:value="attribute.id"
|
||||||
</el-form-item>
|
:label="attribute.id"
|
||||||
</el-form>
|
@change="checkedAttribute(attribute)"
|
||||||
|
border>{{ attribute.name }}
|
||||||
<el-form :inline="true" :model="attributeQuery" class="demo-form-inline">
|
</el-checkbox>
|
||||||
<el-form-item label="屬性名稱">
|
</el-col>
|
||||||
<el-input v-model="attributeQuery.name" placeholder="屬性名稱"></el-input>
|
</el-row>
|
||||||
</el-form-item>
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
<el-form-item>
|
:total="total"
|
||||||
<el-button type="primary" @click="queryAttribute">查询</el-button>
|
:page.sync="attributeQuery.pageNum"
|
||||||
</el-form-item>
|
:limit.sync="attributeQuery.pageSize"
|
||||||
</el-form>
|
@pagination="queryAttribute"
|
||||||
</el-row>
|
/>
|
||||||
|
</el-card>
|
||||||
<el-row >
|
</el-card>
|
||||||
<el-col style="padding: 5px 10px" :span="3" v-for="attribute in attributeList">
|
</el-row>
|
||||||
<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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {listAttribute} from "@/api/product/attribute";
|
import {listAttribute} from "@/api/product/attribute";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CheckAttribute",
|
name: "CheckAttribute",
|
||||||
props:{
|
props: {
|
||||||
value:{
|
value: {
|
||||||
type:Array,
|
type: Array,
|
||||||
default: []
|
default: []
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
value: {
|
|
||||||
handler(val){
|
|
||||||
if (val.toString() !== this.attributeIdList.toString()){
|
|
||||||
this.attributeIdList = val;
|
|
||||||
this.checkedAttributeList = []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
immediate :true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
data(){
|
|
||||||
return{
|
|
||||||
attributeIdList: [],
|
|
||||||
checkedAttributeList: [],
|
|
||||||
attributeQuery:{
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
code: null,
|
|
||||||
name: null
|
|
||||||
},
|
|
||||||
attributeTotal: 0,
|
|
||||||
attributeList: []
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
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: []
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.queryAttribute();
|
this.queryAttribute();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* 选中值触发方法
|
* 选中值触发方法
|
||||||
*/
|
*/
|
||||||
checkedAttribute(attribute){
|
checkedAttribute(attribute) {
|
||||||
let isCheck = this.attributeIdList.indexOf(attribute.id) > -1;
|
let isCheck = this.attributeIdList.indexOf(attribute.id) > -1;
|
||||||
if (isCheck){
|
if (isCheck) {
|
||||||
this.checkedAttributeList.push(attribute);
|
this.checkedAttributeList.push(attribute);
|
||||||
}else {
|
} else {
|
||||||
//删除
|
// 删除
|
||||||
this.checkedAttributeList.splice(
|
this.checkedAttributeList.splice(
|
||||||
this.checkedAttributeList.indexOf(attribute),1
|
this.checkedAttributeList.indexOf(attribute), 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
this.$emit("input", this.attributeIdList);
|
this.$emit("input", this.attributeIdList);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 删除选中值
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
removeChecked(index) {
|
||||||
|
this.checkedAttributeList.splice(index, 1);
|
||||||
|
this.attributeIdList.splice(index, 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* 查询属性
|
||||||
* 删除选中值
|
*/
|
||||||
* @param index
|
queryAttribute() {
|
||||||
*/
|
listAttribute(this.attributeQuery).then(response => {
|
||||||
removeChecked(index){
|
this.attributeList = response.data.rows;
|
||||||
console.log(index)
|
this.total = response.data.total;
|
||||||
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;
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-card class="box-card">
|
<el-card class="box-card">
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
|
@ -10,55 +8,33 @@
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span>已选择属性组</span>
|
<span>已选择属性组</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <el-row>-->
|
|
||||||
<!-- <el-tag>标签一</el-tag>-->
|
|
||||||
<!-- <el-tag type="success">标签二</el-tag>-->
|
|
||||||
<!-- <el-tag type="info">标签三</el-tag>-->
|
|
||||||
<!-- <el-tag type="warning">标签四</el-tag>-->
|
|
||||||
<!-- <el-tag type="danger">标签五</el-tag>-->
|
|
||||||
<!-- </el-row>-->
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="2" v-for="(attributeGroup, index) in checkedAttributeGroupList">
|
<el-col :span="2" v-for="(attributeGroup, index) in checkedAttributeGroupList">
|
||||||
<el-tag
|
<el-tag
|
||||||
style="margin: 5px 10px"
|
style="margin: 5px 10px"
|
||||||
:key="attributeGroup.name"
|
:key="attributeGroup.name"
|
||||||
closable @close="removeChecked(index)">
|
closable @close="removeChecked(index)">
|
||||||
{{attributeGroup.name}}
|
{{ attributeGroup.name }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
|
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<el-divider></el-divider>
|
<el-divider></el-divider>
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-form :inline="true" :model="attributeGroupQuery" class="demo-form-inline">
|
<el-form :inline="true" :model="attributeGroupQuery" class="demo-form-inline">
|
||||||
<el-form-item label="屬性編碼">
|
<el-form-item label="属性组名称">
|
||||||
<el-input v-model="attributeGroupQuery.code" placeholder="屬性編碼"></el-input>
|
<el-input v-model="attributeGroupQuery.name" placeholder="属性名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-form :inline="true" :model="attributeGroupQuery" class="demo-form-inline">
|
|
||||||
<el-form-item label="屬性名稱">
|
|
||||||
<el-input v-model="attributeGroupQuery.name" placeholder="屬性名稱"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="queryAttributeGroup">查询</el-button>
|
<el-button type="primary" @click="queryAttributeGroup">查询</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row>
|
||||||
<el-row >
|
|
||||||
<el-col style="padding: 5px 10px" :span="3" v-for="attributeGroup in attributeGroupList">
|
<el-col style="padding: 5px 10px" :span="3" v-for="attributeGroup in attributeGroupList">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="attributeGroupIdList"
|
v-model="attributeGroupIdList"
|
||||||
|
@ -66,10 +42,10 @@
|
||||||
:value="attributeGroup.id"
|
:value="attributeGroup.id"
|
||||||
:label="attributeGroup.id"
|
:label="attributeGroup.id"
|
||||||
@change="checkedAttributeGroup(attributeGroup)"
|
@change="checkedAttributeGroup(attributeGroup)"
|
||||||
border>{{attributeGroup.name}}</el-checkbox>
|
border>{{ attributeGroup.name }}
|
||||||
|
</el-checkbox>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<pagination
|
<pagination
|
||||||
v-show="total>0"
|
v-show="total>0"
|
||||||
:total="total"
|
:total="total"
|
||||||
|
@ -85,93 +61,92 @@
|
||||||
<script>
|
<script>
|
||||||
import {listAttributeGroup} from "@/api/product/attributeGroup";
|
import {listAttributeGroup} from "@/api/product/attributeGroup";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CheckAttributeGroup",
|
name: "CheckAttributeGroup",
|
||||||
props:{
|
props: {
|
||||||
value:{
|
value: {
|
||||||
type:Array,
|
type: Array,
|
||||||
default: []
|
default: []
|
||||||
|
},
|
||||||
|
checkedList: {
|
||||||
|
type: Array,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
data(){
|
|
||||||
return{
|
|
||||||
attributeGroupIdList: [],
|
attributeGroupIdList: [],
|
||||||
checkedAttributeGroupList: [],
|
checkedAttributeGroupList: [],
|
||||||
attributeGroupQuery:{
|
attributeGroupQuery: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
code: null,
|
|
||||||
name: null
|
name: null
|
||||||
},
|
},
|
||||||
attributeGroupTotal: 0,
|
attributeGroupTotal: 0,
|
||||||
attributeGroupList: []
|
attributeGroupList: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
value: {
|
value: {
|
||||||
handler(val){
|
handler(val) {
|
||||||
if (val.toString() !== this.attributeGroupIdList.toString()){
|
if (val.toString() !== this.attributeGroupIdList.toString()){
|
||||||
this.attributeGroupIdList = val;
|
this.attributeGroupIdList = val;
|
||||||
this.checkedAttributeGroupList = []
|
this.checkedAttributeGroupList = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate :true,
|
immediate: true,
|
||||||
|
},
|
||||||
|
checkedList: {
|
||||||
|
handler(val){
|
||||||
|
if (val !== undefined && val.length > 0){
|
||||||
|
this.checkedAttributeGroupList = val;
|
||||||
|
this.attributeGroupIdList = this.checkedAttributeGroupList.map(checked => checked.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.queryAttributeGroup();
|
this.queryAttributeGroup();
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* 选中值触发方法
|
* 选中值触发方法
|
||||||
*/
|
*/
|
||||||
checkedAttributeGroup(attributeGroup){
|
checkedAttributeGroup(attributeGroup) {
|
||||||
let isCheck = this.attributeGroupIdList.indexOf(attributeGroup.id) > -1;
|
let isCheck = this.attributeGroupIdList.indexOf(attributeGroup.id) > -1;
|
||||||
if (isCheck){
|
if (isCheck) {
|
||||||
this.checkedAttributeGroupList.push(attributeGroup);
|
this.checkedAttributeGroupList.push(attributeGroup);
|
||||||
}else {
|
} else {
|
||||||
//删除
|
// 删除
|
||||||
this.checkedAttributeGroupList.splice(
|
this.checkedAttributeGroupList.splice(
|
||||||
this.checkedAttributeGroupList.indexOf(attributeGroup),1
|
this.checkedAttributeGroupList.indexOf(attributeGroup), 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
this.$emit("input", this.attributeGroupIdList);
|
this.$emit("input", this.attributeGroupIdList);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除选中值
|
* 删除选中值
|
||||||
* @param index
|
* @param index
|
||||||
*/
|
*/
|
||||||
removeChecked(index){
|
removeChecked(index) {
|
||||||
console.log(index)
|
this.checkedAttributeGroupList.splice(index, 1);
|
||||||
this.checkedAttributeGroupList.splice(index,1);
|
this.attributeGroupIdList.splice(index, 1);
|
||||||
this.attributeGroupIdList.splice(index,1);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查詢屬性
|
* 查询属性
|
||||||
*/
|
*/
|
||||||
queryAttributeGroup(){
|
queryAttributeGroup() {
|
||||||
|
|
||||||
listAttributeGroup(this.attributeGroupQuery).then(response => {
|
listAttributeGroup(this.attributeGroupQuery).then(response => {
|
||||||
this.attributeGroupList = response.data.rows;
|
this.attributeGroupList = response.data.rows;
|
||||||
this.total = response.data.total;
|
this.total = response.data.total;
|
||||||
this.loading = false;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
@ -152,15 +152,15 @@
|
||||||
<el-tabs value="attribute" type="card" >
|
<el-tabs value="attribute" type="card" >
|
||||||
|
|
||||||
<el-tab-pane label="商品属性" name="attribute">
|
<el-tab-pane label="商品属性" name="attribute">
|
||||||
<CheckAttribute v-model="form.attributeGroupList"/>
|
<CheckAttribute v-model="form.attributeIdList" :checked-list="attributeInfoList"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane label="商品属性组" name="attributeGroup">
|
<el-tab-pane label="商品属性组" name="attributeGroup">
|
||||||
<CheckAttributeGroup v-model="form.attributeGroupList"/>
|
<CheckAttributeGroup v-model="form.attributeGroupList" :checked-list="attributeGroupList"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane label="商品品牌" name="brand">
|
<el-tab-pane label="商品品牌" name="brand">
|
||||||
<CheckBrandGroup v-model="form.attributeGroupList"/>
|
<CheckBrandGroup v-model="form.brandIdList" :checked-list="brandInfoList"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
|
|
|
@ -116,54 +116,107 @@
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-row v-for="(ruleAttr, index) in form.ruleAttrList">
|
<!-- <el-row v-for="(ruleAttr, index) in form.ruleAttrList">-->
|
||||||
<el-row style="margin: 20px 0">
|
<!-- <el-row style="margin: 20px 0">-->
|
||||||
<el-tag
|
<!-- <el-tag-->
|
||||||
:key="ruleAttr.name"
|
<!-- :key="ruleAttr.name"-->
|
||||||
@close="removeRule(index)"
|
<!-- @close="removeRule(index)"-->
|
||||||
closable>
|
<!-- closable>-->
|
||||||
{{ruleAttr.name}}
|
<!-- {{ruleAttr.name}}-->
|
||||||
</el-tag>
|
<!-- </el-tag>-->
|
||||||
</el-row>
|
<!-- </el-row>-->
|
||||||
<el-row style="margin: 10px 0">
|
<!-- <el-row style="margin: 10px 0">-->
|
||||||
<el-tag
|
<!-- <el-tag-->
|
||||||
style="float: left; margin-right: 20px"
|
<!-- style="float: left; margin-right: 20px"-->
|
||||||
v-for="(ruleProperty, index) in ruleAttr.valueList"
|
<!-- v-for="(ruleProperty, index) in ruleAttr.valueList"-->
|
||||||
:key="ruleProperty"
|
<!-- :key="ruleProperty"-->
|
||||||
@close="removeRuleProperty(ruleAttr.valueList, index)"
|
<!-- @close="removeRuleProperty(ruleAttr.valueList, index)"-->
|
||||||
closable>
|
<!-- closable>-->
|
||||||
{{ruleProperty}}
|
<!-- {{ruleProperty}}-->
|
||||||
</el-tag>
|
<!-- </el-tag>-->
|
||||||
<el-button v-if="!ruleAttr.ruleAttrAddStatus" @click="ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus" size="mini">添加</el-button>
|
<!-- <el-button v-if="!ruleAttr.ruleAttrAddStatus" @click="ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus" size="mini">添加</el-button>-->
|
||||||
<el-input v-if="ruleAttr.ruleAttrAddStatus"
|
<!-- <el-input v-if="ruleAttr.ruleAttrAddStatus"-->
|
||||||
v-model="addRulePropertyValue"
|
<!-- v-model="addRulePropertyValue"-->
|
||||||
@blur="addRuleProperty(ruleAttr, false)"
|
<!-- @blur="addRuleProperty(ruleAttr, false)"-->
|
||||||
@keyup.enter.native="addRuleProperty(ruleAttr, true)"
|
<!-- @keyup.enter.native="addRuleProperty(ruleAttr, true)"-->
|
||||||
size="mini" placeholder="请输入规格属性值" style="float: left; width: 150px"/>
|
<!-- size="mini" placeholder="请输入规格属性值" style="float: left; width: 150px"/>-->
|
||||||
</el-row>
|
<!-- </el-row>-->
|
||||||
<el-divider></el-divider>
|
<!-- <el-divider></el-divider>-->
|
||||||
</el-row>
|
<!-- </el-row>-->
|
||||||
|
<!-- <el-button v-if="!ruleAddFormStatus" @click="ruleAddFormStatus = !ruleAddFormStatus">添加规格</el-button>-->
|
||||||
|
<!-- <el-form v-if="ruleAddFormStatus" :inline="true" :model="ruleAddForm" class="demo-form-inline">-->
|
||||||
|
<!-- <el-form-item label="规格名称">-->
|
||||||
|
<!-- <el-input v-model="ruleAddForm.name" placeholder="请输入规格名称"></el-input>-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<!-- <el-form-item label="规格属性">-->
|
||||||
|
<!-- <el-input v-model="ruleAddForm.valueList" placeholder="请输入规格属性"></el-input>-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<!-- <el-form-item>-->
|
||||||
|
<!-- <el-button type="primary" @click="ruleAddFormFun">添加</el-button>-->
|
||||||
|
<!-- </el-form-item>-->
|
||||||
|
<!-- </el-form>-->
|
||||||
|
<!-- </el-form>-->
|
||||||
|
|
||||||
|
<el-row v-for="(ruleAttr,index) in form.ruleAttrList">
|
||||||
|
<el-row style="margin: 20px 0">
|
||||||
|
<el-tag
|
||||||
|
key="ruleAttr.name"
|
||||||
|
@close="removeRule(index)"
|
||||||
|
closable>
|
||||||
|
{{ruleAttr.name}}
|
||||||
|
</el-tag>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row style="margin: 10px 0">
|
||||||
|
<el-tag
|
||||||
|
style="float: left;margin-right: 20px"
|
||||||
|
v-for="(ruleProperty, index) in ruleAttr.valueList"
|
||||||
|
:key="ruleProperty"
|
||||||
|
@close="removeRuleProperty(ruleAttr.valueList, index)"
|
||||||
|
closable>
|
||||||
|
{{ruleProperty}}
|
||||||
|
</el-tag>
|
||||||
|
|
||||||
|
<el-button v-if="!ruleAttr.ruleAttrAddStatus" @click="ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus" size="mini">添加</el-button>
|
||||||
|
<el-input v-if="ruleAttr.ruleAttrAddStatus"
|
||||||
|
v-model="addRulePropertyValue"
|
||||||
|
@blur="addRuleProperty(ruleAttr, false)"
|
||||||
|
@keyup.enter.native="addRuleProperty(ruleAttr,true)"
|
||||||
|
size="mini" placeholder="请输入规格属性值" style="float: left; width: 150px"/>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-divider></el-divider>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
|
||||||
<el-button v-if="!ruleAddFormStatus" @click="ruleAddFormStatus = !ruleAddFormStatus">添加规格</el-button>
|
<el-button v-if="!ruleAddFormStatus" @click="ruleAddFormStatus = !ruleAddFormStatus">添加规格</el-button>
|
||||||
|
|
||||||
<el-form v-if="ruleAddFormStatus" :inline="true" :model="ruleAddForm" class="demo-form-inline">
|
<el-form v-if="ruleAddFormStatus" :inline="true" :model="ruleAddForm" class="demo-form-inline">
|
||||||
<el-form-item label="规格名称">
|
<el-form-item label="规格名称">
|
||||||
<el-input v-model="ruleAddForm.name" placeholder="请输入规格名称"></el-input>
|
<el-input v-model="ruleAddForm.name" placeholder="请输入规格名称"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="规格属性">
|
<el-form-item label="规格属性">
|
||||||
<el-input v-model="ruleAddForm.valueList" placeholder="请输入规格属性"></el-input>
|
<el-input v-model="ruleAddForm.valueList" placeholder="请输入规格属性"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="ruleAddFormFun">添加</el-button>
|
<el-button type="primary" @click="ruleAddFormFun">添加</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</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>
|
||||||
<el-button @click="cancel">取 消</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listRule, getRule, delRule, addRule, updateRule } from "@/api/product/rule";
|
import { listRule, getRule, delRule, addRule, updateRule } from "@/api/product/rule";
|
||||||
|
|
||||||
|
@ -207,34 +260,111 @@ export default {
|
||||||
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
ruleAddForm: {
|
ruleAddForm: {
|
||||||
name: null,
|
name: null,
|
||||||
valueList: null,
|
valueList: null,
|
||||||
},
|
},
|
||||||
ruleAddFormStatus: false,
|
ruleAddFormStatus: false,
|
||||||
addRulePropertyValue: null
|
addRulePropertyValue: null,
|
||||||
|
|
||||||
|
// ruleAddForm: {
|
||||||
|
// name: null,
|
||||||
|
// valueList: null,
|
||||||
|
// },
|
||||||
|
// ruleAddFormStatus: false,
|
||||||
|
// addRulePropertyValue: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeRule(index){
|
// removeRule(index){
|
||||||
this.form.ruleAttrList.splice(index, 1);
|
// this.form.ruleAttrList.splice(index, 1);
|
||||||
|
// },
|
||||||
|
// removeRuleProperty(valueList,index){
|
||||||
|
// valueList.splice(index, 1);
|
||||||
|
// },
|
||||||
|
// addRuleProperty(ruleAttr, continuousInput){
|
||||||
|
// if (this.addRulePropertyValue === null || this.addRulePropertyValue === 0){
|
||||||
|
// if (!continuousInput){
|
||||||
|
// ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (ruleAttr.valueList.indexOf(this.addRulePropertyValue) > -1){
|
||||||
|
// this.$message({
|
||||||
|
// message: `规格[${ruleAttr.name}]属性值[${this.addRulePropertyValue}]已经存在`,
|
||||||
|
// type: 'warning'
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// ruleAttr.valueList.push(this.addRulePropertyValue)
|
||||||
|
// this.addRulePropertyValue = null;
|
||||||
|
// if (!continuousInput){
|
||||||
|
// ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// ruleAddFormFun(){
|
||||||
|
// if (this.ruleAddForm.name === null || this.ruleAddForm.name.length === 0){
|
||||||
|
// this.$message({
|
||||||
|
// message: '规格名称不可为空',
|
||||||
|
// type: 'warning'
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (this.ruleAddForm.valueList === null || this.ruleAddForm.valueList.length === 0){
|
||||||
|
// this.$message({
|
||||||
|
// message: '规格属性不可为空',
|
||||||
|
// type: 'warning'
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// let ruleAttr = this.form.ruleAttrList.find(ruleAttr => ruleAttr.name === this.ruleAddForm.name);
|
||||||
|
// if (ruleAttr === undefined){
|
||||||
|
// this.form.ruleAttrList.push({
|
||||||
|
// "name": this.ruleAddForm.name,
|
||||||
|
// "valueList": [this.ruleAddForm.valueList],
|
||||||
|
// "ruleAttrAddStatus": false
|
||||||
|
// })
|
||||||
|
// }else {
|
||||||
|
// if (ruleAttr.valueList.indexOf(this.ruleAddForm.valueList) > -1){
|
||||||
|
// this.$message({
|
||||||
|
// message: `规格[${this.ruleAddForm.name}]属性值[${this.ruleAddForm.valueList}]已经存在`,
|
||||||
|
// type: 'warning'
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// ruleAttr.valueList.push(this.ruleAddForm.valueList)
|
||||||
|
// }
|
||||||
|
// this.ruleAddForm = {
|
||||||
|
// name: null,
|
||||||
|
// valueList: null,
|
||||||
|
// }
|
||||||
|
// this.ruleAddFormStatus = false;
|
||||||
|
// },
|
||||||
|
|
||||||
|
removeRule(index) {
|
||||||
|
this.form.ruleAttrList.splice(index,1);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeRuleProperty(valueList,index){
|
removeRuleProperty(valueList,index){
|
||||||
valueList.splice(index, 1);
|
valueList.splice(index,1);
|
||||||
},
|
},
|
||||||
|
|
||||||
addRuleProperty(ruleAttr, continuousInput){
|
addRuleProperty(ruleAttr, continuousInput){
|
||||||
if (this.addRulePropertyValue === null || this.addRulePropertyValue === 0){
|
if (this.addRulePropertyValue == null || this.addRulePropertyValue == 0){
|
||||||
if (!continuousInput){
|
if (continuousInput){
|
||||||
ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus
|
ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ruleAttr.valueList.indexOf(this.addRulePropertyValue) > -1){
|
if (ruleAttr.valueList.indexOf(this.addRulePropertyValue) > -1){
|
||||||
this.$message({
|
this.$message({
|
||||||
message: `规格[${ruleAttr.name}]属性值[${this.addRulePropertyValue}]已经存在`,
|
message:`规格[${ruleAttr.name}]属性值[${this.addRulePropertyValue}]已经存在`,
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -245,45 +375,53 @@ export default {
|
||||||
ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus
|
ruleAttr.ruleAttrAddStatus = !ruleAttr.ruleAttrAddStatus
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ruleAddFormFun(){
|
ruleAddFormFun(){
|
||||||
if (this.ruleAddForm.name === null || this.ruleAddForm.name.length === 0){
|
|
||||||
|
if (this.ruleAddForm.name == null || this.ruleAddForm.name.length == 0){
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '规格名称不可为空',
|
message: '规格名称不可为空',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
});
|
})
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.ruleAddForm.valueList === null || this.ruleAddForm.valueList.length === 0){
|
|
||||||
|
if (this.ruleAddForm.valueList == null || this.ruleAddForm.valueList.length == 0){
|
||||||
this.$message({
|
this.$message({
|
||||||
message: '规格属性不可为空',
|
message: '规格属性不可为空',
|
||||||
type: 'warning'
|
type:'warning'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ruleAttr = this.form.ruleAttrList.find(ruleAttr => ruleAttr.name === this.ruleAddForm.name);
|
let ruleAttr = this.form.ruleAttrList.find(ruleAttr => ruleAttr.name == this.ruleAddForm.name);
|
||||||
if (ruleAttr === undefined){
|
if (ruleAttr == undefined){
|
||||||
this.form.ruleAttrList.push({
|
this.form.ruleAttrList.push({
|
||||||
"name": this.ruleAddForm.name,
|
"name": this.ruleAddForm.name,
|
||||||
"valueList": [this.ruleAddForm.valueList],
|
"valueList": [this.ruleAddForm.valueList],
|
||||||
"ruleAttrAddStatus": false
|
"ruleAttrAddStatus": false
|
||||||
})
|
})
|
||||||
}else {
|
}else {
|
||||||
if (ruleAttr.valueList.indexOf(this.ruleAddForm.valueList) > -1){
|
if (ruleAttr.valueList.indexOf(this.ruleAddForm.valueList) > -1){
|
||||||
this.$message({
|
this.$message({
|
||||||
message: `规格[${this.ruleAddForm.name}]属性值[${this.ruleAddForm.valueList}]已经存在`,
|
message: `规格[${this.ruleAddForm.name}]属性值[${this.ruleAddForm.valueList}]已经存在`,
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ruleAttr.valueList.push(this.ruleAddForm.valueList)
|
ruleAttr.valueList.push(this.ruleAddForm.valueList)
|
||||||
}
|
}
|
||||||
this.ruleAddForm = {
|
|
||||||
name: null,
|
this.ruleAddForm = {
|
||||||
valueList: null,
|
name: null,
|
||||||
}
|
valueList: null,
|
||||||
|
}
|
||||||
|
|
||||||
this.ruleAddFormStatus = false;
|
this.ruleAddFormStatus = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/** 查询商品规格列表 */
|
/** 查询商品规格列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
Loading…
Reference in New Issue