drawer.tsx 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. /*
  2. * @Author: code4eat awesomedema@gmail.com
  3. * @Date: 2022-07-13 15:27:51
  4. * @LastEditors: code4eat awesomedema@gmail.com
  5. * @LastEditTime: 2025-02-28 18:15:16
  6. * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/indicatorMana/drawer.tsx
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. import React, { useEffect, useRef, useState } from 'react';
  10. import { Drawer, Cascader, Button, Form } from 'antd';
  11. import ProForm, { ProFormCascader, ProFormDependency, ProFormDigit, ProFormInstance, ProFormRadio, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form';
  12. import './style.less';
  13. import { getIndicatorDictionary, IndicatorDictionaryDataType } from '@/service/dictionary';
  14. import { DefaultOptionType } from 'antd/lib/select';
  15. import { getHospDepartment } from '@/service/department';
  16. import { getUsers } from '@/service/user';
  17. import { addIndicatorManaList } from '@/service/indicator';
  18. import { createFromIconfontCN } from '@ant-design/icons';
  19. export interface IndicatorDrawerForm {
  20. visible: boolean;
  21. record?: any;
  22. onVisibleChange?: (bool: boolean) => void;
  23. onFinish?: (formData: any) => void;
  24. onChange?: (data: any) => void;
  25. actType: 'EDIT' | 'ADD';
  26. }
  27. const IconFont = createFromIconfontCN({
  28. scriptUrl: '',
  29. });
  30. const DrawerForm = (props: IndicatorDrawerForm) => {
  31. const { visible = false, onChange, onFinish, record, onVisibleChange, actType } = props;
  32. const [_visible, _setVisible] = useState(false);
  33. const [renderType, set_renderType] = useState<'ADD' | 'EDIT'>('ADD');
  34. const [dirData, set_dirData] = useState<IndicatorDictionaryDataType[]>([]);
  35. const baseInfoformRef = useRef<ProFormInstance>();
  36. const manaInfoformRef = useRef<ProFormInstance>();
  37. const showSetInfoformRef = useRef<ProFormInstance>();
  38. const adminInfoformRef = useRef<ProFormInstance>();
  39. const showDrawer = () => {
  40. _setVisible(true);
  41. onVisibleChange && onVisibleChange(true);
  42. };
  43. const onClose = () => {
  44. _setVisible(false);
  45. onVisibleChange && onVisibleChange(false);
  46. };
  47. const commitHandle = () => {
  48. let commitData: any[] = [];
  49. if (baseInfoformRef.current && baseInfoformRef.current.validateFieldsReturnFormatValue) {
  50. baseInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => {
  51. commitData.push({
  52. baseInfoformRef: val,
  53. });
  54. });
  55. }
  56. if (manaInfoformRef.current && manaInfoformRef.current.validateFieldsReturnFormatValue) {
  57. manaInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => {
  58. console.log('manaInfoformRef', val);
  59. //_indicatorTypeList
  60. // manaInfoformRef.current?.getFieldsValue();
  61. // console.log('w',manaInfoformRef.current?.getFieldValue('_indicatorTypeList'))
  62. const _indicatorTypeLists = manaInfoformRef.current?.getFieldValue('_indicatorTypeList');
  63. const _indicatorExternalList = manaInfoformRef.current?.getFieldValue('_indicatorExternalList');
  64. // console.log({_indicatorTypeLists,_indicatorExternalList});
  65. commitData.push({
  66. manaInfoformRef: {
  67. ...val,
  68. indicatorTypeList: _indicatorTypeLists ? _indicatorTypeLists : val.indicatorTypeList ? val.indicatorTypeList.map((t: any) => t[t.length - 1]) : [],
  69. indicatorExternalList: _indicatorExternalList ? _indicatorExternalList : val.indicatorExternalList ? val.indicatorExternalList.map((t: any) => t[t.length - 1]) : [],
  70. },
  71. });
  72. });
  73. }
  74. if (showSetInfoformRef.current && showSetInfoformRef.current.validateFieldsReturnFormatValue) {
  75. showSetInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => {
  76. // console.log('showSetInfoformRef',val);
  77. commitData.push({
  78. showSetInfoformRef: val,
  79. });
  80. });
  81. }
  82. if (adminInfoformRef.current && adminInfoformRef.current.validateFieldsReturnFormatValue) {
  83. adminInfoformRef.current?.validateFieldsReturnFormatValue().then((val) => {
  84. const _indicatorMenuList = adminInfoformRef.current?.getFieldValue('_indicatorMenuList');
  85. if (val.indicatorMenuList) {
  86. commitData.push({
  87. adminInfoformRef: {
  88. ...val,
  89. indicatorMenuList: _indicatorMenuList ? _indicatorMenuList : val.indicatorMenuList ? val.indicatorMenuList.map((t: any) => t[t.length - 1]) : [],
  90. },
  91. });
  92. }
  93. });
  94. }
  95. setTimeout(() => {
  96. const hasBaseInfoformRef = commitData.some((item) => item.hasOwnProperty('baseInfoformRef'));
  97. const hasAdminInfoformRef = commitData.some((item) => item.hasOwnProperty('adminInfoformRef'));
  98. if (hasBaseInfoformRef && hasAdminInfoformRef) {
  99. onFinish && onFinish(commitData);
  100. }
  101. }, 1000);
  102. };
  103. const getDataFromDir = async () => {
  104. const dirData = await getIndicatorDictionary();
  105. set_dirData(dirData);
  106. };
  107. const getSelectorData = (code: string, type?: 'Cascader') => {
  108. const result = dirData.filter((t) => t.code == code);
  109. if (type == 'Cascader' && result.length > 0) {
  110. return result[0].children;
  111. }
  112. if (result.length > 0) {
  113. return result[0].children.map((t) => ({ label: t.name, value: t.code }));
  114. }
  115. return [];
  116. };
  117. const setFormInit = (key: string) => {
  118. if (key == 'indicatorTypeList') {
  119. if (record && record.indicatorTypeList) {
  120. const indicatorTypeListVal = record.indicatorTypeList ? record.indicatorTypeList.map((t: string) => t.split('/')) : [];
  121. const _indicatorTypeList = indicatorTypeListVal.map((t: any) => t.slice(1, t.length));
  122. // console.log({indicatorTypeListVal,_indicatorTypeList})
  123. return _indicatorTypeList;
  124. }
  125. }
  126. if (key == 'indicatorMenuList') {
  127. if (record && record.indicatorMenuList) {
  128. const a = record.indicatorMenuList ? record.indicatorMenuList.map((t: string) => t.split('/')) : [];
  129. const b = a.map((t: any) => t.slice(1, t.length));
  130. // console.log({a,b})
  131. return b;
  132. }
  133. }
  134. if (key == 'indicatorExternalList') {
  135. if (record && record.indicatorExternalList) {
  136. const a = record.indicatorExternalList ? record.indicatorExternalList.map((t: string) => t.split('/')) : [];
  137. const b = a.map((t: any) => t.slice(1, t.length));
  138. // console.log({a,b})
  139. return b;
  140. }
  141. }
  142. };
  143. useEffect(() => {
  144. if (visible) {
  145. getDataFromDir();
  146. }
  147. _setVisible(visible);
  148. }, [visible]);
  149. useEffect(() => {
  150. set_renderType(actType);
  151. }, [actType]);
  152. return (
  153. <div>
  154. <Drawer
  155. className="DrawerForm"
  156. width={1000}
  157. title={renderType == 'ADD' ? '新增指标' : '管理信息'}
  158. placement="right"
  159. onClose={onClose}
  160. open={_visible}
  161. destroyOnClose
  162. footer={false}
  163. headerStyle={{ display: 'none' }}
  164. // footer={
  165. // <div>
  166. // <Button style={{ marginRight: 20 }} onClick={() => onClose()}>取消</Button>
  167. // <Button type="primary" onClick={() => commitHandle()}>确定</Button>
  168. // </div>
  169. // }
  170. bodyStyle={{ background: 'rgba(153, 166, 191, 0.1)', padding: 0, scrollbarWidth: 'thin' }}
  171. >
  172. <div className="drawerHeader">
  173. <div className="drawerTitle">
  174. <svg
  175. style={{ marginRight: 14, position: 'relative', top: 4, cursor: 'pointer' }}
  176. onClick={() => _setVisible(false)}
  177. viewBox="0 0 1024 1024"
  178. version="1.1"
  179. xmlns="http://www.w3.org/2000/svg"
  180. p-id="41844"
  181. width="18"
  182. height="18"
  183. >
  184. <path
  185. d="M793.024 200.96l27.392 27.392a12.8 12.8 0 0 1 0 18.112L555.52 510.784l267.392 266.752a12.8 12.8 0 0 1 0 18.112l-27.392 27.328a12.8 12.8 0 0 1-18.112 0L510.08 556.224l-263.424 262.784a12.8 12.8 0 0 1-18.112 0l-27.392-27.392a12.8 12.8 0 0 1 0-18.112l263.36-262.72-260.864-260.288a12.8 12.8 0 0 1 0-18.112l27.392-27.392a12.8 12.8 0 0 1 18.048 0L510.08 465.344l264.96-264.32a12.8 12.8 0 0 1 18.048 0z"
  186. p-id="41845"
  187. fill="#17181A"
  188. ></path>
  189. </svg>
  190. {/* <IconFont style={{cursor:'pointer',marginRight:14,fontSize:16,color:'red'}} type='iconquxiao' /> */}
  191. {record && record.name}
  192. </div>
  193. <div className="btnGroup">
  194. <span onClick={() => onClose()}>取消</span>
  195. <span className="primary" onClick={() => commitHandle()}>
  196. 确定
  197. </span>
  198. </div>
  199. </div>
  200. <div className="drawerContent">
  201. <div className="card">
  202. <div className="cardTitle">指标基本信息</div>
  203. <div className="formContent">
  204. <ProForm
  205. layout={'vertical'}
  206. formRef={baseInfoformRef}
  207. grid={true}
  208. initialValues={renderType == 'ADD' ? { attributeType: 1 } : { ...record }}
  209. rowProps={{
  210. gutter: [16, 0],
  211. }}
  212. submitter={{
  213. render: () => null,
  214. }}
  215. >
  216. <ProFormText colProps={{ md: 12, xl: 8 }} name="name" label="指标名称" placeholder="请输入" fieldProps={{}} rules={[{ required: true, message: '这是必填项' }]} />
  217. <ProFormText colProps={{ md: 12, xl: 8 }} name="code" label="指标编码" placeholder="请输入" rules={[{ required: true, message: '这是必填项' }]} />
  218. <ProFormText colProps={{ md: 12, xl: 8 }} name="nationalCode" label="国家编码" placeholder="请输入" />
  219. <ProFormTextArea
  220. colProps={{ md: 12, xl: 16 }}
  221. name="targetDefinition"
  222. label="指标定义"
  223. placeholder="请输入"
  224. rules={[{ required: true, message: '这是必填项' }]}
  225. fieldProps={{
  226. allowClear: true,
  227. autoSize: true,
  228. }}
  229. />
  230. <ProFormSelect
  231. colProps={{ md: 12, xl: 8 }}
  232. name="dimension"
  233. label="指标维度"
  234. fieldProps={{ size: 'small' }}
  235. options={[
  236. {
  237. label: '结构面',
  238. value: 1,
  239. },
  240. {
  241. label: '过程面',
  242. value: 2,
  243. },
  244. {
  245. label: '结果面',
  246. value: 3,
  247. },
  248. ]}
  249. placeholder="请选择"
  250. />
  251. <ProFormRadio.Group
  252. name="attributeType"
  253. label="指标属性"
  254. colProps={{ md: 12, xl: 24 }}
  255. options={[
  256. {
  257. label: '定性',
  258. value: 1,
  259. },
  260. {
  261. label: '定量',
  262. value: 2,
  263. },
  264. ]}
  265. />
  266. <ProFormDependency name={['attributeType']}>
  267. {({ attributeType }) => {
  268. if (attributeType == 2) {
  269. return (
  270. <>
  271. <ProFormSelect
  272. colProps={{ md: 12, xl: 8 }}
  273. name="directionType"
  274. label="管理指向"
  275. fieldProps={{ size: 'small' }}
  276. options={[
  277. {
  278. label: '正向',
  279. value: 1,
  280. },
  281. {
  282. label: '负向',
  283. value: 2,
  284. },
  285. {
  286. label: '区间',
  287. value: 3,
  288. },
  289. {
  290. label: '监测达标',
  291. value: 4,
  292. },
  293. {
  294. label: '监测比较',
  295. value: 5,
  296. },
  297. ]}
  298. placeholder="请选择"
  299. />
  300. <ProForm.Group colProps={{ md: 12, xl: 8 }}>
  301. <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
  302. <div>
  303. <ProFormDigit label="指标区间" name="lowerLimit" min={0} max={10000} placeholder="最小值" fieldProps={{ precision: 3 }} />
  304. </div>
  305. -
  306. <div style={{ position: 'relative', top: 10 }}>
  307. <ProFormDigit name="upperLimit" min={0} max={10000} placeholder="最大值" fieldProps={{ precision: 3 }} />
  308. </div>
  309. </div>
  310. </ProForm.Group>
  311. <ProFormSelect
  312. colProps={{ md: 12, xl: 8 }}
  313. name="unit"
  314. label="单位"
  315. fieldProps={{ size: 'small' }}
  316. request={async () => {
  317. const dirData = await getIndicatorDictionary();
  318. const result = dirData.filter((t) => t.code == 'Department');
  319. if (result.length > 0) {
  320. return result[0].children.map((t) => ({ label: t.name, value: t.code }));
  321. }
  322. return [];
  323. }}
  324. placeholder="请选择"
  325. />
  326. <ProFormDependency name={['unit']}>
  327. {({ unit }) => {
  328. return unit == '173' || unit == '326' ? (
  329. <ProForm.Group colProps={{ md: 12, xl: 24 }}>
  330. <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
  331. <div>
  332. <ProFormText name="molecule" label="公式" width={437} placeholder="请输入分子" />
  333. </div>
  334. /
  335. <div style={{ position: 'relative', top: 10 }}>
  336. <ProFormText width={437} name="denominator" placeholder="请输入分母" />
  337. </div>
  338. {unit == '173' ? `*100%` : `‰`}
  339. </div>
  340. </ProForm.Group>
  341. ) : (
  342. <ProForm.Group colProps={{ md: 12, xl: 24 }}>
  343. <ProFormText name="molecule" label="公式" placeholder="请输入公式" />
  344. </ProForm.Group>
  345. );
  346. }}
  347. </ProFormDependency>
  348. <ProFormSelect
  349. colProps={{ md: 12, xl: 8 }}
  350. name="moleculeSourcType"
  351. label="分子数据来源"
  352. fieldProps={{ size: 'small' }}
  353. options={[
  354. {
  355. label: '定期填报',
  356. value: 1,
  357. },
  358. {
  359. label: '表单导入',
  360. value: 2,
  361. },
  362. {
  363. label: '系统导入',
  364. value: 3,
  365. },
  366. {
  367. label: '异动时填报',
  368. value: 4,
  369. },
  370. ]}
  371. placeholder="请选择"
  372. />
  373. {/* <ProFormText colProps={{ md: 12, xl: 8 }} name="moleculeSourcDesc" label='分子来源说明' placeholder="请输入" /> */}
  374. <ProFormTextArea
  375. colProps={{ md: 12, xl: 16 }}
  376. name="moleculeSourcDesc"
  377. label="分子来源说明"
  378. placeholder="请输入"
  379. fieldProps={{
  380. allowClear: true,
  381. autoSize: true,
  382. size: 'small',
  383. }}
  384. />
  385. <ProFormSelect
  386. colProps={{ md: 12, xl: 8 }}
  387. name="denominatorSourceType"
  388. label="分母数据来源"
  389. fieldProps={{ size: 'small' }}
  390. options={[
  391. {
  392. label: '定期填报',
  393. value: 1,
  394. },
  395. {
  396. label: '表单导入',
  397. value: 2,
  398. },
  399. {
  400. label: '系统导入',
  401. value: 3,
  402. },
  403. {
  404. label: '异动时填报',
  405. value: 4,
  406. },
  407. ]}
  408. placeholder="请选择"
  409. />
  410. {/* <ProFormText colProps={{ md: 12, xl: 8 }} name="denominatorSourceDesc" label='分母来源说明' placeholder="请输入" /> */}
  411. <ProFormTextArea
  412. colProps={{ md: 12, xl: 16 }}
  413. name="denominatorSourceDesc"
  414. label="分母来源说明"
  415. placeholder="请输入"
  416. fieldProps={{
  417. allowClear: true,
  418. autoSize: true,
  419. }}
  420. />
  421. </>
  422. );
  423. }
  424. }}
  425. </ProFormDependency>
  426. </ProForm>
  427. </div>
  428. </div>
  429. <div className="card">
  430. <div className="cardTitle">指标管理信息</div>
  431. <div className="formContent">
  432. <ProForm
  433. formRef={manaInfoformRef}
  434. layout={'vertical'}
  435. autoFocusFirstInput={false}
  436. grid={true}
  437. initialValues={
  438. renderType == 'ADD'
  439. ? { indicatorTypeList: [], indicatorExternalList: [] }
  440. : {
  441. ...record,
  442. indicatorMenuList: setFormInit('indicatorMenuList'),
  443. // indicatorTypeList:record.indicatorTypeList?record.indicatorTypeList.map((t:string)=>t.split('/')).slice(1,record.indicatorTypeList.map((t:string)=>t.split('/')).length - 1):[],
  444. indicatorTypeList: setFormInit('indicatorTypeList'),
  445. indicatorExternalList: setFormInit('indicatorExternalList'),
  446. // indicatorCommitteeList:record.indicatorCommitteeList[0]?record.indicatorCommitteeList[0].split('/'):[]
  447. }
  448. }
  449. rowProps={{
  450. gutter: [16, 0],
  451. }}
  452. submitter={{
  453. render: () => null,
  454. }}
  455. >
  456. <ProFormSelect
  457. colProps={{ md: 12, xl: 8 }}
  458. name="divisionId"
  459. label="负责科室"
  460. fieldProps={{ size: 'small' }}
  461. request={async () => {
  462. const data = await getHospDepartment();
  463. return data.map((t) => ({ label: t.name, value: t.code }));
  464. }}
  465. placeholder="请选择"
  466. />
  467. <ProFormSelect
  468. colProps={{ md: 12, xl: 8 }}
  469. name="principalId"
  470. label="负责人"
  471. fieldProps={{ size: 'small' }}
  472. request={async () => {
  473. const data = await getUsers({ pageSize: 1000, current: 1 });
  474. return data.list.map((t) => ({ label: t.name, value: t.code }));
  475. }}
  476. placeholder="请选择"
  477. />
  478. {/* <ProFormSelect
  479. colProps={{ md: 12, xl: 8 }}
  480. name="principalId"
  481. label="负责人"
  482. request={async ()=>{
  483. const data = await getUsers({pageSize:1000,current:1});
  484. return data.list.map(t=>({label:t.name,value:t.code}))
  485. }}
  486. placeholder="请选择"
  487. /> */}
  488. <ProFormSelect
  489. colProps={{ md: 12, xl: 8 }}
  490. name="manageLevel"
  491. label="指标管理级别"
  492. fieldProps={{
  493. // mode: 'multiple',
  494. size: 'small',
  495. maxTagCount: 'responsive',
  496. }}
  497. options={[
  498. {
  499. label: '院级指标/日常',
  500. value: 0,
  501. },
  502. {
  503. label: '院级指标/重点监测',
  504. value: 1,
  505. },
  506. {
  507. label: '科级指标/日常',
  508. value: 2,
  509. },
  510. {
  511. label: '科级指标/重点监测',
  512. value: 3,
  513. },
  514. ]}
  515. placeholder="请选择"
  516. />
  517. <ProFormSelect
  518. colProps={{ md: 12, xl: 8 }}
  519. name="analysisType"
  520. label="分析方式"
  521. fieldProps={{ size: 'small' }}
  522. options={[
  523. {
  524. label: '数值',
  525. value: 1,
  526. },
  527. {
  528. label: '监测比较',
  529. value: 2,
  530. },
  531. {
  532. label: '目标值达标分析',
  533. value: 3,
  534. },
  535. {
  536. label: '数值趋势分析',
  537. value: 4,
  538. },
  539. {
  540. label: '标准差异常分析',
  541. value: 5,
  542. },
  543. {
  544. label: '四分位数值分析',
  545. value: 6,
  546. },
  547. ]}
  548. placeholder="请选择"
  549. />
  550. {/* <Form.Item >
  551. <DiyFormCascader data={getSelectorData('IndicatorType', 'Cascader')} />
  552. </Form.Item> */}
  553. <ProFormCascader
  554. colProps={{ md: 12, xl: 8 }}
  555. name="indicatorTypeList"
  556. label="指标类别"
  557. fieldProps={{
  558. size: 'small',
  559. maxTagCount: 'responsive',
  560. multiple: true,
  561. showCheckedStrategy: 'SHOW_CHILD',
  562. fieldNames: { label: 'name', value: 'code', children: 'children' },
  563. options: getSelectorData('IndicatorType', 'Cascader'),
  564. onChange(value, selectOptions) {
  565. console.log({ value, selectOptions });
  566. var nodes: any[] = [];
  567. function parseTreeJson(array: any[]) {
  568. if (!array) return [];
  569. for (let index = 0; index < array.length; index++) {
  570. const element = array[index];
  571. // 判断element.children是对象
  572. if (element.children && typeof element.children == 'object') {
  573. parseTreeJson(element.children);
  574. } else {
  575. // 判断是否为子节点
  576. if (!(element.children || typeof element.children == 'object')) {
  577. // 获得符合的 node
  578. nodes.push(element);
  579. }
  580. }
  581. }
  582. }
  583. if (value.length > 0) {
  584. for (let index = 0; index < value.length; index++) {
  585. let current = value[index];
  586. let key = current[current.length - 1];
  587. const result = selectOptions[index].filter((t: any) => t.code == key);
  588. if (result[0].children) {
  589. //非直接叶子节点
  590. parseTreeJson(result[0].children);
  591. }
  592. if (!result[0].children) {
  593. //直接叶子节点
  594. nodes.push({ code: result[0].code });
  595. }
  596. }
  597. }
  598. const codes = nodes.map((t) => t.code);
  599. manaInfoformRef.current?.setFieldsValue({ _indicatorTypeList: codes });
  600. },
  601. }}
  602. />
  603. <ProFormText label="管理目标值" colProps={{ md: 12, xl: 8 }} name="targetValue" />
  604. <ProFormSelect
  605. colProps={{ md: 12, xl: 8 }}
  606. name="indicatorDepartmentList"
  607. label="职能科室归属"
  608. fieldProps={{
  609. mode: 'multiple',
  610. size: 'small',
  611. maxTagCount: 'responsive',
  612. }}
  613. options={getSelectorData('IndicatorDepartment') as DefaultOptionType[]}
  614. placeholder="请选择"
  615. />
  616. <ProFormDigit colProps={{ md: 12, xl: 8 }} name="reference" label="同级参考值" placeholder="请输入" />
  617. {/* <ProFormText colProps={{ md: 12, xl: 8 }} name="referenceDesc" label="参考值来源说明" placeholder="请输入" /> */}
  618. <ProFormTextArea
  619. colProps={{ md: 12, xl: 8 }}
  620. name="referenceDesc"
  621. label="参考值来源说明"
  622. placeholder="请输入"
  623. fieldProps={{
  624. allowClear: true,
  625. autoSize: true,
  626. size: 'small',
  627. }}
  628. />
  629. <ProFormSelect
  630. colProps={{ md: 12, xl: 8 }}
  631. name="indicatorCommitteeList"
  632. label="委员会归属"
  633. fieldProps={{
  634. size: 'small',
  635. mode: 'multiple',
  636. maxTagCount: 'responsive',
  637. }}
  638. options={getSelectorData('IndicatorCommittee') as DefaultOptionType[]}
  639. placeholder="请选择"
  640. />
  641. <ProFormCascader
  642. colProps={{ md: 12, xl: 8 }}
  643. name="indicatorExternalList"
  644. label="外部指标"
  645. fieldProps={{
  646. size: 'small',
  647. multiple: true,
  648. maxTagCount: 'responsive',
  649. fieldNames: { label: 'name', value: 'code', children: 'children' },
  650. options: getSelectorData('IndicatorExternal', 'Cascader'),
  651. onChange(value, selectOptions) {
  652. // console.log({ value, selectOptions });
  653. var nodes: any[] = [];
  654. function parseTreeJson(array: any[]) {
  655. if (!array) return [];
  656. for (let index = 0; index < array.length; index++) {
  657. const element = array[index];
  658. // 判断element.children是对象
  659. if (element.children && typeof element.children == 'object') {
  660. parseTreeJson(element.children);
  661. } else {
  662. // 判断是否为子节点
  663. if (!(element.children || typeof element.children == 'object')) {
  664. // 获得符合的 node
  665. nodes.push(element);
  666. }
  667. }
  668. }
  669. }
  670. if (value.length > 0) {
  671. for (let index = 0; index < value.length; index++) {
  672. let current = value[index];
  673. let key = current[current.length - 1];
  674. const result = selectOptions[index].filter((t: any) => t.code == key);
  675. console.log({ result });
  676. if (result[0].children) {
  677. //非直接叶子节点
  678. parseTreeJson(result[0].children);
  679. }
  680. if (!result[0].children) {
  681. //直接叶子节点
  682. nodes.push({ code: result[0].code });
  683. }
  684. }
  685. }
  686. const codes = nodes.map((t) => t.code);
  687. manaInfoformRef.current?.setFieldsValue({ _indicatorExternalList: codes });
  688. },
  689. }}
  690. />
  691. {/* <ProFormText colProps={{ md: 12, xl: 8 }} name="remark" label="其他备注" placeholder="请输入" /> */}
  692. <ProFormTextArea
  693. colProps={{ md: 12, xl: 8 }}
  694. name="remark"
  695. label="其他备注"
  696. placeholder="请输入"
  697. fieldProps={{
  698. allowClear: true,
  699. autoSize: true,
  700. size: 'small',
  701. }}
  702. />
  703. </ProForm>
  704. </div>
  705. </div>
  706. <div className="card">
  707. <div className="cardTitle">指标展示设定</div>
  708. <div className="formContent">
  709. <ProForm
  710. formRef={showSetInfoformRef}
  711. layout={'vertical'}
  712. grid={true}
  713. autoFocusFirstInput={false}
  714. rowProps={{
  715. gutter: [16, 0],
  716. }}
  717. initialValues={
  718. renderType == 'ADD'
  719. ? {}
  720. : renderType == 'EDIT' && record
  721. ? {
  722. ...record,
  723. caseBreakdown: record.caseBreakdown ? record.caseBreakdown.split('/') : [],
  724. chartType: record.chartType ? record.chartType.split('/') : [],
  725. dataDownload: record.dataDownload ? record.dataDownload.split('/') : [],
  726. dataSum: record.dataSum ? record.dataSum.split('/') : [],
  727. drillLevel: record.drillLevel ? record.drillLevel.split('/') : [],
  728. }
  729. : {}
  730. }
  731. submitter={{
  732. render: () => null,
  733. }}
  734. >
  735. <ProFormSelect
  736. colProps={{ md: 12, xl: 8 }}
  737. name="appearDate"
  738. label="呈现期间"
  739. fieldProps={{ size: 'small' }}
  740. options={[
  741. {
  742. label: '年',
  743. value: '年',
  744. },
  745. {
  746. label: '季',
  747. value: '季',
  748. },
  749. {
  750. label: '月',
  751. value: '月',
  752. },
  753. ]}
  754. placeholder="请选择"
  755. />
  756. <ProFormSelect
  757. colProps={{ md: 12, xl: 8 }}
  758. name="chartType"
  759. label="图表形态"
  760. fieldProps={{
  761. size: 'small',
  762. mode: 'multiple',
  763. maxTagCount: 'responsive',
  764. }}
  765. options={[
  766. {
  767. label: '统计表',
  768. value: '统计表',
  769. },
  770. {
  771. label: '直方图',
  772. value: '直方图',
  773. },
  774. {
  775. label: '趋势图',
  776. value: '趋势图',
  777. },
  778. {
  779. label: '其他',
  780. value: '其他',
  781. },
  782. ]}
  783. placeholder="请选择"
  784. />
  785. <ProFormSelect
  786. colProps={{ md: 12, xl: 8 }}
  787. name="dataSum"
  788. label="数据汇总呈现"
  789. fieldProps={{
  790. size: 'small',
  791. mode: 'multiple',
  792. maxTagCount: 'responsive',
  793. }}
  794. options={[
  795. { label: '全院', value: '全院' },
  796. { label: '分院', value: '分院' },
  797. ]}
  798. placeholder="请选择"
  799. />
  800. <ProFormSelect
  801. colProps={{ md: 12, xl: 8 }}
  802. name="drillLevel"
  803. label="资料下钻层级"
  804. fieldProps={{
  805. size: 'small',
  806. mode: 'multiple',
  807. maxTagCount: 'responsive',
  808. }}
  809. options={[
  810. {
  811. label: '全院',
  812. value: '全院',
  813. },
  814. {
  815. label: '分院区',
  816. value: '分院区',
  817. },
  818. {
  819. label: '科别',
  820. value: '科别',
  821. },
  822. {
  823. label: '医师别',
  824. value: '医师别',
  825. },
  826. {
  827. label: '个案',
  828. value: '个案',
  829. },
  830. ]}
  831. placeholder="请选择"
  832. />
  833. <ProFormSelect
  834. colProps={{ md: 12, xl: 8 }}
  835. name="dataDownload"
  836. label="资料下载"
  837. fieldProps={{
  838. size: 'small',
  839. mode: 'multiple',
  840. maxTagCount: 'responsive',
  841. }}
  842. options={[
  843. {
  844. label: '全院',
  845. value: '全院',
  846. },
  847. {
  848. label: '分院区',
  849. value: '分院区',
  850. },
  851. {
  852. label: '科别',
  853. value: '科别',
  854. },
  855. {
  856. label: '医师别',
  857. value: '医师别',
  858. },
  859. {
  860. label: '个案数',
  861. value: '个案数',
  862. },
  863. ]}
  864. placeholder="请选择"
  865. />
  866. <ProFormSelect
  867. colProps={{ md: 12, xl: 8 }}
  868. name="caseBreakdown"
  869. label="个案明细字段"
  870. fieldProps={{
  871. size: 'small',
  872. mode: 'multiple',
  873. maxTagCount: 'responsive',
  874. }}
  875. options={[
  876. {
  877. label: '看诊科别',
  878. value: '看诊科别',
  879. },
  880. {
  881. label: '就诊日期',
  882. value: '就诊日期',
  883. },
  884. {
  885. label: '住院科别',
  886. value: '住院科别',
  887. },
  888. {
  889. label: '出院科别',
  890. value: '出院科别',
  891. },
  892. {
  893. label: '病历号',
  894. value: '病历号',
  895. },
  896. {
  897. label: '住院日期时间',
  898. value: '住院日期时间',
  899. },
  900. {
  901. label: '转出日期',
  902. value: '转出日期',
  903. },
  904. {
  905. label: '出院日期时间',
  906. value: '出院日期时间',
  907. },
  908. {
  909. label: '出院类别',
  910. value: '出院类别',
  911. },
  912. {
  913. label: '出院诊断码',
  914. value: '出院诊断码',
  915. },
  916. {
  917. label: '合并症码',
  918. value: '合并症码',
  919. },
  920. {
  921. label: '死亡原因',
  922. value: '死亡原因',
  923. },
  924. {
  925. label: '手术代码',
  926. value: '手术代码',
  927. },
  928. {
  929. label: '其他',
  930. value: '其他',
  931. },
  932. ]}
  933. placeholder="请选择"
  934. />
  935. </ProForm>
  936. </div>
  937. </div>
  938. <div className="card">
  939. <div className="cardTitle">管理员维护信息</div>
  940. <div className="formContent">
  941. <ProForm
  942. formRef={adminInfoformRef}
  943. layout={'vertical'}
  944. grid={true}
  945. autoFocusFirstInput={false}
  946. initialValues={
  947. renderType == 'ADD'
  948. ? { isPublic: 1 }
  949. : renderType == 'EDIT' && record
  950. ? {
  951. ...record,
  952. indicatorMenuList: setFormInit('indicatorMenuList'),
  953. }
  954. : {}
  955. }
  956. rowProps={{
  957. gutter: [16, 0],
  958. }}
  959. submitter={{
  960. render: () => null,
  961. }}
  962. >
  963. <ProFormCascader
  964. colProps={{ md: 12, xl: 8 }}
  965. name="indicatorMenuList"
  966. label="指标目录"
  967. rules={[{ required: true, message: '这是必填项' }]}
  968. fieldProps={{
  969. size: 'small',
  970. multiple: true,
  971. fieldNames: { label: 'name', value: 'code' },
  972. onChange(value: any, selectOptions: any) {
  973. console.log({ value, selectOptions });
  974. var nodes: any[] = [];
  975. function parseTreeJson(array: any[]) {
  976. if (!array) return [];
  977. for (let index = 0; index < array.length; index++) {
  978. const element = array[index];
  979. // 判断element.children是对象
  980. if (element.children && typeof element.children == 'object') {
  981. parseTreeJson(element.children);
  982. } else {
  983. // 判断是否为子节点
  984. if (!(element.children || typeof element.children == 'object')) {
  985. // 获得符合的 node
  986. nodes.push(element);
  987. }
  988. }
  989. }
  990. }
  991. if (value.length > 0) {
  992. for (let index = 0; index < value.length; index++) {
  993. let current = value[index];
  994. let key = current[current.length - 1];
  995. const result = selectOptions[index].filter((t: any) => t.code == key);
  996. // console.log({result});
  997. if (result[0].children) {
  998. //非直接叶子节点
  999. parseTreeJson(result[0].children);
  1000. }
  1001. if (!result[0].children) {
  1002. //直接叶子节点
  1003. nodes.push({ code: result[0].code });
  1004. }
  1005. }
  1006. }
  1007. const codes = nodes.map((t) => t.code);
  1008. console.log({ codes, nodes });
  1009. adminInfoformRef.current?.setFieldsValue({ _indicatorMenuList: codes });
  1010. },
  1011. }}
  1012. request={async () => {
  1013. if (location.search.length > 0) {
  1014. const id = location.search.split('=')[1];
  1015. if (id) {
  1016. const dirData = await getIndicatorDictionary();
  1017. if (dirData) {
  1018. const result = dirData.filter((t) => t.code == id);
  1019. if (result.length > 0) {
  1020. return result[0].children;
  1021. }
  1022. }
  1023. return [];
  1024. }
  1025. }
  1026. return [];
  1027. }}
  1028. placeholder="请选择"
  1029. />
  1030. <ProFormSelect
  1031. colProps={{ md: 12, xl: 8 }}
  1032. name="isPublic"
  1033. label="是否公开"
  1034. fieldProps={{ size: 'small' }}
  1035. options={[
  1036. {
  1037. label: '是',
  1038. value: 1,
  1039. },
  1040. {
  1041. label: '否',
  1042. value: 0,
  1043. },
  1044. ]}
  1045. placeholder="请选择"
  1046. />
  1047. <ProFormSelect
  1048. colProps={{ md: 12, xl: 8 }}
  1049. name="version"
  1050. label="版本"
  1051. fieldProps={{ size: 'small' }}
  1052. options={[
  1053. {
  1054. label: '版本1',
  1055. value: 1,
  1056. },
  1057. {
  1058. label: '版本2',
  1059. value: 2,
  1060. },
  1061. {
  1062. label: '版本3',
  1063. value: 3,
  1064. },
  1065. ]}
  1066. placeholder="请选择"
  1067. />
  1068. </ProForm>
  1069. </div>
  1070. </div>
  1071. </div>
  1072. </Drawer>
  1073. </div>
  1074. );
  1075. };
  1076. export default DrawerForm;