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

添加请求

上级 1bb62ce7
......@@ -18,7 +18,7 @@ import { connect } from 'dva';
const Step = Steps.Step;
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 }) => ({
DataObj,
......@@ -28,11 +28,11 @@ export default class ImportUtil extends React.PureComponent {
constructor(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 = {
ch:false,
currentKey:"1",
ch: false,
currentKey: "1",
visible: false,
current: 0,
isShow: true,
......@@ -40,15 +40,15 @@ export default class ImportUtil extends React.PureComponent {
sucData: [],
errData: [],
column: [],
exportTemplateUrl,
isNextDisabled:false,
isNextDisabled: false,
};
}
showModal = () => {
this.setState({
visible: true,
});
......@@ -96,17 +96,17 @@ export default class ImportUtil extends React.PureComponent {
}
import() {
const { dispatch ,importParams } = this.props;
const { dispatch, importParams } = this.props;
dispatch({
type: 'DataObj/importExecute',
payload: {
...(importParams||{}),
cacheKey:this.state.filekey,
...(importParams || {}),
cacheKey: this.state.filekey,
objId: this.props.objId,
},
callback: (res) => {
this.next();
message.success('导入成功');
......@@ -114,45 +114,45 @@ export default class ImportUtil extends React.PureComponent {
current: 3,
isShow: true,
visible: false,
});
if(this.props.callback){
if (this.props.callback) {
this.props.callback();
}
}
})
}
getCachKey = (filePath) => {
const { dispatch ,importParams } = this.props;
const { dispatch, importParams } = this.props;
dispatch({
type: 'DataObj/importAnalyse',
payload: {
...(importParams||{}),
isLocal:false,
...(importParams || {}),
isLocal: false,
filePath,
objId: this.props.objId,
},
callback: (res) => {
this.setState({
filekey: res.cacheKey,
});
this.queryFile(res.cacheKey);
}
})
};
queryFile = (cacheKey) => {
const { dispatch ,importParams } = this.props;
const { dispatch, importParams } = this.props;
dispatch({
type: 'DataObj/importDataQuery',
payload: {
...(importParams||{}),
...(importParams || {}),
cacheKey,
objId: this.props.objId,
},
......@@ -160,71 +160,71 @@ export default class ImportUtil extends React.PureComponent {
this.setState({
current: 1,
isShow: false,
sucData: res.pass,
errData: res.noPass,
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('当前没有验证成功的数据,无法导入。');
this.setState({
currentKey:"1",
ch:!this.state.ch,
currentKey: "1",
ch: !this.state.ch,
isNextDisabled: true
});
} else {
message.success('所有数据验证通过,请确认后点击下一步。');
this.setState({
currentKey:"2",
ch:!this.state.ch,
currentKey: "2",
ch: !this.state.ch,
isNextDisabled: false
});
}
}else{
} else {
message.error('当前存在未验证通过的数据,请按错误提示检测更正导入文件');
this.setState({
currentKey:"1",
ch:!this.state.ch,
isNextDisabled: true
});
}
this.setState({
currentKey: "1",
ch: !this.state.ch,
isNextDisabled: true
});
}
}
})
};
changePane=(activeKey)=>{
this.setState({currentKey:activeKey})
changePane = (activeKey) => {
this.setState({ currentKey: activeKey })
}
exportError=(column,dataSource)=>{
exportError = (column, dataSource) => {
if(exportExcel==null){
if (exportExcel == null) {
message.info("当前终端暂不支持此功能")
return
}
var _headers = []
for(var i=0;i<column.length;i++){
_headers.push({k:column[i].dataIndex,v:column[i].title})
}
for(var j=0;j<dataSource.length;j++){
dataSource[j].index=j+1
}
exportExcel(_headers, dataSource);
var _headers = []
for (var i = 0; i < column.length; i++) {
_headers.push({ k: column[i].dataIndex, v: column[i].title })
}
for (var j = 0; j < dataSource.length; j++) {
dataSource[j].index = j + 1
}
exportExcel(_headers, dataSource);
}
render() {
const props = {
name: 'file',
action: config.uploadUrl,
headers: {
authorization: 'authorization-text',
},
accept:'.xlsx',
accept: '.xlsx',
showUploadList: false,
onChange: (info) => {
if (info.file.status !== 'uploading') {
......@@ -250,25 +250,25 @@ export default class ImportUtil extends React.PureComponent {
}, {
title: '数据导入',
},
{
title: '导入完成',
}];
{
title: '导入完成',
}];
const { current } = this.state;
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]:[]
var column2=this.state.column?[...this.state.column]:[]
if(column1.length>1) column1[1].render=(val)=><span style={{color:"red"}}>{val}</span>
column2.splice(0,1)
column2=[{title:"序号",fixed:"left",width:50, render:(v,r,i)=>i+1},...column2]
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] : []
var column2 = this.state.column ? [...this.state.column] : []
if (column1.length > 1) column1[1].render = (val) => <span style={{ color: "red" }}>{val}</span>
column2.splice(0, 1)
column2 = [{ title: "序号", fixed: "left", width: 50, render: (v, r, i) => i + 1 }, ...column2]
return (
<span>
<ButtonDiy name={name||'批量导入'}
type='default'
className='defaultBlue'
handleClick={this.showModal}/>
<ButtonDiy name={name || '批量导入'}
type='default'
className='defaultBlue'
handleClick={this.showModal} />
<Modal
visible={this.state.visible}
onOk={this.handleOk}
......@@ -279,101 +279,101 @@ export default class ImportUtil extends React.PureComponent {
footer={null}
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()}/>
}
{
this.state.current > 0
&&
<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"/>点击上传
<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()} />
}
{
this.state.current > 0
&&
<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>
</Upload>
<Button href={this.state.exportTemplateUrl }
target="_blank"
type="danger">
下载模板
</Upload>
<Button href={this.state.exportTemplateUrl}
target="_blank"
type="danger">
下载模板
</Button>
</div> :
<Upload {...props}>
<Button>
<Icon type="upload"/>
</div> :
<Upload {...props}>
<Button>
<Icon type="upload" />
重新上传
</Button>
</Upload>
}
{
this.state.isShow ? <div className={styles.attentionItem}>
<p>导入事项</p>
<p>1. 导入操作一次只能上传 1 EXCEL文件。</p>
<p>2. 导入文件最大文件大小上传 1 GB</p>
<p>3. 只能上传EXCEL文件(XLS, XLSX) 默认支持EXCEL 2003EXCEL 2007</p>
<p>4. 请将EXCEL文件的所有单元格格式设置为“文本”格式</p>
</div> :
<div className={styles.error} style={{marginTop:20}}>
<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">
<Button style={{marginTop:5,marginBottom:5}} type="danger" onClick={this.exportError.bind(this,column1,this.state.errData)}>导出错误信息</Button>
<Table columns={column1} size="small"
style={{overflow: 'auto'}}
dataSource={this.state.errData}
bordered={true}/></TabPane>}
<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>
<Table columns={column2} size="small"
style={{overflow: 'auto'}}
dataSource={this.state.sucData}
bordered={true}/></TabPane>
</Tabs>
</div>
}
</div>
</Modal>
</Upload>
}
{
this.state.isShow ? <div className={styles.attentionItem}>
<p>导入事项</p>
<p>1. 导入操作一次只能上传 1 EXCEL文件。</p>
<p>2. 导入文件最大文件大小上传 1 GB</p>
<p>3. 只能上传EXCEL文件(XLS, XLSX) 默认支持EXCEL 2003EXCEL 2007</p>
<p>4. 请将EXCEL文件的所有单元格格式设置为“文本”格式</p>
</div> :
<div className={styles.error} style={{ marginTop: 20 }}>
<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">
<Button style={{ marginTop: 5, marginBottom: 5 }} type="danger" onClick={this.exportError.bind(this, column1, this.state.errData)}>导出错误信息</Button>
<Table columns={column1} size="small"
style={{ overflow: 'auto' }}
dataSource={this.state.errData}
bordered={true} /></TabPane>}
<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>
<Table columns={column2} size="small"
style={{ overflow: 'auto' }}
dataSource={this.state.sucData}
bordered={true} /></TabPane>
</Tabs>
</div>
}
</div>
</Modal>
</span>
);
}
......
......@@ -20,6 +20,11 @@ export const querySysCode = () => queryConfig("SYSCODE");
export const queryWsPath = () => queryConfig("WS_PATH");
/**
* @description 获取场景设计器定制后台地址
* */
export const queryDynamicActionPath = () => queryConfig("DYNAMIC_ACTION_PATH");
/**
* @description 获取服务端请求路径前戳
* */
......
......@@ -5,7 +5,7 @@
import { extend } from 'umi-request';
import { notification } from 'antd';
import { getToken } from './token';
import { queryApiActionPath, queryOauthActionPath, queryPermActionPath } from './queryConfig';
import { queryApiActionPath, queryOauthActionPath, queryPermActionPath, queryDynamicActionPath } from './queryConfig';
import { openToast } from '../location/Notification';
import { showToast } from '../location/Toast';
import { offline } from '../location/Toast';
......@@ -33,7 +33,7 @@ const codeMessage = {
*
* return URL参数字符串
*/
const objectToQuery = function(param, key, encode) {
const objectToQuery = function (param, key, encode) {
if (param == null) return '';
var paramStr = '';
var t = typeof param;
......@@ -134,8 +134,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.mobileAdress
? mobileAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
} else {
sessionStorage.removeItem('cacheMobile');
openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作');
......@@ -143,8 +143,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.webAdress
? x.webAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
}
setTimeout(() => location.reload(), 3000);
}
......@@ -209,8 +209,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.mobileAdress
? mobileAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
} else {
sessionStorage.removeItem('cacheMobile');
openToast('error', '版本更新', '检查到最新版本,即将自动更新,更新完成后请重新操作');
......@@ -218,8 +218,8 @@ export const request = (url, data, options = {}) => {
window.location.href = x.webAdress
? x.webAdress + '?timeVersion=' + time
: ul.indexOf('?') > -1
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
? ul + '&timeVersion=' + time
: ul + '?timeVersion=' + time;
}
setTimeout(() => location.reload(), 3000);
}
......@@ -271,6 +271,8 @@ const createServerRequest = (config = {}) => {
return setRequestConfig(config);
};
export const dynamicRequest = createServerRequest({ method: 'POST', prefix: queryDynamicActionPath() });
export const uaaRequest = createServerRequest({ method: 'POST', prefix: queryOauthActionPath() });
export const permRequest = createServerRequest({ method: 'POST', prefix: queryPermActionPath() });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论