115 lines
2.5 KiB
JavaScript
115 lines
2.5 KiB
JavaScript
|
|
import {
|
|||
|
|
observable,
|
|||
|
|
action
|
|||
|
|
} from 'mobx';
|
|||
|
|
import { WeaTools } from 'ecCom';
|
|||
|
|
import * as mobx from 'mobx';
|
|||
|
|
import * as API from '../apis/orgchart';
|
|||
|
|
import {
|
|||
|
|
Modal,
|
|||
|
|
message,
|
|||
|
|
} from 'antd'
|
|||
|
|
import {
|
|||
|
|
i18n
|
|||
|
|
} from '../public/i18n';
|
|||
|
|
import moment from "moment";
|
|||
|
|
const toJS = mobx.toJS;
|
|||
|
|
|
|||
|
|
|
|||
|
|
export class OrgChartStore {
|
|||
|
|
|
|||
|
|
@observable spinning = false;
|
|||
|
|
@observable hasRight = '';
|
|||
|
|
@observable date = moment(new Date()).format('YYYY-MM-DD');
|
|||
|
|
|
|||
|
|
iframe;
|
|||
|
|
/********************* action list *********************/
|
|||
|
|
initData = (refresh = false) => {
|
|||
|
|
this.iframe = null;
|
|||
|
|
//this.hasRight = true;
|
|||
|
|
this.callInitData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
callInitData = () => {
|
|||
|
|
if(this.spinning)
|
|||
|
|
return;
|
|||
|
|
this.spinning = true;
|
|||
|
|
this.getChartData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
setIframe = (iframe) => {
|
|||
|
|
if(iframe == null || this.iframe != null)
|
|||
|
|
return;
|
|||
|
|
this.iframe = iframe;
|
|||
|
|
this.callInitData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
changeDate = (value) => {
|
|||
|
|
this.date = value;
|
|||
|
|
this.getChartData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
onInitOrgChart = (status) => {
|
|||
|
|
this.spinning = false;
|
|||
|
|
switch (status) {
|
|||
|
|
case 0:
|
|||
|
|
message.error(i18n.message.dataNone());
|
|||
|
|
break;
|
|||
|
|
case -1:
|
|||
|
|
message.error(i18n.message.dataConstructError());
|
|||
|
|
break
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
showSpin = (val) => {
|
|||
|
|
this.spinning = (val === '0');
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@action getChartData = (reset = false) => {
|
|||
|
|
this.spinning = true;
|
|||
|
|
const params = {};
|
|||
|
|
|
|||
|
|
Object.assign(params, {
|
|||
|
|
arg0: 1,
|
|||
|
|
arg3: true,
|
|||
|
|
arg11: ';;B',
|
|||
|
|
date: this.date
|
|||
|
|
});
|
|||
|
|
API.getOrgChartData(params).then(data => {
|
|||
|
|
if (data.status === '1') {
|
|||
|
|
const msgData = {
|
|||
|
|
act: 'orgChart', // 自定义的消息类型、行为,用于switch条件判断等。。
|
|||
|
|
orgData: data.data,
|
|||
|
|
params: {
|
|||
|
|
sorgid: 1,
|
|||
|
|
isShow: params.arg11,
|
|||
|
|
showNum: 'false',
|
|||
|
|
shownum: 25
|
|||
|
|
},
|
|||
|
|
client: {
|
|||
|
|
browser: WeaTools.ua.browser,
|
|||
|
|
browserVersion: {
|
|||
|
|
browser: WeaTools.ua.browser,
|
|||
|
|
version: parseInt(WeaTools.ua.version)
|
|||
|
|
},
|
|||
|
|
version: parseInt(WeaTools.ua.version),
|
|||
|
|
os: WeaTools.ua.os
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
const sendMsg = setInterval(() => {
|
|||
|
|
if ($('#orgChartFrame')[0] != null) {
|
|||
|
|
clearInterval(sendMsg);
|
|||
|
|
$('#orgChartFrame')[0].contentWindow.postMessage(msgData, '*');
|
|||
|
|
}
|
|||
|
|
}, 500);
|
|||
|
|
// this.iframe && this.iframe.contentWindow.postMessage(msgData, '*');
|
|||
|
|
} else {
|
|||
|
|
this.spinning = false;
|
|||
|
|
}
|
|||
|
|
}, error => {
|
|||
|
|
this.spinning = false;
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|