This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/mixin/detailViewMixin.js

105 lines
3.4 KiB
JavaScript
Raw Normal View History

export default {
props: {},
data () {
return {
detailType: 'list',
detailViewRightObj: '',
2021-10-12 16:53:59 +08:00
detailViewLoading: false,
detailTimer: ''
}
},
created () {
this.detailType = localStorage.getItem('detail-view-' + this.tableId) || 'list'
},
methods: {
changeDetailType (flag) {
if (this.detailType === flag) {
return
}
this.$refs.dataList.bottomBox.showSubList = false
this.detailViewRightObj = ''
this.detailType = flag
2021-10-15 15:59:46 +08:00
let dataList = ''
localStorage.setItem('detail-view-' + this.tableId, this.detailType)
if (this.detailType === 'view') {
// modelIdsDetail
2021-10-15 15:59:46 +08:00
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)
})
})
}
} else {
2021-10-15 15:59:46 +08:00
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 = ''
}
}
setTimeout(() => {
this.detailViewLoading = false
this.$refs.clickSearch && this.$refs.clickSearch.needMore()
2021-10-15 15:59:46 +08:00
this.$refs[dataList].$refs.searchInput.sreach_num = 0
this.searchMsg.searchLabelList.forEach(searchLabel => {
if (this.searchLabel[searchLabel.label]) {
2021-10-15 15:59:46 +08:00
this.$refs[dataList].$refs.searchInput.select_list.push({
...searchLabel,
val: this.searchLabel[searchLabel.label]
})
2021-10-15 15:59:46 +08:00
this.$refs[dataList].$refs.searchInput.sreach_num++
this.$refs[dataList].$refs.searchInput.searchLabelList = this.$refs.dataList.$refs.searchInput.searchLabelList.filter(item => searchLabel.label !== item.label)
}
})
2021-10-15 15:59:46 +08:00
if (this.orderBy && this.$refs.dataTable.$refs.dataTable) {
2021-10-14 14:14:25 +08:00
const index = this.orderBy.indexOf('-')
let orderBy = ''
let orderType = ''
if (index !== -1) {
orderBy = this.orderBy.slice(index + 1)
orderType = 'descending'
} else {
orderBy = this.orderBy
orderType = 'ascending'
}
this.$refs.dataTable.$refs.dataTable.sort(orderBy, orderType)
2021-10-14 14:14:25 +08:00
}
}, 100)
},
detailViewRightShow (item) {
this.detailViewRightObj = item
},
orderDetail (order, orderType) {
if (orderType === 'ascending') {
this.orderBy = order
} else {
this.orderBy = '-' + order
}
this.getTableData()
}
}
}