代码还原

This commit is contained in:
liyongshun 2022-05-30 10:25:30 +08:00
parent 395fdad5ac
commit 5c2268f4f9
1 changed files with 83 additions and 106 deletions

View File

@ -1,124 +1,101 @@
const { inject, observer } = mobxReact; /*
const ProductItem = ecodeSDK.imp(ProductItem); * Author: 黎永顺
const ProductDialog = ecodeSDK.imp(ProductDialog); * Description: 分部编号设置
const { toJS } = mobx; * Date: 2022-05-17 14:30:57
// const { product } = ecodeSDK.imp(productDataSource); * LastEditTime: 2022-05-30 10:23:18
const { WeaDialog } = ecCom; */
const { createRef } = React; 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") const btns = [<Button type="primary">保存</Button>];
@observer const dropMenuDatas = [
class ProductIndex extends React.Component { {
key: "save",
disabled: false,
icon: <i className="icon-coms-Preservation" />,
content: "保存",
onClick: (key) => alert(`点击了搜索 key = ${key}`),
},
];
export default class BranchNumSetting extends Component {
constructor() { constructor() {
super(); super();
this.state = { this.state = {
dialogParams: { checkVal: "0",
visible: false,
productId: "",
},
dialogWidth: 1200,
dialogHeight: 100,
}; };
this.productRef = createRef();
}
componentDidMount() {
window.addEventListener("resize", this.resizeWidthHeight);
this.resizeWidthHeight();
this.init();
}
conponentWillUnmount() {
window.removeEventListener("resize", this.resizeWidthHeight);
} }
resizeWidthHeight = () => { componentDidMount() {}
requestAnimationFrame(() => {
if (!this.productRef.current) {
return;
}
const { offsetWidth, offsetHeight } = this.productRef.current;
this.setState({
dialogWidth: offsetWidth - 100,
// offsetHeight / 2
dialogHeight: 80,
});
});
};
init = () => { /**
const { * name:提示文本
projectStore: { init }, * return {*}
} = this.props; */
init(); helpContent = () => {
}; return (
<div>
handlePickProduct = async (productId) => { <p>开启后可根据设置的分部编号规则自动生成分部编号涉及场景如下</p>
const { <p>1.手动新建和手动编辑分部时可选择重新生成编号和选择预留分部编号</p>
projectStore: { viewProject, init }, <p>2.组织结构导入-添加新分部且分部编号列为空时会自动生成分部编号</p>
} = this.props; <p>3.导入人员-添加时新创建的分部可自动生成分部编号</p>
const { api_status } = await viewProject(productId); <p>注意开启前请先确认分部编号字段已启用</p>
if (api_status) init(); </div>
this.setState({ );
dialogParams: { ...this.state.dialogParams, visible: true, productId },
});
}; };
render() { render() {
const { dialogParams, dialogHeight, dialogWidth } = this.state; const { checkVal } = this.state;
const {
projectStore: { product },
} = this.props;
return ( return (
<div className="product-demo-wapper" ref={this.productRef}> <div className="branch-wapper">
<div className="product-container"> <WeaTop
{_.map(toJS(product), (item, index) => { title={i18n.label.branchNumSetting()}
const { id, title, subTitle, products } = item; icon={<i className="icon-coms-hrm" />}
return ( iconBgcolor="#217346"
<div className="product-box" key={id}> buttons={btns}
{/* <h2 className="product-title">{title}</h2> showDropIcon={true}
<p className="product-subtitle">{subTitle}</p> */} dropMenuDatas={dropMenuDatas}
<ProductItem />
products={products} <div className="branch-content">
onPickProduct={this.handlePickProduct} <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> </div>
); <div className="startReservedNumberSet">
})} <WeaSearchGroup
{/* <a title={"起始编号及预留编号设置"}
href="https://www.e-cology.com.cn/spa/document/index.jsp?id=7258131&router=1#/main/document/detail" showGroup
target="_blank" center>
className="product-link"> <StartReservedNumberSet />
<span> </WeaSearchGroup>
演示 </div>
<br /> </Fragment>
脚本 )}
</span>
</a> */}
</div> </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> </div>
); );
} }
} }
ecodeSDK.exp(ProductIndex);