trunk/pc4mobx/organization/components/log/LogView.js

218 lines
7.5 KiB
JavaScript
Raw Normal View History

2022-07-05 18:54:56 +08:00
import React from 'react'
import * as mobx from 'mobx'
import {
inject,
observer
} from 'mobx-react'
import {
WeaTop,
WeaTab,
WeaFormItem,
WeaDialog,
2022-07-07 18:06:02 +08:00
WeaSearchGroup,
WeaProgress
2022-07-05 18:54:56 +08:00
} from 'ecCom'
import {
Row,
Col,
Spin,
Modal,
Button,
message,
Switch
} from 'antd'
import {
WeaSwitch,
WeaTableNew
} from 'comsMobx'
import {
i18n
} from '../../public/i18n';
import '../../style/common.less';
const toJS = mobx.toJS;
const confirm = Modal.confirm;
const WeaTable = WeaTableNew.WeaTable;
export default class LogView extends React.Component {
constructor(props) {
super(props);
this.state = ({
2022-07-07 18:06:02 +08:00
height: 502,
2022-07-05 18:54:56 +08:00
width: 1075,
dialogTitle: '日志查看',
2022-07-07 18:06:02 +08:00
showSearchAd: false,
//**** */
detailDialogTitle: "",
detailVisible: false,
record:{}
2022-07-05 18:54:56 +08:00
})
}
componentWillMount() {
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
2022-07-07 18:06:02 +08:00
this.setState({ showSearchAd: false })
2022-07-05 18:54:56 +08:00
if (this.props.keys !== nextProps.keys) {
nextProps.logViewStore.init(nextProps.logMoudleType);
}
}
2022-07-07 18:06:02 +08:00
doView(record) {
this.setState({
record:record,
detailVisible: true,
detailDialogTitle: record.operate_typespan + " - " + record.operate_module_name + " : "+record.value
})
}
reRenderColumns(columns) {
let _this = this;
columns.forEach((c, index) => {
if (c.dataIndex == 'message') {
c.render = function (text, record) {
return <a href='javascript:void(0);' className="common" onClick={() => { _this.doView(record) }}>查看</a>
}
};
})
}
2022-07-05 18:54:56 +08:00
getPanelComponents() {
const {
logViewStore
} = this.props;
const {
searchCondition,
form,
searchConditionLoading
} = logViewStore;
let arr = [];
let formParams = form.getFormParams();
const {
isFormInit
} = form;
isFormInit && searchCondition.map(c => {
c.items.map((field, index) => {
arr.push(<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@4cc308@${index}`} span={(index % 2 == 0) ? 10 : 11} offset={1}>
<div style={{ marginTop: 20 }}>
<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@u6ex85@${index}`}
label={`${field.label}`}
labelCol={{ span: `${field.labelcol}` }}
wrapperCol={{ span: `${field.fieldcol}` }}>
{<WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@p7d3td@${index}`} fieldConfig={field} form={form} formParams={formParams} />}
</WeaFormItem>
</div>
</Col>)
})
})
if (searchConditionLoading) {
return (
<div className='hrm-loading-center-small' style={{ top: '25%' }}>
<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@lbktzb`} spinning={searchConditionLoading}></Spin>
</div>
)
} else {
return <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@ppeb6z`} onKeyDown={(e) => {
if (e.keyCode == 13 && e.target.tagName === "INPUT") {
logViewStore.getTableInfo();
2022-07-07 18:06:02 +08:00
this.setState({ showSearchAd: false })
2022-07-05 18:54:56 +08:00
}
}}>{arr}</Row>
}
}
getTabBtn() {
const {
logViewStore
} = this.props;
const {
form
} = logViewStore;
const btn = [
2022-07-07 18:06:02 +08:00
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@bx87i8`} type="primary" onClick={() => { logViewStore.getTableInfo(); this.setState({ showSearchAd: false }) }}>{i18n.button.search()}</Button>),
2022-07-05 18:54:56 +08:00
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@218ju6`} onClick={() => form.reset()}>{i18n.button.reset()}</Button>),
2022-07-07 18:06:02 +08:00
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@5u9mfz`} onClick={() => this.setState({ showSearchAd: false })}>{i18n.button.cancel()}</Button>),
2022-07-05 18:54:56 +08:00
];
return btn;
}
render() {
const {
visible, onCancel, logViewStore
} = this.props, {
2022-07-07 18:06:02 +08:00
tableStore, conditionNum
2022-07-05 18:54:56 +08:00
} = logViewStore, {
2022-07-07 18:06:02 +08:00
height, dialogTitle, width, showSearchAd, detailDialogTitle, detailVisible,record
2022-07-05 18:54:56 +08:00
} = this.state;
return (
2022-07-07 18:06:02 +08:00
<div>
<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@1txk5f`}
title={dialogTitle}
icon="icon-coms-currency"
iconBgcolor="#217346"
visible={visible}
closable={true}
2023-01-17 09:52:53 +08:00
hasScroll={false}
2022-07-07 18:06:02 +08:00
onCancel={() => onCancel()}
2023-01-17 09:52:53 +08:00
style={{ height: height, width: width}}
initLoadCss
className="logWrapper"
2022-07-07 18:06:02 +08:00
>
<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@9c3zts`}
searchType={['advanced']}
showSearchAd={showSearchAd}
setShowSearchAd={bool => { this.setState({ showSearchAd: bool }) }}
advanceHeight={161}
searchsAd={showSearchAd ? this.getPanelComponents() : <div></div>}
buttonsAd={this.getTabBtn()}
/>
2023-01-17 09:52:53 +08:00
<div style={{"padding":"0 10px 10px 10px"}}>
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@pgmg3x`}
comsWeaTableStore={tableStore}
hasOrder={true}
needScroll={true}
getColumns={c => this.reRenderColumns(c)}
/>
</div>
2022-07-07 18:06:02 +08:00
</WeaDialog>
<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@1txk5f`}
title={detailDialogTitle}
icon="icon-coms-currency"
iconBgcolor="#217346"
visible={detailVisible}
closable={true}
hasScroll={true}
onCancel={() => this.setState({
detailVisible: false
})}
style={{ height: 676, width: 1000 }}
>
<div className='content' style={{ "padding": "20px","height": "100%" }}>
<div style={{ "height": "40%","overflow-x": "auto"}} dangerouslySetInnerHTML={{ __html: record.message }} ></div>
{/* <WeaProgress percent={100} strokeColor="#217346" /> */}
<div style={{"marginTop":"20px","fontSize":"20px","color":"#217346"}}>原始参数查看</div>
<div dangerouslySetInnerHTML={{ __html: record.params_str }} style={{"overflow-x": "auto","height":"50%","marginTop":"20px"}}></div>
</div>
</WeaDialog>
</div>
)
2022-07-05 18:54:56 +08:00
}
}