diff --git a/pc4mobx/organization/apis/numberSet.js b/pc4mobx/organization/apis/numberSet.js index d300660..b287162 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-15 13:06:02 */ import { WeaTools } from "ecCom"; @@ -48,3 +48,68 @@ 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 saveReservedCode = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/saveReservedCode", + "POST", + params + ); +}; + +/** + * name: 新增预留编号表单查询 + * param {*} params + * return {*} + */ +export const getReservedCodeFrom = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/getReservedCodeFrom", + "GET", + params + ); +}; + +/** + * name: 删除预留编号 + * param {*} params + * return {*} + */ +export const deleteReservedCodeById = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/deleteReservedCodeById", + "POST", + params + ); +}; \ No newline at end of file diff --git a/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js b/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js deleted file mode 100644 index 2fb2365..0000000 --- a/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Author: 黎永顺 - * Description: 起始编号设置 - * Date: 2022-06-07 15:27:43 - * LastEditTime: 2022-06-07 17:21:03 - */ -import React, { Component } from "react"; -import { WeaTableEdit, WeaInputNumber } from "ecCom"; - -class StartNumberSetting extends Component { - handleChangeTable = (datas) => { - const { onChange, startNumberInfo } = this.props; - const newColumns = _.map(startNumberInfo.columns, (it) => ({ - ...it, - com: [{ type: "INPUTNUMBER", key: it.dataIndex, viewAttr: 3, min: 0 }], - })); - onChange && onChange(newColumns, datas); - }; - render() { - const { startNumberInfo } = this.props; - const newColumns = _.map(startNumberInfo.columns, (it) => ({ - ...it, - com: [{ type: "INPUTNUMBER", key: it.dataIndex, viewAttr: 3, min: 0 }], - })); - return ( - - ); - } -} - -export default StartNumberSetting; diff --git a/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js similarity index 89% rename from pc4mobx/organization/components/branchNumSetting/components/numberComposition.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/numberComposition.js index 4bf954b..3f65be5 100644 --- a/pc4mobx/organization/components/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-14 14:16:16 */ import React, { Component, Fragment } from "react"; import { Button, Modal } from "antd"; @@ -16,28 +16,10 @@ import { WeaInputNumber, } from "ecCom"; import Preview from "./preview"; -import { i18n } from "../../../public/i18n"; +import { i18n } from "../../../../public/i18n"; import _ from "lodash"; import "../index.less"; -const options = [ - { - key: "string", - showname: "字符串", - }, - { - key: "year", - showname: "当前年份", - }, - { - key: "month", - showname: "当前月份", - }, - { - key: "day", - showname: "当前日期", - }, -]; class NumberComposition extends Component { constructor() { super(); @@ -58,6 +40,9 @@ class NumberComposition extends Component { YEAR: "当前年份", MONTH: "当前月份", DAY: "当前日期", + SUBCOMPANY: "分部编号", + DEPARTMENT: "部门编号", + JOBTITLES: "岗位编号", }; let num = 0; const { dataSource: details, onChange } = this.props; @@ -85,20 +70,20 @@ class NumberComposition extends Component { dataSource: !_.isEmpty(tmpV) ? tmpV : [ - { - id: 1, - value: "", - strLogo: 1, - numFieldName: "字符串1", - numField: "string", - }, - { - id: 2, - value: 3, - numFieldName: "流水号位数", - numField: "number", - }, - ], + { + id: 1, + value: "", + strLogo: 1, + numFieldName: "字符串1", + numField: "string", + }, + { + id: 2, + value: 3, + numFieldName: "流水号位数", + numField: "number", + }, + ], }, () => { onChange && onChange(this.state.dataSource); @@ -138,8 +123,8 @@ class NumberComposition extends Component { const stringRow = _.filter(dataSource, (it) => it.numField === "string"); //字符串列表 const maxStrLen = !_.isEmpty(stringRow) ? _.sortBy(stringRow, function (o) { - return -o.strLogo; - })[0].strLogo + return -o.strLogo; + })[0].strLogo : 0; //字符串列表 const maxIdLen = _.sortBy(dataSource, function (o) { return -o.id; @@ -150,7 +135,17 @@ class NumberComposition extends Component { dataSource, (item) => item.numField === "string" ); - + if (numField === "subcompany" || numField === "department" || numField === "jobtitles") { + if (_.findIndex(dataSource, it => it.numField === numField) !== -1) { + Modal.warning({ + title: "信息确认", + content: `已经添加过一个${numFieldName},请选择其他编号字段!`, + onOk() { }, + okText: "确认", + }); + return; + } + } if (numField === "year" || numField === "month" || numField === "day") { const hasYearOrMonthOrDay = _.some( dataSource, @@ -163,7 +158,7 @@ class NumberComposition extends Component { Modal.warning({ title: "信息确认", content: `添加【${numFieldName}】时,请先添加【当前年份】!`, - onOk() {}, + onOk() { }, okText: "确认", }); return; @@ -172,7 +167,7 @@ class NumberComposition extends Component { Modal.warning({ title: "信息确认", content: `添加【${numFieldName}】时,请先添加【当前年份】和【当前月份】!`, - onOk() {}, + onOk() { }, okText: "确认", }); return; @@ -294,7 +289,7 @@ class NumberComposition extends Component { title: "信息确认", content: `已经添加过一个${objectData.numFieldName},请选择其他编号字段!`, footer: [], - onOk() {}, + onOk() { }, okText: "确认", }); }; @@ -328,6 +323,7 @@ class NumberComposition extends Component { render() { const { visible, objectData, dataSource } = this.state; + const { options } = this.props; const { numField, numFieldName } = objectData; const columns = [ { @@ -352,7 +348,10 @@ class NumberComposition extends Component { if ( numField === "year" || numField === "month" || - numField === "day" + numField === "day" || + numField === "subcompany" || + numField === "department" || + numField === "jobtitles" ) { return ; } @@ -391,9 +390,8 @@ class NumberComposition extends Component { {i18n.button.save()} , , ]; diff --git a/pc4mobx/organization/components/branchNumSetting/components/preview.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js similarity index 84% rename from pc4mobx/organization/components/branchNumSetting/components/preview.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/preview.js index 506eaf0..d791f22 100644 --- a/pc4mobx/organization/components/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..4baaf71 --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/reservedNumberSetting.js @@ -0,0 +1,397 @@ +/* + * Author: 黎永顺 + * Description: 预留编号设置 + * Date: 2022-06-08 09:53:51 + * LastEditTime: 2022-06-15 11:00:55 + */ +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 new file mode 100644 index 0000000..aa4091e --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startNumberSetting.js @@ -0,0 +1,142 @@ +/* + * Author: 黎永顺 + * Description: 起始编号设置 + * Date: 2022-06-07 15:27:43 + * LastEditTime: 2022-06-15 10:47:55 + */ +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) => ({ + ...it, + com: [{ type: "INPUTNUMBER", key: it.dataIndex, viewAttr: 3, min: 0 }], + })); + onChange && onChange(newColumns, datas); + }; + getRowSelection = (rowSelection) => { + return null; + }; + + render() { + const { startDate, endDate } = this.state; + const { startNumberInfo, companyInfo } = this.props; + const { deptSerial = {}, dateSerial = {}, jobtitlesSerial = {} } = companyInfo; + const newColumns = _.map(startNumberInfo.columns, (it) => ({ + ...it, + 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')} + /> + +
+ ) + } + +
+ ); + } +} + +export default StartNumberSetting; diff --git a/pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js similarity index 56% rename from pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/components/startReservedNumberSet.js index b39d4a0..9df6825 100644 --- a/pc4mobx/organization/components/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-14 18:29:38 */ 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"; - +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,25 @@ 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 { + onSet, + companyInfo, + startNumberInfo, + onDeleteReservedNumber, + onAddReservedNumber, + onSubmitReservedNumber, + onSearchReservedNumberset, + loading, + } = this.props; return ( - {i18n.button.save()} - , - + {i18n.button.save()} + , + , - ] + />, + ] : [ - , - ] + />, + ] }> - {type === "start" && ( + {type === "start" ? ( + ) : ( + + this.setState({ reservedAddVisible: true }) + } + /> )} diff --git a/pc4mobx/organization/components/branchNumSetting/index.js b/pc4mobx/organization/components/numberSetting/branchNumSetting/index.js similarity index 64% rename from pc4mobx/organization/components/branchNumSetting/index.js rename to pc4mobx/organization/components/numberSetting/branchNumSetting/index.js index e8743e7..bed9e63 100644 --- a/pc4mobx/organization/components/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-14 18:26:07 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -16,8 +16,9 @@ import { WeaHelpfulTip, } from "ecCom"; import StartReservedNumberSet from "./components/startReservedNumberSet"; +import { serialFieldOptions } from "../constants"; import NumberComposition from "./components/numberComposition"; -import { i18n } from "../../public/i18n"; +import { i18n } from "../../../public/i18n"; import moment from "moment"; import "./index.less"; @@ -63,32 +64,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) => { @@ -108,29 +115,39 @@ 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 }, - }); - } + 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: dateSerial.enable == '1' ? dateSerial.key : '', + dateStart: data.startDate ? data.startDate : moment().format(formatVal), + dateEnd: data.endDate ? data.endDate : moment().format(formatVal), + 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 +175,79 @@ 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; + 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: 保存预留设置 + * 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 +265,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 = [ @@ -232,6 +323,7 @@ export default class BranchNumSetting extends Component {
@@ -255,6 +347,7 @@ export default class BranchNumSetting extends Component { dateSerial: { ...dateSerial, enable: isSingle, + key: isSingle == '0' ? 'YEAR' : dateSerial.key }, }, }) @@ -262,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 @@ -297,10 +390,21 @@ export default class BranchNumSetting extends Component { center> (this.numberSetRef = dom)} + loading={loading} onSet={this.handleSetNumber} + companyInfo={subCompanyInfo} 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/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/numberSetting/constants.js b/pc4mobx/organization/components/numberSetting/constants.js new file mode 100644 index 0000000..442abae --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/constants.js @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000..01fa1ad --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/deptNumberSet/index.js @@ -0,0 +1,481 @@ +/* + * Author: 黎永顺 + * Description: 部门编号设置 + * Date: 2022-06-06 09:37:39 + * LastEditTime: 2022-06-15 09:52:04 + */ +import React, { Component, Fragment } from "react"; +import { inject, observer } from "mobx-react"; +import { Button, message } from "antd"; +import { + WeaTop, + WeaFormItem, + WeaCheckbox, + WeaSearchGroup, + WeaSelect, + WeaHelpfulTip, +} 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 { + constructor() { + super(); + this.state = { + options: [], + loading: false, + dataSource: [], + startNumberInfo: { + columns: [], + dataSource: [], + }, + subCompanyInfo: { + details: [], + serialenable: "0", + deptSerial: { + enable: "0", + key: "", + }, + dateSerial: { + enable: "0", + key: "", + }, + }, + }; + } + + componentDidMount() { + this.getCodeSetting(); + } + + getCodeSetting = () => { + const { numberSet } = this.props; + numberSet + .getCodeSetting({ serialtype: "DEPARTMENT" }) + .then(({ api_status, details, serialenable, dateSerial = {}, deptSerial = {} }) => { + if (api_status && !_.isEmpty(details)) { + this.setState({ + subCompanyInfo: { details, serialenable, dateSerial, deptSerial }, + }); + } + }); + }; + + handleSubmit = () => { + let promise = new Promise((resolve, reject) => { + const { numberSet } = this.props; + const { dataSource, subCompanyInfo } = this.state; + const { serialenable, dateSerial, deptSerial } = 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, + deptSerial, + 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("接口调用失败"); + } + }); + }); + return promise; + }; + + handleChangeCode = (data) => { + const tmpV = _.filter( + data, + (it) => + it.numField === "year" || + it.numField === "month" || + it.numField === "day" || + it.numField === "subcompany" || + it.numField === "department" || + it.numField === "jobtitles" + ); + this.setState({ + dataSource: _.cloneDeep(data), + options: _.map(tmpV, (it) => { + const { numFieldName: showname, numField: key } = it; + return { key: _.upperCase(key), showname }; + }), + }); + }; + + handleSetNumber = (type, data = {}) => { + this.handleSubmit().then((res) => { + const { numberSet } = this.props; + const { subCompanyInfo } = this.state; + const { dateSerial, deptSerial } = subCompanyInfo; + if (type === "start") { + const formatVal = dateSerial.key === "YEAR" ? "YYYY" : dateSerial.key === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD"; + let payload = { + coderuleid: 2, + 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: "", + }; + 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({ + serialtype: "DEPARTMENT", + checkboxType: "multi", + }); + } + }); + }; + handleChangeTable = (newColumns, datas) => { + this.setState({ + startNumberInfo: { + ...this.state.startNumberInfo, + columns: newColumns, + dataSource: datas, + }, + }); + }; + + handleSubmitStartNumber = () => { + const { numberSet } = this.props; + const payload = { + datas: JSON.stringify({ + coderuleid: 2, + ...this.state.startNumberInfo, + }), + }; + numberSet.saveStartNum(payload).then(({ api_status }) => { + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleClose(); + } + }); + }; + + /** + * 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; + 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: 保存预留设置 + * 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 {*} + */ + helpContent = () => { + return ( +
+

开启后,可根据设置的部门编号规则自动生成部门编号,涉及场景如下:

+

1.手动新建和手动编辑部门时可选择重新生成编号和选择预留部门编号;

+

2.导入人员-添加时,新创建的部门可自动生成部门编号;

+

3.组织结构导入-添加新部门且部门编号列为空时可自动生成部门编号;

+

【注意】开启前请先确认部门编号字段已启用!

+
+ ); + }; + render() { + const { options, subCompanyInfo, loading, startNumberInfo } = this.state; + const { numberSet } = this.props; + const { details, serialenable, dateSerial = {}, deptSerial = {} } = subCompanyInfo; + const btns = [ + , + ]; + const dropMenuDatas = [ + { + key: "save", + disabled: false, + icon: , + content: "保存", + onClick: (key) => this.handleSubmit(), + }, + ]; + return ( +
+ } + iconBgcolor="#217346" + buttons={btns} + showDropIcon={true} + dropMenuDatas={dropMenuDatas} + /> +
+
+ + + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + serialenable: checkVal, + }, + }) + } + /> + +
+ {/* 内容区 */} + {serialenable === "1" && ( + +
+ + + +
+ {!_.isEmpty(options) && ( +
+ + { + !_.isEmpty(_.filter(options, item => ["YEAR", "MONTH", "DAY"].includes(item.key))) && +
!["YEAR", "MONTH", "DAY"].includes(item.key))) && 0 }}> + +
+ + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + dateSerial: { + ...dateSerial, + enable: isSingle, + key: isSingle == '0' ? 'YEAR' : dateSerial.key + }, + }, + }) + } + /> + {dateSerial.enable == "1" && ( + ["YEAR", "MONTH", "DAY"].includes(item.key)), it => ({ ...it, showname: it.showname.substr(2, 1) }))} + value={dateSerial.key} + detailtype={3} + supportCancel + onChange={(key) => + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + dateSerial: { + ...dateSerial, + key, + }, + }, + }) + } + /> + )} + +
+
+
+ } + { + !_.isEmpty(_.filter(options, item => !["YEAR", "MONTH", "DAY"].includes(item.key))) && +
+ +
+ + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + deptSerial: { + ...deptSerial, + enable: isSingle, + }, + }, + }) + } + /> + {deptSerial.enable == "1" && ( + ["SUBCOMPANY", "DEPARTMENT"].includes(item.key)), it => ({ ...it, showname: it.showname.substr(0, 2) }))} + value={deptSerial.key} + detailtype={3} + supportCancel + onChange={(key) => + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + deptSerial: { + ...deptSerial, + key, + }, + }, + }) + } + /> + )} + +
+
+
+ } +
+
+ )} +
+ + (this.numberSetRef = dom)} + onSet={this.handleSetNumber} + companyInfo={subCompanyInfo} + loading={loading} + startNumberInfo={startNumberInfo} + onChange={this.handleChangeTable} + onSaveStartNumber={this.handleSubmitStartNumber} + onDeleteReservedNumber={this.deleteReservedNumber} + onAddReservedNumber={this.handleAddReservedNumber} + onSubmitReservedNumber={this.handleSubmitReservedNumber} + onSearchReservedNumberset={() => + numberSet.getSearchReservedCodeList({ + serialtype: "DEPARTMENT", + checkboxType: "multi", + }) + } + /> + +
+
+ )} +
+
+ ); + } +} diff --git a/pc4mobx/organization/components/deptNumberSet/index.js b/pc4mobx/organization/components/numberSetting/postNumberSet/index.js similarity index 62% rename from pc4mobx/organization/components/deptNumberSet/index.js rename to pc4mobx/organization/components/numberSetting/postNumberSet/index.js index 4a384a2..9bb1745 100644 --- a/pc4mobx/organization/components/deptNumberSet/index.js +++ b/pc4mobx/organization/components/numberSetting/postNumberSet/index.js @@ -1,8 +1,8 @@ /* * Author: 黎永顺 - * Description: 部门编号设置 + * Description: 岗位编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-07 17:44:30 + * LastEditTime: 2022-06-15 12:47:43 */ import React, { Component, Fragment } from "react"; import { inject, observer } from "mobx-react"; @@ -17,13 +17,14 @@ import { } from "ecCom"; import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; import NumberComposition from "../branchNumSetting/components/numberComposition"; -import { i18n } from "../../public/i18n"; -import moment from 'moment'; +import { serialFieldOptions } from "../constants"; +import { i18n } from "../../../public/i18n"; +import moment from "moment"; import "../branchNumSetting/index.less"; @inject("numberSet") @observer -export default class DeptNumberSet extends Component { +export default class PostNumberSet extends Component { constructor() { super(); this.state = { @@ -52,7 +53,7 @@ export default class DeptNumberSet extends Component { getCodeSetting = () => { const { numberSet } = this.props; numberSet - .getCodeSetting({ serialtype: "DEPARTMENT" }) + .getCodeSetting({ serialtype: "JOBTITLES" }) .then(({ api_status, details, serialenable, dateSerial = {} }) => { if (api_status && !_.isEmpty(details)) { this.setState({ @@ -63,32 +64,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: "JOBTITLES", + }), }; + 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) => { @@ -108,29 +115,39 @@ 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 }, - }); - } + handleSetNumber = (type, data = {}) => { + this.handleSubmit().then(() => { + 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: 4, + 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: "", + }; + numberSet + .getStartNumForm(payload) + .then(({ api_status, columns, dataSource }) => { + if (api_status) { + this.setState({ + startNumberInfo: { columns, dataSource }, + }); + } + }); + } else { + numberSet.getAdvanceSearchCondition(); + numberSet.getSearchReservedCodeList({ + serialtype: "JOBTITLES", + checkboxType: "multi", }); - } + } + }); }; handleChangeTable = (newColumns, datas) => { this.setState({ @@ -146,7 +163,7 @@ export default class DeptNumberSet extends Component { const { numberSet } = this.props; const payload = { datas: JSON.stringify({ - coderuleid: 2, + coderuleid: 4, ...this.state.startNumberInfo, }), }; @@ -157,6 +174,76 @@ 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: "JOBTITLES", + checkboxType: "multi", + }); + } + }); + }; + /** + * name:新增预留编号 + * return {*} + */ + handleAddReservedNumber = () => { + const { numberSet } = this.props; + const { reservedForm } = numberSet; + const { options } = this.state; + numberSet.getReservedCodeFrom({ serialtype: "JOBTITLES" }).then(() => { + const type = _.get(_.last(options), ['key']); + const format = type === "YEAR" ? "YYYY" : type === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD" + const payload = { + coderuleid: 4, + 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: 保存预留设置 + * param {*} params + * return {*} + */ + handleSubmitReservedNumber = (params) => { + const { numberSet } = this.props; + const payload = { ...params, serialtype: "JOBTITLES" }; + numberSet.saveReservedCode(payload).then(({ api_status }) => { + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleCloseReservedModal(); + numberSet.getSearchReservedCodeList({ + serialtype: "JOBTITLES", + checkboxType: "multi", + }); + } + }); + }; /** * name:提示文本 @@ -174,6 +261,7 @@ export default class DeptNumberSet extends Component { ); }; render() { + const { numberSet } = this.props; const { options, subCompanyInfo, loading, startNumberInfo } = this.state; const { details, serialenable, dateSerial } = subCompanyInfo; const btns = [ @@ -193,7 +281,7 @@ export default class DeptNumberSet extends Component { return (
} iconBgcolor="#217346" buttons={btns} @@ -203,7 +291,7 @@ export default class DeptNumberSet extends Component {
@@ -254,6 +343,7 @@ export default class DeptNumberSet extends Component { dateSerial: { ...dateSerial, enable: isSingle, + key: isSingle == '0' ? 'YEAR' : dateSerial.key }, }, }) @@ -261,7 +351,7 @@ export default class DeptNumberSet extends Component { /> {dateSerial.enable == "1" && ( ({ ...item, showname: item.showname.substr(2, 1) }))} value={dateSerial.key} detailtype={3} supportCancel @@ -297,9 +387,20 @@ export default class DeptNumberSet extends Component { (this.numberSetRef = dom)} onSet={this.handleSetNumber} + companyInfo={subCompanyInfo} + loading={loading} startNumberInfo={startNumberInfo} onChange={this.handleChangeTable} onSaveStartNumber={this.handleSubmitStartNumber} + onDeleteReservedNumber={this.deleteReservedNumber} + onAddReservedNumber={this.handleAddReservedNumber} + onSubmitReservedNumber={this.handleSubmitReservedNumber} + onSearchReservedNumberset={() => + numberSet.getSearchReservedCodeList({ + serialtype: "JOBTITLES", + checkboxType: "multi", + }) + } />
diff --git a/pc4mobx/organization/components/numberSetting/resourceNumberSet/index.js b/pc4mobx/organization/components/numberSetting/resourceNumberSet/index.js new file mode 100644 index 0000000..d1245a2 --- /dev/null +++ b/pc4mobx/organization/components/numberSetting/resourceNumberSet/index.js @@ -0,0 +1,529 @@ +/* + * Author: 黎永顺 + * Description: 岗位编号设置 + * Date: 2022-06-06 09:37:39 + * LastEditTime: 2022-06-15 10:36:30 + */ +import React, { Component, Fragment } from "react"; +import { inject, observer } from "mobx-react"; +import { Button, message } from "antd"; +import { + WeaTop, + WeaFormItem, + WeaCheckbox, + WeaSearchGroup, + WeaSelect, + WeaHelpfulTip, +} 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 resourceSerialFieldOptions = [ + { key: 'subcompany', showname: "分部编号" }, + { key: 'department', showname: "部门编号" }, + { key: 'jobtitles', showname: "岗位编号" } +] + +@inject("numberSet") +@observer +export default class ResourceNumberSet extends Component { + constructor() { + super(); + this.state = { + options: [], + loading: false, + dataSource: [], + startNumberInfo: { + columns: [], + dataSource: [], + }, + subCompanyInfo: { + details: [], + serialenable: "0", + deptSerial: { + enable: "0", + key: "", + }, + jobtitlesSerial: { + enable: "0", + key: "", + }, + dateSerial: { + enable: "0", + key: "", + }, + }, + }; + } + + componentDidMount() { + this.getCodeSetting(); + } + + getCodeSetting = () => { + const { numberSet } = this.props; + numberSet + .getCodeSetting({ serialtype: "USER" }) + .then(({ api_status, details, serialenable, dateSerial = {}, jobtitlesSerial = {}, deptSerial = {} }) => { + if (api_status && !_.isEmpty(details)) { + this.setState({ + subCompanyInfo: { details, serialenable, dateSerial, jobtitlesSerial, deptSerial }, + }); + } + }); + }; + + handleSubmit = () => { + let promise = new Promise((resolve, reject) => { + const { numberSet } = this.props; + const { dataSource, subCompanyInfo } = this.state; + const { serialenable, dateSerial, jobtitlesSerial, deptSerial } = 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, + jobtitlesSerial, deptSerial, + serialtype: "USER", + }), + }; + this.setState({ loading: true }); + numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { + this.setState({ loading: false }); + if (api_status) { + message.success("保存成功"); + resolve(api_status); + } else { + reject("接口调用失败"); + } + }); + }); + return promise; + }; + + handleChangeCode = (data) => { + const tmpV = _.filter( + data, + (it) => + it.numField === "year" || + it.numField === "month" || + it.numField === "day" || + it.numField === "subcompany" || + it.numField === "department" || + it.numField === "jobtitles" + ); + this.setState({ + dataSource: _.cloneDeep(data), + options: _.map(tmpV, (it) => { + const { numFieldName: showname, numField: key } = it; + return { key: _.upperCase(key), showname }; + }), + }); + }; + + handleSetNumber = (type, data = {}) => { + this.handleSubmit().then(() => { + const { numberSet } = this.props; + const { subCompanyInfo } = this.state; + const { dateSerial, deptSerial, jobtitlesSerial } = subCompanyInfo; + if (type === "start") { + const formatVal = dateSerial.key === "YEAR" ? "YYYY" : dateSerial.key === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD"; + let payload = { + coderuleid: 3, + 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: data.deptId ? data.deptId : "", + jobtitlesId: data.jobtitlesId ? data.jobtitlesId : "", + }; + if (deptSerial.enable === '1' && deptSerial.key === 'SUBCOMPANY' && !data.subCompanyId) return + if (deptSerial.enable === '1' && deptSerial.key === 'DEPARTMENT' && !data.deptId) return + if (jobtitlesSerial.enable === '1' && !data.jobtitlesId) return + if (deptSerial.enable === '1' && data.subCompanyId) { + payload = { ...payload, type: payload.type + ',' + deptSerial.key } + } + if (jobtitlesSerial.enable === '1' && data.jobtitlesId) { + payload = { ...payload, type: payload.type + ',' + jobtitlesSerial.key } + } + numberSet + .getStartNumForm(payload) + .then(({ api_status, columns, dataSource }) => { + if (api_status) { + this.setState({ + startNumberInfo: { columns, dataSource }, + }); + } + }); + } else { + numberSet.getAdvanceSearchCondition(); + numberSet.getSearchReservedCodeList({ + serialtype: "USER", + checkboxType: "multi", + }); + } + }); + }; + + handleChangeTable = (newColumns, datas) => { + this.setState({ + startNumberInfo: { + ...this.state.startNumberInfo, + columns: newColumns, + dataSource: datas, + }, + }); + }; + + handleSubmitStartNumber = () => { + const { numberSet } = this.props; + const payload = { + datas: JSON.stringify({ + coderuleid: 4, + ...this.state.startNumberInfo, + }), + }; + numberSet.saveStartNum(payload).then(({ api_status }) => { + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleClose(); + } + }); + }; + + /** + * name: 删除预留编号 + * param {*} ids + * return {*} + */ + deleteReservedNumber = (ids) => { + const { numberSet } = this.props; + numberSet.deleteReservedCodeById({ ids }).then(({ api_status }) => { + if (api_status) { + message.success("删除成功"); + numberSet.getSearchReservedCodeList({ + serialtype: "USER", + checkboxType: "multi", + }); + } + }); + }; + /** + * name:新增预留编号 + * return {*} + */ + handleAddReservedNumber = () => { + const { numberSet } = this.props; + const { reservedForm } = numberSet; + const { options } = this.state; + numberSet.getReservedCodeFrom({ serialtype: "USER" }).then(() => { + const type = _.get(_.last(options), ['key']); + const format = type === "YEAR" ? "YYYY" : type === "MONTH" ? "YYYY-MM" : "YYYY-MM-DD" + const payload = { + coderuleid: 3, + 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: 保存预留设置 + * param {*} params + * return {*} + */ + handleSubmitReservedNumber = (params) => { + const { numberSet } = this.props; + const payload = { ...params, serialtype: "USER" }; + numberSet.saveReservedCode(payload).then(({ api_status }) => { + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleCloseReservedModal(); + numberSet.getSearchReservedCodeList({ + serialtype: "USER", + checkboxType: "multi", + }); + } + }); + }; + + /** + * name:提示文本 + * return {*} + */ + helpContent = () => { + return ( +
+

开启后,可根据设置的部门编号规则自动生成部门编号,涉及场景如下:

+

1.手动新建和手动编辑部门时可选择重新生成编号和选择预留部门编号;

+

2.导入人员-添加时,新创建的部门可自动生成部门编号;

+

3.组织结构导入-添加新部门且部门编号列为空时可自动生成部门编号;

+

【注意】开启前请先确认部门编号字段已启用!

+
+ ); + }; + render() { + const { options, subCompanyInfo, loading, startNumberInfo } = this.state; + const { numberSet } = this.props; + const { details, serialenable, dateSerial, jobtitlesSerial, deptSerial } = subCompanyInfo; + const btns = [ + , + ]; + const dropMenuDatas = [ + { + key: "save", + disabled: false, + icon: , + content: "保存", + onClick: (key) => this.handleSubmit(), + }, + ]; + return ( +
+ } + iconBgcolor="#217346" + buttons={btns} + showDropIcon={true} + dropMenuDatas={dropMenuDatas} + /> +
+
+ + + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + serialenable: checkVal, + }, + }) + } + /> + +
+ {/* 内容区 */} + {serialenable === "1" && ( + +
+ + + +
+ {!_.isEmpty(options) && ( +
+ + { + !_.isEmpty(_.filter(options, item => ["YEAR", "MONTH", "DAY"].includes(item.key))) && +
!["YEAR", "MONTH", "DAY"].includes(item.key))) && 0 }}> + +
+ + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + dateSerial: { + ...dateSerial, + enable: isSingle, + key: isSingle == '0' ? 'YEAR' : dateSerial.key + }, + }, + }) + } + /> + {dateSerial.enable == "1" && ( + ["YEAR", "MONTH", "DAY"].includes(item.key)), it => ({ ...it, showname: it.showname.substr(2, 1) }))} + value={dateSerial.key} + detailtype={3} + supportCancel + onChange={(key) => + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + dateSerial: { + ...dateSerial, + key, + }, + }, + }) + } + /> + )} + +
+
+
+ } + { + !_.isEmpty(_.filter(options, item => ["SUBCOMPANY", "DEPARTMENT"].includes(item.key))) && +
!["JOBTITLES"].includes(item.key))) && 0 }}> + +
+ + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + deptSerial: { + ...deptSerial, + enable: isSingle, + }, + }, + }) + } + /> + {deptSerial.enable == "1" && ( + ["SUBCOMPANY", "DEPARTMENT"].includes(item.key)), it => ({ ...it, showname: it.showname.substr(0, 2) }))} + value={deptSerial.key} + detailtype={3} + supportCancel + onChange={(key) => + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + deptSerial: { + ...deptSerial, + key, + }, + }, + }) + } + /> + )} + +
+
+
+ } + { + !_.isEmpty(_.filter(options, item => ["JOBTITLES"].includes(item.key))) && +
+ +
+ + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + jobtitlesSerial: { + ...jobtitlesSerial, + enable: isSingle, + }, + }, + }) + } + /> + +
+
+
+ } +
+
+ )} +
+ + (this.numberSetRef = dom)} + onSet={this.handleSetNumber} + companyInfo={subCompanyInfo} + loading={loading} + startNumberInfo={startNumberInfo} + onChange={this.handleChangeTable} + onSaveStartNumber={this.handleSubmitStartNumber} + onDeleteReservedNumber={this.deleteReservedNumber} + onAddReservedNumber={this.handleAddReservedNumber} + onSubmitReservedNumber={this.handleSubmitReservedNumber} + onSearchReservedNumberset={() => + numberSet.getSearchReservedCodeList({ + serialtype: "USER", + checkboxType: "multi", + }) + } + /> + +
+
+ )} +
+
+ ); + } +} diff --git a/pc4mobx/organization/components/postNumberSet/index.js b/pc4mobx/organization/components/postNumberSet/index.js deleted file mode 100644 index 5866c6c..0000000 --- a/pc4mobx/organization/components/postNumberSet/index.js +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Author: 黎永顺 - * Description: 岗位编号设置 - * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-07 18:13:32 - */ -import React, { Component, Fragment } from "react"; -import { inject, observer } from "mobx-react"; -import { Button, message } from "antd"; -import { - WeaTop, - WeaFormItem, - WeaCheckbox, - WeaSearchGroup, - WeaSelect, - WeaHelpfulTip, -} from "ecCom"; -import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; -import NumberComposition from "../branchNumSetting/components/numberComposition"; -import { i18n } from "../../public/i18n"; -import moment from "moment"; -import "../branchNumSetting/index.less"; - -@inject("numberSet") -@observer -export default class PostNumberSet extends Component { - constructor() { - super(); - this.state = { - options: [], - loading: false, - dataSource: [], - startNumberInfo: { - columns: [], - dataSource: [], - }, - subCompanyInfo: { - details: [], - serialenable: "0", - dateSerial: { - enable: "0", - key: "", - }, - }, - }; - } - - componentDidMount() { - this.getCodeSetting(); - } - - getCodeSetting = () => { - const { numberSet } = this.props; - numberSet - .getCodeSetting({ serialtype: "JOBTITLES" }) - .then(({ api_status, details, serialenable, dateSerial = {} }) => { - if (api_status && !_.isEmpty(details)) { - this.setState({ - subCompanyInfo: { details, serialenable, dateSerial }, - }); - } - }); - }; - - 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, - }; - }); - const payload = { - datas: JSON.stringify({ - serialenable, - details, - dateSerial, - serialtype: "JOBTITLES", - }), - }; - this.setState({ loading: true }); - numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { - this.setState({ loading: false }); - if (api_status) { - message.success("保存成功"); - } - }); - }; - - handleChangeCode = (data) => { - const tmpV = _.filter( - data, - (it) => - it.numField === "year" || - it.numField === "month" || - it.numField === "day" - ); - this.setState({ - dataSource: _.cloneDeep(data), - options: _.map(tmpV, (it) => { - const { numFieldName: showname, numField: key } = it; - return { key: _.upperCase(key), showname }; - }), - }); - }; - - handleSetNumber = (type) => { - this.handleSubmit(); - const { numberSet } = this.props; - if (type === "start") { - const payload = { - coderuleid: 3, - 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 }, - }); - } - }); - } - }; - handleChangeTable = (newColumns, datas) => { - this.setState({ - startNumberInfo: { - ...this.state.startNumberInfo, - columns: newColumns, - dataSource: datas, - }, - }); - }; - - handleSubmitStartNumber = () => { - const { numberSet } = this.props; - const payload = { - datas: JSON.stringify({ - coderuleid: 3, - ...this.state.startNumberInfo, - }), - }; - numberSet.saveStartNum(payload).then(({ api_status }) => { - if (api_status) { - message.success("保存成功"); - this.numberSetRef.handleClose(); - } - }); - }; - - /** - * name:提示文本 - * return {*} - */ - helpContent = () => { - return ( -
-

开启后,可根据设置的岗位编号规则自动生成岗位编号,涉及场景如下:

-

1.新建岗位和编辑岗位时可选择重新生成编号和选择预留编号;

-

2.导入人员-添加时,新创建的岗位可自动生成岗位编号;

-

3.岗位导入新岗位且岗位编号列为空时可自动生成编号;

-
- ); - }; - render() { - const { options, subCompanyInfo, loading, startNumberInfo } = this.state; - const { details, serialenable, dateSerial } = subCompanyInfo; - const btns = [ - , - ]; - const dropMenuDatas = [ - { - key: "save", - disabled: false, - icon: , - content: "保存", - onClick: (key) => this.handleSubmit(), - }, - ]; - return ( -
- } - iconBgcolor="#217346" - buttons={btns} - showDropIcon={true} - dropMenuDatas={dropMenuDatas} - /> -
-
- - - this.setState({ - subCompanyInfo: { - ...subCompanyInfo, - serialenable: checkVal, - }, - }) - } - /> - -
- {/* 内容区 */} - {serialenable === "1" && ( - -
- - - -
- {!_.isEmpty(options) && ( -
- -
- -
- - this.setState({ - subCompanyInfo: { - ...subCompanyInfo, - dateSerial: { - ...dateSerial, - enable: isSingle, - }, - }, - }) - } - /> - {dateSerial.enable == "1" && ( - - this.setState({ - subCompanyInfo: { - ...subCompanyInfo, - dateSerial: { - ...dateSerial, - key, - }, - }, - }) - } - /> - )} - -
-
-
-
-
- )} -
- - (this.numberSetRef = dom)} - onSet={this.handleSetNumber} - startNumberInfo={startNumberInfo} - onChange={this.handleChangeTable} - onSaveStartNumber={this.handleSubmitStartNumber} - /> - -
-
- )} -
-
- ); - } -} diff --git a/pc4mobx/organization/components/resourceNumberSet/index.js b/pc4mobx/organization/components/resourceNumberSet/index.js deleted file mode 100644 index dda9ed6..0000000 --- a/pc4mobx/organization/components/resourceNumberSet/index.js +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Author: 黎永顺 - * Description: 岗位编号设置 - * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-07 18:12:11 - */ -import React, { Component, Fragment } from "react"; -import { inject, observer } from "mobx-react"; -import { Button, message } from "antd"; -import { - WeaTop, - WeaFormItem, - WeaCheckbox, - WeaSearchGroup, - WeaSelect, - WeaHelpfulTip, -} from "ecCom"; -import StartReservedNumberSet from "../branchNumSetting/components/startReservedNumberSet"; -import NumberComposition from "../branchNumSetting/components/numberComposition"; -import { i18n } from "../../public/i18n"; -import moment from "moment"; -import "../branchNumSetting/index.less"; - -@inject("numberSet") -@observer -export default class ResourceNumberSet extends Component { - constructor() { - super(); - this.state = { - options: [], - loading: false, - dataSource: [], - startNumberInfo: { - columns: [], - dataSource: [], - }, - subCompanyInfo: { - details: [], - serialenable: "0", - dateSerial: { - enable: "0", - key: "", - }, - }, - }; - } - - componentDidMount() { - this.getCodeSetting(); - } - - getCodeSetting = () => { - const { numberSet } = this.props; - numberSet - .getCodeSetting({ serialtype: "USER" }) - .then(({ api_status, details, serialenable, dateSerial = {} }) => { - if (api_status && !_.isEmpty(details)) { - this.setState({ - subCompanyInfo: { details, serialenable, dateSerial }, - }); - } - }); - }; - - 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, - }; - }); - const payload = { - datas: JSON.stringify({ - serialenable, - details, - dateSerial, - serialtype: "USER", - }), - }; - this.setState({ loading: true }); - numberSet.saveOrUpdateCodeSetting(payload).then(({ api_status }) => { - this.setState({ loading: false }); - if (api_status) { - message.success("保存成功"); - } - }); - }; - - handleChangeCode = (data) => { - const tmpV = _.filter( - data, - (it) => - it.numField === "year" || - it.numField === "month" || - it.numField === "day" - ); - this.setState({ - dataSource: _.cloneDeep(data), - options: _.map(tmpV, (it) => { - const { numFieldName: showname, numField: key } = it; - return { key: _.upperCase(key), showname }; - }), - }); - }; - - handleSetNumber = (type) => { - this.handleSubmit(); - const { numberSet } = this.props; - if (type === "start") { - const payload = { - coderuleid: 4, - 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 }, - }); - } - }); - } - }; - handleChangeTable = (newColumns, datas) => { - this.setState({ - startNumberInfo: { - ...this.state.startNumberInfo, - columns: newColumns, - dataSource: datas, - }, - }); - }; - - handleSubmitStartNumber = () => { - const { numberSet } = this.props; - const payload = { - datas: JSON.stringify({ - coderuleid: 4, - ...this.state.startNumberInfo, - }), - }; - numberSet.saveStartNum(payload).then(({ api_status }) => { - if (api_status) { - message.success("保存成功"); - this.numberSetRef.handleClose(); - } - }); - }; - - /** - * name:提示文本 - * return {*} - */ - helpContent = () => { - return ( -
-

开启后,可根据设置的人员编号规则自动生成人员编号,涉及场景如下:

-

1.手动新建和手动编辑人员时可选择自动生成和选择预留人员编号;

-

- 2.导入人员类型选择-添加,导入Excel中人员编号为空时,可自动生成人员编号; -

-

3.人员入职流程中人员编号字段为空时可自动生成人员编号;

-
- ); - }; - render() { - const { options, subCompanyInfo, loading, startNumberInfo } = this.state; - const { details, serialenable, dateSerial } = subCompanyInfo; - const btns = [ - , - ]; - const dropMenuDatas = [ - { - key: "save", - disabled: false, - icon: , - content: "保存", - onClick: (key) => this.handleSubmit(), - }, - ]; - return ( -
- } - iconBgcolor="#217346" - buttons={btns} - showDropIcon={true} - dropMenuDatas={dropMenuDatas} - /> -
-
- - - this.setState({ - subCompanyInfo: { - ...subCompanyInfo, - serialenable: checkVal, - }, - }) - } - /> - -
- {/* 内容区 */} - {serialenable === "1" && ( - -
- - - -
- {!_.isEmpty(options) && ( -
- -
- -
- - this.setState({ - subCompanyInfo: { - ...subCompanyInfo, - dateSerial: { - ...dateSerial, - enable: isSingle, - }, - }, - }) - } - /> - {dateSerial.enable == "1" && ( - - this.setState({ - subCompanyInfo: { - ...subCompanyInfo, - dateSerial: { - ...dateSerial, - key, - }, - }, - }) - } - /> - )} - -
-
-
-
-
- )} -
- - (this.numberSetRef = dom)} - onSet={this.handleSetNumber} - startNumberInfo={startNumberInfo} - onChange={this.handleChangeTable} - onSaveStartNumber={this.handleSubmitStartNumber} - /> - -
-
- )} -
-
- ); - } -} diff --git a/pc4mobx/organization/index.js b/pc4mobx/organization/index.js index 917c942..e51c7ef 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 StaffScheme from "./components/staff/StaffScheme"; import Staff from "./components/staff/Staff"; diff --git a/pc4mobx/organization/stores/numberSet.js b/pc4mobx/organization/stores/numberSet.js index 55917a5..6a8610a 100644 --- a/pc4mobx/organization/stores/numberSet.js +++ b/pc4mobx/organization/stores/numberSet.js @@ -2,13 +2,74 @@ * Author: 黎永顺 * Description: 编号设置 * Date: 2022-06-07 09:54:46 - * LastEditTime: 2022-06-07 17:00:49 + * LastEditTime: 2022-06-15 13:09:28 */ import { observable, action } from "mobx"; +import { WeaForm } from "comsMobx"; +import { WeaTableNew } from "comsMobx"; import * as mobx from "mobx"; import * as API from "../apis/numberSet"; // 引入API接口文件 +const { TableStore } = WeaTableNew; + export class NumberSetStore { + @observable searchCondition = []; //高级搜索框form数据 + @observable tableStore = new TableStore(); //列表store + @observable form = new WeaForm(); //高级搜索渲染的表单 + @observable condition = []; //新增职务信息form数据 + @observable reservedForm = new WeaForm(); //新增预留编号表单 + + @action("高级搜索表单渲染") + getAdvanceSearchCondition() { + API.getAdvanceSearchCondition().then(({ api_status, conditions }) => { + if (api_status && !_.isEmpty(conditions)) { + this.setSearchCondition(conditions); + this.form.initFormFields(conditions); + } + }); + } + + @action("获取表格数据") + getSearchReservedCodeList(params) { + const payload = { + ...this.form.getFormParams(), + ...params, + }; + API.getSearchReservedCodeList(payload).then( + ({ api_status, sessionkey }) => { + if (api_status && !_.isEmpty(sessionkey)) { + this.tableStore.getDatas(sessionkey, 1); + } + } + ); + } + + @action("新增预留编号表单查询") + getReservedCodeFrom(payload) { + return API.getReservedCodeFrom(payload).then(({ api_status, conditioninfo }) => { + if (api_status && !_.isEmpty(conditioninfo)) { + conditioninfo.map((c) => + c.items.map((item) => { + if (item.domkey[0] == "YEAR") { + item.value = item.value.toString(); + } + }) + ); + this.setCondition(conditioninfo); + this.reservedForm.initFormFields(conditioninfo); + } + }); + } + @action + setCondition(condition) { + this.condition = condition; + } + + @action + setSearchCondition(condition) { + this.searchCondition = condition; + } + @action getCodeSetting(params) { return API.getCodeSetting(params); @@ -23,8 +84,19 @@ export class NumberSetStore { getStartNumForm(params) { return API.getStartNumForm(params); } + @action saveStartNum(params) { return API.saveStartNum(params); } -} + + @action("删除预留编号") + deleteReservedCodeById(params) { + return API.deleteReservedCodeById(params); + } + + @action("保存预留编号") + saveReservedCode(params) { + return API.saveReservedCode(params); + } +} \ No newline at end of file