From d5588c19f73a786cbd0c78e5b53dee0646a439ee Mon Sep 17 00:00:00 2001
From: MustangDeng <670124965@qq.com>
Date: Mon, 18 Apr 2022 15:33:19 +0800
Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pc4mobx/hrmSalary/apis/item.js | 2 +-
.../pages/salaryItem/customSalaryItemSlide.js | 23 ++---
.../pages/salaryItem/formalFormModal.js | 98 ++++++++++++++++---
pc4mobx/hrmSalary/stores/salaryItem.js | 39 +++++++-
4 files changed, 133 insertions(+), 29 deletions(-)
diff --git a/pc4mobx/hrmSalary/apis/item.js b/pc4mobx/hrmSalary/apis/item.js
index 7f3f0fcd..f9b75945 100644
--- a/pc4mobx/hrmSalary/apis/item.js
+++ b/pc4mobx/hrmSalary/apis/item.js
@@ -136,7 +136,7 @@ export const formualSearchField = params => {
// /api/bs/hrmsalary/formula/save
// 保存公式
-export const saveFormual = parmas => {
+export const saveFormual = params => {
return fetch('/api/bs/hrmsalary/formula/save', {
method: 'POST',
mode: 'cors',
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js
index d3d65122..234383ab 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/customSalaryItemSlide.js
@@ -14,12 +14,9 @@ export default class CustomSalaryItemSlide extends React.Component {
formalModalVisible: false
}
}
+
handleChange(params) {
let request = {...this.props.request, ...params}
- this.setState({
- request,
- showForm: e.target.value == 2 ? true: false
- })
this.props.onChange(request)
}
@@ -30,7 +27,7 @@ export default class CustomSalaryItemSlide extends React.Component {
}
render() {
- const { request, editable } = this.props;
+ const { editable, request } = this.props;
const { name, useDefault, useInEmployeeSalary, roundingMode, pattern, valueType, description, dataType } = request;
const { formalModalVisible } = this.state;
return (
@@ -103,27 +100,23 @@ export default class CustomSalaryItemSlide extends React.Component {
取值方式
{
-
- this.handleChange({valueType: e.target.value}, e.target.value)
+ this.handleChange({valueType: e.target.value})
}}>
输入
公式
-
{
- this.state.showForm &&
-
+ valueType == 2 &&
公式
- this.handleShowFormal()}
>
}
-
备注
@@ -137,8 +130,8 @@ export default class CustomSalaryItemSlide extends React.Component {
formalModalVisible &&
this.setState({
+ formalModalVisible: false
})}
/>
}
diff --git a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
index 28670dec..b8433689 100644
--- a/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
+++ b/pc4mobx/hrmSalary/pages/salaryItem/formalFormModal.js
@@ -1,5 +1,5 @@
import React from 'react'
-import {Modal} from 'antd'
+import {Modal, Button, Icon } from 'antd'
import { WeaTextarea } from 'ecCom'
import { inject, observer } from 'mobx-react';
@@ -11,44 +11,118 @@ export default class FormalFormModal extends React.Component {
this.state = {
value: ''
}
+ this.group = {};
+ this.field = {};
+ this.parameters = []
}
+
componentWillMount() {
const { salaryItemStore } = this.props;
- const { salaryAcctImportTemplateParam } = salaryItemStore;
+ const { salaryAcctImportTemplateParam, setSearchFields } = salaryItemStore;
salaryAcctImportTemplateParam();
+ setSearchFields([])
}
// 多行文本编辑
handleChange(value) {
this.setState({
value
})
+
}
+ // 分组项被点击
+ handleItemClick(item) {
+ const { salaryItemStore } = this.props;
+ const { formualSearchField } = salaryItemStore;
+ this.group = item;
+ formualSearchField(item.key)
+ }
+
+ // 保存
+ handleSave() {
+ const { salaryItemStore } = this.props;
+ const { saveFormual } = salaryItemStore
+ let params = {
+ name:'公式1',
+ description:'备注',
+ module:'salary',
+ useFor:'salaryitem',
+ referenceType:'',
+ returnType:'number',
+ validateType:'number',
+ extendParam:'{}',
+ formula: this.state.value,
+ parameters: this.parameters
+ }
+ saveFormual(params)
+ }
+
+ // 字段点击回调
+ handleFieldClick(item) {
+ this.field = item;
+ let fieldName = "{"+this.group.value+"."+this.field.name+"}"
+
+ let parameterItem = {
+ name: item.name,
+ fieldId: item.fieldId,
+ fieldName: fieldName,
+ fieldType: item.fieldType,
+ source: item.source,
+ orderIndex: this.parameters.length
+ }
+ this.parameters.push(parameterItem)
+ this.setState({
+ value: this.state.value + fieldName
+ })
+ }
+
render() {
const {salaryItemStore} = this.props;
- const { searchGroup } = salaryItemStore
+ const { searchGroup, searchFields } = salaryItemStore
const { value } = this.state;
return (
- {this.props.onCancel()}}>
+ {this.handleSave()}}>保存
+ }
+ onCancel={() => {this.props.onCancel()}}>
-
+ this.handleChange(value)}
+ noResize={true}
+ style={{fontSize: "14px", lineHeight: 1.2}}
+ />
-
-
+
+
-
变量
+
变量
{
- searchGroup.map(item => {
- return
+ searchGroup && searchGroup.map(item => {
+ return
{this.handleItemClick(item)}}>
{item.value}
+
+ {item.value} 的字段
})
}
-
-
+
+ {
+ searchFields && searchFields.map(item => {
+ return (
+
{this.handleFieldClick(item)}}>
+ {item.name}
+
+
+ )
+ })
+ }
diff --git a/pc4mobx/hrmSalary/stores/salaryItem.js b/pc4mobx/hrmSalary/stores/salaryItem.js
index 910fa8a2..32d44c51 100644
--- a/pc4mobx/hrmSalary/stores/salaryItem.js
+++ b/pc4mobx/hrmSalary/stores/salaryItem.js
@@ -33,7 +33,20 @@ export class SalaryItemStore {
@observable tableDataSource = []; // 主列表
@observable tableColumns = []; // 主列表列
- @observable searchGroup = []
+
+ // ** 公式 **
+ // 类型列表
+ @observable searchGroup = [];
+ // 字段列表
+ @observable searchFields = [];
+
+
+
+ // 设置字段列表
+ @action
+ setSearchFields = (searchFields) => {
+ this.searchFields = searchFields
+ }
@action
@@ -248,4 +261,28 @@ export class SalaryItemStore {
}
})
}
+
+ // 获取公式变量字段
+ @action
+ formualSearchField = (sourceId) => {
+ API.formualSearchField({sourceId}).then(res => {
+ if(res.status) {
+ this.searchFields = res.data
+ } else {
+ message.error(res.errormsg || "获取失败")
+ }
+ })
+ }
+
+ // 保存公式
+ @action
+ saveFormual = (params) => {
+ API.saveFormual(params).then(res => {
+ if(res.status) {
+ message.success("保存成功");
+ } else {
+ message.error(res.errormsg || "保存失败");
+ }
+ })
+ }
}
\ No newline at end of file