import { inject, observer } from "mobx-react";
import { toJS } from "mobx"
import React from 'react';
import { WeaLeftRightLayout, WeaTop, WeaTab, WeaNewScroll, WeaLocaleProvider, WeaBrowser, WeaAlertPage } from 'ecCom';
import { WeaTableNew } from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;
import '../style/taskCardNew.less';
import ListView from "../../comp/task-view-list";
import { Row, Tooltip, Col, Icon, Modal, message } from "antd";
import { TaskDynamic } from "./TaskDynamic";
import TabDiscuss from '../../common/TabDiscuss'
import RelateWorkFlow from '../../common/relateWorkFlow'
import RelateDocument from "../../common/relateDocument"
import TaskSub from '../../common/taskSub';
import { TabComponent as TabSelf } from '../../common/tabComponent';
import TaskShare from '../../common/sharePage'
//import TaskNewInfo from './TaskNewInfo'
import RealteCrmDialog from '../../dialog/relateCrmDialog'
import ProjectLogDialog from "../../dialog/modifyLogDialog"
import ProjectFieldLogDialog from '../../dialog/projectFieldLogDialog';
import ProjectFieldDetailLogDialog from '../../dialog/ProjectFieldDetailLogDialog';
import TaskInfoDialog from '../../dialog/taskDialog'
import PrjForm from "../../prjForm.js";
import classnames from 'classnames';
// const rightMenus = [
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-edit", menuName: "编辑", type: "BTN_EDIT" },
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-delete", menuName: "删除", type: "BTN_DELETE" }
// ],
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-New-Flow", menuName: "添加", type: "BTN_APPEND" },
// { isControl: "1", isTop: "1", menuFun: "", menuIcon: "icon-coms-delete", menuName: "批量删除", type: "BTN_DELETEBATCH" }
// ],
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-New-Flow", menuName: "添加子任务", type: "BTN_NEWSUB" },
// { isTop: "0", menuFun: "", menuIcon: "icon-coms-Custom", menuName: "显示列定制", type: "BTN_COLUMN" },
// { isTop: "1", type: "searchsAd" }
// ],
// [
// ],
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-New-Flow", menuName: "新建流程", type: "BTN_NEWREQ" }
// ],
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-New-Flow", menuName: "新建文档", type: "BTN_NEWDOC" }
// ],
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-New-Flow", menuName: "添加", type: "BTN_APPEND" },
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-delete", menuName: "批量删除", type: "BTN_DELETEBATCH" }
// ],
// [
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-New-Flow", menuName: "添加", type: "BTN_APPEND" },
// { isTop: "1", menuFun: "", menuIcon: "icon-coms-delete", menuName: "批量删除", type: "BTN_DELETEBATCH" }
// ]
// ]
@inject("taskCardNewStore","taskDynamicStore")
@observer
class TaskCardNew extends React.Component {
static defaultProps = {
prefixCls: 'new'
};
constructor(props) {
super(props);
this.state = {
selectedKey : "",
showdt : false
}
}
componentDidMount(){
const { prjid, taskCardNewStore, hasList, taskid } = this.props;
if(hasList){
taskCardNewStore.initData(prjid);
}else{
taskCardNewStore.initTaskData(taskid);
}
}
componentWillReceiveProps(nextProps) {
if (this.props.prjid !== nextProps.prjid) {
const { prjid, taskCardNewStore, hasList, taskid } = nextProps;
if(hasList){
taskCardNewStore.initData(prjid);
}else{
taskCardNewStore.initTaskData(taskid);
}
}
}
render() {
const { taskCardNewStore, taskid, hasList, prefixCls, taskInfoStore, prjid, isDialog, taskDynamicStore, delCallBack, fromPortal } = this.props;
const { taskinfo, loading, changeTabs } = taskCardNewStore;
const { tabDatas, selectTabKey, shareStore, taskLogTableStore, taskFieldLogTableStore, taskFieldDetailLogTableStore, fieldname, fieldinfo, getTaskList, breadcrumb, rightMenu, getTaskForm, initData, initTaskData } = taskCardNewStore;
const { getPortalProjectDynamicInfo } = taskDynamicStore;
const tabDatas1 = toJS(tabDatas);
let _this = this;
const titleStyle = {
fontSize : "15px"
}
const height = document.body.offsetHeight - $(".prj-portal-page .wea-new-top-wapper").height() - 57 - 52.4 - $(".task_card_new .task_card_new_l_top").height() - 20 - 30;
const scrollHeight = ($(".e9theme-layout-header").length > 0 || $(".e8theme-layout-header").length > 0) ? height - 55 - 22 : height - 15;
const { showdt } = this.state;
const textdt = showdt ? getLabel('518183','显示动态') : getLabel('518184','隐藏动态');
const classdtArrow = classnames({
'new-show-dt-arrow': showdt,
'new-show-dt-arrow-r': !showdt
});
const classdtLine = classnames('new-dt-container',{
'new-show-dt-line': showdt,
'new-show-dt-line-r': !showdt
});
const classCardL = classnames('task_card_new_l',{
'task_card_new_l_contents': showdt
})
const bWidth = !showdt?"62%":"100%";
const showDynamic = !showdt?"":"none";
const tabRenderNode = {
[selectTabKey]: {
'taskinfo':
< ProjectLogDialog ecId={`${this && this.props && this.props.ecId || ''}_ProjectLogDialog@t80d3f`} ref="taskLogDialog" title={getLabel('83926', '任务日志')} tableStore={taskLogTableStore} store={taskCardNewStore} />
{
if(hasList){
initData(prjid);
}else{
initTaskData(taskid);
}
getTaskForm({ viewtype: 'view', taskid: taskCardNewStore.taskid });
getPortalProjectDynamicInfo("alltask");
getPortalProjectDynamicInfo("tasklog");
}} />
,
'tasksub': {
if(hasList){
initData(prjid);
}else{
initTaskData(taskid);
}
}} />
,
'exchange':
,
'taskshare':
,
'req':
,
'doc':
,
'crm': {_this.getReleateCrmOrCpt("crm")}
,
'cpt': {_this.getReleateCrmOrCpt("cpt")}
_this.addCapital(ids, names, datas)} customized={true} hasAdvanceSerach={true} />
}
}
const tabRenderHandle = (id, shortname, linkurl) => {
if (shortname !== '') {
return tabRenderNode[id][shortname]
} else if (shortname === "") {
if (linkurl.indexOf("noright") > -1) {
return
{getLabel(2012, "对不起,您暂时没有权限!")}
} else {
return linkurl;
}
}
}
let tabUrl = function () {
if (tabDatas1) {
const prefixCls = 'new-tab-bar-menu'
for (let i = 0; i < tabDatas1.length; i++) {
if (tabDatas1[i].id == selectTabKey) {
if (tabDatas1[i].shortname !== ''){
return (
{
rightMenu&&rightMenu.length>1&&
{rightMenu.map((menu,i) => (
menu.isTop == 1 &&
(menu.type === 'searchsAd' ?
: - { _this.menuClick(menu) }}>{menu.menuName}
)
))
}
}
1)?'45px':'0px',bottom: '0px',width: '100%'}}>
{
tabRenderHandle(tabDatas1[i].id, tabDatas1[i].shortname, tabDatas[i].linkurl)
}
)
}else if (tabDatas1[i].shortname === ""){
return tabRenderHandle(tabDatas1[i].id, tabDatas1[i].shortname, tabDatas[i].linkurl);
}
}
}
return ""
}
}();
if (hasList) {
if(taskCardNewStore.taskList.length==0){
return
{getLabel(83553, '暂无数据')}
{
if(hasList){
initData(prjid);
if(delCallBack){
delCallBack();
}
}else{
initTaskData(taskid);
}
}} />
}
return (
}
onCollapse={showLeft => {}}
>
{/*
任务1
展开收起按钮
*/}
{ this.setState(pre => ({ showdt: !pre.showdt })) }}>{textdt}
]}
loading={loading}
breadcrumb={breadcrumb || [{ name: "#9" }, { name: "#12" }, { name: "#13" }]}
/>
0?taskinfo.hrmidname.join(' '):taskinfo.hrmidname}>
{taskinfo.hrmidname&&taskinfo.hrmidname.length>0?taskinfo.hrmidname.join(' '):taskinfo.hrmidname}
{getLabel('15285', '任务负责人')}
{
taskinfo.finish == 100 ? :
taskinfo.islater ? :
//
taskinfo.wks ? :
}
{
taskinfo.finish == 100 ? getLabel('23774','已完成') : taskinfo.islater ? getLabel('21984', "已超期") : taskinfo.wks ? getLabel(1979,"未开始") : getLabel('1960','进行中')
}
{getLabel('1929','当前状态')}
{taskinfo.islandmark == 0 ? getLabel('30587', '否') : getLabel('163', '是')}
{getLabel('2232', '里程碑任务')}
{taskinfo.begindate ||getLabel('514133','未设置')}~{taskinfo.enddate ||getLabel('514133','未设置')}
{getLabel('518186','开始结束时间')}
changeTabs(v) }
/>
{
typeof tabUrl === "object" ? tabUrl :
}
{ getTaskList(); }} />
)
}else{
return(
{/*
任务1
展开收起按钮
*/}
}
iconBgcolor='#217346'
buttons={[]}
loading={loading}
/>
0?taskinfo.hrmidname.join(' '):taskinfo.hrmidname}>
{taskinfo.hrmidname&&taskinfo.hrmidname.length>0?taskinfo.hrmidname.join(' '):taskinfo.hrmidname}
{getLabel('15285','任务负责人')}
{
taskinfo.finish == 100 ? :
taskinfo.islater ? :
//
taskinfo.wks ? :
}
{
taskinfo.finish == 100 ? getLabel('23774','已完成') : taskinfo.islater ? getLabel('21984', "已超期") : taskinfo.wks ? getLabel(1979,"未开始") : getLabel('1960','进行中')
}
{getLabel('1929','当前状态')}
{
{taskinfo.islandmark == 0 ? getLabel('30587', '否') : getLabel('163', '是')}
{getLabel('2232','里程碑任务')}
}
{taskinfo.begindate}~{taskinfo.enddate}
{getLabel('518186','开始结束时间')}
changeTabs(v) }
/>
{
typeof tabUrl === "object" ? tabUrl :
}
)
}
}
getReleateCrmOrCpt(type) {
const { taskRelRight: { hasRight, verified }, taskCrmStore, taskCptStore } = this.props.taskCardNewStore;
if (verified && !hasRight) {
return (
{getLabel(2012, "对不起,您暂时没有权限!")}
)
}
if (verified && hasRight) {
if (type == "crm") {
return
}
if (type == "cpt") {
return
}
}
return
}
//资产操作按钮
onCrmOperatesClick = (record, index, operate, flag) => {
let _href = operate && operate.href ? operate.href : "";
let fn = _href.replace("javascript:", "");
fn = fn.substring(0, fn.indexOf('('));
const { taskCardNewStore } = this.props;
const { doDspTaskReferenceOpt, taskid, taskDocStore } = taskCardNewStore;
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) { //编辑
taskCardNewStore.setRelateCrmUpdateID(record.randomFieldId);
taskCardNewStore.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 { taskCardNewStore } = this.props;
const { doDspTaskReferenceOpt, taskid, taskDocStore } = taskCardNewStore;
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() { },
})
}
}
}
menuClick = (m) =>{
const { taskCardNewStore, prjid, delCallBack } = this.props;
const { selectTabKey, shareTableStore, tabDatas, taskInfoStore, taskid } = taskCardNewStore;
const tabDatas1 = toJS(tabDatas);
if (tabDatas1) {
for (let i = 0; i < tabDatas1.length; i++) {
console.log(tabDatas1[i],tabDatas1[i].shortname,tabDatas1[i].key,selectTabKey)
if (tabDatas1[i].shortname == "taskinfo" && tabDatas1[i].id == selectTabKey) {
if (m.type == "BTN_EDIT") { //编辑
taskInfoStore.handleDialog(true,"edit",taskid);
} else if (m.type == "BTN_SAVE") { //保存
taskCardNewStore.saveTaskInfo({ taskid: taskid });
} else if (m.type == "BTN_DELETE") { //删除
taskCardNewStore.delTask("del", taskid, {callBack: ()=> {if(delCallBack){delCallBack()}}});
} else if (m.type == "BTN_BACK") { //返回
taskCardNewStore.getTaskForm({ viewtype: 'view', taskid: taskid });
}
} else if (tabDatas1[i].shortname == "cpt" && tabDatas1[i].id == 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].id == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
taskCardNewStore.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].id == 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].id == 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].id == selectTabKey) {
if (m.type == "BTN_APPEND") { //添加
taskCardNewStore.showAddShareModal(true);
} else if (m.type == "BTN_DELETEBATCH") { //删除
let { selectedRowKeys } = shareTableStore;
if (selectedRowKeys.length > 0) {
taskCardNewStore.delBatchShare(`${toJS(selectedRowKeys)}`);
} else {
message.error(getLabel(84093, "请至少选择一条记录!"));
}
}
}
}
if(m.type == "BTN_NEWSUB"){ //添加子任务
taskInfoStore.handleDialog(true,"add",taskid,{prjid:prjid,parentid:taskid});
}
}
}
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 {taskCardNewStore,prjid} = this.props;
const {doDspTaskReferenceOpt,taskid} = taskCardNewStore;
doDspTaskReferenceOpt({
dotype:'doc',
method:'add',
prjid : prjid,
taskid:taskid,
docid:ids,
ids:""
},'doc')
}
addWorkFlow=(ids, names, datas)=>{
const {taskCardNewStore,prjid} = this.props;
const {doDspTaskReferenceOpt,taskid} = taskCardNewStore;
doDspTaskReferenceOpt({
dotype:'doc',
method:'add',
prjid : prjid,
taskid:taskid,
docid:ids,
ids:""
},'doc')
}
//资产新建
addCapital = (ids, name, data) => {
const { taskCardNewStore, prjid } = this.props;
const { doDspTaskReferenceOpt, taskid } = taskCardNewStore;
doDspTaskReferenceOpt({
dotype: 'cpt',
method: 'add',
prjid: prjid,
taskid: taskid,
cptid: ids
}, 'cpt');
}
deleteCrmOrCpt = (type) => {
const { taskCardNewStore } = this.props;
const { taskid, doDspTaskReferenceOpt, taskCrmStore, taskCptStore } = taskCardNewStore;
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, "请至少选择一条记录!"));
}
}
}
export default TaskCardNew;