Skip to content

Commit d16bed4

Browse files
author
puhui999
committed
form-create-designer: 表单组件新增用户选择器
1 parent 68dae2d commit d16bed4

File tree

5 files changed

+38
-29
lines changed

5 files changed

+38
-29
lines changed

src/components/DictSelect/src/DictSelect.vue

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<el-select :model-value="modelValue" class="w-1/1" v-bind="attrs" @change="changeValue">
2+
<el-select class="w-1/1" v-bind="attrs">
33
<template v-if="valueType === 'int'">
44
<el-option
55
v-for="(dict, index) in getIntDictOptions(dictType)"
@@ -43,11 +43,4 @@ withDefaults(defineProps<Props>(), {
4343
})
4444
const attrs = useAttrs()
4545
defineOptions({ name: 'DictSelect' })
46-
const emits = defineEmits<{
47-
(e: 'update:modelValue', v: any): void
48-
}>()
49-
const changeValue = (value: any) => {
50-
console.log(value)
51-
emits('update:modelValue', value)
52-
}
5346
</script>

src/components/FormCreate/src/config/useUserSelectRule.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
import { generateUUID } from '@/utils'
2-
import * as UserApi from '@/api/system/user'
3-
import { localeProps, makeOptionsRule, makeRequiredRule } from '@/components/FormCreate/src/utils'
2+
import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils'
43

54
export const useUserSelectRule = () => {
6-
const label = 'aa选择器'
7-
const name = 'select'
8-
const userOptions = ref<{ label: string; value: number }[]>([]) // 用户下拉数据
9-
onMounted(async () => {
10-
const data = await UserApi.getSimpleUserList()
11-
if (!data || data.length === 0) {
12-
return
13-
}
14-
userOptions.value =
15-
data?.map((item: UserApi.UserVO) => ({
16-
label: item.nickname,
17-
value: item.id
18-
})) ?? []
19-
})
5+
const label = '用户选择器'
6+
const name = 'UserSelect'
207
return {
218
icon: 'icon-select',
229
label,
@@ -33,7 +20,6 @@ export const useUserSelectRule = () => {
3320
props(_, { t }) {
3421
return localeProps(t, name + '.props', [
3522
makeRequiredRule(),
36-
makeOptionsRule(t, 'options', userOptions.value),
3723
{ type: 'switch', field: 'multiple', title: '是否多选' },
3824
{
3925
type: 'switch',

src/plugins/formCreate/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import install from '@form-create/element-ui/auto-import'
2020
//======================= 自定义组件 =======================
2121
import { UploadFile, UploadImg, UploadImgs } from '@/components/UploadFile'
2222
import { DictSelect } from '@/components/DictSelect'
23+
import UserSelect from '@/views/system/user/components/UserSelect.vue'
2324

2425
const components = [
2526
ElAside,
@@ -37,7 +38,8 @@ const components = [
3738
UploadImg,
3839
UploadImgs,
3940
UploadFile,
40-
DictSelect
41+
DictSelect,
42+
UserSelect
4143
]
4244

4345
// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档

src/utils/dict.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
22
* 数据字典工具类
33
*/
4-
import { useDictStoreWithOut } from '@/store/modules/dict'
5-
import { ElementPlusInfoType } from '@/types/elementPlus'
4+
import {useDictStoreWithOut} from '@/store/modules/dict'
5+
import {ElementPlusInfoType} from '@/types/elementPlus'
66

77
const dictStore = useDictStoreWithOut()
88

@@ -137,7 +137,7 @@ export enum DICT_TYPE {
137137
INFRA_FILE_STORAGE = 'infra_file_storage',
138138

139139
// ========== BPM 模块 ==========
140-
BPM_MODEL_FORM_TYPE = 'bpm_model_form_type',
140+
BPM_MODEL_FORM_TYPE = 'bpm_model_category',
141141
BPM_TASK_CANDIDATE_STRATEGY = 'bpm_task_candidate_strategy',
142142
BPM_PROCESS_INSTANCE_STATUS = 'bpm_process_instance_status',
143143
BPM_TASK_STATUS = 'bpm_task_status',
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!-- TODO puhui999: 先单独一个后面封装成通用选择组件 -->
2+
<template>
3+
<el-select class="w-1/1" v-bind="attrs">
4+
<el-option
5+
v-for="(dict, index) in userOptions"
6+
:key="index"
7+
:label="dict.nickname"
8+
:value="dict.id"
9+
/>
10+
</el-select>
11+
</template>
12+
13+
<script lang="ts" setup>
14+
import * as UserApi from '@/api/system/user'
15+
16+
defineOptions({ name: 'UserSelect' })
17+
18+
const attrs = useAttrs()
19+
const userOptions = ref<UserApi.UserVO[]>([]) // 用户下拉数据
20+
21+
onMounted(async () => {
22+
const data = await UserApi.getSimpleUserList()
23+
if (!data || data.length === 0) {
24+
return
25+
}
26+
userOptions.value = data
27+
})
28+
</script>

0 commit comments

Comments
 (0)