Commit 88a97c3b authored by wangxl's avatar wangxl

888

parent acdcbe9d
......@@ -913,10 +913,6 @@ export default {
getArrayListByType (params) {
return fetch(`/v1/science-admin/system-parameter/getArrayListByType`, params)
},
// 根据字典类型查询字典数据信息
getDicts (dictType) {
return fetch(`/v1/science-admin/system-parameter/getArrayListByType`, { typeId: dictType })
},
getTreeListByType (params) {
return fetch(`/v1/science-admin/system-parameter/getTreeListByType`, params)
},
......
......@@ -67,14 +67,14 @@ export default {
components: {
talentView, audit, batchAudit, paraSelect
},
// dicts: ['PROJECT_STATUS', 'PARAMETER_TYPE', 'STATUS_TYPE'],
// mounted () {
// // 监听字典数据加载完成事件
// this.$on('dictReady', () => {
// console.log('字典数据加载完成')
// console.log('项目状态字典:', this.dict.projectStatus)
// })
// },
dicts: ['title'],
mounted () {
// 监听字典数据加载完成事件
this.$on('dictReady', () => {
console.log('字典数据加载完成')
console.log('项目状态字典:', this.dict.title, this.dict.dictLabel.title)
})
},
data () {
return {
selectedRowKeys: [],
......
<template>
<div style=" width:auto; display:inline-block !important; display:inline;z-index:100">
<a-select :style="{width: width + 'px'}" v-model="parSelected" @change="parentChange($event)" :key="0">
<a-select-option v-for="item in parArray" :key="item.key" :value="item.key" select>{{ item.title }}</a-select-option>
</a-select>
<a-select :style="{width: width + 'px'}" v-model="selected" @change="childChange($event)" :key="1">
<a-select-option v-for="item in chArray" :key="item.key" :value="item.key" select>{{ item.title }}</a-select-option>
</a-select>
</div>
</template>
<script>
export default {
//用法 <para-multi-select v-model="formData.projClass" :typeId="52" />
name: "paraMultiSelect",
data () {
return {
parArray: [],
chArray: [],
parSelected: '',
selected: '',
defaultAll: {
title: "--请选择" + this.title + "--",
key: "",
children: [{
title: "--请先选择上级-",
key: "",
}]
},
loading: false
};
},
props: {
value: {
type: String,
default () {
return null
}
},
typeId: {
type: Number,
default () {
return 0
}
},
width: {
type: Number,
default () {
return 180
}
},
title: {
type: String,
default () {
return ''
}
},
},
created () {
this.load(this.value)
},
methods: {
async load (value) {
if (!!!this.parArray || this.parArray.length == 0) {
this.parArray = await this.$store.dispatch('cache/getDictByType', 6)
this.parArray.unshift(this.defaultAll)
this.chArray = this.parArray[0].children
this.parSelected = ''
this.selected = ''
}
if (!!value) {
var show = this.getParIndex(this.parArray, value)
this.chArray = this.parArray[show].children
this.parSelected = this.parArray[show].key
this.selected = value
}
},
parentChange (value) {
this.childArray = [];
this.childArray.unshift(this.defaultChild)
this.childValue = ''
if (value != '') {
let pars2 = { typeId: this.typeId, parentId: value };
this.$api.parameter.getParameterList(pars2).then(({ data = {} }) => {
if (data) {
this.childArray = data.data
this.childArray.unshift(this.defaultChild)
}
}).catch(() => { });
}
else {
this.childArray = [this.defaultChild]
this.childValue = ''
this.$emit("input", null);
this.$emit("change");
}
this.$emit('parentChange', value)
this.$emit("change");
},
childChange (value) {
this.$emit("input", value);
var newArr = this.childArray.filter(x => x.key == value);
if (!!newArr && newArr.length > 0) {
var text = !!value ? newArr[0].title : ''
this.$emit('changeTitle', text)
}
this.$emit("change");
},
getParIndex (list, value) {
var show = 0
if (!!list && list.length > 0) {
for (var i = 0; i < list.length; i++) {
for (var j = 0; j < list[i].children.length; j++) {
if (list[i].children[j].key == value) {
show = i
break
}
}
}
}
return show
}
},
watch: {
value: {
handler (value) {
if (!!value && !this.loading) {
this.loading = true
this.load(value)
}
},
},
}
}
</script>
import Vue from 'vue'
import api from '@/api'
import DictTypes from './DictTypes'
export default class Dict {
constructor(dict) {
this.dict = dict
}
/**
* 初始化字典数据
* @param {Array} names 字典类型名称数组
......@@ -17,15 +15,15 @@ export default class Dict {
throw new Error('need Dict names')
}
const promises = names.map(n => {
let param = DictTypes[n]
if (param === undefined || param === null) {
let obj = DictTypes[n]
if (obj === undefined || obj === null) {
throw new Error('need Dict names')
}
// 初始化字典数据结构
Vue.set(this.dict.dictLabel, n, {})
Vue.set(this.dict, n, [])
// 获取字典数据
return api.parameter.getDicts(n).then(res => {
return obj.api.then(res => {
if (res && res.data) {
// 更新字典数据
this.dict[n].splice(0, 0, ...res.data)
......@@ -76,13 +74,15 @@ export default class Dict {
*/
async refreshDict (name) {
try {
let obj = DictTypes[n]
if (obj === undefined || obj === null) {
throw new Error('need Dict names')
}
Vue.set(this.dict.dictLabel, name, {})
Vue.set(this.dict, name, [])
const res = await api.parameter.getDicts(name)
const res = await obj.api
if (res && res.data) {
this.dict[name].splice(0, 0, ...res.data)
res.data.forEach(d => {
Vue.set(this.dict.dictLabel[name], d.key, d.title)
})
......
import api from '@/api'
/**
* 字典类型常量定义
* 用于统一管理系统中所有字典类型的ID
*/
export default {
// 基础字典类型
UNIT_TYPE: 1, // 单位类型
PERSON_TYPE: 2, // 人员类型
PROJECT_TYPE: 3, // 项目类型
TALENT_TYPE: 4, // 人才类型
EXPERT_TYPE: 5, // 专家类型
PARAMETER_TYPE: 6, // 参数类型
EVALUATION_TYPE: 7, // 评估类型
AUDIT_TYPE: 8, // 审核类型
STATUS_TYPE: 9, // 状态类型
// 项目相关
PROJECT_STATUS: 10, // 项目状态
PROJECT_CATEGORY: 11, // 项目分类
PROJECT_LEVEL: 12, // 项目级别
}
/**
* 字典类型描述映射
*/
export const DictTypeLabels = {
1: '单位类型',
2: '人员类型',
3: '项目类型',
4: '人才类型',
5: '专家类型',
6: '参数类型',
7: '评估类型',
8: '审核类型',
9: '状态类型',
10: '项目状态',
title: { type:7,api:api.parameter.getArrayListByType({typeId:7})},
education: { type:8,api:api.parameter.getParameterList({typeId:8})},
nation: { type:11,api:api.parameter.getParameterList({typeId:11})},
degree: { type:9,api:api.parameter.getParameterList({typeId:9})},
knowledge: { type:56,api:api.parameter.getParameterList({typeId:56})},
proj_class: { type:52,api:api.parameter.getParameterList({typeId:52})},
unit_role: { type:65,api:api.parameter.getParameterList({typeId:65})},
talent_category: { type:21,api:api.parameter.getParameterList({typeId:21})},
unit_nature: { type:58,api:api.parameter.getParameterList({typeId:58})},
}
\ No newline at end of file
......@@ -8,11 +8,7 @@
<div class="demo-item">
<label>项目状态选择:</label>
<a-select v-model="projectStatus" placeholder="请选择项目状态" style="width: 200px">
<a-select-option
v-for="item in dict.projectStatus"
:key="item.key"
:value="item.key"
>
<a-select-option v-for="item in dict.projectStatus" :key="item.key" :value="item.key">
{{ item.title }}
</a-select-option>
</a-select>
......@@ -31,11 +27,7 @@
<div class="demo-item">
<label>多选项目状态:</label>
<a-select v-model="multipleStatus" mode="multiple" placeholder="请选择多个状态" style="width: 300px">
<a-select-option
v-for="item in dict.projectStatus"
:key="item.key"
:value="item.key"
>
<a-select-option v-for="item in dict.projectStatus" :key="item.key" :value="item.key">
{{ item.title }}
</a-select-option>
</a-select>
......@@ -49,11 +41,7 @@
<div class="demo-item">
<label>单选按钮:</label>
<a-radio-group v-model="radioValue">
<a-radio
v-for="item in dict.projectStatus"
:key="item.key"
:value="item.key"
>
<a-radio v-for="item in dict.projectStatus" :key="item.key" :value="item.key">
{{ item.title }}
</a-radio>
</a-radio-group>
......@@ -63,11 +51,7 @@
<div class="demo-item">
<label>多选按钮:</label>
<a-checkbox-group v-model="checkboxValues">
<a-checkbox
v-for="item in dict.projectStatus"
:key="item.key"
:value="item.key"
>
<a-checkbox v-for="item in dict.projectStatus" :key="item.key" :value="item.key">
{{ item.title }}
</a-checkbox>
</a-checkbox-group>
......@@ -108,7 +92,7 @@ export default {
name: 'DictExample',
// 配置需要使用的字典类型
dicts: ['projectStatus', 'taskStatus', 'auditStatus'],
data() {
data () {
return {
DictTypes,
projectStatus: '',
......@@ -117,7 +101,7 @@ export default {
checkboxValues: []
}
},
mounted() {
mounted () {
// 监听字典数据加载完成事件
this.$on('dictReady', () => {
console.log('字典数据加载完成')
......@@ -126,12 +110,12 @@ export default {
},
methods: {
// 获取字典标签
getDictLabel(name, value) {
getDictLabel (name, value) {
return this.getDictLabel(name, value)
},
// 刷新项目状态字典
async refreshProjectStatus() {
async refreshProjectStatus () {
try {
await this.refreshDict('projectStatus')
this.$message.success('项目状态字典刷新成功')
......@@ -141,13 +125,13 @@ export default {
},
// 清除项目状态缓存
clearProjectStatus() {
clearProjectStatus () {
this.clearDict('projectStatus')
this.$message.success('项目状态缓存清除成功')
},
// 清除所有缓存
clearAllDicts() {
clearAllDicts () {
this.clearAllDicts()
this.$message.success('所有字典缓存清除成功')
}
......
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