feature/2.9.42310.01-工资单发放页面重构单

This commit is contained in:
黎永顺 2023-10-18 10:18:26 +08:00
parent 7e30f73069
commit 0acc570a24
6 changed files with 172 additions and 42 deletions

View File

@ -212,7 +212,9 @@ export const tempNormalSetConditions = [
labelcol: 6,
value: "",
showClearAll: false,
listType: "img",
showListBottom: false,
showListTop: false,
// listType: "img",
limitType: "jpg,jpeg,png",
uploadUrl: "/api/doc/upload/uploadFile",
category: "string",

View File

@ -1,11 +1,16 @@
import { WeaSwitch } from "comsMobx";
import { WeaFormItem, WeaLocaleProvider, WeaSearchGroup, WeaTools } from "ecCom";
import { WeaButtonIcon, WeaFormItem, WeaLocaleProvider, WeaSearchGroup, WeaTools } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;
const getKey = WeaTools.getKey;
export const payrollTempNormalSetForm = (form, condition, col, isCenter, onChange = () => void (0), insertVar = () => void (0)) => {
export const payrollTempNormalSetForm = (form, condition, background, onChange = () => void (0), insertVar = () => void (0)) => {
const { isFormInit } = form;
const formParams = form.getFormParams();
const img1Props = {
src: "/weaver/weaver.file.FileDownload?fileid=a897b63092c473b95d98ed95138518e72fcaff559a225b618062f453c4d21b4bc43d18cd849d0ba00c94d2b02a53750b08e683c37ee144133",
width: 100,
height: 100
};
let group = [];
isFormInit && condition && condition.map(c => {
let items = [];
@ -19,19 +24,29 @@ export const payrollTempNormalSetForm = (form, condition, col, isCenter, onChang
error={form.getError(fields)}
tipPosition="bottom"
>
<WeaSwitch
fieldConfig={fields}
form={form}
formParams={formParams}
onChange={onChange}
/>
{
(getKey(fields) === "background" && background) ?
<React.Fragment>
<WeaButtonIcon buttonType="del" type="primary" onClick={() => insertVar("background", "")}/>
<img {...img1Props} alt=""/>
</React.Fragment>
:
<WeaSwitch
fieldConfig={fields}
form={form}
formParams={formParams}
onChange={onChange}
/>
}
{
getKey(fields) === "theme" &&
<div className="sft-variables">
<span className="sftv-tip">{getLabel(500143, "插入变量")}</span>
<a className="sftv-item" onClick={() => insertVar("${companyName}")}>{getLabel(1976, "公司名称")}</a>
<a className="sftv-item"
onClick={() => insertVar("${salaryMonth}")}>{getLabel(542604, "薪资所属月")}</a>
onClick={() => insertVar("theme", "${companyName}")}>{getLabel(1976, "公司名称")}</a>
<a className="sftv-item"
onClick={() => insertVar("theme", "${salaryMonth}")}>{getLabel(542604, "薪资所属月")}</a>
</div>
}
</WeaFormItem>),
@ -41,12 +56,12 @@ export const payrollTempNormalSetForm = (form, condition, col, isCenter, onChang
});
group.push(
<WeaSearchGroup
col={col || 1}
col={1}
needTigger={true}
title={c.title}
showGroup={c.defaultshow}
items={items}
center={isCenter || false}
center={false}
/>);
});
return group;

View File

@ -42,6 +42,7 @@ class Index extends Component {
const { salaryTemplateShowSet, salaryTemplateSalaryItemSet: salaryItemSet, salaryBillItemNameSet } = data;
const { data: result } = salaryTemplateShowSet;
const { ...fieldsEchoData } = { ...result, ...toJS(tmplDataSource) };
console.log(111, toJS(tmplDataSource), { ...result, ...toJS(tmplDataSource) });
this.setState({
conditions: _.map(tempNormalSetConditions, it => {
if (it.title === "themeSet") {
@ -77,9 +78,6 @@ class Index extends Component {
case "salaryItemNullStatus":
payrollTempNormalForm.updateFields({ [it]: fieldsEchoData[it] ? "1" : "0" });
break;
case "background":
console.log(81, fieldsEchoData);
break;
default:
payrollTempNormalForm.updateFields({ [it]: fieldsEchoData[it] ? fieldsEchoData[it].toString() : "" });
break;
@ -92,10 +90,12 @@ class Index extends Component {
};
getPayrollItemList = () => {
const { salaryItemSet } = this.state;
const { payrollStore: { tmplDataSource } } = this.props;
const { payrollStore: { tmplDataSource, setTmplDataSource } } = this.props;
getPayrollItemList({ salarySobId: toJS(tmplDataSource).salarySob }).then(({ status, data }) => {
if (status && _.isEmpty(salaryItemSet)) {
this.setState({ salaryItemSet: data });
this.setState({ salaryItemSet: data }, () => {
setTmplDataSource({ ...toJS(tmplDataSource), salaryItemSetting: data });
});
}
});
};
@ -107,16 +107,29 @@ class Index extends Component {
setTmplDataSource({ ...toJS(tmplDataSource), background });
}
};
handleInsertVar = (themeVar) => {
const { payrollStore: { payrollTempNormalForm } } = this.props;
handleInsertVar = (key, themeVar) => {
const { payrollStore: { payrollTempNormalForm, setTmplDataSource, tmplDataSource } } = this.props;
const theme = payrollTempNormalForm.getFormParams().theme;
payrollTempNormalForm.updateFields({ theme: `${theme}${themeVar}` });
if (key === "background") {
setTmplDataSource({ ...toJS(tmplDataSource), background: themeVar });
} else {
payrollTempNormalForm.updateFields({ [key]: `${theme}${themeVar}` });
}
};
handleChangeSalaryItem = (resultSet) => {
console.log(resultSet);
const { payrollStore: { setTmplDataSource, tmplDataSource } } = this.props;
this.setState({ salaryItemSet: resultSet }, () => {
setTmplDataSource({ ...toJS(tmplDataSource), salaryItemSetting: resultSet });
});
};
handleChangeSalaryItemShowNamesetting = (itemShowNamesetting) => {
console.log(itemShowNamesetting);
const { payrollStore: { setSalaryBillItemNameSetting, salaryBillItemNameSetting } } = this.props;
setSalaryBillItemNameSetting(_.map(salaryBillItemNameSetting, it => {
if (it.salaryBillType === 0) {
return { ...it, salaryTemplateId: this.props.tmplId, itemShowNameSetting: itemShowNamesetting };
}
return { ...it, salaryTemplateId: this.props.tmplId };
}));
};
render() {
@ -124,7 +137,7 @@ class Index extends Component {
const { payrollStore: { payrollTempNormalForm, tmplDataSource } } = this.props;
return (
<React.Fragment>
{!_.isEmpty(conditions) && payrollTempNormalSetForm(payrollTempNormalForm, conditions, 1, false, this.handleChange, this.handleInsertVar)}
{!_.isEmpty(conditions) && payrollTempNormalSetForm(payrollTempNormalForm, conditions, toJS(tmplDataSource).background, this.handleChange, this.handleInsertVar)}
<WeaSearchGroup
title={
<div className="salarySetTitle">

View File

@ -0,0 +1,91 @@
/*
* Author: 黎永顺
* name:工资单发放-重构页面补发工资单模板
* Description:
* Date: 2023/10/17
*/
import React, { Component } from "react";
import { toJS } from "mobx";
import { WeaButtonIcon, WeaLocaleProvider, WeaSearchGroup } from "ecCom";
import SalaryItemSettings from "../../../payroll/stepForm/salaryItemSettings";
import { getReplenishForm } from "../../../../apis/payroll";
const getLabel = WeaLocaleProvider.getLabel;
class Index extends Component {
constructor(props) {
super(props);
this.state = {
replenishSalaryTemplateSalaryItemSet: [], salaryBillItemNameSet: {}
};
}
componentDidMount() {
this.getReplenishForm();
}
getReplenishForm = () => {
const { payrollStore: { tmplDataSource, setTmplDataSource }, tmplId: id } = this.props;
const salarySobId = toJS(tmplDataSource).salarySob;
getReplenishForm({ salarySobId, id }).then(({ status, data }) => {
if (status) {
const { replenishSalaryTemplateSalaryItemSet, salaryBillItemNameSet } = data;
this.setState({
replenishSalaryTemplateSalaryItemSet, salaryBillItemNameSet
}, () => {
// setTmplDataSource({
// ...toJS(tmplDataSource),
// replenishSalaryItemSetting: replenishSalaryTemplateSalaryItemSet
// });
});
}
});
};
handleChangeSalaryItem = (resultSet) => {
const { payrollStore: { setTmplDataSource, tmplDataSource } } = this.props;
this.setState({ replenishSalaryTemplateSalaryItemSet: resultSet }, () => {
setTmplDataSource({
...toJS(tmplDataSource),
replenishSalaryItemSetting: resultSet
});
});
};
handleChangeSalaryItemShowNamesetting = (itemShowNamesetting) => {
const { payrollStore: { setSalaryBillItemNameSetting, salaryBillItemNameSetting } } = this.props;
setSalaryBillItemNameSetting(_.map(salaryBillItemNameSetting, it => {
if (it.salaryBillType === 1) {
return { ...it, salaryTemplateId: this.props.tmplId, itemShowNameSetting: itemShowNamesetting };
}
return { ...it, salaryTemplateId: this.props.tmplId };
}));
};
render() {
const { payrollStore: { tmplDataSource } } = this.props;
const { replenishSalaryTemplateSalaryItemSet, salaryBillItemNameSet } = this.state;
return (
<WeaSearchGroup
title={
<div className="salarySetTitle">
<span>{getLabel(543593, "薪资项目设置")}</span>
<WeaButtonIcon buttonType="add" type="primary"
onClick={() => this.salaryItemSettingsRef.handleOpenModal(toJS(tmplDataSource).salarySob, getLabel(543594, "添加分类"))}/>
</div>
}
items={[]} needTigger showGroup>
<SalaryItemSettings
ref={dom => this.salaryItemSettingsRef = dom}
dataSource={replenishSalaryTemplateSalaryItemSet}
onChangeSalaryItem={this.handleChangeSalaryItem}
onChangeSalaryItemShowNamesetting={this.handleChangeSalaryItemShowNamesetting}
salarySobId={toJS(tmplDataSource).salarySob}
salaryTemplateId={this.props.tmplId || ""}
isReplenish={true} salaryBillItemNameSet={salaryBillItemNameSet}
/>
</WeaSearchGroup>
);
}
}
export default Index;

View File

@ -11,6 +11,7 @@ import { WeaLocaleProvider, WeaSlideModal, WeaSteps } from "ecCom";
import { Button, message } from "antd";
import PayrollTempBaseSet from "../payrollTempBaseSet";
import PayrollTempNormalSet from "../payrollTempNormalSet";
import PayrollTempReissueSet from "../payrollTempReissueSet";
import { savePayroll } from "../../../../apis/payroll";
const Step = WeaSteps.Step;
@ -87,7 +88,11 @@ class Index extends Component {
}
});
};
savePayroll = (payload) => {
savePayroll = () => {
const { payrollStore: { tmplDataSource, salaryBillItemNameSetting } } = this.props;
const payload = { ...toJS(tmplDataSource), salaryBillItemNameSetting: toJS(salaryBillItemNameSetting) };
console.log(payload, tmplDataSource, toJS(salaryBillItemNameSetting));
return;
this.setState({ loading: true });
savePayroll(payload).then(({ status, errormsg }) => {
this.setState({ loading: false });
@ -108,7 +113,7 @@ class Index extends Component {
<div className="titleCol titleRightBox">
{
current === 0 ?
<Button type="primary" loading={loading} onClick={this.save}>{getLabel(1402, "下一步")}</Button> :
<Button type="primary" onClick={this.save}>{getLabel(1402, "下一步")}</Button> :
current === 1 ?
<React.Fragment>
<Button type="ghost"
@ -119,7 +124,7 @@ class Index extends Component {
<React.Fragment>
<Button type="ghost"
onClick={() => this.setState({ current: current - 1 })}>{getLabel(1876, "上一步")}</Button>
<Button type="primary">{getLabel(537558, "保存")}</Button>
<Button type="primary" loading={loading} onClick={this.savePayroll}>{getLabel(537558, "保存")}</Button>
</React.Fragment>
}
</div>
@ -133,7 +138,10 @@ class Index extends Component {
dom = <PayrollTempBaseSet {...this.props} ref={dom => this.tmpBaseSetRef = dom}/>;
break;
case 1:
dom = <PayrollTempNormalSet {...this.props} ref={dom => this.tmpNormalSetRef = dom}/>;
dom = <PayrollTempNormalSet {...this.props} />;
break;
case 2:
dom = <PayrollTempReissueSet {...this.props} />;
break;
default:
break;

View File

@ -21,6 +21,20 @@ export class payrollStore {
@observable payrollTempNormalForm = new WeaForm(); //新建编辑工资单模板-主题设置form
@action initPayrollTempNormalForm = () => this.payrollTempNormalForm = new WeaForm();
@observable salaryBillItemNameSetting = [
{
salaryTemplateId: "",
salaryBillType: 0,
itemShowNameSetting: []
},
{
salaryTemplateId: "",
salaryBillType: 1,
itemShowNameSetting: []
}
]; // 工资单模板薪资项目名称修改列表
@action
setSalaryBillItemNameSetting = salaryBillItemNameSetting => (this.salaryBillItemNameSetting = salaryBillItemNameSetting);
@observable tableStore = new TableStore(); // new table
@ -40,18 +54,7 @@ export class payrollStore {
@observable salaryTemplateShowSet = {}; // 显示设置基础表单
@observable replenishSalaryTemplateSalaryItemSet = []; // 补发工资单模版基础表单
@observable salaryItemSet = []; // 显示设置薪资项
@observable salaryBillItemNameSetting = [
{
salaryTemplateId: "",
salaryBillType: 0,
itemShowNameSetting: []
},
{
salaryTemplateId: "",
salaryBillType: 1,
itemShowNameSetting: []
}
]; // 工资单模板薪资项目名称修改列表
@observable salaryBillItemNameSet = {}; // 工资单模板薪资项目名称修改列表
// **** 工资单页面 ****
@ -116,8 +119,6 @@ export class payrollStore {
setSalaryItemSet = salaryItemSet => (this.salaryItemSet = salaryItemSet);
@action
setSalaryBillItemNameSet = salaryBillItemNameSet => (this.salaryBillItemNameSet = salaryBillItemNameSet);
@action
setSalaryBillItemNameSetting = salaryBillItemNameSetting => (this.salaryBillItemNameSetting = salaryBillItemNameSetting);
@action("工资单模板分页信息修改")
setTemplateTablePageInfo = (pageInfo, callback) => {