分部编号设置的页面完成50%

This commit is contained in:
liyongshun 2022-05-17 18:32:09 +08:00
parent 89aab7a742
commit e1cc281cff
6 changed files with 366 additions and 0 deletions

View File

@ -0,0 +1,212 @@
/*
* Author: 黎永顺
* Description:
* Date: 2022-05-17 16:02:56
* LastEditTime: 2022-05-17 18:30:57
*/
import React, { Component, Fragment } from "react";
import { Button } from "antd";
import {
WeaTableEdit,
WeaDialog,
WeaMoreButton,
WeaFormItem,
WeaSelect,
} from "ecCom";
import { i18n } from "../../../public/i18n";
import _ from "lodash";
const columns = [
{
title: "",
dataIndex: "numFieldName",
key: "numFieldName",
colSpan: 1,
com: [{ label: "", type: "TEXT" }],
width: "20%",
},
{
title: "",
dataIndex: "value",
useRecord: true,
key: "value",
com: [{ label: "", type: "INPUT", viewAttr: 2, key: "value" }],
colSpan: 1,
width: "70%",
},
];
const dataSource = [
// {
// com: {
// value: [{ key: "value", label: "", type: "TEXT" }],
// },
// value: "",
// numFieldName: "字符串",
// numField: "string",
// },
{
value: "",
numFieldName: "字符串",
numField: "string",
},
{ value: "3", numFieldName: "流水号位数", numField: "number" },
];
const options = [
{
key: "string",
showname: "字符串",
},
{
key: "year",
showname: "当前年份",
},
{
key: "month",
showname: "当前月份",
},
{
key: "day",
showname: "当前日期",
},
];
class NumberComposition extends Component {
constructor() {
super();
this.state = {
visible: false,
numField: "string",
numFieldName: "字符串",
dataSource,
};
}
getRowSelection = (rowSelection) => {
const sel = { ...rowSelection };
sel.getCheckboxProps = (record) => {
return { disabled: record.numField === "number" };
};
return sel;
};
handleAddTable = () => {
this.setState({
visible: true,
});
};
handleSave = () => {
const { numField, numFieldName, dataSource } = this.state;
const objWrite = {
value: "",
numFieldName,
numField,
};
const objView = {
com: {
value: [{ key: numField, label: "", type: "TEXT" }],
},
[numField]: "",
numFieldName,
numField,
};
this.setState({
visible: false,
numField: "string",
numFieldName: "字符串",
dataSource:
numField === "year" || numField === "month" || numField === "day"
? [...dataSource, objView]
: [...dataSource, objWrite],
});
};
handleDeleteTable = (keys, datas) => {
console.log("handleDeleteTable", keys, datas);
};
render() {
const { visible, numField, dataSource } = this.state;
const buttons = [
<Button
ecId={`${(this && this.props && this.props.ecId) || ""}_Button@jd6baw`}
onClick={this.handleSave}
type="primary">
{i18n.button.save()}
</Button>,
<WeaMoreButton
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaMoreButton@e4f4n1`}
/>,
];
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 (
<Fragment>
<WeaTableEdit
draggable={true}
columns={columns}
datas={[
...stringRow,
...yearRow,
...monthRow,
...dayRow,
...disableRow,
]}
getRowSelection={this.getRowSelection}
pushTitleIntoHeader
showCopy={false}
btnsType="inline"
deleteConfirm
addType="func"
addFunc={this.handleAddTable}
onDelete={this.handleDeleteTable}
/>
{/* 新增弹框 */}
<WeaDialog
onCancel={() =>
this.setState({
visible: false,
})
}
icon="icon-coms-hrm"
iconBgcolor="#217346"
title={i18n.label.addNumberField()}
visible={visible}
hasScroll
maxHeight={150}
buttons={buttons}>
<WeaFormItem
label="编号字段"
style={{ padding: "20px 20%" }}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<WeaSelect
options={options}
value={numField}
style={{ width: "100%" }}
viewAttr={2}
onChange={(numField, numFieldName) => {
this.setState({ numField, numFieldName });
}}
/>
</WeaFormItem>
</WeaDialog>
</Fragment>
);
}
}
export default NumberComposition;

View File

@ -0,0 +1,31 @@
/*
* Author: 黎永顺
* Description: 起始编号及预留编号设置
* Date: 2022-05-17 15:51:41
* LastEditTime: 2022-05-17 16:01:33
*/
import React, { Component, Fragment } from "react";
import { WeaFormItem } from "ecCom";
class StartReservedNumberSet extends Component {
render() {
return (
<Fragment>
<WeaFormItem
label="起始编号"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<i className="icon-coms-Flow-setting"></i>
</WeaFormItem>
<WeaFormItem
label="预留编号"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<i className="icon-coms-Flow-setting"></i>
</WeaFormItem>
</Fragment>
);
}
}
export default StartReservedNumberSet;

View File

@ -0,0 +1,94 @@
/*
* Author: 黎永顺
* Description: 分部编号设置
* Date: 2022-05-17 14:30:57
* LastEditTime: 2022-05-17 17:18:36
*/
import React, { Component } from "react";
import { Button } from "antd";
import { WeaTop, WeaFormItem, WeaCheckbox, WeaSearchGroup } from "ecCom";
import StartReservedNumberSet from "./components/startReservedNumberSet";
import NumberComposition from "./components/numberComposition";
import { i18n } from "../../public/i18n";
import "./index.less";
const btns = [<Button type="primary">保存</Button>];
const dropMenuDatas = [
{
key: "save",
disabled: false,
icon: <i className="icon-coms-Preservation" />,
content: "保存",
onClick: (key) => alert(`点击了搜索 key = ${key}`),
},
];
export default class BranchNumSetting extends Component {
constructor() {
super();
this.state = {
checkVal: "0",
};
}
componentDidMount() {}
/**
* name:提示文本
* return {*}
*/
helpContent = () => {
return (
<div>
<p>开启后可根据设置的分部编号规则自动生成分部编号涉及场景如下</p>
<p>1.手动新建和手动编辑分部时可选择重新生成编号和选择预留分部编号</p>
<p>2.组织结构导入-添加新分部且分部编号列为空时会自动生成分部编号</p>
<p>3.导入人员-添加时新创建的分部可自动生成分部编号</p>
<p>注意开启前请先确认分部编号字段已启用</p>
</div>
);
};
render() {
const { checkVal } = this.state;
return (
<div className="branch-wapper">
<WeaTop
title={i18n.label.branchNumSetting()}
icon={<i className="icon-coms-hrm" />}
iconBgcolor="#217346"
buttons={btns}
showDropIcon={true}
dropMenuDatas={dropMenuDatas}
/>
<div className="branch-content">
<div className="switch-wrapper">
<WeaFormItem
label="分部编号自动生成"
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}>
<WeaCheckbox
value={checkVal}
helpfulTip={this.helpContent}
helpfulTipProps={{ placement: "top" }}
display="switch"
id="num-set-switch"
onChange={(checkVal) => this.setState({ checkVal })}
/>
</WeaFormItem>
</div>
{/* 内容区 */}
<div className="numberComposition">
<WeaSearchGroup title={"编号组成"} showGroup>
<NumberComposition />
</WeaSearchGroup>
</div>
<div className="startReservedNumberSet">
<WeaSearchGroup title={"起始编号及预留编号设置"} showGroup center>
<StartReservedNumberSet />
</WeaSearchGroup>
</div>
</div>
</div>
);
}
}

View File

@ -0,0 +1,26 @@
.branch-wapper {
height: 100%;
display: flex;
flex-direction: column;
.branch-content {
flex: 1;
.switch-wrapper {
width: 100%;
padding: 20px 20% 40px 30%;
}
.numberComposition .ant-table-thead {
background: #f7fbfe;
}
.startReservedNumberSet {
.icon-coms-Flow-setting {
font-size: 16px;
cursor: pointer;
line-height: 30px;
}
}
}
}

View File

@ -10,6 +10,7 @@ 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 stores from "./stores";
import "./style/index";
@ -41,6 +42,7 @@ const Routes = (
<Route key="group" path="group" component={Group} />
<Route key="officeManage" path="officeManage" component={OfficeManage} />
<Route key="companyExtend" path="companyExtend" component={CompanyExtend} />
<Route key="branchNumSetting" path="branchNumSetting" component={BranchNumSetting} />
</Route>
);

View File

@ -128,6 +128,7 @@ export const i18n = {
newOfficeName: () => getLabel(386246, '新建职务信息'),
editOfficeName: () => getLabel(386247, '编辑职务信息'),
newOfficeClassifyName: () => getLabel(386246, '新建职务分类信息'),
branchNumSetting: () => getLabel(386246, '分部编号设置'),