feat:endpoint 复用详细视图

This commit is contained in:
zhangyu
2021-10-19 10:55:54 +08:00
parent c4183fddbf
commit 0d6ca0015a
4 changed files with 397 additions and 40 deletions

View File

@@ -22,41 +22,14 @@ export default {
let dataList = ''
localStorage.setItem('detail-view-' + this.tableId, this.detailType)
if (this.detailType === 'view') {
// modelIdsDetail
dataList = 'detailList'
this.selectValue.modelIdsDetail = []
this.selectValue.modelIds.forEach(modelId => {
this.titleSearchList.model.children.forEach(model => {
const brand = model.children.find(children => modelId == children.id)
if (brand) {
this.selectValue.modelIdsDetail.push(brand.brandId + '-' + modelId)
}
})
})
this.selectValue.fieldsDetail = []
if (this.selectValue.fields) {
const obj = JSON.parse(this.selectValue.fields)
Object.keys(obj).forEach(key => {
obj[key].forEach(item => {
this.selectValue.fieldsDetail.push(key + '-' + item)
})
})
if (this.from === this.fromRoute.asset) {
this.setAsset(true)
}
} else {
dataList = 'dataList'
const obj = {}
this.selectValue.modelIds = this.selectValue.modelIdsDetail.map(item => item.split('-')[1])
this.selectValue.fieldsDetail.forEach(item => {
const arr = item.split('-')
if (obj[arr[0]]) {
obj[arr[0]].push(arr[1])
} else {
obj[arr[0]] = [arr[1]]
}
})
this.selectValue.fields = JSON.stringify(obj)
if (this.selectValue.fields === '{}') {
this.selectValue.fields = ''
if (this.from === this.fromRoute.asset) {
this.setAsset(false)
}
}
setTimeout(() => {
@@ -99,6 +72,43 @@ export default {
this.orderBy = '-' + order
}
this.getTableData()
},
setAsset (flag) {
if (flag) {
this.selectValue.modelIdsDetail = []
this.selectValue.modelIds.forEach(modelId => {
this.titleSearchList.model.children.forEach(model => {
const brand = model.children.find(children => modelId == children.id)
if (brand) {
this.selectValue.modelIdsDetail.push(brand.brandId + '-' + modelId)
}
})
})
this.selectValue.fieldsDetail = []
if (this.selectValue.fields) {
const obj = JSON.parse(this.selectValue.fields)
Object.keys(obj).forEach(key => {
obj[key].forEach(item => {
this.selectValue.fieldsDetail.push(key + '-' + item)
})
})
}
} else {
const obj = {}
this.selectValue.modelIds = this.selectValue.modelIdsDetail.map(item => item.split('-')[1])
this.selectValue.fieldsDetail.forEach(item => {
const arr = item.split('-')
if (obj[arr[0]]) {
obj[arr[0]].push(arr[1])
} else {
obj[arr[0]] = [arr[1]]
}
})
this.selectValue.fields = JSON.stringify(obj)
if (this.selectValue.fields === '{}') {
this.selectValue.fields = ''
}
}
}
}
}