|
@@ -1,15 +1,18 @@
|
|
|
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, } from "@sundata/ui-frame";
|
|
|
+import {Form, Input, Upload} from 'antd'
|
|
|
+import { SDPage,SDFormText,SDModalForm,SDTable,SDFormItem,SDButton,SDSubmitButton,EditType, SDAreaTtile, SDOperate, baseFun,SDModal, validateFun, SDLayout, SDFormAttach, SDFormDict, } from "@sundata/ui-frame";
|
|
|
import type { TemplateBasicInfoDefineModel,TemplateFieldDetailDefineModel } from '@/services/rwa/product/datasupplementary/supplementtemplatedefine';
|
|
|
import {getDataList,selectDetailData,getFieldDetailDataList,deleteInfoData,
|
|
|
updateRowData,createRowData,createFieldRowData
|
|
|
} from '@/services/rwa/product/datasupplementary/supplementtemplatedefine';
|
|
|
import { PlusSquareTwoTone, WomanOutlined } from "@ant-design/icons";
|
|
|
import { ProductProps } from "@/sundataImport";
|
|
|
+import { useModel } from '@umijs/max';
|
|
|
import { ReportCalculationModel } from "@/services/rwa/product/report_form_config_reportcreater/reportfillingconfig";
|
|
|
+import { number } from "echarts";
|
|
|
+import { toNumber } from "lodash";
|
|
|
type widowRush = {
|
|
|
onCancel: () => void;
|
|
|
onChangeVisible(visible: boolean, type: string): unknown;
|
|
@@ -23,17 +26,26 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
const [detailVisible, setDetailVisible] = useState<boolean>(false);
|
|
|
const [fieldDetailVisible, setFieldDetailVisible] = useState<boolean>(false);
|
|
|
const [currentRow, setCurrentRow] = useState<TemplateBasicInfoDefineModel>();
|
|
|
+ const { fetchDict } = useModel('dict');
|
|
|
/** 表格引用对象,刷新表格使用 */
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
const formRef = useRef<FormInstance<any>>();
|
|
|
const templateRef = useRef<FormInstance<any>>();
|
|
|
+ const fillInActionRef = useRef<ActionType>();
|
|
|
+ /** 附件上传组件主键 */
|
|
|
+ const [busiPk, setBusiPk] = useState<string>('');
|
|
|
|
|
|
const [formDetailData, setFormDetailData] = useState<TemplateFieldDetailDefineModel[]>();
|
|
|
// 页面数据
|
|
|
var formDataList = new Array<TemplateBasicInfoDefineModel>;
|
|
|
|
|
|
+ /** 编辑方式,查看、修改、新增按钮时设置,详细信息表单中使用 */
|
|
|
+ const [readRowType, setReadRowType] = useState<boolean>(false);
|
|
|
+ const [readColType, setReadColType] = useState<boolean>(false);
|
|
|
+
|
|
|
/** 字段关系序号编辑 */
|
|
|
- var dataIndex = 1;
|
|
|
+ var dataInfoIndex = 1;
|
|
|
+ var dataDetailIndex = 0;
|
|
|
|
|
|
useEffect(() => {
|
|
|
}, []);
|
|
@@ -42,7 +54,7 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
// 修改查询查询
|
|
|
const selectData = async (formdata : TemplateBasicInfoDefineModel) => {
|
|
|
const data = await selectDetailData(formdata);
|
|
|
- formRef.current?.setFieldsValue(data);
|
|
|
+ templateRef.current?.setFieldsValue(data);
|
|
|
const dataList = await getFieldDetailDataList(formdata);
|
|
|
setFormDetailData(dataList);
|
|
|
}
|
|
@@ -57,7 +69,7 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
}
|
|
|
|
|
|
// 插入或者更新数据
|
|
|
- const handleSave = async(data: TemplateBasicInfoDefineModel,) => {
|
|
|
+ const handleSave = async(data: TemplateBasicInfoDefineModel) => {
|
|
|
|
|
|
if (editType == 'update' ) {
|
|
|
await updateRowData(data);
|
|
@@ -73,7 +85,6 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
const handleFieldSave = async(data: TemplateBasicInfoDefineModel,) => {
|
|
|
await createFieldRowData(data);
|
|
|
closeAndRefresh();
|
|
|
- setFieldDetailVisible(false);
|
|
|
}
|
|
|
|
|
|
//关闭窗口刷新父页面
|
|
@@ -89,7 +100,7 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
title: '序号',
|
|
|
dataIndex: 'index',
|
|
|
search: false,
|
|
|
- render: (text, record, index) => { index = index + 1;dataIndex = index; return index},
|
|
|
+ render: (text, record, index) => { index = index + 1;dataInfoIndex = index; return index},
|
|
|
width:100,
|
|
|
ellipsis:true
|
|
|
},
|
|
@@ -158,6 +169,7 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
selectData(record);
|
|
|
setDetailVisible(true);
|
|
|
setEditType('update');
|
|
|
+ setBusiPk(String(dataInfoIndex));
|
|
|
} }
|
|
|
>
|
|
|
修改
|
|
@@ -197,11 +209,12 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
const detailColumns: ProColumns<TemplateFieldDetailDefineModel>[] = [
|
|
|
{
|
|
|
title: '序号',
|
|
|
- dataIndex: 'index',
|
|
|
+ dataIndex: 'id',
|
|
|
search: false,
|
|
|
- render: (text, record, index) => { index = index + 1; return index},
|
|
|
+ render: (text, record, index) => { index = index + 1;dataDetailIndex = index; return index},
|
|
|
width:100,
|
|
|
- ellipsis:true
|
|
|
+ ellipsis:true,
|
|
|
+ editable:false
|
|
|
},
|
|
|
{
|
|
|
title: '计算实例号',
|
|
@@ -231,16 +244,65 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
title: '行列类型',
|
|
|
dataIndex: 'rowColType',
|
|
|
hideInTable: false,
|
|
|
+ valueType:'treeSelect',
|
|
|
+ request: () => fetchDict('ROW_COLUMN_TYPE'),
|
|
|
+ fieldProps: {
|
|
|
+ treeDefaultExpandAll: true,
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
title: '行范围',
|
|
|
dataIndex: 'filedRowRange',
|
|
|
hideInTable: false,
|
|
|
+ formItemProps:{
|
|
|
+ rules:[
|
|
|
+ {pattern: RegExp(`[0-9]+\\-[0-9]+|[n|N]`),message:'请输入正确范围'},
|
|
|
+ {validator:(rules,value,callback)=>{
|
|
|
+ if (String(value).split('-').length == 2) {
|
|
|
+ let rowStart = String(value).split('-')[0];
|
|
|
+ let rowEnd = String(value).split('-')[1];
|
|
|
+ let formRange = templateRef.current?.getFieldValue('rowRange');
|
|
|
+ if (formRange) {
|
|
|
+ let formRowStart = String(formRange).split('-')[0];
|
|
|
+ let formRowEnd = String(formRange).split('-')[1];
|
|
|
+ if (toNumber(rowStart) > toNumber(formRowStart) || toNumber(rowEnd) > toNumber(formRowEnd)){
|
|
|
+ callback('输入范围超出上方规定范围');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback('上方输入框内行范围必输');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ }},
|
|
|
+ ]
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
title: '列范围',
|
|
|
dataIndex: 'filedColumnRange',
|
|
|
hideInTable: false,
|
|
|
+ formItemProps:{
|
|
|
+ rules:[
|
|
|
+ {pattern: RegExp(`[0-9]+\\-[0-9]+|[n|N]`),message:'请输入正确范围'},
|
|
|
+ {validator:(rules,value,callback)=>{
|
|
|
+ if (String(value).split('-').length == 2) {
|
|
|
+ let rowStart = String(value).split('-')[0];
|
|
|
+ let rowEnd = String(value).split('-')[1];
|
|
|
+ let formRange = templateRef.current?.getFieldValue('rowRange');
|
|
|
+ if (formRange) {
|
|
|
+ let formRowStart = String(formRange).split('-')[0];
|
|
|
+ let formRowEnd = String(formRange).split('-')[1];
|
|
|
+ if (toNumber(rowStart) > toNumber(formRowStart) || toNumber(rowEnd) > toNumber(formRowEnd)){
|
|
|
+ callback('输入范围超出上方规定范围');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback('上方输入框内行范围必输');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ callback();
|
|
|
+ }},
|
|
|
+ ]
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
title: '字段类型与长度',
|
|
@@ -252,6 +314,36 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
dataIndex: 'remark',
|
|
|
hideInTable: false,
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'operate',
|
|
|
+ valueType: 'option',
|
|
|
+ render: (_, record) => [
|
|
|
+ <SDOperate
|
|
|
+ key="roleCfg"
|
|
|
+ icon={<WomanOutlined />}
|
|
|
+ successMessage=""
|
|
|
+ onClick={
|
|
|
+ ()=>{
|
|
|
+ fillInActionRef.current?.startEditable(dataDetailIndex);
|
|
|
+ } }
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </SDOperate>,
|
|
|
+ <SDOperate
|
|
|
+ key="roleCfg"
|
|
|
+ icon={<WomanOutlined />}
|
|
|
+ successMessage=""
|
|
|
+ onClick={
|
|
|
+ ()=>{
|
|
|
+ setFormDetailData(...[formDetailData?.filter((item)=>{return item.id != record.id})]);
|
|
|
+ fillInActionRef.current?.cancelEditable(dataDetailIndex);
|
|
|
+ } }
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </SDOperate>,
|
|
|
+ ],
|
|
|
+ },
|
|
|
];
|
|
|
|
|
|
return (
|
|
@@ -303,62 +395,68 @@ const supplementtemplatedefine : React.FC<widowRush> = (prop:widowRush) => {
|
|
|
}}>关闭</SDButton>
|
|
|
]}
|
|
|
tableRef={actionRef}
|
|
|
- formRef={formRef}
|
|
|
+ formRef={templateRef}
|
|
|
+ onValuesChange={(changedValues,values)=>{
|
|
|
+ if (changedValues.tmpType && changedValues.tmpType == 'FIXED_COLUMN') {
|
|
|
+ templateRef.current?.setFieldValue("rowRange",'');
|
|
|
+ setReadRowType(true);
|
|
|
+ setReadColType(false);
|
|
|
+ } else if (changedValues.tmpType && changedValues.tmpType == 'FIXED_ROW') {
|
|
|
+ templateRef.current?.setFieldValue("columnRange",'');
|
|
|
+ setReadColType(true);
|
|
|
+ setReadRowType(false);
|
|
|
+ } else {
|
|
|
+ setReadRowType(false);
|
|
|
+ setReadColType(false);
|
|
|
+ }
|
|
|
+ }}
|
|
|
>
|
|
|
- <SDAreaTtile title='规则信息'/>
|
|
|
+ <SDAreaTtile title='补录模板新增页面'/>
|
|
|
<SDFormText name="tmpCode" readonlyCond="update" required={true} label="模板编号"/>
|
|
|
<SDFormText name="tmpName" label="模板名称"/>
|
|
|
- <SDFormText name="tmpType" label="模板类型"/>
|
|
|
- <SDFormText name="rowRange" label="行范围"/>
|
|
|
- <SDFormText name="columnRange" label="列范围"/>
|
|
|
- <SDFormText name="tmpFileCode" label="模板文件上传"/>
|
|
|
-
|
|
|
+ <SDFormDict dictKey="TEMPLATE_TYPE" name="tmpType" label="模板类型"/>
|
|
|
+ <SDFormText name="rowRange" disabled={readRowType}
|
|
|
+ rules={[{pattern: RegExp(`[0-9]+\\-[0-9]+|[n|N]`),message:'请输入正确范围'}]}
|
|
|
+ label="行范围" placeholder={'例:1-3'}/>
|
|
|
+ <SDFormText name="columnRange" disabled={readColType}
|
|
|
+ rules={[{pattern: RegExp(`[0-9]+\\-[0-9]+|[n|N]`),message:'请输入正确范围'}]}
|
|
|
+ label="列范围" placeholder={'例:1-3'}/>
|
|
|
+ <SDFormAttach name={"tmpFileCode"} label="模板文件上传" funcType={"supplementtemplatedefine"} filetype="" maxFileNum={1} busiPkId={busiPk}/>
|
|
|
<SDLayout>
|
|
|
<SDAreaTtile title='模板范围配置'/>
|
|
|
- <ProTable
|
|
|
- search={false}
|
|
|
- rowKey="index"
|
|
|
- columns={detailColumns}
|
|
|
- dataSource={formDetailData}
|
|
|
- toolBarRender={(_, { selectedRowKeys }) => editType == 'create' || editType == 'update' ? [
|
|
|
- <SDButton
|
|
|
- key="export"
|
|
|
- successMessage=''
|
|
|
- onClick={() => {
|
|
|
+ <EditableProTable
|
|
|
+ rowKey="id"
|
|
|
+ columns={detailColumns}
|
|
|
+ recordCreatorProps={false}
|
|
|
+ actionRef={fillInActionRef}
|
|
|
+ value={formDetailData}
|
|
|
+ editable={{
|
|
|
+ actionRender: (row,config,defaultDoms)=>{
|
|
|
+ return [defaultDoms.save,defaultDoms.cancel]
|
|
|
+ }
|
|
|
}}
|
|
|
- >
|
|
|
- 新增
|
|
|
- </SDButton>,
|
|
|
- ]:[]}
|
|
|
- />
|
|
|
+ toolBarRender={(_, { selectedRowKeys }) => [
|
|
|
+ <SDButton
|
|
|
+ key="export"
|
|
|
+ successMessage=''
|
|
|
+ onClick={() => {
|
|
|
+ fillInActionRef.current?.addEditRecord?.({
|
|
|
+ id: dataDetailIndex+1,
|
|
|
+ title: 'NEWROW',
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </SDButton>,
|
|
|
+ ]}
|
|
|
+ onChange={ (value: readonly TemplateFieldDetailDefineModel[]) => {
|
|
|
+ setFormDetailData([...value]);
|
|
|
+ } }
|
|
|
+ />
|
|
|
</SDLayout>
|
|
|
</SDModalForm>
|
|
|
)}
|
|
|
|
|
|
- {fieldDetailVisible && (
|
|
|
- <SDModalForm
|
|
|
- visible={fieldDetailVisible}
|
|
|
- onVisibleChange={() => {setFieldDetailVisible(false)}}
|
|
|
- footer={[
|
|
|
- <SDSubmitButton editType={editType} formRef={formRef} doSubmit={handleFieldSave} >保存</SDSubmitButton>,
|
|
|
- <SDButton
|
|
|
- key="closeUpdate"
|
|
|
- successMessage=''
|
|
|
- onClick={() => {
|
|
|
- setFieldDetailVisible(false);
|
|
|
- }}>关闭</SDButton>
|
|
|
- ]}
|
|
|
- >
|
|
|
- <SDFormText name="tmpName" label="行列类型"/>
|
|
|
- <SDFormText name="tmpType" label="行范围"/>
|
|
|
- <SDFormText name="rowRange" label="列范围"/>
|
|
|
- <SDFormText name="columnRange" label="字段类型与长度"/>
|
|
|
- <SDFormText name="tmpFileCode" label="数据项说明"/>
|
|
|
- </SDModalForm>
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
</SDPage>
|
|
|
|
|
|
);
|