import React from 'react'; import { inject, observer } from 'mobx-react'; import {toJS} from "mobx" import {WeaSearchGroup,WeaBrowser,WeaUpload,WeaLocaleProvider,WeaError} from "ecCom" import { Button ,Row,Col,Spin} from 'antd'; const getLabel = WeaLocaleProvider.getLabel; @inject('prjImportStore') @observer class PrjImport extends React.Component { constructor(props) { super(props); this.state={ } } componentDidMount(){ const {prjImportStore } = this.props; const {initDatas,} = prjImportStore; initDatas({imptype:'prj',isdata:'1'}); } getCircle() { let style = { width: 20, height: 20, backgroundColor: '#D8D8D8', webkitBorderRadius: 10, mozBorderRadius: 10, msBorderRadius: 10, oBorderRadius: 10, borderRadius: 10, textAlign: 'center', } return style; } getForm() { const{ prjImportStore} = this.props; const{isuse,mandstr,otherstr,prjmsg,imp_totalCount,imp_successCount} = prjImportStore; let prjcode = ""; if(isuse==2){ prjcode = getLabel(17852,"项目编码"); } const require = ""+getLabel(18019,"必填")+": "+getLabel(195,"名称")+" "+getLabel(586,"项目类型")+" "+prjcode+" "+getLabel(144,"经理")+" "+getLabel(18628,"项目成员")+" "+mandstr+" "; const other = ""+getLabel(375,"其他")+": "+getLabel(15486,"序号")+" "+getLabel(432,"工作类型")+" "+getLabel(783,"相关客户")+" "+ getLabel(15263,"客户可见")+" "+getLabel(624,"成员可见")+" "+getLabel(636,"上级项目")+" "+getLabel(637,"评价书")+" "+getLabel(638,"确认书")+" "+getLabel(639,"建议书")+" "+otherstr+" "; let condition = [{ "title": getLabel(24893, "基础信息"), "defaultshow": true, "items": [{ "checkbox": false, "colSpan": 2, "conditionType": "BROWSER", "detailtype": 1, "domkey": ["prjtype"], "fieldcol": 18, "hasBorder": false, "helpfulTipProps": {}, "isQuickSearch": false, "label": getLabel(586,"项目类型"), "labelcol": 5, "length": 0, "precision": 0, "showOrder": 0, "stringLength": 0, "tipPosition": "bottom", "viewAttr": 2, "value":"" }, { "checkbox": false, "colSpan": 2, "conditionType": "RESOURCEIMG", "detailtype": 1, "domkey": ["excelfile"], "fieldcol": 18, "hasBorder": false, "helpfulTipProps": {}, "isQuickSearch": false, "label": getLabel(16699, "Excel文件"), "labelcol": 5, "length": 0, "precision": 0, "showOrder": 0, "stringLength": 0, "tipPosition": "bottom", "viewAttr": 2 }] }, { "title": getLabel(19010,"操作说明"), "defaultshow": true, "items": [{ "index": 1, "value": getLabel(28447, "第一步,请先") }, { "index": 2, "value": getLabel(32986,"第二步,下载后,填写内容,注意,要填写的内容在下边的说明中有详细的说明,请一定要确定你的Excel文档的格式是模板中的格式,而没有被修改掉") }, { "index": 3, "value": getLabel(32987,"第三步,选择填写好的Excel文档,点击提交按钮进行批量导入") }, { "index": 4, "value": getLabel(32988,"第四步,如果以上步骤和Excel文档正确的话,数据会被正确的导入,导入成功会有提示。如果有问题,则会提示Excel文档的错误之处") }] }, { "title": getLabel(24962,"字段说明"), "defaultshow": true, "items": [{ "index": 1, "value": getLabel(18617,"请按下列顺序排列需导入的EXCEL文档中各字段的顺序,其中红色的部分为必填字段,不能为空!") }, { "index": 2, "value":require }, { "index": 3, "value":other }] }, { "title": getLabel(502196,"注意事项"), "defaultshow": true, "items": [{ "index": 1, "value": getLabel(521941,"若要给已存在的项目导入子项目时,则需要在Excel模板中的上级项目字段输入已存在的项目,格式为:name_项目名称或者key_项目id") }] }] let _arr = []; condition.map((c, i) => { let arr = []; if (i == 0) { //基本信息 c.items.map((field, index) => { arr.push({ com: (
{index + 1}
{field.label}: {this.getDom(field)}
), colSpan: 1, }) }) //导入提示信息 arr.push({ com: (
{ prjmsg!=""&&(parseInt(imp_totalCount)>0&& {getLabel(128217,"总记录数")}{imp_totalCount}{getLabel(18256,"条")} ,{getLabel(128219,"成功导入")}{imp_successCount}{getLabel(18256,"条")},{getLabel(25009,"失败")}{parseInt(imp_totalCount) - parseInt(imp_successCount)}{getLabel(18256,"条")}。 ) }
), colSpan: 1, }) } if (i == 1) { //导入说明 c.items.map((field, index) => { arr.push({ com: (
{index + 1}
{this.getIllustration(field.value, field.link, index, field)}
), colSpan: 1 }) }) } if (i == 2) { //字段说明 c.items.map((field, index) => { arr.push({ com: (
{index + 1}
{this.getIllustration1(field.value, field.link, index, field)}
), colSpan: 1 }) }) } if (i == 3) { //注意事项 c.items.map((field, index) => { arr.push({ com: (
{index + 1}

), colSpan: 1 }) }) } _arr.push(
) }); return _arr; } getDom(field) { const { prjImportStore} = this.props; const {filelist,replaceDatas} = prjImportStore; let dom; let domkey = field.domkey; if (domkey&&domkey[0] == 'excelfile') { dom = (
{ prjImportStore.prjremind = ref } } error={getLabel(126186,"未")+getLabel(82694,"选择Excel文件")} tipPosition="bottom" >
{ this.setFileId(ids, list) } } >
{filelist.length == 0 ?

{getLabel(384040,"未选择任何文件")}

: filelist.map(file =>

{file.filename}

)}
) } else { dom =
{ prjImportStore.savePrjType(ids,datas,'prj'); }}/>
} return dom; } getIllustration(val, url, index, link) { const { prjImportStore} = this.props; const {isrefresh,isuse } = prjImportStore; let tempurl = ""; if(isuse == 0 || isuse == 1){ tempurl = (window.ecologyContentPath || '')+"/proj/imp/prjimp_xlsnew.xls?V="+isrefresh; }else{ tempurl = (window.ecologyContentPath || '')+"/proj/imp/prjimp_xlsnew1.xls?V="+isrefresh; } let p; if (index == 0) { p = (

{val}:{getLabel(28446,"下载EXCEL文档模板")}

); } else { p = (

); } return p; } getIllustration1(val, url, index, link) { let p; if (index == 0) { p = (

); } else if(index==1){ p = (

); } else{ p = (

); } return p; } render(){ const { prjImportStore } = this.props; const { spinning } = prjImportStore; return (
{this.getForm()}
) } setFileId(ids, list) { const {prjImportStore} = this.props; prjImportStore.excelfile = ids; prjImportStore.filelist = list; } regenTemplate=(key)=>{ const{ prjImportStore} = this.props; prjImportStore.regenTemplate(); } } export default PrjImport;