feature/2.16.1.2410.01-薪酬统计报表薪资明细添加模板切换和模板创建功能

This commit is contained in:
lys 2024-11-11 14:43:17 +08:00
parent 7063732d6f
commit 3654e2a378
5 changed files with 117 additions and 57 deletions

View File

@ -66,6 +66,26 @@ class CustomBrowserMutiRight extends Component {
clearTimeout(timeout);
this.props.onDoubleClick && this.props.onDoubleClick(key);
};
onDragStart = (obj) => {
clearTimeout(timeout);
this.props.checkedCb && this.props.checkedCb([]);
};
onDrop = (obj) => {
const dragNodes = obj.dragNodesKeys;
const targetNode = obj.node.props.eventKey;
const result = [];
this.nodeIds.filter((item) => {
return dragNodes.indexOf(item) === -1;
}).forEach((id) => {
if (id === targetNode) {
dragNodes.forEach((drag) => {
result.push(this.nodeObj[drag]);
});
}
result.push(this.nodeObj[id]);
});
this.props.onDrag && this.props.onDrag(result);
};
render() {
const { height, checkedKeys } = this.props;
@ -76,9 +96,8 @@ class CustomBrowserMutiRight extends Component {
<div>
<WeaNewScroll height={height || 400}>
<Tree className="transfer-tree" draggable multiple={true} async={true} selectable={true}
onSelect={this.checkHandler}
onDoubleClick={this.onDoubleClick}
selectedKeys={checkedKeys}>
onSelect={this.checkHandler} onDoubleClick={this.onDoubleClick} selectedKeys={checkedKeys}
onDragStart={this.onDragStart} onDrop={this.onDrop}>
{this.generateTreeNodes()}
</Tree>
</WeaNewScroll>

View File

@ -188,6 +188,7 @@ class CustomTransferDialog extends Component {
data={rightDatas} checkedKeys={rightCheckedKeys}
checkedCb={rightCheckedKeys => this.setState({ rightCheckedKeys })}
onDoubleClick={this.onRightDoubleClick}
onDrag={(data) => {this.setState({rightDatas: data})}}
/>
</div>
</div>

View File

@ -30,9 +30,9 @@ class SalaryDetails extends Component {
constructor(props) {
super(props);
this.state = {
loading: false, dataSource: [], columns: [], selectedRowKeys: [], tempPageList: [],
loading: false, dataSource: [], columns: [], selectedRowKeys: [], tempPageList: [], sumRow: {},
pageInfo: { current: 1, pageSize: 10, total: 0 }, payload: {}, templateId: "",
showTotalCell: false, updateSum: true, tempDialog: { visible: false, setting: [] },
showTotalCell: false, updateSum: true, tempDialog: { visible: false, setting: [], id: "", template: {} },
transferDialog: {
visible: false, searchParamsKey: "name", dataParams: { page: "salary_details_report" }, saveLoading: false,
completeURL: "", convertDatasource: datas => {
@ -46,13 +46,16 @@ class SalaryDetails extends Component {
};
}
componentDidMount() {
this.getSalaryList(this.props);
this.getPageListTemplatelist();
async componentDidMount() {
const [{ data: confCode }] = await Promise.all([sysConfCodeRule({ code: "OPEN_ACCT_RESULT_SUM" })]);
this.setState({
showTotalCell: confCode === "1"
}, () => {
this.getSalaryList(this.props);
this.getPageListTemplatelist();
});
window.addEventListener("message", this.handleReceive, false);
window.addEventListener("resize", () => this.setState({
transferDialog: { ...this.state.transferDialog, cancel: true }
}, () => this.forceUpdate()), false);
window.addEventListener("resize", () => this.forceUpdate(), false);
}
componentWillReceiveProps(nextProps, nextContext) {
@ -63,9 +66,7 @@ class SalaryDetails extends Component {
componentWillUnmount() {
window.removeEventListener("message", this.handleReceive, false);
window.removeEventListener("message", () => this.setState({
transferDialog: { ...this.state.transferDialog, cancel: true }
}, () => this.forceUpdate()), false);
window.removeEventListener("message", () => this.forceUpdate(), false);
this.setState(({ selectedRowKeys: [] }));
}
@ -73,9 +74,9 @@ class SalaryDetails extends Component {
API.getPageListTemplatelist({ page: "salary_details_report" }).then(({ status, data }) => {
if (status) {
this.setState({
tempPageList: _.map(data, o => ({ key: String(o.id), showname: o.name })),
tempPageList: _.map(data, o => ({ ...o, key: String(o.id), showname: o.name })),
templateId: !_.isEmpty(_.find(data, o => !!o.checked)) ? String(_.find(data, o => !!o.checked).id) : "",
transferDialog: { ...this.state.transferDialog, visible: false, cancel: true, type: "default" }
transferDialog: { ...this.state.transferDialog, visible: false, type: "default" }
});
}
});
@ -110,7 +111,7 @@ class SalaryDetails extends Component {
const { attendanceStore: { salaryDetailSearchForm, tableStore }, dateRange } = props || this.props;
const [startDateStr, endDateStr] = dateRange;
const { taxAgentIds, subcompanyIds, departmentIds, ...extra } = salaryDetailSearchForm.getFormParams();
const { pageInfo, transferDialog } = this.state;
const { pageInfo, transferDialog, updateSum } = this.state;
const payload = {
taxAgentIds: taxAgentIds ? taxAgentIds.split(",") : [],
departmentIds: departmentIds ? departmentIds.split(",") : [],
@ -118,20 +119,23 @@ class SalaryDetails extends Component {
...extra, ...pageInfo, startDateStr, endDateStr
};
this.setState({ loading: true });
API.getSalaryList(payload).then(async ({ status, data }) => {
// API.getSalaryListSum(payload),
const [{ data: confCode }] = await Promise.all([sysConfCodeRule({ code: "OPEN_ACCT_RESULT_SUM" })]);
API.getSalaryList(payload).then(({ status, data }) => {
if (updateSum) this.getSalaryListSum(payload);
this.setState({ loading: false });
if (status) {
const { columns, dataKey, pageInfo: pageparams } = data;
const { list: dataSource, pageNum: current, total, pageSize } = pageparams;
this.setState({
columns, dataSource, pageInfo: { ...pageInfo, current, total, pageSize }, payload,
showTotalCell: confCode === "1", transferDialog: { ...transferDialog, cancel: false }
columns, dataSource, pageInfo: { ...pageInfo, current, total, pageSize }, payload
}, () => tableStore.getDatas(dataKey.datas));
}
}).catch(() => this.setState({ loading: false }));
};
getSalaryListSum = (payload) => {
API.getSalaryListSum(payload).then(({ status, data }) => {
if (status) this.setState({ sumRow: data.sumRow });
});
};
handleExportSalaryList = (key) => {
const { attendanceStore: { tableStore }, salaryDetailShowType } = this.props;
let { selectedRowKeys, payload, columns: tempCols } = this.state;
@ -149,15 +153,13 @@ class SalaryDetails extends Component {
getColumns = () => {
const { attendanceStore: { tableStore }, salaryDetailShowType } = this.props;
const {
columns: tempCols, dataSource, pageInfo, selectedRowKeys, showTotalCell, payload, updateSum, transferDialog
columns: tempCols, dataSource, pageInfo, selectedRowKeys, showTotalCell, sumRow, transferDialog
} = this.state;
const customCols = _.filter(toJS(tableStore.columns), (item) => item.display === "true" && item.dataIndex !== "acctTimes");
const sumRowlistUrl = showTotalCell ? "/api/bs/hrmsalary/report/statistics/employee/salaryListSum" : "";
const columns = salaryDetailShowType === "1" ? _.filter(tempCols, o => o.column !== "acctTimes") : customCols;
if (!_.isEmpty(columns) && !transferDialog.visible && !transferDialog.cancel) {
if (!_.isEmpty(columns)) {
this.postMessageToChild({
dataSource, pageInfo, selectedRowKeys, showTotalCell, calcDetail: true, tableScrollHeight: 154,
sumRowlistUrl, payload: { ...payload, updateSum },
dataSource, pageInfo, selectedRowKeys, showTotalCell, calcDetail: true, tableScrollHeight: 154, sumRow,
columns: _.map(columns, (it, idx) => ({
dataIndex: it.column || it.dataIndex, title: it.text || it.title, calcDetail: true,
width: (it.dataIndex === "taxAgent" || it.dataIndex === "salarySob") ? 176 : (it.width || it.oldWidth),
@ -170,13 +172,14 @@ class SalaryDetails extends Component {
};
handleSetDefCols = () => this.setState({
transferDialog: {
...this.state.transferDialog, completeURL: "/api/bs/hrmsalary/common/pageList/get/setting", visible: true
...this.state.transferDialog, completeURL: "/api/bs/hrmsalary/common/pageList/get/setting", visible: true,
dataParams: { page: "salary_details_report" }
}
});
converCheckedCol = (data) => {
return _.reduce(data.checked || [], (pre, cur) => {
const item = _.find(data.setting, k => k.id === cur);
if (!_.isEmpty(item)) return [...pre, item];
const item = _.find(data.setting, k => (k.id === cur) || (k.column === cur.column));
if (!_.isEmpty(item)) return [...pre, { ...item, id: item.id || item.column, name: item.name || item.text }];
return pre;
}, []);
};
@ -205,12 +208,17 @@ class SalaryDetails extends Component {
}
});
};
handelAddTemp = () => this.setState({
transferDialog: {
...this.state.transferDialog, visible: true, type: "temp",
completeURL: "/api/bs/hrmsalary/common/pageList/template/get"
}
});
handelAddTemp = (templateId) => {
const { transferDialog, tempDialog, tempPageList } = this.state;
this.setState({
transferDialog: {
...transferDialog, visible: true, type: "temp",
dataParams: { ...transferDialog.dataParams, id: templateId },
completeURL: "/api/bs/hrmsalary/common/pageList/template/get"
},
tempDialog: { ...tempDialog, id: templateId, template: _.find(tempPageList, o => o.key === templateId) }
});
};
changePageListTemplate = (templateId) => {
this.setState({ templateId }, () => {
API.changePageListTemplate({ page: "salary_details_report", templateId }).then(({ status, errormsg }) => {
@ -231,21 +239,25 @@ class SalaryDetails extends Component {
<div className="query-div">
{
salaryDetailShowType === "1" &&
<WeaSelect style={{ width: 200 }} hasAddBtn options={tempPageList} addOnClick={this.handelAddTemp}
showSearch optionFilterProp="children" value={templateId}
onChange={this.changePageListTemplate}/>
<div className="custom-select">
<WeaSelect style={{ width: 200 }} hasAddBtn options={tempPageList} addOnClick={this.handelAddTemp}
showSearch optionFilterProp="children" value={templateId}
onChange={this.changePageListTemplate}/>
{
templateId &&
<span className="custom-select-edit" title={getLabel(111, "编辑模板")}
onClick={() => this.handelAddTemp(templateId)}>
<i className="icon-coms-BatchEditing-Hot"></i>
</span>
}
</div>
}
<MonthRangePicker dateRange={dateRange} viewAttr={2} onChange={this.props.onChange}/>
<AdvanceInputBtn onOpenAdvanceSearch={() => this.setState({
transferDialog: { ...this.state.transferDialog, cancel: true }
}, () => this.props.handleOpenAdvanceSearch())} onAdvanceSearch={this.props.handleAdvanceSearch}/>
<AdvanceInputBtn onOpenAdvanceSearch={this.props.handleOpenAdvanceSearch}
onAdvanceSearch={this.props.handleAdvanceSearch}/>
</div>
<div className={cs("searchAdvanced-condition-container", { "searchAdvanced-condition-hide": !showSearchAd })}>
<SearchPannel onCancel={() => {
this.setState({
transferDialog: { ...this.state.transferDialog, cancel: true }
}, () => this.props.onCancel());
}} onAdSearch={this.props.onAdSearch}/>
<SearchPannel onCancel={this.props.onCancel} onAdSearch={this.props.onAdSearch}/>
</div>
<div className="table-layout"
style={{ height: getIframeParentHeight(".wea-new-top-req-content", dataSource.length, 70) + "px" }}>
@ -267,14 +279,18 @@ class SalaryDetails extends Component {
<CustomTransferDialog {...transferDialog} onChange={this.savePageListSetting}
onCancel={() => this.setState({
transferDialog: {
...transferDialog, completeURL: "", visible: false, cancel: true, type: "default"
...transferDialog, completeURL: "", visible: false, type: "default"
}
})}/>
{/*薪资明细模板设置*/}
<SalaryDetailsTempDialog {...tempDialog} onSuccess={this.getPageListTemplatelist}
onCancel={() => this.setState({
<SalaryDetailsTempDialog {...tempDialog}
onCancel={callback => this.setState({
tempDialog: { ...tempDialog, visible: false, setting: [] }
})}/>
}, () => callback && callback())}
onSuccess={() => {
this.getPageListTemplatelist();
this.getSalaryList();
}}/>
</div>
</React.Fragment>
);

View File

@ -39,12 +39,13 @@ class SalaryDetailTempDialog extends Component {
getTempForm = (props) => {
getTaxAgentSelectList().then(({ status, data }) => {
if (status) {
const { id, template } = props;
this.setState({
conditions: _.map(tempCondition, item => ({
...item, items: _.map(item.items, o => {
if (getKey(o) === "sharedType") {
return {
...o, label: getLabel(o.lanId, o.label), value: "0",
...o, label: getLabel(o.lanId, o.label), value: id ? String(template["sharedType"]) : "0",
options: [
{ key: "0", showname: getLabel(111, "公共") },
{ key: "1", showname: getLabel(111, "私有") }
@ -52,11 +53,12 @@ class SalaryDetailTempDialog extends Component {
};
} else if (getKey(o) === "limitIds") {
return {
...o, label: getLabel(o.lanId, o.label),
...o, label: getLabel(o.lanId, o.label), hide: !id || (id && template["sharedType"] === 0),
value: id ? template["limitIds"].join(",") : "",
options: _.map(data, o => ({ key: o.id, showname: o.content }))
};
}
return { ...o, label: getLabel(o.lanId, o.label) };
return { ...o, label: getLabel(o.lanId, o.label), value: id ? template[getKey(o)] : "" };
})
}))
}, () => {
@ -67,13 +69,13 @@ class SalaryDetailTempDialog extends Component {
});
};
save = () => {
const { attendanceStore: { tempForm }, setting } = this.props;
const { attendanceStore: { tempForm }, setting, id } = this.props;
tempForm.validateForm().then(f => {
if (f.isValid) {
this.setState({ loading: true });
const { limitIds, ...formVal } = tempForm.getFormParams();
const payload = {
page: "salary_details_report", setting, ...formVal,
page: "salary_details_report", setting, id, ...formVal,
limitIds: !_.isEmpty(limitIds) ? limitIds.split(",") : []
};
API.savePageListTemplate(payload).then(({ status, errormsg }) => {

View File

@ -220,8 +220,30 @@
margin-bottom: 8px;
padding: 0 8px;
.custom-select {
display: flex;
align-content: center;
position: relative;
.custom-select-edit {
position: absolute;
right: -56px;
cursor: pointer;
display: inline-block;
vertical-align: middle;
background-color: #f4f4f4;
color: #b2b2b2;
border: 1px solid #d9d9d9;
border-left: none;
width: 28px;
height: 30px;
line-height: 28px;
text-align: center;
}
}
.rangePickerBox {
margin: 0 10px 0 40px;
margin: 0 10px 0 68px;
}
}