index.tsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /*
  2. * @Author: code4eat awesomedema@gmail.com
  3. * @Date: 2023-03-03 11:30:33
  4. * @LastEditors: code4eat awesomedema@gmail.com
  5. * @LastEditTime: 2024-09-09 10:47:11
  6. * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. import KCIMPagecontainer from '@/components/KCIMPageContainer';
  10. import { KCIMTable } from '@/components/KCIMTable';
  11. import { formatMoneyNumber } from '@/utils/format';
  12. import { createFromIconfontCN } from '@ant-design/icons';
  13. import FormItem from 'antd/es/form/FormItem';
  14. import { ActionType, ProFormInstance, ProFormText } from '@ant-design/pro-components';
  15. import { ModalForm,ProFormSelect, ProFormSwitch } from '@ant-design/pro-form'
  16. import { ProColumns } from '@ant-design/pro-table';
  17. import { Input, message, Popconfirm, Modal } from 'antd';
  18. import { useEffect, useRef, useState } from 'react';
  19. import 'moment/locale/zh-cn';
  20. import locale from 'antd/es/date-picker/locale/zh_CN';
  21. import { addData, delData, editData, getDiseaseComparisonTableData, importDataPost, matchDiseaseTypeMap } from './service';
  22. import './style.less';
  23. import KCIMUpload from '@/components/KCIMUpload';
  24. import { downloadTemplateReq } from '@/utils/tooljs';
  25. import { getDiseaseTableData } from '../diseaseMana/service';
  26. const IconFont = createFromIconfontCN({
  27. scriptUrl: '',
  28. });
  29. export default function DiseaseDiagnosisComparison() {
  30. const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
  31. const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState<string>('');
  32. const tableRef = useRef<ActionType>();
  33. const formRef = useRef<ProFormInstance>();
  34. const [stopStat, set_stopStat] = useState(0);
  35. const columns: ProColumns[] = [
  36. {
  37. title: '诊断代码',
  38. dataIndex: 'diagCode',
  39. },
  40. {
  41. title: '诊断名称',
  42. dataIndex: 'diagName',
  43. },
  44. {
  45. title: '国家编码',
  46. dataIndex: 'icdCode',
  47. },
  48. {
  49. title: '病种编码',
  50. dataIndex: 'diseaseTypeCode',
  51. },
  52. {
  53. title: '病种名称',
  54. dataIndex: 'diseaseTypeCodeName',
  55. },
  56. {
  57. title: '操作',
  58. key: 'option',
  59. width: 90,
  60. valueType: 'option',
  61. render: (_: any, record: any) => {
  62. return [
  63. <UpDataActBtn key={'act'} record={record} type='EDIT' />,
  64. <Popconfirm
  65. title="是否确认删除?"
  66. key="del"
  67. onConfirm={() => delTableData(record)}
  68. >
  69. <a>删除</a>
  70. </Popconfirm>,
  71. ]
  72. },
  73. },
  74. ]
  75. const getTableData = async (params: any) => {
  76. const resp = await getDiseaseComparisonTableData({ ...params,type:stopStat });
  77. if (resp) {
  78. return {
  79. data: resp.list,
  80. success: true,
  81. total: resp.totalCount,
  82. pageSize: resp.pageSize,
  83. totalPage: resp.totalPage,
  84. }
  85. }
  86. return []
  87. }
  88. const delTableData = async (record: any) => {
  89. const resp = await delData(record.id);
  90. if (resp) {
  91. message.success('操作成功!');
  92. tableRef.current?.reload();
  93. // message.success('操作成功!');
  94. }
  95. }
  96. const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => {
  97. const result = {
  98. ...formVal,
  99. diseaseTypeCode:formVal.diseaseTypeCode == -1?'':formVal.diseaseTypeCode
  100. }
  101. if (type == 'ADD') {
  102. const resp = await addData(result);
  103. if (resp) {
  104. tableRef.current?.reload();
  105. message.success('操作成功!');
  106. }
  107. }
  108. if (type == 'EDIT') {
  109. const resp = await editData({
  110. ...result,
  111. diseaseTypeCodeName:formVal.diseaseTypeCode == -1?'':formVal.diseaseTypeCodeName
  112. });
  113. if (resp) {
  114. tableRef.current?.reload();
  115. message.success('操作成功!');
  116. }
  117. }
  118. return true;
  119. }
  120. const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD'}) => {
  121. return (
  122. <ModalForm
  123. title={`${type == 'EDIT' ? '编辑' : '新增'}诊断`}
  124. width={350}
  125. formRef={formRef}
  126. initialValues={type == 'EDIT' ? {
  127. ...record,
  128. diseaseTypeCode:record.diseaseTypeCode?record.diseaseTypeCode:-1
  129. } : {diseaseTypeCode:-1}}
  130. trigger={
  131. type == 'EDIT' ? <a key="edit" >编辑</a> : <a className='add'>新增</a>
  132. }
  133. onFinish={(val) => {
  134. return updateTable(type == 'EDIT' ? { ...record, ...val } :{ ...val}, type);
  135. }}
  136. modalProps={{ destroyOnClose: true }}
  137. colProps={{ span: 24 }}
  138. grid
  139. >
  140. <ProFormText
  141. name="diagCode"
  142. label="诊断编码:"
  143. placeholder="请输入"
  144. rules={[{ required: true, message: '诊断编码不能为空!' }]}
  145. />
  146. <ProFormText
  147. name="diagName"
  148. label="诊断名称:"
  149. placeholder="请输入"
  150. rules={[{ required: true, message: '诊断名称不能为空!' }]}
  151. />
  152. <ProFormText
  153. name="icdCode"
  154. label="国家编码:"
  155. placeholder="请输入"
  156. rules={[{ required: true, message: '国家编码不能为空!' }]}
  157. />
  158. <ProFormSelect
  159. name="diseaseTypeCode"
  160. label="病种名称:"
  161. placeholder="请输入"
  162. showSearch
  163. request={async()=>{
  164. const resp = await getDiseaseTableData({pageSize:500,current:1});
  165. if(resp){
  166. const arr = resp.list.map((a:any)=>({label:`${a.name}(${a.code})`,value:a.code}));
  167. return [
  168. {label:'暂不选择',value:-1},
  169. ...arr
  170. ]
  171. }
  172. return []
  173. }}
  174. fieldProps={{
  175. onChange(value, option) {
  176. console.log({value});
  177. if(!value){
  178. formRef.current?.setFieldValue('diseaseTypeCode',undefined);
  179. }
  180. },
  181. }}
  182. />
  183. </ModalForm>
  184. )
  185. }
  186. const tableDataSearchHandle = (paramName: string) => {
  187. set_tableDataFilterParams({
  188. ...tableDataFilterParams,
  189. [`${paramName}`]: tableDataSearchKeywords
  190. })
  191. }
  192. const downloadTemplate = async () => {
  193. await downloadTemplateReq('/costAccount/setting/exportDiseaseTypeMap');
  194. };
  195. const mapBtnHandle = () => {
  196. Modal.confirm({
  197. title: '注意',
  198. content: '对照操作只会自动匹配未对照的项目,是否继续操作?',
  199. okText:'确定',
  200. cancelText:'取消',
  201. onOk: async (...args) => {
  202. const resp = await matchDiseaseTypeMap();
  203. if (resp) {
  204. message.success('操作成功!');
  205. tableRef.current?.reload();
  206. }
  207. },
  208. })
  209. }
  210. const importData = () => {
  211. return (
  212. <ModalForm
  213. width={360}
  214. title={`导入数据`}
  215. trigger={
  216. <a className="import" key="3">
  217. 导入
  218. </a>
  219. }
  220. submitter={{
  221. render: (props, defaultDoms) => {
  222. const needBtn = defaultDoms.filter((b) => {
  223. return b.key != 'rest';
  224. });
  225. return [
  226. ...needBtn,
  227. ];
  228. },
  229. }}
  230. onFinish={async (values) => {
  231. const {
  232. importFile: { fileList },
  233. } = values;
  234. let formData = new FormData();
  235. formData.append('file', fileList[0].originFileObj);
  236. const resp = await importDataPost(formData);
  237. if (resp) {
  238. tableRef.current?.reload();
  239. return true;
  240. }
  241. }}
  242. >
  243. <FormItem name={'importFile'}>
  244. <KCIMUpload downloadTemplateFile={() => downloadTemplate()} />
  245. </FormItem>
  246. </ModalForm>
  247. );
  248. };
  249. useEffect(() => {
  250. }, [])
  251. return (
  252. <KCIMPagecontainer className='DiseaseDiagnosisComparison' title={false}>
  253. <div className='toolBar'>
  254. <div className='filter'>
  255. <div className='filterItem'>
  256. <span className='label' style={{ whiteSpace: 'nowrap' }}> 检索:</span>
  257. <Input placeholder={'诊断名称/国家编码'} allowClear autoComplete='off'
  258. suffix={
  259. <IconFont type="iconsousuo" style={{color:'#99A6BF'}} onClick={() => tableDataSearchHandle('name')} />
  260. }
  261. onChange={(e) => {
  262. set_tableDataSearchKeywords(e.target.value);
  263. if (e.target.value.length == 0) {
  264. set_tableDataFilterParams({
  265. ...tableDataFilterParams,
  266. name: ''
  267. });
  268. }
  269. }}
  270. onPressEnter={(e) => {
  271. set_tableDataFilterParams({
  272. ...tableDataFilterParams,
  273. name: (e.target as HTMLInputElement).value
  274. });
  275. }}
  276. />
  277. </div>
  278. </div>
  279. <div className='btnGroup'>
  280. <span style={{ paddingRight: 16 }}><ProFormSwitch noStyle fieldProps={{
  281. size: 'small', onChange: (bool) => {
  282. set_stopStat(bool ? 1 : 0);
  283. tableRef.current?.reload();
  284. }
  285. }} /> 显示未对照项目</span>
  286. <span className='mapBtn' onClick={()=>mapBtnHandle()}>对照</span>
  287. {importData()}
  288. <UpDataActBtn record type='ADD' />
  289. </div>
  290. </div>
  291. <div style={{ marginTop: 16 }}>
  292. <KCIMTable scroll={{y:`calc(100vh - 233px)`}} columns={columns as ProColumns[]} actionRef={tableRef} rowKey='id' params={tableDataFilterParams} request={(params) => getTableData(params)} />
  293. </div>
  294. </KCIMPagecontainer>
  295. )
  296. }