Commit b4734208 authored by wangxl's avatar wangxl

3333

parent ace7feac
...@@ -63,6 +63,14 @@ export default { ...@@ -63,6 +63,14 @@ export default {
components: { components: {
talentView, audit, batchAudit talentView, audit, batchAudit
}, },
// dicts: ['PROJECT_STATUS', 'PARAMETER_TYPE', 'STATUS_TYPE'],
// mounted () {
// // 监听字典数据加载完成事件
// this.$on('dictReady', () => {
// console.log('字典数据加载完成')
// console.log('项目状态字典:', this.dict.projectStatus)
// })
// },
data () { data () {
return { return {
selectedRowKeys: [], selectedRowKeys: [],
......
import Vue from 'vue' import Vue from 'vue'
import api from '@/api' import api from '@/api'
import DictTypes from './DictTypes'
export default class Dict { export default class Dict {
constructor(dict) { constructor(dict) {
...@@ -11,28 +12,29 @@ export default class Dict { ...@@ -11,28 +12,29 @@ export default class Dict {
* @param {Array} names 字典类型名称数组 * @param {Array} names 字典类型名称数组
* @param {Function} callback 回调函数 * @param {Function} callback 回调函数
*/ */
async init(names, callback) { async init (names, callback) {
if (names === undefined || names === null) { if (names === undefined || names === null) {
throw new Error('need Dict names') throw new Error('need Dict names')
} }
const promises = names.map(n => { const promises = names.map(n => {
let param = DictTypes[n]
if (param === undefined || param === null) {
throw new Error('need Dict names')
}
// 初始化字典数据结构 // 初始化字典数据结构
Vue.set(this.dict.dictLabel, n, {}) Vue.set(this.dict.dictLabel, n, {})
Vue.set(this.dict, n, []) Vue.set(this.dict, n, [])
// 获取字典数据 // 获取字典数据
return api.parameter.getDicts(n).then(res => { return api.parameter.getDicts(n).then(res => {
if (res && res.data) { if (res && res.data) {
// 更新字典数据 // 更新字典数据
this.dict[n].splice(0, 0, ...res.data) this.dict[n].splice(0, 0, ...res.data)
// 构建字典标签映射 // 构建字典标签映射
res.data.forEach(d => { res.data.forEach(d => {
Vue.set(this.dict.dictLabel[n], d.key, d.title) Vue.set(this.dict.dictLabel[n], d.key, d.title)
}) })
} }
return res return res
}).catch(error => { }).catch(error => {
console.error(`获取字典数据失败,类型: ${n}`, error) console.error(`获取字典数据失败,类型: ${n}`, error)
return null return null
...@@ -41,7 +43,7 @@ export default class Dict { ...@@ -41,7 +43,7 @@ export default class Dict {
// 等待所有字典数据加载完成 // 等待所有字典数据加载完成
await Promise.all(promises) await Promise.all(promises)
// 执行回调函数 // 执行回调函数
if (callback && typeof callback === 'function') { if (callback && typeof callback === 'function') {
callback() callback()
...@@ -53,7 +55,7 @@ export default class Dict { ...@@ -53,7 +55,7 @@ export default class Dict {
* @param {string} name 字典类型名称 * @param {string} name 字典类型名称
* @returns {Array} 字典数据数组 * @returns {Array} 字典数据数组
*/ */
getDict(name) { getDict (name) {
return this.dict[name] || [] return this.dict[name] || []
} }
...@@ -63,7 +65,7 @@ export default class Dict { ...@@ -63,7 +65,7 @@ export default class Dict {
* @param {string|number} value 字典值 * @param {string|number} value 字典值
* @returns {string} 字典标签 * @returns {string} 字典标签
*/ */
getDictLabel(name, value) { getDictLabel (name, value) {
return this.dict.dictLabel[name]?.[value] || '' return this.dict.dictLabel[name]?.[value] || ''
} }
...@@ -72,7 +74,7 @@ export default class Dict { ...@@ -72,7 +74,7 @@ export default class Dict {
* @param {string} name 字典类型名称 * @param {string} name 字典类型名称
* @returns {Promise} 刷新结果 * @returns {Promise} 刷新结果
*/ */
async refreshDict(name) { async refreshDict (name) {
try { try {
Vue.set(this.dict.dictLabel, name, {}) Vue.set(this.dict.dictLabel, name, {})
Vue.set(this.dict, name, []) Vue.set(this.dict, name, [])
...@@ -80,7 +82,7 @@ export default class Dict { ...@@ -80,7 +82,7 @@ export default class Dict {
const res = await api.parameter.getDicts(name) const res = await api.parameter.getDicts(name)
if (res && res.data) { if (res && res.data) {
this.dict[name].splice(0, 0, ...res.data) this.dict[name].splice(0, 0, ...res.data)
res.data.forEach(d => { res.data.forEach(d => {
Vue.set(this.dict.dictLabel[name], d.key, d.title) Vue.set(this.dict.dictLabel[name], d.key, d.title)
}) })
...@@ -97,7 +99,7 @@ export default class Dict { ...@@ -97,7 +99,7 @@ export default class Dict {
* @param {Array} names 字典类型名称数组 * @param {Array} names 字典类型名称数组
* @returns {Promise} 刷新结果 * @returns {Promise} 刷新结果
*/ */
async refreshDicts(names) { async refreshDicts (names) {
const promises = names.map(name => this.refreshDict(name)) const promises = names.map(name => this.refreshDict(name))
return Promise.all(promises) return Promise.all(promises)
} }
...@@ -106,7 +108,7 @@ export default class Dict { ...@@ -106,7 +108,7 @@ export default class Dict {
* 清除字典缓存 * 清除字典缓存
* @param {string} name 字典类型名称 * @param {string} name 字典类型名称
*/ */
clearDict(name) { clearDict (name) {
Vue.set(this.dict.dictLabel, name, {}) Vue.set(this.dict.dictLabel, name, {})
Vue.set(this.dict, name, []) Vue.set(this.dict, name, [])
} }
...@@ -114,7 +116,7 @@ export default class Dict { ...@@ -114,7 +116,7 @@ export default class Dict {
/** /**
* 清除所有字典缓存 * 清除所有字典缓存
*/ */
clearAllDicts() { clearAllDicts () {
Object.keys(this.dict).forEach(key => { Object.keys(this.dict).forEach(key => {
if (key !== 'dictLabel') { if (key !== 'dictLabel') {
Vue.set(this.dict, key, []) Vue.set(this.dict, key, [])
......
...@@ -18,38 +18,6 @@ export default { ...@@ -18,38 +18,6 @@ export default {
PROJECT_STATUS: 10, // 项目状态 PROJECT_STATUS: 10, // 项目状态
PROJECT_CATEGORY: 11, // 项目分类 PROJECT_CATEGORY: 11, // 项目分类
PROJECT_LEVEL: 12, // 项目级别 PROJECT_LEVEL: 12, // 项目级别
PROJECT_PRIORITY: 13, // 项目优先级
// 任务相关
TASK_STATUS: 20, // 任务状态
TASK_TYPE: 21, // 任务类型
TASK_PRIORITY: 22, // 任务优先级
// 审核相关
AUDIT_STATUS: 30, // 审核状态
AUDIT_TYPE: 31, // 审核类型
AUDIT_RESULT: 32, // 审核结果
// 评估相关
EVALUATION_STATUS: 40, // 评估状态
EVALUATION_TYPE: 41, // 评估类型
EVALUATION_LEVEL: 42, // 评估等级
// 专家相关
EXPERT_SPECIALTY: 50, // 专家专业
EXPERT_LEVEL: 51, // 专家级别
EXPERT_STATUS: 52, // 专家状态
// 系统相关
SYSTEM_PARAMETER: 60, // 系统参数
SYSTEM_CONFIG: 61, // 系统配置
SYSTEM_STATUS: 62, // 系统状态
// 其他
COMMON_STATUS: 100, // 通用状态
COMMON_TYPE: 101, // 通用类型
COMMON_LEVEL: 102, // 通用等级
COMMON_PRIORITY: 103, // 通用优先级
} }
/** /**
...@@ -66,26 +34,4 @@ export const DictTypeLabels = { ...@@ -66,26 +34,4 @@ export const DictTypeLabels = {
8: '审核类型', 8: '审核类型',
9: '状态类型', 9: '状态类型',
10: '项目状态', 10: '项目状态',
11: '项目分类',
12: '项目级别',
13: '项目优先级',
20: '任务状态',
21: '任务类型',
22: '任务优先级',
30: '审核状态',
31: '审核类型',
32: '审核结果',
40: '评估状态',
41: '评估类型',
42: '评估等级',
50: '专家专业',
51: '专家级别',
52: '专家状态',
60: '系统参数',
61: '系统配置',
62: '系统状态',
100: '通用状态',
101: '通用类型',
102: '通用等级',
103: '通用优先级'
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment