diff --git a/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue b/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue index 9f5457e9f..6ab782cdf 100644 --- a/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue +++ b/nezha-fronted/src/components/common/detailView/detailViewTopSearch.vue @@ -53,8 +53,8 @@
- - {{item3.name}} + + {{item3.name}} {{item4.name}} diff --git a/nezha-fronted/src/components/common/detailView/nzDetailView.vue b/nezha-fronted/src/components/common/detailView/nzDetailView.vue index d340f14cc..c89550765 100644 --- a/nezha-fronted/src/components/common/detailView/nzDetailView.vue +++ b/nezha-fronted/src/components/common/detailView/nzDetailView.vue @@ -39,14 +39,14 @@
- - - - - - - - +
diff --git a/nezha-fronted/src/components/common/labelFilter/clickSearch.vue b/nezha-fronted/src/components/common/labelFilter/clickSearch.vue index 41d0acb1f..cd1b9af5b 100644 --- a/nezha-fronted/src/components/common/labelFilter/clickSearch.vue +++ b/nezha-fronted/src/components/common/labelFilter/clickSearch.vue @@ -24,9 +24,11 @@ v-show="j < data.index || data.showMore" :key="j" :selectValue="selectValue[data.key]" + :type="data.key" :ref="`${type}_${item.id}_cascader`" :collapse-tags="true" :item="item" + @resize="(value) => resize(value, type, item, data.key)" @blur="casFocus" @change="(value) => casChange(value, type, item, data.key)" @focus="casFocus" @@ -236,13 +238,33 @@ export default { const inputWidth = tagWidth + this.widthConstant.dropdownCheckBox.moreNumberWidth + this.widthConstant.dropdownCheckBox.arrowDownWidth return { tagWidth, inputWidth, width: labelWidth + inputWidth + this.widthConstant.dropdownCheckBox.boxMargin } }, + resize (value, type, item) { + const oldInputWidth = item.inputWidth + if (type) { + if (value.length === 0) { // 回到初始宽度 + item.width = item.originalWidth + item.inputWidth = this.widthConstant.dropdownCheckBox.inputOriginalWidth + } else { + const showTag = item.children.find(c => c.id == value[0]) // 展示的tag + const { tagWidth, inputWidth, width } = this.computeCascWidth(this.computeDistance(showTag.name, 12), item.labelWidth) + item.width = width + item.inputWidth = inputWidth + } + } + if (item.inputWidth !== oldInputWidth) { + this.$nextTick(() => { + this.$refs[`${type}_${item.id}_cascader`][0].$el.querySelector('.el-input__inner').style.width = `${item.inputWidth}px` + this.needMore(type, item, true) + }) + } + }, setEachCascWidth (value, type, item) { if (type) { if (value.length === 0) { // 回到初始宽度 item.width = item.originalWidth item.inputWidth = this.widthConstant.dropdownCheckBox.inputOriginalWidth } else { - const showTag = item.children.find(c => c.id === value[0][0]) // 展示的tag + const showTag = item.children.find(c => c.id == value[0]) // 展示的tag const { tagWidth, inputWidth, width } = this.computeCascWidth(this.computeDistance(showTag.name, 12), item.labelWidth) item.width = width item.inputWidth = inputWidth diff --git a/nezha-fronted/src/components/common/labelFilter/dropdown.vue b/nezha-fronted/src/components/common/labelFilter/dropdown.vue index 98a4b3acd..2e8bccd69 100644 --- a/nezha-fronted/src/components/common/labelFilter/dropdown.vue +++ b/nezha-fronted/src/components/common/labelFilter/dropdown.vue @@ -10,7 +10,7 @@ v-model="cascaderData" :collapse-tags="collapseTags" :options="item.children" - :props="{ multiple: true, label: 'name', value: 'id' }" + :props="{ multiple: true, label: 'name', value: 'id', checkStrictly: true }" placeholder="" popper-class="click-search-dropdown" size="mini" @@ -31,13 +31,31 @@ export default { type: Boolean, default: false }, - selectValue: {} + selectValue: {}, + type: {} }, watch: { selectValue: { immediate: true, handler (n) { console.log(n) + this.cascaderData = [] + if (n && this.type !== 'fields') { + n.forEach(item => { + if (this.item.children.find(children => children.id == item)) { + this.cascaderData.push([item]) + this.$emit('resize', [item]) + } + }) + } else if (n && this.type === 'fields') { + const obj = JSON.parse(n) + if (obj[this.item.id]) { + obj[this.item.id].forEach(item => { + this.cascaderData.push([item]) + this.$emit('resize', [item]) + }) + } + } } } }, diff --git a/nezha-fronted/src/components/common/mixin/detailViewMixin.js b/nezha-fronted/src/components/common/mixin/detailViewMixin.js index 17c566ce1..64170d70f 100644 --- a/nezha-fronted/src/components/common/mixin/detailViewMixin.js +++ b/nezha-fronted/src/components/common/mixin/detailViewMixin.js @@ -18,28 +18,49 @@ export default { } this.detailType = flag localStorage.setItem('detail-view-' + this.tableId, this.detailType) + if (this.detailType === 'view') { + // modelIdsDetail + 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) { + console.log(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 = '' + } + } this.pageObj.pageNo = 1 setTimeout(() => { this.detailViewLoading = false this.$refs.clickSearch && this.$refs.clickSearch.needMore() }, 100) }, - searchDetailTop () { - if (!this.detailTimer) { - this.detailTimer = setTimeout(() => { - this.getTableData() - clearTimeout(this.detailTimer) - this.detailTimer = '' - }, 1000) - } else { - clearTimeout(this.detailTimer) - this.detailTimer = setTimeout(() => { - this.getTableData() - clearTimeout(this.detailTimer) - this.detailTimer = '' - }, 1000) - } - }, detailViewRightShow (item) { this.detailViewRightObj = item } diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index 95cec0d74..cc43a572d 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -2,7 +2,7 @@
{ - if (typeof obj[key] === 'string') { - this.searchCheckBox[key] = obj[key] ? obj[key] : null + const params = JSON.parse(JSON.stringify(obj)) + if (this.detailType === 'view') { + const obj = {} + params.modelIds = params.modelIdsDetail.map(item => item.split('-')[1]) + params.fieldsDetail.forEach(item => { + const arr = item.split('-') + if (obj[arr[0]]) { + obj[arr[0]].push(arr[1]) + } else { + obj[arr[0]] = [arr[1]] + } + }) + params.fields = JSON.stringify(obj) + if (params.fields === '{}') { + params.fields = '' + } + delete params.modelIdsDetail + delete params.fieldsDetail + } + Object.keys(params).forEach(key => { + if (typeof params[key] === 'string') { + this.searchCheckBox[key] = params[key] ? params[key] : null } else { - obj[key] && obj[key].length > 0 ? this.searchCheckBox[key] = obj[key].join(',') : this.searchCheckBox[key] = null + params[key] && params[key].length > 0 ? this.searchCheckBox[key] = params[key].join(',') : this.searchCheckBox[key] = null } }) - this.getTableData() + if (!this.timer) { + this.timer = setTimeout(() => { + this.getTableData() + clearTimeout(this.timer) + this.timer = '' + }, 1000) + } else { + clearTimeout(this.timer) + this.timer = setTimeout(() => { + this.getTableData() + clearTimeout(this.timer) + this.timer = '' + }, 1000) + } }, getDcData () { return new Promise(resolve => {