|
@@ -0,0 +1,340 @@
|
|
|
+import React, { useEffect, useRef, useState } from "react";
|
|
|
+import { type ProColumns, type ActionType, type ProFormInstance, ProTable } from '@ant-design/pro-components';
|
|
|
+import {Flex, type FormInstance} from 'antd'
|
|
|
+import { SDPage,SDTable,EditType,DictTree,SDFormItem,SDButton, baseFun,SDModalForm,SDOperate,SDSubmitButton, SDAreaTtile, SDFormDict, SDFormText, SDLayout, validateFun } from "@sundata/ui-frame";
|
|
|
+import { ProductProps } from "@/sundataImport";
|
|
|
+import { useModel } from '@umijs/max';
|
|
|
+import { PlusSquareTwoTone, WomanOutlined } from "@ant-design/icons";
|
|
|
+import { max, toNumber } from "lodash";
|
|
|
+import { deleteRows, getDataList, isNotExist,updateRowData, ReportParamDefineModel, createRowData } from "@/services/rwa/product/report_form_config_reportcreater/reportparamdefine";
|
|
|
+
|
|
|
+type widowProps = {
|
|
|
+ onCancel: () => void;
|
|
|
+ onChangeVisible(visible: boolean, type: string): unknown;
|
|
|
+ onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
|
|
|
+ treeData: DictTree[];
|
|
|
+}& ProductProps;
|
|
|
+// 客户基本信息表
|
|
|
+const reportparamdefine : React.FC<widowProps> = (prop:widowProps) => {
|
|
|
+
|
|
|
+ /** 编辑方式,查看、修改、新增按钮时设置,详细信息表单中使用 */
|
|
|
+ const [editType, setEditType] = useState<EditType>(prop.editType || 'display');
|
|
|
+ const [toolRuleEditType, setToolRuleEditType] = useState<EditType>(prop.editType || 'display');
|
|
|
+ /** 是否显示详细信息窗口 */
|
|
|
+ const [detailVisible, setDetailVisible] = useState<boolean>(false);
|
|
|
+
|
|
|
+
|
|
|
+ const [currentRow, setCurrentRow] = useState<ReportParamDefineModel>();
|
|
|
+
|
|
|
+
|
|
|
+ /** 参数编号编辑 */
|
|
|
+ const [paramIndex,setParamIndex] = useState<number>(0);
|
|
|
+
|
|
|
+ /** 表格引用对象,刷新表格使用 */
|
|
|
+ const actionRef = useRef<ActionType>();
|
|
|
+ const formRef = useRef<FormInstance<any>>();
|
|
|
+
|
|
|
+
|
|
|
+ const { fetchDict } = useModel('dict');
|
|
|
+
|
|
|
+ // 页面数据
|
|
|
+ var formDataList = new Array<ReportParamDefineModel>;
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+
|
|
|
+ }, []);
|
|
|
+
|
|
|
+
|
|
|
+ //关闭窗口刷新父页面
|
|
|
+ const closeAndRefresh = ()=>{
|
|
|
+ actionRef.current?.reloadAndRest?.();
|
|
|
+ }
|
|
|
+
|
|
|
+ const selectRowData =async (record:any) => {
|
|
|
+ await getDataList(record);
|
|
|
+ formRef.current?.setFieldsValue(record);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 步骤删除
|
|
|
+ const delRows =async(record:any)=>{
|
|
|
+ baseFun.confirm('确认删除?',async() =>{
|
|
|
+ await deleteRows(record);
|
|
|
+ baseFun.info("删除成功");
|
|
|
+ closeAndRefresh();
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 插入或者更新数据
|
|
|
+ const handleSave = async(data: ReportParamDefineModel,) => {
|
|
|
+ if (editType == 'update') {
|
|
|
+ if (currentRow && currentRow.paramNo) {
|
|
|
+ updateRowData(data,currentRow.paramNo);
|
|
|
+ setDetailVisible(false);
|
|
|
+ closeAndRefresh();
|
|
|
+ }
|
|
|
+ } else if (editType == 'create') {
|
|
|
+ await createRowData(data);
|
|
|
+ setDetailVisible(false);
|
|
|
+ closeAndRefresh();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 阶段信息页面展示元素
|
|
|
+ const columns: ProColumns<ReportParamDefineModel>[] = [
|
|
|
+ {
|
|
|
+ title: '序号',
|
|
|
+ dataIndex: 'index',
|
|
|
+ render: (text, record, index) => {(index = index + 1);setParamIndex(index); return index},
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '计算实例号',
|
|
|
+ dataIndex: 'calcindex',
|
|
|
+ search: false,
|
|
|
+ hideInTable: true,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '起始数据日期',
|
|
|
+ dataIndex: 'startDate',
|
|
|
+ search: false,
|
|
|
+ hideInTable: true,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '截止数据日期',
|
|
|
+ dataIndex: 'endDate',
|
|
|
+ search: false,
|
|
|
+ hideInTable: true,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '年月',
|
|
|
+ dataIndex: 'term',
|
|
|
+ search: false,
|
|
|
+ hideInTable: true,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '数据日期',
|
|
|
+ dataIndex: 'dataDate',
|
|
|
+ search:false,
|
|
|
+ hideInTable: true,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true,
|
|
|
+ valueType: 'date',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数编号',
|
|
|
+ dataIndex: 'paramNo',
|
|
|
+ search:false,
|
|
|
+ hideInTable: false,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数名称',
|
|
|
+ dataIndex: 'paramName',
|
|
|
+ hideInTable: false,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数计算类型',
|
|
|
+ dataIndex: 'paramCalcType',
|
|
|
+ hideInTable: false,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true,
|
|
|
+ valueType: 'treeSelect',
|
|
|
+ request: () => fetchDict('CALC_TASK_RATE'),
|
|
|
+ fieldProps: {
|
|
|
+ treeDefaultExpandAll: true,
|
|
|
+ treeCheckable:true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数对象名称',
|
|
|
+ dataIndex: 'paramObjectName',
|
|
|
+ hideInTable: false,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '参数计算配置',
|
|
|
+ dataIndex: 'paramCalcGetdata',
|
|
|
+ search:false,
|
|
|
+ hideInTable: false,
|
|
|
+ width:150,
|
|
|
+ ellipsis:true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'operate',
|
|
|
+ valueType: 'option',
|
|
|
+ render: (_, record) => [
|
|
|
+ <SDOperate
|
|
|
+ key="update"
|
|
|
+ icon={<WomanOutlined />}
|
|
|
+ successMessage=""
|
|
|
+ onClick={
|
|
|
+ ()=>{
|
|
|
+ setDetailVisible(true);
|
|
|
+ setEditType('update');
|
|
|
+ setCurrentRow(record);
|
|
|
+ selectRowData(record);
|
|
|
+ } }
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </SDOperate>,
|
|
|
+ <SDOperate
|
|
|
+ key="delete"
|
|
|
+ icon={<WomanOutlined />}
|
|
|
+ successMessage=""
|
|
|
+ onClick={()=>{
|
|
|
+ delRows(record) } }
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </SDOperate>,
|
|
|
+ <SDOperate
|
|
|
+ key="update"
|
|
|
+ icon={<WomanOutlined />}
|
|
|
+ successMessage=""
|
|
|
+ onClick={
|
|
|
+ ()=>{
|
|
|
+ setDetailVisible(true);
|
|
|
+ setEditType('display');
|
|
|
+ setCurrentRow(record);
|
|
|
+ selectRowData(record);
|
|
|
+ } }
|
|
|
+ >
|
|
|
+ 查看
|
|
|
+ </SDOperate>,
|
|
|
+ ],
|
|
|
+ },
|
|
|
+];
|
|
|
+
|
|
|
+// 中文字数校验
|
|
|
+function countChineseChars(str:any) {
|
|
|
+ const chineseRegex = /[\u4e00-\u9fa5]/g; // 匹配任何中文字符
|
|
|
+ if (null == str || undefined == str || '' == str) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return str.match(chineseRegex)?.length || 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+return (
|
|
|
+ <SDPage>
|
|
|
+ <SDTable
|
|
|
+ title="查询表格"
|
|
|
+ rowKey="regularRrcsRuleNo"
|
|
|
+ request={async (formdata:ReportParamDefineModel) =>{
|
|
|
+ const formDatas = await getDataList(formdata);
|
|
|
+ // 解构数组(导出用)
|
|
|
+ formDataList=[...formDatas];
|
|
|
+ return {data: formDatas}
|
|
|
+ } }
|
|
|
+ columns={columns}
|
|
|
+ toolBarRender={(_, { selectedRows }) => [
|
|
|
+ <SDButton
|
|
|
+ key="create"
|
|
|
+ icon={<PlusSquareTwoTone/>}
|
|
|
+ successMessage=''
|
|
|
+ onClick={() => {
|
|
|
+ setDetailVisible(true);
|
|
|
+ setEditType('create');
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </SDButton>,
|
|
|
+ ]}
|
|
|
+ actionRef={actionRef}
|
|
|
+ formRef={formRef}
|
|
|
+ setDetailVisible={() => {setDetailVisible(true)}}
|
|
|
+ setEditType={setEditType}
|
|
|
+ setCurrentRow={setCurrentRow}
|
|
|
+ />
|
|
|
+
|
|
|
+ {detailVisible && (
|
|
|
+ <SDModalForm
|
|
|
+ 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}
|
|
|
+ initialValues={{
|
|
|
+ paramNo:"PARAM"+(paramIndex+1),
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <SDAreaTtile title='参数信息'/>
|
|
|
+ <SDFormText name="paramNo"
|
|
|
+ bgValidater={(paramNo: string) => isNotExist(
|
|
|
+ {
|
|
|
+ calcIndex: "",
|
|
|
+ startDate: "",
|
|
|
+ endDate: "",
|
|
|
+ term: "",
|
|
|
+ dataDate: "",
|
|
|
+ paramNo: paramNo == undefined ? "":paramNo,
|
|
|
+ paramName: "",
|
|
|
+ paramCalcType: "",
|
|
|
+ paramObjectName: "",
|
|
|
+ paramCalcGetdata: ""
|
|
|
+ }
|
|
|
+ )}
|
|
|
+ required={true} readonlyCond="both" label="参数编号"/>
|
|
|
+ <SDFormText name="paramName" label="参数名称" rules={[{validator:(rules,value,callback)=>{
|
|
|
+ let chineseCount = countChineseChars(value);
|
|
|
+ if (chineseCount > 100) {
|
|
|
+ callback('最多100个汉字');
|
|
|
+ } else if (chineseCount<=0) {
|
|
|
+ callback('请输入汉字');
|
|
|
+ } else{
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ }}]}/>
|
|
|
+ <SDFormDict dictKey='CALC_TASK_RATE' name="paramCalcType" label="参数计算类型" />
|
|
|
+ <SDFormText name="paramObjectName" required={true} rules={[{max:100,message:'最多100个字符'}]}
|
|
|
+ bgValidater={(paramObjectName: string) => isNotExist(
|
|
|
+ {
|
|
|
+ calcIndex: "",
|
|
|
+ startDate: "",
|
|
|
+ endDate: "",
|
|
|
+ term: "",
|
|
|
+ dataDate: "",
|
|
|
+ paramNo: "",
|
|
|
+ paramName: "",
|
|
|
+ paramCalcType: "",
|
|
|
+ paramObjectName: paramObjectName == undefined ? "":paramObjectName,
|
|
|
+ paramCalcGetdata: ""
|
|
|
+ }
|
|
|
+ )}
|
|
|
+ label="参数对象名称"/>
|
|
|
+ <SDFormText type="textarea" name="paramCalcGetdata" label="参数计算配置"/>
|
|
|
+
|
|
|
+ </SDModalForm>
|
|
|
+ )}
|
|
|
+ </SDPage>
|
|
|
+
|
|
|
+);
|
|
|
+}
|
|
|
+export default reportparamdefine;
|