解决初始化下拉选项的问题
This commit is contained in:
@@ -63,21 +63,23 @@ export default {
|
||||
this.tableData = res.data?.page?.records || []
|
||||
}
|
||||
})
|
||||
},
|
||||
getOptions() {
|
||||
const ops = {}
|
||||
this.tableData.forEach(e => {
|
||||
ops[e.groupCode] = e.groupName
|
||||
})
|
||||
return Object.entries(ops).map(([key, value]) => ({label: value, value: key}))
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
search: {
|
||||
deep: true, handler() {
|
||||
this.getTableData()
|
||||
immediate: true, deep: true, handler() {
|
||||
this.getTableData().then(() => {
|
||||
if (this.options.length == 0) this.options = this.getOptions()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTableData().then(() => {
|
||||
this.options = this.tableData.map(e => ({
|
||||
label: e.groupName, value: e.groupCode
|
||||
}))
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -108,7 +110,8 @@ export default {
|
||||
.AppGroupMonitorTable .dv-scroll-board, .AppGroupMonitorTable .scrollTable {
|
||||
height: calc(100% - 80px) !important;
|
||||
}
|
||||
.AppGroupMonitorTable .el-select{
|
||||
width: 140px!important;
|
||||
|
||||
.AppGroupMonitorTable .el-select {
|
||||
width: 140px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -71,15 +71,12 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
search: {
|
||||
deep: true, handler() {
|
||||
this.getTableData()
|
||||
immediate: true, deep: true, handler() {
|
||||
this.getTableData().then(() => {
|
||||
if (this.options.length == 0) this.options = this.getOptions()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTableData().then(() => {
|
||||
this.options = this.getOptions()
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user