数据采集-考勤引用页面重构

This commit is contained in:
黎永顺 2023-03-08 15:03:08 +08:00
parent 72959ca015
commit 7500887660
3 changed files with 82 additions and 7 deletions

View File

@ -27,21 +27,24 @@ export default class SelectItemModal extends React.Component {
render() {
const { searchValue } = this.state;
const { title, onSearchItemSet, onShowOnlyChecked, children, ...extra } = this.props;
const btns = [<Button type="primary">保存</Button>];
const {
title, onSearchItemSet, onShowOnlyChecked, children,
onMoreOpts, onSave, ...extra
} = this.props;
const btns = [<Button type="primary" onClick={onSave}>保存</Button>];
const moreBtn = {
datas: [
{
key: "recovery",
content: "恢复默认设置",
icon: <i className="icon-coms-Flow-setting"/>,
onClick: key => alert(`点击事物处理函数接受的实参为 ${key}`)
onClick: key => onMoreOpts(key)
},
{
key: "setting",
content: "设为默认设置",
icon: <i className="icon-coms-Flow-setting"/>,
onClick: key => alert(`点击事物处理函数接受的实参为 ${key}`)
onClick: key => onMoreOpts(key)
}
]
};

View File

@ -18,6 +18,15 @@ class SelectItemsWrapper extends Component {
};
}
componentDidMount() {
const { dataSource } = this.props
this.setState({
selectItem: _.map(_.filter(_.reduce(dataSource, (pre, cur) => {
return [...pre, ...cur.items];
}, []), item => !!item.checked), it => it.id)
});
}
handleSearchItemSet = (searchVal) => this.setState({ searchVal });
handleShowOnlyChecked = (showOnlyChecked) => this.setState({ showOnlyChecked: !!Number(showOnlyChecked) });
handleSelectGroupAll = (groupId, checked) => {
@ -47,8 +56,9 @@ class SelectItemsWrapper extends Component {
const { onSelectGroupAll } = this.props;
const { groupName, groupId, items } = item;
const number = _.filter(items, it => !!it.checked).length;
const value = _.every(items, it => !!it.checked) ? "1" : "0";
return <div className="setGroupWrapper">
<WeaCheckbox content={groupName} onChange={(val) => onSelectGroupAll(groupId, val)}/>
<WeaCheckbox content={groupName} value={value} onChange={(val) => onSelectGroupAll(groupId, val)}/>
<span className="checkedtitle">已选择{number}个字段</span>
</div>;
};
@ -75,7 +85,6 @@ class SelectItemsWrapper extends Component {
return { ...item, items: _.filter(item.items, it => !!it.checked) };
});
}
console.log(setItemList);
return (
<React.Fragment>
{

View File

@ -14,7 +14,10 @@ import {
getLedgerList,
getSalaryCycleAndAttendCycle,
importAttendQuoteData,
previewAttendQuote
previewAttendQuote,
returnToAttendanceFieldSettingDefault,
saveAttendanceFieldSetting,
saveAttendanceFieldSettingAsDefault
} from "../../../../apis/attendance";
import ImportModal from "../../../../components/importModal";
import HeaderSet from "../../../../components/importModal/headerSet";
@ -248,6 +251,65 @@ class AttendanceDataComp extends Component {
handleShowOnlyChecked = (checked) => this.setItemRef.handleShowOnlyChecked(checked);
handleSelectGroupAll = (groupId, checked) => this.setItemRef.handleSelectGroupAll(groupId, checked);
handleSelectItem = (id, checked) => this.setItemRef.handleSelectItem(id, checked);
handleMoreOpts = (key) => {
switch (key) {
case "recovery":
returnToAttendanceFieldSettingDefault({ sourceType: "IMPORT" }).then(({ status, errormsg }) => {
if (status) {
message.success("操作成功");
this.handleHeaderSettings({ sourceType: "IMPORT" });
} else {
message.error(errormsg || "操作失败");
}
});
break;
case "setting":
const { state, props } = this.setItemRef;
let currentSettingFields = [];
const { selectItem } = state, { dataSource } = props;
_.forEach(dataSource, item => {
currentSettingFields = _.map([...currentSettingFields, ...item.items], child => {
return {
id: child.id,
checked: selectItem.includes(child.id)
};
});
});
const payload = { currentSettingFields, sourceType: "IMPORT" };
saveAttendanceFieldSettingAsDefault(payload).then(({ status, errormsg }) => {
if (status) {
message.success("操作成功");
} else {
message.error(errormsg || "操作失败");
}
});
break;
default:
break;
}
};
handleSave = () => {
const { state, props } = this.setItemRef;
let currentSettingFields = [];
const { selectItem } = state, { dataSource } = props;
_.forEach(dataSource, item => {
currentSettingFields = _.map([...currentSettingFields, ...item.items], child => {
return {
id: child.id,
checked: selectItem.includes(child.id)
};
});
});
const payload = { currentSettingFields, sourceType: "IMPORT" };
saveAttendanceFieldSetting(payload).then(({ status, errormsg }) => {
if (status) {
message.success("保存成功");
this.handleCloseSettings();
} else {
message.error(errormsg || "保存失败");
}
});
};
/*
* Author: 黎永顺
* Description: 考勤数据引用
@ -330,6 +392,7 @@ class AttendanceDataComp extends Component {
onCancel={this.handleCloseSettings}
onSearchItemSet={this.handleSearchItemSet}
onShowOnlyChecked={this.handleShowOnlyChecked}
onMoreOpts={this.handleMoreOpts} onSave={this.handleSave}
/>
{/* 考勤数据引用 */}
<AttendanceRefrenceDataModal