泛微薪资核算iframe表格

custom-新弘农业/V2-薪资核算表格添加序号列
黎永顺 2 years ago
parent 8394cf8872
commit aa64deb95a

@ -7,18 +7,18 @@ export default defineConfig({
base: '/',
publicPath: '/',
proxy: {
'/gateway': {
// 'target': 'http://gateway',
target: 'https://yule-dev.njhtsz.com',
changeOrigin: true,
},
// '/gateway/idm': {
// target: 'http://192.168.20.5:9110',
// '/gateway': {
// // 'target': 'http://gateway',
// target: 'https://yule-dev.njhtsz.com',
// changeOrigin: true,
// pathRewrite: {
// '^/gateway/idm': '',
// },
// },
'/api': {
target: 'http://192.168.0.50:7602/api',
changeOrigin: true,
pathRewrite: {
'^/api': '',
},
},
// '/gateway/idm': {
// target: 'http://localhost:9110',
// changeOrigin: true,

@ -5,8 +5,10 @@ export default defineConfig({
ENV: 'prod',
},
antd: false,
base: '/slave',
publicPath: '/slave/static/',
// base: '/slave',
// publicPath: '/slave/static/',
base: '/spa/hrmSalary/hrmSalaryCalculateDetail/',
publicPath: './',
externals: {
echarts: 'echarts',
moment: 'moment',

@ -43,13 +43,7 @@ export default defineConfig({
cssLoader: {
localsConvention: 'camelCase',
modules: {
getLocalIdent: (
context: {
resourcePath: string;
},
_: string,
localName: string,
) => {
getLocalIdent: (context: { resourcePath: string }, _: string, localName: string) => {
if (
context.resourcePath.includes('pages/home') ||
context.resourcePath.includes('node_modules') ||

@ -0,0 +1,33 @@
import BasicService from "./BasicService";
/**
* @desc
*/
class CalculateService extends BasicService {
constructor() {
super();
}
//获取人员确认列表信息
getPCDataList = async ({ url, queryParams }: any) => {
const { departmentIds = "", positionIds = "", subcompanyIds="", ...extraParams } = queryParams || {};
queryParams = {
...extraParams,
departmentIds: departmentIds ? departmentIds.split(",") : undefined,
positionIds: positionIds ? positionIds.split(",") : undefined,
subcompanyIds: subcompanyIds ? subcompanyIds.split(",") : undefined
};
for (let key in queryParams) {
if (queryParams[key] === "" || queryParams[key] === "0") {
delete queryParams[key];
}
}
return this.post(
url,
queryParams
);
};
}
const calculateService = new CalculateService();
export default calculateService;

@ -1,8 +1,10 @@
import AccountService from './account.service';
import GlobalService from './global.service';
import MenuService from './menu.service';
import SettingService from './setting.service';
import DictionaryService from './dictionary.service';
import AccountService from "./account.service";
import GlobalService from "./global.service";
import MenuService from "./menu.service";
import SettingService from "./setting.service";
import DictionaryService from "./dictionary.service";
import CalculateService from "./calculate.service";
export {
AccountService,
@ -10,6 +12,7 @@ export {
MenuService,
SettingService,
DictionaryService,
CalculateService
};
export default {
@ -18,4 +21,5 @@ export default {
MenuService,
SettingService,
DictionaryService,
CalculateService
};

@ -2,33 +2,19 @@
*
*/
interface IPage {
/**
* (0)
*/
page: number;
/**
*
*/
pageNum: number;
size: number;
/**
* (header)
*/
total?: number;
/**
* (,,:createdDate)
*/
sort?: string;
}
interface ILoading {
query?: boolean;
save?: boolean;
submit?: boolean;
}
let defaultPage: IPage = {
page: 0,
size: 100,
sort: 'createdDate',
pageNum: 1,
size: 10,
};
export { IPage, defaultPage };
export { IPage, ILoading, defaultPage };

@ -1,12 +1,13 @@
import * as React from 'react';
import { useAccess, Access, Redirect } from 'umi';
import * as React from "react";
import { Access, Redirect, useAccess } from "umi";
export default (props: any) => {
const access = useAccess();
return (
<Access
accessible={access.canUseManage}
fallback={<Redirect to="/exception/403" />}
// @ts-ignore
fallback={<Redirect to="/exception/403"/>}
>
{props.children}
</Access>

@ -70,27 +70,27 @@ div,
iframe,
aside,
main {
scrollbar-color: #999 transparent;
scrollbar-color: #ccc transparent;
/* 第一个方块颜色,第二个轨道颜色(用于更改火狐浏览器样式) */
scrollbar-width: thin;
/* 火狐滚动条无法自定义宽度,只能通过此属性使滚动条宽度变细 */
&::-webkit-scrollbar-track {
-webkit-box-shadow: 0 0 0;
background-color: rgba(0, 0, 0, 0.05);
border-radius: 4px;
-webkit-box-shadow: none;
background-color: transparent;
border-radius: 10px;
}
&::-webkit-scrollbar {
width: 6px;
height: 6px;
width: 10px;
height: 10px;
background-color: transparent;
}
&::-webkit-scrollbar-thumb {
border-radius: 4px;
-webkit-box-shadow: inset 0 0 6px #999;
background-color: #999;
border-radius: 10px;
-webkit-box-shadow: none;
background-color: #ccc;
}
}

@ -1,13 +1,24 @@
import * as React from 'react';
import styles from './index.less';
import * as React from "react";
import { useEffect } from "react";
import { ConfigProvider } from "antd";
import styles from "./index.less";
export default ({ children, style = {} }: any) => {
useEffect(() => {
ConfigProvider.config({
theme: {
primaryColor: "#2DB7F5"
}
});
}, []);
export default ({children, style = {}}: any) => {
return (
<div
className={styles.root}
style={{
width: '100%',
height: '100%',
width: "100%",
height: "100%",
overflow: "hidden",
...style
}}
>

@ -4,6 +4,8 @@ module.exports = {
'/home': 'blank',
'/manage/design/.*': 'blank',
'/manage/editor': 'blank',
'/calculateDetail.*': 'blank',
'/atdTable.*': 'blank',
'/manage.*': 'manage',
'/portal.*': 'template',
'/passport/oauth-in': 'blank',

@ -0,0 +1,317 @@
import React, { FC, useEffect, useState } from "react";
import { exceptStr, paginationFun } from "@/utils/common";
import { defaultPage, ILoading, IPage } from "@/common/types/page";
import { message, Table, Typography } from "antd";
import { LockOutlined, UnlockOutlined } from "@ant-design/icons";
import API from "@/api";
import styles from "./index.less";
const { Text } = Typography;
interface ITableProps {
}
const AntdTable: FC<ITableProps> = (props) => {
const [selected, setSelected] = useState<Array<string>>([]); //列表选中的数据
const [tab, setTab] = useState<string>(""); //顶部TAB变量
const [usertab, setUsertab] = useState<string>(""); //底部TAB变量
const [pageParams, setPageParams] = useState<IPage>(defaultPage); //分页变量
const [loading, setLoading] = useState<ILoading>({});
const [columns, setColumns] = useState<any[]>([]);
const [dataSource, setDataSource] = useState<any[]>([]);
const [sumRow, setSumRow] = useState<Partial<{}>>({});//薪资核算总计行数据
useEffect(() => {
window.parent.postMessage(
{
type: "PC",
data: { id: "SA" }
},
"*"
);
window.addEventListener("message", receiveMessageFromIndex, false);
return () => {
setSumRow({});
window.removeEventListener("message", receiveMessageFromIndex, false);
};
}, []);
const getPCDataList = (params: any = {}) => {
let { type, listType, ...extraParams } = params;
setLoading({ query: true });
setTab(type);
setUsertab(listType);
API.CalculateService.getPCDataList(extraParams).then(({ success, data, errorMsg }) => {
setLoading({ query: false });
if (success) {
const { data: dataCopy } = data;
if (type === "PC") {
if (listType === "SA") {
const { columns = [], list = [], total, pageSize: size, pageNum } = dataCopy;
setColumns(getUserListColumns(columns));
setDataSource(list);
setPageParams({ ...pageParams, total, size, pageNum });
} else if (listType === "MA") {
const { columns = [], list = [], total, pageSize: size, pageNum } = dataCopy;
setColumns(columns);
setDataSource(list);
setPageParams({ ...pageParams, total, size, pageNum });
}
} else {
const { columns = [], pageInfo = {}, sumRow = {} } = dataCopy;
const { list = [], total, pageSize: size, pageNum } = pageInfo;
setColumns(getColumns(columns));
setDataSource(list);
setSumRow(sumRow);
setPageParams({ ...pageParams, total, size, pageNum });
}
} else {
message.error(errorMsg || "");
}
});
};
const getUserListColumns = (acctemployeeListColumns: any) => {
let tmpColumns = [...acctemployeeListColumns, {
key: "cz",
title: "操作",
render: (text: string, record: any) => {
return (
<a
onClick={() => {
window.parent.postMessage(
{
type: "PC",
data: { id: "DELETE", data: record }
},
"*"
);
}}
>
</a>
);
}
}];
return tmpColumns;
};
//薪资核算页面列表
const getColumns = (column: any) => {
let tmpColumns = [...column];
tmpColumns = tmpColumns.filter(item => item.hide == "FALSE").map((item, index) => {
let result = { ...item };
result.title = <span className={styles.titleWrapper}>
<span onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "COLUMNINDEX", data: item.column }
},
"*"
);
}}>{item.text}</span>
{
item.lockStatus && <span className={styles.titleIcon}>
{
item.lockStatus === "UNLOCK" && <LockOutlined
title="点击锁定所有解锁的项目值"
onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "COLUMNINDEX", data: item.column, extraId: "LOCK" }
},
"*"
);
}}
/>
}
{
item.lockStatus !== "UNLOCK" && <UnlockOutlined
title="点击解锁所有锁定的项目值"
onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "COLUMNINDEX", data: item.column, extraId: "UNLOCK" }
},
"*"
);
}}
/>
}
</span>
}
</span>;
result.dataIndex = item.column;
result.oldWidth = result.width;
result.width = "150px";
if (result.children) {
result.width = (result.children.length * 150) + "px";
result.children.map((child: any) => {
child.title = <span className={styles.titleWrapper}>
<span title={child.text} onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "COLUMNINDEX", data: child.column }
},
"*"
);
}}>{child.text}</span>
{
child.lockStatus &&
<span className={styles.titleIcon}>
{
child.lockStatus === "UNLOCK" &&
<LockOutlined
title="点击锁定所有解锁的项目值"
onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "COLUMNINDEX", data: child.column, extraId: "LOCK" }
},
"*"
);
}}
/>
}
{
child.lockStatus !== "UNLOCK" &&
<UnlockOutlined
title="点击解锁所有锁定的项目值"
onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "COLUMNINDEX", data: child.column, extraId: "UNLOCK" }
},
"*"
);
}}
/>
}
</span>
}
</span>;
child.dataIndex = child.column;
child.width = "150px";
child.render = (text: string) => {
return <span className={styles.contentSpan}>
<span>{text}</span>
{
child.lockStatus === "LOCK" ? <LockOutlined title="锁定的项目值"/> : null
}
</span>;
};
});
}
if (index < 3) {
result.fixed = "left";
result.render = (text: string) => {
return <span title={text}>{text}</span>;
};
}
return result;
});
tmpColumns.push({
title: "操作",
key: "cz",
width: "100px",
fixed: "right",
render: (text: string, record: any) => {
return <a onClick={() => {
window.parent.postMessage(
{
type: "PR",
data: { id: "EDIT", data: record }
},
"*"
);
}}></a>;
}
});
return tmpColumns;
};
const receiveMessageFromIndex = (event: any) => {
setDataSource([]);
const data: any = exceptStr(event.data);
if (!_.isEmpty(data)) {
getPCDataList({ ...data, ...pageParams });
}
};
const sizeChange = (pageobj: IPage) => {
};
const onChange = (pageobj: IPage) => {
setPageParams({ ...pageParams, ...pageobj });
window.parent.postMessage(
{
type: tab,
data: { id: "PAGEINFO", extraId: usertab, data: { ...pageParams, ...pageobj } }
},
"*"
);
};
const rowSelection = {
selectedRowKeys: selected,
onChange: (selectedRowKeys: Array<any>) => {
setSelected(selectedRowKeys);
window.parent.postMessage(
{
type: tab,
data: { id: "BATCHDELETE", extraId: usertab, data: selectedRowKeys }
},
"*"
);
}
};
return <Table
rowKey="id"
loading={loading.query}
className={styles.tableWrapper}
columns={columns}
dataSource={dataSource}
size="small"
bordered
rowSelection={tab === "PC" && usertab === "SA" ? rowSelection : undefined}
pagination={{
...paginationFun(pageParams, sizeChange, onChange),
size: "default"
}}
scroll={{
x: "calc(700px + 50%)",
y: tab !== "PR" ? "calc(100vh - 96px)" : !_.isEmpty(sumRow) ? "calc(100vh - 192px)" : "calc(100vh - 156px)"
}}
summary={() => {
if (tab !== "PR" || _.isEmpty(sumRow)) return;
let totalColumns: any[] = [];
_.forEach(columns, it => {
if (!it.children) {
totalColumns.push(it);
} else {
totalColumns = [...totalColumns, ...it.children];
}
});
return (
<Table.Summary fixed>
<Table.Summary.Row>
{
_.map(totalColumns, (item, index) => {
if (index === 0) {
return <Table.Summary.Cell index={0}><Text type="danger"></Text></Table.Summary.Cell>;
}
return <Table.Summary.Cell index={index} key={index}>
<Text type="danger">{sumRow[item.dataIndex] || "-"}</Text>
</Table.Summary.Cell>;
})
}
</Table.Summary.Row>
</Table.Summary>
);
}}
/>;
};
export default AntdTable;

@ -0,0 +1,101 @@
//表格样式
.tableWrapper {
.titleWrapper {
display: flex;
align-items: center;
& > span:first-child {
flex: 1;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
& > span.titleIcon {
margin-left: 4px;
display: none;
& > span {
cursor: pointer;
color: #5d9cec;
}
}
}
.contentSpan {
display: flex;
justify-content: space-between;
align-items: center;
:global {
span.anticon-lock {
color: #5d9cec;
}
}
}
.titleWrapper:hover {
& > span.titleIcon {
display: block;
}
}
:global {
.ant-table-tbody > tr.ant-table-row:hover > td {
background: #e9f7ff;
}
.ant-spin-container {
.ant-pagination {
font-size: 12px;
align-items: center;
.ant-pagination-item, .ant-pagination-prev, .ant-pagination-next {
min-width: 28px;
height: 28px;
line-height: 28px;
border-radius: 6px;
& > button {
border-radius: 6px;
}
}
.ant-pagination-options {
.ant-select {
font-size: 12px;
.ant-select-selector {
height: 28px;
border-radius: 6px;
}
.ant-select-item {
font-size: 12px;
}
}
.ant-pagination-options-quick-jumper {
height: 28px;
line-height: 28px;
& > input {
border-radius: 6px;
height: 28px;
}
}
}
}
}
.ant-table-thead > tr > th {
background-color: #f7fbfe;
}
th, td {
font-size: 12px
}
}
}

@ -0,0 +1,9 @@
import React, { FC } from 'react';
import AntdTable from './components/antdTable';
const AtdTable: FC = (props) => {
return <AntdTable />
};
export default AtdTable;

@ -0,0 +1,17 @@
import { action, makeObservable, observable } from "mobx";
export class CalculateStore {
constructor() {
makeObservable(this);
}
@observable
showOperatePermission: boolean = false;
@action
setgPermission = (permission: boolean) => {
this.showOperatePermission = permission;
};
}
export const calculateStore = new CalculateStore();

@ -1,9 +1,11 @@
import { appStore } from './AppStore';
import { baseLayoutStore } from '@/layouts/BaseLayout/Store';
import { appStore } from "./AppStore";
import { calculateStore } from "./CalculateStore";
import { baseLayoutStore } from "@/layouts/BaseLayout/Store";
export { baseLayoutStore, appStore };
export { baseLayoutStore, appStore, calculateStore };
export default {
baseLayoutStore,
appStore,
calculateStore,
appStore
};

@ -2,16 +2,15 @@
* 上传地址
* @returns {*}
*/
import config from '@/config';
import { Session } from '../utils';
import _ from 'lodash';
import config from "@/config";
import { Session } from "../utils";
/**
* 上传成功返回详情信息
* @returns {string}
*/
export const uploadURLReturnDetail = () => {
return config.get('file/uploadReturnDetail');
return config.get("file/uploadReturnDetail");
};
/**
@ -19,7 +18,7 @@ export const uploadURLReturnDetail = () => {
* @returns {string}
*/
export const uploadURLReturnId = () => {
return config.get('file/uploadReturnId');
return config.get("file/uploadReturnId");
};
/**
@ -29,7 +28,7 @@ export const uploadURLReturnId = () => {
*/
export const downloadURL = (fileId) => {
const token = Session.getAccessToken() || Session.getRefreshToken();
return config.get('file/download') + '/' + fileId + `?access_token=${token}`;
return config.get("file/download") + "/" + fileId + `?access_token=${token}`;
};
/**
@ -39,7 +38,7 @@ export const downloadURL = (fileId) => {
*/
export const viewImg = (fileId) => {
const token = Session.getAccessToken() || Session.getRefreshToken();
return config.get('file/viewImg') + '/' + fileId + `?access_token=${token}`;
return config.get("file/viewImg") + "/" + fileId + `?access_token=${token}`;
};
/**
@ -47,5 +46,38 @@ export const viewImg = (fileId) => {
* @returns {string}
*/
export const getPicSuffix = () => {
return config.get('picSuffix');
return config.get("picSuffix");
};
/**
* 判断是否为JSON字符串
* @returns {string}
*/
export const exceptStr = (str) => {
try {
return JSON.parse(str);
} catch (err) {
return {};
}
};
export const paginationFun = (tableListPageObj, sizeChange, onChange) => {
return {
current: tableListPageObj.pageNum,
pageSize: tableListPageObj.size,
total: tableListPageObj.total,
showTotal: (total) => `${total}`,
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: () => sizeChange(),
onChange: (page, size) => {
const { total } = tableListPageObj;
onChange({
pageNum: page,
size,
total,
});
},
};
};

Loading…
Cancel
Save