Commit 0481d232 authored by Marcus's avatar Marcus

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

http://zentao.jdshangmen.com/bug-view-489.html
parent cc84e62b
......@@ -8,7 +8,7 @@
<el-input v-model="form.brandName" placeholder="商标"></el-input>
</el-form-item>
<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
v-for="item in productTypeList"
:key="item.id"
......@@ -19,7 +19,7 @@
</el-select>
</el-form-item>
<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
v-for="item in getProductListByTypeId(form.productTypeId)"
:key="item.id"
......@@ -73,9 +73,22 @@ export default {
},
methods: {
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() {
this.delete0()
const trademarkCategoryRelList = []
this.form.productIds.forEach(productId => {
trademarkCategoryRelList.push({
......
......@@ -124,7 +124,7 @@
trademarkCategoryRelList: []
})">添加商标</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 @click="cancel">取 消</el-button>
</div>
......@@ -143,7 +143,6 @@ import {getProductList} from "@/api/ecw/product"
import BrandForm from "@/views/ecw/productBrank/BrandForm"
import Empower from "@/views/ecw/productBrank/Empower"
export default {
name: "ProductBrank",
components: {
......@@ -182,6 +181,10 @@ export default {
form: {},
// 表单校验
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),
......@@ -196,7 +199,7 @@ export default {
created() {
this.getList();
getProductTypeList().then(r => {
this.productTypeList = r.data
this.productTypeList = [{id: 0, titleZh: '全部'}, ...r.data]
})
getProductList().then(r => {
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