bussiness.tsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. import React, { useEffect, useRef, useState } from "react";
  2. import { type ProColumns, type ActionType, type ProFormInstance, ProTable } from '@ant-design/pro-components';
  3. import type {FormInstance,CollapseProps} from 'antd'
  4. import {Upload,Collapse} from 'antd'
  5. import { SDPage,SDFormText,SDModalForm,SDTable,SDFormItem,SDButton,SDSubmitButton,EditType, SDAreaTtile, SDOperate, baseFun,SDModal, validateFun, SDFormDict, SDLayout, } from "@sundata/ui-frame";
  6. import type { SysListModel,productListModel,subjectListModel } from '@/services/rwa/rwa_calc_config_dataparam/bussiness';
  7. import {getDataList,selectDetailData,deleteRows,isNotExist,
  8. updateExistData,fetchDetailData,selectProductData,selectSubjectData} from '@/services/rwa/rwa_calc_config_dataparam/bussiness';
  9. import { WomanOutlined } from "@ant-design/icons";
  10. import { ProductProps } from "@/sundataImport";
  11. import { useModel } from '@umijs/max';
  12. import { countChineseChars } from "@/services/rwa/product/rwacheckutils";
  13. import { product_modifyone1, product_querylist, rwaCalcConfProductrulesModel } from "@/services/rwa/product_list";
  14. type widowRush = {
  15. onCancel: () => void;
  16. onChangeVisible(visible: boolean, type: string): unknown;
  17. onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
  18. }& ProductProps;
  19. // 业务配置
  20. const bussiness : React.FC<widowRush> = (prop:widowRush) => {
  21. /** 编辑方式,查看、修改、新增按钮时设置,详细信息表单中使用 */
  22. const [editType, setEditType] = useState<EditType>(prop.editType || 'display');
  23. /** 是否显示详细信息窗口 */
  24. const [detailVisible, setDetailVisible] = useState<boolean>(false);
  25. /** 是否显示产品列表窗口 */
  26. const [productListVisible, setProductListVisible] = useState<boolean>(false);
  27. /** 是否显示科目列表窗口 */
  28. const [subjectListVisible, setSubjectListVisible] = useState<boolean>(false);
  29. const [productDetailList, setProductDetailList] = useState<boolean>(false);
  30. // 当前行数据
  31. const [currentRow, setCurrentRow] = useState<SysListModel>();
  32. /** 表格引用对象,刷新表格使用 */
  33. const actionRef = useRef<ActionType>();
  34. const formRef = useRef<FormInstance<any>>();
  35. const templateRef = useRef<FormInstance<any>>();
  36. const productDetailRef =useRef<FormInstance<any>>();
  37. // 页面数据
  38. var formDataList = new Array<SysListModel>;
  39. /**上传文件 */
  40. const [fileData, setFileData] = useState<File>();
  41. // 导入窗口显示
  42. const [importVisible, setImportVisible] = useState<boolean>(false);
  43. const { fetchDict } = useModel('dict');
  44. /** 产品列表表单显示 */
  45. const [mockData, setMockData] = useState<productListModel[]>([]);
  46. /** 产品列表表单显示 */
  47. const [subjectMockData, setSubjectMockData] = useState<subjectListModel[]>([]);
  48. const [mockDetailData, setMockDetailData] = useState<rwaCalcConfProductrulesModel[]>([]);
  49. useEffect(() => {
  50. }, []);
  51. // 修改查询查询
  52. const selectData = async (formdata : SysListModel) => {
  53. const data = await selectDetailData(formdata);
  54. formRef.current?.setFieldsValue(data);
  55. }
  56. //关闭窗口刷新父页面
  57. const closeAndRefresh = ()=>{
  58. actionRef.current?.reloadAndRest?.();
  59. }
  60. // 插入或者更新数据
  61. const handleSave = async(data: SysListModel,) => {
  62. if (editType == 'update' ) {
  63. if (currentRow?.businessCode) {
  64. await updateExistData(data,currentRow?.businessCode);
  65. closeAndRefresh();
  66. }
  67. } else if (editType == 'create' ) {
  68. await fetchDetailData(data);
  69. closeAndRefresh();
  70. }
  71. setDetailVisible(false);
  72. }
  73. /**查询产品列表 */
  74. const selectProductList= async (record: SysListModel) => {
  75. if (record.businessCode) {
  76. const data = await selectProductData(record.businessCode);
  77. setMockData(data);
  78. }
  79. }
  80. /**查询科目列表 */
  81. const selectSubjectList = async (record: SysListModel) => {
  82. if (record.businessCode) {
  83. const data = await selectSubjectData(record.businessCode);
  84. setSubjectMockData(data);
  85. }
  86. }
  87. // 删除
  88. const delRows =async(record:any)=>{
  89. baseFun.confirm('请确认是否继续操作?',async() =>{
  90. await deleteRows(record.businessCode);
  91. baseFun.info("删除成功");
  92. closeAndRefresh();
  93. });
  94. }
  95. // 校验
  96. const roleidCheck = (bussinessCode: string) => isNotExist({
  97. businessCode:bussinessCode,
  98. });
  99. // 页面展示元素
  100. const columns: ProColumns<SysListModel>[] = [
  101. {
  102. title: '序号',
  103. dataIndex: 'index',
  104. search: false,
  105. render: (text, record, index) => index + 1,
  106. width:100,
  107. ellipsis:true
  108. },
  109. {
  110. title: '计算实例号',
  111. dataIndex: 'calcindex',
  112. search: false,
  113. hideInTable: true,
  114. },
  115. {
  116. title: '起始数据日期',
  117. dataIndex: 'startDate',
  118. search: false,
  119. hideInTable: true,
  120. },
  121. {
  122. title: '截止数据日期',
  123. dataIndex: 'endDate',
  124. search: false,
  125. hideInTable: true,
  126. },
  127. {
  128. title: '数据日期',
  129. dataIndex: 'dataDate',
  130. search: false,
  131. hideInTable: true,
  132. },
  133. {
  134. title: '业务编号',
  135. dataIndex: 'businessCode',
  136. hideInTable: false,
  137. },
  138. {
  139. title: '业务名称',
  140. dataIndex: 'businessName',
  141. hideInTable: false,
  142. },
  143. {
  144. title: '表内外标识',
  145. dataIndex: 'businessAttr',
  146. search: false,
  147. hideInTable: false,
  148. },
  149. {
  150. title: '操作',
  151. dataIndex: 'operate',
  152. valueType: 'option',
  153. render: (_, record) => [
  154. <SDOperate
  155. key="roleCfg"
  156. icon={<WomanOutlined />}
  157. successMessage=""
  158. onClick={
  159. ()=>{
  160. selectData(record);
  161. setCurrentRow(record);
  162. setDetailVisible(true);
  163. setEditType('update')
  164. } }
  165. >
  166. 修改
  167. </SDOperate>,
  168. <SDOperate
  169. key="roleCfg"
  170. icon={<WomanOutlined />}
  171. successMessage=""
  172. onClick={()=>{
  173. delRows(record) } }
  174. >
  175. 删除
  176. </SDOperate>,
  177. <SDOperate
  178. key="roleCfg"
  179. icon={<WomanOutlined />}
  180. successMessage=""
  181. onClick={()=>{
  182. selectProductList(record);
  183. setProductListVisible(true);} }
  184. >
  185. 产品列表
  186. </SDOperate>,
  187. <SDOperate
  188. key="roleCfg"
  189. icon={<WomanOutlined />}
  190. successMessage=""
  191. onClick={()=>{
  192. selectSubjectList(record);
  193. setSubjectListVisible(true);
  194. } }
  195. >
  196. 科目列表
  197. </SDOperate>,
  198. ],
  199. },
  200. ];
  201. // 页面展示元素
  202. const productColumns: ProColumns<productListModel>[] = [
  203. {
  204. title: '产品编号',
  205. dataIndex: 'productNo',
  206. search: false,
  207. hideInTable: false,
  208. },
  209. {
  210. title: '产品名称',
  211. dataIndex: 'productName',
  212. search: false,
  213. hideInTable: false,
  214. },
  215. {
  216. title: '产品分类',
  217. dataIndex: 'productType',
  218. search: false,
  219. hideInTable: false,
  220. },
  221. {
  222. title: '表内外标识',
  223. dataIndex: 'onOrOff',
  224. search: false,
  225. hideInTable: false,
  226. },
  227. {
  228. title: '来源系统',
  229. dataIndex: 'productFromSystem',
  230. search: false,
  231. hideInTable: false,
  232. },
  233. {
  234. title: '操作',
  235. dataIndex: 'operate',
  236. valueType: 'option',
  237. render: (_, record) => [
  238. <SDOperate
  239. key="roleCfg"
  240. icon={<WomanOutlined />}
  241. successMessage=""
  242. onClick={async ()=>{
  243. setProductDetailList(true);
  244. // 产品参数查看实现
  245. const detailData = await product_modifyone1(record.productNo);
  246. productDetailRef.current?.setFieldsValue(detailData);
  247. const detailList = await product_querylist(record.productNo);
  248. setMockDetailData(detailList);
  249. } }
  250. >
  251. 查看
  252. </SDOperate>,
  253. ],
  254. },
  255. ]
  256. // 页面展示元素
  257. const subjectColumns: ProColumns<subjectListModel>[] = [
  258. {
  259. title: '产品编号',
  260. dataIndex: 'productNo',
  261. search: false,
  262. hideInTable: false,
  263. },
  264. {
  265. title: '产品名称',
  266. dataIndex: 'productName',
  267. search: false,
  268. hideInTable: false,
  269. },
  270. {
  271. title: '科目编号',
  272. dataIndex: 'ruleCode',
  273. search: false,
  274. hideInTable: false,
  275. },
  276. {
  277. title: '科目名称',
  278. dataIndex: 'ruleCode',
  279. search: false,
  280. hideInTable: false,
  281. valueType: "treeSelect",
  282. request: () => fetchDict('org'),
  283. fieldProps: {
  284. treeDefaultExpandAll: true,
  285. treeCheckable:true,
  286. },
  287. },
  288. {
  289. title: '数据类型',
  290. dataIndex: 'dataType',
  291. search: false,
  292. hideInTable: false,
  293. },
  294. ]
  295. const columns1: ProColumns<rwaCalcConfProductrulesModel>[] = [
  296. { title : '计算实例号',
  297. dataIndex : 'calcindex',
  298. search:false,
  299. hideInTable:true,
  300. width : 150
  301. },
  302. { title : '起始数据日期',
  303. dataIndex : 'sdate',
  304. search:false,
  305. hideInTable:true,
  306. width : 150
  307. },
  308. { title : '截止数据日期',
  309. dataIndex : 'edate',
  310. search:false,
  311. hideInTable:true,
  312. width : 150
  313. },
  314. { title : '年月',
  315. dataIndex : 'term',
  316. search:false,
  317. hideInTable:true,
  318. width : 150
  319. },
  320. { title : '数据日期',
  321. dataIndex : 'dataDate',
  322. search:false,
  323. hideInTable:true,
  324. width : 150
  325. },
  326. { title : '产品编号',
  327. dataIndex : 'productNo',
  328. search:false,
  329. hideInTable:true,
  330. width : 150
  331. },
  332. { title : '规则编号',
  333. dataIndex : 'ruleCode',
  334. width : 150
  335. },
  336. { title : '规则名称',
  337. dataIndex : 'ruleName',
  338. width : 150
  339. },
  340. { title : '数据类型',
  341. dataIndex : 'dataType',
  342. width : 150
  343. },
  344. { title : '对应科目号',
  345. dataIndex : 'ruleSubject',
  346. width : 150
  347. },
  348. { title : '输入数据源',
  349. dataIndex : 'ruleIn',
  350. width : 150
  351. },
  352. { title : '输出数据源',
  353. dataIndex : 'ruleOut',
  354. width : 150
  355. },
  356. { title : '科目取数规则',
  357. dataIndex : 'ruleGetdata',
  358. width : 150
  359. },
  360. { title : '规则序号',
  361. dataIndex : 'ruleIndex',
  362. width : 150
  363. },]
  364. return (
  365. <SDPage>
  366. <SDTable
  367. title="查询表格"
  368. rowKey="customerName"
  369. request={async (formdata:SysListModel) =>{
  370. const formDatas = await getDataList(formdata);
  371. // 解构数组(导出用)
  372. formDataList=[...formDatas];
  373. return {data: formDatas}
  374. } }
  375. columns={columns}
  376. operations={['create']}
  377. actionRef={actionRef}
  378. formRef={formRef}
  379. setDetailVisible={() => {setDetailVisible(true)}}
  380. setEditType={setEditType}
  381. setCurrentRow={setCurrentRow}
  382. />
  383. {detailVisible && (
  384. <SDModalForm
  385. title={'详细信息'}
  386. editType={editType}
  387. params={currentRow}
  388. visible={detailVisible}
  389. onVisibleChange={() => {setDetailVisible(false)}}
  390. footer={[
  391. <SDSubmitButton editType={editType} formRef={formRef} doSubmit={handleSave} >保存</SDSubmitButton>,
  392. <SDButton
  393. key="closeUpdate"
  394. successMessage=''
  395. onClick={() => {
  396. setDetailVisible(false);
  397. }}>关闭</SDButton>
  398. ]}
  399. tableRef={actionRef}
  400. formRef={formRef}
  401. >
  402. <SDAreaTtile title='业务配置信息'/>
  403. <SDFormText name="businessCode" readonlyCond="update" bgValidater={roleidCheck} rules={[{max:20,message:'不可超过20个字符'},]} label="业务编号"/>
  404. <SDFormText name="businessName" label="业务名称" rules={[{validator:(rules,value,callback)=>{
  405. let chineseCount = countChineseChars(value);
  406. if (chineseCount > 50) {
  407. callback('最多50个汉字');
  408. } else if (chineseCount<=0) {
  409. callback('请输入汉字');
  410. } else{
  411. callback();
  412. }
  413. }}]}/>
  414. <SDFormDict name="businessAttr" dictKey="ONOROFF" label="表内外标识"/>
  415. </SDModalForm>
  416. )}
  417. {productListVisible &&
  418. <SDModalForm
  419. title={'产品列表'}
  420. visible={productListVisible}
  421. editType={editType}
  422. onVisibleChange={() => { setProductListVisible(false);}
  423. }>
  424. <SDLayout>
  425. <ProTable
  426. rowKey="productNo"
  427. search={false}
  428. dataSource={mockData}
  429. columns={productColumns}
  430. //singleSelect={false}
  431. actionRef={actionRef}
  432. formRef={formRef}
  433. />
  434. </SDLayout>
  435. </SDModalForm>
  436. }
  437. {subjectListVisible &&
  438. <SDModalForm
  439. title={'科目列表'}
  440. visible={subjectListVisible}
  441. editType={editType}
  442. onVisibleChange={() => { setSubjectListVisible(false);}
  443. }>
  444. <SDLayout>
  445. <ProTable
  446. rowKey="productNo"
  447. search={false}
  448. dataSource={subjectMockData}
  449. columns={subjectColumns}
  450. actionRef={actionRef}
  451. formRef={formRef}
  452. />
  453. </SDLayout>
  454. </SDModalForm>
  455. }
  456. {productDetailList &&
  457. <SDModalForm
  458. title={'产品列表'}
  459. visible={productDetailList}
  460. editType={editType}
  461. formRef={productDetailRef}
  462. onVisibleChange={() => { setProductDetailList(false);}
  463. }>
  464. <SDFormText name="productNo" label="产品代码" />
  465. <SDFormText name="productName" label="产品名称" />
  466. <SDFormText name="productType" label="产品大类" />
  467. <SDFormText name="productIndex" label="产品序号" />
  468. <SDFormText name="productStageId" label="所属阶段" />
  469. <SDFormText name="productFromSystem" label="来源系统" />
  470. <SDFormText name="defaultOut" label="默认输出数据源" />
  471. <SDFormText name="productBussinessCode" label="所属业务" />
  472. <SDFormText name="defaultGetdatarule" label="默认取数逻辑" />
  473. <SDAreaTtile title='科目取数规则列表' />
  474. <SDLayout>
  475. <ProTable
  476. rowKey="ruleCode"
  477. search={false}
  478. formRef={productDetailRef}
  479. dataSource={mockDetailData}
  480. columns={columns1}
  481. />
  482. </SDLayout>
  483. </SDModalForm>
  484. }
  485. </SDPage>
  486. );
  487. }
  488. export default bussiness;