commit
41cbabcf88
@ -1,3 +0,0 @@
|
|||||||
import DictSelect from './src/DictSelect.vue'
|
|
||||||
|
|
||||||
export { DictSelect }
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
<!-- 数据字典 Select 选择器 -->
|
|
||||||
<template>
|
|
||||||
<el-select class="w-1/1" v-bind="attrs">
|
|
||||||
<template v-if="valueType === 'int'">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in getIntDictOptions(dictType)"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-if="valueType === 'str'">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in getStrDictOptions(dictType)"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-if="valueType === 'bool'">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in getBoolDictOptions(dictType)"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { getBoolDictOptions, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
|
||||||
|
|
||||||
// 接受父组件参数
|
|
||||||
interface Props {
|
|
||||||
dictType: string // 字典类型
|
|
||||||
valueType: string // 字典值类型
|
|
||||||
}
|
|
||||||
|
|
||||||
withDefaults(defineProps<Props>(), {
|
|
||||||
dictType: '',
|
|
||||||
valueType: 'str'
|
|
||||||
})
|
|
||||||
const attrs = useAttrs()
|
|
||||||
defineOptions({ name: 'DictSelect' })
|
|
||||||
</script>
|
|
||||||
@ -1,3 +1,4 @@
|
|||||||
import { useFormCreateDesigner } from './src/useFormCreateDesigner'
|
import { useFormCreateDesigner } from './src/useFormCreateDesigner'
|
||||||
|
import { useApiSelect } from './src/components/useApiSelect'
|
||||||
|
|
||||||
export { useFormCreateDesigner }
|
export { useFormCreateDesigner, useApiSelect }
|
||||||
|
|||||||
@ -0,0 +1,33 @@
|
|||||||
|
import { generateUUID } from '@/utils'
|
||||||
|
import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils'
|
||||||
|
import { selectRule } from '@/components/FormCreate/src/config/selectRule'
|
||||||
|
import { SelectRuleOption } from '@/components/FormCreate/src/type'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用选择器规则 hook
|
||||||
|
* @param option 规则配置
|
||||||
|
*/
|
||||||
|
export const useSelectRule = (option: SelectRuleOption) => {
|
||||||
|
const label = option.label
|
||||||
|
const name = option.name
|
||||||
|
return {
|
||||||
|
icon: option.icon,
|
||||||
|
label,
|
||||||
|
name,
|
||||||
|
rule() {
|
||||||
|
return {
|
||||||
|
type: name,
|
||||||
|
field: generateUUID(),
|
||||||
|
title: label,
|
||||||
|
info: '',
|
||||||
|
$required: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props(_, { t }) {
|
||||||
|
if (!option.props) {
|
||||||
|
option.props = []
|
||||||
|
}
|
||||||
|
return localeProps(t, name + '.props', [makeRequiredRule(), ...option.props, ...selectRule])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,25 +0,0 @@
|
|||||||
import { generateUUID } from '@/utils'
|
|
||||||
import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils'
|
|
||||||
import selectRule from '@/components/FormCreate/src/config/selectRule'
|
|
||||||
|
|
||||||
export const useUserSelectRule = () => {
|
|
||||||
const label = '用户选择器'
|
|
||||||
const name = 'UserSelect'
|
|
||||||
return {
|
|
||||||
icon: 'icon-select',
|
|
||||||
label,
|
|
||||||
name,
|
|
||||||
rule() {
|
|
||||||
return {
|
|
||||||
type: name,
|
|
||||||
field: generateUUID(),
|
|
||||||
title: label,
|
|
||||||
info: '',
|
|
||||||
$required: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
props(_, { t }) {
|
|
||||||
return localeProps(t, name + '.props', [makeRequiredRule(), ...selectRule])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
import { Rule } from '@form-create/element-ui' //左侧拖拽按钮
|
||||||
|
|
||||||
|
// 左侧拖拽按钮
|
||||||
|
export interface MenuItem {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
icon: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 左侧拖拽按钮分类
|
||||||
|
export interface Menu {
|
||||||
|
title: string
|
||||||
|
name: string
|
||||||
|
list: MenuItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MenuList extends Array<Menu> {}
|
||||||
|
|
||||||
|
// 拖拽组件的规则
|
||||||
|
export interface DragRule {
|
||||||
|
icon: string
|
||||||
|
name: string
|
||||||
|
label: string
|
||||||
|
children?: string
|
||||||
|
inside?: true
|
||||||
|
drag?: true | String
|
||||||
|
dragBtn?: false
|
||||||
|
mask?: false
|
||||||
|
|
||||||
|
rule(): Rule
|
||||||
|
|
||||||
|
props(v: any, v1: any): Rule[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用下拉组件 Props 类型
|
||||||
|
export interface ApiSelectProps {
|
||||||
|
name: string // 组件名称
|
||||||
|
labelField?: string // 选项标签
|
||||||
|
valueField?: string // 选项的值
|
||||||
|
url?: string // url 接口
|
||||||
|
isDict?: boolean // 是否字典选择器
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择组件规则配置类型
|
||||||
|
export interface SelectRuleOption {
|
||||||
|
label: string // label 名称
|
||||||
|
name: string // 组件名称
|
||||||
|
icon: string // 组件图标
|
||||||
|
props?: any[] // 组件规则
|
||||||
|
}
|
||||||
Binary file not shown.
@ -0,0 +1,22 @@
|
|||||||
|
// 使用字体图标来源 https://fontello.com/
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'fc-icon';
|
||||||
|
src: url('@/styles/FormCreate/fonts/fontello.woff') format('woff');
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-doc-text:before {
|
||||||
|
content: '\f0f6';
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-server:before {
|
||||||
|
content: '\f233';
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-address-card-o:before {
|
||||||
|
content: '\f2bc';
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-user-o:before {
|
||||||
|
content: '\f2c0';
|
||||||
|
}
|
||||||
@ -1,28 +0,0 @@
|
|||||||
<!-- TODO puhui999: 先单独一个后面封装成通用选择组件 -->
|
|
||||||
<template>
|
|
||||||
<el-select class="w-1/1" v-bind="attrs">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in userOptions"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.nickname"
|
|
||||||
:value="dict.id"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import * as UserApi from '@/api/system/user'
|
|
||||||
|
|
||||||
defineOptions({ name: 'UserSelect' })
|
|
||||||
|
|
||||||
const attrs = useAttrs()
|
|
||||||
const userOptions = ref<UserApi.UserVO[]>([]) // 用户下拉数据
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const data = await UserApi.getSimpleUserList()
|
|
||||||
if (!data || data.length === 0) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userOptions.value = data
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
Loading…
Reference in New Issue