Commit 0481d232 authored by Marcus's avatar Marcus

后台-品牌管理-添加品牌错误

http://zentao.jdshangmen.com/bug-view-489.html
parent cc84e62b
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<el-input v-model="form.brandName" placeholder="商标"></el-input> <el-input v-model="form.brandName" placeholder="商标"></el-input>
</el-form-item> </el-form-item>
<el-form-item :label="`商标${index + 1}分类`"> <el-form-item :label="`商标${index + 1}分类`">
<el-select v-model="form.productTypeId" :placeholder="`请选择商标${index + 1}分类`" @change="form.productIds = [], updateValue()"> <el-select v-model="form.productTypeId" :placeholder="`请选择商标${index + 1}分类`" @change="form.productIds = [0], updateValue()">
<el-option <el-option
v-for="item in productTypeList" v-for="item in productTypeList"
:key="item.id" :key="item.id"
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="`商标${index + 1}商品`"> <el-form-item :label="`商标${index + 1}商品`">
<el-select v-model="form.productIds" :placeholder="`请选择商标${index + 1}商品`" multiple filterable @change="updateValue"> <el-select v-model="form.productIds" :placeholder="`请选择商标${index + 1}商品`" multiple filterable clearable @change="updateValue">
<el-option <el-option
v-for="item in getProductListByTypeId(form.productTypeId)" v-for="item in getProductListByTypeId(form.productTypeId)"
:key="item.id" :key="item.id"
...@@ -73,9 +73,22 @@ export default { ...@@ -73,9 +73,22 @@ export default {
}, },
methods: { methods: {
getProductListByTypeId(typeId) { getProductListByTypeId(typeId) {
return typeId === 0 ? [] : this.productList.filter((p) => p.typeId === typeId) return [
{id: 0, titleZh: '全部'},
...(typeId === 0 ? [] : this.productList.filter((p) => p.typeId === typeId))
]
},
// 删除商品0
delete0(){
if (this.form.productIds.length > 1){
const index = this.form.productIds.indexOf(0)
if (index !== -1) {
this.form.productIds.splice(index, 1)
}
}
}, },
updateValue() { updateValue() {
this.delete0()
const trademarkCategoryRelList = [] const trademarkCategoryRelList = []
this.form.productIds.forEach(productId => { this.form.productIds.forEach(productId => {
trademarkCategoryRelList.push({ trademarkCategoryRelList.push({
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
trademarkCategoryRelList: [] trademarkCategoryRelList: []
})">添加商标</el-button> })">添加商标</el-button>
<div slot="footer" class="dialog-footer"> <div slot="footer" style="text-align: center">
<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>
...@@ -143,7 +143,6 @@ import {getProductList} from "@/api/ecw/product" ...@@ -143,7 +143,6 @@ import {getProductList} from "@/api/ecw/product"
import BrandForm from "@/views/ecw/productBrank/BrandForm" import BrandForm from "@/views/ecw/productBrank/BrandForm"
import Empower from "@/views/ecw/productBrank/Empower" import Empower from "@/views/ecw/productBrank/Empower"
export default { export default {
name: "ProductBrank", name: "ProductBrank",
components: { components: {
...@@ -182,6 +181,10 @@ export default { ...@@ -182,6 +181,10 @@ export default {
form: {}, form: {},
// 表单校验 // 表单校验
rules: { rules: {
titleZh: [{ required: true, message: '请输入品牌中文标题', trigger: "blur" }],
titleEn: [{ required: true, message: '请输入品牌英文标题', trigger: "blur" }],
// aorder: [{ required: true, message: '请输入排序', trigger: "blur" }],
filing: [{ required: true, message: '请选择是否备案', trigger: "change" }],
}, },
recordStatus: getDictDatas(DICT_TYPE.BRAND_REG_TYPE), recordStatus: getDictDatas(DICT_TYPE.BRAND_REG_TYPE),
...@@ -196,7 +199,7 @@ export default { ...@@ -196,7 +199,7 @@ export default {
created() { created() {
this.getList(); this.getList();
getProductTypeList().then(r => { getProductTypeList().then(r => {
this.productTypeList = r.data this.productTypeList = [{id: 0, titleZh: '全部'}, ...r.data]
}) })
getProductList().then(r => { getProductList().then(r => {
this.productList = r.data this.productList = r.data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment