代码还原
This commit is contained in:
parent
395fdad5ac
commit
5c2268f4f9
|
|
@ -1,124 +1,101 @@
|
|||
const { inject, observer } = mobxReact;
|
||||
const ProductItem = ecodeSDK.imp(ProductItem);
|
||||
const ProductDialog = ecodeSDK.imp(ProductDialog);
|
||||
const { toJS } = mobx;
|
||||
// const { product } = ecodeSDK.imp(productDataSource);
|
||||
const { WeaDialog } = ecCom;
|
||||
const { createRef } = React;
|
||||
/*
|
||||
* Author: 黎永顺
|
||||
* Description: 分部编号设置
|
||||
* Date: 2022-05-17 14:30:57
|
||||
* LastEditTime: 2022-05-30 10:23:18
|
||||
*/
|
||||
import React, { Component, Fragment } 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";
|
||||
|
||||
@inject("projectStore")
|
||||
@observer
|
||||
class ProductIndex extends React.Component {
|
||||
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 = {
|
||||
dialogParams: {
|
||||
visible: false,
|
||||
productId: "",
|
||||
},
|
||||
dialogWidth: 1200,
|
||||
dialogHeight: 100,
|
||||
checkVal: "0",
|
||||
};
|
||||
this.productRef = createRef();
|
||||
}
|
||||
componentDidMount() {
|
||||
window.addEventListener("resize", this.resizeWidthHeight);
|
||||
this.resizeWidthHeight();
|
||||
this.init();
|
||||
}
|
||||
conponentWillUnmount() {
|
||||
window.removeEventListener("resize", this.resizeWidthHeight);
|
||||
}
|
||||
|
||||
resizeWidthHeight = () => {
|
||||
requestAnimationFrame(() => {
|
||||
if (!this.productRef.current) {
|
||||
return;
|
||||
}
|
||||
const { offsetWidth, offsetHeight } = this.productRef.current;
|
||||
this.setState({
|
||||
dialogWidth: offsetWidth - 100,
|
||||
// offsetHeight / 2
|
||||
dialogHeight: 80,
|
||||
});
|
||||
});
|
||||
};
|
||||
componentDidMount() {}
|
||||
|
||||
init = () => {
|
||||
const {
|
||||
projectStore: { init },
|
||||
} = this.props;
|
||||
init();
|
||||
};
|
||||
|
||||
handlePickProduct = async (productId) => {
|
||||
const {
|
||||
projectStore: { viewProject, init },
|
||||
} = this.props;
|
||||
const { api_status } = await viewProject(productId);
|
||||
if (api_status) init();
|
||||
this.setState({
|
||||
dialogParams: { ...this.state.dialogParams, visible: true, productId },
|
||||
});
|
||||
/**
|
||||
* name:提示文本
|
||||
* return {*}
|
||||
*/
|
||||
helpContent = () => {
|
||||
return (
|
||||
<div>
|
||||
<p>开启后,可根据设置的分部编号规则自动生成分部编号,涉及场景如下:</p>
|
||||
<p>1.手动新建和手动编辑分部时可选择重新生成编号和选择预留分部编号;</p>
|
||||
<p>2.组织结构导入-添加新分部且分部编号列为空时,会自动生成分部编号;</p>
|
||||
<p>3.导入人员-添加时,新创建的分部可自动生成分部编号;</p>
|
||||
<p>【注意】开启前请先确认分部编号字段已启用!</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { dialogParams, dialogHeight, dialogWidth } = this.state;
|
||||
const {
|
||||
projectStore: { product },
|
||||
} = this.props;
|
||||
const { checkVal } = this.state;
|
||||
return (
|
||||
<div className="product-demo-wapper" ref={this.productRef}>
|
||||
<div className="product-container">
|
||||
{_.map(toJS(product), (item, index) => {
|
||||
const { id, title, subTitle, products } = item;
|
||||
return (
|
||||
<div className="product-box" key={id}>
|
||||
{/* <h2 className="product-title">{title}</h2>
|
||||
<p className="product-subtitle">{subTitle}</p> */}
|
||||
<ProductItem
|
||||
products={products}
|
||||
onPickProduct={this.handlePickProduct}
|
||||
/>
|
||||
<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>
|
||||
{/* 内容区 */}
|
||||
{checkVal === "1" && (
|
||||
<Fragment>
|
||||
<div className="numberComposition">
|
||||
<WeaSearchGroup title={"编号组成"} showGroup>
|
||||
<NumberComposition />
|
||||
</WeaSearchGroup>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{/* <a
|
||||
href="https://www.e-cology.com.cn/spa/document/index.jsp?id=7258131&router=1#/main/document/detail"
|
||||
target="_blank"
|
||||
className="product-link">
|
||||
<span>
|
||||
演示
|
||||
<br />
|
||||
脚本
|
||||
</span>
|
||||
</a> */}
|
||||
<div className="startReservedNumberSet">
|
||||
<WeaSearchGroup
|
||||
title={"起始编号及预留编号设置"}
|
||||
showGroup
|
||||
center>
|
||||
<StartReservedNumberSet />
|
||||
</WeaSearchGroup>
|
||||
</div>
|
||||
</Fragment>
|
||||
)}
|
||||
</div>
|
||||
{/* 弹框 */}
|
||||
{dialogParams.visible && (
|
||||
<WeaDialog
|
||||
onCancel={() => {
|
||||
this.resizeWidthHeight();
|
||||
this.setState({
|
||||
dialogParams: {
|
||||
...this.state.dialogParams,
|
||||
visible: false,
|
||||
productId: "",
|
||||
},
|
||||
});
|
||||
}}
|
||||
visible={dialogParams.visible}
|
||||
style={{ width: dialogWidth }}>
|
||||
<div
|
||||
className="product-dialog"
|
||||
style={{ height: dialogHeight + "vh" }}>
|
||||
<ProductDialog productId={dialogParams.productId} />
|
||||
</div>
|
||||
</WeaDialog>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ecodeSDK.exp(ProductIndex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue