|
@@ -1,15 +1,17 @@
|
|
|
import React, { useEffect, useRef, useState } from 'react';
|
|
|
-import { Button, Form, FormInstance, Input, Space, Tooltip } from 'antd';
|
|
|
-import { EditType, SDForm, SDFormDict, SDFormText, SDModal, SDModalForm, SDOperate, SDPage, SDSubmitButton, SDTable, baseFun, SDButton } from '@sundata/ui-frame';
|
|
|
-import { SovereignModel, deleteSovereign, getSovereign, inserteSovere, selectSovereign, exportExcelModel, selectSovereignCode } from '@/services/rwa/sovereign';
|
|
|
+import { Button, Form, FormInstance, Input, Space, Tooltip, Upload } from 'antd';
|
|
|
+import { EditType, SDForm, SDFormDict, SDFormText, SDModal, SDModalForm, SDOperate, SDPage, SDSubmitButton, SDTable, baseFun, SDButton, SDFormItem, validateFun } from '@sundata/ui-frame';
|
|
|
+import { SovereignModel, deleteSovereign, getSovereign, inserteSovere, selectSovereign, exportExcelModel, selectSovereignCode, updateSovereign, uploadAction, templateUpload } from '@/services/rwa/sovereign';
|
|
|
import { ActionType, ProColumns } from '@ant-design/pro-table';
|
|
|
import { ExportOutlined, WomanOutlined } from '@ant-design/icons';
|
|
|
import { deletedata } from '@/services/idataMng/impandauditp';
|
|
|
import { useModel } from '@umijs/max';
|
|
|
import { ProFormInstance } from '@ant-design/pro-components';
|
|
|
+import { values } from 'lodash';
|
|
|
|
|
|
type aaa = {
|
|
|
custName ?:any;
|
|
|
+ sovereignCode ?:any;
|
|
|
onCancel: () => void;
|
|
|
onChangeVisible(visible: boolean, type: string): unknown;
|
|
|
onChangeVisdible:(visible:boolean,type ?: 'none' | 'raload' )=>void;
|
|
@@ -21,7 +23,6 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
const ref = prop.formRef;
|
|
|
const [editType, setEditType] = useState<EditType>('update');
|
|
|
const formRef = useRef<FormInstance<any>>();
|
|
|
- const formRef1 = useRef<FormInstance<any>>();
|
|
|
/** 当前行对象,查看详情、修改时,作为详细信息表单的查询条件 */
|
|
|
const [currentRow, setCurrentRow] = useState<SovereignModel>();
|
|
|
const [dataSource, setDataSource] = useState<any>() ;
|
|
@@ -29,11 +30,7 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
|
|
|
const [visible,setVisible] = useState<boolean>(false);//弹窗是否显示
|
|
|
|
|
|
- const tableActionRef = useRef<ActionType>();
|
|
|
-
|
|
|
- const SovereignModel = ( custName: string) => deleteSovereign(custName);
|
|
|
const { fetchDict } = useModel('dict');
|
|
|
-
|
|
|
/** 表格引用对象,刷新表格使用 */
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
useEffect(() => {//初始化调用dealinitxmldomain
|
|
@@ -41,85 +38,61 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
}, []);
|
|
|
|
|
|
var formDataList = new Array<SovereignModel>;
|
|
|
-
|
|
|
|
|
|
const dealinit=async()=>{
|
|
|
- console.log(1);
|
|
|
- // const sd = await getSovereign(formData,"");
|
|
|
- // return {data :sd};
|
|
|
- // if ( false){
|
|
|
- // const sd = await selectdata(prop);
|
|
|
- // formRef.current?.setFieldsValue(sd);
|
|
|
-
|
|
|
- // }else{
|
|
|
- // const sd =await getSovereign();
|
|
|
- // formRef.current?.setFieldsValue(sd);
|
|
|
- // return {data : sd};
|
|
|
- // }
|
|
|
- // console.log(sd);
|
|
|
-
|
|
|
- // //return getSovereign();
|
|
|
-
|
|
|
}
|
|
|
const selectdata = async (record:any)=>{
|
|
|
const sd =await selectSovereign(record.custName);
|
|
|
formRef.current?.setFieldsValue(sd);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- const selectdata1=async()=>{
|
|
|
- const sd = await selectSovereign;
|
|
|
-
|
|
|
- // console.log( sd);
|
|
|
- //formRef.current?.setFieldValue('crmFirstLevel','保证');
|
|
|
- }
|
|
|
-
|
|
|
const closeAndRefresh = ()=>{
|
|
|
setVisible(false);
|
|
|
actionRef.current?.reloadAndRest?.();
|
|
|
}
|
|
|
+ const closeAndRefresh1 = ()=>{
|
|
|
+ setImportVisible(false);
|
|
|
+ actionRef.current?.reloadAndRest?.();
|
|
|
+ }
|
|
|
|
|
|
const disdata = async (record:any)=>{
|
|
|
const sd =await selectSovereign(record.custName);
|
|
|
console.log(sd);
|
|
|
formRef.current?.setFieldsValue(sd);
|
|
|
- // return {data :sd};
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
const inst = async(formData : SovereignModel) => {
|
|
|
setEditType('create')
|
|
|
- console.log(formData);
|
|
|
- formRef.current?.getFieldValue(formData);
|
|
|
const insSovere =await inserteSovere(formData)
|
|
|
+ if("国家代码已重复,请重新选择"===insSovere){
|
|
|
+ baseFun.warning(insSovere);
|
|
|
+ }else{
|
|
|
+ baseFun.info(insSovere);
|
|
|
closeAndRefresh();
|
|
|
- console.log(insSovere);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- const del = async(record:any)=>{
|
|
|
- const delSovere =await deleteSovereign(record.custName)
|
|
|
- closeAndRefresh();
|
|
|
- baseFun.info("删除成功");
|
|
|
- console.log(delSovere);
|
|
|
- }
|
|
|
+ const state =async(record:any)=>{
|
|
|
+ baseFun.confirm("请确实是否继续操作" ,async()=>{
|
|
|
+ await updateSovereign(record.custName)
|
|
|
+ closeAndRefresh();
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
const columns: ProColumns<SovereignModel>[] = [
|
|
|
{
|
|
|
title: '计算实例号',
|
|
|
dataIndex: 'calcindex', // 查询结果中的隐藏列
|
|
|
- // search: false,
|
|
|
+ search: false,
|
|
|
ellipsis: true,
|
|
|
- hideInTable: true
|
|
|
- ,width:150
|
|
|
+ hideInTable: true,
|
|
|
+ width:150
|
|
|
},
|
|
|
{
|
|
|
title: '起始数据日期',
|
|
|
dataIndex: 'sdate', // 查询结果中的隐藏列
|
|
|
valueType: 'date',
|
|
|
- // search: false, //注调查询条件显示
|
|
|
+ search: false, //注调查询条件显示
|
|
|
hideInTable: true ,//注调字段列显示
|
|
|
width:150
|
|
|
},
|
|
@@ -127,7 +100,7 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
title: '截止数据日期',
|
|
|
dataIndex: 'edate', // 查询结果中的隐藏列
|
|
|
valueType: 'date',
|
|
|
- // search: false,
|
|
|
+ search: false,
|
|
|
hideInTable: true,
|
|
|
width:150
|
|
|
},
|
|
@@ -135,78 +108,80 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
title: '年月',
|
|
|
dataIndex: 'term', // 查询结果中的隐藏列
|
|
|
valueType:"dateMonth",
|
|
|
- // search: false,
|
|
|
- hideInTable: true
|
|
|
- ,width:150
|
|
|
+ search: false,
|
|
|
+ hideInTable: true,
|
|
|
+ width:150
|
|
|
},
|
|
|
{
|
|
|
title: '数据日期',
|
|
|
dataIndex: 'dataDate', // 查询结果中的隐藏列
|
|
|
valueType: 'date',
|
|
|
- // search: false,
|
|
|
+ search: false,
|
|
|
hideInTable: true,
|
|
|
width:150
|
|
|
- },
|
|
|
- {
|
|
|
- title: '国家名称',
|
|
|
- dataIndex: 'custName', // 查询结果中的隐藏列
|
|
|
- search: false,
|
|
|
- // hideInTable: false
|
|
|
- width:150 ,
|
|
|
- // valueType: 'treeSelect',
|
|
|
- // fieldProps: {
|
|
|
- // treeDefaultExpandAll: true,
|
|
|
- // treeCheckable: true,
|
|
|
- // },
|
|
|
- // request: () => fetchDict('region'),
|
|
|
},
|
|
|
{
|
|
|
title: '国家代码',
|
|
|
dataIndex: 'sovereignCode', // 查询结果中的隐藏列
|
|
|
- search: false,
|
|
|
- // hideInTable: true,
|
|
|
+ // search: false,
|
|
|
+ //hideInTable: true,
|
|
|
width:150
|
|
|
},
|
|
|
{
|
|
|
- title: '主权评级(如有)',
|
|
|
+ title: '主权评级(标普)',
|
|
|
dataIndex: 'sovereignRating', // 查询结果中的隐藏列
|
|
|
search: false,
|
|
|
//hideInTable: true
|
|
|
width:150
|
|
|
},
|
|
|
{
|
|
|
- title: '缓释一级分类',
|
|
|
+ title: '国家名称',
|
|
|
+ dataIndex: 'custName', // 查询结果中的隐藏列
|
|
|
+ // search: false,
|
|
|
+ hideInTable: false,
|
|
|
+ width:150 ,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '主权评级(标普)',
|
|
|
dataIndex: 'crmFirstLevel', // 查询结果中的隐藏列
|
|
|
search: false,
|
|
|
- // hideInTable: true
|
|
|
+ hideInTable: true,
|
|
|
width:150
|
|
|
},
|
|
|
{
|
|
|
title: '合格信用风险缓释工具类型',
|
|
|
dataIndex: 'qualfiedCreditToolTypeName', // 查询结果中的隐藏列
|
|
|
search: false,
|
|
|
- // hideInTable: true
|
|
|
+ hideInTable: true,
|
|
|
width:180
|
|
|
},
|
|
|
{
|
|
|
title: '基础缓释权重',
|
|
|
dataIndex: 'baseWeight', // 查询结果中的隐藏列
|
|
|
- search: false,
|
|
|
- //hideInTable: true
|
|
|
+ search: false,//查询条件隐藏
|
|
|
+ hideInTable: true,//放开字段隐藏
|
|
|
width:150
|
|
|
},
|
|
|
{
|
|
|
title: '豁免后缓释权重',
|
|
|
dataIndex: 'exemptionWeight', // 查询结果中的隐藏列
|
|
|
search: false,
|
|
|
- // hideInTable: true
|
|
|
+ hideInTable: true,
|
|
|
width:150
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'state', // 查询结果中的隐藏列
|
|
|
+ search: false,
|
|
|
+ // hideInTable: true
|
|
|
+ width:100
|
|
|
+},
|
|
|
{
|
|
|
title: '操作',
|
|
|
dataIndex: 'operate',
|
|
|
valueType: 'option',
|
|
|
render: (_, record) => [
|
|
|
+
|
|
|
<SDOperate
|
|
|
key="roleCfg"
|
|
|
icon={<WomanOutlined />}
|
|
@@ -214,30 +189,17 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
|
|
|
onClick={()=>{
|
|
|
selectdata(record);
|
|
|
-
|
|
|
setVisible(true);
|
|
|
setEditType('update')
|
|
|
} }
|
|
|
>
|
|
|
修改
|
|
|
</SDOperate>,
|
|
|
- <SDOperate
|
|
|
- key="roleCfg"
|
|
|
- icon={<WomanOutlined />}
|
|
|
- successMessage=""
|
|
|
-
|
|
|
- onClick={()=>{
|
|
|
- del(record);
|
|
|
-
|
|
|
- } }
|
|
|
- >
|
|
|
- 删除
|
|
|
- </SDOperate>,
|
|
|
+
|
|
|
<SDOperate
|
|
|
key="roleCfg"
|
|
|
icon={<WomanOutlined />}
|
|
|
successMessage=""
|
|
|
-
|
|
|
onClick={()=>{
|
|
|
disdata(record);
|
|
|
closeAndRefresh();
|
|
@@ -247,33 +209,60 @@ const sovereignts: React.FC<aaa>= (prop : aaa) => {
|
|
|
>
|
|
|
查看
|
|
|
</SDOperate>,
|
|
|
+ <span style={record?.state==="作废" ? {display:'none'}: {}}>
|
|
|
+ <SDOperate
|
|
|
+ key="roleCfg"
|
|
|
+ icon={<WomanOutlined />}
|
|
|
+ successMessage=""
|
|
|
+ onClick={()=>{
|
|
|
+ state(record);
|
|
|
+ } }
|
|
|
+ >
|
|
|
+ 作废
|
|
|
+ </SDOperate>,
|
|
|
+ </span>
|
|
|
],
|
|
|
},
|
|
|
]
|
|
|
-
|
|
|
- // const sd1 = async(formData:SovereignModel)=>{
|
|
|
- // console.log(2)
|
|
|
- // if(formData.custName ===undefined){
|
|
|
- // const sd = await getSovereign(formData,"");
|
|
|
- // formDataList=[...sd];
|
|
|
- // return {data :sd };
|
|
|
- // } else{
|
|
|
- // var value ="";
|
|
|
- // formData.custName.forEach(function(item){ value += item +","}); // 循环下拉树数组变成字符串
|
|
|
- // value= value.substring(0,value.length-1) // 去除最后一位,
|
|
|
- // let {custName,...Model1}=formData // 重新解构对象 去除custName字段
|
|
|
- // const sd = await getSovereign(Model1,value);
|
|
|
- // return {data :sd };
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
+ /**上传文件 */
|
|
|
+ const [fileData, setFileData] = useState<File>();
|
|
|
+ // 导入窗口显示
|
|
|
+ const [importVisible, setImportVisible] = useState<boolean>(false);
|
|
|
+ //初始化
|
|
|
const sd1 = async(formData:SovereignModel)=>{
|
|
|
const sd = await getSovereign(formData);
|
|
|
formDataList =[...sd];
|
|
|
return {data :sd };
|
|
|
}
|
|
|
-
|
|
|
+ // 模板下载
|
|
|
+ const templateUploadAction = async() => {
|
|
|
+ await templateUpload("sovereign");
|
|
|
+ // baseFun.info("处理完成");
|
|
|
+ }
|
|
|
+ /**上传属性 */
|
|
|
+ const fileProps = {
|
|
|
+ onRemove: () => {
|
|
|
+ setFileData(undefined);
|
|
|
+ },
|
|
|
+ beforeUpload(info: any) {
|
|
|
+ setFileData(info);
|
|
|
+ },
|
|
|
+ };
|
|
|
+ /**上传提交 */
|
|
|
+ const uploadSubmit = async () => {
|
|
|
+ if (!fileData) {
|
|
|
+ baseFun.warning('未上传文件');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const res = await uploadAction(fileData);
|
|
|
+ if ('导入成功'===res) {
|
|
|
+ baseFun.info("处理完成");
|
|
|
+ } else {
|
|
|
+ baseFun.error(res);
|
|
|
+ }
|
|
|
+ setEditType('update');
|
|
|
+ setDetailVisible(false);
|
|
|
+};
|
|
|
|
|
|
return (
|
|
|
<SDPage >
|
|
@@ -282,78 +271,116 @@ return (
|
|
|
rowKey="custName"
|
|
|
request={sd1}
|
|
|
columns={columns}
|
|
|
- // singleSelect={false}
|
|
|
- // operations={["create"]}
|
|
|
- //displayColumn="custName"
|
|
|
actionRef={actionRef}
|
|
|
formRef={formRef}
|
|
|
- //handleRemove={deletedata}
|
|
|
- //setCurrentRow={setCurrentRow}
|
|
|
- // setEditType={setEditType}
|
|
|
- // setDetailVisible={setVisible}
|
|
|
toolBarRender={(_, { selectedRows }) => [
|
|
|
<SDButton
|
|
|
key="export"
|
|
|
- successMessage='导出成功'
|
|
|
- onClick={() => {
|
|
|
-
|
|
|
- // if (selectedRows === undefined || selectedRows.length < 1) {
|
|
|
- // baseFun.warning('请先选择要倒出的模板');
|
|
|
- // return;
|
|
|
- // }
|
|
|
-
|
|
|
- exportExcelModel(formDataList);
|
|
|
+ // successMessage='导出成功'
|
|
|
+ onClick={async () => {
|
|
|
+ exportExcelModel("sovereign",formDataList);
|
|
|
//baseFun.info('处理完成');
|
|
|
}}
|
|
|
>
|
|
|
全部导出
|
|
|
</SDButton>,
|
|
|
+ <SDButton
|
|
|
+ key="import"
|
|
|
+ successMessage=''
|
|
|
+ onClick={() => {
|
|
|
+ baseFun.confirm("请注意本功能意在覆盖本表所有数据,请谨慎使用!",()=>{ setImportVisible(true);})
|
|
|
+
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 覆盖导入
|
|
|
+ </SDButton>,
|
|
|
<SDButton
|
|
|
key="create"
|
|
|
+ successMessage=''
|
|
|
onClick={() => {
|
|
|
setVisible(true);
|
|
|
setEditType('create');
|
|
|
- formRef.current?.setFieldValue('crmFirstLevel','保证');
|
|
|
}}
|
|
|
>
|
|
|
新增
|
|
|
</SDButton>
|
|
|
]}
|
|
|
+ />
|
|
|
+ {importVisible && (
|
|
|
+ <SDModalForm
|
|
|
+ title={'上传文件窗口'}
|
|
|
+ visible={importVisible}
|
|
|
+ editType={editType}
|
|
|
+ onVisibleChange={() => {setImportVisible(false)}}
|
|
|
+ tableRef={actionRef}
|
|
|
+ footer={[
|
|
|
+ <SDSubmitButton editType={'update'} formRef={formRef} successMessage=""
|
|
|
+ doSubmit={async() => { await uploadSubmit()}} >提交</SDSubmitButton>,
|
|
|
+ <SDButton
|
|
|
+ key="template"
|
|
|
+ onClick={() => {
|
|
|
+ templateUploadAction();
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 模板下载
|
|
|
+ </SDButton>,
|
|
|
+ <SDButton
|
|
|
+ key="close"
|
|
|
+ onClick={() => {
|
|
|
+ closeAndRefresh1();
|
|
|
+ }}
|
|
|
>
|
|
|
- </SDTable>
|
|
|
-
|
|
|
+ 关闭
|
|
|
+ </SDButton>
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <SDFormItem nestType="form">
|
|
|
+ <Upload maxCount={1} {...fileProps} name="rfile">
|
|
|
+ <div style={{ paddingLeft: '5.5vw' }}>
|
|
|
+ 选择上传文件: <SDOperate>上传</SDOperate>
|
|
|
+ </div>
|
|
|
+ </Upload>
|
|
|
+ </SDFormItem>
|
|
|
+ </SDModalForm>
|
|
|
+ )}
|
|
|
{ visible &&(
|
|
|
<SDModalForm
|
|
|
visible={visible}
|
|
|
//rowKey="custName"
|
|
|
editType={editType}
|
|
|
- // request={selectdata1}
|
|
|
+ //request={selectdata1}
|
|
|
//params={setDataSource}
|
|
|
onVisibleChange={() => { setVisible(false) }}
|
|
|
- footer={[<SDSubmitButton editType={editType} formRef={formRef} doSubmit={inst} >保存</SDSubmitButton>]}
|
|
|
+ initialValues={{crmFirstLevel :'保证',sovereignCode:prop.sovereignCode,editType:setEditType}}
|
|
|
+ footer={[<SDSubmitButton editType={editType} formRef={formRef} successMessage="" doSubmit={inst} >保存</SDSubmitButton>,
|
|
|
+ <SDButton successMessage="" onClick={()=>closeAndRefresh()} >关闭</SDButton>
|
|
|
+ ]}
|
|
|
formRef={formRef}
|
|
|
onValuesChange={async (changedValues,Values) => {
|
|
|
- if(changedValues.custName!=undefined){
|
|
|
- const sd = await selectSovereignCode(changedValues.custName);
|
|
|
+ if(changedValues.sovereignCode!=undefined){
|
|
|
+ const sd = await selectSovereignCode(changedValues.sovereignCode);
|
|
|
console.log(sd);
|
|
|
- formRef.current?.setFieldValue('sovereignCode',sd)}
|
|
|
- // const jiaoyan=formRef.current?.getFieldsValue();
|
|
|
+ formRef.current?.setFieldValue('custName',sd)}
|
|
|
}}
|
|
|
>
|
|
|
-
|
|
|
-<SDFormDict name="custName" label="国家名称" readonlyCond='update' dictKey='@sovereignCode' />
|
|
|
-<SDFormText name="sovereignCode" label="国家代码" readonlyCond='both' />
|
|
|
+<SDFormDict name="sovereignCode" label="国家代码" readonlyCond='update' dictKey='@sovereignCode' />
|
|
|
+<SDFormText name="custName" label="国家名称" readonlyCond='both' />
|
|
|
<SDFormDict name="sovereignRating" label="主权评级(标普)" dictKey="sovereignRating" />
|
|
|
<SDFormText name="crmFirstLevel" label="缓释分类" />
|
|
|
<SDFormText name="qualfiedCreditToolTypeName" label="合格信用风险缓释工具类型" />
|
|
|
- <SDFormText name="baseWeight" label="缓释风险权重%" />
|
|
|
+ <SDFormText name="exemptionWeight" label="缓释风险权重%" rules={ [{validator: validateFun.double,message:"请输入数字类型" }
|
|
|
+ ,{pattern :RegExp(`^\\d+\\.{${0},${1}}\\d{${0},${4}}$`),message:"小数位超位" }]}
|
|
|
+ oldValue="%"></SDFormText>
|
|
|
+ <div style={{display:"none"}}><SDFormText name="editType" label="setEditType" />
|
|
|
+ <SDFormText name="baseWeight" label="基础缓释权重" /> </div>
|
|
|
</SDModalForm>
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
</SDPage>
|
|
|
);
|
|
|
|
|
|
-};export default sovereignts;
|
|
|
+}
|
|
|
+export default sovereignts;
|
|
|
|
|
|
|