123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- import React, { useEffect, useRef, useState } from "react";
- import { type ProColumns, type ActionType, type ProFormInstance, ProTable, EditableProTable } from '@ant-design/pro-components';
- import type {FormInstance} from 'antd'
- import {Upload} from 'antd'
- import { SDPage,SDFormText,SDModalForm,SDTable,SDFormItem,SDButton,SDSubmitButton,EditType, SDAreaTtile, SDOperate, baseFun,SDModal, validateFun, SDLayout, SDFormDict, } from "@sundata/ui-frame";
- import type { SupplementTaskDefineModel,SupplementTemplateRelationModel,TemplateDataValidationRuleModel, } from '@/services/rwa/product/datasupplementary/supplementtaskmanagement';
- import {getDataList,selectDetailData,getTemplateCheckDataList,getTemplateDataList,deleteInfoData,updateRowData,
- createRowData,createTemplateListRowData,createTemplateCheckRowData} from '@/services/rwa/product/datasupplementary/supplementtaskmanagement';
- import { PlusSquareTwoTone, WomanOutlined } from "@ant-design/icons";
- import { ProductProps } from "@/sundataImport";
- import { toNumber } from "lodash";
- type widowRush = {
- onCancel: () => void;
- onChangeVisible(visible: boolean, type: string): unknown;
- onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
- }& ProductProps;
- const supplementtaskmanagement : React.FC<widowRush> = (prop:widowRush) => {
- /** 编辑方式,查看、修改、新增按钮时设置,详细信息表单中使用 */
- const [editType, setEditType] = useState<EditType>(prop.editType || 'display');
- /** 是否显示详细信息窗口 */
- const [detailVisible, setDetailVisible] = useState<boolean>(false);
- const [currentRow, setCurrentRow] = useState<SupplementTaskDefineModel>();
- /** 表格引用对象,刷新表格使用 */
- const actionRef = useRef<ActionType>();
- const formRef = useRef<FormInstance<any>>();
- const templateListRef = useRef<FormInstance<any>>();
- const templateCheckRef = useRef<FormInstance<any>>();
- const templateListActionRef = useRef<ActionType>();
- const templateCheckActionRef = useRef<ActionType>();
- const [templateListData, setTemplateListData] = useState<SupplementTemplateRelationModel[]>();
- const [templateCheckData, setTemplateCheckData] = useState<TemplateDataValidationRuleModel[]>();
- // const [resMap, setResMap] = useState<ModelMap>();
- // 页面数据
- var formDataList = new Array<SupplementTaskDefineModel>;
- /** 字段关系序号编辑 */
- var dataInfoIndex = 1;
- var dataDetailIndex = 0;
- useEffect(() => {
- }, []);
-
- // 修改查询查询
- const selectData = async (formdata : SupplementTaskDefineModel) => {
- const data = await selectDetailData(formdata);
- formRef.current?.setFieldsValue(data);
- const dataList = await getTemplateDataList(formdata);
- setTemplateListData(...[dataList]);
- const templateList = await getTemplateCheckDataList(formdata);
- setTemplateCheckData(...[templateList]);
- }
- // 删除
- const deleteData = async(formdata : SupplementTaskDefineModel) => {
- baseFun.confirm('请确认是否继续操作?',async() =>{
- await deleteInfoData(formdata);
- baseFun.info("删除成功");
- closeAndRefresh();
- });
- }
- // 插入或者更新数据
- const handleSave = async(data: SupplementTaskDefineModel,) => {
-
- if (editType == 'update' ) {
- await updateRowData(data).then(()=>{
- if (templateListData && templateCheckData) {
- createTemplateListRowData(templateListData,data.taskCode);
- createTemplateCheckRowData(templateCheckData);
- }
- });
- closeAndRefresh();
- } else if (editType == 'create' ) {
- await createRowData(data).then(()=>{
- if (templateListData && templateCheckData) {
- createTemplateListRowData(templateListData,data.taskCode);
- createTemplateCheckRowData(templateCheckData);
- }
- });
- closeAndRefresh();
- }
- setDetailVisible(false);
- }
- //关闭窗口刷新父页面
- const closeAndRefresh = ()=>{
- actionRef.current?.reloadAndRest?.();
- }
-
- // 数据补录模板定义
- const columns: ProColumns<SupplementTaskDefineModel>[] = [
- {
- title: '序号',
- dataIndex: 'index',
- search: false,
- render: (text, record, index) => { index = index + 1;return index},
- 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: 'term',
- search: false,
- hideInTable: true,
- },
- {
- title: '任务编号',
- dataIndex: 'taskCode',
- hideInTable: false,
- },
- {
- title: '任务名称',
- dataIndex: 'taskName',
- hideInTable: false,
- },
- {
- title: '负责机构',
- dataIndex: 'orgCode',
- hideInTable: false,
- },
- {
- title: '首选负责人',
- dataIndex: 'account',
- hideInTable: false,
- search: false,
- },
- {
- title: '补录频率',
- dataIndex: 'frequency',
- hideInTable: false,
- search: false,
- },
- {
- title: '天数调整',
- dataIndex: 'adjustment',
- hideInTable: false,
- search: false,
- },
- {
- title: '包含模板',
- dataIndex: 'tmpNames',
- hideInTable: false,
- search: false,
- },
- {
- title: '状态',
- dataIndex: 'status',
- hideInTable: false,
- search: false,
- },
- {
- title: '操作',
- dataIndex: 'operate',
- valueType: 'option',
- render: (_, record) => [
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={
- ()=>{
- selectData(record);
- setDetailVisible(true);
- setEditType('update');
- } }
- >
- 修改
- </SDOperate>,
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={
- ()=>{
- deleteData(record);
- setDetailVisible(true);
- setEditType('update');
- } }
- >
- 作废
- </SDOperate>,
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={
- ()=>{
- selectData(record);
- setDetailVisible(true);
- setEditType('update');
- } }
- >
- 查看
- </SDOperate>,
-
- ],
- },
- ];
- // 补录模板列表
- const templateListColumns: ProColumns<SupplementTemplateRelationModel>[] = [
- {
- title: '序号',
- dataIndex: 'id',
- search: false,
- render: (text, record, index) => { index = index + 1;dataInfoIndex = index; return index},
- width:100,
- ellipsis:true,
- editable:false
- },
- {
- title: '计算实例号',
- dataIndex: 'calcIndex',
- search: false,
- hideInTable: true,
- },
- {
- title: '起始数据日期',
- dataIndex: 'startDate',
- search: false,
- hideInTable: true,
- },
- {
- title: '截止数据日期',
- dataIndex: 'endDate',
- search: false,
- hideInTable: true,
- },
- {
- title: '期次',
- dataIndex: 'term',
- search: false,
- hideInTable: true,
- },
- {
- title: '补录模板',
- dataIndex: 'tmpCode',
- search: false,
- hideInTable: false,
- formItemProps:{
- rules:[
- {required:true},]
- }
- },
- {
- title: '补录模板说明',
- dataIndex: 'remark',
- search: false,
- hideInTable: false,
- },
- {
- title: '数据初始化逻辑',
- dataIndex: 'sqlCode',
- search: false,
- hideInTable: false,
- },
- {
- title: '操作',
- dataIndex: 'operate',
- valueType: 'option',
- render: (_, record) => [
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={async ()=>{
- templateListActionRef.current?.startEditable(record.tmpCode);
- } }
- >
- 编辑
- </SDOperate>,
- ],
- },
- ];
- // 补录模板校验规则
- const templateCheckColumns: ProColumns<TemplateDataValidationRuleModel>[] = [
- {
- title: '序号',
- dataIndex: 'id',
- search: false,
- render: (text, record, index) => { index = index + 1;dataDetailIndex =index; return index},
- width:100,
- ellipsis:true,
- editable:false
- },
- {
- 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: 'tmpverificationName',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '补录模板',
- dataIndex: 'tmpCode',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '行列类型',
- dataIndex: 'tmpverRowColType',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '模板验证时点',
- dataIndex: 'vartimmer',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '行范围',
- dataIndex: 'tmpverRowRange',
- hideInTable: false,
- width:150,
- ellipsis:true,
- formItemProps:{
- rules:[
- {pattern: RegExp(`[0-9]+\\-[0-9]+|[n|N]`),message:'请输入正确范围'},]
- }
- },
- {
- title: '列范围',
- dataIndex: 'tmpverColumnRange',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '约束方式',
- dataIndex: 'checkType',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '数据类型',
- dataIndex: 'remark',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '约束公式',
- dataIndex: 'remark',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '约束规则SQL',
- dataIndex: 'remark',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '越界处理方式',
- dataIndex: 'remark',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '提示信息模板',
- dataIndex: 'remark',
- hideInTable: false,
- width:150,
- ellipsis:true
- },
- {
- title: '操作',
- dataIndex: 'operate',
- valueType: 'option',
- width:150,
- ellipsis:true,
- render: (_, record) => [
- <SDOperate
- key="roleCfg"
- icon={<WomanOutlined />}
- successMessage=""
- onClick={
- async()=>{
- templateCheckActionRef.current?.startEditable(record.tmpverificationCode);
- }}
- >
- 编辑
- </SDOperate>,
- ],
- },
- ];
-
- return (
- <SDPage>
- <SDTable
- title="查询表格"
- rowKey="customerName"
- request={async (formdata:SupplementTaskDefineModel) =>{
- const formDatas = await getDataList(formdata);
- // 解构数组(导出用)
- formDataList=[...formDatas];
- return {data: formDatas}
- } }
- columns={columns}
- toolBarRender={(_, { selectedRows }) => [
- <SDButton
- key="export"
- icon={<PlusSquareTwoTone/>}
- successMessage=''
- onClick={() => {
- setEditType('create');
- setDetailVisible(true);
- setTemplateListData([]);
- setTemplateCheckData([]);
- }}
- >
- 新增
- </SDButton>,
- ]}
- 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="taskCode" readonlyCond="update" required={true} label="任务编号"/>
- <SDFormText name="taskName" label="任务名称"/>
- <SDFormDict dictKey="" name="orgCode" label="责任机构"/>
- <SDFormDict dictKey="" name="account" label="首选责任人"/>
- <SDFormDict dictKey="CALC_TASK_RATE" name="frequency" label="补录频率"/>
- <SDFormText name="adjustment" label="天数调整"/>
- <SDFormDict dictKey="" name="tmpFileCode" label="所属阶段"/>
- <SDLayout>
- <SDAreaTtile title='补录模板列表'/>
- <EditableProTable
- rowKey="tmpCode"
- columns={templateListColumns}
- recordCreatorProps={false}
- actionRef={templateListActionRef}
- value={templateListData}
- editable={{
- actionRender: (row,config,defaultDoms)=>{
- return [defaultDoms.save,defaultDoms.delete,defaultDoms.cancel]
- }
- }}
- toolBarRender={(_, { selectedRowKeys }) => editType == 'create' || editType == 'update' ? [
- <SDButton
- key="export"
- successMessage=''
- onClick={() => {
- templateListActionRef.current?.addEditRecord?.({
- tmpCode: dataInfoIndex+1,
- title: 'NEWROW',
- });
- }}
- >
- 新增
- </SDButton>,
- ]:[]}
- onChange={ (value: readonly SupplementTemplateRelationModel[]) => {
- setTemplateListData([...value]);
- } }
- />
- </SDLayout>
- <SDLayout>
- <SDAreaTtile title='补录模板校验规则'/>
- <EditableProTable
- rowKey="tmpverificationCode"
- columns={templateCheckColumns}
- recordCreatorProps={false}
- actionRef={templateCheckActionRef}
- scroll={{ x: 1500 }}
- value={templateCheckData}
- editable={{
- actionRender: (row,config,defaultDoms)=>{
- return [defaultDoms.save,defaultDoms.delete,defaultDoms.cancel]
- }
- }}
- toolBarRender={(_, { selectedRowKeys }) => editType == 'create' || editType == 'update' ? [
- <SDButton
- key="export"
- successMessage=''
- onClick={() => {
- templateCheckActionRef.current?.addEditRecord?.({
- tmpverificationCode: dataDetailIndex+1,
- title: 'NEWROW',
- });
- }}
- >
- 新增
- </SDButton>,
- ]:[]}
- onChange={ (value: readonly TemplateDataValidationRuleModel[]) => {
- setTemplateCheckData([...value]);
- } }
- />
- </SDLayout>
- </SDModalForm>
- )}
- </SDPage>
-
- );
- }
- export default supplementtaskmanagement;
|