mh-sms-web/src/components/CustomPages/FM/SelectUser.js
2024-01-22 09:18:38 +08:00

159 lines
5.2 KiB
JavaScript

import { message } from "antd/lib/index";
import { Layout,Descriptions, Tabs, Steps, Button, Popconfirm, Row, Col, Form, Input, Select, Table, Drawer ,Icon} from 'antd';
import React from 'react';
import { PlusOutlined } from '@ant-design/icons';
import ReactToPrint from "react-to-print";
import styles from '../HI/StepForm.css';
import config from "../../../config";
import XLSX from 'xlsx';
import { connect } from 'dva';
import moment from 'moment';
const { Header, Footer, Sider, Content } = Layout;
const TabPane = Tabs.TabPane;
const { TextArea } = Input;
const { Step } = Steps;
import {
extend,
extendRule,
initFilter,
initQueryFilter,
getOnlyPropertyData,
extendInclude,
empty,
getDataFieldValue, guid, initFilterGroup, extendGroupRule
} from "../../../utils/common";
import FormPage from '../../../components/FormPage'
class SelectUser extends React.Component {
constructor(props) {
super(props)
this.state = {
title: '选择人员',
data: {},
userData: [],
selectUserId: '',
}
};
componentDidMount() {
if (this.props.data?.id)
this.loadData(this.props.data?.id);
}
componentWillReceiveProps(NextProps) {
if (NextProps.data?.id && this.props.data?.id != NextProps.data?.id) {
this.loadData(NextProps.data?.id);
}
}
BtnClose = () => {
if (typeof this.props.data.onCancel != "undefined" && typeof this.props.data.onCancel == 'function')
this.props.data.onCancel();
}
selectChange = (e) => {
// const jsonUser = initFilter(this.props.login.OrgId, '', '', 0, 1)
// extendRule(jsonUser, "NAME", 1, e);
// this.props.dispatch({
// type: 'app/getDataByPost',
// url: 'FM/User/OrderEntities',
// payload: jsonUser,
// onlyData: false,
// onComplete: (ret) => {
// this.setState({
// userData: ret.Data
// });
// }
// });
this.setState({
selectUserId: e
})
}
onComplaint = (e) => {
if (this.state.selectUserId === '') {
message.error("请选择转办人");
return;
}
const json = initFilter(this.props.login.OrgId, this.props.data.id, '', 0, 1, this.state.selectUserId)
this.props.dispatch({
type: 'app/getDataByPost',
url: 'FM/FMNotificationTask/Complaint',
payload: json,
onlyData: false,
onComplete: (re) => {
if (re && re.IsSuccessful) {
this.setState({
// userData: [],
selectUserId: '',
});
this.BtnClose();
message.success("转办成功");
} else {
message.error("转办失败");
}
}
})
}
loadData() {
const jsonUser = initFilter(this.props.login.OrgId)
jsonUser.Limit=1000;
this.props.dispatch({
type: 'app/getDataByPost',
url: 'FM/User/OrderPagedAuthority',
payload: jsonUser,
onlyData: false,
onComplete: (ret) => {
if (ret) {
this.setState({
userData: ret.Data,
});
}
}
});
}
render() {
const { userData } = this.state;
const formItemLayout = {
labelCol: { span: 3 },
wrapperCol: { span: 20 },
};
return (
<Layout style={{backgroundColor:"#fff",marginLeft:"500px",marginTop:"200px"}}>
<Form layout="vertical" hideRequiredMark>
<Row gutter={16}>
<Col span={12}>
<Form.Item
label={'转办人'}
{...formItemLayout}
>
<Select
showSearch
style={{ width: 200 }}
placeholder='选择人员'
onChange={this.selectChange}
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
>
{
userData
? userData.map(t => {
return <Option value={t.ID} key={t.ID}>{t.NAME}</Option>
}) : null
}
</Select>
</Form.Item>
</Col>
</Row>
<Row gutter={16}>
<Col span={2} style={{ textAlign: 'right' }}>
<Form.Item span={4}>
<Button type="primary" htmlType="complaint" icon="issues-close" onClick={this.onComplaint}>确认转办</Button>
</Form.Item>
</Col>
</Row>
</Form>
</Layout>
)
}
}
export default connect(({ login, app }) => ({ login, app }))(Form.create()(SelectUser))