/*
* Author: 黎永顺
* name: 字段列表
* Description:
* Date: 2023/1/19
*/
import React, { Component } from "react";
import { WeaTable } from "ecCom";
import { inject, observer } from "mobx-react";
import { Switch } from "antd";
import { salaryFieldList } from "../../../apis/fieldManage";
@inject("taxAgentStore")
@observer
class FieldTable extends Component {
constructor(props) {
super(props);
this.state = {
loading: false,
dataSource: [],
columns: [],
pageInfo: {
current: 1,
pageSize: 10,
total: 0
}
};
}
componentDidMount() {
this.salaryFieldList();
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.doSearch !== this.props.doSearch) this.salaryFieldList({ current: 1 });
}
salaryFieldList = (extra = {}) => {
const { name } = this.props;
const { pageInfo } = this.state;
const payload = { name, ...pageInfo, ...extra };
this.setState({ loading: true });
salaryFieldList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const { pageNum: current, pageSize, total, columns, list: dataSource } = data;
this.setState({
pageInfo: { ...pageInfo, current, pageSize, total },
dataSource,
columns
});
}
});
};
getColumns = () => {
const { columns } = this.state;
const { taxAgentStore, onEditLedger, onDeleteLedger } = this.props;
const { showSalaryItemBtn, showOperateBtn } = taxAgentStore;
return _.map([...columns, {
dataIndex: "operate",
display: true,
key: "operate",
title: "操作"
}], item => {
const { dataIndex } = item;
if (dataIndex === "useDefault" || dataIndex === "hideDefault") {
item.render = (text) => (