From 6aa662d432e429669cf52cf38ce0a9d5e1dd7e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Fri, 11 Oct 2024 10:01:46 +0800 Subject: [PATCH] =?UTF-8?q?feature/2.15.1.2407.01-=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/salary/components/constants.js | 137 +++++++++++++++-- .../salary/components/personalScopeModal.js | 142 ++++++++++-------- 2 files changed, 202 insertions(+), 77 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/salary/components/constants.js b/pc4mobx/hrmSalary/pages/salary/components/constants.js index b457ae44..ac81a719 100644 --- a/pc4mobx/hrmSalary/pages/salary/components/constants.js +++ b/pc4mobx/hrmSalary/pages/salary/components/constants.js @@ -302,20 +302,9 @@ export const personScopeConditions = [ lanId: 111, labelcol: 6, options: [], - rules: "required|string", - selectLinkageDatas: { - EMPLOYEE: { - conditionType: "TEXTAREA", - domkey: ["target"], - fieldcol: 24, - label: "", - labelcol: 0, - value: "", - rules: "required|string", - viewAttr: 3 - } - }, - viewAttr: 3 + viewAttr: 3, + rules: "selectLinkageRequired", + selectLinkageDatas: {} }, { conditionType: "SELECT", @@ -326,10 +315,126 @@ export const personScopeConditions = [ labelcol: 6, value: "", detailtype: "2", - rules: "required|string", + rules: "required", viewAttr: 3 - } + }, ], defaultshow: true } ]; +export const scopeSelectLinkageDatas = { + EMPLOYEE:{ + browserConditionParam: { + completeParams: {}, + dataParams: {}, + hasAddBtn: false, + hasAdvanceSerach: true, + isAutoComplete: 1, + isDetail: 0, + isMultCheckbox: false, + isSingle: false, + pageSize: 10, + linkUrl: "", + type: "17", + viewAttr: 3, + rules:'required', + title: "" + }, + conditionType: "BROWSER", + domkey: ["target"], + fieldcol: 24, + label: "", + labelcol: 0, + value: "", + rules: "required", + viewAttr: 3 + }, + DEPT:{ + browserConditionParam: { + completeParams: {}, + dataParams: {}, + hasAddBtn: false, + hasAdvanceSerach: true, + isAutoComplete: 1, + isDetail: 0, + isMultCheckbox: false, + isSingle: false, + pageSize: 10, + linkUrl: "", + type: "57", + viewAttr: 3, + rules:'required', + title: "" + }, + conditionType: "BROWSER", + domkey: ["target"], + fieldcol: 24, + label: "", + labelcol: 0, + value: "", + rules: "required", + viewAttr: 3 + }, + SUBCOMPANY:{ + browserConditionParam: { + completeParams: {}, + dataParams: {}, + hasAddBtn: false, + hasAdvanceSerach: true, + isAutoComplete: 1, + isDetail: 0, + isMultCheckbox: false, + isSingle: false, + pageSize: 10, + linkUrl: "", + type: "164", + viewAttr: 3, + rules:'required', + title: "" + }, + conditionType: "BROWSER", + domkey: ["target"], + fieldcol: 24, + label: "", + labelcol: 0, + value: "", + rules: "required", + viewAttr: 3 + }, + POSITION:{ + browserConditionParam: { + completeParams: {}, + dataParams: {}, + hasAddBtn: false, + hasAdvanceSerach: true, + isAutoComplete: 1, + isDetail: 0, + isMultCheckbox: false, + isSingle: false, + pageSize: 10, + linkUrl: "", + type: "278", + viewAttr: 3, + rules:'required', + title: "" + }, + conditionType: "BROWSER", + domkey: ["target"], + fieldcol: 24, + label: "", + labelcol: 0, + value: "", + rules: "required", + viewAttr: 3 + }, + SQL: { + conditionType: "TEXTAREA", + domkey: ["target"], + fieldcol: 24, + label: "", + labelcol: 0, + value: "", + rules: "required", + viewAttr: 3 + } +}; diff --git a/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js b/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js index f8aced8d..9ad50c15 100644 --- a/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js +++ b/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js @@ -6,11 +6,11 @@ */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; -import { WeaBrowser, WeaDialog, WeaLocaleProvider, WeaTools } from "ecCom"; +import { WeaSwitch } from "comsMobx"; +import { WeaBrowser, WeaCheckbox, WeaDialog, WeaFormItem, WeaLocaleProvider, WeaSearchGroup, WeaTools } from "ecCom"; import { Button, message, Modal } from "antd"; import { getTaxAgentRangeForm, taxAgentRangeSave } from "../../../apis/taxAgent"; -import { personScopeConditions } from "./constants"; -import { getSearchs } from "../../../util"; +import { personScopeConditions, scopeSelectLinkageDatas } from "./constants"; const getKey = WeaTools.getKey; const getLabel = WeaLocaleProvider.getLabel; @@ -33,9 +33,7 @@ class PersonalScopeModal extends Component { componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) this.getTaxAgentRangeForm(); - if (nextProps.visible !== this.props.visible && !nextProps.visible) { - this.props.taxAgentStore.initPersonScopeForm(); - } + if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.taxAgentStore.initPersonScopeForm(); } componentDidMount() { @@ -52,15 +50,13 @@ class PersonalScopeModal extends Component { if (getKey(o) === "employeeStatus") { return { ...o, label: getLabel(o.lanId, o.label), - options: [ - { key: "ALL", showname: getLabel(111, "全选") }, - ..._.map(employeeStatus, it => ({ key: it.id, showname: it.name })) - ] + options: _.map(employeeStatus, it => ({ key: it.id, showname: it.name })) }; } return { ...o, label: getLabel(o.lanId, o.label), - options: _.map(targetTypeList, it => ({ key: it.id, showname: it.name })) + options: _.map(targetTypeList, it => ({ key: it.id, showname: it.name })), + selectLinkageDatas: scopeSelectLinkageDatas[_.head(targetTypeList).id] }; }) })) @@ -69,33 +65,44 @@ class PersonalScopeModal extends Component { }); }; taxAgentRangeSave = () => { - const { status, targetTypeIds, targetType } = this.state; - const { includeType, taxAgentId, onSuccess, onCancel } = this.props; - if (_.isEmpty(status) || _.isEmpty(targetTypeIds)) { - Modal.warning({ - title: "信息确认", - content: "必要信息不完整,红色*为必填项!" - }); - return; - } - const payload = { - employeeStatus: status.split(","), - includeType, - targetParams: _.map(targetTypeIds.split(","), it => ({ targetType, targetId: it })), - taxAgentId - }; - this.setState({ loading: true }); - taxAgentRangeSave(payload).then(({ status, errormsg }) => { - this.setState({ loading: false }); - if (status) { - message.success("保存成功"); - this.handleReset(); - onSuccess(); - onCancel(); + const { taxAgentStore: { personScopeForm } } = this.props; + personScopeForm.validateForm().then(f => { + if (f.isValid) { + console.log(70, personScopeForm.getFormParams()); + + + const { status, targetTypeIds, targetType } = this.state; + const { includeType, taxAgentId, onSuccess, onCancel } = this.props; + if (_.isEmpty(status) || _.isEmpty(targetTypeIds)) { + Modal.warning({ + title: "信息确认", + content: "必要信息不完整,红色*为必填项!" + }); + return; + } + const payload = { + employeeStatus: status.split(","), + includeType, + targetParams: _.map(targetTypeIds.split(","), it => ({ targetType, targetId: it })), + taxAgentId + }; + this.setState({ loading: true }); + taxAgentRangeSave(payload).then(({ status, errormsg }) => { + this.setState({ loading: false }); + if (status) { + message.success("保存成功"); + this.handleReset(); + onSuccess(); + onCancel(); + } else { + message.error(errormsg || "保存失败"); + } + }).catch(() => this.setState({ loading: true })); } else { - message.error(errormsg || "保存失败"); + f.showErrors(); + this.forceUpdate(); } - }).catch(() => this.setState({ loading: true })); + }); }; renderBrowser = () => { const { targetType, targetTypeIds, targetTypeIdsNames } = this.state; @@ -128,27 +135,44 @@ class PersonalScopeModal extends Component { }} />; }; + renderForm = () => { + const { taxAgentStore: { personScopeForm } } = this.props; + const { conditions, employeeStatus } = this.state, { isFormInit } = personScopeForm, + formParams = personScopeForm.getFormParams(); + const checked = formParams.employeeStatus && _.every(_.map(employeeStatus, o => o.id), k => formParams.employeeStatus.indexOf(k) !== -1); + let group = []; + isFormInit && conditions.map(c => { + let items = []; + c.items.map(fields => { + items.push({ + com: ( + + { + getKey(fields) === "employeeStatus" && + + } + + ), + hide: fields.hide + }); + }); + group.push(); + }); + return group; + }; + handleChangeAll = (val) => { + const { taxAgentStore: { personScopeForm } } = this.props, { employeeStatus } = this.state; + val === "1" ? personScopeForm.updateFields({ employeeStatus: { value: _.map(employeeStatus, o => o.id).join(",") } }) : + personScopeForm.updateFields({ employeeStatus: { value: "" } }); + }; handleChange = (params) => { const { taxAgentStore: { personScopeForm } } = this.props, { employeeStatus } = this.state; const key = _.keys(params)[0], value = params[key].value; - if ( - (key === "employeeStatus" && value.indexOf("ALL") !== -1) - // (key === "employeeStatus" && value.indexOf("ALL") === -1 && _.every(employeeStatus, o => value.indexOf(o.id) !== -1)) - ) { - personScopeForm.updateFields({ [key]: { value: "ALL," + _.map(employeeStatus, o => o.id).join(",") } }); - } else if (key === "employeeStatus" && value.indexOf("ALL") === -1) { - console.log(1) - // personScopeForm.updateFields({ [key]: { value: "" } }); - } - console.log(params); - }; - handleReset = () => { - this.setState({ - targetType: "EMPLOYEE", - targetTypeIds: "", - status: "", - statusAll: "" - }); + console.log(params, key, value); }; render() { @@ -156,15 +180,11 @@ class PersonalScopeModal extends Component { const { employeeStatus, targetTypeList, targetType, status, statusAll, loading, conditions } = this.state; const buttons = [ 确定, - 重置 + personScopeForm.renderForm()}>重置 ]; return ( - { - this.handleReset(); - onCancel(); - }}> - {getSearchs(personScopeForm, conditions, 1, false, this.handleChange)} + + {this.renderForm()} {/**/} {/*