123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- import React, { Component } from "react";
- import {
- Button,
- message,
- Spin,
- Upload,
- Tabs,
- Table,
- Modal,
- } from "antd";
- import $ from "jquery/src/ajax";
- import { ShowModal } from "@/tools";
- import moment from "moment";
- import ShowModalDiv from "@/showModal.jsx";
- import './index.less';
- const { TabPane } = Tabs;
- class Complete extends Component {
- constructor(props) {
- super(props);
- this.state = {
- type: 0,
- Loading: false,
- columns: [
- {
- title: "姓名",
- dataIndex: "name",
- key: "name",
- width: 130,
- },
- {
- title: "是否有效",
- dataIndex: "povertyStatus",
- key: "povertyStatus",
- width: 130,
- },
- {
- title: "",
- dataIndex: "op",
- key: "op",
- },
- ],
- dataSource: [],
- totalcount: 0,
- effectiveCount: 0,
- id: "",
- upLoad: {
- customRequest: (options) => {
- this.setState({
- Loading: true,
- })
- let params = new FormData();
- params.append("file", options.file);
- $.ajax({
- method: "post",
- url: globalConfig.context + "/open/selectFlag",
- async: true,
- cache: false,
- contentType: false,
- processData: false,
- data: params
- }).done(
- function (data) {
- this.setState({
- Loading: false,
- })
- if (data.error.length === 0) {
- let info = data.data
- this.setState({
- dataSource: info.list,
- totalcount: info.totalcount,
- effectiveCount: info.effectiveCount,
- id: info.id,
- })
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this)
- ).always(
- function () {
- this.setState({
- Loading: false,
- });
- }.bind(this)
- );
- },
- name: "file",
- action: globalConfig.context + "/api/user/channel/import",
- },
- };
- this.exportExec = this.exportExec.bind(this);
- this.onSwitch = this.onSwitch.bind(this);
- }
- componentWillMount() {
- }
- // 导出
- exportExec() {
- message.config({
- duration: 20,
- });
- let loading = message.loading("下载中...");
- this.setState({
- Loading: true,
- });
- let data = {
- id: this.state.id,
- type: this.state.type,
- };
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/open/selectPovertyFlagById/export",
- data,
- success: function (data) {
- if (data.error.length === 0) {
- this.download(data.data);
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this),
- }).always(
- function () {
- loading();
- this.setState({
- Loading: false,
- });
- }.bind(this)
- );
- }
- // 导出下载
- download(fileName) {
- window.location.href =
- globalConfig.context + "/open/download?fileName=" + fileName;
- }
- // 下载模板
- downLoadFile() {
- window.open(globalConfig.context + '/open/downloadPovertyTemplate')
- }
- // 有效数据切换
- onSwitch() {
- this.setState({
- Loading: true,
- });
- $.ajax({
- method: "get",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/open/selectPovertyFlagById",
- data: {
- id: this.state.id,
- type: this.state.type == 0 ? 1 : 0,
- },
- success: function (data) {
- this.setState({
- Loading: false,
- });
- if (data.error.length === 0) {
- this.setState({
- type: this.state.type == 0 ? 1 : 0,
- dataSource: data.data.list,
- })
- } else {
- message.warning(data.error[0].message);
- }
- }.bind(this),
- }).always(
- function () {
- this.setState({
- Loading: false,
- });
- }.bind(this)
- );
- }
- render() {
- const { columns, dataSource, totalcount, effectiveCount, id, type } = this.state;
- return (
- <div className="user-content">
- <ShowModalDiv ShowModal={this.state.showModal} onClose={() => { this.setState({ showModal: false }) }} />
- <div className="content-title" style={{ marginBottom: 10 }}>
- <span style={{ fontWeight: 900, fontSize: 16 }}>建档立卡脱贫户-批量查询</span>
- </div>
- <Tabs defaultActiveKey="1">
- <TabPane tab="操作" key="1">
- <div
- style={{
- width: "100%",
- paddingBottom: 10,
- display: "flex",
- flexDirection: "row",
- justifyContent: "space-between",
- }}
- >
- <div
- style={{
- display: "flex"
- }}
- >
- <Upload {...this.state.upLoad} disabled={this.state.Loading}>
- <Button
- type="primary"
- onClick={() => {
- }}
- style={{ marginLeft: "10px" }}
- >
- 导入查询数据
- </Button>
- </Upload>
- <Button
- type="primary"
- onClick={this.downLoadFile}
- style={{ marginLeft: "10px" }}
- >
- 下载批量查询模板
- </Button>
- <Button
- type="primary"
- loading={this.state.Loading}
- onClick={this.exportExec}
- style={{ marginLeft: "10px" }}
- disabled={!id}
- >
- 导出EXCEL
- </Button>
- </div>
- <div>
- <span>数据统计:有效数据<span style={{ color: "red" }}>{effectiveCount}</span>条,共<span style={{ color: "red" }}>{totalcount}</span>条数据</span>
- <Button
- type="primary"
- onClick={this.onSwitch}
- style={{ margin: "0 10px" }}
- disabled={!id}
- >
- {type == 0 ? "仅显示有效数据" : "显示所有数据"}
- </Button>
- </div>
- </div>
- </TabPane>
- </Tabs>
- <div className="patent-table">
- <Spin spinning={this.state.Loading}>
- <Table
- bordered
- size="middle"
- columns={columns}
- dataSource={dataSource}
- />
- </Spin>
- </div>
- </div>
- );
- }
- }
- export default Complete;
|