weaver_trunk_cli/pc4mobx/prj/components/common/relateWorkFlow.js

249 lines
10 KiB
JavaScript

import {Button,Row,Col, Icon,message,Modal} from 'antd';
import {WeaTools,WeaBrowser,WeaAlertPage,WeaLocaleProvider} from 'ecCom';
import {inject, observer} from "mobx-react";
import {toJS} from 'mobx';
import PrjShowGroup from '../comp/prj-show-group'
import PrjTableEdit from '../comp/prj-table-edit'
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;
@observer
export default class RelateExchange extends React.Component {
constructor(props) {
super(props);
this.state ={
}
}
componentDidMount(){
}
componentWillReceiveProps(nextProps) {
}
render() {
const {contentStore} = this.props;
const {taskReqStore,relateList,relateList:{canRef},taskRelRight:{hasRight,verified},register_table} = contentStore;
const columns = [
{
title: getLabel(16579,"流程类型"), //列名
dataIndex: 'wfname', //列的id 对应数据
key: 'wfname', //前端渲染key值
com: [
{ label: '', type: 'LINK_WF' , key: 'wfname', viewAttr:1, width: 120, otherParams: {className: 'test-className'}},
],
colSpan: 1,
width: '50%',
className: 'wea-table-edit-name',
},
{
title: getLabel(17906,"必要"), //列名
dataIndex: 'isNecessary', //列的id 对应数据
key: 'isNecessary', //前端渲染key值
com: [
{ label: '', type: 'CHECKBOX' ,editType: '1', viewAttr:canRef?2:1,key: 'isNecessary', width: 80, }
],
colSpan: 1,
width: '40%',
className: 'wea-table-edit-ismust',
},
{
title: '', //列名
dataIndex: 'operate', //列的id 对应数据
key: 'sex', //前端渲染key值
com: [
{ label: '', type: 'OPERATE' ,editType: '1', key: 'operate', options: [{ key: '1', showname: getLabel(91,"删除")}] }
],
colSpan: 1,
width: '10%',
className: 'prj-dropdown-link',
},
];
if (verified && !hasRight) {
return (<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@ukfh1m`} >
<div style={{color : '#000'}}>
{getLabel(2012,"对不起,您暂时没有权限!")}
</div>
</WeaAlertPage>
)
}
if (verified && hasRight) {
return (
<div className="prj-exchange">
<PrjShowGroup ecId={`${this && this.props && this.props.ecId || ''}_PrjShowGroup@nz3pd2`}
leftComponent={getLabel(83870,"所需流程")}
rightComponent={this.getButtons()}
>
<PrjTableEdit ecId={`${this && this.props && this.props.ecId || ''}_PrjTableEdit@hxizqu`}
columns={columns}
datas={toJS(relateList.needList)}
onChange={this.onChange}
onRowSelect={null}
pagination={false}
viewAttr={1}
tableProps={{rowSelection:null}}
getRowSelection={this.getRowSelection}
operate ={this.handleOperate}
onCreatReq={this.onCreatReq}
onCreatDoc={this.onCreatDoc}
/>
</PrjShowGroup>
<PrjShowGroup ecId={`${this && this.props && this.props.ecId || ''}_PrjShowGroup@hunf8t`}
leftComponent={getLabel(1044,"相关流程")}
rightComponent={this.getRelateButtons()}
btnspace={10}
>
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@f3qsbk`}
comsWeaTableStore={taskReqStore}
hasOrder={true}
needScroll={true}
onOperatesClick={this.onOperatesClick.bind(this)}
register_table={register_table}
/>
</PrjShowGroup>
</div>)
}
return <div></div>
}
getButtons(){
const {contentStore} = this.props;
const {taskReqStore,relateList:{canRef}} = contentStore;
let btn = [];
if(canRef){
btn.push(
<WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@8eq8ht`} type={"-99991"} title={getLabel(18499,"路径")} hasAdvanceSerach={true} isSingle={false} onChange ={(ids, names, datas)=>this.addWorkFlowType(ids, names, datas)} customized={true} >
<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@pmfdro`} type="primary" className="prj-btn-small" title={getLabel(611,"添加")} size="small" onClick={()=>{}}><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@allf77`} type="plus" /></Button>
</WeaBrowser>
);
}
return btn;
}
getRelateButtons(){
const {contentStore} = this.props;
const {taskReqStore,relateList:{canRelated}} = contentStore;
const {selectedRowKeys} = taskReqStore;
let btn = [];
if(canRelated){
btn.push(<WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@6tcc4p`} type={"16"} title={getLabel(18015,"流程")} hasAdvanceSerach={true} isSingle={true} onChange ={(ids, names, datas)=>this.addWorkFlow(ids, names, datas)} customized={true} >
<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@gnzedh`} type="primary" className="prj-btn-small" title={getLabel(611,"添加")} size="small" onClick={()=>{}}><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@1adcsw`} type="plus" /></Button>
</WeaBrowser>);
btn.push( <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@zsvqog`} type="primary" className="prj-btn-small" title={getLabel(91,"删除")} disabled={!(selectedRowKeys.length>0)} size="small" onClick={this.deleteWorkFlow}><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@taejhk`} type="minus" /></Button>);
}
return btn;
}
//编辑
onChange=(data)=>{
const {contentStore} = this.props;
const {doDspTaskRequiredOpt,taskid,} = contentStore;
doDspTaskRequiredOpt({
method:'modifyRequiredWFN',
taskid : taskid,
wfid : data.wfid1,
isNecessary:data.isNecessary
},'req');
}
//新增
addWorkFlowType=(ids, names, datas)=>{
const {contentStore} = this.props;
const {doDspTaskRequiredOpt,taskid,} = contentStore;
doDspTaskRequiredOpt({
method:'addRequiredWF',
taskid : taskid,
wfids : ids
},'req');
}
//删除
handleOperate=(record)=>{
const {contentStore} = this.props;
const {doDspTaskRequiredOpt,taskid,} = contentStore;
Modal.confirm({
title: getLabel(15172,"系统提示"),
content: getLabel(83600,"您确认要删除吗?"),
onOk() {
doDspTaskRequiredOpt({
method:'delRequiredWF',
taskid : taskid,
wfid : record.wfid1
},'req');
},
onCancel() { },
})
}
onCreatReq = (workflowid,taskId) => {
window.open("/workflow/request/CreateRequestForward.jsp?workflowid="+workflowid+"&taskrecordid="+taskId , "_blank");
}
onCreatDoc = (docid,taskid) => {
window.open((window.ecologyContentPath || '')+"/spa/document/index.jsp?secid="+ docid +"&isEdit=1&router=1&moudleFrom=task#/main/document/edit?taskrecordid="+taskid , "_blank");
}
//新建流程
addWorkFlow=(ids, names, datas)=>{
const {contentStore} = this.props;
const {doDspTaskReferenceOpt,taskid,prjid} = contentStore;
doDspTaskReferenceOpt({
dotype:'workflow',
method:'add',
prjid : prjid,
taskid:taskid,
requestid:ids,
ids:""
},'req')
}
//删除流程
deleteWorkFlow = ()=>{
const {contentStore} = this.props;
const {doDspTaskReferenceOpt,taskid,taskReqStore,prjid} = contentStore;
const {selectedRowKeys} = taskReqStore;
Modal.confirm({
title: getLabel(15172,"系统提示"),
content: getLabel(83601,"您确认要删除选中的记录吗?"),
onOk() {
doDspTaskReferenceOpt({
dotype:'workflow',
method:'del',
prjid : prjid,
taskid:taskid,
requestid:"",
ids:`${toJS(selectedRowKeys)}`
},'req')
},
onCancel() { },
})
}
onOperatesClick(record,index,operate,flag){
let _href = operate && operate.href ? operate.href : "";
let fn = _href.replace("javascript:","");
fn = fn.substring(0,fn.indexOf('('));
const {contentStore} = this.props;
const {doDspTaskReferenceOpt,taskid,taskReqStore,prjid} = contentStore;
if(fn != ""){
if("onDelRelated"==fn){ //delete
Modal.confirm({
title: getLabel(15172,"系统提示"),
content: getLabel(83600,"您确认要删除吗?"),
onOk() {
doDspTaskReferenceOpt({
dotype:'workflow',
method:'del',
prjid : prjid,
taskid:taskid,
requestid:"",
ids:record.randomFieldId
},'req')
},
onCancel() { },
})
}
}
}
}