108 lines
3.8 KiB
JavaScript
108 lines
3.8 KiB
JavaScript
/*
|
|
* 考勤引用数据编辑
|
|
* @Author: 黎永顺
|
|
* @Date: 2025/4/23
|
|
* @Wechat:
|
|
* @Email: 971387674@qq.com
|
|
* @description:
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLocaleProvider, WeaSlideModal, WeaTop } from "ecCom";
|
|
import { editAttendQuoteData, getAttendQuoteData } from "../../../../apis/attendance";
|
|
import FormInfo from "../../../../components/FormInfo";
|
|
import { WeaForm } from "comsMobx";
|
|
import { Button, message } from "antd";
|
|
import "./index.less";
|
|
|
|
const { getLabel } = WeaLocaleProvider;
|
|
const form = new WeaForm();
|
|
const baseInforFields = ["username", "departmentName", "mobile", "jobNum", "idNo"];
|
|
|
|
class AttendanceDataEditSlide extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { conditions: [], loading: false };
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.visible !== this.props.visible && nextProps.visible) {
|
|
this.getAttendQuoteData(nextProps);
|
|
} else if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
|
form.resetForm();
|
|
}
|
|
}
|
|
|
|
getAttendQuoteData = (props) => {
|
|
const { record } = props || this.props, { id } = record;
|
|
getAttendQuoteData({ id }).then(({ status, data }) => {
|
|
if (status) {
|
|
const { columns, data: result } = data;
|
|
this.setState({
|
|
conditions: [{
|
|
defaultshow: true,
|
|
items: [
|
|
..._.map(baseInforFields, o => ({
|
|
conditionType: "INPUT",
|
|
domkey: [o],
|
|
fieldcol: 14,
|
|
label: _.find(columns, k => k.column === o).text,
|
|
labelcol: 8,
|
|
value: result[o] || "",
|
|
viewAttr: 1
|
|
})),
|
|
..._.map(_.filter(columns, o => !baseInforFields.includes(o.column)), k => ({
|
|
conditionType: "INPUT",
|
|
domkey: [k.column],
|
|
fieldcol: 14,
|
|
rules: "",
|
|
label: k.text,
|
|
labelcol: 8,
|
|
value: result[k.column] || "",
|
|
viewAttr: 2
|
|
}))
|
|
]
|
|
}]
|
|
}, () => form.initFormFields(this.state.conditions));
|
|
}
|
|
});
|
|
};
|
|
save = () => {
|
|
form.validateForm().then(f => {
|
|
if (f.isValid) {
|
|
const { record } = this.props, { id } = record;
|
|
const { username, departmentName, mobile, jobNum, idNo, ...formData } = form.getFormParams();
|
|
const payload = { id, attendQuoteData: { ...formData } };
|
|
this.setState({ loading: true });
|
|
editAttendQuoteData(payload).then(({ status, errormsg }) => {
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
message.success(getLabel(30700, "操作成功"));
|
|
this.props.onClose();
|
|
this.props.onSuccess();
|
|
} else {
|
|
message.error(errormsg);
|
|
}
|
|
}).catch(() => this.setState({ loading: false }));
|
|
} else {
|
|
f.showErrors();
|
|
}
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { record } = this.props, { username } = record, { conditions, loading } = this.state;
|
|
const btns = [
|
|
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(111, "保存")}</Button>
|
|
];
|
|
return (<WeaSlideModal {...this.props} className="editAttendanceSlide" top={0} height={100} width={1000}
|
|
measureX="px" measureT="%" measureY="%" direction="right"
|
|
title={<WeaTop title={username} icon={<i className="icon-coms-fa"/>}
|
|
iconBgcolor="#F14A2D" buttons={btns}/>}
|
|
content={<FormInfo className="form-dialog-layout" center={false} itemRender={{}} form={form}
|
|
formFields={conditions} colCount={2}/>
|
|
}/>);
|
|
}
|
|
}
|
|
|
|
export default AttendanceDataEditSlide;
|