SlavesInfo.js
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Created by mar105 on 2019-02-13.
*/
/* eslint-disable no-undef,import/first,prefer-destructuring,jsx-a11y/alt-text */
import React, { Component } from 'react';
import { Input } from 'antd-v4';
import * as commonUtils from '../../utils/utils';
import * as commonFunc from './commonFunc'; /* 通用方法 */
import AntdDraggableModal from '../Common/AntdDraggableModal';
const { TextArea } = Input;
export default class SlavesInfo extends Component {
/** 构造函数 */
constructor(props) {
super(props);
// this.handleTextareaChange = this.handleTextareaChange.bind(this);
this.state = { textareaValue: '' };
this.max = 200;
this.min = 0;
}
componentWillReceiveProps(nextProps) {
const { sInfoArr } = nextProps;
/* state和this属性赋值 */
let textareaValue = '';
if (commonUtils.isNotEmptyArr(sInfoArr)) {
sInfoArr.forEach((item) => {
textareaValue += item.sInfo;
});
}
this.setState({ textareaValue });
this.max = commonUtils.convertStrToNumber(commonUtils.isNotEmptyObject(nextProps.sMemoConfig) && commonUtils.isNotEmptyObject(nextProps.sMemoConfig.sMaxValue) ? nextProps.sMemoConfig.sMaxValue : 100); /* 最大值(数据格式:数字) */
this.min = commonUtils.convertStrToNumber(commonUtils.isNotEmptyObject(nextProps.sMemoConfig) && commonUtils.isNotEmptyObject(nextProps.sMemoConfig.sMinValue) ? nextProps.sMemoConfig.sMinValue : 0); /* 最小值(数据格式:数字) */
}
handleOk = () => {
this.props.onSaveState({
bVisiblesInfo: false,
});
};
handleCancel = () => {
this.props.onSaveState({
bVisiblesInfo: false,
});
};
// /* 设置textareaValue */
// handleTextareaChange(e) {
// this.setState({
// textareaValue: e.target.value,
// });
// }
/** 渲染 */
render() {
const { bVisiblesInfo, sInfoArr } = this.props;
const sInfoTitle = commonFunc.showMessage(this.props.app.commonConst, 'sInfo');/* sInfo信息 */
return (
<div>
{
bVisiblesInfo ?
<AntdDraggableModal
width={1200}
zIndex={1000}
title={sInfoTitle}
visible={bVisiblesInfo}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<div>
{commonUtils.isNotEmptyArr(sInfoArr) ? (
<TextArea
value={this.state.textareaValue}
maxLength={this.max}
minLength={this.min}
rows={20}
/>) : null}
</div>
</AntdDraggableModal>
: ''
}
</div>
);
}
}