|
|
|
@ -25,7 +25,6 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
const [pageInfo, setPageInfo] = useState<Partial<PaginationData>>({});
|
|
|
|
|
const [i18n, setI18n] = useState<any>({});
|
|
|
|
|
const [runStatuses, setRunStatuses] = useState<string>("");
|
|
|
|
|
const [showOperateBtn, setShowOperateBtn] = useState<boolean>(false);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
window.parent.postMessage({ type: "init" }, "*");
|
|
|
|
@ -38,11 +37,7 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
const receiveMessageFromIndex = (event: any) => {
|
|
|
|
|
const data: any = exceptStr(event.data);
|
|
|
|
|
if (!_.isEmpty(data)) {
|
|
|
|
|
const {
|
|
|
|
|
columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {},
|
|
|
|
|
runStatuses, showOperateBtn
|
|
|
|
|
} = data;
|
|
|
|
|
setShowOperateBtn(showOperateBtn);
|
|
|
|
|
const { columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {}, runStatuses } = data;
|
|
|
|
|
setRunStatuses(runStatuses);
|
|
|
|
|
setI18n(i18nRes);
|
|
|
|
|
setPageInfo(pageInfo);
|
|
|
|
@ -69,11 +64,7 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
selectedRowKeys: selectedRowKeys,
|
|
|
|
|
onChange: (selectedRowKeys: React.Key[]) => {
|
|
|
|
|
setSelectedRowKeys(selectedRowKeys);
|
|
|
|
|
window.parent.postMessage(
|
|
|
|
|
{
|
|
|
|
|
type: "turn",
|
|
|
|
|
payload: { id: "CHECKBOX", params: { selectedRowKeys } }
|
|
|
|
|
},
|
|
|
|
|
window.parent.postMessage({ type: "turn", payload: { id: "CHECKBOX", params: { selectedRowKeys } } },
|
|
|
|
|
"*"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -89,6 +80,14 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
};
|
|
|
|
|
const cols: any = useMemo(() => {
|
|
|
|
|
let opts: any = { title: i18n["操作"], dataIndex: "operate", fixed: "right", width: 185 };
|
|
|
|
|
const UnAuthOpts = (record: any) => (<Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("VIEW", record)}>{i18n["查看"]}</Button>
|
|
|
|
|
<Dropdown menu={{
|
|
|
|
|
items: [{ key: "Log", label: i18n["操作日志"], onClick: () => handleWelfareOperate("log", record) }]
|
|
|
|
|
}} placement="bottomRight">
|
|
|
|
|
<Button type="link" icon={<MoreOutlined/>}/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Space>);
|
|
|
|
|
switch (runStatuses) {
|
|
|
|
|
case "1":
|
|
|
|
|
opts = {
|
|
|
|
@ -111,13 +110,13 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
onClick: () => handleWelfareOperate("log", record)
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
return (<Space>
|
|
|
|
|
return (record?.opts.includes("admin") ? <Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("EDIT", record)}>{i18n["编辑"]}</Button>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("ADD-TO-PAY", record)}>{i18n["增员"]}</Button>
|
|
|
|
|
<Dropdown menu={{ items }} placement="bottomRight">
|
|
|
|
|
<Button type="link" icon={<MoreOutlined/>}/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Space>);
|
|
|
|
|
</Space> : UnAuthOpts(record));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
@ -133,13 +132,12 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
onClick: () => handleWelfareOperate("log", record)
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
return (
|
|
|
|
|
<Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("EDIT", record)}>{i18n["编辑"]}</Button>
|
|
|
|
|
<Dropdown menu={{ items }} placement="bottomRight">
|
|
|
|
|
<Button type="link" icon={<MoreOutlined/>}/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Space>);
|
|
|
|
|
return (record?.opts.includes("admin") ? <Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("EDIT", record)}>{i18n["编辑"]}</Button>
|
|
|
|
|
<Dropdown menu={{ items }} placement="bottomRight">
|
|
|
|
|
<Button type="link" icon={<MoreOutlined/>}/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Space> : UnAuthOpts(record));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
@ -159,14 +157,14 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
onClick: () => handleWelfareOperate("log", record)
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
return (<Space>
|
|
|
|
|
return (record?.opts.includes("admin") ? <Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("EDIT", record)}>{i18n["编辑"]}</Button>
|
|
|
|
|
<Button type="link"
|
|
|
|
|
onClick={() => handleWelfareOperate("STAY-DEL-TO-STOP", record)}>{i18n["减员"]}</Button>
|
|
|
|
|
<Dropdown menu={{ items: downsizingItems }} placement="bottomRight">
|
|
|
|
|
<Button type="link" icon={<MoreOutlined/>}/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Space>);
|
|
|
|
|
</Space> : UnAuthOpts(record));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
@ -186,38 +184,27 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
onClick: () => handleWelfareOperate("log", record)
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
return (<Space>
|
|
|
|
|
return (record?.opts.includes("admin") ? <Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("VIEW", record)}>{i18n["查看"]}</Button>
|
|
|
|
|
<Button type="link"
|
|
|
|
|
onClick={() => handleWelfareOperate("DEL-ARCHIVE", record)}>{i18n["删除档案"]}</Button>
|
|
|
|
|
<Dropdown menu={{ items: stopItems }} placement="bottomRight">
|
|
|
|
|
<Button type="link" icon={<MoreOutlined/>}/>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</Space>);
|
|
|
|
|
</Space> : UnAuthOpts(record));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return showOperateBtn ? [...columns, opts] : [...columns, {
|
|
|
|
|
...opts,
|
|
|
|
|
render: (__: any, record: any) => (
|
|
|
|
|
<Space>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("VIEW", record)}>{i18n["查看"]}</Button>
|
|
|
|
|
<Button type="link" onClick={() => handleWelfareOperate("log", record)}>{i18n["操作日志"]}</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
)
|
|
|
|
|
}];
|
|
|
|
|
}, [columns, runStatuses, i18n, showOperateBtn]);
|
|
|
|
|
return [...columns, opts];
|
|
|
|
|
}, [columns, runStatuses, i18n]);
|
|
|
|
|
return (<Table
|
|
|
|
|
rowKey="baseInfo" size="small" className={styles.tableWrapper}
|
|
|
|
|
rowKey="baseInfoId" size="small" className={styles.tableWrapper}
|
|
|
|
|
columns={cols} dataSource={dataSource} rowSelection={rowSelection}
|
|
|
|
|
scroll={{ x: 1200, y: `calc(100vh - 103px)` }}
|
|
|
|
|
pagination={{
|
|
|
|
|
...paginationAction(pageInfo, i18n, onChange),
|
|
|
|
|
size: "default"
|
|
|
|
|
}}
|
|
|
|
|
pagination={{ ...paginationAction(pageInfo, i18n, onChange), size: "default" }}
|
|
|
|
|
/>);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|