From 88bf00cc8d5cec794617bae8c5ca324abff4a60d Mon Sep 17 00:00:00 2001 From: liyongshun <971387674@qq.com> Date: Wed, 8 Jun 2022 09:44:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=BC=96=E5=8F=B7=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/numberSet.js | 41 ++++++++++++++++++- .../components/numberComposition.js | 2 +- .../branchNumSetting/components/preview.js | 0 .../components/startNumberSetting.js | 0 .../components/startReservedNumberSet.js | 2 +- .../branchNumSetting/index.js | 2 +- .../branchNumSetting/index.less | 0 .../deptNumberSet/index.js | 4 +- .../postNumberSet/index.js | 4 +- .../resourceNumberSet/index.js | 4 +- pc4mobx/organization/index.js | 8 ++-- 11 files changed, 53 insertions(+), 14 deletions(-) rename pc4mobx/organization/components/{ => numberSetting}/branchNumSetting/components/numberComposition.js (99%) rename pc4mobx/organization/components/{ => numberSetting}/branchNumSetting/components/preview.js (100%) rename pc4mobx/organization/components/{ => numberSetting}/branchNumSetting/components/startNumberSetting.js (100%) rename pc4mobx/organization/components/{ => numberSetting}/branchNumSetting/components/startReservedNumberSet.js (98%) rename pc4mobx/organization/components/{ => numberSetting}/branchNumSetting/index.js (99%) rename pc4mobx/organization/components/{ => numberSetting}/branchNumSetting/index.less (100%) rename pc4mobx/organization/components/{ => numberSetting}/deptNumberSet/index.js (99%) rename pc4mobx/organization/components/{ => numberSetting}/postNumberSet/index.js (99%) rename pc4mobx/organization/components/{ => numberSetting}/resourceNumberSet/index.js (99%) diff --git a/pc4mobx/organization/apis/numberSet.js b/pc4mobx/organization/apis/numberSet.js index d300660..f3820f6 100644 --- a/pc4mobx/organization/apis/numberSet.js +++ b/pc4mobx/organization/apis/numberSet.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: * Date: 2022-06-07 09:52:01 - * LastEditTime: 2022-06-07 17:00:34 + * LastEditTime: 2022-06-08 09:37:41 */ import { WeaTools } from "ecCom"; @@ -48,3 +48,42 @@ export const getStartNumForm = (params) => { params ); }; + +/** + * name: 高级搜索条件 + * param {*} params + * return {*} + */ +export const getAdvanceSearchCondition = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/getAdvanceSearchCondition", + "GET", + params + ); +}; + +/** + * name: 预留编号设置列表查询 + * param {*} params + * return {*} + */ +export const getSearchReservedCodeList = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/getSearchReservedCodeList", + "POST", + params + ); +}; + +/** + * name: 新增预留编号表单查询 + * param {*} params + * return {*} + */ +export const getReservedCodeFrom = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/getReservedCodeFrom", + "GET", + params + ); +}; diff --git a/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js similarity index 99% rename from pc4mobx/organization/components/branchNumSetting/components/numberComposition.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js index 4bf954b..f7b1f2a 100644 --- a/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js @@ -16,7 +16,7 @@ import { WeaInputNumber, } from "ecCom"; import Preview from "./preview"; -import { i18n } from "../../../public/i18n"; +import { i18n } from "../../../../public/i18n"; import _ from "lodash"; import "../index.less"; diff --git a/pc4mobx/organization/components/branchNumSetting/components/preview.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js similarity index 100% rename from pc4mobx/organization/components/branchNumSetting/components/preview.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js diff --git a/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js similarity index 100% rename from pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js diff --git a/pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js similarity index 98% rename from pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js index b39d4a0..762dc6d 100644 --- a/pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js @@ -8,7 +8,7 @@ import React, { Component, Fragment } from "react"; import { Button, Modal } from "antd"; import StartNumberSetting from "./startNumberSetting"; import { WeaFormItem, WeaDialog, WeaMoreButton } from "ecCom"; -import { i18n } from "../../../public/i18n"; +import { i18n } from "../../../../public/i18n"; class StartReservedNumberSet extends Component { constructor() { diff --git a/pc4mobx/organization/components/branchNumSetting/index.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js similarity index 99% rename from pc4mobx/organization/components/branchNumSetting/index.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/index.js index e8743e7..344521c 100644 --- a/pc4mobx/organization/components/branchNumSetting/index.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js @@ -17,7 +17,7 @@ import { } from "ecCom"; import StartReservedNumberSet from "./components/startReservedNumberSet"; import NumberComposition from "./components/numberComposition"; -import { i18n } from "../../public/i18n"; +import { i18n } from "../../../public/i18n"; import moment from "moment"; import "./index.less"; diff --git a/pc4mobx/organization/components/branchNumSetting/index.less b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.less similarity index 100% rename from pc4mobx/organization/components/branchNumSetting/index.less rename to pc4mobx/organization/components/numberSetting/branchNumSetting/index.less diff --git a/pc4mobx/organization/components/deptNumberSet/index.js b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js similarity index 99% rename from pc4mobx/organization/components/deptNumberSet/index.js rename to pc4mobx/organization/components/numberSetting/deptNumberSet/index.js index 4a384a2..44bc55b 100644 --- a/pc4mobx/organization/components/deptNumberSet/index.js +++ b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 部门编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-07 17:44:30 + * LastEditTime: 2022-06-08 09:32:09 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -17,7 +17,7 @@ import { } from "ecCom"; import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; import NumberComposition from "../branchNumSetting/components/numberComposition"; -import { i18n } from "../../public/i18n"; +import { i18n } from "../../../public/i18n"; import moment from 'moment'; import "../branchNumSetting/index.less"; diff --git a/pc4mobx/organization/components/postNumberSet/index.js b/pc4mobx/organization/components/numberSetting/postNumberSet/index.js similarity index 99% rename from pc4mobx/organization/components/postNumberSet/index.js rename to pc4mobx/organization/components/numberSetting/postNumberSet/index.js index 9164bb2..4f66049 100644 --- a/pc4mobx/organization/components/postNumberSet/index.js +++ b/pc4mobx/organization/components/numberSetting/postNumberSet/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 岗位编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-07 17:49:19 + * LastEditTime: 2022-06-08 09:32:24 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -17,7 +17,7 @@ import { } from "ecCom"; import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; import NumberComposition from "../branchNumSetting/components/numberComposition"; -import { i18n } from "../../public/i18n"; +import { i18n } from "../../../public/i18n"; import moment from "moment"; import "../branchNumSetting/index.less"; diff --git a/pc4mobx/organization/components/resourceNumberSet/index.js b/pc4mobx/organization/components/numberSetting/resourceNumberSet/index.js similarity index 99% rename from pc4mobx/organization/components/resourceNumberSet/index.js rename to pc4mobx/organization/components/numberSetting/resourceNumberSet/index.js index 702528b..1505038 100644 --- a/pc4mobx/organization/components/resourceNumberSet/index.js +++ b/pc4mobx/organization/components/numberSetting/resourceNumberSet/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 岗位编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-07 17:56:42 + * LastEditTime: 2022-06-08 09:32:33 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -17,7 +17,7 @@ import { } from "ecCom"; import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; import NumberComposition from "../branchNumSetting/components/numberComposition"; -import { i18n } from "../../public/i18n"; +import { i18n } from "../../../public/i18n"; import moment from "moment"; import "../branchNumSetting/index.less"; diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index f234ebc..4b1308e 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -11,10 +11,10 @@ import Sequence from "./components/sequence/Sequence"; import Group from "./components/group/Group"; import OfficeManage from "./components/office/officeManage"; import CompanyExtend from "./components/company/CompanyExtend"; -import BranchNumSetting from "./components/branchNumSetting"; -import DeptNumberSet from "./components/deptNumberSet"; -import PostNumberSet from "./components/postNumberSet"; -import ResourceNumberSet from "./components/resourceNumberSet"; +import BranchNumSetting from "./components/numberSetting/branchNumSetting"; +import DeptNumberSet from "./components/numberSetting/deptNumberSet"; +import PostNumberSet from "./components/numberSetting/postNumberSet"; +import ResourceNumberSet from "./components/numberSetting/resourceNumberSet"; import Company from "./components/company/company"; import DepartmentManage from "./components/department/department"; import StaffScheme from "./components/staff/StaffScheme"; From 938e17aaadf377a1c21781b71adf84ba943f40c0 Mon Sep 17 00:00:00 2001 From: liyongshun <971387674@qq.com> Date: Thu, 9 Jun 2022 16:51:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BC=96=E5=8F=B7?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/numberSet.js | 28 +- .../components/numberComposition.js | 10 +- .../branchNumSetting/components/preview.js | 7 +- .../components/reservedNumberSetting.js | 406 ++++++++++++++++++ .../components/startNumberSetting.js | 8 +- .../components/startReservedNumberSet.js | 48 ++- .../numberSetting/branchNumSetting/index.js | 163 +++++-- .../numberSetting/deptNumberSet/index.js | 163 +++++-- .../numberSetting/postNumberSet/index.js | 160 +++++-- .../numberSetting/resourceNumberSet/index.js | 162 +++++-- .../components/office/officeManage.js | 16 +- pc4mobx/organization/stores/numberSet.js | 75 +++- 12 files changed, 1034 insertions(+), 212 deletions(-) create mode 100644 pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js diff --git a/pc4mobx/organization/apis/numberSet.js b/pc4mobx/organization/apis/numberSet.js index f3820f6..19f2571 100644 --- a/pc4mobx/organization/apis/numberSet.js +++ b/pc4mobx/organization/apis/numberSet.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: * Date: 2022-06-07 09:52:01 - * LastEditTime: 2022-06-08 09:37:41 + * LastEditTime: 2022-06-08 14:57:56 */ import { WeaTools } from "ecCom"; @@ -75,6 +75,19 @@ export const getSearchReservedCodeList = (params) => { ); }; +/** + * name: 保存预留编号设置 + * param {*} params + * return {*} + */ +export const saveReservedCode = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/saveReservedCode", + "POST", + params + ); +}; + /** * name: 新增预留编号表单查询 * param {*} params @@ -87,3 +100,16 @@ export const getReservedCodeFrom = (params) => { params ); }; + +/** + * name: 删除预留编号 + * param {*} params + * return {*} + */ +export const deleteReservedCodeById = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/deleteReservedCodeById", + "POST", + params + ); +}; diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js index f7b1f2a..277a215 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: * Date: 2022-05-17 16:02:56 - * LastEditTime: 2022-06-07 15:30:43 + * LastEditTime: 2022-06-08 16:35:49 */ import React, { Component, Fragment } from "react"; import { Button, Modal } from "antd"; @@ -58,6 +58,9 @@ class NumberComposition extends Component { YEAR: "当前年份", MONTH: "当前月份", DAY: "当前日期", + SUBCOMPANY: "分部编号", + DEPARTMENT: "部门编号", + JOBTITLES: "岗位编号", }; let num = 0; const { dataSource: details, onChange } = this.props; @@ -352,7 +355,10 @@ class NumberComposition extends Component { if ( numField === "year" || numField === "month" || - numField === "day" + numField === "day" || + numField === "subcompany" || + numField === "department" || + numField === "jobtitles" ) { return ; } diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js index 506eaf0..d791f22 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 编号设置预览 * Date: 2022-05-18 10:21:09 - * LastEditTime: 2022-05-18 13:26:11 + * LastEditTime: 2022-06-08 16:37:01 */ import React, { Component } from "react"; @@ -19,7 +19,10 @@ class Preview extends Component { if ( numField === "year" || numField === "month" || - numField === "day" + numField === "day" || + numField === "subcompany" || + numField === "department" || + numField === "jobtitles" ) { return { ...item, diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js new file mode 100644 index 0000000..b1c8bb2 --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js @@ -0,0 +1,406 @@ +/* + * Author: 黎永顺 + * Description: 预留编号设置 + * Date: 2022-06-08 09:53:51 + * LastEditTime: 2022-06-09 16:07:51 + */ +import React, { Component } from "react"; +import { Row, Col, Spin, Modal, Button, Alert, message } from "antd"; +import { inject, observer } from "mobx-react"; +import { toJS } from "mobx"; +import { i18n } from "../../../../public/i18n"; +import { + WeaTab, + WeaButtonIcon, + WeaFormItem, + WeaDialog, + WeaMoreButton, + WeaSearchGroup, +} from "ecCom"; +import { WeaSwitch, WeaTableNew } from "comsMobx"; + +const WeaTable = WeaTableNew.WeaTable; + +@inject("numberSet") +@observer +class ReservedNumberSetting extends Component { + constructor() { + super(); + this.state = { + addVisible: false, + showSearchAd: false, + reservedcode: "", + previewStr: "", + date: "", + }; + } + componentWillReceiveProps(nextProps) { + const { numberSet, onChangeAddVisible } = this.props; + const { reservedForm } = numberSet; + if (nextProps.addVisible !== this.props.addVisible) { + !nextProps.addVisible && + this.setState({ addVisible: false }, () => { + reservedForm.reset(); + onChangeAddVisible && onChangeAddVisible(); + }); + } + } + /** + * name:渲染搜索栏 + * return {*} + */ + getPanelComponents = () => { + const { numberSet } = this.props; + const { searchCondition, form } = numberSet; + let colList = []; + const { isFormInit } = form; + isFormInit && + searchCondition.map((c) => { + c.items.map((field, index) => { + colList.push( + +
+ + { + + } + +
+ + ); + }); + }); + return ( + + {colList} + + ); + }; + + onSearchChange = (reservedcode) => { + const { numberSet } = this.props; + const { form } = numberSet; + this.setState({ reservedcode }); + !_.isEmpty(form.getFormParams()) && + form.updateFields({ + reservedcode: { + value: reservedcode, + }, + }); + }; + /** + * name: 查询 + * return {*} + */ + handelSearch = () => { + const { onSearchReservedNumberset } = this.props; + onSearchReservedNumberset && onSearchReservedNumberset(); + }; + /** + * name: 删除 预留编号 + * return {*} + */ + handleDelete = () => { + const { numberSet, onDeleteReservedNumber } = this.props; + const { tableStore } = numberSet; + const selectedKeys = toJS(tableStore.selectedRowKeys); + Modal.confirm({ + title: "信息确认", + content: `确定要删除选择的记录吗?`, + onOk: () => { + onDeleteReservedNumber && + onDeleteReservedNumber(selectedKeys.join(",")); + }, + onCancel: () => {}, + }); + }; + handleAddReservedNumber = () => { + const { onAddReservedNumber } = this.props; + this.setState({ addVisible: true }, () => { + onAddReservedNumber && onAddReservedNumber(); + }); + }; + /** + * name: 提交预留编号设置 + * return {*} + */ + handleSubmitReservedNumber = () => { + const { numberSet, onSubmitReservedNumber } = this.props; + const { reservedForm, condition } = numberSet; + reservedForm.validateForm().then((f) => { + if (f.isValid) { + const { desc: reserveddesc, flowcode: reservedcodes } = + reservedForm.getFormParams() || {}; + if (!/(^[1-9]\d*$)/.test(reservedcodes)) { + message.warning(`"流水号"格式不正确,请重新输入!`); + return; + } + onSubmitReservedNumber && + onSubmitReservedNumber({ + reserveddesc, + reservedcodes: this.state.previewStr, + }); + } else { + message.warning("请完善表单信息"); + f.showErrors(); + this.setState({ date: new Date() }); // 改变一个state的变量,强制页面刷新 + } + }); + }; + /** + * name: 新增预留编号表单渲染 + * return {*} + */ + getReservedForm = () => { + const { condition, reservedForm } = this.props.numberSet; + let reservedFormItem = []; + const { isFormInit } = reservedForm; + isFormInit && + condition.map((c, i) => { + let switchItem = []; + c.items.map((field, index) => { + switchItem.push({ + com: ( +
+ {i === condition.length - 1 && index === 0 && ( +
+ +
+ )} + + + {field.domkey[0] === "flowcode" && ( +

格式为:5,6-10,21,66,99

+ )} +
+
+ ), + colSpan: 1, + }); + }); + reservedFormItem.push( + + ); + }); + + return reservedFormItem; + }; + + /** + * name: 输出指定个数0 + * param {*} num + * param {*} length + * return {*} + */ + prefixInteger = (num, length) => { + return (Array(length).join("0") + num).slice(-length); + }; + /** + * name: 字符串替换 + * param {*} str + * param {*} index + * param {*} char + * return {*} + */ + replaceStr2 = (str, index, char) => { + return str.substring(0, index) + char; + }; + + /** + * name: 预留编号的设置 + * param {*} formVal + * return {*} + */ + handleFormItemChange = (formVal) => { + const { numberSet, onSubmitReservedNumber } = this.props; + const { reservedForm, condition } = numberSet; + const NumberOfData = reservedForm.getFormParams() || {}; + let previewStr = "", + originStr = ""; + for (let i in NumberOfData) { + if ( + i.indexOf("STRING") > -1 || + i.indexOf("YEAR") > -1 || + i.indexOf("MONTH") > -1 || + i.indexOf("DAY") > -1 + ) { + originStr = originStr + NumberOfData[i]; + } + } + let integer_0 = this.prefixInteger(0, Number(NumberOfData["NUMBER"])); + //预留流水号值输入 + if (_.hasIn(formVal, "flowcode")) { + const inputValue = formVal["flowcode"].value; + if (inputValue.length <= Number(NumberOfData["NUMBER"])) { + previewStr = + originStr + + this.replaceStr2( + integer_0, + integer_0.length - inputValue.length, + inputValue + ); + } else { + previewStr = originStr + previewStr + inputValue; + } + this.setState({ previewStr: inputValue ? previewStr : "" }); + } else if ( + _.hasIn(formVal, "YEAR") || + _.hasIn(formVal, "MONTH") || + _.hasIn(formVal, "DAY") + ) { + const { flowcode } = NumberOfData; + if (flowcode.length <= Number(NumberOfData["NUMBER"])) { + previewStr = + originStr + + this.replaceStr2( + integer_0, + integer_0.length - flowcode.length, + flowcode + ); + } else { + previewStr = originStr + previewStr + flowcode; + } + this.setState({ previewStr }); + } + }; + render() { + const { + showSearchAd, + reservedcodem, + addVisible, + reservedcode, + date, + previewStr, + } = this.state; + const { numberSet, loading } = this.props; + const { form, tableStore, reservedForm } = numberSet; + return ( +
+ { + this.setState({ + showSearchAd: bool, + }); + }} + searchsAd={this.getPanelComponents()} + searchsBaseValue={ + _.isEmpty(form.getFormParams()) + ? reservedcode + : form.getFormParams().reservedcode + } + onSearchChange={this.onSearchChange} + onSearch={this.handelSearch} + onAdReset={() => form.reset()} + onAdSearch={this.handelSearch} + hasMask={false} + buttons={[ + , + , + ]} + /> + + {/* 起始/预留编号设置 */} + { + reservedForm.resetForm(); + this.setState({ addVisible: false, previewStr: "" }); + }} + icon="icon-coms-hrm" + iconBgcolor="#217346" + hasScroll + style={{ width: 640, height: 480 }} + buttons={[ + , + , + ]}> + {this.getReservedForm()} + +

+ {previewStr} +

+
+
+
+ ); + } +} + +export default ReservedNumberSetting; diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js index 2fb2365..ac48d27 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 起始编号设置 * Date: 2022-06-07 15:27:43 - * LastEditTime: 2022-06-07 17:21:03 + * LastEditTime: 2022-06-09 16:14:32 */ import React, { Component } from "react"; import { WeaTableEdit, WeaInputNumber } from "ecCom"; @@ -16,6 +16,10 @@ class StartNumberSetting extends Component { })); onChange && onChange(newColumns, datas); }; + getRowSelection = (rowSelection) => { + return null; + }; + render() { const { startNumberInfo } = this.props; const newColumns = _.map(startNumberInfo.columns, (it) => ({ @@ -28,7 +32,7 @@ class StartNumberSetting extends Component { showAdd={false} showDelete={false} showCopy={false} - tableProps={{ rowSelection: {} }} + getRowSelection={this.getRowSelection} columns={newColumns} datas={startNumberInfo.dataSource} onChange={this.handleChangeTable} diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js index 762dc6d..23b5367 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js @@ -2,18 +2,19 @@ * Author: 黎永顺 * Description: 起始编号及预留编号设置 * Date: 2022-05-17 15:51:41 - * LastEditTime: 2022-06-07 17:40:30 + * LastEditTime: 2022-06-08 18:03:02 */ import React, { Component, Fragment } from "react"; import { Button, Modal } from "antd"; import StartNumberSetting from "./startNumberSetting"; +import ReservedNumberSetting from "./reservedNumberSetting"; import { WeaFormItem, WeaDialog, WeaMoreButton } from "ecCom"; import { i18n } from "../../../../public/i18n"; - class StartReservedNumberSet extends Component { constructor() { super(); this.state = { + reservedAddVisible: true, dialogProps: { type: "start", visible: false, @@ -40,7 +41,14 @@ class StartReservedNumberSet extends Component { }; handleSave = () => { const { onSaveStartNumber } = this.props; - onSaveStartNumber && onSaveStartNumber(); + Modal.confirm({ + title: "信息确认", + content: `是否保存数据?`, + onOk: () => { + onSaveStartNumber && onSaveStartNumber(); + }, + onCancel: () => {}, + }); }; handleClose = () => { this.setState({ @@ -50,10 +58,23 @@ class StartReservedNumberSet extends Component { }, }); }; + handleCloseReservedModal = () => { + this.setState({ + reservedAddVisible: false, + }); + }; + render() { - const { dialogProps } = this.state; + const { dialogProps, reservedAddVisible } = this.state; const { type } = dialogProps; - const { startNumberInfo } = this.props; + const { + startNumberInfo, + onDeleteReservedNumber, + onAddReservedNumber, + onSubmitReservedNumber, + onSearchReservedNumberset, + loading, + } = this.props; return ( , ] }> - {type === "start" && ( + {type === "start" ? ( + ) : ( + + this.setState({ reservedAddVisible: true }) + } + /> )} diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js index 344521c..9aa465a 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 分部编号设置 * Date: 2022-05-17 14:30:57 - * LastEditTime: 2022-06-07 17:49:14 + * LastEditTime: 2022-06-09 15:12:50 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -63,32 +63,38 @@ export default class BranchNumSetting extends Component { }; handleSubmit = () => { - const { numberSet } = this.props; - const { dataSource, subCompanyInfo } = this.state; - const { serialenable, dateSerial } = subCompanyInfo; - const details = _.map(dataSource, (it, showorder) => { - const { numField, value: rulevalue } = it; - return { - ruletype: _.upperCase(numField), - rulevalue, - showorder, + let promise = new Promise((resolve, reject) => { + const { numberSet } = this.props; + const { dataSource, subCompanyInfo } = this.state; + const { serialenable, dateSerial } = subCompanyInfo; + const details = _.map(dataSource, (it, showorder) => { + const { numField, value: rulevalue } = it; + return { + ruletype: _.upperCase(numField), + rulevalue, + showorder, + }; + }); + const payload = { + datas: JSON.stringify({ + serialenable, + details, + dateSerial, + serialtype: "SUBCOMPANY", + }), }; + this.setState({ loading: true }); + numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { + this.setState({ loading: false }); + if (api_status) { + message.success("保存成功"); + resolve(api_status); + } else { + reject("接口调用失败"); + } + }); }); - const payload = { - datas: JSON.stringify({ - serialenable, - details, - dateSerial, - serialtype: "SUBCOMPANY", - }), - }; - this.setState({ loading: true }); - numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { - this.setState({ loading: false }); - if (api_status) { - message.success("保存成功"); - } - }); + return promise; }; handleChangeCode = (data) => { @@ -109,28 +115,35 @@ export default class BranchNumSetting extends Component { }; handleSetNumber = (type) => { - this.handleSubmit(); - const { numberSet } = this.props; - if (type === "start") { - const payload = { - coderuleid: 1, - type: "", - dateStart: moment().format("YYYY"), - dateEnd: moment().format("YYYY"), - subCompanyId: "", - deptId: "", - jobtitlesId: "", - }; - numberSet - .getStartNumForm(payload) - .then(({ api_status, columns, dataSource }) => { - if (api_status) { - this.setState({ - startNumberInfo: { columns, dataSource }, - }); - } + this.handleSubmit().then((res) => { + const { numberSet } = this.props; + if (type === "start") { + const payload = { + coderuleid: 1, + type: "", + dateStart: moment().format("YYYY"), + dateEnd: moment().format("YYYY"), + subCompanyId: "", + deptId: "", + jobtitlesId: "", + }; + numberSet + .getStartNumForm(payload) + .then(({ api_status, columns, dataSource }) => { + if (api_status) { + this.setState({ + startNumberInfo: { columns, dataSource }, + }); + } + }); + } else { + numberSet.getAdvanceSearchCondition(); + numberSet.getSearchReservedCodeList({ + serialtype: "SUBCOMPANY", + checkboxType: "multi", }); - } + } + }); }; handleChangeTable = (newColumns, datas) => { this.setState({ @@ -158,6 +171,53 @@ export default class BranchNumSetting extends Component { }); }; + /** + * name: 删除预留编号 + * param {*} ids + * return {*} + */ + deleteReservedNumber = (ids) => { + const { numberSet } = this.props; + numberSet.deleteReservedCodeById({ ids }).then(({ api_status }) => { + if (api_status) { + message.success("删除成功"); + numberSet.getSearchReservedCodeList({ + serialtype: "SUBCOMPANY", + checkboxType: "multi", + }); + } + }); + }; + /** + * name:新增预留编号 + * return {*} + */ + handleAddReservedNumber = () => { + const { numberSet } = this.props; + numberSet.getReservedCodeFrom({ serialtype: "SUBCOMPANY" }); + }; + /** + * name: 保存预留设置 + * param {*} params + * return {*} + */ + handleSubmitReservedNumber = (params) => { + const { numberSet } = this.props; + const payload = { ...params, serialtype: "SUBCOMPANY" }; + this.setState({ loading: true }); + numberSet.saveReservedCode(payload).then(({ api_status }) => { + this.setState({ loading: false }); + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleCloseReservedModal(); + numberSet.getSearchReservedCodeList({ + serialtype: "SUBCOMPANY", + checkboxType: "multi", + }); + } + }); + }; + /** * name:提示文本 * return {*} @@ -175,6 +235,7 @@ export default class BranchNumSetting extends Component { }; render() { + const { numberSet } = this.props; const { options, subCompanyInfo, loading, startNumberInfo } = this.state; const { details, serialenable, dateSerial } = subCompanyInfo; const btns = [ @@ -297,10 +358,20 @@ export default class BranchNumSetting extends Component { center> (this.numberSetRef = dom)} + loading={loading} onSet={this.handleSetNumber} startNumberInfo={startNumberInfo} onChange={this.handleChangeTable} onSaveStartNumber={this.handleSubmitStartNumber} + onDeleteReservedNumber={this.deleteReservedNumber} + onAddReservedNumber={this.handleAddReservedNumber} + onSubmitReservedNumber={this.handleSubmitReservedNumber} + onSearchReservedNumberset={() => + numberSet.getSearchReservedCodeList({ + serialtype: "SUBCOMPANY", + checkboxType: "multi", + }) + } />
diff --git a/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js index 44bc55b..1d5226a 100644 --- a/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js +++ b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 部门编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-08 09:32:09 + * LastEditTime: 2022-06-09 15:12:57 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -18,7 +18,7 @@ import { import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; import NumberComposition from "../branchNumSetting/components/numberComposition"; import { i18n } from "../../../public/i18n"; -import moment from 'moment'; +import moment from "moment"; import "../branchNumSetting/index.less"; @inject("numberSet") @@ -63,32 +63,38 @@ export default class DeptNumberSet extends Component { }; handleSubmit = () => { - const { numberSet } = this.props; - const { dataSource, subCompanyInfo } = this.state; - const { serialenable, dateSerial } = subCompanyInfo; - const details = _.map(dataSource, (it, showorder) => { - const { numField, value: rulevalue } = it; - return { - ruletype: _.upperCase(numField), - rulevalue, - showorder, + let promise = new Promise((resolve, reject) => { + const { numberSet } = this.props; + const { dataSource, subCompanyInfo } = this.state; + const { serialenable, dateSerial } = subCompanyInfo; + const details = _.map(dataSource, (it, showorder) => { + const { numField, value: rulevalue } = it; + return { + ruletype: _.upperCase(numField), + rulevalue, + showorder, + }; + }); + const payload = { + datas: JSON.stringify({ + serialenable, + details, + dateSerial, + serialtype: "DEPARTMENT", + }), }; + this.setState({ loading: true }); + numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { + this.setState({ loading: false }); + if (api_status) { + message.success("保存成功"); + resolve(api_status); + } else { + reject("接口调用失败"); + } + }); }); - const payload = { - datas: JSON.stringify({ - serialenable, - details, - dateSerial, - serialtype: "DEPARTMENT", - }), - }; - this.setState({ loading: true }); - numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { - this.setState({ loading: false }); - if (api_status) { - message.success("保存成功"); - } - }); + return promise; }; handleChangeCode = (data) => { @@ -109,28 +115,35 @@ export default class DeptNumberSet extends Component { }; handleSetNumber = (type) => { - this.handleSubmit(); - const { numberSet } = this.props; - if (type === "start") { - const payload = { - coderuleid: 2, - type: "", - dateStart: moment().format("YYYY"), - dateEnd: moment().format("YYYY"), - subCompanyId: "", - deptId: "", - jobtitlesId: "", - }; - numberSet - .getStartNumForm(payload) - .then(({ api_status, columns, dataSource }) => { - if (api_status) { - this.setState({ - startNumberInfo: { columns, dataSource }, - }); - } + this.handleSubmit().then((res) => { + const { numberSet } = this.props; + if (type === "start") { + const payload = { + coderuleid: 2, + type: "", + dateStart: moment().format("YYYY"), + dateEnd: moment().format("YYYY"), + subCompanyId: "", + deptId: "", + jobtitlesId: "", + }; + numberSet + .getStartNumForm(payload) + .then(({ api_status, columns, dataSource }) => { + if (api_status) { + this.setState({ + startNumberInfo: { columns, dataSource }, + }); + } + }); + } else { + numberSet.getAdvanceSearchCondition(); + numberSet.getSearchReservedCodeList({ + serialtype: "DEPARTMENT", + checkboxType: "multi", }); - } + } + }); }; handleChangeTable = (newColumns, datas) => { this.setState({ @@ -158,6 +171,51 @@ export default class DeptNumberSet extends Component { }); }; + /** + * name: 删除预留编号 + * param {*} ids + * return {*} + */ + deleteReservedNumber = (ids) => { + const { numberSet } = this.props; + numberSet.deleteReservedCodeById({ ids }).then(({ api_status }) => { + if (api_status) { + message.success("删除成功"); + numberSet.getSearchReservedCodeList({ + serialtype: "DEPARTMENT", + checkboxType: "multi", + }); + } + }); + }; + /** + * name:新增预留编号 + * return {*} + */ + handleAddReservedNumber = () => { + const { numberSet } = this.props; + numberSet.getReservedCodeFrom({ serialtype: "DEPARTMENT" }); + }; + /** + * name: 保存预留设置 + * param {*} params + * return {*} + */ + handleSubmitReservedNumber = (params) => { + const { numberSet } = this.props; + const payload = { ...params, serialtype: "DEPARTMENT" }; + numberSet.saveReservedCode(payload).then(({ api_status }) => { + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleCloseReservedModal(); + numberSet.getSearchReservedCodeList({ + serialtype: "DEPARTMENT", + checkboxType: "multi", + }); + } + }); + }; + /** * name:提示文本 * return {*} @@ -175,6 +233,7 @@ export default class DeptNumberSet extends Component { }; render() { const { options, subCompanyInfo, loading, startNumberInfo } = this.state; + const { numberSet } = this.props; const { details, serialenable, dateSerial } = subCompanyInfo; const btns = [ , , ]; diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js index b1c8bb2..4baaf71 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 预留编号设置 * Date: 2022-06-08 09:53:51 - * LastEditTime: 2022-06-09 16:07:51 + * LastEditTime: 2022-06-15 11:00:55 */ import React, { Component } from "react"; import { Row, Col, Spin, Modal, Button, Alert, message } from "antd"; @@ -59,24 +59,21 @@ class ReservedNumberSetting extends Component { c.items.map((field, index) => { colList.push(
{ @@ -128,7 +125,7 @@ class ReservedNumberSetting extends Component { onDeleteReservedNumber && onDeleteReservedNumber(selectedKeys.join(",")); }, - onCancel: () => {}, + onCancel: () => { }, }); }; handleAddReservedNumber = () => { @@ -189,17 +186,15 @@ class ReservedNumberSetting extends Component {
)} {i18n.button.save()} , , ]}> {this.getReservedForm()} diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js index ac48d27..aa4091e 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js @@ -2,12 +2,51 @@ * Author: 黎永顺 * Description: 起始编号设置 * Date: 2022-06-07 15:27:43 - * LastEditTime: 2022-06-09 16:14:32 + * LastEditTime: 2022-06-15 10:47:55 */ -import React, { Component } from "react"; -import { WeaTableEdit, WeaInputNumber } from "ecCom"; +import React, { Component, Fragment } from "react"; +import { WeaTableEdit, WeaInputNumber, WeaDatePicker, WeaBrowser, WeaError } from "ecCom"; +import moment from 'moment'; +const enumStr = { + YEAR: '年', + MONTH: '月份', + DAY: '日期' +} +const browserProps = { + iconBgcolor: '#217346', + icon: 'icon-coms-hrm', + isSingle: false, + inputStyle: { width: 200 }, + viewAttr: 3 +} class StartNumberSetting extends Component { + constructor() { + super(); + this.state = { + startDate: '', + endDate: '', + subCompanyId: '', + jobtitlesId: "" + } + } + handleDatePickerChange = (val, type) => { + this.setState({ + [type]: val + }, () => { + const { startDate, endDate, subCompanyId, jobtitlesId } = this.state; + const { onSet } = this.props; + onSet('start', { startDate, endDate, subCompanyId, jobtitlesId }) + }) + } + handleBrowserChange = (val, type) => { + this.setState({ + [type]: val + }, () => { + const { onSet } = this.props; + onSet('start', { ...this.state, [type]: val }) + }) + } handleChangeTable = (datas) => { const { onChange, startNumberInfo } = this.props; const newColumns = _.map(startNumberInfo.columns, (it) => ({ @@ -21,22 +60,81 @@ class StartNumberSetting extends Component { }; render() { - const { startNumberInfo } = this.props; + const { startDate, endDate } = this.state; + const { startNumberInfo, companyInfo } = this.props; + const { deptSerial = {}, dateSerial = {}, jobtitlesSerial = {} } = companyInfo; const newColumns = _.map(startNumberInfo.columns, (it) => ({ ...it, - com: [{ type: "INPUTNUMBER", key: it.dataIndex, viewAttr: 3, min: 0 }], + com: [{ type: it.dataIndex === 'startnum' ? "INPUTNUMBER" : "TEXT", key: it.dataIndex, viewAttr: 3, min: 0 }], })); + const format = dateSerial.key === "YEAR" ? "YYYY" : dateSerial.key === "MONTH" ? "YYYY-MM" : "yyyy-MM-dd"; + const formatVal = dateSerial.key === "YEAR" ? "YYYY" : dateSerial.key === "MONTH" ? "YYYY-MM" : "yyyy-MM-DD"; return ( - + + {dateSerial.enable == '1' && ( +
+ {enumStr[dateSerial.key]} + this.handleDatePickerChange(val, 'startDate')} /> + + this.handleDatePickerChange(val, 'endDate')} /> +
+ )} + { + (deptSerial.enable == '1' && (deptSerial.key === "SUBCOMPANY" || deptSerial.key === "DEPARTMENT")) && ( +
+ 分部名称 + + this.handleBrowserChange(ids, 'subCompanyId')} + /> + +
+ ) + } + { + (deptSerial.enable == '1' && deptSerial.key === "DEPARTMENT") && ( +
+ 部门名称 + + this.handleBrowserChange(ids, 'deptId')} + /> + +
+ ) + } + { + (jobtitlesSerial.enable == '1' && jobtitlesSerial.key === "JOBTITLES") && ( +
+ 岗位名称 + + this.handleBrowserChange(ids, 'jobtitlesId')} + /> + +
+ ) + } + +
); } } diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js index 23b5367..9df6825 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 起始编号及预留编号设置 * Date: 2022-05-17 15:51:41 - * LastEditTime: 2022-06-08 18:03:02 + * LastEditTime: 2022-06-14 18:29:38 */ import React, { Component, Fragment } from "react"; import { Button, Modal } from "antd"; @@ -47,7 +47,7 @@ class StartReservedNumberSet extends Component { onOk: () => { onSaveStartNumber && onSaveStartNumber(); }, - onCancel: () => {}, + onCancel: () => { }, }); }; handleClose = () => { @@ -68,6 +68,8 @@ class StartReservedNumberSet extends Component { const { dialogProps, reservedAddVisible } = this.state; const { type } = dialogProps; const { + onSet, + companyInfo, startNumberInfo, onDeleteReservedNumber, onAddReservedNumber, @@ -104,30 +106,29 @@ class StartReservedNumberSet extends Component { buttons={ type === "start" ? [ - , - + {i18n.button.save()} + , + , - ] + />, + ] : [ - , - ] + />, + ] }> {type === "start" ? ( diff --git a/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js index 9aa465a..bed9e63 100644 --- a/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 分部编号设置 * Date: 2022-05-17 14:30:57 - * LastEditTime: 2022-06-09 15:12:50 + * LastEditTime: 2022-06-14 18:26:07 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -16,6 +16,7 @@ import { WeaHelpfulTip, } from "ecCom"; import StartReservedNumberSet from "./components/startReservedNumberSet"; +import { serialFieldOptions } from "../constants"; import NumberComposition from "./components/numberComposition"; import { i18n } from "../../../public/i18n"; import moment from "moment"; @@ -114,15 +115,18 @@ export default class BranchNumSetting extends Component { }); }; - handleSetNumber = (type) => { + handleSetNumber = (type, data = {}) => { this.handleSubmit().then((res) => { const { numberSet } = this.props; + const { subCompanyInfo } = this.state; + const { dateSerial } = subCompanyInfo; if (type === "start") { + const formatVal = dateSerial.key === "YEAR" ? "YYYY" : dateSerial.key === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD"; const payload = { coderuleid: 1, - type: "", - dateStart: moment().format("YYYY"), - dateEnd: moment().format("YYYY"), + type: dateSerial.enable == '1' ? dateSerial.key : '', + dateStart: data.startDate ? data.startDate : moment().format(formatVal), + dateEnd: data.endDate ? data.endDate : moment().format(formatVal), subCompanyId: "", deptId: "", jobtitlesId: "", @@ -194,7 +198,33 @@ export default class BranchNumSetting extends Component { */ handleAddReservedNumber = () => { const { numberSet } = this.props; - numberSet.getReservedCodeFrom({ serialtype: "SUBCOMPANY" }); + const { reservedForm } = numberSet; + const { options } = this.state; + numberSet.getReservedCodeFrom({ serialtype: "SUBCOMPANY" }).then(() => { + const type = _.get(_.last(options), ['key']); + const format = type === "YEAR" ? "YYYY" : type === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD" + const payload = { + coderuleid: 1, + type, + dateStart: moment().format(format), + dateEnd: moment().format(format), + subCompanyId: "", + deptId: "", + jobtitlesId: "", + }; + numberSet + .getStartNumForm(payload) + .then(({ api_status, dataSource }) => { + if (api_status && !_.isEmpty(dataSource)) { + const currentnumber = _.get(_.last(dataSource), ['startnum']); + reservedForm.updateFields({ + currentnumber: { + value: currentnumber, + }, + }); + } + }); + }) }; /** * name: 保存预留设置 @@ -293,6 +323,7 @@ export default class BranchNumSetting extends Component { @@ -316,6 +347,7 @@ export default class BranchNumSetting extends Component { dateSerial: { ...dateSerial, enable: isSingle, + key: isSingle == '0' ? 'YEAR' : dateSerial.key }, }, }) @@ -323,7 +355,7 @@ export default class BranchNumSetting extends Component { /> {dateSerial.enable == "1" && ( ({ ...item, showname: item.showname.substr(2, 1) }))} value={dateSerial.key} detailtype={3} supportCancel @@ -360,6 +392,7 @@ export default class BranchNumSetting extends Component { ref={(dom) => (this.numberSetRef = dom)} loading={loading} onSet={this.handleSetNumber} + companyInfo={subCompanyInfo} startNumberInfo={startNumberInfo} onChange={this.handleChangeTable} onSaveStartNumber={this.handleSubmitStartNumber} diff --git a/pc4mobx/organization/components/numberSetting/constants.js b/pc4mobx/organization/components/numberSetting/constants.js new file mode 100644 index 0000000..a45a284 --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/constants.js @@ -0,0 +1,6 @@ +export const serialFieldOptions = [ + { key: "string", showname: "字符串" }, + { key: "year", showname: "当前年份" }, + { key: "month", showname: "当前月份" }, + { key: "day", showname: "当前日期" }, +]; \ No newline at end of file diff --git a/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js index 1d5226a..01fa1ad 100644 --- a/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js +++ b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: 部门编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-09 15:12:57 + * LastEditTime: 2022-06-15 09:52:04 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -17,10 +17,13 @@ import { } from "ecCom"; import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; import NumberComposition from "../branchNumSetting/components/numberComposition"; +import { serialFieldOptions } from "../constants"; import { i18n } from "../../../public/i18n"; import moment from "moment"; import "../branchNumSetting/index.less"; +const deptSerialFieldOptions = [{ key: 'subcompany', showname: "分部编号" }] + @inject("numberSet") @observer export default class DeptNumberSet extends Component { @@ -37,6 +40,10 @@ export default class DeptNumberSet extends Component { subCompanyInfo: { details: [], serialenable: "0", + deptSerial: { + enable: "0", + key: "", + }, dateSerial: { enable: "0", key: "", @@ -53,10 +60,10 @@ export default class DeptNumberSet extends Component { const { numberSet } = this.props; numberSet .getCodeSetting({ serialtype: "DEPARTMENT" }) - .then(({ api_status, details, serialenable, dateSerial = {} }) => { + .then(({ api_status, details, serialenable, dateSerial = {}, deptSerial = {} }) => { if (api_status && !_.isEmpty(details)) { this.setState({ - subCompanyInfo: { details, serialenable, dateSerial }, + subCompanyInfo: { details, serialenable, dateSerial, deptSerial }, }); } }); @@ -66,7 +73,7 @@ export default class DeptNumberSet extends Component { let promise = new Promise((resolve, reject) => { const { numberSet } = this.props; const { dataSource, subCompanyInfo } = this.state; - const { serialenable, dateSerial } = subCompanyInfo; + const { serialenable, dateSerial, deptSerial } = subCompanyInfo; const details = _.map(dataSource, (it, showorder) => { const { numField, value: rulevalue } = it; return { @@ -80,6 +87,7 @@ export default class DeptNumberSet extends Component { serialenable, details, dateSerial, + deptSerial, serialtype: "DEPARTMENT", }), }; @@ -103,7 +111,10 @@ export default class DeptNumberSet extends Component { (it) => it.numField === "year" || it.numField === "month" || - it.numField === "day" + it.numField === "day" || + it.numField === "subcompany" || + it.numField === "department" || + it.numField === "jobtitles" ); this.setState({ dataSource: _.cloneDeep(data), @@ -114,28 +125,33 @@ export default class DeptNumberSet extends Component { }); }; - handleSetNumber = (type) => { + handleSetNumber = (type, data = {}) => { this.handleSubmit().then((res) => { const { numberSet } = this.props; + const { subCompanyInfo } = this.state; + const { dateSerial, deptSerial } = subCompanyInfo; if (type === "start") { - const payload = { + const formatVal = dateSerial.key === "YEAR" ? "YYYY" : dateSerial.key === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD"; + let payload = { coderuleid: 2, - type: "", - dateStart: moment().format("YYYY"), - dateEnd: moment().format("YYYY"), - subCompanyId: "", + type: dateSerial.enable == '1' ? dateSerial.key : '', + dateStart: data.startDate ? data.startDate : moment().format(formatVal), + dateEnd: data.endDate ? data.endDate : moment().format(formatVal), + subCompanyId: data.subCompanyId ? data.subCompanyId : "", deptId: "", jobtitlesId: "", }; - numberSet - .getStartNumForm(payload) - .then(({ api_status, columns, dataSource }) => { - if (api_status) { - this.setState({ - startNumberInfo: { columns, dataSource }, - }); - } - }); + if (deptSerial.enable === '1' && !data.subCompanyId) return + if (deptSerial.enable === '1' && data.subCompanyId) { + payload = { ...payload, type: payload.type + ',' + deptSerial.key } + } + numberSet.getStartNumForm(payload).then(({ api_status, columns, dataSource }) => { + if (api_status) { + this.setState({ + startNumberInfo: { columns, dataSource }, + }); + } + }); } else { numberSet.getAdvanceSearchCondition(); numberSet.getSearchReservedCodeList({ @@ -194,7 +210,33 @@ export default class DeptNumberSet extends Component { */ handleAddReservedNumber = () => { const { numberSet } = this.props; - numberSet.getReservedCodeFrom({ serialtype: "DEPARTMENT" }); + const { reservedForm } = numberSet; + const { options } = this.state; + numberSet.getReservedCodeFrom({ serialtype: "DEPARTMENT" }).then(() => { + const type = _.get(_.last(options), ['key']); + const format = type === "YEAR" ? "YYYY" : type === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD" + const payload = { + coderuleid: 2, + type, + dateStart: moment().format(format), + dateEnd: moment().format(format), + subCompanyId: "", + deptId: "", + jobtitlesId: "", + }; + numberSet + .getStartNumForm(payload) + .then(({ api_status, dataSource }) => { + if (api_status && !_.isEmpty(dataSource)) { + const currentnumber = _.get(_.last(dataSource), ['startnum']); + reservedForm.updateFields({ + currentnumber: { + value: currentnumber, + }, + }); + } + }); + }) }; /** * name: 保存预留设置 @@ -234,7 +276,7 @@ export default class DeptNumberSet extends Component { render() { const { options, subCompanyInfo, loading, startNumberInfo } = this.state; const { numberSet } = this.props; - const { details, serialenable, dateSerial } = subCompanyInfo; + const { details, serialenable, dateSerial = {}, deptSerial = {} } = subCompanyInfo; const btns = [