import { inject, observer } from "mobx-react"; import React from 'react'; import { Button, Card, Row, Col, Modal, message } from 'antd'; import { WeaNewScroll, WeaRichText, WeaBrowser, WeaTextarea, WeaLocaleProvider, WeaDialog } from 'ecCom'; import { toJS } from "mobx"; import '../style/taskDynamic.less'; import { imgZoom} from '../../../util/index'; const confirm = Modal.confirm; const getLabel = WeaLocaleProvider.getLabel; import Edit from "../../portal/edit"; import { JlChild, jlParamsHandle, Daily, Log } from "../../tools/dtConfig"; @inject("taskDynamicStore") @observer export class TaskDynamic extends React.Component { constructor(props) { super(props); this.state = { selectedKey: "0", value: "3", viewAttr: 3, selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showDailyEdit: {}, visible: false, showRich: false, richValue: '', richValueChangeMethod: () =>{}, richMethod: () =>{}, isCreate:true }; } componentDidMount(){ let dom = ReactDOM.findDOMNode(this); imgZoom(dom, ".wea-cl-content"); const { taskid, taskDynamicStore } = this.props; taskDynamicStore.setTaskId(taskid); taskDynamicStore.initData(); } componentDidUpdate(prevProps, prevState) { let dom = ReactDOM.findDOMNode(this); imgZoom(dom, ".wea-cl-content"); } componentWillReceiveProps(nextProps){ if(this.props.taskid !== nextProps.taskid){ const { taskid, taskDynamicStore } = nextProps; this.setState({ selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false }); taskDynamicStore.setTaskId(taskid); taskDynamicStore.initData(); } } render() { const { selectedDynamicTab, showRich, visible, richValue } = this.state; const checkOptions = [ { title: getLabel('332','全部'), index: 0 }, { title: getLabel('20620','日报'), index: 1 }, { title: getLabel('518347','交流'), index: 2 }, { title: getLabel('83','日志'), index: 3 } ]; const { submitDaily, exchangeList, loading, canSubmitDaily } = this.props.taskDynamicStore; // const {exchangeList,logList,_BrowserList,taskid,dailys,setReply,saveReply,alldatas} = this.props.taskDynamicStore; const height = document.body.offsetHeight - 260.3; let scrollHeight = ($(".e9theme-layout-header").length > 0 || $(".e8theme-layout-header").length > 0) ? height - 55 : height; if(this.props.fromPortal){ scrollHeight = scrollHeight - 51; } const richSubmitfun = selectedDynamicTab == 1 ? submitDaily : this.dosubmit; const richid = { "1": "create_daily", "2": "create_discuss" }[selectedDynamicTab.toString()] let richPlaceholder = { "1": getLabel('518257','填写日报'), "2": getLabel('518258','填写相关交流') }[selectedDynamicTab.toString()]; const canSubmit = { "1": canSubmitDaily, "2": true }[selectedDynamicTab.toString()]; if(!canSubmit){ richPlaceholder += '('+getLabel('520676','一天只能提交一次') +')'; } const richProps = { transfStr: this.transfStr, richChange: this.richChange, richSubmitfun: richSubmitfun, showRichfun: this.showRichfun, showDialogfun: this.showDialogfun, setIsCreate: (bool) =>{this.setState({isCreate:bool})}, exchangeList, richid, showRich, richPlaceholder, loading, canSubmit } const richDom = (hasEdit = true) => (
{hasEdit && } {this.getDynamicContent()}
); const Elem = (
{checkOptions.map((opt, index) => { if(index==selectedDynamicTab){ return (
{this.changeDynamicTab(index);this.setState({richValue:''});}}>{opt.title}
) }else{ return (
{this.changeDynamicTab(index);this.setState({richValue:''});}}>{opt.title}
) } })}
); const editHeight = window.screen.width>=1920?"600px":"400px"; return (
{getLabel('518353','任务动态')} 
{Elem}
{ { '0': richDom(false), '1': richDom(), "2": richDom(), '3': richDom(false) }[selectedDynamicTab.toString()] } { this.getRichSubmitfun('create'); this.showDialogfun(false) }}>{getLabel(383336, "提交")}, ]} onCancel={() => this.setState({ visible: false })} style={{ width: 'calc(100% - 200px)', height: editHeight }} > ,
) } richChange = (text) => { const { taskDynamicStore: { setDaily } } = this.props; const { selectedDynamicTab, isCreate, richValueChangeMethod } = this.state; if(isCreate){ this.setState({richValue:text}); if(selectedDynamicTab == 1){ setDaily(text); }else if(selectedDynamicTab == 2){ this.onChange('create', text); } }else{ richValueChangeMethod(text); } } showRichfun = (bool) => { this.setState({ showRich: bool }) } showDialogfun = (visible) => { this.setState({ visible }) } huifuHandle = (item) => { let { showReply } = this.state; let showReply1 = showReply; showReply1[item.id] = !showReply1[item.id]; this.setState({ showReply: showReply1 }); } shanchuHandle = () => { } bianjiHandle = (item,tabKey) => { let { showDailyEdit } = this.state; let showDailyEdit1 = showDailyEdit; showDailyEdit1[item.id] = !showDailyEdit1[item.id]; this.setState({ richValue: item.content }); this.setState({ showDailyEdit: showDailyEdit1 }); this.setState({richMethod:(v) =>{this.editDaily(item.id,tabKey);}}); this.setState({richValueChangeMethod:(text) =>{this.setState({richValue:text});}}); this.setState({isCreate:false}); } tijiaoHandle = (showReply, item, submitType) => { const { saveReply } = this.props.taskDynamicStore; saveReply(item.id, submitType); let showReply1 = showReply; showReply1[item.id] = !showReply1[item.id]; this.setState({ showReply: showReply1 }); } getDynamicContent = () => { let datas = []; let { selectedDynamicTab, showReply, showDailyEdit } = this.state; const { exchangeList, logList, _BrowserList, taskid, dailys, setReply, saveReply, alldatas } = this.props.taskDynamicStore; let _exchangeList = toJS(exchangeList); if (selectedDynamicTab == 0) { alldatas.datas && alldatas.datas.map((item, index) => { const { type } = item; if (type == 1) { datas.push( { showDailyEdit[item.id]?
window.pointerXY(e)} > {item.creater.name}:   {this.setState({richValue:text});}} richSubmitfun={(v) =>{this.editDaily(item.id,0);}} showRichfun={(bool) =>{ let showDailyEdit1 = showDailyEdit; showDailyEdit1[item.id] = bool; this.setState({ showDailyEdit: showDailyEdit1 }); }} exchangeList={_exchangeList} loading={false} />
:
window.pointerXY(e)} > {item.creater.name}:   {item.createdate + ' ' + item.createtime} {item.canEdit&& { this.deleteDaily(item.id,0); }}>{getLabel(131966,"删除")} } {item.canEdit&& this.bianjiHandle(item,0)}>{getLabel(126036, "编辑")} } this.huifuHandle(item)}>{getLabel('128123', '回复')}
} { item.replys&&item.replys.map((item,index) =>{ return window.pointerXY(e)} > {item.creater.name}   {item.createdate+' '+item.createtime} }) } {showReply[item.id]&& {setReply(v)}} /> }
) } else if (type == 2) { let _exchangeList = toJS(exchangeList); let BrowserList = toJS(_BrowserList); const sortid = taskid; let wf_auth_url = _exchangeList ? _exchangeList.wf_auth_url : ""; let doc_auth_url = _exchangeList ? _exchangeList.doc_auth_url : ""; let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : ""; let browserParam = { hasAddBtn: false, hasAdvanceSerach: true, idSeparator: ",", isAutoComplete: 1, isDetail: 0, isMultCheckbox: false, isSingle: true, linkUrl: "/hrm/resource/HrmResource.jsp?id=", pageSize: 10, quickSearchName: "", title: getLabel(383424,"人力资源"), type: "1", viewAttr: 1, } Array.isArray(BrowserList.datas) && BrowserList.datas.map((element, index) => { if (element.id == item.id) { let replaceDatas = []; replaceDatas.push(element.creater); element['id'] == BrowserList[element['id']] let showDom = element.isEdit == true ?
{this.onChange(element.id, text);this.setState({richValue:text});}} richSubmitfun={(v) =>{this.dosubmit(element.id)}} showRichfun={(bool) =>{this.docancel(index,bool)}} exchangeList={_exchangeList} loading={false} />
:
{element.time} { element.canedit ? (
{ this.setState({richValue:BrowserList[element.id].remark}); this.edit(element.id); this.setState({richMethod:(v) =>{this.dosubmit(element.id)}}); this.setState({richValueChangeMethod:(text) =>{this.onChange(element.id, text);this.setState({richValue:text})}}); this.setState({isCreate:false}); }} > {`${getLabel(126036, "编辑")}`} this.delete(element.id)} style={{ right: '10px', cursor: 'pointer', color: '#b2b2b2' }} > {`${getLabel(131966, "删除")}`}
) : "" }
datas.push(showDom); } }) } else if (type == 3) { datas.push() } }) } else if (selectedDynamicTab == 1) { dailys && dailys.map((item, index) => { datas.push( { showDailyEdit[item.id]?
window.pointerXY(e)} > {item.creater.name}:   {this.setState({richValue:text});}} richSubmitfun={(v) =>{this.editDaily(item.id,1);}} showRichfun={(bool) =>{ let showDailyEdit1 = showDailyEdit; showDailyEdit1[item.id] = bool; this.setState({ showDailyEdit: showDailyEdit1 }); }} exchangeList={_exchangeList} loading={false} />
:
window.pointerXY(e)} > {item.creater.name}:   {item.createdate + ' ' + item.createtime} {item.canEdit&& { this.deleteDaily(item.id,1); }}>{getLabel(131966,"删除")} } {item.canEdit&& this.bianjiHandle(item,1)}>{getLabel(126036, "编辑")} } this.huifuHandle(item)}>{getLabel('128123', '回复')}
} { item.replys&&item.replys.map((item,index) =>{ return window.pointerXY(e)} > {item.creater.name}   {item.createdate+' '+item.createtime} }) } {showReply[item.id]&& {setReply(v)}} /> }
) }) } else if (selectedDynamicTab == 2) { let _exchangeList = toJS(exchangeList); let BrowserList = toJS(_BrowserList); const sortid = taskid; let exchangeListDatas = _exchangeList ? _exchangeList.datas : []; let wf_auth_url = _exchangeList ? _exchangeList.wf_auth_url : ""; let doc_auth_url = _exchangeList ? _exchangeList.doc_auth_url : ""; let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : ""; let browserParam = { hasAddBtn: false, hasAdvanceSerach: true, idSeparator: ",", isAutoComplete: 1, isDetail: 0, isMultCheckbox: false, isSingle: true, linkUrl: "/hrm/resource/HrmResource.jsp?id=", pageSize: 10, quickSearchName: "", title: getLabel(383424,"人力资源"), type: "1", viewAttr: 1, } Array.isArray(BrowserList.datas) && BrowserList.datas.map((element, index) => { if (index != 0) { let replaceDatas = []; replaceDatas.push(element.creater); element['id'] == BrowserList[element['id']] let showDom = element.isEdit == true ?
{this.onChange(element.id, text);this.setState({richValue:text});}} richSubmitfun={(v) =>{this.dosubmit(element.id)}} showRichfun={(bool) =>{this.docancel(index,bool)}} exchangeList={_exchangeList} loading={false} />
:
{element.time} { element.canedit ? (
{ this.setState({richValue:BrowserList[element.id].remark}); this.edit(element.id); this.setState({richMethod:(v) =>{this.dosubmit(element.id)}}); this.setState({richValueChangeMethod:(text) =>{this.onChange(element.id, text);this.setState({richValue:text})}}); this.setState({isCreate:false}); }} > {`${getLabel(126036, "编辑")}`} this.delete(element.id)} style={{ right: '10px', cursor: 'pointer', color: '#b2b2b2' }} > {`${getLabel(131966, "删除")}`}
) : "" }
datas.push(showDom); } }) exchangeListDatas && exchangeListDatas.length == 1 && datas.push(
{getLabel(383567, "暂无相关交流")}
) } else if (selectedDynamicTab == 3) { logList && logList.map((item, index) => { datas.push(); }) } if(datas.length == 0){ datas.push(

{getLabel('83553',"暂无数据")}

); } return datas; } dosubmit = (id) => { const {exchangeSave,_BrowserList,setBrowserList,taskid} = this.props.taskDynamicStore; let BrowserList = toJS(_BrowserList); let oldBrowserList = { ...BrowserList } const sortid = taskid; let params = oldBrowserList[id]; let mewParams = { ...params } let canSubmit = false; for (let key in mewParams) { if (key != 'id' && key != 'sortid') { if (key == 'remark') { if (mewParams[key]) { canSubmit = true } } } } if (params.docids.length == 0) { delete mewParams.docids } if (params.projectids.length == 0) { delete mewParams.projectids } if (params.relatedcus.length == 0) { delete mewParams.relatedcus } if (params.relateddoc.length == 0) { delete mewParams.relateddoc } if (params.relatedprj.length == 0) { delete mewParams.relatedprj } if (params.relatedwf.length == 0) { delete mewParams.relatedwf } if (params.docids.length > 0) { let docidsarr = [] params.docids.forEach((_e, _index) => { docidsarr.push(_e['id']); }) mewParams.docids = docidsarr.join(','); } if (params.projectids.length > 0) { let projectidssarr = [] params.projectids.forEach((_e, _index) => { projectidssarr.push(_e['id']); }) mewParams.projectids = projectidssarr.join(','); } if (params.relatedcus.length > 0) {//客户和任务有问题 let relatedcusarr = [] params.relatedcus.forEach((_e, _index) => { relatedcusarr.push(_e['id']); }) mewParams.relatedcus = relatedcusarr.join(','); } if (params.relateddoc.length > 0) { let relateddocarr = [] params.relateddoc.forEach((_e, _index) => { relateddocarr.push(_e['id']); }) mewParams.relateddoc = relateddocarr.join(','); } if (params.relatedprj.length > 0) { let relatedprjarr = [] params.relatedprj.forEach((_e, _index) => { relatedprjarr.push(_e['id']); }) mewParams.relatedprj = relatedprjarr.join(','); } if (params.relatedwf.length > 0) { let relatedwfarr = [] params.relatedwf.forEach((_e, _index) => { relatedwfarr.push(_e['id']); }) mewParams.relatedwf = relatedwfarr.join(','); } mewParams['id'] = id == 'create' ? '' : id; mewParams['sortid'] = sortid; let stateBrowserList = { ...BrowserList }; stateBrowserList['create']['docids'] = [] stateBrowserList['create']['projectids'] = [] stateBrowserList['create']['relatedcus'] = [] stateBrowserList['create']['relateddoc'] = [] stateBrowserList['create']['relatedprj'] = [] stateBrowserList['create']['relatedwf'] = [] stateBrowserList['create']['remark'] = '' if (canSubmit) { setBrowserList(stateBrowserList); exchangeSave(mewParams); this.setState({showExDiv:false}); } else { message.error(getLabel(126982,"请填写内容")); } } docancel = (e,flag=false) => { const {exchangeList,changeDiscussList} = this.props.taskDynamicStore; let _exchangeList = toJS(exchangeList); let oldexchangeList = { ..._exchangeList } oldexchangeList.datas.forEach((element, index) => { if (e == index) { element.isEdit = flag; } }) changeDiscussList(oldexchangeList) } transfStr = (name = '', ids = '', list = [], type = '', id = '') => { const {_BrowserList,setBrowserList,exchangeList,taskid} = this.props.taskDynamicStore; let BrowserList = toJS(_BrowserList); let _exchangeList = toJS(exchangeList); let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : ""; let sortid = taskid; let str = ''; let idsArr = []; const mirror = { 37: "doc", prjtsk: "task", 18: "crm", 152: "workflow", 135: "project", workplan: "workplan", blogTemplate: "blogTemplate" } const browserType = { 37: "docids", prjtsk: "relatedprj", 18: "relatedcus", 152: "relatedwf", 135: "projectids",//项目 Upload: "relateddoc",//附件 } list.map(item => { if (name === 'Browser') { let urlstr=this.openProjectAppLink(mirror[type],item.id,sortid); str +=` ${item.name || item.showname} ` idsArr.push(item.id) } if (name === 'Upload' && type === 'image') { str += '  ' } if (name === 'Upload' && type === 'file') { str += ` ${item.filename} ` if (item.showLoad) { let urlstr=item.loadlink+"&sortid="+sortid; str += `${getLabel(258,"下载")}(${item.filesize}) ` } } }) let oldBrowserList = { ...BrowserList }; if (oldBrowserList[id] == undefined) { oldBrowserList[id] = {}; } if (name != 'Upload') { oldBrowserList[id][browserType[type]] = list; } else { oldBrowserList[id]['relateddoc'].push({ id: ids[0] }) } setBrowserList(oldBrowserList); return str } onChange = (id, text) => { const {_BrowserList,setBrowserList} = this.props.taskDynamicStore; let BrowserList = toJS(_BrowserList); let oldBrowserList = { ...BrowserList }; if (oldBrowserList[id] == undefined) { oldBrowserList[id] = {}; } oldBrowserList[id]['remark'] = text; setBrowserList(oldBrowserList); } edit = (_id) => { const {exchangeList,changeDiscussList,_BrowserList,setBrowserList} = this.props.taskDynamicStore; let _exchangeList = toJS(exchangeList); let BrowserList = toJS(_BrowserList); let oldBrowserList = { ...BrowserList }; let oldexchangeList = { ..._exchangeList } oldexchangeList.datas.forEach((element, index) => { if (_id == element['id']) { element.isEdit = true; if (oldBrowserList[_id] == undefined) { oldBrowserList[_id] = {}; } oldBrowserList[_id].relatedwf = element.relatedwf; oldBrowserList[_id].docids = element.docids; oldBrowserList[_id].projectids = element.projectids; oldBrowserList[_id].relatedcus = element.relatedcus; oldBrowserList[_id].relateddoc = element.relateddoc; oldBrowserList[_id].relatedprj = element.relatedprj; } }) setBrowserList(oldBrowserList); changeDiscussList(oldexchangeList) } delete = (e) => { const {exchangeDelete} = this.props.taskDynamicStore; confirm({ title : getLabel(131329,"信息确认"), content : getLabel(15097,"确定要删除吗?"), onOk(){ exchangeDelete({id:e}); }, onCancel() {} }) } deleteDaily = (e,type) => { const {deleteDaily,prjid} = this.props.taskDynamicStore; confirm({ title : getLabel(131329,"信息确认"), content : getLabel(15097,"确定要删除吗?"), onOk(){ deleteDaily({ id: e, prjid: prjid },type); }, onCancel() {} }) } changeDynamicTab = (index) =>{ const {getPortalProjectDynamicInfo,getDailys,getExchangeList,setExchangeList,setBrowserList} = this.props.taskDynamicStore; if(index==0){ getPortalProjectDynamicInfo("alltask"); }else if(index==1){ getDailys(); getExchangeList(); }else if(index==2){ setExchangeList({}); setBrowserList({}); getExchangeList(); }else if(index==3){ getPortalProjectDynamicInfo("tasklog"); } this.setState({ selectedDynamicTab: index, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false }); } openProjectAppLink=(linkType, linkid, prjid)=>{ const {exchangeList} = this.props.taskDynamicStore; let _exchangeList = toJS(exchangeList); let wf_auth_url = _exchangeList ? _exchangeList.wf_auth_url : ""; let doc_auth_url = _exchangeList ? _exchangeList.doc_auth_url : ""; let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : ""; if (linkType == "doc") return `${window.ecologyContentPath || ''}/spa/document/index.jsp?id=${linkid}&prjid=${prjid}`+doc_auth_url; else if (linkType == "task") return `${window.ecologyContentPath || ''}/spa/prj/index.html#/main/prj/taskCard?taskid=${linkid}`; else if (linkType == "crm") return `${window.ecologyContentPath || ''}/spa/crm/static/index.html#/main/crm/customerView?customerId=${linkid}`; else if (linkType == "workflow") return `${window.ecologyContentPath || ''}/spa/workflow/static4form/index.html#/main/workflow/req?fromModul=prj&modulResourceId=${prjid}&requestid=${linkid}`+wf_auth_url; else if (linkType == "project") return `${window.ecologyContentPath || ''}/spa/prj/index.html#/main/prj/projectCard?prjid=${prjid}`; else return ''; } getRichSubmitfun = (v) =>{ const { taskDynamicStore: { submitDaily } } = this.props; const { selectedDynamicTab, isCreate, richMethod } = this.state; if(isCreate){ if(selectedDynamicTab == 1){ submitDaily(v); }else if(selectedDynamicTab == 2){ this.dosubmit(v); } }else{ richMethod(); } } editDaily = (id,tabKey) =>{ const { taskDynamicStore: { editDaily } } = this.props; const { richValue } = this.state; editDaily(id,richValue,tabKey); } }