import { observable, action, toJS } from 'mobx'; import { message } from 'antd'; import { WeaForm, WeaLogView } from 'comsMobx'; import { WeaLocaleProvider } from 'ecCom'; import * as API from '../../apis'; // 引入API接口文件 const getLabel = WeaLocaleProvider.getLabel; export class SimpleOrgStore { @observable form = new WeaForm(); // new 一个form @observable condition = []; // 存储后台得到的form数据 @observable loading = true; // 页面初始化的loading状态:数据加载成功前后前使用 @observable hasRight = true; // 判断用户是有权限查看当前页面: 没有权限渲染无权限页面,有权限渲染数据 @observable data = {}; //组织架构数据 @observable horizontal = false; // true:横向 false:纵向 @observable collapsable = true; // true:可折叠 false:不可折叠 @observable expandAll = true; // true: 全部展开 false:全部折叠 @observable labelClassName = 'bg-white'; @observable treeType = 'simple'; @observable scale = 1; @action // 初始化操作: 一般用来初始化获取后台数据 doInit = () => { this.getBaseForm(); this.getSimpleOrg(); } @action // 获得组织架构数据 getSimpleOrg = (params) => { API.getSimpleOrganizationDatas(params).then(action(result => { this.loading = false; // this.hasRight = result.hasRight; // if (result.hasRight) { // this.data = result.data; // } this.data = result.data; })); setTimeout(function(){ this.loading = false; },2000) } @action getBaseForm = () => { this.condition = [{ "colSpan": 2, "conditionType": "DATEPICKER", 'rules': 'required|string', 'hide': false, // 隐藏 "domkey": [ "datasDate" ], "fieldcol": 12, "label": "数据日期", "labelcol": 6, "value": "2022-01-21", "viewAttr": 2 },{ "colSpan": 2, "conditionType": "SELECT", 'rules': 'required|string', 'hide': false, "domkey": [ "dimension" ], "fieldcol": 12, "label": "维度", "options": [ { "key": "1", "selected": false, "showname": "行政维度", },{ "key": "2", "selected": false, "showname": "公司维度", }], "labelcol": 6, "value": "行政维度", "viewAttr": 2 },{ "colSpan": 2, "conditionType": "SELECT", 'rules': 'required|string', 'hide': false, "domkey": [ "node" ], "fieldcol": 12, "label": "根节点", "options": [ { "key": "1", "selected": false, "showname": "集团", },{ "key": "2", "selected": false, "showname": "部门", }], "labelcol": 6, "value": "集团", "viewAttr": 2 },{ "colSpan": 2, "conditionType": "SELECT", 'rules': 'required|string', 'hide': false, "domkey": [ "hierarchy" ], "fieldcol": 12, "label": "显示层级", "options": [ { "key": "1", "selected": false, "showname": "一级", },{ "key": "2", "selected": false, "showname": "二级", }], "labelcol": 6, "value": "一级", "viewAttr": 2 },{ "colSpan": 2, "conditionType": "CHECKBOX", 'rules': 'required|string', 'hide': false, "domkey": [ "visiable" ], "fieldcol": 12, "label": "显示虚拟组织", "labelcol": 6, "value": "true", "viewAttr": 2 }] this.form.initFormFields(this.condition); } }