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')}>编辑