weaver_trunk_cli/pc4mobx/prj/stores/minePrjStore.js

148 lines
4.2 KiB
JavaScript

import { observable, action, autorun,toJS } from 'mobx';
import {WeaTableNew,WeaForm} from 'comsMobx'
const {TableStore} = WeaTableNew;
import {WeaTools,WeaLocaleProvider} from "ecCom"
const getLabel = WeaLocaleProvider.getLabel;
import { ListStore } from './listStore';
import * as Apis from '../apis/minePrj';
import * as Apis_prj from '../apis/project';
import {ShareStore} from './shareStore'
import {ExchangeStore } from "./exchangeStore"
import {ProjectInfoStore } from './projectInfoStore';
class MinePrjStore extends ListStore{
@observable topTabCount =[];
@observable baseParams={};
@observable showLeft = true;
@observable searchParams = {
tabkey: "doing",
}
@observable rightMenu =[];
conditiontype = {conditiontype:"mymanagerprj"};
@observable shareData ={
type: getLabel(1332,"任务"),
visible:false
}
@observable shareStore = new ShareStore();
@observable exchangeStore = new ExchangeStore();
@observable projectInfoStore = new ProjectInfoStore();
// @observable taskListStore = new TaskListStoreNew();
/** 左侧树store */
@observable leftTree = [];
@observable leftTreeCount = {};
@observable leftTreeCountType = [];
@observable selectedTreeKey = "";
@observable verified = false;
@observable hasRight = false; //权限
//@observable treeType={};
@action
appendBaseParams=(params)=> {
this.baseParams = {...this.baseParams,...params};
}
@action
initDatas=(params = {})=> {
let newParams = {...this.conditiontype,...this.searchParams,...params};
this.title = this.title;
this.topTab = this.topTab;
this.topTabCount = this.topTabCount;
this.searchParams = { ...this.searchParams, ...params };
Apis.getMyPrjCondition(newParams).then(data=>{
this.form = new WeaForm();
this.condition = data.condition;
//根据高级搜索条件初始化form
this.form && !this.form.isFormInit && this.form.initFormFields(data.condition);
}).then(()=>{
this.initTreeDatas(params);
});
}
@action
initTreeDatas=(params={})=>{
Apis.getPrjTypeTreePageList({treetype:'mymanagerprj',...params}).then(data=>{
this.leftTree =data.treedata;
this.leftTreeCount = data.treecount;
this.leftTreeCountType = data.treecountcfg;
this.selectedTreeKey = data.selectedKeys;
this.doSearch({prjtype:data.selectedKeys});
})
}
@action
doSearch=(params={})=>{
this.loading = true;
//获取表单的参数值
if(params.prjtype){
this.appendFormFields({prjtype:{value:params.prjtype}})
this.selectedTreeKey = params.prjtype;
}
const searchParamsAd = this.form.getFormParams();
if(searchParamsAd.prjtype){
this.selectedTreeKey = searchParamsAd.prjtype;
}
const newParams = { ...this.baseParams, ...this.searchParams, ...searchParamsAd, ...params };
Apis.getMyPrjList(newParams).then(data=>{
this.tableStore = new TableStore();
this.tableStore.getDatas(data.sessionkey, params.current || 1);
this.searchParams = { ...this.searchParams, ...params };
this.topTabCount = data.tabnum;
this.dataKey = data.sessionkey;
this.rightMenu = data.rightMenus;
this.loading = false;
})
}
// reLoad=()=>{
// this.doSearch();
// }
onShowColumn=()=>{
this.tableStore.setColSetVisible(true);
this.tableStore.tableColSet(true)
}
setSelectedTreeKey=(key) =>{
this.selectedTreeKey = key;
}
@action
setLeftShow=(bool) =>{
this.showLeft = bool;
}
clearStatus=()=>{
this.searchParams = {tabkey: "doing",};
this.showSearchAd = false;
this.selectedTreeKey = "";
this.clearFormFields();
this.resetForm();
this.condition = [];
this.resetTable(true);
}
//项目执行操作
@action
doPlanOpt=(params={})=>{
Apis_prj.doPlanOpt(params).then(data=>{
this.doSearch();
});
}
//项目删除
@action
delPrjInfo=(params={})=>{
Apis_prj.delPrjInfo(params).then(data=>{
Apis.getPrjTypeTreePageList({treetype:'mymanagerprj',...params}).then(data=>{
this.leftTree =data.treedata;
this.leftTreeCount = data.treecount;
this.leftTreeCountType = data.treecountcfg;
this.doSearch({prjtype:this.selectedTreeKey});
})
});
}
}
const minePrjStore = new MinePrjStore();
export default minePrjStore;