supplementtaskmanagement.tsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. import React, { useEffect, useRef, useState } from "react";
  2. import { type ProColumns, type ActionType, type ProFormInstance, ProTable, EditableProTable } from '@ant-design/pro-components';
  3. import type {FormInstance} from 'antd'
  4. import {Upload} from 'antd'
  5. import { SDPage,SDFormText,SDModalForm,SDTable,SDFormItem,SDButton,SDSubmitButton,EditType, SDAreaTtile, SDOperate, baseFun,SDModal, validateFun, SDLayout, SDFormDict, } from "@sundata/ui-frame";
  6. import type { SupplementTaskDefineModel,SupplementTemplateRelationModel,TemplateDataValidationRuleModel, } from '@/services/rwa/product/datasupplementary/supplementtaskmanagement';
  7. import {getDataList,selectDetailData,getTemplateCheckDataList,getTemplateDataList,deleteInfoData,updateRowData,
  8. createRowData,createTemplateListRowData,createTemplateCheckRowData} from '@/services/rwa/product/datasupplementary/supplementtaskmanagement';
  9. import { PlusSquareTwoTone, WomanOutlined } from "@ant-design/icons";
  10. import { ProductProps } from "@/sundataImport";
  11. import { toNumber } from "lodash";
  12. type widowRush = {
  13. onCancel: () => void;
  14. onChangeVisible(visible: boolean, type: string): unknown;
  15. onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
  16. }& ProductProps;
  17. const supplementtaskmanagement : React.FC<widowRush> = (prop:widowRush) => {
  18. /** 编辑方式,查看、修改、新增按钮时设置,详细信息表单中使用 */
  19. const [editType, setEditType] = useState<EditType>(prop.editType || 'display');
  20. /** 是否显示详细信息窗口 */
  21. const [detailVisible, setDetailVisible] = useState<boolean>(false);
  22. const [currentRow, setCurrentRow] = useState<SupplementTaskDefineModel>();
  23. /** 表格引用对象,刷新表格使用 */
  24. const actionRef = useRef<ActionType>();
  25. const formRef = useRef<FormInstance<any>>();
  26. const templateListRef = useRef<FormInstance<any>>();
  27. const templateCheckRef = useRef<FormInstance<any>>();
  28. const templateListActionRef = useRef<ActionType>();
  29. const templateCheckActionRef = useRef<ActionType>();
  30. const [templateListData, setTemplateListData] = useState<SupplementTemplateRelationModel[]>();
  31. const [templateCheckData, setTemplateCheckData] = useState<TemplateDataValidationRuleModel[]>();
  32. // const [resMap, setResMap] = useState<ModelMap>();
  33. // 页面数据
  34. var formDataList = new Array<SupplementTaskDefineModel>;
  35. /** 字段关系序号编辑 */
  36. var dataInfoIndex = 1;
  37. var dataDetailIndex = 0;
  38. useEffect(() => {
  39. }, []);
  40. // 修改查询查询
  41. const selectData = async (formdata : SupplementTaskDefineModel) => {
  42. const data = await selectDetailData(formdata);
  43. formRef.current?.setFieldsValue(data);
  44. const dataList = await getTemplateDataList(formdata);
  45. setTemplateListData(...[dataList]);
  46. const templateList = await getTemplateCheckDataList(formdata);
  47. setTemplateCheckData(...[templateList]);
  48. }
  49. // 删除
  50. const deleteData = async(formdata : SupplementTaskDefineModel) => {
  51. baseFun.confirm('请确认是否继续操作?',async() =>{
  52. await deleteInfoData(formdata);
  53. baseFun.info("删除成功");
  54. closeAndRefresh();
  55. });
  56. }
  57. // 插入或者更新数据
  58. const handleSave = async(data: SupplementTaskDefineModel,) => {
  59. if (editType == 'update' ) {
  60. await updateRowData(data).then(()=>{
  61. if (templateListData && templateCheckData) {
  62. createTemplateListRowData(templateListData,data.taskCode);
  63. createTemplateCheckRowData(templateCheckData);
  64. }
  65. });
  66. closeAndRefresh();
  67. } else if (editType == 'create' ) {
  68. await createRowData(data).then(()=>{
  69. if (templateListData && templateCheckData) {
  70. createTemplateListRowData(templateListData,data.taskCode);
  71. createTemplateCheckRowData(templateCheckData);
  72. }
  73. });
  74. closeAndRefresh();
  75. }
  76. setDetailVisible(false);
  77. }
  78. //关闭窗口刷新父页面
  79. const closeAndRefresh = ()=>{
  80. actionRef.current?.reloadAndRest?.();
  81. }
  82. // 数据补录模板定义
  83. const columns: ProColumns<SupplementTaskDefineModel>[] = [
  84. {
  85. title: '序号',
  86. dataIndex: 'index',
  87. search: false,
  88. render: (text, record, index) => { index = index + 1;return index},
  89. width:100,
  90. ellipsis:true
  91. },
  92. {
  93. title: '计算实例号',
  94. dataIndex: 'calcIndex',
  95. search: false,
  96. hideInTable: true,
  97. },
  98. {
  99. title: '起始数据日期',
  100. dataIndex: 'startDate',
  101. search: false,
  102. hideInTable: true,
  103. },
  104. {
  105. title: '截止数据日期',
  106. dataIndex: 'endDate',
  107. search: false,
  108. hideInTable: true,
  109. },
  110. {
  111. title: '期次',
  112. dataIndex: 'term',
  113. search: false,
  114. hideInTable: true,
  115. },
  116. {
  117. title: '任务编号',
  118. dataIndex: 'taskCode',
  119. hideInTable: false,
  120. },
  121. {
  122. title: '任务名称',
  123. dataIndex: 'taskName',
  124. hideInTable: false,
  125. },
  126. {
  127. title: '负责机构',
  128. dataIndex: 'orgCode',
  129. hideInTable: false,
  130. },
  131. {
  132. title: '首选负责人',
  133. dataIndex: 'account',
  134. hideInTable: false,
  135. search: false,
  136. },
  137. {
  138. title: '补录频率',
  139. dataIndex: 'frequency',
  140. hideInTable: false,
  141. search: false,
  142. },
  143. {
  144. title: '天数调整',
  145. dataIndex: 'adjustment',
  146. hideInTable: false,
  147. search: false,
  148. },
  149. {
  150. title: '包含模板',
  151. dataIndex: 'tmpNames',
  152. hideInTable: false,
  153. search: false,
  154. },
  155. {
  156. title: '状态',
  157. dataIndex: 'status',
  158. hideInTable: false,
  159. search: false,
  160. },
  161. {
  162. title: '操作',
  163. dataIndex: 'operate',
  164. valueType: 'option',
  165. render: (_, record) => [
  166. <SDOperate
  167. key="roleCfg"
  168. icon={<WomanOutlined />}
  169. successMessage=""
  170. onClick={
  171. ()=>{
  172. selectData(record);
  173. setDetailVisible(true);
  174. setEditType('update');
  175. } }
  176. >
  177. 修改
  178. </SDOperate>,
  179. <SDOperate
  180. key="roleCfg"
  181. icon={<WomanOutlined />}
  182. successMessage=""
  183. onClick={
  184. ()=>{
  185. deleteData(record);
  186. setDetailVisible(true);
  187. setEditType('update');
  188. } }
  189. >
  190. 作废
  191. </SDOperate>,
  192. <SDOperate
  193. key="roleCfg"
  194. icon={<WomanOutlined />}
  195. successMessage=""
  196. onClick={
  197. ()=>{
  198. selectData(record);
  199. setDetailVisible(true);
  200. setEditType('update');
  201. } }
  202. >
  203. 查看
  204. </SDOperate>,
  205. ],
  206. },
  207. ];
  208. // 补录模板列表
  209. const templateListColumns: ProColumns<SupplementTemplateRelationModel>[] = [
  210. {
  211. title: '序号',
  212. dataIndex: 'id',
  213. search: false,
  214. render: (text, record, index) => { index = index + 1;dataInfoIndex = index; return index},
  215. width:100,
  216. ellipsis:true,
  217. editable:false
  218. },
  219. {
  220. title: '计算实例号',
  221. dataIndex: 'calcIndex',
  222. search: false,
  223. hideInTable: true,
  224. },
  225. {
  226. title: '起始数据日期',
  227. dataIndex: 'startDate',
  228. search: false,
  229. hideInTable: true,
  230. },
  231. {
  232. title: '截止数据日期',
  233. dataIndex: 'endDate',
  234. search: false,
  235. hideInTable: true,
  236. },
  237. {
  238. title: '期次',
  239. dataIndex: 'term',
  240. search: false,
  241. hideInTable: true,
  242. },
  243. {
  244. title: '补录模板',
  245. dataIndex: 'tmpCode',
  246. search: false,
  247. hideInTable: false,
  248. formItemProps:{
  249. rules:[
  250. {required:true},]
  251. }
  252. },
  253. {
  254. title: '补录模板说明',
  255. dataIndex: 'remark',
  256. search: false,
  257. hideInTable: false,
  258. },
  259. {
  260. title: '数据初始化逻辑',
  261. dataIndex: 'sqlCode',
  262. search: false,
  263. hideInTable: false,
  264. },
  265. {
  266. title: '操作',
  267. dataIndex: 'operate',
  268. valueType: 'option',
  269. render: (_, record) => [
  270. <SDOperate
  271. key="roleCfg"
  272. icon={<WomanOutlined />}
  273. successMessage=""
  274. onClick={async ()=>{
  275. templateListActionRef.current?.startEditable(record.tmpCode);
  276. } }
  277. >
  278. 编辑
  279. </SDOperate>,
  280. ],
  281. },
  282. ];
  283. // 补录模板校验规则
  284. const templateCheckColumns: ProColumns<TemplateDataValidationRuleModel>[] = [
  285. {
  286. title: '序号',
  287. dataIndex: 'id',
  288. search: false,
  289. render: (text, record, index) => { index = index + 1;dataDetailIndex =index; return index},
  290. width:100,
  291. ellipsis:true,
  292. editable:false
  293. },
  294. {
  295. title: '计算实例号',
  296. dataIndex: 'calcIndex',
  297. search: false,
  298. hideInTable: true,
  299. width:150,
  300. ellipsis:true
  301. },
  302. {
  303. title: '起始数据日期',
  304. dataIndex: 'startDate',
  305. search: false,
  306. hideInTable: true,
  307. width:150,
  308. ellipsis:true
  309. },
  310. {
  311. title: '截止数据日期',
  312. dataIndex: 'endDate',
  313. search: false,
  314. hideInTable: true,
  315. width:150,
  316. ellipsis:true
  317. },
  318. {
  319. title: '期次',
  320. dataIndex: 'term',
  321. search: false,
  322. hideInTable: true,
  323. width:150,
  324. ellipsis:true
  325. },
  326. {
  327. title: '规则名称',
  328. dataIndex: 'tmpverificationName',
  329. hideInTable: false,
  330. width:150,
  331. ellipsis:true
  332. },
  333. {
  334. title: '补录模板',
  335. dataIndex: 'tmpCode',
  336. hideInTable: false,
  337. width:150,
  338. ellipsis:true
  339. },
  340. {
  341. title: '行列类型',
  342. dataIndex: 'tmpverRowColType',
  343. hideInTable: false,
  344. width:150,
  345. ellipsis:true
  346. },
  347. {
  348. title: '模板验证时点',
  349. dataIndex: 'vartimmer',
  350. hideInTable: false,
  351. width:150,
  352. ellipsis:true
  353. },
  354. {
  355. title: '行范围',
  356. dataIndex: 'tmpverRowRange',
  357. hideInTable: false,
  358. width:150,
  359. ellipsis:true,
  360. formItemProps:{
  361. rules:[
  362. {pattern: RegExp(`[0-9]+\\-[0-9]+|[n|N]`),message:'请输入正确范围'},]
  363. }
  364. },
  365. {
  366. title: '列范围',
  367. dataIndex: 'tmpverColumnRange',
  368. hideInTable: false,
  369. width:150,
  370. ellipsis:true
  371. },
  372. {
  373. title: '约束方式',
  374. dataIndex: 'checkType',
  375. hideInTable: false,
  376. width:150,
  377. ellipsis:true
  378. },
  379. {
  380. title: '数据类型',
  381. dataIndex: 'remark',
  382. hideInTable: false,
  383. width:150,
  384. ellipsis:true
  385. },
  386. {
  387. title: '约束公式',
  388. dataIndex: 'remark',
  389. hideInTable: false,
  390. width:150,
  391. ellipsis:true
  392. },
  393. {
  394. title: '约束规则SQL',
  395. dataIndex: 'remark',
  396. hideInTable: false,
  397. width:150,
  398. ellipsis:true
  399. },
  400. {
  401. title: '越界处理方式',
  402. dataIndex: 'remark',
  403. hideInTable: false,
  404. width:150,
  405. ellipsis:true
  406. },
  407. {
  408. title: '提示信息模板',
  409. dataIndex: 'remark',
  410. hideInTable: false,
  411. width:150,
  412. ellipsis:true
  413. },
  414. {
  415. title: '操作',
  416. dataIndex: 'operate',
  417. valueType: 'option',
  418. width:150,
  419. ellipsis:true,
  420. render: (_, record) => [
  421. <SDOperate
  422. key="roleCfg"
  423. icon={<WomanOutlined />}
  424. successMessage=""
  425. onClick={
  426. async()=>{
  427. templateCheckActionRef.current?.startEditable(record.tmpverificationCode);
  428. }}
  429. >
  430. 编辑
  431. </SDOperate>,
  432. ],
  433. },
  434. ];
  435. return (
  436. <SDPage>
  437. <SDTable
  438. title="查询表格"
  439. rowKey="customerName"
  440. request={async (formdata:SupplementTaskDefineModel) =>{
  441. const formDatas = await getDataList(formdata);
  442. // 解构数组(导出用)
  443. formDataList=[...formDatas];
  444. return {data: formDatas}
  445. } }
  446. columns={columns}
  447. toolBarRender={(_, { selectedRows }) => [
  448. <SDButton
  449. key="export"
  450. icon={<PlusSquareTwoTone/>}
  451. successMessage=''
  452. onClick={() => {
  453. setEditType('create');
  454. setDetailVisible(true);
  455. setTemplateListData([]);
  456. setTemplateCheckData([]);
  457. }}
  458. >
  459. 新增
  460. </SDButton>,
  461. ]}
  462. actionRef={actionRef}
  463. formRef={formRef}
  464. setDetailVisible={() => {setDetailVisible(true)}}
  465. setEditType={setEditType}
  466. setCurrentRow={setCurrentRow}
  467. />
  468. {detailVisible && (
  469. <SDModalForm
  470. title={'详细信息'}
  471. editType={editType}
  472. params={currentRow}
  473. visible={detailVisible}
  474. onVisibleChange={() => {setDetailVisible(false)}}
  475. footer={[
  476. <SDSubmitButton editType={editType} formRef={formRef} doSubmit={handleSave} >保存</SDSubmitButton>,
  477. <SDButton
  478. key="closeUpdate"
  479. successMessage=''
  480. onClick={() => {
  481. setDetailVisible(false);
  482. }}>关闭</SDButton>
  483. ]}
  484. tableRef={actionRef}
  485. formRef={formRef}
  486. >
  487. <SDAreaTtile title='补录任务新增页面'/>
  488. <SDFormText name="taskCode" readonlyCond="update" required={true} label="任务编号"/>
  489. <SDFormText name="taskName" label="任务名称"/>
  490. <SDFormDict dictKey="" name="orgCode" label="责任机构"/>
  491. <SDFormDict dictKey="" name="account" label="首选责任人"/>
  492. <SDFormDict dictKey="CALC_TASK_RATE" name="frequency" label="补录频率"/>
  493. <SDFormText name="adjustment" label="天数调整"/>
  494. <SDFormDict dictKey="" name="tmpFileCode" label="所属阶段"/>
  495. <SDLayout>
  496. <SDAreaTtile title='补录模板列表'/>
  497. <EditableProTable
  498. rowKey="tmpCode"
  499. columns={templateListColumns}
  500. recordCreatorProps={false}
  501. actionRef={templateListActionRef}
  502. value={templateListData}
  503. editable={{
  504. actionRender: (row,config,defaultDoms)=>{
  505. return [defaultDoms.save,defaultDoms.delete,defaultDoms.cancel]
  506. }
  507. }}
  508. toolBarRender={(_, { selectedRowKeys }) => editType == 'create' || editType == 'update' ? [
  509. <SDButton
  510. key="export"
  511. successMessage=''
  512. onClick={() => {
  513. templateListActionRef.current?.addEditRecord?.({
  514. tmpCode: dataInfoIndex+1,
  515. title: 'NEWROW',
  516. });
  517. }}
  518. >
  519. 新增
  520. </SDButton>,
  521. ]:[]}
  522. onChange={ (value: readonly SupplementTemplateRelationModel[]) => {
  523. setTemplateListData([...value]);
  524. } }
  525. />
  526. </SDLayout>
  527. <SDLayout>
  528. <SDAreaTtile title='补录模板校验规则'/>
  529. <EditableProTable
  530. rowKey="tmpverificationCode"
  531. columns={templateCheckColumns}
  532. recordCreatorProps={false}
  533. actionRef={templateCheckActionRef}
  534. scroll={{ x: 1500 }}
  535. value={templateCheckData}
  536. editable={{
  537. actionRender: (row,config,defaultDoms)=>{
  538. return [defaultDoms.save,defaultDoms.delete,defaultDoms.cancel]
  539. }
  540. }}
  541. toolBarRender={(_, { selectedRowKeys }) => editType == 'create' || editType == 'update' ? [
  542. <SDButton
  543. key="export"
  544. successMessage=''
  545. onClick={() => {
  546. templateCheckActionRef.current?.addEditRecord?.({
  547. tmpverificationCode: dataDetailIndex+1,
  548. title: 'NEWROW',
  549. });
  550. }}
  551. >
  552. 新增
  553. </SDButton>,
  554. ]:[]}
  555. onChange={ (value: readonly TemplateDataValidationRuleModel[]) => {
  556. setTemplateCheckData([...value]);
  557. } }
  558. />
  559. </SDLayout>
  560. </SDModalForm>
  561. )}
  562. </SDPage>
  563. );
  564. }
  565. export default supplementtaskmanagement;