From f0139232855bb2926d4f395bf44abbbce8f22360 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Tue, 3 Jan 2023 10:36:13 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE?=
=?UTF-8?q?=E5=85=AC=E5=BC=8F=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js | 8 ++++++--
pc4mobx/hrmSalary/pages/salaryItem/index.less | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
index bfad58ff..a7e697af 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
@@ -64,7 +64,7 @@ export default class FormalFormModal extends React.Component {
let groupParams = {};
if (this.referenceType == "sql") {
groupParams = { "referenceType": "sql" };
- }else{
+ } else {
groupParams = this.props.backCalcType === "issuedItems" ? { "referenceType": "backCalc" } : {};
}
salaryAcctImportTemplateParam(groupParams);
@@ -257,9 +257,13 @@ export default class FormalFormModal extends React.Component {
const { salaryItemStore } = this.props;
const { searchGroup, searchFields } = salaryItemStore;
const { value, formulaDatasourceList, extendParam } = this.state;
+ const title =
+
{`${(this.props.valueType == 2 || this.props.valueType === "FORMULA") ? "函数" : "SQL"}公式`}
+
+
;
return (
Date: Wed, 4 Jan 2023 09:46:20 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pages/salaryItem/formalFormModal.js | 12 +++-
pc4mobx/hrmSalary/pages/salaryItem/index.less | 31 +++++++++-
.../hrmSalary/pages/salaryItem/testModal.js | 58 +++++++++++++++++++
3 files changed, 95 insertions(+), 6 deletions(-)
create mode 100644 pc4mobx/hrmSalary/pages/salaryItem/testModal.js
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
index a7e697af..e86155d5 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
@@ -3,6 +3,7 @@ import { Button, Col, Icon, Modal, Row } from "antd";
import { WeaCheckbox, WeaDialog, WeaFormItem, WeaHelpfulTip, WeaInput, WeaSelect, WeaTextarea } from "ecCom";
import { inject, observer } from "mobx-react";
import "./index.less";
+import TestModal from "./testModal";
@inject("salaryItemStore")
@observer
@@ -21,7 +22,8 @@ export default class FormalFormModal extends React.Component {
}
},
returnValue: "",
- formulaDatasourceList: []
+ formulaDatasourceList: [],
+ testVisible: false
};
this.group = {};
this.field = {};
@@ -256,10 +258,14 @@ export default class FormalFormModal extends React.Component {
render() {
const { salaryItemStore } = this.props;
const { searchGroup, searchFields } = salaryItemStore;
- const { value, formulaDatasourceList, extendParam } = this.state;
+ const { value, formulaDatasourceList, extendParam, testVisible } = this.state;
const title =
{`${(this.props.valueType == 2 || this.props.valueType === "FORMULA") ? "函数" : "SQL"}公式`}
-
+ {
+ value &&
+ }
+ {/*公式测试*/}
+
this.setState({ testVisible: false })}/>
;
return (
!!s)
+ });
+ }
+ }
+
+ render() {
+ const { visible, onCancel, testParams } = this.props;
+ const { showResults, testValue } = this.state;
+ return (
+ {
+ }}> 执行
+ ]}>
+
+
+
+
+
+
+
+ );
+ }
+}
+
+const TestTip = () => {
+ return
+
涉及到选择具体数据进行运算时,请先检查对应数据源中是否有数据项;
+
涉及到日期控件时,请先选择日期控件的格式,保持和控件本身设置的格式一致,否则可能会导致预期与实际执行结果不一致;
+
涉及到日期控件判断与预期不符合时,请先检查日期控件的格式是否与等号右边的格式保持一致;
+
;
+};
From 77b1ae17ed933c9632595989daa318b1401adc7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com>
Date: Wed, 4 Jan 2023 11:19:22 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E8=96=AA=E8=B5=84=E9=A1=B9=E7=9B=AE?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pc4mobx/hrmSalary/apis/item.js | 11 +++
.../pages/salaryItem/formalFormModal.js | 82 ++++++++++++++++---
.../hrmSalary/pages/salaryItem/testModal.js | 52 ++++++++++--
3 files changed, 127 insertions(+), 18 deletions(-)
diff --git a/pc4mobx/hrmSalary/apis/item.js b/pc4mobx/hrmSalary/apis/item.js
index 5ad36dbc..ca3c269b 100644
--- a/pc4mobx/hrmSalary/apis/item.js
+++ b/pc4mobx/hrmSalary/apis/item.js
@@ -144,6 +144,17 @@ export const saveFormual = params => {
body: JSON.stringify(params)
}).then(res => res.json())
}
+// 公式测试
+export const testFormual = params => {
+ return fetch('/api/bs/hrmsalary/formula/mock', {
+ method: 'POST',
+ mode: 'cors',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(params)
+ }).then(res => res.json())
+}
// 根据id获取formual
export const detailFormual = params => {
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
index e86155d5..d0d52100 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
@@ -1,9 +1,10 @@
import React from "react";
-import { Button, Col, Icon, Modal, Row } from "antd";
+import { Button, Col, Icon, message, Modal, Row } from "antd";
import { WeaCheckbox, WeaDialog, WeaFormItem, WeaHelpfulTip, WeaInput, WeaSelect, WeaTextarea } from "ecCom";
import { inject, observer } from "mobx-react";
-import "./index.less";
+import { testFormual } from "../../apis/item";
import TestModal from "./testModal";
+import "./index.less";
@inject("salaryItemStore")
@observer
@@ -23,7 +24,8 @@ export default class FormalFormModal extends React.Component {
},
returnValue: "",
formulaDatasourceList: [],
- testVisible: false
+ testVisible: false,
+ showTestVal: ""
};
this.group = {};
this.field = {};
@@ -176,7 +178,7 @@ export default class FormalFormModal extends React.Component {
}
// 保存
- handleSave() {
+ handleSave = () => {
const { salaryItemStore } = this.props;
const { saveFormual } = salaryItemStore;
this.parameters = this.parameters.filter(item => this.state.value.indexOf(item.name) > -1);
@@ -210,7 +212,7 @@ export default class FormalFormModal extends React.Component {
this.props.onSaveFormal(data);
this.props.onCancel();
});
- }
+ };
/**
* name: 获取文本框光标位置
@@ -255,17 +257,79 @@ export default class FormalFormModal extends React.Component {
let position = this.insertText(propsTextarea, fieldName); // 光标的位置
}
+ handleChangeTestValue = (record, value) => {
+ if (!record && !value) {
+ this.parameters = _.map(this.parameters, item => ({ ...item, content: null }));
+ this.setState({
+ showTestVal: "显示结果"
+ });
+ } else {
+ this.parameters = _.map(this.parameters, item => {
+ if (item.id === record.id) {
+ return {
+ ...item,
+ content: value
+ };
+ }
+ return { ...item };
+ });
+ }
+ this.forceUpdate();
+ };
+ handleImplement = () => {
+ this.parameters = this.parameters.filter(item => this.state.value.indexOf(item.name) > -1);
+ let result = [];
+ this.parameters.map(item => {
+ let flag = false;
+ result.map(i => {
+ if (item.fieldId == i.fieldId) {
+ flag = true;
+ }
+ });
+ if (!flag) {
+ result.push(item);
+ }
+ });
+ this.parameters = result;
+ let params = {
+ name: "公式1",
+ description: "备注",
+ module: "salary",
+ useFor: "salaryitem",
+ returnType: this.props.dataType || this.state.returnType,
+ validateType: this.props.dataType || this.state.returnType,
+ extendParam: JSON.stringify(this.state.extendParam),
+ formula: this.state.value,
+ parameters: this.parameters,
+ referenceType: this.referenceType == "" ? this.props.valueType == "2" ? "formula" : this.props.valueType == "3" ? "sql" : "" : this.referenceType
+ };
+ testFormual(params).then(({ status, data, errormsg }) => {
+ if (status) {
+ message.success("测试结果已更新");
+ this.setState({
+ showTestVal: data
+ });
+ } else {
+ message.error(errormsg || "");
+ }
+ });
+ };
+
render() {
const { salaryItemStore } = this.props;
const { searchGroup, searchFields } = salaryItemStore;
- const { value, formulaDatasourceList, extendParam, testVisible } = this.state;
+ const { value, formulaDatasourceList, extendParam, testVisible, showTestVal } = this.state;
const title =
{`${(this.props.valueType == 2 || this.props.valueType === "FORMULA") ? "函数" : "SQL"}公式`}
{
value &&
}
{/*公式测试*/}
-
this.setState({ testVisible: false })}/>
+ this.setState({ testVisible: false }, () => this.handleChangeTestValue())}/>
;
return (
{
- this.handleSave();
- }}>保存
+
]}
className="formula-wrapper"
initLoadCss
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/testModal.js b/pc4mobx/hrmSalary/pages/salaryItem/testModal.js
index 84b494ab..b53a6d55 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/testModal.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/testModal.js
@@ -1,6 +1,6 @@
import React from "react";
import { Button } from "antd";
-import { WeaDialog, WeaSearchGroup, WeaTextarea } from "ecCom";
+import { WeaDialog, WeaInput, WeaSearchGroup, WeaTable, WeaTextarea } from "ecCom";
import { inject, observer } from "mobx-react";
import "./index.less";
@@ -16,16 +16,53 @@ export default class TestModal extends React.Component {
}
componentWillReceiveProps(nextProps, nextContext) {
- if (nextProps.testParams !== this.props.testParams && nextProps.testParams) {
+ if (nextProps.parameters !== this.props.parameters && nextProps.parameters) {
this.setState({
- testValue: nextProps.testParams.split(/({.*?})/).filter(s => !!s)
+ testValue: nextProps.parameters
+ });
+ }
+ if (nextProps.showTestVal !== this.props.showTestVal && nextProps.showTestVal) {
+ this.setState({
+ showResults: nextProps.showTestVal
});
}
}
+ 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 (
+ onChangeTestValue(record, val)}
+ />
+ );
+ }
+ }
+ ];
+ return ;
+ };
render() {
- const { visible, onCancel, testParams } = this.props;
- const { showResults, testValue } = this.state;
+ const { visible, onCancel, testParams, onImplement } = this.props;
+ const { showResults } = this.state;
return (
{
- }}> 执行
+
]}>
-
+ {this.renderInputItem()}