249 lines
10 KiB
JavaScript
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 {taskDocStore,relateList,taskRelRight:{hasRight,verified},relateList:{canRef}} = contentStore;
|
|
const columns = [
|
|
{
|
|
title: getLabel(16398,"文档目录"), //列名
|
|
dataIndex: 'docCategoryName', //列的id 对应数据
|
|
key: 'docCategoryName', //前端渲染key值
|
|
com: [
|
|
{ label: '', type: 'LINK_DOC' , key: 'docCategoryName', 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@phvbye`} >
|
|
<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@bqaxq2`}
|
|
leftComponent={getLabel(83873,"所需文档")}
|
|
rightComponent={this.getButtons()}
|
|
>
|
|
<PrjTableEdit ecId={`${this && this.props && this.props.ecId || ''}_PrjTableEdit@4j1ktl`}
|
|
columns={columns}
|
|
datas={toJS(relateList.needList)}
|
|
onChange={this.onChange}
|
|
onRowSelect={null}
|
|
pagination={false}
|
|
viewAttr={1}
|
|
tableProps={{rowSelection:null}}
|
|
getRowSelection={this.getRowSelection}
|
|
operate ={this.handleOperate}
|
|
onCreatDoc = {(categoryid,taskid)=>{this.onCreatDoc(categoryid,taskid)}}
|
|
/>
|
|
|
|
</PrjShowGroup>
|
|
<PrjShowGroup ecId={`${this && this.props && this.props.ecId || ''}_PrjShowGroup@751czf`}
|
|
leftComponent={getLabel(857,"相关文档")}
|
|
rightComponent={this.getRelateButtons()}
|
|
btnspace={10}
|
|
>
|
|
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@gv1um9`}
|
|
comsWeaTableStore={taskDocStore}
|
|
hasOrder={true}
|
|
needScroll={true}
|
|
onOperatesClick={this.onOperatesClick.bind(this)}
|
|
/>
|
|
</PrjShowGroup>
|
|
</div>)
|
|
}
|
|
return <div></div>
|
|
}
|
|
getButtons(){
|
|
const {contentStore} = this.props;
|
|
const {relateList:{canRef}} = contentStore;
|
|
let btn = [];
|
|
if(canRef){
|
|
btn.push(
|
|
<WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@4aa8sd`} type={"doccategory"} title={getLabel(16398,"文档目录")} hasAdvanceSerach={true} isSingle={true} onChange ={(ids, names, datas)=>this.addDocType(ids, names, datas)} customized={true} >
|
|
<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@6iap6n@add`} type="primary" className="prj-btn-small" title={getLabel(611,"添加")} size="small" onClick={()=>{}}><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@p6fv00`} type="plus" /></Button>
|
|
</WeaBrowser>
|
|
);
|
|
}
|
|
return btn;
|
|
}
|
|
getRelateButtons(){
|
|
const {contentStore} = this.props;
|
|
const {taskDocStore,relateList:{canRelated}} = contentStore;
|
|
const {selectedRowKeys} = taskDocStore;
|
|
let btn = [];
|
|
if(canRelated){
|
|
btn.push(<WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@su8uoh`} type={"9"} title={getLabel(58,"文档")} hasAdvanceSerach={true} isSingle={true} onChange ={(ids, names, datas)=>this.addDocument(ids, names, datas)} customized={true} >
|
|
<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@aum745@add`} type="primary" className="prj-btn-small" title={getLabel(611,"添加")} size="small" onClick={()=>{}}><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@sd84fb`} type="plus" /></Button>
|
|
</WeaBrowser>);
|
|
btn.push( <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@l7f9uh`} type="primary" className="prj-btn-small" title={getLabel(91,"删除")} disabled={!(selectedRowKeys.length>0)} size="small" onClick={this.deleteDocument}><Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@3sigu2`} type="minus" /></Button>);
|
|
}
|
|
return btn;
|
|
}
|
|
//编辑
|
|
onChange=(data)=>{
|
|
const {contentStore} = this.props;
|
|
const {doDspTaskRequiredOpt,taskid,} = contentStore;
|
|
doDspTaskRequiredOpt({
|
|
method:'modifyRequiredDocN',
|
|
taskid : taskid,
|
|
secID : data.reqDocSecCategory,
|
|
isNecessary:data.isNecessary
|
|
},'doc');
|
|
}
|
|
//新增所需文档
|
|
addDocType=(ids, names, datas)=>{
|
|
const {contentStore} = this.props;
|
|
const {doDspTaskRequiredOpt,taskid,} = contentStore;
|
|
doDspTaskRequiredOpt({
|
|
method:'addRequiredDoc',
|
|
taskid : taskid,
|
|
secID : ids
|
|
},'doc');
|
|
}
|
|
onCreatDoc = (categoryid,taskid) =>{
|
|
// const {addDocFn} = this.props;
|
|
window.open((window.ecologyContentPath || '')+"/spa/document/index.jsp?secid="+categoryid+"&isEdit=1&router=1&moudleFrom=task#/main/document/edit", "_blank");
|
|
let _this = this;
|
|
window.__createDocFn = function (obj) {
|
|
let docid = obj.docid;
|
|
let docsubject = obj.docSubject;
|
|
// console.log(docid,docsubject);
|
|
// addDocFn && addDocFn(docid,docsubject);
|
|
_this.addDocument(docid, docsubject, '')
|
|
}
|
|
}
|
|
//删除
|
|
handleOperate=(record)=>{
|
|
const {contentStore} = this.props;
|
|
const {doDspTaskRequiredOpt,taskid,} = contentStore;
|
|
Modal.confirm({
|
|
title: getLabel(15172,"系统提示"),
|
|
content: getLabel(83600,"您确认要删除吗?"),
|
|
onOk() {
|
|
doDspTaskRequiredOpt({
|
|
method:'delRequiredDoc',
|
|
taskid : taskid,
|
|
secID : record.reqDocSecCategory
|
|
},'doc');
|
|
},
|
|
onCancel() { },
|
|
})
|
|
|
|
}
|
|
//新建
|
|
addDocument=(ids, names, datas)=>{
|
|
const {contentStore} = this.props;
|
|
const {doDspTaskReferenceOpt,taskid,prjid} = contentStore;
|
|
doDspTaskReferenceOpt({
|
|
dotype:'doc',
|
|
method:'add',
|
|
prjid : prjid,
|
|
taskid:taskid,
|
|
docid:ids,
|
|
ids:""
|
|
},'doc')
|
|
}
|
|
deleteDocument=()=>{
|
|
const {contentStore} = this.props;
|
|
const {doDspTaskReferenceOpt,taskid,taskDocStore,prjid} = contentStore;
|
|
const {selectedRowKeys} = taskDocStore;
|
|
Modal.confirm({
|
|
title: getLabel(15172,"系统提示"),
|
|
content: getLabel(83601,"您确认要删除选中的记录吗?"),
|
|
onOk() {
|
|
doDspTaskReferenceOpt({
|
|
dotype:'doc',
|
|
method:'del',
|
|
prjid : prjid,
|
|
taskid:taskid,
|
|
docid:"",
|
|
ids:`${toJS(selectedRowKeys)}`
|
|
},'doc')
|
|
},
|
|
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,taskDocStore,prjid} = contentStore;
|
|
if(fn != ""){
|
|
if("onDelRelated"==fn){ //delete
|
|
Modal.confirm({
|
|
title: getLabel(15172,"系统提示"),
|
|
content: getLabel(83600,"您确认要删除吗?"),
|
|
onOk() {
|
|
doDspTaskReferenceOpt({
|
|
dotype:'doc',
|
|
method:'del',
|
|
prjid : prjid,
|
|
taskid:taskid,
|
|
docid:"",
|
|
ids:record.randomFieldId
|
|
},'doc')
|
|
},
|
|
onCancel() { },
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|