import React from 'react';
|
|
import HeadView from '../view/HeadView';
|
import TableBtnView from '../view/TableBtnView';
|
import CommonSearchForm from '../view/CommonSearchForm';
|
import { Input, Button, DatePicker, Divider, message, Popconfirm, Select, Tooltip, Modal, Row, Col } from 'antd';
|
import moment from 'moment';
|
import Fetch from '../fetch';
|
import TableView from '../view/TableView';
|
|
const Option = Select.Option;
|
|
export default class CareList extends React.Component {
|
constructor(props) {
|
super(props);
|
this.state = {
|
list: [],
|
formdata: {
|
__key: Date.now(),
|
page: 1,
|
size: 10,
|
},
|
resetKey: Date.now(),
|
loading: false,
|
zIndex: '-1',
|
savedate: {},
|
display: 'none',
|
fingerCode: ''
|
};
|
}
|
|
componentDidMount() {
|
document.title = '刑执监督管理';
|
let _this = this;
|
window.addEventListener('message', function (e) {
|
console.log('反馈', e)
|
if (e.data) {
|
_this.setState({
|
...e.data
|
})
|
}
|
}, false);
|
_this.iframeAddEventListener();
|
_this.getData();
|
}
|
|
getData = () => {
|
const { formdata } = this.state;
|
this.setState({ loading: true })
|
console.log('formdata', formdata)
|
Fetch.criminalQuery({ ...formdata })
|
.then(res => {
|
console.log("res", res)
|
this.setState({
|
list: res.data.content,
|
loading: false
|
});
|
});
|
}
|
|
setFormData = data => {
|
console.log('form', data);
|
this.setState({
|
formdata: data,
|
});
|
}
|
|
deleteItems = (e) => {
|
console.log(e);
|
this.setState({ loading: true })
|
Fetch.criminalDelete(e).then(res => {
|
if (res.code == 0) {
|
console.log(res)
|
this.setState({ loading: false })
|
message.success('删除成功');
|
this.getData();
|
} else {
|
this.setState({ loading: false })
|
message.error('删除失败,请联系管理员', 2)
|
}
|
}
|
)
|
}
|
|
showModal = (id) => {
|
this.setState({
|
visible: true,
|
zIndex: 1000,
|
iframeKey: id,
|
display: 'none',
|
loading: true,
|
});
|
this.sendMsg();
|
Fetch.criminalFind(id)
|
.then(res => {
|
console.log(res)
|
this.setState({ savedate: res.data, fingerCode: res.data.fingerCode || '', loading: false })
|
})
|
}
|
|
saveInputChange = ({ target: { value, name } }) => {
|
this.setState(({ savedate }) => ({
|
savedate: {
|
...savedate,
|
[name]: value
|
}
|
}))
|
}
|
|
renderColumns = () => {
|
return [{
|
title: '编号',
|
dataIndex: 'index',
|
key: 'index',
|
render: (text, item, index) => <span>{index + 1}</span>
|
}, {
|
title: ' 姓名',
|
dataIndex: 'name',
|
key: 'name',
|
}, {
|
title: '牢房号',
|
dataIndex: 'number',
|
key: 'number',
|
}, {
|
title: '指纹唯一识别',
|
dataIndex: 'fingerCode',
|
key: 'fingerCode',
|
render: text => <div className="nowrap">{text}</div>
|
}, {
|
title: '录入时间',
|
dataIndex: 'createTime',
|
key: 'createTime',
|
render: text => <span>{moment(text).format("YYYY-MM-DD")}</span>
|
}, {
|
title: '操作',
|
key: 'action',
|
render: (text, record) => (
|
<span>
|
<label onClick={() => this.showModal(record.id)} className='theme-color' style={{ cursor: 'pointer' }}>编辑</label>
|
<Divider type="vertical" />
|
<Popconfirm
|
title="确认删除吗?"
|
id={record.id}
|
onConfirm={e => this.deleteItems(record.id)}
|
okText="确定"
|
cancelText="取消"
|
>
|
<label className='theme-color' style={{ cursor: 'pointer' }}>删除</label>
|
</Popconfirm>
|
</span>
|
),
|
}]
|
}
|
|
iframeAddEventListener = () => {
|
let _this = this;
|
this.iframeWin = this.refs.iframe && this.refs.iframe.contentWindow;
|
this.refs.iframe && this.refs.iframe.addEventListener("load", function () {
|
//代码能执行到这里说明已经载入成功完毕了
|
//这里是回调函数
|
_this.iframeWin.postMessage({
|
fgData: false
|
}, '*');
|
}, false);
|
}
|
|
sendMsg = () => {
|
this.iframeWin = this.refs.iframe && this.refs.iframe.contentWindow;
|
this.iframeWin.postMessage({
|
fgData: false
|
}, '*');
|
}
|
|
//确认提交按钮
|
handleOk = () => {
|
const { savedate, fingerCode } = this.state;
|
if (!savedate.name) {
|
return message.warning("姓名不能为空");
|
}
|
if (!savedate.number) {
|
return message.warning("牢房号不能为空");
|
}
|
if (!fingerCode) {
|
return message.warning("请录入指纹");
|
}
|
this.setState({ btloading: true })
|
Fetch.criminalSave({ ...savedate, fingerCode })
|
.then(res => {
|
if (res.code === 0) {
|
this.setState({
|
zIndex: '-1',
|
fingerCode: "",
|
btloading: false,
|
closeKey: Date.now()
|
}, this.getData);
|
message.success("提交成功!")
|
}
|
});
|
this.setState({
|
|
})
|
}
|
|
//取消按钮
|
handleCancel = () => {
|
this.setState({
|
fingerCode: "",
|
zIndex: '-1',
|
});
|
}
|
|
render() {
|
const { list, resetKey, visible, loading, btloading, savedate, closeKey, formdata, zIndex, display, fingerCode, iframeKey } = this.state;
|
return (
|
<div className="app-page">
|
<HeadView history={this.props.history} />
|
<div style={{ marginLeft: '90%', marginBottom: '20px', marginTop: '20px' }}>
|
<Button type="primary" size='large' onClick={() => this.showModal('new')}>新增</Button>
|
</div>
|
<div style={{ background: '#fff', margin: 20 }}>
|
{/* <CommonSearchForm
|
{...this.props}
|
formData={formdata}
|
setFormData={this.setFormData}
|
searchonClick={this.searchonClick}
|
pathName={this.props.location.pathname}
|
data={[
|
{
|
type: 'input', name: '公司名称', label: '公司名称', key: 'companyName'
|
},
|
{
|
type: 'input', name: '法人姓名', label: '法人姓名', key: 'companyLegal'
|
},
|
{
|
type: 'input', name: '联系电话', label: '联系电话', key: 'companyTel'
|
},
|
]} /> */}
|
<TableView columns={this.renderColumns()} data={list} pageSize='10' size='default' loading={loading} />
|
</div>
|
<Modal
|
zIndex={zIndex}
|
key={closeKey}
|
confirmLoading={btloading}
|
visible={true}
|
title="指纹录入"
|
onOk={this.handleOk}
|
onCancel={this.handleCancel}
|
bodyStyle={{ lineHeight: 4 }}
|
// footer={null}
|
width={'60%'}
|
bodyStyle={{ lineHeight: 4 }}
|
>
|
<Input addonBefore="姓名" name='name' onChange={this.saveInputChange} value={savedate.name || ''} />
|
<Input addonBefore="牢房号" name='number' onChange={this.saveInputChange} value={savedate.number || ''} />
|
<Input addonBefore="指纹唯一标识" name='fingerCode' value={fingerCode || ''} disabled addonAfter={<Row type="flex" style={{ flexWrap: 'nowrap' }}>
|
<Col style={{ cursor: 'pointer' }} onClick={() => this.setState({ display: 'block' })}>
|
录入指纹
|
</Col>
|
</Row>} />
|
<div style={{ display: display }}>
|
<Divider style={{ margin: '2px 0' }} />
|
<iframe
|
key={iframeKey}
|
style={{ width: '100%', height: '550px' }}
|
onLoad={() => { }}
|
ref="iframe"
|
src='./fingerprint/dengji.html'
|
width="100%"
|
scrolling="no"
|
frameBorder="0"
|
/>
|
</div>
|
</Modal>
|
|
{/* </div> */}
|
</div>
|
)
|
}
|
}
|