salary-management-front/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/refereAttendFormModal.js

152 lines
5.8 KiB
JavaScript
Raw Normal View History

2022-03-14 18:58:02 +08:00
import React from 'react'
2022-04-26 10:42:08 +08:00
import { Modal, Row, Col, Button, Select, message } from 'antd'
import moment from 'moment'
2022-03-14 18:58:02 +08:00
import { WeaSelect, WeaInput, WeaBrowser, WeaDatePicker } from "ecCom"
import SelectItemModal, {items} from '../../../components/selectItemsModal'
import SelectItemsWrapper from '../../../components/selectItemsModal/selectItemsWrapper'
2022-04-26 10:42:08 +08:00
import { inject, observer } from 'mobx-react';
import RequiredLabelTip from '../../../components/requiredLabelTip'
import { notNull } from '../../../util/validate'
const { Option } = Select
2022-03-14 18:58:02 +08:00
2022-04-26 10:42:08 +08:00
@inject('attendanceStore')
@observer
2022-03-14 18:58:02 +08:00
export default class RefereAttendFormModal extends React.Component {
constructor(props) {
super(props)
this.state = {
2022-04-26 10:42:08 +08:00
headerSetVisible: false,
inited: false,
request: {
salarySobId: "",
salaryYearMonth: moment(new Date()).format("YYYY-MM"),
employeeIds: [],
description: ""
}
2022-03-14 18:58:02 +08:00
}
}
2022-03-23 16:01:10 +08:00
handleHeaderSet() {
this.setState({headerSetVisible: true})
this.props.onHeaderSet();
}
2022-04-26 10:42:08 +08:00
componentWillMount() {
const { attendanceStore: { getLedgerList }} = this.props;
getLedgerList().then(() => {
this.setState({
inited: true
})
})
}
// 请求参数改变事件
handleRequestChange(params) {
const { request } = this.state;
let result = { ...request, ...params }
this.setState({request: result})
}
// 同步点击回调
handleSync() {
const { attendanceStore: {syncAttendanceRefer}} = this.props
if(!this.validate()) {
return
}
syncAttendanceRefer(this.state.request).then(() => {
this.props.onCancel()
})
}
// 校验数据
validate() {
const { request } = this.state;
if(!notNull(request.salarySobId)) {
message.warning("薪资账套不能为空");
return false;
}
if(!notNull(request.salaryYearMonth)) {
message.warning("薪资所属月不能为空")
return false;
}
return true;
}
2022-03-14 18:58:02 +08:00
render() {
2022-04-26 10:42:08 +08:00
const { attendanceStore: { importLedgerList }} = this.props;
2022-03-14 18:58:02 +08:00
return (
<Modal width={600} title="引用考勤数据" footer={
<div style={{display: "inline-block"}}>
2022-04-26 10:42:08 +08:00
<Button type="primary" onClick={() => {this.handleSync()}}>同步</Button>
2022-03-23 16:01:10 +08:00
<Button type="default" onClick={() => {this.handleHeaderSet()}}>表头设置</Button>
2022-03-14 18:58:02 +08:00
</div>
} visible={this.props.visible} onCancel={this.props.onCancel}>
<Row style={{marginBottom: "10px"}}>
2022-04-26 10:42:08 +08:00
<Col span={8}>薪资所属月: <RequiredLabelTip /></Col>
2022-03-14 18:58:02 +08:00
<Col span={16}>
<WeaDatePicker
format="yyyy-MM"
style={{width: 200}}
2022-04-26 10:42:08 +08:00
value={this.state.request.salaryYearMonth}
onChange={(value) => {
this.handleRequestChange({salaryYearMonth: value})
}}
2022-03-14 18:58:02 +08:00
/>
</Col>
</Row>
<Row style={{marginBottom: "10px"}}>
2022-04-26 10:42:08 +08:00
<Col span={8}>薪资账套<RequiredLabelTip /></Col>
2022-03-14 18:58:02 +08:00
<Col span={16}>
2022-04-26 10:42:08 +08:00
{
this.state.inited && <Select
defaultValue={this.state.request.salarySobId} value={this.state.request.salarySobId} style={{ width: "200px" }} onChange={(value) => {
this.handleRequestChange({salarySobId: value})
}}>
{importLedgerList.map(item => (
<Option value={item.id} key={item.id}>{item.content}</Option>
))}
</Select>
}
2022-03-14 18:58:02 +08:00
</Col>
</Row>
<Row style={{marginBottom: "10px"}}>
<Col span={8}>添加账套外人员</Col>
<Col span={16}>
2022-04-26 10:42:08 +08:00
<WeaBrowser
type={17}
textDecoration={true}
inputStyle={{ width: 200 }}
onChange={(ids, names, datas) =>
this.handleRequestChange({employeeIds: ids.split(",")})
}
isSingle={false}
/>
2022-03-14 18:58:02 +08:00
</Col>
</Row>
<Row style={{marginBottom: "10px"}}>
<Col span={8}>备注</Col>
<Col span={16}>
2022-04-26 10:42:08 +08:00
<WeaInput style={{width: 200}} value={this.state.request.description} onChange={(value) => {
this.handleRequestChange({description: value})
}}/>
2022-03-14 18:58:02 +08:00
</Col>
</Row>
2022-03-23 16:01:10 +08:00
<SelectItemModal
onShowChecked={(value) => {this.props.onShowChecked(value)}}
onRestoreDefault={() => {this.props.onRestoreDefault()}}
onSetDefault={() => {this.props.onSetDefault()}}
onSearch={(value) => {this.props.onSearch(value)}}
onSave={(value) => {this.props.onSave(value)}}
visible={this.state.headerSetVisible} onCancel={() => this.setState({headerSetVisible: false})}>
<SelectItemsWrapper items={this.props.items} title={"考勤模块"} onChange={(value) => {this.props.onChange(value)}}/>
2022-03-14 18:58:02 +08:00
</SelectItemModal>
</Modal>
)
}
}