import React from 'react';
import { Button, Tabs, Row, Col, InputNumber, Modal, message } from 'antd';
import { inject, observer } from 'mobx-react';
import { toJS } from "mobx"
import { WeaRightMenu, WeaReqTop, WeaNewScroll, WeaTools, WeaAlertPage, WeaDialog, WeaBrowser, WeaLocaleProvider, WeaTop, WeaTab } from "ecCom"
import { WeaTableNew, WeaSwitch } from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getKey = WeaTools.getKey;
const getLabel = WeaLocaleProvider.getLabel;
import RelareExchange from '../common/relateExchange'
import TabDiscuss from '../common/TabDiscuss'
import RelateWorkFlow from '../common/relateWorkFlow'
import RelateDocument from "../common/relateDocument"
import TaskSub from '../projectBoard/taskSub'
import TaskShare from '../common/sharePage'
import TaskInfo from '../common/taskInfo'
import RealteCrmDialog from '../dialog/relateCrmDialog'
import "../projectBoard/style/slide.less"
@observer
export default class TaskCard extends React.Component {
componentDidMount() {
const { taskCardStore, taskid } = this.props;
const { getTaskTabs } = taskCardStore;
getTaskTabs({taskid: taskid });
}
componentWillUnmount() {
}
componentWillReceiveProps(nextprops) {
const { taskCardStore } = this.props;
const { clearStatus, getTaskTabs } = taskCardStore;
if (this.props.taskid !== nextprops.taskid) {
clearStatus();
getTaskTabs({ taskid: nextprops.taskid });
}
}
render() {
const { taskCardStore, callBack } = this.props;
const { tabDatas, selectTabKey, loading, taskname, shareStore, hasRight, verified, form, taskid, saveAndReLoadWf } = taskCardStore;
if (verified && !hasRight) {
return (
{getLabel(2012, "对不起,您暂时没有权限!")}
)
}
if (verified && hasRight) {
const tabDatas1 = toJS(tabDatas);
let _this = this;
let tabUrl = function (key) {
if (tabDatas1) {
for (let i = 0; i < tabDatas1.length; i++) {
if (tabDatas1[i].id == key && tabDatas1[i].shortname == "taskinfo") {
return
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "tasksub") {
return
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "exchange") {
return
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "taskshare") {
return
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "req") {
return
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "doc") {
return
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "crm") {
return {_this.getReleateCrmOrCpt("crm")}
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "cpt") {
return {_this.getReleateCrmOrCpt("cpt")}
_this.addCapital(ids, names, datas)} customized={true} hasAdvanceSerach={true}>
} else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "") {
if (tabDatas[i].linkurl.indexOf("noright") > -1) {
return
{getLabel(2012, "对不起,您暂时没有权限!")}
} else {
return tabDatas1[i].linkurl;
}
}
}
return ""
}
}(selectTabKey);
return (
}
iconBgcolor='#217346'
buttons={this.getButtons()}
buttonSpace={10}
showDropIcon={true}
dropMenuDatas={this.getRightMenu()}
onDropMenuClick={this.onRightMenuClick.bind(this)}
tabDatas={tabDatas}
selectedKey={selectTabKey}
onChange={this.taskCardChangeTab.bind(this)}
>
{
typeof tabUrl === "object" ? tabUrl :
}
)
}
return (
)
}
getReleateCrmOrCpt(type) {
const { taskRelRight: { hasRight, verified }, taskCrmStore, taskCptStore } = this.props.taskCardStore;
if (verified && !hasRight) {
return (
{getLabel(2012, "对不起,您暂时没有权限!")}
)
}
if (verified && hasRight) {
if (type == "crm") {
return
}
if (type == "cpt") {
return
}
}
return
}
getButtons() {
const { taskCardStore, contentStore } = this.props;
const { rightMenu, taskid, selectTabKey, taskInfoStore, prjid, shareTableStore, taskCptStore, taskCrmStore, tabDatas, canSave , setCanSave } = taskCardStore;
let btnArr = [];
let that = this;
const tabDatas1 = toJS(tabDatas);
rightMenu && rightMenu.length > 0 && rightMenu.map(m => {
let disabled = false;
if (tabDatas1) {
for (let i = 0; i < tabDatas1.length; i++) {
if (tabDatas1[i].shortname == "taskshare" && tabDatas1[i].key == selectTabKey) {
let { selectedRowKeys } = shareTableStore;
disabled = selectedRowKeys.length == 0 ? true : false;
} else if (tabDatas1[i].shortname == "cpt" && tabDatas1[i].key == selectTabKey) {
let { selectedRowKeys } = taskCptStore;
disabled = selectedRowKeys.length == 0 ? true : false;
} else if (tabDatas1[i].shortname == "crm" && tabDatas1[i].key == selectTabKey) {
let { selectedRowKeys } = taskCrmStore;
disabled = selectedRowKeys.length == 0 ? true : false;
} else if (tabDatas1[i].shortname == "taskinfo" && tabDatas1[i].key == selectTabKey) {
disabled = canSave ? false : true;
}
}
}
m.isTop == '1' && btnArr.length < 4 && btnArr.push(
{
let fn = m.menuFun.indexOf('this') >= 0 ? `${m.menuFun.split('this')[0]})` : m.menuFun;
if (tabDatas1) {
for (let i = 0; i < tabDatas1.length; i++) {
if (tabDatas1[i].shortname == "taskinfo" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_EDIT") { //编辑
taskCardStore.getTaskForm({ viewtype: 'edit', taskid: taskid });
} else if (m.type == "BTN_SAVE") { //保存
setCanSave(false);
taskCardStore.saveTaskInfo({ taskid: taskid }, contentStore);
} else if (m.type == "BTN_DELETE") { //删除
taskCardStore.delTask("del", taskid, contentStore);
} else if (m.type == "BTN_BACK") { //返回
taskCardStore.getTaskForm({ viewtype: 'view', taskid: taskid });
}
} else if (tabDatas1[i].shortname == "cpt" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
this.refs.addCpt.openModal();
} else if (m.type == "BTN_DELETEBATCH") { //删除
this.deleteCrmOrCpt('cpt');
}
} else if (tabDatas1[i].shortname == "crm" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
taskCardStore.handleRelateCrmDialog(true, "add", {
crmid: { value: '', valueSpan: '', valueObj: [] },
reasondesc: { value: "" }
});
} else if (m.type == "BTN_DELETEBATCH") { //删除
this.deleteCrmOrCpt('crm');
}
} else if (tabDatas1[i].shortname == "req" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_NEWREQ") {
//console.log("新建流程")
this.openFullWindow((window.ecologyContentPath || '')+"/spa/workflow/static/index.html#/main/workflow/add?openNewWindow=0&taskid=" + taskid);
}
} else if (tabDatas1[i].shortname == "doc" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_NEWDOC") {
//console.log("新建文档")
this.openFullWindow((window.ecologyContentPath || '')+'/spa/document/static/index.html#/main/document/add?openNewWindow=0&moudleFrom=task');
let _this = this;
window.__createDocFn = function (obj) {
let docid = obj.docid;
let docsubject = obj.docSubject;
// console.log(docid,docsubject);
_this.addDocument(docid,docsubject,'');
}
}
} else if (tabDatas1[i].shortname == "taskshare" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
taskCardStore.showAddShareModal(true);
} else if (m.type == "BTN_DELETEBATCH") { //删除
let { selectedRowKeys } = shareTableStore;
taskCardStore.delBatchShare(`${toJS(selectedRowKeys)}`);
}
}
}
if(m.type == "BTN_NEWSUB"){ //添加子任务
taskInfoStore.handleDialog(true,"add",taskid,{prjid:prjid,parentid:taskid});
}
}
}}>
{m.menuName}
);
});
return btnArr;
}
getRightMenu() {
const { taskCardStore } = this.props;
const { rightMenu, selectTabKey, shareTableStore, taskCptStore, taskCrmStore, tabDatas, canSave } = taskCardStore;
let btnArr = [];
const tabDatas1 = toJS(tabDatas);
rightMenu && rightMenu.length > 0 && rightMenu.map(m => {
let disabled = false;
if (tabDatas1) {
for (let i = 0; i < tabDatas1.length; i++) {
if (tabDatas1[i].shortname == "taskshare" && tabDatas1[i].key == selectTabKey) {
let { selectedRowKeys } = shareTableStore;
disabled = selectedRowKeys.length == 0 ? true : false;
} else if (tabDatas1[i].shortname == "cpt" && tabDatas1[i].key == selectTabKey) {
let { selectedRowKeys } = taskCptStore;
disabled = selectedRowKeys.length == 0 ? true : false;
} else if (tabDatas1[i].shortname == "crm" && tabDatas1[i].key == selectTabKey) {
let { selectedRowKeys } = taskCrmStore;
disabled = selectedRowKeys.length == 0 ? true : false;
} else if (tabDatas1[i].shortname == "taskinfo" && tabDatas1[i].key == selectTabKey) {
disabled = canSave ? false : true;
}
}
}
btnArr.push({
icon: ,
content: m.menuName,
disabled: (m.type == "BTN_DELETEBATCH"||m.type == "BTN_SAVE") ? disabled : false
})
});
return btnArr
}
onRightMenuClick(key) {
const { taskCardStore, contentStore } = this.props;
const { rightMenu, taskid, selectTabKey, taskInfoStore, prjid, shareTableStore, tabDatas, setCanSave } = taskCardStore;
let that = this;
const tabDatas1 = toJS(tabDatas);
rightMenu && rightMenu.length > 0 && rightMenu.map((m, i) => {
if (Number(key) == i) {
if (tabDatas1) {
for (let i = 0; i < tabDatas1.length; i++) {
if (tabDatas1[i].shortname == "taskinfo" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_EDIT") { //编辑
taskCardStore.getTaskForm({ viewtype: 'edit', taskid: taskid });
} else if (m.type == "BTN_SAVE") { //保存
setCanSave(false);
taskCardStore.saveTaskInfo({ taskid: taskid }, contentStore);
} else if (m.type == "BTN_DELETE") { //删除
taskCardStore.delTask("del", taskid, contentStore);
} else if (m.type == "BTN_BACK") { //返回
taskCardStore.getTaskForm({ viewtype: 'view', taskid: taskid });
}
} else if (tabDatas1[i].shortname == "cpt" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
this.refs.addCpt.openModal();
} else if (m.type == "BTN_DELETEBATCH") { //删除
this.deleteCrmOrCpt('cpt');
}
} else if (tabDatas1[i].shortname == "crm" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
taskCardStore.handleRelateCrmDialog(true, "add", {
crmid: { value: '', valueSpan: '', valueObj: [] },
reasondesc: { value: "" }
});
} else if (m.type == "BTN_DELETEBATCH") { //删除
this.deleteCrmOrCpt('crm');
}
} else if (tabDatas1[i].shortname == "req" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_NEWREQ") {
//console.log("新建流程")
this.openFullWindow((window.ecologyContentPath || '')+"/spa/workflow/static/index.html#/main/workflow/add?openNewWindow=0&taskid=" + taskid);
}
} else if (tabDatas1[i].shortname == "doc" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_NEWDOC") {
//console.log("新建文档")
this.openFullWindow((window.ecologyContentPath || '')+'/spa/document/static/index.html#/main/document/add?openNewWindow=0&moudleFrom=task');
let _this = this;
window.__createDocFn = function (obj) {
let docid = obj.docid;
let docsubject = obj.docSubject;
// console.log(docid,docsubject);
_this.addDocument(docid,docsubject,'');
}
}
} else if (tabDatas1[i].shortname == "taskshare" && tabDatas1[i].key == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
taskCardStore.showAddShareModal(true);
} else if (m.type == "BTN_DELETEBATCH") { //删除
let { selectedRowKeys } = shareTableStore;
taskCardStore.delBatchShare(`${toJS(selectedRowKeys)}`);
}
}
}
}
if (m.type == "BTN_NEWSUB") { //添加子任务
taskInfoStore.handleDialog(true, "add", taskid, { prjid: prjid, parentid: taskid });
} else if (m.type == "BTN_COLUMN") { //定制列
taskCardStore.onShowColumn();
}
}
});
}
taskCardChangeTab(key) {
const { taskCardStore } = this.props;
taskCardStore.changeTab(key);
}
cancelShare = () => {
const { taskCardStore } = this.props;
taskCardStore.showTaskShare(false);
}
saveShare = () => {
const { taskCardStore } = this.props;
taskCardStore.showTaskShare(false);
}
reloadExchanges = () => {
const { taskCardStore } = this.props;
taskCardStore.getRelateExchangeInfo();
}
deleteCrmOrCpt = (type) => {
const { taskCardStore } = this.props;
const { taskid, doDspTaskReferenceOpt, taskCrmStore, taskCptStore } = taskCardStore;
const { selectedRowKeys } = (type == "cpt" ? taskCptStore : taskCrmStore);
if (selectedRowKeys.length > 0) {
Modal.confirm({
title: getLabel(15172, "系统提示"),
content: getLabel(83601, "您确认要删除选中的记录吗?"),
onOk() {
doDspTaskReferenceOpt({
dotype: type,
method: 'del',
prjid: "",
taskid: taskid,
ids: `${toJS(selectedRowKeys)}`
}, type)
},
onCancel() { },
})
} else {
// Modal.warning({
// title: getLabel(15172, "系统提示"),
// content: getLabel(84093, "请至少选择一条记录!"),
// })
message.error(getLabel(84093, "请至少选择一条记录!"));
}
}
//资产操作按钮
onCrmOperatesClick = (record, index, operate, flag) => {
let _href = operate && operate.href ? operate.href : "";
let fn = _href.replace("javascript:", "");
fn = fn.substring(0, fn.indexOf('('));
const { taskCardStore } = this.props;
const { doDspTaskReferenceOpt, taskid, taskDocStore } = taskCardStore;
if (fn != "") {
if ("onDelRelated" == fn) { //delete
Modal.confirm({
title: getLabel(15172, "系统提示"),
content: getLabel(83600, "您确认要删除吗?"),
onOk() {
doDspTaskReferenceOpt({
dotype: 'crm',
method: 'del',
prjid: "",
taskid: taskid,
ids: record.randomFieldId
}, 'crm')
},
onCancel() { },
})
} else if ("onEdit" == fn) { //编辑
taskCardStore.setRelateCrmUpdateID(record.randomFieldId);
taskCardStore.handleRelateCrmDialog(true, "edit", {
crmid: {
value: record.customerid,
valueSpan: record.customeridspan,
valueObj: [{ id: record.customerid, name: record.customeridspan, }],
},
reasondesc: { value: record.reasondesc }
});
}
}
}
//资产操作按钮
onCptOperatesClick = (record, index, operate, flag) => {
let _href = operate && operate.href ? operate.href : "";
let fn = _href.replace("javascript:", "");
fn = fn.substring(0, fn.indexOf('('));
const { taskCardStore } = this.props;
const { doDspTaskReferenceOpt, taskid, taskDocStore } = taskCardStore;
if (fn != "") {
if ("onDelRelated" == fn) { //delete
Modal.confirm({
title: getLabel(15172, "系统提示"),
content: getLabel(83600, "您确认要删除吗?"),
onOk() {
doDspTaskReferenceOpt({
dotype: 'cpt',
method: 'del',
prjid: "",
taskid: taskid,
ids: record.randomFieldId
}, 'cpt')
},
onCancel() { },
})
}
}
}
//资产新建
addCapital = (ids, name, data) => {
const { taskCardStore } = this.props;
const { doDspTaskReferenceOpt, taskid, prjid } = taskCardStore;
doDspTaskReferenceOpt({
dotype: 'cpt',
method: 'add',
prjid: prjid,
taskid: taskid,
cptid: ids
}, 'cpt');
}
openFullWindow = (url) => {
const width = screen.availWidth - 10;
const height = screen.availHeight - 50;
let szFeatures = 'top=0,';
szFeatures += 'left=0,';
szFeatures += `width=${width},`;
szFeatures += `height=${height},`;
szFeatures += 'directories=no,';
szFeatures += 'status=yes,toolbar=no,location=no,';
szFeatures += 'menubar=no,';
szFeatures += 'scrollbars=yes,';
szFeatures += 'resizable=yes';
window.open(url, '', szFeatures);
}
//新建
addDocument=(ids, names, datas)=>{
const {taskCardStore} = this.props;
const {doDspTaskReferenceOpt,taskid,prjid} = taskCardStore;
doDspTaskReferenceOpt({
dotype:'doc',
method:'add',
prjid : prjid,
taskid:taskid,
docid:ids,
ids:""
},'doc')
}
}