提交 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,
...@@ -40,15 +40,15 @@ export default class ImportUtil extends React.PureComponent { ...@@ -40,15 +40,15 @@ export default class ImportUtil extends React.PureComponent {
sucData: [], sucData: [],
errData: [], errData: [],
column: [], column: [],
exportTemplateUrl, exportTemplateUrl,
isNextDisabled:false, isNextDisabled: false,
}; };
} }
showModal = () => { showModal = () => {
this.setState({ this.setState({
visible: true, visible: true,
}); });
...@@ -96,17 +96,17 @@ export default class ImportUtil extends React.PureComponent { ...@@ -96,17 +96,17 @@ 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,
}, },
callback: (res) => { callback: (res) => {
this.next(); this.next();
message.success('导入成功'); message.success('导入成功');
...@@ -114,45 +114,45 @@ export default class ImportUtil extends React.PureComponent { ...@@ -114,45 +114,45 @@ export default class ImportUtil extends React.PureComponent {
current: 3, current: 3,
isShow: true, isShow: true,
visible: false, visible: false,
}); });
if(this.props.callback){ if (this.props.callback) {
this.props.callback(); this.props.callback();
} }
} }
}) })
} }
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,
}, },
callback: (res) => { callback: (res) => {
this.setState({ this.setState({
filekey: res.cacheKey, filekey: res.cacheKey,
}); });
this.queryFile(res.cacheKey); this.queryFile(res.cacheKey);
} }
}) })
}; };
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,
}, },
...@@ -160,71 +160,71 @@ export default class ImportUtil extends React.PureComponent { ...@@ -160,71 +160,71 @@ export default class ImportUtil extends React.PureComponent {
this.setState({ this.setState({
current: 1, current: 1,
isShow: false, isShow: false,
sucData: res.pass, sucData: res.pass,
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
}); });
} }
} }
}) })
}; };
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);
} }
render() { render() {
const props = { const props = {
name: 'file', name: 'file',
action: config.uploadUrl, action: config.uploadUrl,
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') {
...@@ -250,25 +250,25 @@ export default class ImportUtil extends React.PureComponent { ...@@ -250,25 +250,25 @@ export default class ImportUtil extends React.PureComponent {
}, { }, {
title: '数据导入', title: '数据导入',
}, },
{ {
title: '导入完成', title: '导入完成',
}]; }];
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}
...@@ -279,101 +279,101 @@ export default class ImportUtil extends React.PureComponent { ...@@ -279,101 +279,101 @@ export default class ImportUtil extends React.PureComponent {
footer={null} footer={null}
width={"80%"} width={"80%"}
> >
<div className={styles.nomal}>
<p className={styles.import}>
EXCEL导入向导
</p>
<div style={{ margin: 'auto 23px' }}>
<Steps current={current}>
{steps.map(item =>
<Step key={item.title}
title={item.title}/>)}
</Steps>
<div className="steps-content">
{steps[this.state.current].content}
</div>
<div className={styles.button}>
{
(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()}/>
} <div className={styles.nomal}>
<p className={styles.import}>
{ EXCEL导入向导
this.state.current > 0 </p>
&& <div style={{ margin: 'auto 23px' }}>
<ButtonDiy style={{ marginLeft: 8 }} name="上一步" className='defaultBlue' handleClick={() => this.prev()}/> <Steps current={current}>
{steps.map(item =>
} <Step key={item.title}
</div> title={item.title} />)}
</div> </Steps>
<div className="steps-content">
<div className={styles.tip}> {steps[this.state.current].content}
<p className={styles.tipContent}> </div>
<span>欢迎使用EXCEL导入向导,首先请您上传需要导入的EXCEL文件。</span> <div className={styles.button}>
<span>点击“选择文件”选择您要导入的EXCEL文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。</span> {
</p> (this.state.current < steps.length - 1 && this.state.current !== 0)
&&
</div> <ButtonDiy name={this.state.current == 3 ? "确认导入" : "下一步"} type="primary" disabled={this.state.current != 3 && this.state.isNextDisabled} className='primaryBlue' handleClick={() => this.next()} />
{
this.state.isShow ? }
<div className={styles.buttonDown}>
<Upload {...props}> {
<Button> this.state.current > 0
<Icon type="upload"/>点击上传 &&
<ButtonDiy style={{ marginLeft: 8 }} name="上一步" className='defaultBlue' handleClick={() => this.prev()} />
}
</div>
</div>
<div className={styles.tip}>
<p className={styles.tipContent}>
<span>欢迎使用EXCEL导入向导,首先请您上传需要导入的EXCEL文件。</span>
<span>点击“选择文件”选择您要导入的EXCEL文件,点击“开始上传”将其上传到服务器上,点击“清空队列”清空当前上传文件队列。</span>
</p>
</div>
{
this.state.isShow ?
<div className={styles.buttonDown}>
<Upload {...props}>
<Button>
<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">
下载模板 下载模板
</Button> </Button>
</div> : </div> :
<Upload {...props}> <Upload {...props}>
<Button> <Button>
<Icon type="upload"/> <Icon type="upload" />
重新上传 重新上传
</Button> </Button>
</Upload> </Upload>
} }
{ {
this.state.isShow ? <div className={styles.attentionItem}> this.state.isShow ? <div className={styles.attentionItem}>
<p>导入事项</p> <p>导入事项</p>
<p>1. 导入操作一次只能上传 1 EXCEL文件。</p> <p>1. 导入操作一次只能上传 1 EXCEL文件。</p>
<p>2. 导入文件最大文件大小上传 1 GB</p> <p>2. 导入文件最大文件大小上传 1 GB</p>
<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>
</div> </div>
} }
</div> </div>
</Modal> </Modal>
</span> </span>
); );
} }
......
...@@ -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;
...@@ -134,8 +134,8 @@ export const request = (url, data, options = {}) => { ...@@ -134,8 +134,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.mobileAdress window.location.href = x.mobileAdress
? mobileAdress + '?timeVersion=' + time ? mobileAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1 : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time ? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time; : ul + '?timeVersion=' + time;
} else { } else {
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作'); openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作');
...@@ -143,8 +143,8 @@ export const request = (url, data, options = {}) => { ...@@ -143,8 +143,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.webAdress window.location.href = x.webAdress
? x.webAdress + '?timeVersion=' + time ? x.webAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1 : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time ? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time; : ul + '?timeVersion=' + time;
} }
setTimeout(() => location.reload(), 3000); setTimeout(() => location.reload(), 3000);
} }
...@@ -209,8 +209,8 @@ export const request = (url, data, options = {}) => { ...@@ -209,8 +209,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.mobileAdress window.location.href = x.mobileAdress
? mobileAdress + '?timeVersion=' + time ? mobileAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1 : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time ? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time; : ul + '?timeVersion=' + time;
} else { } else {
sessionStorage.removeItem('cacheMobile'); sessionStorage.removeItem('cacheMobile');
openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作'); openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作');
...@@ -218,8 +218,8 @@ export const request = (url, data, options = {}) => { ...@@ -218,8 +218,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.webAdress window.location.href = x.webAdress
? x.webAdress + '?timeVersion=' + time ? x.webAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1 : ul.indexOf('?') > -1
? ul + '&timeVersion=' + time ? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time; : ul + '?timeVersion=' + time;
} }
setTimeout(() => location.reload(), 3000); setTimeout(() => location.reload(), 3000);
} }
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论