bussiness.tsx 16 KB

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