import { observable, action, autorun, toJS } from 'mobx'; import { WeaTools, WeaLocaleProvider } from "ecCom" import objectAssign from 'object-assign'; import { message, Modal } from 'antd'; const confirm = Modal.confirm; import isEqual from 'lodash/isEqual'; import { WeaTableNew, WeaForm } from 'comsMobx' const { TableStore } = WeaTableNew; const { ls } = WeaTools; const getLabel = WeaLocaleProvider.getLabel; import * as Apis from '../apis/project'; import * as BoardApis from '../apis/projecboard'; import * as Common_Apis from '../apis/index'; import * as Task_Apis from "../apis/task"; import { AddProjectStore } from "./addProjectStore"; import { ProjectInfoStore } from './projectInfoStore'; import { ShareStore } from './shareStore' import { TaskInfoStore } from './task/taskInfoStore' import { ExchangeStore } from "./exchangeStore" import { RelateListStore } from './taskListStore'; export class PrjCardStore { @observable tabDatas = []; @observable selectTabKey = "1" @observable loading = false; @observable prjid = ""; @observable prjname = ""; @observable targetid = ""; discusstype = "PP"; taskname = ""; @observable showSearchAd = false // 高级搜索显示 @observable rightMenu = []; @observable form = new WeaForm(); //项目信息 @observable templatename = "";//模板名称 @observable doSaveVisible = false; @observable fieldInfo = []; @observable prjinfoRight = { hasRight: false, verified: false }; @observable prjisdel = false; validateRules = {}; //校验规则 @observable prjSubStore = new TableStore(); //子项目 @observable prjSubform = new WeaForm(); @observable prjsubRight = { hasRight: false, verified: false } @observable condition = []; //高级搜索 @observable addProjectStore = new AddProjectStore(); @observable exchangeList = ""; @observable _BrowserList = { 'create': {remark: ''}, datas: [], }; @observable shareTableStore = new TableStore(); //共享 @observable shareStore = new ShareStore(); @observable isShowShare = false; @observable shareRight = { hasRight: false, verified: false } @observable projectInfoStore = new ProjectInfoStore(); @observable stastics = []; //统计报告 @observable taskListTableStore = new TableStore({ dataHandle: (datas) => { //任务列表 datas.forEach((data) => { if (typeof (data.subListspan) == 'string') { data.subListspan = data.subListspan ? JSON.parse(data.subListspan) : undefined; } }); return datas; } }); @observable taskListform = new WeaForm(); @observable taskListquickform = new WeaForm(); @observable taskListTabs = []; @observable taskListSearchParams = { version: "0" }; @observable taskListQuickitems = []; @observable taskListRight = { hasRight: false, verified: false } @observable relateListStore = new RelateListStore(); @observable taskInfoStore = new TaskInfoStore(); @observable exchangeStore = new ExchangeStore(); @observable prjLogTableStore = new TableStore(); //日志 @observable prjFieldLogTableStore = new TableStore(); //字段日志 @observable prjFieldDetailLogTableStore = new TableStore(); //字段详情日志 @observable fieldLogVisible = false; @observable fieldDetailLogVisible = false; @observable fieldname = ''; @observable field = ''; @observable verified = false; @observable hasRight = false; //权限 @observable showEditTask = false; @observable isreload = false; @observable stageInfo = { stageColumns: [], stageColumnDatas: [], selectedRowKeys: [], selectedDatas: {}, canedit:false } @observable approveplanstatus = false; @observable resourceInfo = { cptList : [], prjList : [], taskList : [], accList : [], wfList : [], cusList : [], docList : [] } @observable isBatchEdit = 0; @observable isApprove = false; @observable status = ''; @action reLoad = (tableStore) => { tableStore.getDatas(tableStore.dataKey, tableStore.current, tableStore.pageSize, tableStore.sortParams) } @action refTaskList = () => { this.getPrjTaskCondition(); this.getPrjTaskVersion(); this.getPrjTaskList(); } //设置选中按钮 changeTab = (key) => { this.selectTabKey = key; this.rightMenu = []; const tabDatas = toJS(this.tabDatas); if (tabDatas) { for (let i = 0; i < tabDatas.length; i++) { if (tabDatas[i].id == key && tabDatas[i].shortname == "prjinfo") { //基本信息 this.getPrjInfo({ viewtype: 'view', prjid: this.prjid }); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "tasklist") {//任务列表 this.setIsBatchEdit(0); this.getPrjTaskCondition(); this.getPrjTaskVersion(); this.getPrjTaskList(); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "childprj") { //子项目 this.getPrjSubList(); this.getPrjSubCondition(); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "prjdiscuss") { //相关交流 this.targetid = this.prjid; this.getExchangeList({}); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "prjshare") { //共享设置 this.getPrjShareList(); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "stareport") { //统计报告 this.stastics = []; this.getPrjStastics(); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "stageset") { //项目阶段 this.clearStageStatus(); this.getPrjTempletStageList(); } else if (tabDatas[i].id == key && tabDatas[i].shortname == "resources") { //相关资源 this.getPrjResourceInfo(); } } } } getPrjTabs = (params = {}) => { this.prjid = params.prjid; this.selectTabKey = "1"; this.prjisdel = false; Apis.getPrjTabs(params).then(data => { if (!data.isright && typeof (data.isright) !== "undefined") { this.hasRight = data.isright; this.verified = true; } else { this.hasRight = true; this.verified = true; this.tabDatas = data.tabs; this.changeTab(this.selectTabKey); } }) } getPrjInfo = (params = {}) => { this.loading = true; this.form = new WeaForm(); Apis.getPrjInfo(params).then(data => { if (!data.isright && typeof (data.isright) !== "undefined") { this.prjinfoRight = { hasRight: data.isright, verified: true }; } else { this.prjinfoRight = { hasRight: true, verified: true }; this.isApprove = data.isApprove; this.fieldInfo = data.fieldinfo; this.rightMenu = data.rightMenus; this.prjname = data.prjname; this.prjid = data.prjid; this.form && !this.form.isFormInit && this.form.initFormFields(data.fieldinfo); if(data.accessory){ this.setFormFields({"accessory":data.accessory}); } } this.loading = false; }) } //项目看板卡片 getPrjInfoForBoard = (params = {}) => { this.loading = true; this.form = new WeaForm(); BoardApis.getPrjInfoForBoard(params).then(data => { if (!data.isright && typeof (data.isright) !== "undefined") { this.prjinfoRight = { hasRight: data.isright, verified: true }; } else { this.prjinfoRight = { hasRight: true, verified: true }; this.fieldInfo = data.fieldinfo; this.rightMenu = data.rightMenus; this.prjname = data.prjname; this.prjid = data.prjid; this.form && !this.form.isFormInit && this.form.initFormFields(data.fieldinfo); } this.loading = false; }) } //项目看板卡片 -- 编辑保存 savePrjInfoForBoard = (params = {}) => { this.loading = true; this.form.validateForm().then(f => { if (f.isValid) { let newParams = { ...toJS(this.form.getFormParams()), method: "edit", prjid: this.prjid, ...params }; Apis.savePrjInfo(newParams).then(data => { if (data.success) { this.getPrjInfoForBoard({ viewtype: "edit", prjid: this.prjid }); } else { // Modal.warning({ // title: getLabel(15172, "系统提示"), // content: data.msg, // }); message.error(data.msg); } }) } else { f.showErrors(); } }); } //项目信息 -- 编辑保存 savePrjInfo = (params = {},parentStore) => { this.form.validateForm().then(f => { if (f.isValid) { let newParams = { ...toJS(this.form.getFormParams()), method: "edit", prjid: this.prjid, ...params }; Apis.savePrjInfo(newParams).then(data => { if (data.success) { this.getPrjInfo({ viewtype: "view", prjid: this.prjid }); //刷新 if(parentStore && parentStore.refresh){ parentStore.refresh();//调用父页面刷新方法 }else{ //刷新查询列表 if (typeof window.opener._table !== "undefined") { window.opener._table.reLoad(); } } } else { // Modal.warning({ // title: getLabel(15172, "系统提示"), // content: data.msg, // }); message.error(data.msg); } }) } else { f.showErrors(); } }); } //项目执行操作 @action doPlanOpt = (params = {}) => { Apis.doPlanOpt(params).then(data => { this.getPrjInfo({ viewtype: "view", prjid: this.prjid }); }); } //子项目执行操作 @action doSubPlanOpt = (params = {}) => { Apis.doPlanOpt(params).then(data => { this.getPrjSubList(); }); } //任务列表执行操作 @action doPlanOpt_task = (params = {}) => { this.approveplanstatus = true; Apis.doPlanOpt(params).then(data => { if (data.success) { this.getPrjTaskList(); this.getPrjTaskCondition(); this.getPrjTaskVersion(); Modal.success({ title: getLabel(15172, "系统提示"), content: getLabel(16248, "提交成功"), }); if(params.callBack){ params.callBack(); } } else { Modal.error({ title: getLabel(15172, "系统提示"), content: getLabel(15173, "提交失败"), }); } this.approveplanstatus = false; }); } //项目任务保存为计划版本操作 @action saveasplan = (params = {}) => { let _this = this; Modal.confirm({ title: getLabel(15172, "系统提示"), content: getLabel(83928, "您确认要存为计划版本吗?"), onOk() { Apis.doPlanOpt(params).then(data => { _this.getPrjTaskList(); _this.getPrjTaskCondition(); _this.getPrjTaskVersion(); }); }, onCancel() { }, }) } //导出 @action doTaskExcelExp = (params = {}) => { this.loading = true; let newParams = { ...toJS(this.taskListSearchParams), ...toJS(this.taskListform.getFormParams()), ...toJS(this.taskListquickform.getFormParams()), prjid: this.prjid, ...params }; //获取表单的参数值 if(window.setShare4ec){ window.setShare4ec({ mouldCode: 'PRJ', itemCode: 'PRJ_EXPORT_3', encrypt: '1', targetid: "" } , (datas)=>{ const {status,sharepassword = '',serialid = ''} = datas; if(status === '1'){ newParams.sharepassword = sharepassword; newParams.itemCode = 'PRJ_EXPORT_3'; WeaTools.callApi('/api/proj/pctask/doTaskExcelExp','GET',newParams).then(data => { window.location=(window.ecologyContentPath || '')+"/weaver/weaver.file.ExcelOut"; this.loading = false; }).catch(err=>message.error(err)) } }); }else{ WeaTools.callApi('/api/proj/pctask/doTaskExcelExp','GET',newParams).then(data => { window.location=(window.ecologyContentPath || '')+"/weaver/weaver.file.ExcelOut"; this.loading = false; }).catch(err=>message.error(err)) } } setVisiable = (bool) => { this.templatename=this.prjname; this.doSaveVisible = bool; } saveTemplateName =(data)=> { this.templatename = data; } //项目卡片另存为模板 @action doSaveTemplet = (params = {}) => { Apis.doSaveTemplet({ prjname:this.templatename, prjid:this.prjid }).then(data => { if (data.success) { Modal.success({ title: getLabel(15172, "系统提示"), content: getLabel(19468, "另存为模板") + getLabel(84565, "成功!"), }); } else { Modal.error({ title: getLabel(15172, "系统提示"), content: getLabel(19468, "另存为模板") + getLabel(84566, "失败!"), }); } this.setVisiable(false); }); } //项目删除 @action delPrjInfo = (params = {}) => { let _this = this; Modal.confirm({ title: getLabel(15172, "系统提示"), content: getLabel(383860, "您确认要删除项目吗?"), onOk() { Apis.delPrjInfo(params).then(data => { _this.prjisdel = true; if (typeof window.opener._table !== "undefined") { window.opener._table.reLoad(); window.close(); } }); }, onCancel() { }, }) } //项目信息-校验规则 setValidate = (params = {}) => { this.validateRules = params; } //子项目列表 getPrjSubList = (params = {}) => { this.loading = true; const searchParamsAd = this.prjSubform.getFormParams(); const newParams = { prjid: this.prjid, ...searchParamsAd, ...params }; Apis.getPrjSubList(newParams).then(data => { if (!data.isright && typeof (data.isright) !== "undefined") { this.prjsubRight = { hasRight: data.isright, verified: true }; } else { this.prjsubRight = { hasRight: true, verified: true }; this.prjSubStore.getDatas(data.sessionkey, 1); this.rightMenu = data.rightMenus; this.loading = false; } }); } //子项目 高级搜索 getPrjSubCondition = () => { this.prjSubform = new WeaForm(); Apis.getPrjCondition({ conditiontype: "prjsub" }).then(data => { this.condition = data.condition; this.prjSubform && !this.prjSubform.isFormInit && this.prjSubform.initFormFields(data.condition); }) } //删除 exchangeDelete = (value) => { let _this = this; Apis.exchangeDelete(value).then(data => { if(data.status){ _this.getExchangeList() }else { message.error(data.error ? data.error : `${getLabel(384137,'操作失败!')}`); } }) } //获取相关交流信息 @action getExchangeList = (value) => { let _this = this; this.loading = true; const newParams = { types: "PP", sortid: this.prjid, ...value }; Apis.getExchangeList(newParams).then(data => { let exchange = { ...data } exchange.datas.forEach((element, index) => { element.isEdit = false }) exchange.datas.unshift({ id: 'create', isEdit: true, remark: '', docids: [], projectids: [], relatedcus: [], relateddoc: [], relatedprj: [], relatedwf: [], }) _this.exchangeList = exchange; _this._BrowserList = { 'create': {remark: ''}, datas: [], }; _this.exchangeList.datas&&_this.exchangeList.datas.forEach((element, index) => { if (_this._BrowserList[element['id']] == undefined) { _this._BrowserList[element['id']] = {}; } _this._BrowserList[element['id']].remark = element.remark; _this._BrowserList[element['id']].docids = element.docids; _this._BrowserList[element['id']].projectids = element.projectids; _this._BrowserList[element['id']].relatedcus = element.relatedcus; _this._BrowserList[element['id']].relateddoc = element.relateddoc; _this._BrowserList[element['id']].relatedprj = element.relatedprj; _this._BrowserList[element['id']].relatedwf = element.relatedwf; }) _this._BrowserList.datas = _this.exchangeList.datas; this.loading = false; }) } //相关交流datas循环 changeDiscussList = (value = {}) => { this.exchangeList = value; this.exchangeList.datas&&this.exchangeList.datas.forEach((element, index) => { if (this._BrowserList[element['id']] == undefined) { this._BrowserList[element['id']] = {}; } this._BrowserList[element['id']].remark = element.remark; this._BrowserList[element['id']].docids = element.docids; this._BrowserList[element['id']].projectids = element.projectids; this._BrowserList[element['id']].relatedcus = element.relatedcus; this._BrowserList[element['id']].relateddoc = element.relateddoc; this._BrowserList[element['id']].relatedprj = element.relatedprj; this._BrowserList[element['id']].relatedwf = element.relatedwf; }) this._BrowserList.datas = this.exchangeList.datas; } //相关交流提交 exchangeSave = (value) => { let _this = this; Apis.exchangeSave({...value,discusstype:'PP'}).then(data => { if(data.status){ _this.getExchangeList({ }); }else { message.error(data.error ? data.error : `${getLabel(384137,'操作失败!')}`); } }) } //相关交流提交 setBrowserList = (_BrowserList) => { this._BrowserList = _BrowserList; } //高级搜索设值 setFormFields = (value) => { if (this.selectTabKey == "1") { //项目信息 this.form.updateFields(value, false); //true代表完全覆盖方式更新条件值 } if (this.selectTabKey == "3") { //子项目 this.prjSubform.updateFields(value, false); //true代表完全覆盖方式更新条件值 } if (this.selectTabKey == "2") { //任务列表 this.taskListform.updateFields(value, false); //true代表完全覆盖方式更新条件值 } } appendFormFields = (value) => { this.setFormFields(value); } //共享 getPrjShareList = (params = {}) => { //获取表单的参数值 this.loading = true; const newParams = { prjid: this.prjid, ...params }; Apis.getPrjShare(newParams).then(data => { if (!data.isright && typeof (data.isright) !== "undefined") { this.shareRight = { hasRight: data.isright, verified: true }; } else { this.shareRight = { hasRight: true, verified: true }; this.shareTableStore.getDatas(data.sessionkey, 1); this.rightMenu = data.rightMenus; } this.loading = false; }); } showAddShareModal = (bool) => { this.isShowShare = bool; } //统计报告 getPrjStastics = (params = {}) => { this.loading = true; Apis.getPrjStastics({ prjid: this.prjid, ...params }).then(data => { this.stastics = data; this.loading = false; }) } //任务列表 getPrjTaskList = (params = {}) => { this.loading = true; let newParams = { ...toJS(this.taskListSearchParams), ...toJS(this.taskListform.getFormParams()), ...toJS(this.taskListquickform.getFormParams()), prjid: this.prjid, ...params }; for (let item in newParams) { if (newParams[item] == "") { delete newParams[item] } } if (newParams.version == "0") { newParams.version = "" } newParams.isBatchEdit = this.isBatchEdit; Apis.getPrjTaskList(newParams).then(data => { if (!data.isright && typeof (data.isright) !== "undefined") { this.taskListRight = { hasRight: data.isright, verified: true }; } else { this.taskListRight = { hasRight: true, verified: true }; this.status = data.status; this.taskListTableStore.getDatas(data.sessionkey, 1); this.rightMenu = data.rightMenus; this.taskListSearchParams = params.version==""?{version:"0"}:{...this.taskListSearchParams,...params}; }; this.loading = false; }) } //任务列表-condition getPrjTaskCondition = () => { this.taskListform = new WeaForm(); this.taskListquickform = new WeaForm(); this.condition = []; this.taskListQuickitems = []; this.taskListSearchParams = {version: this.taskListSearchParams.version}; Common_Apis.getTaskCondition({ conditiontype: "prjtasklist", prjid: this.prjid }).then(data => { this.condition = data.condition; this.taskListQuickitems = data.quickitmes; this.taskListform && !this.taskListform.isFormInit && this.taskListform.initFormFields(data.condition); this.taskListquickform && !this.taskListquickform.isFormInit && this.taskListquickform.initFormFields(data.quickitmes); }) } getPrjTaskVersion = () => { Apis.getPrjTaskVersion({ prjid: this.prjid }).then(data => { this.taskListTabs = data; }) } showEditTaskModal = (bool) => { this.showEditTask = bool; } //form 重置 clearFormFields = () => { if (this.selectTabKey == "2") { //任务列表 this.taskListform.reset(); //清除查询条件值 } if (this.selectTabKey == "3") { this.prjSubform.reset(); //清除查询条件值 } } //添加共享v addShare = (value) => { Apis.addPrjShare({ ...value, method: 'add', prjid: this.prjid, opttype: 'prj' }).then(data => { if(data.success){ this.getPrjShareList(); }else{ message.error(data.msg); } }) } //批量删除 delBatchShare = (value) => { let _this = this; Modal.confirm({ title: getLabel(15172, "系统提示"), content: getLabel(83601, "您确认要删除选中的记录吗?"), onOk() { Apis.delBatchPjrShare({ id: value, method: 'batchdelete', opttype: 'prj',prjid: _this.prjid }).then(data => { if(data.success){ _this.getPrjShareList(); }else{ message.error(data.msg); } }); }, onCancel() { }, }) } //高级搜索显隐 setShowSearchAd = (bool) => { this.showSearchAd = bool } onShowColumn = () => { //显示定制列 if (this.selectTabKey == "3") { this.prjSubStore.setColSetVisible(true); this.prjSubStore.tableColSet(true) } } getPrjLogList = (params = {}) => { Apis.getPrjLogList(params).then(data => { this.prjLogTableStore.getDatas(data.sessionkey, 1); }) } getPrjFieldLogList = (params = {}) => { Apis.getPrjFieldLogList(params).then(data => { this.prjFieldLogTableStore.getDatas(data.sessionkey, 1); }) } getPrjFieldDetaiLogList = (params = {}) => { Apis.getPrjFieldDetaiLogList(params).then(data => { this.prjFieldDetailLogTableStore.getDatas(data.sessionkey, 1); }) } @action setFieldLogVisible = (v) =>{ this.fieldLogVisible = v; } @action setFieldDetailLogVisible = (v) =>{ this.fieldDetailLogVisible = v; } @action setFieldName = (v) =>{ this.fieldname = v; } @action setField = (v) =>{ this.field = v; } @action setLoaded = () => { this.isreload = true; } getPrjTempletStageList = (params = {}) => { this.loading = true; let newParams = { prjid: this.prjid, ...params }; Apis.getPrjTempletStageList(newParams).then(data => { this.stageInfo.stageColumns = data.columns; this.stageInfo.stageColumnDatas = data.columnDatas; this.stageInfo.canedit = data.canedit; this.rightMenu = data.rightMenus; this.loading = false; }) } onRowSelect = (sRowKeys, rows, dataIndex, selectedDatas) => { this.stageInfo.selectedRowKeys = sRowKeys; if (selectedDatas) { this.stageInfo.selectedDatas = selectedDatas; } } onChange = (datas) => { this.stageInfo.stageColumnDatas = datas; } saveStageSet = (checkProps) => { const { pass } = checkProps; if (pass&&this.checkRepeat()) { let keepgroupids = ""; this.stageInfo.stageColumnDatas.forEach(element => { if (element.id) { keepgroupids += "," + element.id } }); keepgroupids = keepgroupids.substr(1, keepgroupids.length); Apis.savePrjTempletStage({ datas: JSON.stringify(this.stageInfo.stageColumnDatas), keepgroupids: keepgroupids, prjid: this.prjid }).then(data => { if (data.success) { this.clearStageStatus(); message.success(data.msg); this.getPrjTempletStageList(); } else { message.error(data.msg); } }) } } checkRepeat = () => { let repeat = true; let datas = toJS(this.stageInfo.stageColumnDatas); datas && datas.length>0 && datas.map((d1,i1) => { if(repeat){ datas && datas.length>0 && datas.map((d2,i2) => { if(i1 !== i2 && d1.name == d2.name){ message.warning(getLabel('387703',"阶段名称重复!")); repeat = false; } }) } }) return repeat; } clearStageStatus = () => { let _canedit = this.stageInfo.canedit; this.stageInfo = { stageColumns: [], stageColumnDatas: [], selectedRowKeys: [], selectedDatas: {}, canedit:_canedit } } getPrjResourceInfo = (params) => { this.loading = true; let newParams = { prjid: this.prjid, ...params }; Apis.getPrjResources(newParams).then(data => { if(data.success){ this.resourceInfo = { ...data } } this.loading = false; }) } //龙烟二次开发独立代码 @action sendMsg = (params = {}) => { const newParams = { prjid: this.prjid,...params} this.loading = true; WeaTools.callApi('/api/proj/mindmapdev/sendMsg', 'GET', newParams).then(data => { this.loading = false; message.success("发送通知成功!"); }); } setIsBatchEdit = (v) =>{ this.isBatchEdit = v; } resetTaskInfoStore = () =>{ this.taskInfoStore = new TaskInfoStore(); } triggerBreakDownWF = (params = {}) =>{ const newParams = { prjid: this.prjid,...params} WeaTools.callApi('/api/proj/pctask/triggerBreakDownWF', 'POST', newParams).then(data => { if(data.msg=='success'){ this.getPrjTaskList(); this.getPrjTaskCondition(); this.getPrjTaskVersion(); if(params.callBack){ params.callBack(); } message.success(getLabel('513071',"触发流程成功!")); }else{ message.error(getLabel('513072',"触发流程失败!")); } }); } @action delTaskBatch=(type,params)=>{ let _this = this; if(this.taskInfoStore.selectedRowKeys.length > 0){ Modal.confirm({ title: getLabel(15172,"系统提示"), content: getLabel(83925,"该任务及其子任务都会被删除,您确认要删除吗?"), onOk() { Task_Apis.delTask({method:type,taskids:`${_this.taskInfoStore.selectedRowKeys}`}).then(data=>{ if(data.success){ _this.taskInfoStore.selectedRowKeys = []; window._table.reLoad(); Modal.success({ title: getLabel(15172,"系统提示"), content: getLabel(83472,"删除成功!"), }); _this.getPrjTaskList(); _this.getPrjTaskCondition(); _this.getPrjTaskVersion(); if(params.callBack){ params.callBack(); } }else{ message.error(getLabel(383746,"请求失败")+":"+data.msgcode); } }) }, onCancel() { }, }) } } }