提交 d02c9365 authored 作者: xuli's avatar xuli

添加请求

上级 1bb62ce7
...@@ -18,7 +18,7 @@ import { connect } from 'dva'; ...@@ -18,7 +18,7 @@ import { connect } from 'dva';
const Step = Steps.Step; const Step = Steps.Step;
const TabPane = Tabs.TabPane; const TabPane = Tabs.TabPane;
const exportExcel=(CLIENT_TYPE=="mobile")?null:require('xlsx-oc').exportExcel const exportExcel = (CLIENT_TYPE == "mobile") ? null : require('xlsx-oc').exportExcel
@connect(({ DataObj, loading }) => ({ @connect(({ DataObj, loading }) => ({
DataObj, DataObj,
...@@ -28,11 +28,11 @@ export default class ImportUtil extends React.PureComponent { ...@@ -28,11 +28,11 @@ export default class ImportUtil extends React.PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
const exportTemplateUrl= encodeURI(`${config.httpServer}/DataObjApi/importTemplateDownload?objId=${this.props.objId}&name=${props.fileName}`); const exportTemplateUrl = encodeURI(`${config.httpServer}/DataObjApi/importTemplateDownload?objId=${this.props.objId}&name=${props.fileName}`);
this.state = { this.state = {
ch:false, ch: false,
currentKey:"1", currentKey: "1",
visible: false, visible: false,
current: 0, current: 0,
isShow: true, isShow: true,
...@@ -43,7 +43,7 @@ export default class ImportUtil extends React.PureComponent { ...@@ -43,7 +43,7 @@ export default class ImportUtil extends React.PureComponent {
exportTemplateUrl, exportTemplateUrl,
isNextDisabled:false, isNextDisabled: false,
}; };
} }
...@@ -96,12 +96,12 @@ export default class ImportUtil extends React.PureComponent { ...@@ -96,12 +96,12 @@ export default class ImportUtil extends React.PureComponent {
} }
import() { import() {
const { dispatch ,importParams } = this.props; const { dispatch, importParams } = this.props;
dispatch({ dispatch({
type: 'DataObj/importExecute', type: 'DataObj/importExecute',
payload: { payload: {
...(importParams||{}), ...(importParams || {}),
cacheKey:this.state.filekey, cacheKey: this.state.filekey,
objId: this.props.objId, objId: this.props.objId,
}, },
...@@ -116,7 +116,7 @@ export default class ImportUtil extends React.PureComponent { ...@@ -116,7 +116,7 @@ export default class ImportUtil extends React.PureComponent {
visible: false, visible: false,
}); });
if(this.props.callback){ if (this.props.callback) {
this.props.callback(); this.props.callback();
} }
} }
...@@ -126,12 +126,12 @@ export default class ImportUtil extends React.PureComponent { ...@@ -126,12 +126,12 @@ export default class ImportUtil extends React.PureComponent {
} }
getCachKey = (filePath) => { getCachKey = (filePath) => {
const { dispatch ,importParams } = this.props; const { dispatch, importParams } = this.props;
dispatch({ dispatch({
type: 'DataObj/importAnalyse', type: 'DataObj/importAnalyse',
payload: { payload: {
...(importParams||{}), ...(importParams || {}),
isLocal:false, isLocal: false,
filePath, filePath,
objId: this.props.objId, objId: this.props.objId,
}, },
...@@ -148,11 +148,11 @@ export default class ImportUtil extends React.PureComponent { ...@@ -148,11 +148,11 @@ export default class ImportUtil extends React.PureComponent {
}; };
queryFile = (cacheKey) => { queryFile = (cacheKey) => {
const { dispatch ,importParams } = this.props; const { dispatch, importParams } = this.props;
dispatch({ dispatch({
type: 'DataObj/importDataQuery', type: 'DataObj/importDataQuery',
payload: { payload: {
...(importParams||{}), ...(importParams || {}),
cacheKey, cacheKey,
objId: this.props.objId, objId: this.props.objId,
}, },
...@@ -165,29 +165,29 @@ export default class ImportUtil extends React.PureComponent { ...@@ -165,29 +165,29 @@ export default class ImportUtil extends React.PureComponent {
errData: res.noPass, errData: res.noPass,
column: res.column column: res.column
}); });
if(res.noPass&&res.noPass.length==0){ if (res.noPass && res.noPass.length == 0) {
if (res.pass.length==0) { if (res.pass.length == 0) {
message.error('当前没有验证成功的数据,无法导入。'); message.error('当前没有验证成功的数据,无法导入。');
this.setState({ this.setState({
currentKey:"1", currentKey: "1",
ch:!this.state.ch, ch: !this.state.ch,
isNextDisabled: true isNextDisabled: true
}); });
} else { } else {
message.success('所有数据验证通过,请确认后点击下一步。'); message.success('所有数据验证通过,请确认后点击下一步。');
this.setState({ this.setState({
currentKey:"2", currentKey: "2",
ch:!this.state.ch, ch: !this.state.ch,
isNextDisabled: false isNextDisabled: false
}); });
} }
}else{ } else {
message.error('当前存在未验证通过的数据,请按错误提示检测更正导入文件'); message.error('当前存在未验证通过的数据,请按错误提示检测更正导入文件');
this.setState({ this.setState({
currentKey:"1", currentKey: "1",
ch:!this.state.ch, ch: !this.state.ch,
isNextDisabled: true isNextDisabled: true
}); });
} }
...@@ -195,21 +195,21 @@ export default class ImportUtil extends React.PureComponent { ...@@ -195,21 +195,21 @@ export default class ImportUtil extends React.PureComponent {
} }
}) })
}; };
changePane=(activeKey)=>{ changePane = (activeKey) => {
this.setState({currentKey:activeKey}) this.setState({ currentKey: activeKey })
} }
exportError=(column,dataSource)=>{ exportError = (column, dataSource) => {
if(exportExcel==null){ if (exportExcel == null) {
message.info("当前终端暂不支持此功能") message.info("当前终端暂不支持此功能")
return return
} }
var _headers = [] var _headers = []
for(var i=0;i<column.length;i++){ for (var i = 0; i < column.length; i++) {
_headers.push({k:column[i].dataIndex,v:column[i].title}) _headers.push({ k: column[i].dataIndex, v: column[i].title })
} }
for(var j=0;j<dataSource.length;j++){ for (var j = 0; j < dataSource.length; j++) {
dataSource[j].index=j+1 dataSource[j].index = j + 1
} }
exportExcel(_headers, dataSource); exportExcel(_headers, dataSource);
...@@ -224,7 +224,7 @@ export default class ImportUtil extends React.PureComponent { ...@@ -224,7 +224,7 @@ export default class ImportUtil extends React.PureComponent {
headers: { headers: {
authorization: 'authorization-text', authorization: 'authorization-text',
}, },
accept:'.xlsx', accept: '.xlsx',
showUploadList: false, showUploadList: false,
onChange: (info) => { onChange: (info) => {
if (info.file.status !== 'uploading') { if (info.file.status !== 'uploading') {
...@@ -255,20 +255,20 @@ export default class ImportUtil extends React.PureComponent { ...@@ -255,20 +255,20 @@ export default class ImportUtil extends React.PureComponent {
}]; }];
const { current } = this.state; const { current } = this.state;
const {name, loading} = this.props const { name, loading } = this.props
const column1=this.state.column?[{title:"序号",dataIndex:"index",fixed:"left",width:50, render:(v,r,i)=>i+1},...this.state.column]:[] const column1 = this.state.column ? [{ title: "序号", dataIndex: "index", fixed: "left", width: 50, render: (v, r, i) => i + 1 }, ...this.state.column] : []
var column2=this.state.column?[...this.state.column]:[] var column2 = this.state.column ? [...this.state.column] : []
if(column1.length>1) column1[1].render=(val)=><span style={{color:"red"}}>{val}</span> if (column1.length > 1) column1[1].render = (val) => <span style={{ color: "red" }}>{val}</span>
column2.splice(0,1) column2.splice(0, 1)
column2=[{title:"序号",fixed:"left",width:50, render:(v,r,i)=>i+1},...column2] column2 = [{ title: "序号", fixed: "left", width: 50, render: (v, r, i) => i + 1 }, ...column2]
return ( return (
<span> <span>
<ButtonDiy name={name||'批量导入'} <ButtonDiy name={name || '批量导入'}
type='default' type='default'
className='defaultBlue' className='defaultBlue'
handleClick={this.showModal}/> handleClick={this.showModal} />
<Modal <Modal
visible={this.state.visible} visible={this.state.visible}
onOk={this.handleOk} onOk={this.handleOk}
...@@ -288,7 +288,7 @@ export default class ImportUtil extends React.PureComponent { ...@@ -288,7 +288,7 @@ export default class ImportUtil extends React.PureComponent {
<Steps current={current}> <Steps current={current}>
{steps.map(item => {steps.map(item =>
<Step key={item.title} <Step key={item.title}
title={item.title}/>)} title={item.title} />)}
</Steps> </Steps>
<div className="steps-content"> <div className="steps-content">
{steps[this.state.current].content} {steps[this.state.current].content}
...@@ -297,14 +297,14 @@ export default class ImportUtil extends React.PureComponent { ...@@ -297,14 +297,14 @@ export default class ImportUtil extends React.PureComponent {
{ {
(this.state.current < steps.length - 1 && this.state.current !== 0) (this.state.current < steps.length - 1 && this.state.current !== 0)
&& &&
<ButtonDiy name={this.state.current==3?"确认导入":"下一步"} type="primary" disabled={this.state.current!=3 && this.state.isNextDisabled} className='primaryBlue' handleClick={() => this.next()}/> <ButtonDiy name={this.state.current == 3 ? "确认导入" : "下一步"} type="primary" disabled={this.state.current != 3 && this.state.isNextDisabled} className='primaryBlue' handleClick={() => this.next()} />
} }
{ {
this.state.current > 0 this.state.current > 0
&& &&
<ButtonDiy style={{ marginLeft: 8 }} name="上一步" className='defaultBlue' handleClick={() => this.prev()}/> <ButtonDiy style={{ marginLeft: 8 }} name="上一步" className='defaultBlue' handleClick={() => this.prev()} />
} }
</div> </div>
...@@ -322,10 +322,10 @@ export default class ImportUtil extends React.PureComponent { ...@@ -322,10 +322,10 @@ export default class ImportUtil extends React.PureComponent {
<div className={styles.buttonDown}> <div className={styles.buttonDown}>
<Upload {...props}> <Upload {...props}>
<Button> <Button>
<Icon type="upload"/>点击上传 <Icon type="upload" />点击上传
</Button> </Button>
</Upload> </Upload>
<Button href={this.state.exportTemplateUrl } <Button href={this.state.exportTemplateUrl}
target="_blank" target="_blank"
type="danger"> type="danger">
下载模板 下载模板
...@@ -333,7 +333,7 @@ export default class ImportUtil extends React.PureComponent { ...@@ -333,7 +333,7 @@ export default class ImportUtil extends React.PureComponent {
</div> : </div> :
<Upload {...props}> <Upload {...props}>
<Button> <Button>
<Icon type="upload"/> <Icon type="upload" />
重新上传 重新上传
</Button> </Button>
</Upload> </Upload>
...@@ -347,24 +347,24 @@ export default class ImportUtil extends React.PureComponent { ...@@ -347,24 +347,24 @@ export default class ImportUtil extends React.PureComponent {
<p>3. 只能上传EXCEL文件(XLS, XLSX) 默认支持EXCEL 2003EXCEL 2007</p> <p>3. 只能上传EXCEL文件(XLS, XLSX) 默认支持EXCEL 2003EXCEL 2007</p>
<p>4. 请将EXCEL文件的所有单元格格式设置为“文本”格式</p> <p>4. 请将EXCEL文件的所有单元格格式设置为“文本”格式</p>
</div> : </div> :
<div className={styles.error} style={{marginTop:20}}> <div className={styles.error} style={{ marginTop: 20 }}>
<Tabs activeKey={this.state.currentKey} key={this.state.ch} onChange={this.changePane} type="card"> <Tabs activeKey={this.state.currentKey} key={this.state.ch} onChange={this.changePane} type="card">
{this.state.errData&&this.state.errData.length==0?"":<TabPane tab={<span style={{color:"red"}}>验证错误列表</span>} key="1"> {this.state.errData && this.state.errData.length == 0 ? "" : <TabPane tab={<span style={{ color: "red" }}>验证错误列表</span>} key="1">
<Button style={{marginTop:5,marginBottom:5}} type="danger" onClick={this.exportError.bind(this,column1,this.state.errData)}>导出错误信息</Button> <Button style={{ marginTop: 5, marginBottom: 5 }} type="danger" onClick={this.exportError.bind(this, column1, this.state.errData)}>导出错误信息</Button>
<Table columns={column1} size="small" <Table columns={column1} size="small"
style={{overflow: 'auto'}} style={{ overflow: 'auto' }}
dataSource={this.state.errData} dataSource={this.state.errData}
bordered={true}/></TabPane>} bordered={true} /></TabPane>}
<TabPane tab={<span style={{color:"green"}}>验证成功列表</span>} key="2"> <TabPane tab={<span style={{ color: "green" }}>验证成功列表</span>} key="2">
<Button style={{marginTop:5,marginBottom:5}} type="primary" onClick={this.exportError.bind(this,column2,this.state.sucData)}>导出正确信息</Button> <Button style={{ marginTop: 5, marginBottom: 5 }} type="primary" onClick={this.exportError.bind(this, column2, this.state.sucData)}>导出正确信息</Button>
<Table columns={column2} size="small" <Table columns={column2} size="small"
style={{overflow: 'auto'}} style={{ overflow: 'auto' }}
dataSource={this.state.sucData} dataSource={this.state.sucData}
bordered={true}/></TabPane> bordered={true} /></TabPane>
</Tabs> </Tabs>
......
...@@ -20,6 +20,11 @@ export const querySysCode = () => queryConfig("SYSCODE"); ...@@ -20,6 +20,11 @@ export const querySysCode = () => queryConfig("SYSCODE");
export const queryWsPath = () => queryConfig("WS_PATH"); export const queryWsPath = () => queryConfig("WS_PATH");
/**
* @description 获取场景设计器定制后台地址
* */
export const queryDynamicActionPath = () => queryConfig("DYNAMIC_ACTION_PATH");
/** /**
* @description 获取服务端请求路径前戳 * @description 获取服务端请求路径前戳
* */ * */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import { extend } from 'umi-request'; import { extend } from 'umi-request';
import { notification } from 'antd'; import { notification } from 'antd';
import { getToken } from './token'; import { getToken } from './token';
import { queryApiActionPath, queryOauthActionPath, queryPermActionPath } from './queryConfig'; import { queryApiActionPath, queryOauthActionPath, queryPermActionPath, queryDynamicActionPath } from './queryConfig';
import { openToast } from '../location/Notification'; import { openToast } from '../location/Notification';
import { showToast } from '../location/Toast'; import { showToast } from '../location/Toast';
import { offline } from '../location/Toast'; import { offline } from '../location/Toast';
...@@ -33,7 +33,7 @@ const codeMessage = { ...@@ -33,7 +33,7 @@ const codeMessage = {
* *
* return URL参数字符串 * return URL参数字符串
*/ */
const objectToQuery = function(param, key, encode) { const objectToQuery = function (param, key, encode) {
if (param == null) return ''; if (param == null) return '';
var paramStr = ''; var paramStr = '';
var t = typeof param; var t = typeof param;
...@@ -271,6 +271,8 @@ const createServerRequest = (config = {}) => { ...@@ -271,6 +271,8 @@ const createServerRequest = (config = {}) => {
return setRequestConfig(config); return setRequestConfig(config);
}; };
export const dynamicRequest = createServerRequest({ method: 'POST', prefix: queryDynamicActionPath() });
export const uaaRequest = createServerRequest({ method: 'POST', prefix: queryOauthActionPath() }); export const uaaRequest = createServerRequest({ method: 'POST', prefix: queryOauthActionPath() });
export const permRequest = createServerRequest({ method: 'POST', prefix: queryPermActionPath() }); export const permRequest = createServerRequest({ method: 'POST', prefix: queryPermActionPath() });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论