|
@@ -6,13 +6,11 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
isEditIndex: -1,
|
|
|
- orderBrands: [],
|
|
|
- classifyList: [],
|
|
|
- classifyListLv2: []
|
|
|
+ productList_wb: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
- productColumns() {
|
|
|
+ productColumns_wb() {
|
|
|
return [
|
|
|
{
|
|
|
columnAttributes: {
|
|
@@ -28,14 +26,14 @@ export default {
|
|
|
onInput={(val) => { row[column.columnAttributes.prop] = val }}
|
|
|
onChange={(val) => {
|
|
|
if (val) {
|
|
|
- var data = this.orderBrands.find(item => item.value == val)
|
|
|
+ var data = this.huoquweiyi('brandId', 'brandName').find(item => item.value == val)
|
|
|
row.brandName = data.label
|
|
|
} else {
|
|
|
row.brandName = ""
|
|
|
}
|
|
|
}}
|
|
|
placeholder="请选择">
|
|
|
- {this.orderBrands.map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
|
|
|
+ {this.huoquweiyi('brandId', 'brandName').map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)}
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</div> : <div style="padding-left:10px">{row.brandName}</div>
|
|
@@ -57,14 +55,20 @@ export default {
|
|
|
row.smallId = ""
|
|
|
row.smallName = ""
|
|
|
if (val) {
|
|
|
- var data = this.classifyList.find(item => item.categoryId == val)
|
|
|
- row.mainName = data.name
|
|
|
+ var data = this.huoquweiyi('mainId', 'mainName').filter(item => {
|
|
|
+ return !!this.productList_wb.filter(v => v.mainId == item.value).find(v2 => v2.brandId == row.brandId)
|
|
|
+ }).find(item => item.value == val)
|
|
|
+ row.mainName = data.label
|
|
|
} else {
|
|
|
row.mainName = ""
|
|
|
}
|
|
|
}}
|
|
|
placeholder="请选择">
|
|
|
- {this.classifyList.map((item, index_) => <el-option key={index_} label={item.name} value={item.categoryId}></el-option>)}
|
|
|
+ {
|
|
|
+ this.huoquweiyi('mainId', 'mainName').filter(item => {
|
|
|
+ return !!this.productList_wb.filter(v => v.mainId == item.value).find(v2 => v2.brandId == row.brandId)
|
|
|
+ }).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)
|
|
|
+ }
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</div> : <div style="padding-left:10px">{row.mainName}</div>
|
|
@@ -84,17 +88,22 @@ export default {
|
|
|
onInput={(val) => { row[column.columnAttributes.prop] = val }}
|
|
|
onChange={(val) => {
|
|
|
if (val) {
|
|
|
- var data = this.classifyListLv2.find(item => item.categoryId == val)
|
|
|
- console.log(data)
|
|
|
- row.smallName = data.name
|
|
|
- row.imgUrl = data.imgUrl
|
|
|
+ var data = this.huoquweiyi('smallId', 'smallName', "smallImg").filter(item => {
|
|
|
+ return !!this.productList_wb.filter(v => v.smallId == item.value).find(v2 => v2.brandId == row.brandId && v2.mainId == row.mainId)
|
|
|
+ }).find(item => item.value == val)
|
|
|
+ row.smallName = data.label
|
|
|
+ row.imgUrl = data.smallImg
|
|
|
} else {
|
|
|
row.smallName = ""
|
|
|
row.imgUrl = ""
|
|
|
}
|
|
|
}}
|
|
|
placeholder="请选择">
|
|
|
- {this.classifyListLv2.filter(item => item.parentId === row.mainId).map((item, index_) => <el-option key={index_} label={item.name} value={item.categoryId}></el-option>)}
|
|
|
+ {
|
|
|
+ this.huoquweiyi('smallId', 'smallName', "smallImg").filter(item => {
|
|
|
+ return !!this.productList_wb.filter(v => v.smallId == item.value).find(v2 => v2.brandId == row.brandId && v2.mainId == row.mainId)
|
|
|
+ }).map((item, index_) => <el-option key={index_} label={item.label} value={item.value}></el-option>)
|
|
|
+ }
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</div> : <div style="padding-left:10px">{row.smallName}</div>
|
|
@@ -186,10 +195,10 @@ export default {
|
|
|
render: (h, { row, column, index }) => {
|
|
|
return <div style="padding-left:10px">
|
|
|
<el-button type="text" onClick={() => {
|
|
|
- this.delProduct(row, index)
|
|
|
+ this.delProduct_wb(row, index)
|
|
|
}}>删除</el-button>
|
|
|
{this.isEditIndex == index && <el-button type="text" onClick={() => {
|
|
|
- this.eidtProduct(row, index)
|
|
|
+ this.eidtProduct_wb(row, index)
|
|
|
}}>确定</el-button>}
|
|
|
{this.isEditIndex == -1 && <el-button type="text" onClick={() => {
|
|
|
this.isEditIndex = index
|
|
@@ -203,7 +212,7 @@ export default {
|
|
|
})()
|
|
|
]
|
|
|
},
|
|
|
- product() {
|
|
|
+ product_wb() {
|
|
|
return [{
|
|
|
isShow: this.formOptions.orderProducts.isShow,
|
|
|
name: 'slot-component',
|
|
@@ -220,7 +229,7 @@ export default {
|
|
|
<div>
|
|
|
{this.formOptions.orderProducts.isEdit ? <div>
|
|
|
<el-button size="mini" type="primary" onClick={() => {
|
|
|
- this.appointVerify(this.getVfyKey(this.isEditIndex, false), (v) => {
|
|
|
+ this.appointVerify(this.getVfyKey_wb(this.isEditIndex, false), (v) => {
|
|
|
if (v) {
|
|
|
try {
|
|
|
this.orderInfo.orderProducts.map((item, index_) => {
|
|
@@ -246,6 +255,7 @@ export default {
|
|
|
"mainId": "",
|
|
|
"mainName": "",
|
|
|
"num": "",
|
|
|
+ "insideCode":"",
|
|
|
"orderBaseId": this.id || '',
|
|
|
"productId": "",
|
|
|
"productName": "",
|
|
@@ -259,7 +269,7 @@ export default {
|
|
|
}}>新增</el-button>
|
|
|
</div> : null}
|
|
|
<zj-table
|
|
|
- columns={this.productColumns}
|
|
|
+ columns={this.productColumns_wb}
|
|
|
table-data={this.orderInfo.orderProducts}
|
|
|
/>
|
|
|
</div>
|
|
@@ -268,29 +278,25 @@ export default {
|
|
|
}]
|
|
|
},
|
|
|
},
|
|
|
- created() {
|
|
|
- // 获取品牌
|
|
|
- getDataDictionary({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.dict_type", "compare": "=", "value": "BRAND" }] }).then(res => {
|
|
|
- this.orderBrands = res.data.records.map(item => ({
|
|
|
- value: item.dictCode,
|
|
|
- label: item.dictValue
|
|
|
- }))
|
|
|
- })
|
|
|
- // 获取产品大类小类
|
|
|
- getClassifyList({ type: 2, status: true }).then(res => {
|
|
|
- var classifyListLv2 = []
|
|
|
- this.classifyList = res.data.map(item => {
|
|
|
- var { children, ...data } = item
|
|
|
- classifyListLv2.push(...(children || []))
|
|
|
+ methods: {
|
|
|
+ huoquweiyi(value, label, ...keys) {
|
|
|
+ var obj = {}
|
|
|
+ this.productList_wb.map(item => {
|
|
|
+ obj[item[value]] = {
|
|
|
+ label: item[label]
|
|
|
+ }
|
|
|
+ for (var key of keys) {
|
|
|
+ obj[item[value]][key] = item[key]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return Object.keys(obj).map(value => {
|
|
|
return {
|
|
|
- ...data
|
|
|
+ value: value,
|
|
|
+ ...obj[value]
|
|
|
}
|
|
|
- });
|
|
|
- this.classifyListLv2 = classifyListLv2
|
|
|
- })
|
|
|
- },
|
|
|
- methods: {
|
|
|
- getVfyKey(index, bool = true) {
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getVfyKey_wb(index, bool = true) {
|
|
|
return [
|
|
|
...(() => {
|
|
|
if (bool) {
|
|
@@ -316,7 +322,7 @@ export default {
|
|
|
]
|
|
|
},
|
|
|
// 重新获取赋值
|
|
|
- getOrderBaseProduct() {
|
|
|
+ getOrderBaseProduct_wb() {
|
|
|
if (this.id) {
|
|
|
orderBaseProductList({
|
|
|
orderBaseId: this.id
|
|
@@ -325,7 +331,7 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- eidtProduct(row, index) {
|
|
|
+ eidtProduct_wb(row, index) {
|
|
|
try {
|
|
|
this.orderInfo.orderProducts.map((item, index_) => {
|
|
|
if (
|
|
@@ -339,12 +345,12 @@ export default {
|
|
|
this.$message.warning('产品机型重复')
|
|
|
return
|
|
|
}
|
|
|
- this.appointVerify(this.getVfyKey(this.isEditIndex), (v) => {
|
|
|
+ this.appointVerify(this.getVfyKey_wb(this.isEditIndex), (v) => {
|
|
|
if (v) {
|
|
|
if (this.id) {
|
|
|
[orderBaseProductAdd, orderBaseProductUpdate][row.id ? 1 : 0](row).then(res => {
|
|
|
this.isEditIndex = -1
|
|
|
- this.getOrderBaseProduct()
|
|
|
+ this.getOrderBaseProduct_wb()
|
|
|
this.getOrderBaseLogList()
|
|
|
})
|
|
|
} else {
|
|
@@ -353,13 +359,13 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- delProduct(row, index) {
|
|
|
- this.appointVerify(this.getVfyKey(this.isEditIndex), (v) => {
|
|
|
+ delProduct_wb(row, index) {
|
|
|
+ this.appointVerify(this.getVfyKey_wb(this.isEditIndex), (v) => {
|
|
|
if (v && this.id) {
|
|
|
orderBaseProductDelete({
|
|
|
orderProductId: row.id
|
|
|
}).then(res => {
|
|
|
- this.getOrderBaseProduct()
|
|
|
+ this.getOrderBaseProduct_wb()
|
|
|
this.getOrderBaseLogList()
|
|
|
})
|
|
|
} else {
|