/* * @Author: code4eat awesomedema@gmail.com * @Date: 2022-07-13 15:27:51 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2025-02-28 18:15:16 * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/indicatorMana/drawer.tsx * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import React, { useEffect, useRef, useState } from 'react'; import { Drawer, Cascader, Button, Form } from 'antd'; import ProForm, { ProFormCascader, ProFormDependency, ProFormDigit, ProFormInstance, ProFormRadio, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; import './style.less'; import { getIndicatorDictionary, IndicatorDictionaryDataType } from '@/service/dictionary'; import { DefaultOptionType } from 'antd/lib/select'; import { getHospDepartment } from '@/service/department'; import { getUsers } from '@/service/user'; import { addIndicatorManaList } from '@/service/indicator'; import { createFromIconfontCN } from '@ant-design/icons'; export interface IndicatorDrawerForm { visible: boolean; record?: any; onVisibleChange?: (bool: boolean) => void; onFinish?: (formData: any) => void; onChange?: (data: any) => void; actType: 'EDIT' | 'ADD'; } const IconFont = createFromIconfontCN({ scriptUrl: '', }); const DrawerForm = (props: IndicatorDrawerForm) => { const { visible = false, onChange, onFinish, record, onVisibleChange, actType } = props; const [_visible, _setVisible] = useState(false); const [renderType, set_renderType] = useState<'ADD' | 'EDIT'>('ADD'); const [dirData, set_dirData] = useState([]); const baseInfoformRef = useRef(); const manaInfoformRef = useRef(); const showSetInfoformRef = useRef(); const adminInfoformRef = useRef(); const showDrawer = () => { _setVisible(true); onVisibleChange && onVisibleChange(true); }; const onClose = () => { _setVisible(false); onVisibleChange && onVisibleChange(false); }; const commitHandle = () => { let commitData: any[] = []; if (baseInfoformRef.current && baseInfoformRef.current.validateFieldsReturnFormatValue) { baseInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => { commitData.push({ baseInfoformRef: val, }); }); } if (manaInfoformRef.current && manaInfoformRef.current.validateFieldsReturnFormatValue) { manaInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => { console.log('manaInfoformRef', val); //_indicatorTypeList // manaInfoformRef.current?.getFieldsValue(); // console.log('w',manaInfoformRef.current?.getFieldValue('_indicatorTypeList')) const _indicatorTypeLists = manaInfoformRef.current?.getFieldValue('_indicatorTypeList'); const _indicatorExternalList = manaInfoformRef.current?.getFieldValue('_indicatorExternalList'); // console.log({_indicatorTypeLists,_indicatorExternalList}); commitData.push({ manaInfoformRef: { ...val, indicatorTypeList: _indicatorTypeLists ? _indicatorTypeLists : val.indicatorTypeList ? val.indicatorTypeList.map((t: any) => t[t.length - 1]) : [], indicatorExternalList: _indicatorExternalList ? _indicatorExternalList : val.indicatorExternalList ? val.indicatorExternalList.map((t: any) => t[t.length - 1]) : [], }, }); }); } if (showSetInfoformRef.current && showSetInfoformRef.current.validateFieldsReturnFormatValue) { showSetInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => { // console.log('showSetInfoformRef',val); commitData.push({ showSetInfoformRef: val, }); }); } if (adminInfoformRef.current && adminInfoformRef.current.validateFieldsReturnFormatValue) { adminInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => { const _indicatorMenuList = adminInfoformRef.current?.getFieldValue('_indicatorMenuList'); if (val.indicatorMenuList) { commitData.push({ adminInfoformRef: { ...val, indicatorMenuList: _indicatorMenuList ? _indicatorMenuList : val.indicatorMenuList ? val.indicatorMenuList.map((t: any) => t[t.length - 1]) : [], }, }); } }); } setTimeout(() => { const hasBaseInfoformRef = commitData.some((item) => item.hasOwnProperty('baseInfoformRef')); const hasAdminInfoformRef = commitData.some((item) => item.hasOwnProperty('adminInfoformRef')); if (hasBaseInfoformRef && hasAdminInfoformRef) { onFinish && onFinish(commitData); } }, 1000); }; const getDataFromDir = async () => { const dirData = await getIndicatorDictionary(); set_dirData(dirData); }; const getSelectorData = (code: string, type?: 'Cascader') => { const result = dirData.filter((t) => t.code == code); if (type == 'Cascader' && result.length > 0) { return result[0].children; } if (result.length > 0) { return result[0].children.map((t) => ({ label: t.name, value: t.code })); } return []; }; const setFormInit = (key: string) => { if (key == 'indicatorTypeList') { if (record && record.indicatorTypeList) { const indicatorTypeListVal = record.indicatorTypeList ? record.indicatorTypeList.map((t: string) => t.split('/')) : []; const _indicatorTypeList = indicatorTypeListVal.map((t: any) => t.slice(1, t.length)); // console.log({indicatorTypeListVal,_indicatorTypeList}) return _indicatorTypeList; } } if (key == 'indicatorMenuList') { if (record && record.indicatorMenuList) { const a = record.indicatorMenuList ? record.indicatorMenuList.map((t: string) => t.split('/')) : []; const b = a.map((t: any) => t.slice(1, t.length)); // console.log({a,b}) return b; } } if (key == 'indicatorExternalList') { if (record && record.indicatorExternalList) { const a = record.indicatorExternalList ? record.indicatorExternalList.map((t: string) => t.split('/')) : []; const b = a.map((t: any) => t.slice(1, t.length)); // console.log({a,b}) return b; } } }; useEffect(() => { if (visible) { getDataFromDir(); } _setVisible(visible); }, [visible]); useEffect(() => { set_renderType(actType); }, [actType]); return (
// // //
// } bodyStyle={{ background: 'rgba(153, 166, 191, 0.1)', padding: 0, scrollbarWidth: 'thin' }} >
_setVisible(false)} viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="41844" width="18" height="18" > {/* */} {record && record.name}
onClose()}>取消 commitHandle()}> 确定
指标基本信息
null, }} > {({ attributeType }) => { if (attributeType == 2) { return ( <>
-
{ const dirData = await getIndicatorDictionary(); const result = dirData.filter((t) => t.code == 'Department'); if (result.length > 0) { return result[0].children.map((t) => ({ label: t.name, value: t.code })); } return []; }} placeholder="请选择" /> {({ unit }) => { return unit == '173' || unit == '326' ? (
/
{unit == '173' ? `*100%` : `‰`}
) : ( ); }}
{/* */} {/* */} ); } }}
指标管理信息
t.split('/')).slice(1,record.indicatorTypeList.map((t:string)=>t.split('/')).length - 1):[], indicatorTypeList: setFormInit('indicatorTypeList'), indicatorExternalList: setFormInit('indicatorExternalList'), // indicatorCommitteeList:record.indicatorCommitteeList[0]?record.indicatorCommitteeList[0].split('/'):[] } } rowProps={{ gutter: [16, 0], }} submitter={{ render: () => null, }} > { const data = await getHospDepartment(); return data.map((t) => ({ label: t.name, value: t.code })); }} placeholder="请选择" /> { const data = await getUsers({ pageSize: 1000, current: 1 }); return data.list.map((t) => ({ label: t.name, value: t.code })); }} placeholder="请选择" /> {/* { const data = await getUsers({pageSize:1000,current:1}); return data.list.map(t=>({label:t.name,value:t.code})) }} placeholder="请选择" /> */} {/* */} 0) { for (let index = 0; index < value.length; index++) { let current = value[index]; let key = current[current.length - 1]; const result = selectOptions[index].filter((t: any) => t.code == key); if (result[0].children) { //非直接叶子节点 parseTreeJson(result[0].children); } if (!result[0].children) { //直接叶子节点 nodes.push({ code: result[0].code }); } } } const codes = nodes.map((t) => t.code); manaInfoformRef.current?.setFieldsValue({ _indicatorTypeList: codes }); }, }} /> {/* */} 0) { for (let index = 0; index < value.length; index++) { let current = value[index]; let key = current[current.length - 1]; const result = selectOptions[index].filter((t: any) => t.code == key); console.log({ result }); if (result[0].children) { //非直接叶子节点 parseTreeJson(result[0].children); } if (!result[0].children) { //直接叶子节点 nodes.push({ code: result[0].code }); } } } const codes = nodes.map((t) => t.code); manaInfoformRef.current?.setFieldsValue({ _indicatorExternalList: codes }); }, }} /> {/* */}
指标展示设定
null, }} >
管理员维护信息
null, }} > 0) { for (let index = 0; index < value.length; index++) { let current = value[index]; let key = current[current.length - 1]; const result = selectOptions[index].filter((t: any) => t.code == key); // console.log({result}); if (result[0].children) { //非直接叶子节点 parseTreeJson(result[0].children); } if (!result[0].children) { //直接叶子节点 nodes.push({ code: result[0].code }); } } } const codes = nodes.map((t) => t.code); console.log({ codes, nodes }); adminInfoformRef.current?.setFieldsValue({ _indicatorMenuList: codes }); }, }} request={async () => { if (location.search.length > 0) { const id = location.search.split('=')[1]; if (id) { const dirData = await getIndicatorDictionary(); if (dirData) { const result = dirData.filter((t) => t.code == id); if (result.length > 0) { return result[0].children; } } return []; } } return []; }} placeholder="请选择" />
); }; export default DrawerForm;