weaver_trunk_cli/pc4mobx/prj/stores/exchangeStore.js

137 lines
4.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { observable, action } from 'mobx';
import {WeaTableNew,WeaForm} from 'comsMobx'
const {TableStore} = WeaTableNew;
import { WeaTools,WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import * as Prj_Apis from '../apis/project'
import * as Task_Apis from "../apis/task"
/**
* @author ljc 2017-12-19
* 项目分享通用store模板实例任务执行项目执行等共享设置modal/
*/
export class ExchangeStore{
@observable title = getLabel(15153,"相关交流");
@observable rightMenu = [];
@observable targetid = "";
@observable type = "";
@observable discusstype = "";
@observable visible = false;
@observable showSearchAd = false;
@observable exchangeContent = [];
@observable condition = [];
@observable exchangeList = "";
@observable _BrowserList = {
'create': {remark: ''},
datas: [],
};
@action
handleExchangeDialog = (bool,type,id ,params={}) =>{
this.visible = bool;
if(bool){
this.targetid = id;
this.type = type;
if(type == "prj"){
this.discusstype = "PP";
this.title = getLabel(83810,"项目相关交流");
}else if(type == "task"){
this.discusstype = "PT";
this.title = getLabel(83800,"任务相关交流");
}
this.getExchangeList({});
}
}
//删除
exchangeDelete = (value) => {
let _this = this;
Prj_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;
const newParams = { types: this.discusstype, sortid: this.targetid, ...value };
Prj_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;
})
}
//相关交流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;
Prj_Apis.exchangeSave({...value,discusstype:this.discusstype}).then(data => {
if(data.status){
_this.getExchangeList({});
}else {
message.error(data.error ? data.error : `${getLabel(384137,'操作失败!')}`);
}
})
}
//相关交流提交
setBrowserList = (_BrowserList) => {
this._BrowserList = _BrowserList;
}
}