diff --git a/apps/web/src/app/admin/staffinfo-manage/defaultFields.ts b/apps/web/src/app/admin/staffinfo-manage/defaultFields.ts index db931e8..206f9d3 100644 --- a/apps/web/src/app/admin/staffinfo-manage/defaultFields.ts +++ b/apps/web/src/app/admin/staffinfo-manage/defaultFields.ts @@ -1,3 +1,5 @@ +import { areaOptions } from "@web/src/data/area-options"; + export const defaultFields = [ // 基本信息组 { name: 'username', label: '用户名', type: 'text',required: true, group: '基本信息', order: 1 }, @@ -26,7 +28,12 @@ export const defaultFields = [ ], group: '基本信息', order: 8 }, - { name: 'birthplace', label: '籍贯', type: 'text', group: '基本信息', order: 9 }, + { name: 'birthplace', + label: '籍贯', + type: 'cascader', + // options:areaOptions, + group: '基本信息', + order: 9 }, { name: 'source', label: '来源', type: 'text', group: '基本信息', order: 10 }, // 政治信息组 @@ -119,9 +126,9 @@ export const defaultFields = [ { name: 'foreignLang', label: '外语能力', type: 'text', group: '教育信息', order: 27 }, // 培训信息组 - { name: 'trainType', label: '培训类型', type: 'text', group: '培训信息', order: 28 }, - { name: 'trainInstitute', label: '培训机构', type: 'text', group: '培训信息', order: 29 }, - { name: 'trainMajor', label: '培训专业', type: 'text', group: '培训信息', order: 30 }, + { name: 'trainType', label: '培训类型', type: 'text', group: '培训信息', order: 28 ,dependsOn:{field: 'hasTrain', value: '是'}}, + { name: 'trainInstitute', label: '培训机构', type: 'text', group: '培训信息', order: 29 ,dependsOn: {field: 'hasTrain', value: '是'}}, + { name: 'trainMajor', label: '培训专业', type: 'text', group: '培训信息', order: 30 ,dependsOn: {field: 'hasTrain', value: '是'}}, { name: 'hasTrain', label: '是否参加培训', type: 'radio', @@ -133,8 +140,18 @@ export const defaultFields = [ order: 31 }, // 鉴定信息组 - { name: 'certRank', label: '鉴定等级', type: 'text', group: '鉴定信息', order: 32 }, - { name: 'certWork', label: '鉴定工种', type: 'text', group: '鉴定信息', order: 33 }, + { name: 'certRank', + label: '鉴定等级', + type: 'text', + group: '鉴定信息', + order: 32 , + dependsOn: {field: 'hasCert', value: '是'}}, + { name: 'certWork', + label: '鉴定工种', + type: 'text', + group: '鉴定信息', + order: 33 , + dependsOn: {field: 'hasCert', value: '是'}}, { name: 'hasCert', label: '是否参加鉴定', type: 'radio', @@ -159,6 +176,7 @@ export const defaultFields = [ { label: '选择', value: 'select' }, { label: '单选', value: 'radio' }, { label: '多行文本', value: 'textarea' }, + { label: '级联', value: 'cascader' }, ]; export const GroupOptions = [ diff --git a/apps/web/src/app/admin/staffinfo-manage/staffFieldManage.tsx b/apps/web/src/app/admin/staffinfo-manage/staffFieldManage.tsx index d79edff..e2f3f61 100644 --- a/apps/web/src/app/admin/staffinfo-manage/staffFieldManage.tsx +++ b/apps/web/src/app/admin/staffinfo-manage/staffFieldManage.tsx @@ -8,6 +8,7 @@ import StaffFieldTable from './staffFieldTable'; import StaffFieldModal from './staffFieldModal'; import { useWatch } from 'antd/es/form/Form'; import { Form } from 'antd'; + const StaffFieldManage = () => { const [form] = Form.useForm(); const [isModalVisible, setIsModalVisible] = useState(false); @@ -19,7 +20,7 @@ const StaffFieldManage = () => { useCustomFields } = useStaff(); const { data: fields, isLoading } = useCustomFields(); - const optionFieldTypes = ['select', 'radio']; + const optionFieldTypes = ['select', 'radio',]; const [showOptions, setShowOptions] = useState(false); const typeValue = useWatch('type', form); diff --git a/apps/web/src/app/admin/staffinfo-manage/staffFieldTable.tsx b/apps/web/src/app/admin/staffinfo-manage/staffFieldTable.tsx index c20a2f7..7db29be 100644 --- a/apps/web/src/app/admin/staffinfo-manage/staffFieldTable.tsx +++ b/apps/web/src/app/admin/staffinfo-manage/staffFieldTable.tsx @@ -30,6 +30,7 @@ const StaffFieldTable: React.FC = ({ handleDelete, handleBatchDelete }) => { + console.log(fields); const columns = [ { title: '字段名称', diff --git a/apps/web/src/app/main/staffinfo_write/infoCard.tsx b/apps/web/src/app/main/staffinfo_write/infoCard.tsx new file mode 100644 index 0000000..027e1b6 --- /dev/null +++ b/apps/web/src/app/main/staffinfo_write/infoCard.tsx @@ -0,0 +1,29 @@ +import { Card, Button, Input, Space } from 'antd'; +import React, { useState } from 'react'; + +type InfoCardProps = { + onAdd: (content: string) => void; +} +const InfoCard:React.FC = ({onAdd}) => { + const [content, setContent] = useState(''); + const handleAdd = () => { + if(content){ + onAdd(content); + setContent(''); + } + } + return ( + + + setContent(e.target.value)} + > + + + + + ); +} +export default InfoCard; \ No newline at end of file diff --git a/apps/web/src/app/main/staffinfo_write/page.tsx b/apps/web/src/app/main/staffinfo_write/page.tsx deleted file mode 100644 index 70d0094..0000000 --- a/apps/web/src/app/main/staffinfo_write/page.tsx +++ /dev/null @@ -1,129 +0,0 @@ -"use client"; - -import { Button, Form, Input, Select, DatePicker, Radio, message, Modal, Cascader, InputNumber } from "antd"; -import { useState, useMemo } from "react"; -import { useStaff } from "@nice/client"; -import { areaOptions } from './area-options'; -const { TextArea } = Input; - -const StaffInfoWrite = () => { - const [form] = Form.useForm(); - const [loading, setLoading] = useState(false); - const { create, useCustomFields } = useStaff(); - const { data: fields, isLoading: fieldsLoading } = useCustomFields(); - - // 按分组组织字段 - const fieldGroups = useMemo(() => { - if (!fields) return {}; - return fields.reduce((groups: any, field: any) => { - const group = field.group || '其他信息'; - if (!groups[group]) { - groups[group] = []; - } - groups[group].push(field); - return groups; - }, {}); - }, [fields]); - - const renderField = (field: any) => { - switch (field.type) { - case 'text': - return ; - case 'number': - return ; - case 'date': - return ; - case 'select': - // 检查 field.options 是否存在且有数据 - if (field.options && field.options.length > 0) { - return ; - case 'radio': - // 检查 field.options 是否存在且有数据 - if (field.options && field.options.length > 0) { - return ; - } - return ; - case 'textarea': - return ; - default: - return ; - } - }; - - const onFinish = async (values: any) => { - try { - setLoading(true); - const formattedValues = { - ...values, - birthplace: values.birthplace?.join('/'), - }; - - await create.mutateAsync({ - data: formattedValues - }); - - message.success("信息提交成功"); - } catch (error) { - console.error('提交出错:', error); - message.error("提交失败,请重试"); - } finally { - setLoading(false); - } - }; - - if (fieldsLoading) { - return
加载中...
; - } - - return ( -
-

人员信息管理

- - {/* 信息填报表单 */} -
- {Object.entries(fieldGroups).map(([groupName, groupFields]) => ( -
-

{groupName}

-
- {groupFields.map((field: any) => ( - - {renderField(field)} - - ))} -
-
- ))} - -
- - -
-
-
- ); -}; - -export default StaffInfoWrite; \ No newline at end of file diff --git a/apps/web/src/app/main/staffinfo_write/staffinfo_write.page.tsx b/apps/web/src/app/main/staffinfo_write/staffinfo_write.page.tsx new file mode 100644 index 0000000..0f03bb2 --- /dev/null +++ b/apps/web/src/app/main/staffinfo_write/staffinfo_write.page.tsx @@ -0,0 +1,135 @@ +"use client"; + +import { Button, Form, Input, Select, DatePicker, Radio, message, Modal, Cascader, InputNumber } from "antd"; +import { useState, useMemo } from "react"; +import { useStaff } from "@nice/client"; +import { areaOptions } from './area-options'; +import InfoCard from './infoCard'; + +const StaffInfoWrite = () => { + const [form] = Form.useForm(); + const [loading, setLoading] = useState(false); + const { create, useCustomFields } = useStaff(); + const { data: fields, isLoading: fieldsLoading } = useCustomFields(); + const [infoCards, setInfoCards] = useState([]); + const handleAdd = ( content: string) => { + setInfoCards([...infoCards, { content }]); + } + // 按分组组织字段 + const fieldGroups = useMemo(() => { + if (!fields) return {}; + return fields.reduce((groups: any, field: any) => { + const group = field.group || '其他信息'; + if (!groups[group]) { + groups[group] = []; + } + groups[group].push(field); + return groups; + }, {}); + }, [fields]); + + const renderField = (field: any) => { + switch (field.type) { + case 'text': + return ; + case 'number': + return ; + case 'date': + return ; + case 'select': + if (field.options && field.options.length > 0) { + return ; + case 'radio': + if (field.options && field.options.length > 0) { + return ; + } + return ; + case 'textarea': + return ; + case 'cascader': + if(field.label === '籍贯'){ + return ; + }else{ + return ; + } + default: + return ; + } + }; + + const onFinish = async (values: any) => { + try { + setLoading(true); + const formattedValues = { + ...values, + birthplace: values.birthplace?.join('/'), + }; + + await create.mutateAsync({ + data: formattedValues + }); + + message.success("信息提交成功"); + } catch (error) { + console.error('提交出错:', error); + message.error("提交失败,请重试"); + } finally { + setLoading(false); + } + }; + + if (fieldsLoading) { + return
加载中...
; + } + + return ( +
+

人员信息管理

+ +
+ {Object.entries(fieldGroups).map(([groupName, groupFields]) => ( +
+

{groupName}

+
+ {groupFields.map((field: any) => ( + + {renderField(field)} + + ))} +
+
+ ))} + +
+ + +
+
+
+ ); +}; + +export default StaffInfoWrite; \ No newline at end of file diff --git a/apps/web/src/routes/index.tsx b/apps/web/src/routes/index.tsx index 2744f81..5d3d0b9 100755 --- a/apps/web/src/routes/index.tsx +++ b/apps/web/src/routes/index.tsx @@ -13,7 +13,7 @@ import MainLayout from "../app/main/layout/MainLayout"; import DailyPage from "../app/main/daily/page"; import Dashboard from "../app/main/home/page"; import WeekPlanPage from "../app/main/plan/weekplan/page"; -import StaffInformation from "../app/main/staffinfo_write/page"; +import StaffInformation from "../app/main/staffinfo_write/staffinfo_write.page"; import DeptSettingPage from "../app/main/admin/deptsettingpage/page"; import { adminRoute } from "./admin-route"; import AdminLayout from "../components/layout/admin/AdminLayout";