|
|
|
@ -30,14 +30,14 @@ |
|
|
|
v-loading="typeLoading" |
|
|
|
style="width:100%" |
|
|
|
@row-click="selectDictType"> |
|
|
|
<el-table-column prop="dictName" label="字典名称" min-width="140" header-align="center" align="left" show-overflow-tooltip /> |
|
|
|
<!-- <el-table-column prop="dictType" label="字典类型" min-width="200" header-align="center" align="left" show-overflow-tooltip />--> |
|
|
|
<!-- <el-table-column prop="dictType" label="字典类型" min-width="120" header-align="center" align="left" show-overflow-tooltip />--> |
|
|
|
<el-table-column prop="dictName" label="字典名称" min-width="120" header-align="center" align="left" show-overflow-tooltip /> |
|
|
|
<el-table-column prop="status" label="状态" width="80" header-align="center" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
{{ scope.row.status === 'Y' ? '启用' : '停用' }} |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="操作" width="70" header-align="center" align="center"> |
|
|
|
<el-table-column label="操作" width="70" fixed="right" header-align="center" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-link |
|
|
|
v-if="canDeleteType(scope.row)" |
|
|
|
@ -110,7 +110,7 @@ |
|
|
|
<el-link style="cursor:pointer" @click="handleDisableData(scope.row)">停用</el-link> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column prop="dictLabel" label="字典标签" min-width="120" header-align="center" align="left" show-overflow-tooltip /> |
|
|
|
<el-table-column prop="dictLabel" label="字典标签" min-width="120" header-align="center" align="left" show-overflow-tooltip /> |
|
|
|
<el-table-column prop="dictValue" label="字典键值" min-width="120" header-align="center" align="left" show-overflow-tooltip /> |
|
|
|
<el-table-column label="作用范围" width="80" header-align="center" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
@ -167,7 +167,7 @@ |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="字典标签" prop="dictLabel"> |
|
|
|
<el-input v-model="dataForm.dictLabel" maxlength="255" /> |
|
|
|
<el-input v-model="dataForm.dictLabel" @blur="dictLabel()" maxlength="255" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="字典键值" prop="dictValue"> |
|
|
|
<el-input v-model="dataForm.dictValue" :disabled="dataEditMode" maxlength="255" /> |
|
|
|
@ -323,7 +323,7 @@ export default { |
|
|
|
status: this.typeSearch.status |
|
|
|
})).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
const rows = data.rows || [] |
|
|
|
const rows = this.normalizeTypeRows(data.rows || []) |
|
|
|
this.applyTypeListResult(rows, rows.length) |
|
|
|
} else { |
|
|
|
this.$message.error((data && data.msg) || '查询字典类型失败') |
|
|
|
@ -352,6 +352,85 @@ export default { |
|
|
|
this.dataTotal = 0 |
|
|
|
} |
|
|
|
}, |
|
|
|
dictLabel(){ |
|
|
|
this.dataForm.dictValue = JSON.parse(JSON.stringify(this.dataForm.dictLabel)); |
|
|
|
}, |
|
|
|
normalizeTypeRows (rows) { |
|
|
|
if (!Array.isArray(rows)) { |
|
|
|
return [] |
|
|
|
} |
|
|
|
return rows.map(row => this.normalizeTypeRow(row)) |
|
|
|
}, |
|
|
|
normalizeTypeRow (row) { |
|
|
|
const normalized = { ...(row || {}) } |
|
|
|
normalized.dictId = normalized.dictId != null ? normalized.dictId : normalized.dict_id |
|
|
|
normalized.dictType = this.firstText( |
|
|
|
normalized.dictType, |
|
|
|
normalized.dict_type |
|
|
|
) |
|
|
|
normalized.status = this.normalizeStatus( |
|
|
|
this.firstText(normalized.status, normalized.STATUS, normalized.active) |
|
|
|
) |
|
|
|
normalized.createBy = this.firstText(normalized.createBy, normalized.create_by) |
|
|
|
normalized.site = this.firstText(normalized.site, normalized.SITE) |
|
|
|
normalized.remark = this.firstText(normalized.remark) |
|
|
|
normalized.dictName = this.resolveTypeDisplayName(normalized) |
|
|
|
return normalized |
|
|
|
}, |
|
|
|
resolveTypeDisplayName (row) { |
|
|
|
const direct = this.firstText(row && row.dictName, row && row.dict_name) |
|
|
|
if (direct && !this.isStatusText(direct)) { |
|
|
|
return direct |
|
|
|
} |
|
|
|
const remark = this.firstText(row && row.remark) |
|
|
|
if (remark) { |
|
|
|
const sep = remark.indexOf('-') |
|
|
|
if (sep > 0) { |
|
|
|
const prefix = remark.substring(0, sep).trim() |
|
|
|
if (prefix && !this.isStatusText(prefix)) { |
|
|
|
return prefix |
|
|
|
} |
|
|
|
} |
|
|
|
if (!this.isStatusText(remark)) { |
|
|
|
return remark |
|
|
|
} |
|
|
|
} |
|
|
|
return this.firstText(row && row.dictType, row && row.dict_type) |
|
|
|
}, |
|
|
|
normalizeStatus (raw) { |
|
|
|
const text = this.firstText(raw) |
|
|
|
if (!text) { |
|
|
|
return '' |
|
|
|
} |
|
|
|
const upper = text.toUpperCase() |
|
|
|
if (upper === 'Y' || text === '启用') { |
|
|
|
return 'Y' |
|
|
|
} |
|
|
|
if (upper === 'N' || text === '停用') { |
|
|
|
return 'N' |
|
|
|
} |
|
|
|
return text |
|
|
|
}, |
|
|
|
isStatusText (text) { |
|
|
|
const val = this.firstText(text) |
|
|
|
if (!val) { |
|
|
|
return false |
|
|
|
} |
|
|
|
const upper = val.toUpperCase() |
|
|
|
return upper === 'Y' || upper === 'N' || val === '启用' || val === '停用' |
|
|
|
}, |
|
|
|
firstText (...vals) { |
|
|
|
for (const val of vals) { |
|
|
|
if (val === null || val === undefined) { |
|
|
|
continue |
|
|
|
} |
|
|
|
const text = String(val).trim() |
|
|
|
if (text) { |
|
|
|
return text |
|
|
|
} |
|
|
|
} |
|
|
|
return '' |
|
|
|
}, |
|
|
|
selectDictType (row) { |
|
|
|
if (!row || !row.dictType) return |
|
|
|
this.currentType = { ...row } |
|
|
|
|