/* * Author: 黎永顺 * name: 人员范围列表数据 * Description: * Date: 2022/11/30 */ import React, { Component } from "react"; import { WeaTable } from "ecCom"; import { getTaxAgentRangeListExclude, getTaxAgentRangeListInclude, taxAgentRangelistExt } from "../../../apis/taxAgent"; import "./index.less"; import { calcPageNo } from "../../../util"; const APIFox = { listInclude: getTaxAgentRangeListInclude, listExclude: getTaxAgentRangeListExclude, listExt: taxAgentRangelistExt }; class PersonalScopeTable extends Component { constructor(props) { super(props); this.state = { loading: { query: false }, dataSource: [], columns: [], selectedRowKeys: [], pageInfo: { current: 1, pageSize: 10, total: 0 } }; } componentDidMount() { this.getPersonalScopeList(); } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.tabActive !== this.props.tabActive) { this.setState({ selectedRowKeys: [] }, () => { this.getPersonalScopeList(nextProps.tabActive); nextProps.onChangeSelectKey([]); }); } } getPersonalScopeList = (tabActive = this.props.tabActive, current) => { const { searchValue, taxAgentId } = this.props; const { pageInfo, loading } = this.state; const payload = { taxAgentId, targetName: searchValue, ...pageInfo, current: current || pageInfo.current }; this.setState({ loading: { ...loading, query: true } }); APIFox[tabActive](payload).then(({ status, data }) => { this.setState({ loading: { ...loading, query: false } }); if (status) { const { pageNum: current, pageSize, total, columns, list: dataSource } = data; this.setState({ pageInfo: { ...pageInfo, current, pageSize, total }, dataSource, columns: _.map(columns, item => { return { ...item, render: (text, record) => { if (item.dataIndex === "targetName") { return this.props.onEditScope(record)}>{text}; } return {text}; } }; }) }); } }).catch(() => { this.setState({ loading: { ...loading, query: false } }); }); }; /* * Author: 黎永顺 * Description: 清空选中项 * Params: * Date: 2022/11/30 */ clearRowkeys = () => { const { pageInfo, selectedRowKeys } = this.state; this.setState({ selectedRowKeys: [], pageInfo: { ...pageInfo, current: calcPageNo(pageInfo.total, pageInfo.current, 10, selectedRowKeys.length) } }, () => { this.getPersonalScopeList(); }); }; render() { const { dataSource, columns, pageInfo, loading, selectedRowKeys } = this.state; const { onChangeSelectKey } = this.props; const pagination = { ...pageInfo, showTotal: total => `共 ${total} 条`, showQuickJumper: true, pageSizeOptions: ["10", "20", "50", "100"], onChange: current => { this.setState({ pageInfo: { ...pageInfo, current } }, () => { this.getPersonalScopeList(); }); } }; const rowSelection = { selectedRowKeys, onChange: (selectedRowKeys) => { this.setState({ selectedRowKeys }, () => { onChangeSelectKey(this.state.selectedRowKeys); }); } }; return ( ); } } export default PersonalScopeTable;