123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- import React, { useEffect, useRef, useState } from "react";
- import { type ProColumns, type ActionType, type ProFormInstance, ProTable } from '@ant-design/pro-components';
- import type {FormInstance,CollapseProps} from 'antd'
- import {Upload,Collapse} from 'antd'
- import { SDPage,SDFormText,SDModalForm,SDTable,SDFormItem,SDButton,SDSubmitButton,EditType, SDAreaTtile, SDOperate, baseFun,SDModal, validateFun, SDFormDict, SDLayout, } from "@sundata/ui-frame";
- import type { SysListModel,productListModel,subjectListModel } from '@/services/rwa/rwa_calc_config_dataparam/bussiness';
- import {getDataList,selectDetailData,deleteRows,isNotExist,
- updateExistData,fetchDetailData,selectProductData,selectSubjectData} from '@/services/rwa/rwa_calc_config_dataparam/bussiness';
- import { WomanOutlined } from "@ant-design/icons";
- import { ProductProps } from "@/sundataImport";
- import { useModel } from '@umijs/max';
- import { countChineseChars } from "@/services/rwa/product/rwacheckutils";
- import { product_modifyone1, product_querylist, rwaCalcConfProductrulesModel } from "@/services/rwa/product_list";
- type widowRush = {
- onCancel: () => void;
- onChangeVisible(visible: boolean, type: string): unknown;
- onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
- }& ProductProps;
- // 业务配置
- const bussiness : React.FC<widowRush> = (prop:widowRush) => {
- /** 编辑方式,查看、修改、新增按钮时设置,详细信息表单中使用 */
- const [editType, setEditType] = useState<EditType>(prop.editType || 'display');
- /** 是否显示详细信息窗口 */
- const [detailVisible, setDetailVisible] = useState<boolean>(false);
- /** 是否显示产品列表窗口 */
- const [productListVisible, setProductListVisible] = useState<boolean>(false);
- /** 是否显示科目列表窗口 */
- const [subjectListVisible, setSubjectListVisible] = useState<boolean>(false);
- const [productDetailList, setProductDetailList] = useState<boolean>(false);
- // 当前行数据
- const [currentRow, setCurrentRow] = useState<SysListModel>();
- /** 表格引用对象,刷新表格使用 */
- const actionRef = useRef<ActionType>();
- const formRef = useRef<FormInstance<any>>();
- const templateRef = useRef<FormInstance<any>>();
- const productDetailRef =useRef<FormInstance<any>>();
- // 页面数据
- var formDataList = new Array<SysListModel>;
- /**上传文件 */
- const [fileData, setFileData] = useState<File>();
- // 导入窗口显示
- const [importVisible, setImportVisible] = useState<boolean>(false);
- const { fetchDict } = useModel('dict');
- /** 产品列表表单显示 */
- const [mockData, setMockData] = useState<productListModel[]>([]);
- /** 产品列表表单显示 */
- const [subjectMockData, setSubjectMockData] = useState<subjectListModel[]>([]);
- const [mockDetailData, setMockDetailData] = useState<rwaCalcConfProductrulesModel[]>([]);
- const [defaultOut,setDefaultOut] = useState<any>();
- var formDataList1 = new Array<productListModel>;
-
- useEffect(() => {
- }, []);
-
- // 修改查询查询
- const selectData = async (formdata : SysListModel) => {
- const data = await selectDetailData(formdata);
- formRef.current?.setFieldsValue(data);
- }
- //关闭窗口刷新父页面
- const closeAndRefresh = ()=>{
- actionRef.current?.reloadAndRest?.();
- }
- // 插入或者更新数据
- const handleSave = async(data: SysListModel,) => {
-
- if (editType == 'update' ) {
- if (currentRow?.businessCode) {
- await updateExistData(data,currentRow?.businessCode);
- closeAndRefresh();
- }
-
- } else if (editType == 'create' ) {
- await fetchDetailData(data);
- closeAndRefresh();
- }
- setDetailVisible(false);
- }
- /**查询产品列表 */
- const selectProductList= async (record: any) => {
- if (record.businessCode) {
- const data = await selectProductData(record.businessCode);
- setMockData(data);
- }
- }
- /**查询科目列表 */
- const selectSubjectList = async (record: SysListModel) => {
- if (record.businessCode) {
- const data = await selectSubjectData(record.businessCode);
- setSubjectMockData(data);
- }
-
- }
- // 删除
- const delRows =async(record:any)=>{
- baseFun.confirm('请确认是否继续操作?',async() =>{
- await deleteRows(record.businessCode);
- baseFun.info("删除成功");
- closeAndRefresh();
- });
- }
- // 校验
- const roleidCheck = (bussinessCode: string) => isNotExist({
- businessCode:bussinessCode,
- });
-
- // 页面展示元素
- const columns: ProColumns<SysListModel>[] = [
- {
- title: '序号',
- dataIndex: 'index',
- search: false,
- render: (text, record, index) => index + 1,
- width:100,
- ellipsis:true
- },
- {
- title: '计算实例号',
- dataIndex: 'calcindex',
- search: false,
- hideInTable: true,
- },
- {
- title: '起始数据日期',
- dataIndex: 'startDate',
- search: false,
- hideInTable: true,
- },
- {
- title: '截止数据日期',
- dataIndex: 'endDate',
- search: false,
- hideInTable: true,
- },
- {
- title: '数据日期',
- dataIndex: 'dataDate',
- search: false,
- hideInTable: true,
- },
- {
- title: '业务编号',
- dataIndex: 'businessCode',
- hideInTable: false,
- },
- {
- title: '业务名称',
- dataIndex: 'businessName',
- hideInTable: false,
- },
- {
- title: '表内外标识',
- dataIndex: 'businessAttr',
- search: false,
- hideInTable: false,
- },
- {
- title: '操作',
- dataIndex: 'operate',
- valueType: 'option',
- render: (_, record) => [
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={
- ()=>{
- selectData(record);
- setCurrentRow(record);
- setDetailVisible(true);
- setEditType('update')
- } }
- >
- 修改
- </SDOperate>,
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={()=>{
- delRows(record) } }
- >
- 删除
- </SDOperate>,
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={()=>{
- selectProductList(record);
- setProductListVisible(true);} }
- >
- 产品列表
- </SDOperate>,
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={()=>{
- selectSubjectList(record);
- setSubjectListVisible(true);
- } }
- >
- 科目列表
- </SDOperate>,
- ],
- },
- ];
- // 页面展示元素
- const productColumns: ProColumns<productListModel>[] = [
- {
- title: '产品编号',
- dataIndex: 'productNo',
- search: false,
- hideInTable: false,
- },
- {
- title: '产品名称',
- dataIndex: 'productName',
- search: false,
- hideInTable: false,
- },
- {
- title: '产品分类',
- dataIndex: 'productType',
- valueType:'select',
- request:()=>fetchDict({dictKey : 'PRODUCT_TYPE'}),
- search: false,
- hideInTable: false,
- },
- {
- title: '表内外标识',
- dataIndex: 'onOrOff',
- request:()=>fetchDict({}),
- search: false,
- hideInTable: false,
- },
- {
- title: '来源系统',
- dataIndex: 'productFromSystems',
- valueType:'select',
- request:()=>fetchDict({ dictKey : 'PRODUCTFROMSYSTEM'}),
- search: false,
- hideInTable: false,
- },
- {
- title: '操作',
- dataIndex: 'operate',
- valueType: 'option',
- render: (_, record) => [
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={async ()=>{
- setProductDetailList(true);
- // 产品参数查看实现
- const detailData1 = await product_modifyone1(record.productNo);
- const colorsArray = detailData1.productFromSystems.split(',');
- let i=0;
- productDetailRef.current?.setFieldValue("productFromSystem",colorsArray)
-
- const {productFromSystem,...detailData}=detailData1
- setDefaultOut(detailData.productStageId);
- productDetailRef.current?.setFieldsValue(detailData);
- const detailList = await product_querylist(record.productNo);
- setMockDetailData(detailList);
- setEditType('display')
- } }
- >
- 查看
- </SDOperate>,
- ],
- },
- ]
- // 页面展示元素
- const subjectColumns: ProColumns<subjectListModel>[] = [
- {
- title: '产品编号',
- dataIndex: 'productNo',
- search: false,
- hideInTable: false,
- },
- {
- title: '产品名称',
- dataIndex: 'productName',
- search: false,
- hideInTable: false,
- },
- {
- title: '科目编号',
- dataIndex: 'ruleCode',
- search: false,
- hideInTable: false,
- },
- {
- title: '科目名称',
- dataIndex: 'ruleCode',
- search: false,
- hideInTable: false,
- valueType: "treeSelect",
- request: () => fetchDict('org'),
- fieldProps: {
- treeDefaultExpandAll: true,
- treeCheckable:true,
- },
- },
- {
- title: '数据类型',
- dataIndex: 'dataType',
- valueType:'select',
- request:()=>fetchDict({ dictKey :'DATA_TYPE'}),
- search: false,
- hideInTable: false,
- },
- ]
- const columns1: ProColumns<rwaCalcConfProductrulesModel>[] = [
- { title : '计算实例号',
- dataIndex : 'calcindex',
- search:false,
- hideInTable:true,
- width : 150
- },
-
- { title : '起始数据日期',
- dataIndex : 'sdate',
- search:false,
- hideInTable:true,
- width : 150
- },
-
- { title : '截止数据日期',
- dataIndex : 'edate',
- search:false,
- hideInTable:true,
- width : 150
- },
-
- { title : '年月',
- dataIndex : 'term',
- search:false,
- hideInTable:true,
- width : 150
- },
-
- { title : '数据日期',
- dataIndex : 'dataDate',
- search:false,
- hideInTable:true,
- width : 150
- },
-
- { title : '产品编号',
- dataIndex : 'productNo',
- search:false,
- hideInTable:true,
- width : 150
- },
-
- { title : '规则编号',
- dataIndex : 'ruleCode',
- width : 150
- },
-
- { title : '规则名称',
- dataIndex : 'ruleName',
- width : 150
- },
- { title : '数据类型',
- dataIndex : 'dataType',
- valueType:'select',
- request:()=>fetchDict({ dictKey :'DATA_TYPE'}),
- width : 150
- },
-
- { title : '对应科目号',
- dataIndex : 'ruleSubject',
- width : 150
- },
-
- { title : '输入数据源',
- dataIndex : 'ruleInName',
- width : 150
- },
-
- { title : '输出数据源',
- dataIndex : 'ruleOutName',
- width : 150
- },
-
- { title : '科目取数规则',
- dataIndex : 'ruleGetdata',
- width : 150
- },
- { title : '规则序号',
- dataIndex : 'ruleIndex',
- width : 150
- },]
-
- return (
- <SDPage>
- <SDTable
- title="查询表格"
- rowKey="customerName"
- request={async (formdata:SysListModel) =>{
- const formDatas = await getDataList(formdata);
- // 解构数组(导出用)
- formDataList=[...formDatas];
- return {data: formDatas}
- } }
- columns={columns}
- operations={['create']}
- actionRef={actionRef}
- formRef={formRef}
- setDetailVisible={() => {setDetailVisible(true)}}
- setEditType={setEditType}
- setCurrentRow={setCurrentRow}
- />
- {detailVisible && (
- <SDModalForm
- title={'详细信息'}
- editType={editType}
- params={currentRow}
- visible={detailVisible}
- onVisibleChange={() => {setDetailVisible(false)}}
- footer={[
- <SDSubmitButton editType={editType} formRef={formRef} doSubmit={handleSave} >保存</SDSubmitButton>,
- <SDButton
- key="closeUpdate"
- successMessage=''
- onClick={() => {
- setDetailVisible(false);
- }}>关闭</SDButton>
- ]}
- tableRef={actionRef}
- formRef={formRef}
- >
- <SDAreaTtile title='业务配置信息'/>
- <SDFormText name="businessCode" readonlyCond="update" bgValidater={roleidCheck} rules={[{max:20,message:'不可超过20个字符'},]} label="业务编号"/>
- <SDFormText name="businessName" label="业务名称" rules={[{validator:(rules,value,callback)=>{
- let chineseCount = countChineseChars(value);
- if (chineseCount > 50) {
- callback('最多50个汉字');
- } else if (chineseCount<=0) {
- callback('请输入汉字');
- } else{
- callback();
- }
- }}]}/>
- <SDFormDict name="businessAttr" dictKey="ONOROFF" label="表内外标识"/>
- </SDModalForm>
-
- )}
-
- {productListVisible &&
- <SDModalForm
- title={'产品列表'}
- visible={productListVisible}
- editType={editType}
- onVisibleChange={() => { setProductListVisible(false);}
- }>
- <SDLayout>
- <ProTable
- rowKey="productNo"
- search={false}
- dataSource={mockData}
- columns={productColumns}
- //singleSelect={false}
- actionRef={actionRef}
- formRef={formRef}
- />
- </SDLayout>
- </SDModalForm>
- }
- {subjectListVisible &&
- <SDModalForm
- title={'科目列表'}
- visible={subjectListVisible}
- editType={editType}
- onVisibleChange={() => { setSubjectListVisible(false);}
- }>
- <SDLayout>
- <ProTable
- rowKey="productNo"
- search={false}
- dataSource={subjectMockData}
- columns={subjectColumns}
- actionRef={actionRef}
- formRef={formRef}
- />
- </SDLayout>
- </SDModalForm>
- }
- {productDetailList &&
- <SDModalForm
- title={'产品列表'}
- visible={productDetailList}
- editType={editType}
- formRef={productDetailRef}
- onVisibleChange={() => { setProductDetailList(false);}
- }>
- <SDFormText name="productNo" label="产品代码" />
- <SDFormText name="productName" label="产品名称" />
- <SDFormDict name="productType" label="产品大类" dictKey='PRODUCT_TYPE' />
- <SDFormText name="productIndex" label="产品序号" />
- <SDFormDict name="productStageId" label="所属阶段" dictKey ='@productStageId' />
- <SDFormDict name="productFromSystem" label="来源系统" dictKey='PRODUCTFROMSYSTEM' />
- <SDFormDict name="defaultOut" label="默认输出数据源" dictKey='@selectdefaultOut' dictParam={`{"defaultOut":"${defaultOut}"}`} />
- <SDFormDict name="productBussinessCode" label="所属业务" dictKey='@BUSSINESS_CODE' />
- <SDFormText name="defaultGetdatarule" label="默认取数逻辑" />
- <SDAreaTtile title='科目取数规则列表' />
- <SDLayout>
- <ProTable
- rowKey="ruleCode"
- search={false}
- formRef={productDetailRef}
- dataSource={mockDetailData}
- columns={columns1}
- />
- </SDLayout>
- </SDModalForm>
- }
- </SDPage>
- );
- }
- export default bussiness;
|