职务管理页面的新增

This commit is contained in:
liyongshun 2022-05-13 18:06:15 +08:00
parent 2e167f4099
commit 9e8d36bbc4
9 changed files with 1075 additions and 6 deletions

View File

@ -0,0 +1,25 @@
import { WeaTools } from "ecCom";
export const getHasRight = (params) => {
return WeaTools.callApi(
"/api/bs/hrmorganization/postinfo/getHasRight",
"GET",
params
);
};
export const getSearchCondition = (params) => {
return WeaTools.callApi(
"/api/bs/hrmorganization/postinfo/getSearchCondition",
"GET",
params
);
};
export const getPostInfoForm = (params) => {
return WeaTools.callApi(
"/api/bs/hrmorganization/postinfo/getPostInfoForm",
"GET",
params
);
};

View File

@ -0,0 +1,9 @@
import React, { Component } from 'react'
export default class CompanyManage extends Component {
render() {
return (
<div>C</div>
)
}
}

View File

@ -0,0 +1,259 @@
import React, { Component } from "react";
import { Tree, Menu } from "antd";
import { WeaInputSearch } from "ecCom";
import "../index.less";
const TreeNode = Tree.TreeNode;
const treeData = [
{
title: "0-0",
key: "0-0",
children: [
{
title: "0-0-0",
key: "0-0-0",
children: [
{ title: "0-0-0-0-88", key: "0-0-0-0" },
{ title: "0-0-0-1", key: "0-0-0-1" },
{ title: "0-0-0-2", key: "0-0-0-2" },
],
},
{
title: "0-0-1",
key: "0-0-1",
children: [
{ title: "0-0-1-0", key: "0-0-1-0" },
{ title: "0-0-1-1", key: "0-0-1-1" },
{ title: "0-0-1-2", key: "0-0-1-2" },
],
},
{
title: "0-0-2",
key: "0-0-2",
},
],
},
{
title: "99",
key: "0-1",
children: [
{ title: "0-1-0-0", key: "0-1-0-0" },
{ title: "9988", key: "0-1-0-1" },
{ title: "0-1-0-2-99988", key: "0-1-0-2" },
],
},
{
title: "0-2",
key: "0-2",
},
];
export default class LeftTree extends Component {
constructor(props) {
super(props);
this.state = {
expandedKeys: [],
treeData: [],
copyTree: [],
copyExpandedKeys: [],
searchValue: "",
rightClickNodeTreeItem: null,
};
}
componentDidMount() {
let a = this.expandedKeysFun(treeData); //展开key
let cp = JSON.stringify(treeData); //这个是最简单的 深拷贝
this.setState({
treeData: treeData,
expandedKeys: a,
copyTree: cp,
copyExpandedKeys: a,
});
document.addEventListener("click", this.handleClick);
}
componentWillUnmount() {
document.removeEventListener("click", this.handleClick);
}
handleClick = () => {
this.setState({ rightClickNodeTreeItem: null });
};
onSelect = (node) => {
this.setState({ rightClickNodeTreeItem: null });
};
treeNodeonRightClick = (e) => {
this.setState({
rightClickNodeTreeItem: {
pageX: e.event.pageX,
pageY: e.event.pageY,
id: e.node.props["data-key"],
categoryName: e.node.props["data-title"],
},
});
};
arrayTreeFilter = (data, predicate, filterText) => {
const nodes = data;
if (!(nodes && nodes.length)) {
return;
}
const newChildren = [];
for (const node of nodes) {
if (predicate(node, filterText)) {
newChildren.push(node);
node.children = this.arrayTreeFilter(
node.children,
predicate,
filterText
);
} else {
const subs = this.arrayTreeFilter(node.children, predicate, filterText);
if ((subs && subs.length) || predicate(node, filterText)) {
node.children = subs;
newChildren.push(node);
}
}
}
return newChildren;
};
filterFn = (data, filterText) => {
if (!filterText) {
return true;
}
return new RegExp(filterText, "i").test(data.title);
};
flatTreeFun = (treeData) => {
let arr = [];
const flatTree = (treeData) => {
treeData.map((item, index) => {
arr.push(item);
if (item.children && item.children.length > 0) {
flatTree(item.children);
item.children = [];
}
});
};
flatTree(treeData);
return arr;
};
expandedKeysFun = (treeData) => {
if (treeData && treeData.length == 0) {
return [];
}
let arr = [];
const expandedKeysFn = (treeData) => {
treeData.map((item, index) => {
arr.push(item.key);
if (item.children && item.children.length > 0) {
expandedKeysFn(item.children);
}
});
};
expandedKeysFn(treeData);
return arr;
};
onChange = (value) => {
if (value == "") {
let { copyTree, copyExpandedKeys } = this.state;
this.setState({
treeData: JSON.parse(copyTree),
expandedKeys: copyExpandedKeys,
});
} else {
let { copyTree, copyExpandedKeys } = this.state;
let res = this.arrayTreeFilter(
JSON.parse(copyTree),
this.filterFn,
value
);
let expkey = this.expandedKeysFun(res);
this.setState({
treeData: res,
expandedKeys: expkey,
});
}
};
onExpand = (expandedKeys) => {
this.setState({
expandedKeys,
});
};
getNodeTreeRightClickMenu = () => {
const { pageX, pageY } = { ...this.state.rightClickNodeTreeItem };
const tmpStyle = {
position: "absolute",
left: `${pageX}px`,
top: `${pageY}px`,
};
const menu = (
<Menu
// onClick={this.handleMenuClick}
style={tmpStyle}
// className={style.categs_tree_rightmenu}
>
<Menu.Item key="1">新增</Menu.Item>
<Menu.Item key="3">删除</Menu.Item>
</Menu>
);
return this.state.rightClickNodeTreeItem == null ? "" : menu;
};
renderTreeNode = (data) => {
if (data.length == 0) {
return;
}
let { expandedKeys, searchValue } = this.state;
return data.map((item) => {
const index = item.title.indexOf(searchValue);
const beforeStr = item.title.substr(0, index);
const afterStr = item.title.substr(index + searchValue.length);
const title =
index > -1 ? (
<span>
{beforeStr}
<span style={{ color: "red" }}>{searchValue}</span>
{afterStr}
</span>
) : (
<span>{item.title}</span>
);
if (item.children && item.children.length > 0) {
return (
<TreeNode key={item.key} title={title} className="tree-node">
{this.renderTreeNode(item.children)}
</TreeNode>
);
}
return (
<TreeNode key={item.key} title={title} className="tree-node"></TreeNode>
);
});
};
render() {
const { searchValue, expandedKeys } = this.state;
return (
<div className="tree-wapper">
<WeaInputSearch
value={searchValue}
style={{ width: "100%", marginBottom: 16 }}
onSearch={this.onChange}
/>
<Tree
onExpand={this.onExpand}
expandedKeys={expandedKeys}
onRightClick={this.treeNodeonRightClick}
onSelect={this.onSelect}
autoExpandParent={true}>
{this.renderTreeNode(treeData)}
</Tree>
{/* {this.getNodeTreeRightClickMenu()} */}
</div>
);
}
}

View File

@ -0,0 +1,263 @@
import React, { Component } from "react";
import { Input, Tree, Menu } from "antd";
import { WeaInputSearch } from "ecCom";
import _ from "lodash";
import "../index.less";
const TreeNode = Tree.TreeNode;
const treeData = [
{
title: "0-0",
key: "0-0",
children: [
{
title: "0-0-0",
key: "0-0-0",
children: [
{ title: "0-0-0-0-88", key: "0-0-0-0" },
{ title: "0-0-0-1", key: "0-0-0-1" },
{ title: "0-0-0-2", key: "0-0-0-2" },
],
},
{
title: "0-0-1",
key: "0-0-1",
children: [
{ title: "0-0-1-0", key: "0-0-1-0" },
{ title: "0-0-1-1", key: "0-0-1-1" },
{ title: "0-0-1-2", key: "0-0-1-2" },
],
},
{
title: "0-0-2",
key: "0-0-2",
},
],
},
{
title: "99",
key: "0-1",
children: [
{ title: "0-1-0-0", key: "0-1-0-0" },
{ title: "9988", key: "0-1-0-1" },
{ title: "0-1-0-2-99988", key: "0-1-0-2" },
],
},
{
title: "0-2",
key: "0-2",
},
];
class LeftTree extends Component {
constructor(props) {
super(props);
this.state = {
expandedKeys: [],
treeData: [],
copyTree: [],
copyExpandedKeys: [],
searchValue: "",
rightClickNodeTreeItem: null,
};
}
componentDidMount() {
let cp = JSON.stringify(treeData);
this.setState({
treeData,
expandedKeys: [],
copyTree: cp,
copyExpandedKeys: [],
});
document.addEventListener("click", this.handleClick);
}
componentWillUnmount() {
document.removeEventListener("click", this.handleClick);
}
handleClick = () => {
this.setState({ rightClickNodeTreeItem: null });
};
onSelect = (node) => {
this.setState({
rightClickNodeTreeItem: null,
});
};
treeNodeonRightClick = (e) => {
this.setState({
rightClickNodeTreeItem: {
pageX: e.event.pageX,
pageY: e.event.pageY,
id: e.node.props["data-key"],
categoryName: e.node.props["data-title"],
},
});
};
arrayTreeFilter = (data, predicate, filterText) => {
const nodes = data;
if (!(nodes && nodes.length)) {
return;
}
const newChildren = [];
for (const node of nodes) {
if (predicate(node, filterText)) {
newChildren.push(node);
node.children = this.arrayTreeFilter(
node.children,
predicate,
filterText
);
} else {
const subs = this.arrayTreeFilter(node.children, predicate, filterText);
if ((subs && subs.length) || predicate(node, filterText)) {
node.children = subs;
newChildren.push(node);
}
}
}
return newChildren;
};
filterFn = (data, filterText) => {
if (!filterText) {
return true;
}
return new RegExp(filterText, "i").test(data.title);
};
flatTreeFun = (treeData) => {
let arr = [];
const flatTree = (treeData) => {
treeData.map((item, index) => {
arr.push(item);
if (item.children && item.children.length > 0) {
flatTree(item.children);
item.children = [];
}
});
};
flatTree(treeData);
return arr;
};
expandedKeysFun = (treeData) => {
if (treeData && treeData.length == 0) {
return [];
}
let arr = [];
const expandedKeysFn = (treeData) => {
treeData.map((item, index) => {
arr.push(item.key);
if (item.children && item.children.length > 0) {
expandedKeysFn(item.children);
}
});
};
expandedKeysFn(treeData);
return arr;
};
onChange = (value) => {
if (value == "") {
let { copyTree, copyExpandedKeys } = this.state;
this.setState({
treeData: JSON.parse(copyTree),
expandedKeys: copyExpandedKeys,
searchValue: value,
});
} else {
let { copyTree, copyExpandedKeys } = this.state;
let res = this.arrayTreeFilter(
JSON.parse(copyTree),
this.filterFn,
value
);
let expkey = this.expandedKeysFun(res);
this.setState({
treeData: res,
expandedKeys: expkey,
searchValue: value,
});
}
};
getNodeTreeRightClickMenu = () => {
const { pageX, pageY } = { ...this.state.rightClickNodeTreeItem };
const tmpStyle = {
position: "absolute",
left: `${pageX}px`,
top: `${pageY}px`,
};
const menu = (
<Menu
// onClick={this.handleMenuClick}
style={tmpStyle}
className='rightmenu'
>
<Menu.Item key="1">新增</Menu.Item>
<Menu.Item key="3">删除</Menu.Item>
</Menu>
);
return this.state.rightClickNodeTreeItem == null ? "" : menu;
};
renderTreeNode = (data) => {
//生成树结构函数
if (data.length == 0) {
return;
}
let { expandedKeys, searchValue } = this.state;
return data.map((item) => {
const index = item.title.indexOf(searchValue);
const beforeStr = item.title.substr(0, index);
const afterStr = item.title.substr(index + searchValue.length);
const title =
index > -1 ? (
<span>
{beforeStr}
<span style={{ color: "red" }}>{searchValue}</span>
{afterStr}
</span>
) : (
<span>{item.title}</span>
);
if (item.children && item.children.length > 0) {
return (
<TreeNode key={item.key} title={title} className="tree-node">
{this.renderTreeNode(item.children)}
</TreeNode>
);
}
return (
<TreeNode key={item.key} title={title} className="tree-node"></TreeNode>
);
});
};
onExpand = (expandedKeys) => {
this.setState({
expandedKeys,
});
};
render() {
let { expandedKeys, treeData, searchValue } = this.state;
return (
<div>
<div style={{ padding: 10 }}>
<WeaInputSearch
value={searchValue}
style={{ width: "100%" }}
onChange={this.onChange}
/>
</div>
<Tree
onExpand={this.onExpand}
expandedKeys={expandedKeys}
onRightClick={this.treeNodeonRightClick}
onSelect={this.onSelect}>
{this.renderTreeNode(treeData)}
</Tree>
{this.getNodeTreeRightClickMenu()}
</div>
);
}
}
export default LeftTree;

View File

@ -0,0 +1,20 @@
// office-wapper
.office-wapper {
height: 100%;
.rightmenu {
border-right: none;
box-shadow: 0 2px 8px rgb(0, 0, 0 /15%);
.ant-menu-item {
padding: 0 40px;
}
}
.tree-node {
.ant-tree-node-content-wrapper {
width: 100%;
}
}
}

View File

@ -0,0 +1,283 @@
import React, { Component } from "react";
import { toJS } from "mobx";
import { inject, observer } from "mobx-react";
import { i18n } from "../../public/i18n";
import LeftTree from "./components/leftTree";
import NewAndEditDialog from "../NewAndEditDialog";
import {
WeaTop,
WeaTab,
WeaFormItem,
WeaRightMenu,
WeaLeftRightLayout,
} from "ecCom";
import { Row, Col, Spin, Modal, Button, message, Switch } from "antd";
import { WeaSwitch, WeaTableNew } from "comsMobx";
import "./index.less";
@inject("officeManageStore")
@observer
export default class OfficeManage extends Component {
componentDidMount() {
const { officeManageStore } = this.props;
officeManageStore.getHasRight && officeManageStore.getHasRight();
}
getDropMenuDatas = () => {
const { officeManageStore } = this.props;
const { rightMenu } = officeManageStore;
let menus = [];
toJS(rightMenu).map((item, index) => {
let obj = {
key: item.menuFun,
icon: <i className={`${item.menuIcon}`} />,
content: item.menuName,
};
if (
item.menuFun == "collection" ||
item.menuFun == "help" ||
item.menuFun == "pageAddress"
) {
obj.disabled = true;
}
menus.push(obj);
});
return menus;
};
handleMenuClick = (key) => {};
getTopMenuBtns = () => {
const { officeManageStore } = this.props;
const { topMenu, tableStore, getPostInfoForm } = officeManageStore;
let btns = [];
topMenu.map((item, i) => {
if (item.menuFun !== "batchDelete") {
btns.push(
<Button
type="primary"
onClick={() => {
const { officeManageStore } = this.props;
const { isPanelShow, setPanelStatus } = officeManageStore;
isPanelShow && setPanelStatus(false);
getPostInfoForm();
}}>
{item.menuName}
</Button>
);
} else {
btns.push(
<Button
type="primary"
onClick={() => console.log(item)}
// disabled={tableStore.selectedRowKeys.length > 0 ? false : true}
>
{item.menuName}
</Button>
);
}
});
return btns;
};
getPanelComponents = () => {
const { officeManageStore } = this.props;
const { searchCondition, form2, searchConditionLoading } =
officeManageStore;
let arr = [];
let formParams = form2.getFormParams();
const { isFormInit } = form2;
isFormInit &&
searchCondition.map((c) => {
c.items.map((field, index) => {
arr.push(
<Col
ecId={`${
(this && this.props && this.props.ecId) || ""
}_Col@4cc308@${index}`}
span={index % 2 == 0 ? 10 : 11}
offset={1}>
<div style={{ marginTop: 20 }}>
<WeaFormItem
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaFormItem@u6ex85@${index}`}
label={`${field.label}`}
labelCol={{ span: `${field.labelcol}` }}
wrapperCol={{ span: `${field.fieldcol}` }}>
{
<WeaSwitch
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaSwitch@p7d3td@${index}`}
fieldConfig={field}
form={form2}
formParams={formParams}
/>
}
</WeaFormItem>
</div>
</Col>
);
});
});
if (searchConditionLoading) {
return (
<div className="hrm-loading-center-small" style={{ top: "25%" }}>
<Spin
ecId={`${
(this && this.props && this.props.ecId) || ""
}_Spin@lbktzb`}
spinning={searchConditionLoading}></Spin>
</div>
);
} else {
return (
<Row
ecId={`${(this && this.props && this.props.ecId) || ""}_Row@ppeb6z`}
// onKeyDown={(e) => {
// if (e.keyCode == 13 && e.target.tagName === "INPUT") {
// officeManageStore.getTableInfo();
// officeManageStore.setPanelStatus(false);
// }
// }}
>
{arr}
</Row>
);
}
};
getTabBtn = () => {
const { officeManageStore } = this.props;
const { form2, setPanelStatus } = officeManageStore;
const btn = [
<Button
ecId={`${(this && this.props && this.props.ecId) || ""}_Button@bx87i8`}
type="primary"
onClick={() => {
officeManageStore.getTableInfo();
setPanelStatus(false);
}}>
{i18n.button.search()}
</Button>,
<Button
ecId={`${(this && this.props && this.props.ecId) || ""}_Button@218ju6`}
onClick={() => form2.reset()}>
{i18n.button.reset()}
</Button>,
<Button
ecId={`${(this && this.props && this.props.ecId) || ""}_Button@5u9mfz`}
onClick={() => setPanelStatus(false)}>
{i18n.button.cancel()}
</Button>,
];
return btn;
};
onSearchChange = (val) => {
const { officeManageStore } = this.props;
const { form2 } = officeManageStore;
officeManageStore.setSchemeName(val);
!_.isEmpty(form2.getFormParams()) && officeManageStore.updateFields(val);
};
render() {
const { officeManageStore } = this.props;
const {
isPanelShow,
form2,
schemeName,
conditionNum,
tableStore,
nEdialogTitle,
visible,
condition,
form,
dialogLoading,
} = officeManageStore;
return (
<div className="office-wapper">
<WeaLeftRightLayout
isNew={true}
leftWidth={310}
leftCom={<LeftTree />}
onCollapse={(showLeft) => console.log("showLeft:", showLeft)}>
<WeaRightMenu
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaRightMenu@cea97d`}
datas={this.getDropMenuDatas()}
onClick={(key) => this.handleMenuClick(key)}>
<WeaTop
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaTop@446d12`}
title={i18n.label.schemeName()}
icon={<i className="icon-coms-hrm" />}
iconBgcolor="#217346"
loading={true}
buttons={this.getTopMenuBtns()}
showDropIcon={true}
dropMenuDatas={this.getDropMenuDatas()}
onDropMenuClick={(e) => this.handleMenuClick(e)}>
<WeaTab
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaTab@39c727`}
searchType={["base", "advanced"]}
showSearchAd={isPanelShow}
searchsBaseValue={
_.isEmpty(form2.getFormParams())
? schemeName
: form2.getFormParams().schemeName
}
setShowSearchAd={(bool) =>
officeManageStore.setPanelStatus(bool)
}
hideSearchAd={() => officeManageStore.setPanelStatus(false)}
searchsAd={
isPanelShow ? this.getPanelComponents() : <div></div>
}
advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20}
hasMask={false}
buttonsAd={this.getTabBtn()}
// onSearch={() => officeManageStore.getSearchCondition()}
onSearchChange={(val) => this.onSearchChange(val)}
/>
{/* <WeaTable
ecId={`${
(this && this.props && this.props.ecId) || ""
}_WeaTable@b43a4c`}
comsWeaTableStore={tableStore}
hasOrder={true}
needScroll={true}
getColumns={(c) => this.reRenderColumns(c)}
onOperatesClick={(record, index, operate) =>
this.onOperatesClick(record, index, operate)
}
/> */}
</WeaTop>
<NewAndEditDialog
ecId={`${
(this && this.props && this.props.ecId) || ""
}_NewAndEditDialog@q4rrwm`}
title={nEdialogTitle}
visible={visible}
condition={toJS(condition)}
form={form}
isFormInit={form.isFormInit}
loading={dialogLoading}
isEdit={false}
height={250}
conditionLen={3}
// save={() => this.handleSave()}
// onCancel={() => rankScheme.setVisible(false)}
/>
</WeaRightMenu>
</WeaLeftRightLayout>
</div>
);
}
}

View File

@ -0,0 +1,90 @@
import { observable, action, toJS } from "mobx";
import { WeaForm } from "comsMobx";
import { WeaTableNew } from "comsMobx";
import { Modal, message } from "antd";
import { i18n } from "../public/i18n";
const { TableStore } = WeaTableNew;
export class RankSchemeStore {
@observable tableStore = new TableStore();
@observable topMenu = [];
@observable rightMenu = [];
@observable condition = [];
@observable searchCondition = [];
@observable isEdit = true;
@observable isNew = true;
@observable isPanelShow = false; //高级搜索面板
@observable form2 = new WeaForm();
@observable form = new WeaForm();
@observable form1 = new WeaForm();
@observable schemeName = "";
@observable conditionNum = 2;
@observable ids = ""; //选择行id
@observable searchConditionLoading = true;
@observable nEdialogTitle = "";
@observable visible = false;
@observable dialogLoading = true;
@observable schemeId = "";
@observable date = "";
@action
getHasRight() {
this.topMenu = [
{
isBatch: "1",
isTop: "1",
menuFun: "new",
menuIcon: "icon-coms-New-Flow",
menuName: "新建",
type: "BTN_Addnew",
},
{
isBatch: "1",
isTop: "1",
menuFun: "batchDelete",
menuIcon: "icon-coms-Batch-delete",
menuName: "批量删除",
type: "BTN_BatchDelete",
},
];
this.rightMenu = [
{
isBatch: "0",
isTop: "1",
menuFun: "new",
menuIcon: "icon-coms-New-Flow",
menuName: "新建",
type: "BTN_Addnew",
},
{
isBatch: "0",
isTop: "0",
menuFun: "log",
menuIcon: "icon-coms-Print-log",
menuName: "日志",
type: "BTN_log",
},
{
isBatch: "0",
isTop: "0",
menuFun: "custom",
menuIcon: "icon-coms-task-list",
menuName: "显示列定制",
type: "BTN_COLUMN",
},
];
}
updateFields(val) {
this.form2.updateFields({
schemeName: {
value: val,
},
});
}
formReset() {
this.form = new WeaForm();
}
}

View File

@ -1,9 +1,9 @@
import { SimpleOrgStore } from './tree/simple_org';
import {StandardOrgStore} from './tree/standard_org'
import {RankSchemeStore} from './rankscheme';
import {JobLevelStore} from './joblevel';
import {JobGradeStore} from './jobgrade'
import { SimpleOrgStore } from "./tree/simple_org";
import { StandardOrgStore } from "./tree/standard_org";
import { RankSchemeStore } from "./rankscheme";
import { JobLevelStore } from "./joblevel";
import { JobGradeStore } from "./jobgrade";
import { OfficeManageStore } from "./officeManage";
module.exports = {
simpleOrgStore: new SimpleOrgStore(),
@ -11,4 +11,5 @@ module.exports = {
rankScheme: new RankSchemeStore(),
jobLevel: new JobLevelStore(),
jobGrade: new JobGradeStore(),
officeManageStore: new OfficeManageStore(),
};

View File

@ -0,0 +1,119 @@
import { observable, action, toJS } from "mobx";
import { WeaForm } from "comsMobx";
import { WeaTableNew } from "comsMobx";
import { Modal, message } from "antd";
import { i18n } from "../public/i18n";
import * as API from "../apis/officeManage";
import _ from "lodash";
const { TableStore } = WeaTableNew;
export class OfficeManageStore {
@observable tableStore = new TableStore();
@observable topMenu = []; //顶部菜单
@observable rightMenu = []; //右侧更多菜单
@observable condition = [];
@observable searchCondition = [];
@observable isEdit = true;
@observable isNew = true;
@observable isPanelShow = false; //高级搜索面板
@observable form2 = new WeaForm();
@observable form = new WeaForm(); //新增编辑渲染的表单
@observable form1 = new WeaForm();
@observable schemeName = "";
@observable conditionNum = 2;
@observable ids = ""; //选择行id
@observable searchConditionLoading = false;
@observable nEdialogTitle = "";
@observable visible = false;
@observable dialogLoading = false;
@observable schemeId = "";
@observable date = "";
@action
getHasRight() {
API.getHasRight().then((res) => {
const { code, data, msg } = res;
if (code === 200) {
const { rightMenu, topMenu } = data;
this.topMenu = topMenu;
this.rightMenu = rightMenu;
} else {
message.error(msg);
}
});
}
@action("高级搜索表单渲染")
getSearchCondition() {
this.setScLoadingStatus(true);
API.getSearchCondition().then((res) => {
this.setScLoadingStatus(false);
const { code, data, msg } = res;
if (code === 200) {
res.data.conditions && this.setSearchCondition(res.data.conditions);
res.data.conditions && this.form2.initFormFields(res.data.conditions);
} else {
message.error(res.msg);
}
});
}
@action("获取新增/编辑表单")
getPostInfoForm(id) {
// this.setDialogLoadingStatus(true);
API.getPostInfoForm({ id }).then((res) => {
// this.setDialogLoadingStatus(false);
const { code, data, msg } = res;
if (code === 200) {
data.condition && this.setCondition(data.condition);
data.condition && this.form.initFormFields(data.condition);
} else {
message.error(res.msg);
}
});
}
@action("展开关闭搜索面板")
setPanelStatus(bool) {
this.isPanelShow = bool;
bool && this.getSearchCondition();
if (!bool) {
this.searchConditionLoading = false;
}
}
setScLoadingStatus(bool) {
this.searchConditionLoading = bool;
}
setSearchCondition(condition) {
this.searchCondition = condition;
}
setVisible(bool) {
this.visible = bool;
this.formReset();
if (!bool) this.setDialogLoadingStatus(false);
}
setDialogLoadingStatus(bool) {
this.dialogLoading = bool;
}
setCondition(condition) {
this.condition = condition;
}
updateFields(val) {
this.form2.updateFields({
schemeName: {
value: val,
},
});
}
formReset() {
this.form = new WeaForm();
}
}