From 07d1135a1913a919679dc23f0a38b9b61987171f Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期五, 01 八月 2025 15:29:37 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/OAManage --- src/pages/humanResourcePlanning/personnelRequirementAnalysis/index.tsx | 572 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 572 insertions(+), 0 deletions(-) diff --git a/src/pages/humanResourcePlanning/personnelRequirementAnalysis/index.tsx b/src/pages/humanResourcePlanning/personnelRequirementAnalysis/index.tsx new file mode 100644 index 0000000..bcb3bf4 --- /dev/null +++ b/src/pages/humanResourcePlanning/personnelRequirementAnalysis/index.tsx @@ -0,0 +1,572 @@ +import { + postOaResourceRequirementAnalysisGetResourceRequirementAnalysisList, + postOaResourceRequirementAnalysisNewApprove, + postOaResourceRequirementAnalysisNewResourceRequirementAnalysis, + postOaResourceRequirementAnalysisUpdateResourceRequirementAnalysis, + postOaResourceRequirementAnalysisDelResourceRequirementAnalysis +} from "@/services/WebApi/resourceRequirementAnalysis"; +import { postOaDepartmentGetDepartmentList } from '@/services/WebApi/oaDepartment'; +import { postOaJobGetJobList } from '@/services/WebApi/oaJob'; +import { PageContainer, ProTable } from "@ant-design/pro-components"; +import { PlusOutlined, ExclamationCircleOutlined } from "@ant-design/icons"; +import styles from "./index.less"; +import dayjs from "dayjs"; +import React, { useEffect, useRef, useState } from "react"; +import { + Button, + Col, + Form, + Input, + Modal, + Row, + message, + Select, + Radio, + Divider +} from "antd"; +import TextArea from "antd/es/input/TextArea"; + +const personnelRequirementAnalysis: React.FC = () => { + const [dialogTitle, setDialogTitle] = useState(""); + const [addDialogVisible, setAddDialogVisible] = useState({ + open: false, // 鍒濆鐘舵�� + type: "", // examine 瀹℃壒 add 鏂板缓 modify 淇敼 + }); + const [currentTime, setCurrentTime] = useState(''); + const [formRef] = Form.useForm(); + const tableRef = useRef(null); + const { confirm } = Modal; + + // 鍙渶瑕佸瓨鍌ㄥ師濮嬫暟鎹� + const [departments, setDepartments] = useState([]); + const [positions, setPositions] = useState([]); + + useEffect(() => { + // 缁勪欢鎸傝浇鏃惰幏鍙栧綋鍓嶆椂闂� + const loadData = async () => { + try { + // 浣跨敤 Promise.all 骞惰璇锋眰锛屾晥鐜囨洿楂� + const [depData, posData] = await Promise.all([ + getDepList(), + getPositionList() + ]); + setDepartments(depData.data); + setPositions(posData.data); + setCurrentTime(new Date().toLocaleString()); + + } catch (error) { + console.error("鑾峰彇鏁版嵁澶辫触:", error); + } + }; + loadData(); + setCurrentTime(new Date().toLocaleString()); + }, []); + + //鑾峰彇閮ㄩ棬鍒楄〃 + const getDepList = () => { + const params = { + start: 0, + size: 99, + orgId: 5, + filterList: [], + searchList: [], + }; + return postOaDepartmentGetDepartmentList(params).then((res) => { + console.log(res, 'res'); + return { + data: res.datas, + total: res.totalSize, + }; + }); + }; + // 鑾峰彇鑱屼綅鍒楄〃 + const getPositionList = () => { + const params = { + start: 0, + size: 99, + orgId: 5, + filterList: [], + searchList: [], + }; + return postOaJobGetJobList(params).then((res) => { + console.log(res, 'res'); + return { + data: res.datas, + total: res.totalSize, + }; + }); + }; + + const handleEdit = (record: any, txt: any,) => { + setAddDialogVisible({ + open: true, + type: "edit", + }); + setDialogTitle(txt + "缁勭粐鎴樼暐"); + // 鐢ㄤ簬鍙嶆樉鏁版嵁 + formRef.setFieldsValue({ + name: record.name, + department: record.department?.id, + position: record.job?.id, + currentStaffCount: record.job.currentStaffCount, + resourceCount: record.resourceCount, + remarks: record.remarks, + affect: record.affect, + }); + }; + + const handleSubmit = async (record: any,) => { + const params = { + refId: record.id, + state: "涓嶉敊锛屽緢婊℃剰", + remarks:"", + }; + return await postOaResourceRequirementAnalysisNewApprove(params).then((res) => { + console.log(res, 'res'); + return { + data: res.datas, + total: res.totalSize, + }; + }); + }; + + // 琛ㄥご + const columns = [ + { + title: "闇�姹傚垎鏋愬悕绉�", + dataIndex: "name", + key: "name", + formItemProps: { + labelWrap: true, + labelCol: { span: 8 }, + }, + }, + { + title: "閮ㄩ棬", + dataIndex: "department", + key: "department", + search: false, + render: (text: string, record: any) => { + return ( + <div> + {record.department.name} + </div> + ) + } + }, + { + title: "鑱屼綅", + dataIndex: "position", + key: "position", + search: false, + render: (text: string, record: any) => { + return ( + <div> + {record.job.name} + </div> + ) + } + }, + { + title: "鐜版湁浜烘暟", + dataIndex: "currentStaffCount", + key: "currentStaffCount", + search: false, + render: (text: string, record: any) => { + return ( + <div> + {record.job.currentStaffCount} + </div> + ) + } + }, + { + title: "鏄惁鍙椾緵缁欏洜绱犲奖鍝�", + dataIndex: "affectByMarket", + key: "affectByMarket", + search: false, + render: (text: string, record: any) => { + return ( + <div> + {record.affectByMarket == true ? "鏄�" : "鍚�"} + </div> + ) + } + }, + { + title: "闇�姹備汉鏁�", + dataIndex: "resourceCount", + key: "resourceCount", + search: false, + }, + { + title: "鐘舵��", + dataIndex: "affectByMarket", + key: "affectByMarket", + search: false, + render: (text: string, record: any) => { + // 鍋囪 record.approve 鐨勫�兼槸 true, false, 鎴� null + let statusText = ""; + let color = ""; + if (record.approve === true) { + statusText = "宸插鎵�"; + color = "#3f7cb5"; + } else if (record.approve === false) { + statusText = "寰呭鎵�"; + color = "#ff1c1c"; + } else { + statusText = "鏈彁浜�"; + color = "#bab7aa"; + } + return ( + <div style={{ color: color, fontWeight: 'bold' }}> + {statusText} + </div> + ) + } + }, + { + title: "鎿嶄綔", + width: 200, + dataIndex: "operate", + key: "operate", + search: false, + render: (text: string, record: any) => { + let statusText = ""; + let type = "" + if (record.approve === true) { + statusText = "鏌ョ湅"; + type + } else if (record.approve === false) { + statusText = "瀹℃壒"; + } else { + statusText = "缂栬緫"; + } + return ( + <div> + <Button + onClick={() => { + console.log(record, "record001"); + record.time = [dayjs(record.beginDate), dayjs(record.endDate)]; + handleEdit(record, statusText,) + }} + color="primary" + variant="text" + > + {statusText} + </Button> + <Button + onClick={() => { + console.log(record, "record001"); + handleSubmit(record) + + }} + color="primary" + variant="text" + > + 鎻愪氦 + </Button> + <Button onClick={() => { + confirm({ + icon: <ExclamationCircleOutlined />, + content: "鏄惁鍒犻櫎璇ユ暟鎹�", + onOk() { + postOaResourceRequirementAnalysisDelResourceRequirementAnalysis({ + ids: [record.id], + }).then((res) => { + message.success("鍒犻櫎鎴愬姛"); + tableRef?.current?.reload(); + }); + console.log('OK'); + }, + onCancel() { + console.log('Cancel'); + }, + }); + + }} color="danger" variant="text"> + 鍒犻櫎 + </Button> + </div> + ); + }, + }, + ]; + // 鍏ㄩ�� + const rowSelection: TableProps<DataType>["rowSelection"] = { + onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => { + // 褰撻�変腑琛屽彉鍖栨椂瑙﹀彂锛屾墦鍗伴�変腑鐨勮閿拰琛屾暟鎹� + console.log( + `selectedRowKeys: ${selectedRowKeys}`, + "selectedRows: ", + selectedRows + ); + }, + }; + // 鑾峰彇琛ㄦ牸鏁版嵁 + const getTableData = (params: { current: number; pageSize: number }) => { + const body = { + start: (params.current - 1) * params.pageSize, + size: params.pageSize, + filterList: [], + searchList: [], + orgId: 5, + }; + return postOaResourceRequirementAnalysisGetResourceRequirementAnalysisList(body).then((res) => { + return { + data: res.datas, + total: res.totalSize, + }; + }); + }; + + // 琛ㄥ崟鎻愪氦 + const handleOk = () => { + formRef.validateFields().then((values) => { + console.log(values, "values"); + debugger + }); + }; + // 琛ㄥ崟鍙栨秷 + const handleCancel = () => { + setAddDialogVisible({ + open: false, + type: "", + }); + }; + + + + // 鏌ヨ + const handleSearch = (params: { current: number; pageSize: number }) => { + console.log(params, "params001"); + debugger; + }; + + const radioOptions: CheckboxGroupProps<string>['options'] = [ + { label: '瀹℃壒閫氳繃', value: 'true' }, + { label: '瀹℃壒鎷掔粷', value: 'false' }, + ]; + + const supplyOptions: CheckboxGroupProps<string>['options'] = [ + { label: '鏄�', value: 'true' }, + { label: '鍚�', value: 'false' }, + ]; + + return ( + <PageContainer> + <ProTable + actionRef={tableRef} + headerTitle="浜哄憳闇�姹傚垎鏋愯〃" + columns={columns} + rowKey="id" + rowSelection={rowSelection} + request={getTableData} + onSearch={handleSearch} + toolBarRender={() => [ + <Button + key="button" + icon={<PlusOutlined />} + onClick={() => { + setAddDialogVisible({ + open: true, + type: "add", + }); + setDialogTitle("鏂板缓浜哄憳闇�姹傚垎鏋愯〃"); + }} + type="primary" + > + 鏂板缓 + </Button>, + ]}> + </ProTable> + <Modal + title={addDialogVisible.type == "add" ? "鏂板缓浜哄憳闇�姹傚垎鏋�" : "缂栬緫浜哄憳闇�姹傚垎鏋�"} + width={900} + onOk={handleOk} + open={addDialogVisible.open} + // confirmLoading={confirmLoading} + onCancel={handleCancel} + > + <div className={styles.addDialog}> + <Form + form={formRef} + layout="vertical" + labelCol={{ span: 6 }} + wrapperCol={{ span: 18 }} + > + <Row> + <Col span={12}> + <Form.Item + label="浜哄憳闇�姹傚垎鏋愬悕绉�" + labelCol={{ span: 12 }} + name="name" + rules={[ + { required: true, message: "璇疯緭鍏ヤ汉鍛橀渶姹傚垎鏋愬悕绉�" }, + ]} + > + <Input placeholder="璇疯緭鍏ヤ汉鍛橀渶姹傚垎鏋愬悕绉�" /> + </Form.Item> + </Col> + <Col span={12}> + <Form.Item + label="閮ㄩ棬" + name="department" + rules={[{ required: true, message: "璇烽�夋嫨閮ㄩ棬" }]} + > + <Select + placeholder="璇烽�夋嫨閮ㄩ棬" + options={departments.map(dep => ({ + value: dep.id, + label: dep.name, + }))} + /> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={12}> + <Form.Item + label="鑱屼綅" + name="position" + rules={[{ required: true, message: "璇烽�夋嫨鑱屼綅" }]} + > + <Select + placeholder="璇烽�夋嫨鑱屼綅" + options={positions.map(dep => ({ + value: dep.id, + label: dep.name, + }))} + /> + </Form.Item> + </Col> + <Col span={12}> + <Form.Item + label="鐜版湁浜烘暟" + name="currentStaffCount" + > + <Input placeholder="璇疯緭鍏ヤ汉鍛橀渶姹傚垎鏋愬悕绉�" /> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={12}> + <Form.Item + label="浜哄姏闇�姹傞娴嬫柟娉�" + name="demandForecastingMethod" + rules={[{ required: true, message: "璇烽�夋嫨浜哄姏闇�姹傞娴嬫柟娉�" }]} + labelCol={{ span: 12 }} + > + <Select + defaultValue="a1" + style={{ width: '100%' }} + // onChange={handleChange} + + // options={options} + /> + </Form.Item> + </Col> + <Col span={12}> + <Form.Item + label="鏄惁鍙椾緵缁欏洜绱犲奖鍝�" + name="affectByMarket" + rules={[{ required: true, message: "璇烽�夋嫨鏄惁鍙椾緵缁欏洜绱犲奖鍝�" }]} + labelCol={{ span: 12 }} + > + <Radio.Group block options={supplyOptions} defaultValue="true" /> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={24}> + <Form.Item + label="闇�姹備汉鏁�" + name="resourceCount" + rules={[{ required: true, message: "璇疯緭鍏ラ渶姹備汉鏁�" }]} + > + <Input placeholder="璇疯緭鍏ヤ汉鍛橀渶姹傚垎鏋愬悕绉�" /> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={24}> + <Form.Item + label="褰卞搷鍥犵礌" + name="affect" + rules={[{ message: "璇疯緭鍏ュ奖鍝嶅洜绱�" }]} + > + <TextArea rows={4} /> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={24}> + <Form.Item + label="澶囨敞" + name="remarks" + rules={[{ message: "璇疯緭鍏ュ娉�" }]} + > + <TextArea rows={4} /> + </Form.Item> + </Col> + </Row> + + {/* 鏍规嵁琛ㄦ牸鐨則ype鏉ュ垽鏂槸鍚︽樉绀� */} + { + addDialogVisible.type == "examine" ? ( + <> + <Divider orientation="center">寰呭鐞嗙殑浜哄憳闇�姹傚垎鏋�</Divider> + <Row> + <Col span={24}> + <Form.Item + label="瀹℃壒璇存槑" + name="affect" + rules={[{ required: true, message: "璇疯緭鍏ュ鎵硅鏄�" }]} + > + <TextArea rows={4} /> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={12}> + <Form.Item + label="瀹℃壒浜虹瀛�" + name="affect" + rules={[{ required: true, message: "璇疯緭鍏ュ鎵硅鏄�" }]} + > + <TextArea rows={4} /> + </Form.Item> + </Col> + <Col span={12}> + <Form.Item + label="瀹℃壒鏃堕棿" + name="affect" + rules={[{ required: true, message: "璇疯緭鍏ュ鎵硅鏄�" }]} + > + <div >{currentTime}</div> + </Form.Item> + </Col> + </Row> + <Row> + <Col span={12}> + <Form.Item + label="閫夋嫨瑕佹墽琛岀殑鎿嶄綔" + labelCol={{ span: 12 }} + name="remarks" + rules={[{ required: true, message: "璇烽�夋嫨瑕佹墽琛岀殑鎿嶄綔" }]} + > + <Radio.Group block options={radioOptions} defaultValue="" /> + </Form.Item> + </Col> + </Row> + </> + ) : null + } + </Form> + </div> + </Modal> + </PageContainer> + ); +}; + +export default personnelRequirementAnalysis; \ No newline at end of file -- Gitblit v1.9.1