From 942cb64adf9f3f8113549ffc9f64e6861d556064 Mon Sep 17 00:00:00 2001
From: Mr Ke <kelq@hugeinfo.com.cn>
Date: Wed, 27 May 2020 17:41:57 +0800
Subject: [PATCH] 加入iframeKey值

---
 SunshineIns/src/page/CriminalExecution.jsx |  207 ++++++++++++++++++++++-----------------------------
 1 files changed, 91 insertions(+), 116 deletions(-)

diff --git a/SunshineIns/src/page/CriminalExecution.jsx b/SunshineIns/src/page/CriminalExecution.jsx
index 89a6780..560de49 100644
--- a/SunshineIns/src/page/CriminalExecution.jsx
+++ b/SunshineIns/src/page/CriminalExecution.jsx
@@ -3,7 +3,7 @@
 import HeadView from '../view/HeadView';
 import TableBtnView from '../view/TableBtnView';
 import CommonSearchForm from '../view/CommonSearchForm';
-import { Input, Button, DatePicker, Divider, message, Popconfirm, Select, Badge, Modal } from 'antd';
+import { Input, Button, DatePicker, Divider, message, Popconfirm, Select, Badge, Modal, Row, Col } from 'antd';
 import moment from 'moment';
 import Fetch from '../fetch';
 import TableView from '../view/TableView';
@@ -64,13 +64,26 @@
                 size: 10,
             },
             resetKey: Date.now(),
-            loading: false
+            loading: false,
+            zIndex: '-1',
+            savedate: {},
+            display: 'none',
+            fingerCode: ''
         };
     }
 
     componentDidMount() {
         document.title = '社会观护管理';
-        this.getData();
+        let _this = this;
+        window.addEventListener('message', function (e) {
+            console.log('反馈', e)
+            if (e.data) {
+                _this.setState({
+                    ...e.data
+                })
+            }
+        }, false);
+        this.iframeAddEventListener();
     }
 
     setFormData = data => {
@@ -80,52 +93,7 @@
         });
     }
 
-    getData = () => {
-        const { formData } = this.state;
-        this.setState({ loading: true })
-        Fetch.socialQuery({ ...formData })
-            .then(res => {
-                console.log(res)
-                for (var i = 0; i < res.rows.length; i++) {
-                    res.rows[i]['index'] = i + 1;
-                }
-                this.setState({
-                    data: res.rows,
-                    loading: false,
-                });
-            });
-    }
-
-    onInputChange = ({ target: { value, name } }) => {
-        this.setState(({ formData }) => ({
-            formData: {
-                ...formData,
-                [name]: value
-            }
-        }))
-    }
-
-    Seaech = () => {
-        const { formData } = this.state;
-        Fetch.getSweeping(formData)
-            .then(res => {
-                for (var i = 0; i < res.length; i++) {
-                    res[i]['index'] = i + 1;
-                }
-                this.setState({
-                    data: res
-                });
-            });
-    }
-    Reset = () => {
-        this.setState({
-            resetKey: Date.now(),
-            formData: {}
-        }, this.getData);
-    }
-
-
-    confirm = (e) => {
+    deleteItems = (e) => {
         console.log(e);
         this.setState({ loading: true })
         Fetch.socialDelete(e).then(res => {
@@ -144,90 +112,84 @@
 
     showModal = (id) => {
         this.setState({
-          visible: true,
+            visible: true,
+            zIndex: 1000,
+            iframeKey: id,
+            display: 'none'
         });
+        this.sendMsg();
         // Fetch.socialCompanyDetail(id)
         //   .then(res => {
         //     this.setState({ savedate: res })
         //   })
-      }
+    }
+
+    saveInputChange = ({ target: { value, name } }) => {
+        this.setState(({ savedate }) => ({
+            savedate: {
+                ...savedate,
+                [name]: value
+            }
+        }))
+    }
 
     renderColumns = () => {
         return [{
-            title: '任务标题',
-            dataIndex: 'taskTitle',
-            key: 'taskTitle'
+            title: '编号',
+            dataIndex: 'index',
+            key: 'index',
+            render: (text, item, index) => <span>{index}</span>
         }, {
-            title: '任务类型',
-            dataIndex: 'taskType',
-            key: 'taskType',
-            render: text => <span>{typeOfName(text)}</span>
+            title: ' 姓名',
+            dataIndex: 'name',
+            key: 'name',
         }, {
-            title: '状态',
-            dataIndex: 'status',
-            key: 'status',
-            render: text => (
-                text == 0 ?
-                    <Badge style={{ backgroundColor: '#6C757C' }} count={'未开始'} /> : text == 1 ? <Badge count={'进行中'} style={{ backgroundColor: '#F1C40F' }} /> : text == 2 ? <Badge count={'已结束'} style={{ backgroundColor: '#2ECC71' }} /> : <Badge count={'暂停'} style={{ backgroundColor: '#2ECC71' }} />
-            )
+            title: '牢房号',
+            dataIndex: 'number',
+            key: 'number',
         }, {
-            title: '创建时间',
+            title: '指纹唯一识别',
+            dataIndex: 'shibie',
+            key: 'shibie',
+        }, {
+            title: '录入时间',
             dataIndex: 'createTime',
             key: 'createTime',
-            render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
-        }, {
-            title: '开始时间',
-            dataIndex: 'startTime',
-            key: 'startTime',
-            render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
-        }, {
-            title: '结束时间',
-            dataIndex: 'endTime',
-            key: 'endTime',
-            render: text => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>
+            render: text => <span>{moment(text).format("YYYY-MM-DD")}</span>
         }, {
             title: '操作',
             key: 'action',
             render: (text, record) => (
                 <span>
-                    {
-                        record.status == 0 ?
-                            <React.Fragment>
-                                <a onClick={() => this.showModal(record.id)}>编辑</a>
-                                <Divider type="vertical" />
-                                <Popconfirm
-                                    title="确认删除任务吗?"
-                                    id={record.id}
-                                    onConfirm={e => this.confirm(record.id)}
-                                    okText="确定"
-                                    cancelText="取消"
-                                >
-                                    <a href="#">删除</a>
-                                    <Divider type="vertical" />
-                                </Popconfirm>
-                                <a onClick={() => this.reboot(record.id, 99)}>暂停</a>
-                            </React.Fragment> :
-                            record.status == 1 ?
-                                <React.Fragment>
-                                    <a onClick={() => this.showModal(record.id)}>查看</a>
-                                    <Divider type="vertical" />
-                                    <a onClick={() => this.showModal(record.id)}>结束任务</a>
-                                    <Divider type="vertical" />
-                                    <a onClick={() => this.reboot(record.id, 99)}>暂停</a>
-                                </React.Fragment> :
-                                <React.Fragment>
-                                    <a onClick={() => this.showModal(record.id)}>查看</a>
-                                    <Divider type="vertical" />
-                                    <a onClick={() => this.reboot(record.id, 0)}>重启</a>
-                                </React.Fragment>
-                    }
+                    <label onClick={() => this.showModal(record.id)} className='theme-color' style={{ cursor: 'pointer' }}>编辑</label>
+                    <Divider type="vertical" />
+                    <label onClick={() => this.deleteItems(record.id)} className='theme-color' style={{ cursor: 'pointer' }}>删除</label>
                 </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
+        }, '*');
+    }
+
     render() {
-        const { data, resetKey, visible, loading, savedate, closeKey, formData } = this.state;
+        const { data, resetKey, visible, loading, savedate, closeKey, formData, zIndex, display, fingerCode, iframeKey } = this.state;
         return (
             <div className="app-page">
                 <HeadView history={this.props.history} />
@@ -255,25 +217,38 @@
                     <TableView columns={this.renderColumns()} data={data} pageSize='10' size='default' loading={loading} />
                 </div>
                 <Modal
+                    zIndex={zIndex}
                     key={closeKey}
                     confirmLoading={loading}
-                    visible={visible}
-                    title="公司信息"
-                    onOk={this.handleOk}
-                    onCancel={this.handleCancel}
+                    visible={true}
+                    title="指纹录入"
+                    onCancel={() => { this.setState({ visible: false, zIndex: '-1', }) }}
+                    bodyStyle={{ lineHeight: 4 }}
+                    // footer={null}
+                    width={'60%'}
                     bodyStyle={{ lineHeight: 4 }}
                 >
+                    <Input addonBefore="姓名" name='name' onChange={this.saveInputChange} value={savedate.name || ''} />
+                    <Input addonBefore="牢房号" name='lnumber' onChange={this.saveInputChange} value={savedate.lnumber || ''} />
+                    <Input addonBefore="指纹唯一标识" name='fingerCode' onChange={this.saveInputChange} value={fingerCode || ''} addonAfter={<Row type="flex" style={{ flexWrap: 'nowrap' }}>
+                        <Col style={{ cursor: 'pointer' }} onClick={() => this.setState({ display: 'block' })}>
+                            录入指纹
+                        </Col>
+                    </Row>} />
+                    <Divider style={{ margin: '2px 0' }} />
                     <iframe
-                        className="h-100"
-                        style={{ width: '100%' }}
+                        key={iframeKey}
+                        style={{ width: '100%', height: '550px', display: display }}
                         onLoad={() => { }}
                         ref="iframe"
-                        src='../../asset/fingerprint/指纹登记.html'
+                        src='./fingerprint/指纹登记.html'
                         width="100%"
                         scrolling="no"
                         frameBorder="0"
                     />
                 </Modal>
+
+                {/* </div> */}
             </div>
         )
     }

--
Gitblit v1.8.0