import { observable, action, autorun,toJS } from 'mobx'; import {WeaTableNew,WeaForm} from 'comsMobx' import {Modal} from 'antd'; const confirm = Modal.confirm; const {TableStore} = WeaTableNew; import { ListStore } from './listStore'; import {WeaTools,WeaLocaleProvider} from "ecCom" import * as Apis from '../apis/project'; const getLabel = WeaLocaleProvider.getLabel; class MonitorStore extends ListStore{ @observable rightMenu =[]; conditiontype = {conditiontype:"monitor"}; /** 左侧树store */ @observable leftTree = []; @observable leftTreeCount = {}; @observable leftTreeCountType = []; @observable selectedTreeKey = ""; @observable showLeft = true; @observable verified = false; @observable hasRight = false; //权限 @action initDatas=(params={},needReset=false)=>{ this.loading = true; const newParams = {...this.conditiontype,...params}; if(needReset){ this.resetForm(); } Apis.getPrjCondition(newParams).then(data=>{ this.loading = false; this.condition = data.condition; this.form && !this.form.isFormInit && this.form.initFormFields(data.condition); }).then(()=>{ this.initTreeDatas(params) }); } initTreeDatas=(params={})=>{ const searchParamsAd = this.form.getFormParams(); Apis.getPrjTypeTreePageList({treetype:'prjmonitor',...params,...searchParamsAd}).then(data=>{ this.leftTree =data.treedata; this.leftTreeCount = data.treecount; this.leftTreeCountType = data.treecountcfg; this.selectedTreeKey = data.selectedKeys; this.doSearch({prjtype:this.selectedTreeKey}); }) } doSearch=(params={})=>{ this.loading = true; //获取表单的参数值 if(params.prjtype){ this.appendFormFields({prjtype:{value:params.prjtype}}) } const searchParamsAd = this.form.getFormParams(); if(searchParamsAd.prjtype){ this.selectedTreeKey = searchParamsAd.prjtype; } const newParams = { ...searchParamsAd}; Apis.getPrjMonitorList(newParams).then(data=>{ this.tableStore.getDatas(data.sessionkey, params.current || 1); this.topTabCount = data.tabnum; this.dataKey = data.sessionkey; this.rightMenu = data.rightMenus; this.loading = false; }) } onShowColumn=()=>{ this.tableStore.setColSetVisible(true); this.tableStore.tableColSet(true) } setSelectedTreeKey=(key) =>{ this.selectedTreeKey = key; } @action setLeftShow=(bool) =>{ this.showLeft = bool; } clearStatus=()=>{ this.showSearchAd = false; this.selectedTreeKey = ""; this.clearFormFields(); } //项目删除 @action delPrjInfo=(params={})=>{ let _this = this; const searchParamsAd = this.form.getFormParams(); Modal.confirm({ title: getLabel(15172,"系统提示"), content: getLabel(83601,"您确认要删除选中的记录吗?"), onOk() { Apis.delPrjInfo(params).then(data=>{ if(data.isright){ Apis.getPrjTypeTreePageList({treetype:'prjmonitor',...searchParamsAd}).then(data=>{ _this.leftTree =data.treedata; _this.leftTreeCount = data.treecount; _this.leftTreeCountType = data.treecountcfg; _this.doSearch({prjtype:_this.selectedTreeKey}); }) }else{ message.error(getLabel('507580','出现错误!对不起,您暂时没有权限!!')); } }); }, onCancel() { }, }) } } const prjMonitorStore = new MonitorStore(); export default prjMonitorStore;