antd二级联动异步加载
/**
* Created by Admin on 2016/9/19.
* 批量导入
*/
import React, {Component, PropTypes} from "react";
import {Link} from "react-router";
import {Upload, Icon, Select, Row, Col, Button, notification, Card, Cascader} from "antd";
import CustomBreadcrumb from "../CustomBreadcrumb";
import Utils from "../../common/Utils";
import moment from "moment"; export default class ExportData extends Component { state = {
inputValue: '',
// templateUrl: '/assets/templatefile/行政处罚模板.xlsx',
options: [{
value: 'TI_B_XZXK_REPORTING',
label: '行政许可',
isLeaf: false,
}, {
value: 'TI_B_XZCF_REPORTING',
label: '行政处罚',
isLeaf: false,
}],
}; fetchSelectData = (tableName) => {
// debugger;
this.setState({loading: true});
const query = {
tableName: tableName
};
this.props.exportDataService.findList(query)
.then(arr => {
const options = this.state.options.map(item => {
if (item.value === tableName) {
item.children = arr.map(value => ({value: value, label: value, isLeaf: true}));
}
return item;
});
this.setState({options: options});
});
// .catch(e => this.setState({loading: false}));
// Utils.pushLink(this.props.location.pathname, query);
}; onChange = (values, selectedOptions) => {
console.log(values, selectedOptions); this.setState({
inputValue: selectedOptions.map(o => o.label).join(', '),
});
}; loadData = (selectedOptions) => {
console.log('loadData', selectedOptions); const obj = selectedOptions[0];
if (obj && !obj.isLeaf) {
this.fetchSelectData(obj.value);
}
// const targetOption = selectedOptions[selectedOptions.length - 1];
// targetOption.loading = true;
//
// // load options lazily
// setTimeout(() => {
// targetOption.loading = false;
// targetOption.children = [{
// label: `${targetOption.label} Dynamic 1`,
// value: 'dynamic1',
// }, {
// label: `${targetOption.label} Dynamic 2`,
// value: 'dynamic2',
// }];
// this.setState({
// options: [...this.state.options],
// });
// }, 1000);
}; render() {
const breadcrumbItems = [{
name: '在线填报'
}, {
link: '/reporting/data',
name: '数据维护'
}, {
name: '导出错误数据'
}];
console.log(this.state); let downloadElement ='';
//需要注意这里的取值条件可能有不满足的情况
if(this.state.inputValue && this.state.inputValue.length>6){
const myTime = this.state.inputValue.substring(5);
downloadElement = myTime
? <a href={`/inapi/reportingXzcf/export?time=${myTime}`}><Button type="primary" size="large">导出错误数据</Button></a>
: '';
} return (
<div>
<CustomBreadcrumb global={this.props.global}
globalService={this.props.globalService}
location={this.props.location}
items={breadcrumbItems}/>
<div className="block-box">
<div className="block-box-body clearfix"> <Row gutter={24} style={{marginBottom: "40px", marginLeft: "20px"}}>
<Col className="gutter-row" span={12}>
<div className="ant-row" style={{marginBottom: "40px"}}>
<div className="ant-col-5 ant-form-item-label">
<label htmlFor="CF_WSH" className="ant-form-item-required">请选择</label>
</div>
<Cascader
style={{width: '250px'}}
options={this.state.options}
loadData={this.loadData}
onChange={this.onChange}
changeOnSelect
/>
</div>
</Col> <Col className="gutter-row" span={5}>
{downloadElement}
</Col>
</Row>
</div>
</div>
</div>
);
} }
效果图展示:

antd二级联动异步加载的更多相关文章
- Android批量图片加载经典系列——采用二级缓存、异步加载网络图片
一.问题描述 Android应用中经常涉及从网络中加载大量图片,为提升加载速度和效率,减少网络流量都会采用二级缓存和异步加载机制,所谓二级缓存就是通过先从内存中获取.再从文件中获取,最后才会访问网络. ...
- winform TreeView的一些用法以及异步加载
今天,主要弄了一下对于树型控件的一些方法,以及异步加载.参考: http://www.cnblogs.com/greatverve/archive/2012/03/23/winform-treevie ...
- android listview 异步加载图片并防止错位
网上找了一张图, listview 异步加载图片之所以错位的根本原因是重用了 convertView 且有异步操作. 如果不重用 convertView 不会出现错位现象, 重用 convertVie ...
- Android ListView 图片异步加载和图片内存缓存
开发Android应用经常需要处理图片的加载问题.因为图片一般都是存放在服务器端,需要联网去加载,而这又是一个比较耗时的过程,所以Android中都是通过开启一个异步线程去加载.为了增加用户体验,给用 ...
- Listview异步加载之优化篇
异步加载图片基本思想: 1. 先从内存缓存中获取图片显示(内存缓冲) 2. 获取不到的话从SD卡里获取(SD卡缓冲) 3. 都获取不到的话从网络下载图片并保存到SD卡同时 ...
- zTree 异步加载
zTree异步加载数据的简单实现,更为详细的Api请参考 zTree官网 http://www.treejs.cn/ <link href="~/Content/ztree/css ...
- Listview 异步加载图片之优化篇(有图有码有解释)
在APP应用中,listview的异步加载图片方式能够带来很好的用户体验,同时也是考量程序性能的一个重要指标.关于listview的异步加载,网上其实很多示例了,中心思想都差不多,不过很多版本或是有b ...
- 转:web前端面试题合集 (Javascript相关)(js异步加载详解)
1. HTTP协议的状态消息都有哪些? 1**:请求收到,继续处理2**:操作成功收到,分析.接受3**:完成此请求必须进一步处理4**:请求包含一个错误语法或不能完成5**:服务器执行一个完全有效请 ...
- 【jar包】图片的异步加载--【 Imageloader】
Android Imageloader图片异步加载 Imageloader是一个在android平台下简单的下载.显示.缓存空间的图片加载库. 异步下载网络图片并可以在UI线程更新View,使用二级缓 ...
随机推荐
- Codeforces 1187 F - Expected Square Beauty
F - Expected Square Beauty 思路:https://codeforces.com/blog/entry/68111 代码: #pragma GCC optimize(2) #p ...
- Why do we name variables in Tensorflow?
Reference:Stack Overflow. The name parameter is optional (you can create variables and constants wit ...
- Python基本语法变量
Python的语法和其它编程语言的语法有所不同,编写Paython程序之前需要对语法有所了解,才能编写规范的Python程序.本篇介绍Python标识符的同时,也讨论了Python变量的声明和赋值.通 ...
- C语言博客I作业04
问题 回答 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 作业要求 我在这个课程的目标是 掌握使用for循环语句实现指定次数的循环程序设计. 这个作业在那个具体方面帮助我实现目标 通过 ...
- C# 得到本周的第一天和最后一天
1.得到本周的第一天和最后一天 /// <summary> /// 得到本周第一天(以星期一为第一天) /// </summary> /// <param name=&q ...
- C# 通过浏览器打开指定url
using System.Diagnostics; var resultsg = Process.Start(@"C:\Users\Administrator\AppData\Local\S ...
- 第一篇博客-MVC路由简述
一直念叨着写博客,可是迟迟不见下笔,工作到现在,技术长进了一点,但是记的东西都很杂,也没个思路,也不知道怎么去写一遍博客,现在在做MVC,写一点跟MVC有关的吧. 我们都知道MVC程序的所有请求都是先 ...
- 19、属性赋值-@PropertySource加载外部配置文件
19.属性赋值-@PropertySource加载外部配置文件 加载外部配置文件的注解 19.1 [xml] 在原先的xml 中需要 导入context:property-placeholder 声明 ...
- SIGAI深度学习第九集 卷积神经网络3
讲授卷积神经网络面临的挑战包括梯度消失.退化问题,和改进方法包括卷积层.池化层的改进.激活函数.损失函数.网络结构的改 进.残差网络.全卷机网络.多尺度融合.批量归一化等 大纲: 面临的挑战梯度消失问 ...
- P2993 [FJOI2014]最短路径树问题
思路:最短路+点分治 提交:2次 错因:更新桶的时候没有重置,而直接加上了. 题解: 对于构建最短路树,我们可以先跑最短路,然后dfs一遍连边. 然后就是点分治了,还是一些桶,存点数为\(x\)的最长 ...