feature/2.12.1.2403.02-薪资核算自定义导出模板设置

This commit is contained in:
黎永顺 2024-03-29 14:37:49 +08:00
parent a768470afb
commit 8a7f3fcb7a
4 changed files with 160 additions and 28 deletions

View File

@ -258,3 +258,12 @@ export const saveExportTemplate = (params) => {
export const getExportTemplateList = (params) => {
return postFetch("/api/bs/hrmsalary/salaryacct/acctresult/exportTemplateList", params);
};
//薪资核算-删除自定义导出模板列表
export const deleteExportTemplate = (params) => {
return postFetch("/api/bs/hrmsalary/salaryacct/acctresult/deleteExportTemplate", params);
};
//薪资核算-获取导出模板详细信息
export const getExportTemplateForm = (params) => {
return postFetch("/api/bs/hrmsalary/salaryacct/acctresult/getExportTemplateForm", params);
};

View File

@ -10,7 +10,12 @@ import { Button, Col, message, Row } from "antd";
import { inject, observer } from "mobx-react";
import { WeaCheckbox, WeaDialog, WeaLocaleProvider, WeaSearchGroup, WeaSelect } from "ecCom";
import ExpTempManagementDialog from "../expTempManagementDialog";
import { customCacheExportField } from "../../../../../apis/calculate";
import {
customCacheExportField,
getExportField,
getExportTemplateForm,
getExportTemplateList
} from "../../../../../apis/calculate";
import { convertToUrlString } from "../../../../../util/url";
import "./index.less";
import TempDialog from "../expFieldsSetDialog/tempDialog";
@ -24,18 +29,43 @@ class Index extends Component {
super(props);
this.state = {
itemsCheckeds: [], showOnlyChecked: false, tempMangeDialog: { visible: false, salaryAcctRecordId: "" },
tempDialog: { visible: false, salaryAcctRecordId: "", id: "", salaryItemIds: [] }
tempDialog: { visible: false, salaryAcctRecordId: "", id: "", salaryItemIds: [] },
tempOptions: [
{ key: "", showname: "" },
{ key: "system", showname: getLabel(111, "系统模板") }
]
};
}
componentWillReceiveProps(nextProps, nextContext) {
async componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) {
this.setState({
itemsCheckeds: !_.isEmpty(nextProps.checkItems) ? nextProps.checkItems : []
}, () => this.getExportTemplateList(nextProps));
} else {
this.setState({
tempOptions: [
{ key: "", showname: "" },
{ key: "system", showname: getLabel(111, "系统模板") }
]
});
}
}
getExportTemplateList = (props) => {
const { salaryAcctRecordId } = props;
getExportTemplateList({ salaryAcctRecordId }).then(({ status, data }) => {
if (status) {
const { pageInfo: { list } } = data;
this.setState({
tempOptions: [
...this.state.tempOptions, ..._.map(list, o => ({ key: String(o.id), showname: o.templateName }))
]
});
}
});
};
customExportClick = () => {
const { calculateStore: { ECSearchForm }, salaryAcctRecordId } = this.props;
const { itemsCheckeds } = this.state;
@ -69,9 +99,25 @@ class Index extends Component {
}
});
};
handleChangeExpTemp = async (id) => {
switch (id) {
case "system":
const { salaryAcctRecordId } = this.props;
const { data: { checkItems: checkeds } } = await getExportField({ salaryAcctRecordId });
this.setState({ itemsCheckeds: checkeds });
break;
case "":
this.setState({ itemsCheckeds: "" });
break;
default:
const { data: { checkItems } } = await getExportTemplateForm({ id });
this.setState({ itemsCheckeds: _.map(checkItems, o => parseInt(o)) });
break;
}
};
render() {
const { showOnlyChecked, itemsCheckeds, tempMangeDialog, tempDialog } = this.state;
const { showOnlyChecked, itemsCheckeds, tempMangeDialog, tempDialog, tempOptions } = this.state;
const { itemsByGroup, salaryAcctRecordId } = this.props;
let dataSource = _.map(itemsByGroup, item => {
return {
@ -88,7 +134,7 @@ class Index extends Component {
}
const titleComp = <div className="setHeaderWrapper">
<span>{getLabel(111, "选择字段")}</span>
<WeaSelect options={[]} style={{ width: 200 }}/>
<WeaSelect options={tempOptions} style={{ width: 200 }} onChange={this.handleChangeExpTemp}/>
</div>;
return (
<WeaDialog
@ -107,7 +153,7 @@ class Index extends Component {
buttons={[
<Button type="primary" onClick={this.customExportClick}>{getLabel(17416, "导出")}</Button>,
<Button type="primary" onClick={() => this.setState({
tempDialog: { visible: true, salaryAcctRecordId, id: "", salaryItemIds: [] }
tempDialog: { visible: true, salaryAcctRecordId, id: "", salaryItemIds: itemsCheckeds }
})}>{getLabel(111, "存为模板")}</Button>,
<Button type="primary"
onClick={() => this.setState({
@ -145,7 +191,9 @@ class Index extends Component {
})
}
<ExpTempManagementDialog {...tempMangeDialog}
onCancel={(isRefresh) => this.setState({ tempMangeDialog: { visible: false } })}
onCancel={() => this.setState({
tempMangeDialog: { ...tempMangeDialog, visible: false }
}, () => this.getExportTemplateList(this.props))}
/>
{/*模板保存*/}
<TempDialog {...tempDialog} onCancel={(isRefresh) => this.setState({

View File

@ -6,7 +6,7 @@
*/
import React, { Component } from "react";
import { WeaCheckbox, WeaDialog, WeaLocaleProvider, WeaSearchGroup } from "ecCom";
import { Button, Col, Row } from "antd";
import { Button, Col, message, Row } from "antd";
import * as API from "../../../../../apis/calculate";
import TempDialog from "./tempDialog";
@ -29,11 +29,11 @@ class Index extends Component {
}
getExportField = (props) => {
const { salaryAcctRecordId } = props;
const { salaryAcctRecordId, checkItems } = props;
API.getExportField({ salaryAcctRecordId }).then(({ status, data }) => {
if (status) {
const { itemsByGroup } = data;
this.setState({ itemsByGroup });
this.setState({ itemsByGroup, itemsCheckeds: checkItems });
}
});
};
@ -43,24 +43,45 @@ class Index extends Component {
if (item.salarySobItemGroupId === groupId) {
if (!!Number(checked)) {
this.setState({
itemsCheckeds: [...itemsCheckeds, ..._.map(item.salaryItems, child => child.salaryItemId)]
itemsCheckeds: [...itemsCheckeds, ..._.map(item.salaryItems, child => String(child.salaryItemId))]
});
} else {
this.setState({
itemsCheckeds: _.differenceWith(itemsCheckeds, _.map(item.salaryItems, child => child.salaryItemId), _.isEqual)
itemsCheckeds: _.differenceWith(itemsCheckeds, _.map(item.salaryItems, child => String(child.salaryItemId)), _.isEqual)
});
}
}
});
};
save = () => {
const { itemsCheckeds } = this.state;
const { salaryAcctRecordId, tempId: id, templateName } = this.props;
if (!id) {
this.setState({
tempDialog: {
visible: true, salaryAcctRecordId, id, salaryItemIds: itemsCheckeds
}
});
} else {
API.saveExportTemplate({ templateName, salaryAcctRecordId, id, salaryItemIds: itemsCheckeds })
.then(({ status, errormsg }) => {
this.setState({ loading: false });
if (status) {
message.success(getLabel(111, "操作成功!"));
this.props.onCancel(true);
} else {
message.error(errormsg);
}
}).catch(() => this.setState({ loading: false }));
}
};
render() {
const { itemsCheckeds, itemsByGroup, tempDialog } = this.state;
const { salaryAcctRecordId, tempId: id } = this.props;
let dataSource = _.map(itemsByGroup, item => {
return {
...item, salaryItems: _.map(item.salaryItems, child => {
return { ...child, checked: itemsCheckeds.includes(child.salaryItemId) };
return { ...child, checked: itemsCheckeds.includes(String(child.salaryItemId)) };
})
};
});
@ -72,11 +93,7 @@ class Index extends Component {
width: 700, height: 606.6, minHeight: 200, minWidth: 380, maxHeight: "70%",
maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
}}
buttons={[<Button type="primary" onClick={() => this.setState({
tempDialog: {
visible: true, salaryAcctRecordId, id, salaryItemIds: itemsCheckeds
}
})}>{getLabel(111, "保存")}</Button>]}
buttons={[<Button type="primary" onClick={this.save}>{getLabel(111, "保存")}</Button>]}
>
{
_.map(dataSource, item => {
@ -93,7 +110,7 @@ class Index extends Component {
const { salaryItemId, salaryItemName, checked } = it;
return <Col span={8} style={{ marginBottom: 16 }}>
<WeaCheckbox content={salaryItemName} value={checked ? "1" : "0"}
onChange={() => this.setState({ itemsCheckeds: _.xorWith(itemsCheckeds, [salaryItemId], _.isEqual) })}
onChange={() => this.setState({ itemsCheckeds: _.xorWith(itemsCheckeds, [String(salaryItemId)], _.isEqual) })}
/>
</Col>;
}) : <Col span={24} style={{

View File

@ -6,6 +6,7 @@
*/
import React, { Component } from "react";
import { WeaButtonIcon, WeaDialog, WeaInputSearch, WeaLocaleProvider, WeaTab, WeaTable } from "ecCom";
import { message, Modal } from "antd";
import ExpFieldsSetDialog from "../expFieldsSetDialog";
import * as API from "../../../../../apis/calculate";
@ -16,8 +17,8 @@ class Index extends Component {
super(props);
this.state = {
pageInfo: { current: 1, pageSize: 10, total: 0 }, dataSource: [], columns: [], loading: false,
fieldsSetDialog: { visible: false, salaryAcctRecordId: "" }, query: { templateName: "" },
selectedRowKeys: []
fieldsSetDialog: { visible: false, salaryAcctRecordId: "", tempId: "", templateName: "", checkItems: [] },
query: { templateName: "" }, selectedRowKeys: []
};
this.dialogRef = null;
}
@ -35,10 +36,59 @@ class Index extends Component {
API.getExportTemplateList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const {} = data;
const { pageInfo: { columns, list: dataSource, pageNum: current, pageSize, total } } = data;
this.setState({
dataSource, pageInfo: { ...pageInfo, current, pageSize, total },
columns: [...columns, {
dataIndex: "operate", title: getLabel(111, "操作"), width: 120,
render: (__, record) => (<React.Fragment>
<a href="javascript:void(0);"
onClick={() => this.getExportTemplateForm(record)}>{getLabel(111, "编辑")}</a>
<a href="javascript:void(0);" style={{ marginLeft: 10 }}
onClick={() => this.deleteExportTemplate([record.id])}>{getLabel(111, "删除")}</a>
</React.Fragment>)
}]
});
}
}).catch(() => this.setState({ loading: false }));
};
getExportTemplateForm = (record) => {
const { id, templateName } = record;
const { fieldsSetDialog } = this.state;
const { salaryAcctRecordId } = this.props;
API.getExportTemplateForm({ id }).then(({ status, data }) => {
if (status) {
const { checkItems } = data;
this.setState({
fieldsSetDialog: {
...fieldsSetDialog, tempId: id, templateName, visible: true, salaryAcctRecordId, checkItems
}
});
} else {
this.setState({
fieldsSetDialog: {
...fieldsSetDialog, tempId: id, templateName, visible: true, salaryAcctRecordId, checkItems: []
}
});
}
});
};
deleteExportTemplate = (ids) => {
Modal.confirm({
title: getLabel(131329, "信息确认"),
content: getLabel(111, "确定要删除吗?"),
onOk: () => {
API.deleteExportTemplate({ ids }).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(111, "操作成功!"));
this.setState({ selectedRowKeys: [] }, () => this.getExportTemplateList(this.props));
} else {
message.error(errormsg);
}
});
}
});
};
render() {
const { fieldsSetDialog, query, pageInfo, selectedRowKeys, dataSource, columns } = this.state;
@ -75,18 +125,26 @@ class Index extends Component {
>
<WeaTab datas={[]} buttons={[
<WeaButtonIcon buttonType="add" type="primary" title={getLabel(111, "添加")}
onClick={() => this.setState({ fieldsSetDialog: { visible: true, salaryAcctRecordId } })}/>,
onClick={() => this.setState({
fieldsSetDialog: {
...fieldsSetDialog, visible: true, tempId: "", templateName: "",
salaryAcctRecordId, checkItems: []
}
})}/>,
<WeaButtonIcon buttonType="del" type="primary" title={getLabel(111, "删除")}
disabled={_.isEmpty(selectedRowKeys)}/>,
disabled={_.isEmpty(selectedRowKeys)}
onClick={() => this.deleteExportTemplate(selectedRowKeys)}/>,
<WeaInputSearch value={query.templateName}
onChange={val => this.setState({ query: { ...query, templateName: val } })}
onSearch={() => this.getExportTemplateList(this.props)}/>
onSearch={() => this.setState({
pageInfo: { ...pageInfo, current: 1 }
}, () => this.getExportTemplateList(this.props))}/>
]}/>
<WeaTable dataSource={dataSource} columns={columns} pagination={pagination} rowSelection={rowSelection}
scroll={{ y: `calc(${dialogBodyHeight} - 100px)` }}/>
scroll={{ y: `calc(${dialogBodyHeight}px - 148px)` }}/>
<ExpFieldsSetDialog {...fieldsSetDialog}
onCancel={(isRefresh) => this.setState({
fieldsSetDialog: { ...fieldsSetDialog, visible: false }
fieldsSetDialog: { ...fieldsSetDialog, visible: false, checkItems: [] }
}, () => isRefresh && this.getExportTemplateList(this.props))}/>
</WeaDialog>
);