refactor(dict): 优化字典数据查询逻辑和接口
- 移除不必要的 ISysDictTypeService 依赖,简化 SysDictDataController - 新增 selectDictDataByTypeRealtime 方法,支持实时查询字典数据,避免缓存问题 - 更新 SysDictDataController 中的字典数据查询逻辑,使用新方法 - 在 SysDictTypeController 中添加按字典类型编码精确查询的接口 - 更新前端组件以支持新的字典查询接口,优化字典选择器的加载逻辑
This commit is contained in:
@@ -23,14 +23,14 @@
|
||||
<!-- 左侧段分组 -->
|
||||
<div class="left-tree">
|
||||
<div
|
||||
:class="['tree-item', { active: activeSegment === '' }]"
|
||||
@click="activeSegment = ''"
|
||||
:class="['tree-item', { active: activeSegmentType === '' }]"
|
||||
@click="selectSegmentType('')"
|
||||
>全部</div>
|
||||
<div
|
||||
v-for="seg in segmentOptions"
|
||||
:key="seg.value"
|
||||
:class="['tree-item', { active: activeSegment === seg.value }]"
|
||||
@click="activeSegment = seg.value"
|
||||
v-for="seg in segmentTypeTabOptions"
|
||||
:key="String(seg.value)"
|
||||
:class="['tree-item', { active: String(activeSegmentType) === String(seg.value) }]"
|
||||
@click="selectSegmentType(seg.value)"
|
||||
>
|
||||
<span class="tree-arrow">›</span> {{ seg.label }}
|
||||
</div>
|
||||
@@ -40,6 +40,24 @@
|
||||
<div class="right-content">
|
||||
<!-- 搜索栏 -->
|
||||
<div class="search-bar">
|
||||
<template v-if="activeSegmentType !== '' && activeSegmentType !== undefined && activeSegmentType !== null">
|
||||
<span class="search-label">段名称:</span>
|
||||
<el-select
|
||||
v-model="activeSegmentName"
|
||||
placeholder="请选择"
|
||||
size="small"
|
||||
clearable
|
||||
style="width:180px"
|
||||
@change="onSegmentNameFilterChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="opt in segmentNameFilterOptions"
|
||||
:key="String(opt.value) + '-' + opt.label"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
<span class="search-label">点位名称:</span>
|
||||
<el-input
|
||||
v-model="filterName"
|
||||
@@ -116,7 +134,7 @@
|
||||
<el-form ref="planFormRef" :model="planForm" :rules="planRules" label-width="90px" size="small">
|
||||
<el-form-item label="段类型" prop="segmentType">
|
||||
<el-select v-model="planForm.segmentType" style="width:100%">
|
||||
<el-option v-for="s in segmentOptions" :key="s.value" :label="s.label" :value="s.value" />
|
||||
<el-option v-for="s in segmentFormOptionsForDialog" :key="String(s.value)" :label="s.label" :value="s.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="段名称" prop="segmentName">
|
||||
@@ -193,7 +211,8 @@
|
||||
import { listProcessPlan, addProcessPlan, updateProcessPlan, delProcessPlan } from '@/api/wms/processPlan'
|
||||
import { listProcessPlanParam, addProcessPlanParam, updateProcessPlanParam, delProcessPlanParam } from '@/api/wms/processPlanParam'
|
||||
|
||||
const SEGMENTS = [
|
||||
/** 表单内可选段类型(新建/编辑仍支持全部枚举) */
|
||||
const SEGMENT_FORM_OPTIONS = [
|
||||
{ label: '入口段', value: 'INLET' },
|
||||
{ label: '工艺段', value: 'PROCESS' },
|
||||
{ label: '出口段', value: 'OUTLET' }
|
||||
@@ -208,10 +227,12 @@ export default {
|
||||
versionCode: '',
|
||||
specId: undefined,
|
||||
configMode: 'configurable',
|
||||
activeSegment: '',
|
||||
/** 左侧:段类型;空=全部 */
|
||||
activeSegmentType: '',
|
||||
/** 工具栏下拉:当前段类型下的段名称;空字符串=该段类型下全部名称;__EMPTY__=未命名 */
|
||||
activeSegmentName: '',
|
||||
filterName: '',
|
||||
appliedFilterName: '',
|
||||
segmentOptions: SEGMENTS,
|
||||
planList: [],
|
||||
planLoading: false,
|
||||
selectedPlan: null,
|
||||
@@ -237,16 +258,125 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
/**
|
||||
* 左侧 Tab:仅从点位数据汇总「段类型」,展示用语义名称(入口段/工艺段/出口段)
|
||||
*/
|
||||
segmentTypeTabOptions() {
|
||||
const orderIdx = {}
|
||||
SEGMENT_FORM_OPTIONS.forEach((s, i) => { orderIdx[String(s.value)] = i })
|
||||
const seen = new Set()
|
||||
const list = []
|
||||
for (const plan of this.planList) {
|
||||
const t = plan.segmentType
|
||||
if (t === undefined || t === null || String(t).trim() === '') continue
|
||||
const key = String(t)
|
||||
if (seen.has(key)) continue
|
||||
seen.add(key)
|
||||
list.push({
|
||||
value: plan.segmentType,
|
||||
label: this.segmentTypeDisplayLabel(t)
|
||||
})
|
||||
}
|
||||
list.sort((a, b) => {
|
||||
const ia = orderIdx[String(a.value)]
|
||||
const ib = orderIdx[String(b.value)]
|
||||
const aKnown = ia !== undefined
|
||||
const bKnown = ib !== undefined
|
||||
if (aKnown && bKnown) return ia - ib
|
||||
if (aKnown) return -1
|
||||
if (bKnown) return 1
|
||||
return String(a.label).localeCompare(String(b.label), 'zh-CN')
|
||||
})
|
||||
return list
|
||||
},
|
||||
/** 当前选中段类型下,出现于数据中的段名称下拉项 */
|
||||
segmentNameFilterOptions() {
|
||||
const t = this.activeSegmentType
|
||||
if (t === '' || t === undefined || t === null) return [{ value: '', label: '全部' }]
|
||||
const names = new Set()
|
||||
let hasEmpty = false
|
||||
for (const p of this.planList) {
|
||||
if (String(p.segmentType) !== String(t)) continue
|
||||
const sn = p.segmentName != null ? String(p.segmentName).trim() : ''
|
||||
if (!sn) hasEmpty = true
|
||||
else names.add(sn)
|
||||
}
|
||||
const sorted = [...names].sort((a, b) => a.localeCompare(b, 'zh-CN'))
|
||||
const opts = [{ value: '', label: '全部' }]
|
||||
if (hasEmpty) opts.push({ value: '__EMPTY__', label: '(未命名)' })
|
||||
sorted.forEach(n => opts.push({ value: n, label: n }))
|
||||
return opts
|
||||
},
|
||||
/** 新建/编辑下拉:标准三项 + 当前方案中已出现的其它段类型 */
|
||||
segmentFormOptionsForDialog() {
|
||||
const seen = new Set(SEGMENT_FORM_OPTIONS.map(s => String(s.value)))
|
||||
const extra = []
|
||||
for (const plan of this.planList) {
|
||||
const v = plan.segmentType
|
||||
if (v === undefined || v === null || String(v).trim() === '') continue
|
||||
const key = String(v)
|
||||
if (seen.has(key)) continue
|
||||
seen.add(key)
|
||||
const name = plan.segmentName != null ? String(plan.segmentName).trim() : ''
|
||||
extra.push({
|
||||
value: plan.segmentType,
|
||||
label: name || this.segmentTypeDisplayLabel(v)
|
||||
})
|
||||
}
|
||||
extra.sort((a, b) => String(a.label).localeCompare(String(b.label), 'zh-CN'))
|
||||
return [...SEGMENT_FORM_OPTIONS, ...extra]
|
||||
},
|
||||
filteredPlans() {
|
||||
const type = this.activeSegmentType
|
||||
const sub = this.activeSegmentName
|
||||
return this.planList.filter(p => {
|
||||
const segOk = !this.activeSegment || p.segmentType === this.activeSegment
|
||||
const typeOk =
|
||||
type === '' || type === undefined || type === null
|
||||
? true
|
||||
: String(p.segmentType) === String(type)
|
||||
let nameOkSeg = true
|
||||
if (typeOk && type !== '' && type !== undefined && type !== null) {
|
||||
if (sub === '' || sub === undefined || sub === null) {
|
||||
nameOkSeg = true
|
||||
} else if (sub === '__EMPTY__') {
|
||||
const sn = p.segmentName != null ? String(p.segmentName).trim() : ''
|
||||
nameOkSeg = !sn
|
||||
} else {
|
||||
const sn = p.segmentName != null ? String(p.segmentName).trim() : ''
|
||||
nameOkSeg = sn === String(sub).trim()
|
||||
}
|
||||
}
|
||||
const nameOk = !this.appliedFilterName || (p.pointName || '').includes(this.appliedFilterName)
|
||||
return segOk && nameOk
|
||||
return typeOk && nameOkSeg && nameOk
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
$route: { immediate: true, handler() { this.syncFromRoute() } }
|
||||
$route: { immediate: true, handler() { this.syncFromRoute() } },
|
||||
segmentTypeTabOptions: {
|
||||
handler() {
|
||||
const a = this.activeSegmentType
|
||||
if (a === '' || a === undefined || a === null) return
|
||||
const still = this.segmentTypeTabOptions.some(s => String(s.value) === String(a))
|
||||
if (!still) {
|
||||
this.activeSegmentType = ''
|
||||
this.activeSegmentName = ''
|
||||
}
|
||||
}
|
||||
},
|
||||
planList: {
|
||||
handler() {
|
||||
this.$nextTick(() => {
|
||||
if (this.activeSegmentType === '' || this.activeSegmentType === undefined || this.activeSegmentType === null) return
|
||||
const allowed = this.segmentNameFilterOptions.map(o => o.value)
|
||||
const cur = this.activeSegmentName
|
||||
if (cur !== '' && cur !== undefined && cur !== null && !allowed.includes(cur)) {
|
||||
this.activeSegmentName = ''
|
||||
}
|
||||
})
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
syncFromRoute() {
|
||||
@@ -257,9 +387,22 @@ export default {
|
||||
if (this.versionId) this.loadPlans()
|
||||
},
|
||||
goBack() { this.$router.go(-1) },
|
||||
selectSegmentType(val) {
|
||||
this.activeSegmentType = val === undefined || val === null ? '' : val
|
||||
this.activeSegmentName = ''
|
||||
},
|
||||
onSegmentNameFilterChange() {
|
||||
const allowed = this.segmentNameFilterOptions.map(o => o.value)
|
||||
if (!allowed.includes(this.activeSegmentName)) {
|
||||
this.activeSegmentName = ''
|
||||
}
|
||||
},
|
||||
segmentTypeDisplayLabel(segmentType) {
|
||||
const hit = SEGMENT_FORM_OPTIONS.find(s => String(s.value) === String(segmentType))
|
||||
return hit ? hit.label : (segmentType != null ? String(segmentType) : '')
|
||||
},
|
||||
segLabel(val) {
|
||||
const hit = SEGMENTS.find(s => s.value === val)
|
||||
return hit ? hit.label : val || ''
|
||||
return this.segmentTypeDisplayLabel(val)
|
||||
},
|
||||
loadPlans() {
|
||||
this.planLoading = true
|
||||
@@ -281,7 +424,11 @@ export default {
|
||||
this.loadParams(row.planId)
|
||||
},
|
||||
applyFilter() { this.appliedFilterName = this.filterName },
|
||||
resetFilter() { this.filterName = ''; this.appliedFilterName = '' },
|
||||
resetFilter() {
|
||||
this.filterName = ''
|
||||
this.appliedFilterName = ''
|
||||
this.activeSegmentName = ''
|
||||
},
|
||||
openPlanDialog(row) {
|
||||
this.planForm = row
|
||||
? { ...row }
|
||||
|
||||
Reference in New Issue
Block a user