import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; import { Input, Table, Button, Select, message, Popconfirm } from 'antd'; // import { getAccidentInfo, createAccidentInfo, deleteAccidentInfo, editAccidentInfo, getAllCompany } from '../actions/device'; // import EditAccidentModal from '../components/editAccidentModal'; import EditGuanlang from '../components/editGuanlang'; import '../style.less'; import { Func } from '$utils'; import moment from 'moment'; var recordId = null; const Guanlang = (props) => { const { dispatch, user, totalPage, companys, creditScore } = props const [data, setData] = useState([]) const [modalVisible, setModalVisible] = useState(false); const [modalRecord, setModalRecord] = useState(); const [companyName, setCompanyName] = useState(null) const [creditCode, setCreditCode] = useState(null) const [pageSize, setPageSize] = useState(10); const [currentPage, setCurrentPage] = useState(1); const [applyStatus, setApplyStatus] = useState(null); const [applyState, setApplyState] = useState('check'); // check 查看;create 新增; apply 初审; approve 复审 const [editModal, setEditModal] = useState(false); const [readOnly, setReadOnly] = useState(false); const accidentInfo= [] // const initial = (params, search = false) => { // dispatch(getAccidentInfo(params)).then(() => { if (search) setCurrentPage(1) }) // } useEffect(() => { const params = { limit: pageSize, offset: currentPage } // initial(params) }, [true]) const openModal = (record, state) => { if (state == 'check') { setReadOnly(true) } else { setReadOnly(false) } searchCompany(record.companyName) setApplyState(state); setModalVisible(true); setModalRecord(record); } const search = () => { const params = { company: companyName, applyStatus, limit: pageSize, offset: 1 } // initial(params, true) } const clearSearch = () => { setCompanyName(null) setCreditCode(null) const params = { limit: pageSize, offset: currentPage } // initial(params) } const columns = [ { title: '序号', dataIndex: 'companyName', key: 'companyName', }, { title: '设备名称', dataIndex: 'accidentTime', key: 'accidentTime', render: (text) => { return moment(text).format('YYYY-MM-DD') } }, { title: '设备状态', dataIndex: 'stationName', key: 'stationName', render: (v, t) => { let list = t.accidentStations.map(item => item.stationName); return list.join(','); } }, { title: '接入类型', dataIndex: 'stationName', key: 'stationName', render: (v, t) => { let list = t.accidentStations.map(item => item.stationName); return list.join(','); } }, { title: '设备厂家', dataIndex: 'stationName', key: 'stationName', render: (v, t) => { let list = t.accidentStations.map(item => item.stationName); return list.join(','); } }, { title: '操作', render: (record) => { return ( openModal(record, 'check')}>查看   openModal(record, 'edit')}>编辑   { // console.log(record) // dispatch(deleteAccidentInfo(record.id)).then((res) => { // if (res.success) { // message.success('删除记录成功'); // search(); // } // } // ) } } > 删除   ) } } ]; const handleSaveScore = (data) => { console.log('执行了') setModalVisible(false); // if (applyState == 'create') // dispatch(createAccidentInfo(data)).then(res => { // if (res.success) { // message.success('事故资讯添加成功'); // setModalVisible(false); // search(); // } // }) // else if (applyState == 'edit') { // dispatch(editAccidentInfo(data)).then(res => { // if (res.success) { // message.success('事故资讯编辑成功'); // setModalVisible(false); // search(); // } // }) // } } var timer = null; const searchCompany = (companyName) => { if (timer) { clearTimeout(timer) } else { timer = setTimeout(() => { // dispatch(getAllCompany({ companyName })); }, 400); } } const spanStyle = { diplay: 'inline-block', marginLeft: 10 } const inputStyle = { width: 200 } return (
设备搜索: setCompanyName(v.target.value)}> 接入类型: setCompanyName(v.target.value)}> 厂家筛选: setCompanyName(v.target.value)}> 查询状态: setCompanyName(v.target.value)}>
{ return {`共${Math.ceil(total / pageSize)}页,${total}项`} }, onShowSizeChange: (currentPage, pageSize) => { setCurrentPage(currentPage); setPageSize(pageSize); const params = { company: companyName, creditCode, limit: pageSize, offset: currentPage } // initial(params) }, onChange: (page, pageSize) => { setCurrentPage(page); setPageSize(pageSize); const params = { company: companyName, creditCode, limit: pageSize, offset: page } // initial(params) } }} /> {modalVisible ? { setModalVisible(false) }} handleSaveScore={handleSaveScore} // searchCompany={searchCompany} companys={companys} editData={modalRecord} readOnly={readOnly} applyState={applyState} > : ''} ) } function mapStateToProps(state) { const { auth, accidentInfo, allCompany } = state return { // user: auth?.user, // accidentInfo: accidentInfo?.data && accidentInfo?.data.rows || [], // totalPage: accidentInfo.data && accidentInfo.data.count, // companys: allCompany.data && allCompany.data.rows || [] } } export default connect(mapStateToProps)(Guanlang);