luoyali 1 year ago
parent
commit
ce73649b22

+ 24 - 22
src/components/packages/formEditor/componentsConfig.js

@@ -150,27 +150,28 @@ export const fieldsConfig = [
 					required: false,
 					renderType: 3
 				}
-			} // ,
-			// {
-			// 	type: 'select',
-			// 	label: '部门',
-			// 	icon: 'dropdown0',
-			// 	key: '',
-			// 	id: '',
-			// 	options: {
-			// 		dataKey: '',
-			// 		filterable: true,
-			// 		multiple: false,
-			// 		defaultValue: '',
-			// 		placeholder: '',
-			// 		labelWidth: 100,
-			// 		isShowLabel: true,
-			// 		disabled: false,
-			// 		clearable: true,
-			// 		required: false,
-			// 		renderType: 4
-			// 	}
-			// }
+			},
+			{
+				type: 'cascader',
+				label: '部门',
+				icon: 'cascader',
+				key: '',
+				id: '',
+				options: {
+					filterable: true,
+					multiple: false,
+					checkStrictly: false,
+					defaultValue: '',
+					placeholder: '',
+					labelWidth: 100,
+					isShowLabel: true,
+					required: false,
+					disabled: false,
+					clearable: true,
+					renderType: 2,
+					props: { value: 'id', label: 'name' }
+				}
+			}
 		]
 	},
 	{
@@ -430,7 +431,8 @@ export const fieldsConfig = [
 					isShowLabel: true,
 					required: false,
 					disabled: false,
-					clearable: true
+					clearable: true,
+					renderType: 1
 				}
 			},
 			{

+ 1 - 1
src/components/packages/formEditor/locale/en.js

@@ -22,7 +22,7 @@ export default {
       switch: 'Switch',
       slider: 'Slider',
       html: 'Html',
-      cascader: 'Cascader',
+			cascader: ['Cascader', 'Depart'],
       uploadfile: 'File',
       signature: 'Signature',
       region: 'Region',

+ 1 - 1
src/components/packages/formEditor/locale/zh-cn.js

@@ -22,7 +22,7 @@ export default {
       switch: '开关',
       slider: '滑块',
       html: '富文本',
-      cascader: '级联框',
+			cascader: ['级联框', '部门'],
       uploadfile: '上传文件',
       signature: '签名',
       region: '省市区',

+ 137 - 3
src/components/packages/hooks/use-props/index.js

@@ -240,6 +240,7 @@ export const useProps = (state, data, isPc = true, isRoot = false, specialHandli
 		if (isPc) {
 			result.labelWidth = options.isShowLabel ? options.labelWidth + 'px' : 'auto'
 		}
+		const { renderType } = options
 		switch (node.type) {
 			case 'input':
 				if (options.isShowWordLimit) {
@@ -293,7 +294,6 @@ export const useProps = (state, data, isPc = true, isRoot = false, specialHandli
 				result.options = _.get(state, `data[${options.dataKey}].list`, [])
 				break
 			case 'select':
-				const { renderType } = options
 				// 当前选中的值,如果是人员就获取人员的api,部门就获取部门的api
 				if ([2, 3, 4].indexOf(renderType) > -1) {
 					result.options = options?.options
@@ -386,10 +386,144 @@ export const useProps = (state, data, isPc = true, isRoot = false, specialHandli
 				}
 				break
 			case 'cascader':
-				result.options = _.get(state, `data[${options.dataKey}].list`, [])
+				if (renderType === 2) {
+					result.options = [
+						{
+							id: '3',
+							createId: '0',
+							createBy: 'admin',
+							createTime: '2022-02-20 22:21',
+							updateBy: 'admin',
+							updateTime: '2024-05-02 13:18',
+							pid: '0',
+							name: '飞龙驱动科技',
+							code: '1000',
+							sort: 2,
+							remark: '太阳科技',
+							status: 1,
+							headId: '0',
+							headName: 'CEO',
+							children: [
+								{
+									id: '1778237792399392769',
+									createId: '0',
+									createBy: 'admin',
+									createTime: '2024-04-11 09:45',
+									pid: '3',
+									name: '财务部',
+									code: '0023',
+									sort: 4,
+									remark: '财务部',
+									status: 0,
+									headId: '1778236187025342466',
+									parentName: '飞龙驱动科技'
+								},
+								{
+									id: '1778247413147107329',
+									createId: '0',
+									createBy: 'admin',
+									createTime: '2024-04-11 10:23',
+									pid: '3',
+									name: '应用部',
+									code: 'yingyongbu',
+									sort: 2,
+									remark: '应用部',
+									status: 1,
+									headId: '1778236187025342466',
+									headName: '夏小华',
+									parentName: '飞龙驱动科技'
+								},
+								{
+									id: '1778246587070545922',
+									createId: '0',
+									createBy: 'admin',
+									createTime: '2024-04-11 10:19',
+									pid: '3',
+									name: '综合管理部',
+									code: 'zongheguanli',
+									sort: 1,
+									remark: '综合管理',
+									status: 1,
+									headId: '1778236187025342466',
+									headName: '部门领导',
+									parentName: '飞龙驱动科技',
+									children: [
+										{
+											id: '1778247724637093889',
+											createId: '0',
+											createBy: 'admin',
+											createTime: '2024-04-11 10:24',
+											pid: '1778246587070545922',
+											name: '人事部',
+											code: 'renshibu',
+											sort: 1,
+											remark: '人事部',
+											status: 1,
+											headId: '1778235419958444034',
+											headName: '出纳',
+											parentName: '综合管理部'
+										}
+									]
+								},
+								{
+									id: '2',
+									createId: '0',
+									createBy: 'admin',
+									createTime: '2021-11-07 10:13',
+									updateBy: 'admin',
+									updateTime: '2024-04-11 10:22',
+									pid: '3',
+									name: '产品部',
+									code: '2000',
+									sort: 0,
+									remark: '产品部',
+									status: 1,
+									headId: '1778236021094481921',
+									headName: '杨小凤',
+									parentName: '飞龙驱动科技',
+									children: [
+										{
+											id: '1',
+											createId: '0',
+											createBy: 'admin',
+											createTime: '2022-02-20 22:19',
+											updateBy: 'admin',
+											updateTime: '2023-12-30 14:23',
+											pid: '2',
+											name: '开发 A 组',
+											code: '2020',
+											sort: 1,
+											remark: '开发 A 组',
+											status: 1,
+											parentName: '产品部'
+										},
+										{
+											id: '1696346580223049729',
+											createId: '0',
+											createBy: 'admin',
+											createTime: '2023-08-29 10:18',
+											updateBy: 'admin',
+											updateTime: '2023-12-30 14:23',
+											pid: '2',
+											name: '开发 B 组',
+											code: '2010',
+											sort: 1,
+											remark: '开发 B 组',
+											status: 1,
+											parentName: '产品部'
+										}
+									]
+								}
+							]
+						}
+					]
+				} else if (renderType === 1) {
+					result.options = _.get(state, `data[${options.dataKey}].list`, [])
+				}
 				result.props = {
 					multiple: options.multiple,
-					checkStrictly: options.checkStrictly
+					checkStrictly: options.checkStrictly,
+					...options.props
 				}
 				// result.options = options.options
 				break