diff --git a/pc4mobx/organization/apis/numberSet.js b/pc4mobx/organization/apis/numberSet.js new file mode 100644 index 0000000..d300660 --- /dev/null +++ b/pc4mobx/organization/apis/numberSet.js @@ -0,0 +1,50 @@ +/* + * Author: 黎永顺 + * Description: + * Date: 2022-06-07 09:52:01 + * LastEditTime: 2022-06-07 17:00:34 + */ +import { WeaTools } from "ecCom"; + +/** + * name:获取编号设置 + * param {*} params serialtype, SUBCOMPANY:分部 + * return {*} + */ +export const getCodeSetting = (params) => { + return WeaTools.callApi("/api/hrm/codeSetting/getCodeSetting", "GET", params); +}; + +/** + * name: 保存编号设置 + * param {*} params + * return {*} + */ +export const saveOrUpdateCodeSetting = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/saveOrUpdateCodeSetting", + "POST", + params + ); +}; +/** + * name: 保存起始编号设置 + * param {*} params + * return {*} + */ +export const saveStartNum = (params) => { + return WeaTools.callApi("/api/hrm/codeSetting/saveStartNum", "POST", params); +}; + +/** + * name: 起始编号设置 + * param {*} params + * return {*} + */ +export const getStartNumForm = (params) => { + return WeaTools.callApi( + "/api/hrm/codeSetting/getStartNumForm", + "GET", + params + ); +}; diff --git a/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js b/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js index 25f9140..4bf954b 100644 --- a/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js +++ b/pc4mobx/organization/components/branchNumSetting/components/numberComposition.js @@ -2,7 +2,7 @@ * Author: 黎永顺 * Description: * Date: 2022-05-17 16:02:56 - * LastEditTime: 2022-05-18 18:03:07 + * LastEditTime: 2022-06-07 15:30:43 */ import React, { Component, Fragment } from "react"; import { Button, Modal } from "antd"; @@ -13,21 +13,13 @@ import { WeaFormItem, WeaSelect, WeaInput, + WeaInputNumber, } from "ecCom"; import Preview from "./preview"; import { i18n } from "../../../public/i18n"; import _ from "lodash"; import "../index.less"; -const dataSource = [ - { - value: "", - numFieldName: "字符串", - numField: "string", - }, - { value: "3", numFieldName: "流水号位数", numField: "number" }, -]; - const options = [ { key: "string", @@ -51,12 +43,69 @@ class NumberComposition extends Component { super(); this.state = { visible: false, - numField: "string", - numFieldName: "字符串", - dataSource, + objectData: { + numField: "string", + numFieldName: "字符串", + }, + dataSource: [], }; } + componentDidMount() { + const enums = { + STRING: "字符串", + NUMBER: "流水号位数", + YEAR: "当前年份", + MONTH: "当前月份", + DAY: "当前日期", + }; + let num = 0; + const { dataSource: details, onChange } = this.props; + for (let i in details) { + if (details[i].ruletype === "STRING") { + details[i].showorder = num; + num++; + } + } + const tmpV = _.map(details, (it, index) => { + const { ruletype, rulevalue, showorder } = it; + return { + id: index, + value: rulevalue, + strLogo: Number(showorder) + 1, + numFieldName: + ruletype === "STRING" + ? `${enums[ruletype]}${Number(showorder) + 1}` + : enums[ruletype], + numField: _.toLower(ruletype), + }; + }); + this.setState( + { + dataSource: !_.isEmpty(tmpV) + ? tmpV + : [ + { + id: 1, + value: "", + strLogo: 1, + numFieldName: "字符串1", + numField: "string", + }, + { + id: 2, + value: 3, + numFieldName: "流水号位数", + numField: "number", + }, + ], + }, + () => { + onChange && onChange(this.state.dataSource); + } + ); + } + /** * name:复选框禁用 * param undefined @@ -82,20 +131,26 @@ class NumberComposition extends Component { * return {*} */ handleSave = () => { - const { numField, numFieldName, dataSource } = this.state; - const objWrite = { - value: "", - numFieldName, - numField, - }; - const objView = { - com: { - value: [{ key: numField, label: "", type: "TEXT" }], - }, - [numField]: "", - numFieldName, - numField, - }; + let newDataSource = []; + const { objectData, dataSource } = this.state; + const { onChange } = this.props; + const { numField, numFieldName } = objectData; + const stringRow = _.filter(dataSource, (it) => it.numField === "string"); //字符串列表 + const maxStrLen = !_.isEmpty(stringRow) + ? _.sortBy(stringRow, function (o) { + return -o.strLogo; + })[0].strLogo + : 0; //字符串列表 + const maxIdLen = _.sortBy(dataSource, function (o) { + return -o.id; + })[0].id; //字符串列表 + + const index = _.findIndex(dataSource, (item) => item.numField !== "string"); + const lastStrindex = _.findLastIndex( + dataSource, + (item) => item.numField === "string" + ); + if (numField === "year" || numField === "month" || numField === "day") { const hasYearOrMonthOrDay = _.some( dataSource, @@ -122,87 +177,158 @@ class NumberComposition extends Component { }); return; } - this.setState({ - visible: false, - numField: "string", - numFieldName: "字符串", - dataSource: [...dataSource, objView], - }); } else { this.showConfirm(); + return; } - } else { - this.setState({ - visible: false, - numField: "string", - numFieldName: "字符串", - dataSource: [...dataSource, objWrite], - }); } + + // 如果前n项为空或者当中包含非字符串项,则 + if (index > lastStrindex) { + if (numField === "month") { + const tmpVLastYearindex = _.findLastIndex( + dataSource, + (item) => item.numField === "year" + ); + dataSource.splice(tmpVLastYearindex + 1, 0, { + id: maxIdLen + 1, + value: "", + numFieldName: + numField === "string" + ? `${numFieldName}${stringRow.length + 1}` + : numFieldName, + numField, + }); + } else if (numField === "day") { + const tmpVLastMonthindex = _.findLastIndex( + dataSource, + (item) => item.numField === "month" + ); + dataSource.splice(tmpVLastMonthindex + 1, 0, { + id: maxIdLen + 1, + value: "", + numFieldName: + numField === "string" + ? `${numFieldName}${stringRow.length + 1}` + : numFieldName, + numField, + }); + } else { + const tmpVLastStrindex = _.findLastIndex( + dataSource, + (item) => item.numField === "string" + ); + dataSource.splice(tmpVLastStrindex + 1, 0, { + id: maxIdLen + 1, + value: "", + strLogo: maxStrLen + 1, + numFieldName: + numField === "string" + ? `${numFieldName}${maxStrLen + 1}` + : numFieldName, + numField, + }); + } + newDataSource = [...dataSource]; + } else { + if (numField === "month") { + const tmpVLastYearindex = _.findLastIndex( + dataSource, + (item) => item.numField === "year" + ); + dataSource.splice(tmpVLastYearindex + 1, 0, { + id: maxIdLen + 1, + value: "", + numFieldName: + numField === "string" + ? `${numFieldName}${stringRow.length + 1}` + : numFieldName, + numField, + }); + } else if (numField === "day") { + const tmpVLastMonthindex = _.findLastIndex( + dataSource, + (item) => item.numField === "month" + ); + dataSource.splice(tmpVLastMonthindex + 1, 0, { + id: maxIdLen + 1, + value: "", + numFieldName: + numField === "string" + ? `${numFieldName}${stringRow.length + 1}` + : numFieldName, + numField, + }); + } else { + const tmpVLastStrindex = _.findLastIndex( + dataSource, + (item) => item.numField === "string" + ); + dataSource.splice(tmpVLastStrindex, 0, { + id: maxIdLen + 1, + value: "", + strLogo: maxStrLen + 1, + numFieldName: + numField === "string" + ? `${numFieldName}${maxStrLen + 1}` + : numFieldName, + numField, + }); + } + newDataSource = [...dataSource]; + } + this.setState({ + visible: false, + objectData: { numField: "string", numFieldName: "字符串" }, + dataSource: newDataSource, + }); + onChange && onChange(newDataSource); }; /** * name:年月日字段重复提示 * return {*} */ showConfirm = () => { - const { numFieldName } = this.state; + const { objectData } = this.state; Modal.warning({ title: "信息确认", - content: `已经添加过一个${numFieldName},请选择其他编号字段!`, + content: `已经添加过一个${objectData.numFieldName},请选择其他编号字段!`, footer: [], onOk() {}, okText: "确认", }); }; - /** - * name: 编号字段删除 - * return {*} - */ - handleDeleteTable = (keys, datas) => { + + handleChangeInput = (value, index, record) => { const { dataSource } = this.state; - const stringRow = _.filter(dataSource, (it) => it.numField === "string"); - const yearRow = _.filter(dataSource, (it) => it.numField === "year"); - const monthRow = _.filter(dataSource, (it) => it.numField === "month"); - const dayRow = _.filter(dataSource, (it) => it.numField === "day"); - const disableRow = _.filter(dataSource, (it) => it.numField === "number"); - const tmpV = [ - ...stringRow, - ...yearRow, - ...monthRow, - ...dayRow, - ...disableRow, - ]; - this.setState({ - dataSource: _.filter(tmpV, (it, idx) => !keys.includes(idx)), - }); + const { onChange } = this.props; + this.setState( + { + dataSource: _.map(dataSource, (it) => { + if (it.id === record.id) { + return { + ...it, + value, + }; + } + return { ...it }; + }), + }, + () => { + onChange && onChange(this.state.dataSource); + } + ); }; - handleChangeInput = (value, index) => { - const { dataSource } = this.state; - const stringRow = _.filter(dataSource, (it) => it.numField === "string"); - const yearRow = _.filter(dataSource, (it) => it.numField === "year"); - const monthRow = _.filter(dataSource, (it) => it.numField === "month"); - const dayRow = _.filter(dataSource, (it) => it.numField === "day"); - const disableRow = _.filter(dataSource, (it) => it.numField === "number"); - const tmpV = _.map( - [...stringRow, ...yearRow, ...monthRow, ...dayRow, ...disableRow], - (it, idx) => ({ ...it, key: idx }) - ); - this.setState({ - dataSource: _.map(tmpV, (it) => { - if (it.key === index) { - return { - ...it, - value, - }; - } - return { ...it }; - }), - }); + handleDragChange = (dataSource) => { + const { onChange } = this.props; + this.setState({ dataSource }); + onChange && onChange(dataSource); }; render() { - const { visible, numField, dataSource } = this.state; + const { visible, objectData, dataSource } = this.state; + const { numField, numFieldName } = objectData; const columns = [ { title: "", @@ -230,6 +356,17 @@ class NumberComposition extends Component { ) { return ; } + if (numField === "number") { + return ( + + this.handleChangeInput(value, index, record) + } + /> + ); + } return ( , ]; - const stringRow = _.map( - _.filter(dataSource, (it) => it.numField === "string"), - (item, index) => { - return { - ...item, - numFieldName: `${item.numFieldName}${index + 1}`, - }; - } - ); - const yearRow = _.filter(dataSource, (it) => it.numField === "year"); - const monthRow = _.filter(dataSource, (it) => it.numField === "month"); - const dayRow = _.filter(dataSource, (it) => it.numField === "day"); - const disableRow = _.filter(dataSource, (it) => it.numField === "number"); return ( {/* 预览 */} - + {/* 新增弹框 */} @@ -335,7 +442,7 @@ class NumberComposition extends Component { value={numField} viewAttr={2} onChange={(numField, numFieldName) => { - this.setState({ numField, numFieldName }); + this.setState({ objectData: { numField, numFieldName } }); }} /> diff --git a/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js b/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js new file mode 100644 index 0000000..2fb2365 --- /dev/null +++ b/pc4mobx/organization/components/branchNumSetting/components/startNumberSetting.js @@ -0,0 +1,40 @@ +/* + * 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/startReservedNumberSet.js b/pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js index b5cd812..b39d4a0 100644 --- a/pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js +++ b/pc4mobx/organization/components/branchNumSetting/components/startReservedNumberSet.js @@ -2,27 +2,117 @@ * Author: 黎永顺 * Description: 起始编号及预留编号设置 * Date: 2022-05-17 15:51:41 - * LastEditTime: 2022-05-17 16:01:33 + * LastEditTime: 2022-06-07 17:40:30 */ import React, { Component, Fragment } from "react"; -import { WeaFormItem } from "ecCom"; +import { Button, Modal } from "antd"; +import StartNumberSetting from "./startNumberSetting"; +import { WeaFormItem, WeaDialog, WeaMoreButton } from "ecCom"; +import { i18n } from "../../../public/i18n"; class StartReservedNumberSet extends Component { + constructor() { + super(); + this.state = { + dialogProps: { + type: "start", + visible: false, + title: "", + }, + }; + } + handleClickStartNumber = (type) => { + const { onSet } = this.props; + const { dialogProps } = this.state; + onSet && onSet(type); + this.setState({ + dialogProps: { + ...dialogProps, + type, + visible: true, + title: type === "start" ? "起始编号" : "预留编号", + }, + }); + }; + handleChangeTable = (newColumns, datas) => { + const { onChange } = this.props; + onChange && onChange(newColumns, datas); + }; + handleSave = () => { + const { onSaveStartNumber } = this.props; + onSaveStartNumber && onSaveStartNumber(); + }; + handleClose = () => { + this.setState({ + dialogProps: { + ...this.state.dialogProps, + visible: false, + }, + }); + }; render() { + const { dialogProps } = this.state; + const { type } = dialogProps; + const { startNumberInfo } = this.props; return ( - + this.handleClickStartNumber("start")}> - + this.handleClickStartNumber("reserved")}> + {/* 起始/预留编号设置 */} + + {i18n.button.save()} + , + , + ] + : [ + , + ] + }> + {type === "start" && ( + + )} + ); } diff --git a/pc4mobx/organization/components/branchNumSetting/index.js b/pc4mobx/organization/components/branchNumSetting/index.js index 960e39c..e8743e7 100644 --- a/pc4mobx/organization/components/branchNumSetting/index.js +++ b/pc4mobx/organization/components/branchNumSetting/index.js @@ -2,35 +2,161 @@ * Author: 黎永顺 * Description: 分部编号设置 * Date: 2022-05-17 14:30:57 - * LastEditTime: 2022-06-06 09:42:23 + * LastEditTime: 2022-06-07 17:49:14 */ import React, { Component, Fragment } from "react"; -import { Button } from "antd"; -import { WeaTop, WeaFormItem, WeaCheckbox, WeaSearchGroup } from "ecCom"; +import { inject, observer } from "mobx-react"; +import { Button, message } from "antd"; +import { + WeaTop, + WeaFormItem, + WeaCheckbox, + WeaSearchGroup, + WeaSelect, + WeaHelpfulTip, +} from "ecCom"; import StartReservedNumberSet from "./components/startReservedNumberSet"; import NumberComposition from "./components/numberComposition"; import { i18n } from "../../public/i18n"; +import moment from "moment"; import "./index.less"; -const btns = []; -const dropMenuDatas = [ - { - key: "save", - disabled: false, - icon: , - content: "保存", - onClick: (key) => alert(`点击了搜索 key = ${key}`), - }, -]; +@inject("numberSet") +@observer export default class BranchNumSetting extends Component { constructor() { super(); this.state = { - checkVal: "0", + options: [], + loading: false, + dataSource: [], + startNumberInfo: { + columns: [], + dataSource: [], + }, + subCompanyInfo: { + details: [], + serialenable: "0", + dateSerial: { + enable: "0", + key: "", + }, + }, }; } - componentDidMount() {} + componentDidMount() { + this.getCodeSetting(); + } + + getCodeSetting = () => { + const { numberSet } = this.props; + numberSet + .getCodeSetting({ serialtype: "SUBCOMPANY" }) + .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: "SUBCOMPANY", + }), + }; + 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: 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 }, + }); + } + }); + } + }; + handleChangeTable = (newColumns, datas) => { + this.setState({ + startNumberInfo: { + ...this.state.startNumberInfo, + columns: newColumns, + dataSource: datas, + }, + }); + }; + + handleSubmitStartNumber = () => { + const { numberSet } = this.props; + const payload = { + datas: JSON.stringify({ + coderuleid: 1, + ...this.state.startNumberInfo, + }), + }; + numberSet.saveStartNum(payload).then(({ api_status }) => { + if (api_status) { + message.success("保存成功"); + this.numberSetRef.handleClose(); + } + }); + }; /** * name:提示文本 @@ -49,7 +175,22 @@ export default class BranchNumSetting extends Component { }; render() { - const { checkVal } = this.state; + 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 (
this.setState({ checkVal })} + onChange={(checkVal) => + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + serialenable: checkVal, + }, + }) + } />
{/* 内容区 */} - {checkVal === "1" && ( + {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/deptNumberSet/index.js b/pc4mobx/organization/components/deptNumberSet/index.js index 17ce04c..4a384a2 100644 --- a/pc4mobx/organization/components/deptNumberSet/index.js +++ b/pc4mobx/organization/components/deptNumberSet/index.js @@ -1,11 +1,12 @@ /* * Author: 黎永顺 - * Description: 部门编号设 + * Description: 部门编号设置 * Date: 2022-06-06 09:37:39 - * LastEditTime: 2022-06-06 10:26:35 + * LastEditTime: 2022-06-07 17:44:30 */ import React, { Component, Fragment } from "react"; -import { Button } from "antd"; +import { inject, observer } from "mobx-react"; +import { Button, message } from "antd"; import { WeaTop, WeaFormItem, @@ -17,18 +18,146 @@ import { 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 DeptNumberSet extends Component { constructor() { super(); this.state = { - checkVal: "0", - isSingle: "0", //是否单独流水 - singleDate: "month", //日期单独流水 + 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: "DEPARTMENT" }) + .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: "DEPARTMENT", + }), + }; + 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: 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 }, + }); + } + }); + } + }; + 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:提示文本 * return {*} @@ -45,27 +174,20 @@ export default class DeptNumberSet extends Component { ); }; render() { - const { checkVal, isSingle, singleDate } = this.state; - const btns = []; + const { options, subCompanyInfo, loading, startNumberInfo } = this.state; + const { details, serialenable, dateSerial } = subCompanyInfo; + const btns = [ + , + ]; const dropMenuDatas = [ { key: "save", disabled: false, icon: , content: "保存", - onClick: (key) => alert(`点击了搜索 key = ${key}`), - }, - ]; - const options = [ - { - key: "month", - selected: false, - showname: "月", - }, - { - key: "day", - selected: true, - showname: "日", + onClick: (key) => this.handleSubmit(), }, ]; return ( @@ -85,64 +207,100 @@ export default class DeptNumberSet extends Component { labelCol={{ span: 8 }} wrapperCol={{ span: 16 }}> this.setState({ checkVal })} + onChange={(checkVal) => + this.setState({ + subCompanyInfo: { + ...subCompanyInfo, + serialenable: checkVal, + }, + }) + } /> {/* 内容区 */} - {checkVal === "1" && ( + {serialenable === "1" && (
- +
-
- -
- -
- this.setState({ isSingle })} - /> - {isSingle == "1" && ( - { - console.log("v", v, "showname", showname); - }} + {!_.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/postNumberSet/index.js b/pc4mobx/organization/components/postNumberSet/index.js new file mode 100644 index 0000000..9164bb2 --- /dev/null +++ b/pc4mobx/organization/components/postNumberSet/index.js @@ -0,0 +1,312 @@ +/* + * Author: 黎永顺 + * Description: 岗位编号设置 + * Date: 2022-06-06 09:37:39 + * LastEditTime: 2022-06-07 17:49:19 + */ +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 new file mode 100644 index 0000000..702528b --- /dev/null +++ b/pc4mobx/organization/components/resourceNumberSet/index.js @@ -0,0 +1,312 @@ +/* + * Author: 黎永顺 + * Description: 岗位编号设置 + * Date: 2022-06-06 09:37:39 + * LastEditTime: 2022-06-07 17:56:42 + */ +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.导入人员-添加时,新创建的部门可自动生成部门编号;

+

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 d0ca84f..f234ebc 100644 --- a/pc4mobx/organization/index.js +++ b/pc4mobx/organization/index.js @@ -13,6 +13,8 @@ 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 Company from "./components/company/company"; import DepartmentManage from "./components/department/department"; import StaffScheme from "./components/staff/StaffScheme"; @@ -58,14 +60,20 @@ const Routes = ( path="branchNumSetting" component={BranchNumSetting} /> + + - + diff --git a/pc4mobx/organization/public/i18n.js b/pc4mobx/organization/public/i18n.js index 7f7137a..aa401a4 100644 --- a/pc4mobx/organization/public/i18n.js +++ b/pc4mobx/organization/public/i18n.js @@ -130,7 +130,8 @@ export const i18n = { newOfficeClassifyName: () => getLabel(386246, '新建职务分类信息'), branchNumSetting: () => getLabel(386246, '分部编号设置'), deptNumSetting: () => getLabel(386246, '部门编号设置'), - posiNumSetting: () => getLabel(386246, '岗位编号设置'), + postNumSetting: () => getLabel(386246, '岗位编号设置'), + userNumSetting: () => getLabel(386246, '人员编号设置'), companyName: () => getLabel(385937, '分部'), staffSchemeName: () => getLabel(385936, '编制方案'), newStaffScheme: () => getLabel(386246, '新建编制方案'), diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js index ca257b8..d42be77 100644 --- a/pc4mobx/organization/stores/index.js +++ b/pc4mobx/organization/stores/index.js @@ -6,15 +6,15 @@ import { JobGradeStore } from "./jobgrade"; import { OfficeManageStore } from "./officeManage"; import { SequenceStore } from "./sequence"; import { GroupStore } from "./group"; -import {CompanyExtendStore} from "./companyextend"; -import {CompanyStore} from "./company"; -import {DepartmentStore} from "./department"; -import {DepartmentExtendStore} from "./departmentextend"; -import {StaffSchemeStore} from "./staffscheme"; -import {StaffStore} from "./staff"; -import {JobStore} from "./job"; -import {JobExtendStore} from "./jobextend"; - +import { CompanyExtendStore } from "./companyextend"; +import { CompanyStore } from "./company"; +import { DepartmentStore } from "./department"; +import { DepartmentExtendStore } from "./departmentextend"; +import { StaffSchemeStore } from "./staffscheme"; +import { StaffStore } from "./staff"; +import { JobStore } from "./job"; +import { JobExtendStore } from "./jobextend"; +import { NumberSetStore } from "./numberSet"; module.exports = { simpleOrgStore: new SimpleOrgStore(), @@ -33,4 +33,5 @@ module.exports = { staff: new StaffStore(), job: new JobStore(), jobExtend: new JobExtendStore(), + numberSet: new NumberSetStore(), }; diff --git a/pc4mobx/organization/stores/numberSet.js b/pc4mobx/organization/stores/numberSet.js new file mode 100644 index 0000000..55917a5 --- /dev/null +++ b/pc4mobx/organization/stores/numberSet.js @@ -0,0 +1,30 @@ +/* + * Author: 黎永顺 + * Description: 编号设置 + * Date: 2022-06-07 09:54:46 + * LastEditTime: 2022-06-07 17:00:49 + */ +import { observable, action } from "mobx"; +import * as mobx from "mobx"; +import * as API from "../apis/numberSet"; // 引入API接口文件 + +export class NumberSetStore { + @action + getCodeSetting(params) { + return API.getCodeSetting(params); + } + + @action + saveOrUpdateCodeSetting(params) { + return API.saveOrUpdateCodeSetting(params); + } + + @action + getStartNumForm(params) { + return API.getStartNumForm(params); + } + @action + saveStartNum(params) { + return API.saveStartNum(params); + } +}