salary-management-front/pc4mobx/hrmSalary/pages/salaryItem/testModal.js

96 lines
2.9 KiB
JavaScript
Raw Normal View History

2023-01-04 09:46:20 +08:00
import React from "react";
import { Button } from "antd";
2023-01-04 11:19:22 +08:00
import { WeaDialog, WeaInput, WeaSearchGroup, WeaTable, WeaTextarea } from "ecCom";
2023-01-04 09:46:20 +08:00
import { inject, observer } from "mobx-react";
import "./index.less";
@inject("ledgerStore")
@observer
export default class TestModal extends React.Component {
constructor(props) {
super(props);
this.state = {
testValue: [],
showResults: "显示结果"
};
}
componentWillReceiveProps(nextProps, nextContext) {
2023-01-04 11:39:00 +08:00
if (nextProps.parameters) {
2023-01-04 09:46:20 +08:00
this.setState({
2023-01-04 11:19:22 +08:00
testValue: nextProps.parameters
});
}
2023-03-01 09:05:57 +08:00
if (nextProps.showTestVal !== this.props.showTestVal && !_.isNil(nextProps.showTestVal)) {
2023-01-04 11:19:22 +08:00
this.setState({
showResults: nextProps.showTestVal
2023-01-04 09:46:20 +08:00
});
}
}
2023-01-04 11:39:00 +08:00
2023-01-04 11:19:22 +08:00
renderInputItem = () => {
const { onChangeTestValue } = this.props;
const { testValue } = this.state;
const dataSource = !_.isEmpty(testValue) ? _.map(testValue, item => {
return {
...item,
paramsName: item.fieldName.replace(/[{}]/g, "")
};
}) : [];
const columns = [
{
dataIndex: "paramsName", title: "参数名"
},
{
dataIndex: "content", title: "测试值",
render: (text, record) => {
return (
<WeaInput
value={record.content}
onChange={(val) => onChangeTestValue(record, val)}
/>
);
}
}
];
return <WeaTable
rowKey="id"
dataSource={dataSource}
pagination={false}
columns={columns}
/>;
};
2023-01-04 09:46:20 +08:00
render() {
2023-01-04 11:19:22 +08:00
const { visible, onCancel, testParams, onImplement } = this.props;
const { showResults } = this.state;
2023-01-04 09:46:20 +08:00
return (
<WeaDialog
visible={visible}
onCancel={onCancel}
initLoadCss
className="testModalWrapper"
style={{ width: 800 }}
title="公式测试"
buttons={[
2023-01-04 11:19:22 +08:00
<Button type="primary" onClick={onImplement}>执行</Button>
2023-01-04 09:46:20 +08:00
]}>
<div className="testContent">
<WeaSearchGroup title="" showGroup><WeaTextarea viewAttr={1} value={testParams}/></WeaSearchGroup>
2023-01-04 11:19:22 +08:00
<WeaSearchGroup title="输入参数测试值" showGroup>{this.renderInputItem()}</WeaSearchGroup>
2023-01-04 09:46:20 +08:00
<WeaSearchGroup title="测试结果" showGroup><WeaTextarea viewAttr={1} value={showResults}/></WeaSearchGroup>
<TestTip/>
</div>
</WeaDialog>
);
}
}
const TestTip = () => {
return <div className="testTipWrapper">
<div>涉及到选择具体数据进行运算时请先检查对应数据源中是否有数据项</div>
<div>涉及到日期控件时请先选择日期控件的格式保持和控件本身设置的格式一致否则可能会导致预期与实际执行结果不一致</div>
<div>涉及到日期控件判断与预期不符合时请先检查日期控件的格式是否与等号右边的格式保持一致</div>
</div>;
};