import React, {Component} from 'react'
|
import { is, fromJS } from 'immutable'
|
import { notification, Table} from 'antd'
|
|
import Api from '@/api'
|
import UtilsDM from '@/utils/utils-datamanage.js'
|
|
import './index.scss'
|
|
class DebugTable extends Component {
|
state = {
|
columns: null, // 显示列
|
data: [], // 列表数据集
|
loading: false, // 列表数据加载中
|
setting: {
|
interType: 'system',
|
execute: true,
|
dataresource: 'select * from s_debug_value_log where createuserid=@userid@'
|
},
|
arr_field: 'ID,Sort,CDefine1,CDefine2,CDefine3,CDefine4,CDefine5,CDefine6,CDefine7,'
|
}
|
|
/**
|
* @description 子表数据加载
|
*/
|
async loadmaindata () {
|
const { setting, arr_field } = this.state
|
|
this.setState({
|
loading: true
|
})
|
|
let _orderBy = 'sort'
|
let param = UtilsDM.getQueryDataParams(setting, arr_field, [], _orderBy, 1, 9999, '')
|
|
let result = await Api.genericInterface(param)
|
|
if (result.status) {
|
let start = 1
|
|
this.setState({
|
data: result.data.map((item, index) => {
|
item.key = index
|
item.$$uuid = item.ID || ''
|
item.$$key = '' + item.key + item.$$uuid
|
item.$Index = start + index + ''
|
|
return item
|
}),
|
loading: false
|
})
|
} else {
|
this.setState({
|
loading: false
|
})
|
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
UNSAFE_componentWillMount() {
|
// 组件加载时,获取菜单数据
|
this.loadmaindata()
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { data, loading, columns } = this.state
|
|
return (
|
<div className="debugtable">
|
<Table size="middle" columns={columns} dataSource={data} loading={loading} scroll={{ x: '100%', y: false }}/>
|
</div>
|
)
|
}
|
}
|
|
export default DebugTable
|