import * as React from 'react';
import { PageHeaderFoot, Button, AutoTableContainer, Pagination, message, TableManual, Modal as Modal2 } from 'kts-xui';
import { AdvancedSearch, KtsForm } from 'kts-components';
import { WrapperDrop } from 'kts-components';
import HistoryModal from './UI.HistoryModal'; 
import DenyModal from './UI.DenyModal';
import { columnEnum } from '../CommonComponents/ColumnEnum';
import Icon, { InfoCircleOutlined, CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons';
import { findLabel, invoiceTypeEnum, proveStatusEnum, effectiveStatusEnum, appealStatusEnum } from '../CommonComponents/FiledsEnum';
import moment from 'moment';
import { withRouter, RouteChildrenProps } from 'react-router-dom';
import agent from '../Server';
import { DigitalAssetVerification as agentDig } from '../../';
import { Space, Tag, Tooltip, Menu, Modal } from 'kts-components-antd-x4';
import { DigitalAssetVerification } from '../..';  
import Sort from '../CommonComponents/Sort';
import { SettingOutlined } from '@ant-design/icons'; 
import './index.less'
/** Props接口 */
interface IProps {

}

class UIComponents extends React.Component<IProps & RouteChildrenProps, any> {
    columnAction = [{
        title: '操作',
        dataIndex: 'id',
        width: 120,
        fixed: 'right',
        render: (text, record) => {
            return <Space> 
                {record.appealStatus === 2 && <a style={{ marginRight: 5 }} onClick={() => { this.onYesHandler([text]); }}>同意</a>}
                {record.appealStatus === 2 && <a style={{ marginRight: 5 }} onClick={() => { this.onDenyHandler([text]); }}>拒绝</a>}
                {/* <a style={{ marginRight: 5 }} onClick={() => { this.showHistory(text); }}>处理记录</a> */}
            </Space>
        }
    }]

    constructor(props) {
        super(props);
        this.state = {
            pageMeta: null,
            list: [

            ],
            params: this.props.location.state || {},
            denyModal: false,
            selectedRowKeys: [],
            processList: [],
            viewID: '',
            historyModal: false,
            columns: [
                {
                    title: '商品id',
                    dataIndex: 'lineUuid',
                    key:'lineUuid',
                    width: 340,
                },
                {
                    title: '处理状态',
                    dataIndex: 'appealStatus',
                    key: 'appealStatus',
                    align: 'center',
                    width: 100,
                    render: (text) => {
                        if (text === 3) {
                            return <span style={{ color: '#0074ff' }}>{findLabel(text, appealStatusEnum)}</span>
                        } else if (text === 1) {
                            return <span style={{ color: 'red' }}>{findLabel(text, appealStatusEnum)}</span>
                        } else {
                            return findLabel(text, appealStatusEnum);
                        }
                    }
                },
                {
                    title: '业务有效性',
                    width: 120,
                    align: 'center',
                    dataIndex: columnEnum['有效性状态'],
                    key: columnEnum['有效性状态'],
                    render: (text, record) => {
                        if (text === 2) {
                            return <Tooltip title={record.refusalCause}><span style={{ color: 'red' }}>{findLabel(text, effectiveStatusEnum)}</span></Tooltip>
                        } else {
                            return <span style={{ color: '#0074ff' }}>{findLabel(text, effectiveStatusEnum)}</span>
                        }
                    }
                },
                {
                    title: '证明结果',
                    width: 100,
                    align: 'center',
                    dataIndex: columnEnum['证明标识'],
                    key: columnEnum['证明标识'],
                    render: (text, record) => {
                        if (text === 2 || text === 4) {
                            return <Tooltip title={record.proveMsg}><span style={{ color: 'red' }}>{findLabel(text, proveStatusEnum)}</span></Tooltip>
                        } else if (!text) {
                            return '-';
                        } else if (text === 1) {
                            return <span style={{ color: '#0074ff' }}>{findLabel(text, proveStatusEnum)}</span>
                        } else {
                            return findLabel(text, proveStatusEnum)
                        }

                    }
                }, {
                    title: '采集方',
                    dataIndex: columnEnum['被核验方'],
                    key: columnEnum['被核验方'],
                    width: 160,
                    ellipsis: true,
                },
                {
                    title: '申诉原因',
                    dataIndex: 'appealReason',
                    key: 'appealReason',
                    width: 240,
                    ellipsis: true,
                }, {
                    title: '销售方',
                    dataIndex: columnEnum['销售方'],
                    key: columnEnum['销售方'],
                    width: 190,
                    ellipsis: true,
                }, {
                    title: '采购方',
                    dataIndex: columnEnum['采购方'],
                    key: columnEnum['采购方'],
                    width: 190,
                    ellipsis: true,
                }, {
                    title: '商品名称',
                    dataIndex: columnEnum['商品名称'],
                    key: columnEnum['商品名称'],
                    width: 150,
                    ellipsis: true,
                }, {
                    title: '规格型号',
                    dataIndex: columnEnum['规格型号'],
                    key: columnEnum['规格型号'],
                    width: 150,
                    ellipsis: true,
                    render: (text) => {
                        return <span style={{ whiteSpace: 'pre-wrap' }}>{text}</span>
                    }
                },  {
                    title: '数量',
                    width: 80,
                    dataIndex: columnEnum['数量'],
                    key: columnEnum['数量'],
                    align: 'right'
                }, {
                    title: '单位',
                    dataIndex: columnEnum['单位'],
                    key: columnEnum['单位'],
                    width: 80,
                    align: 'right'
                }, {
                    title: '发票类型',
                    dataIndex: 'invoiceType',
                    key: 'invoiceType',
                    align: 'center',
                    width: 120,
                    render: (text, record) => {
                        if (text) {
                            return <Tag>{findLabel(text, invoiceTypeEnum)}</Tag>

                        }
                    }
                }, {
                    title: '发票代码',
                    width: 150,
                    dataIndex: 'invoiceCode',
                    key: 'invoiceCode',
                }, {
                    title: '发票号码',
                    dataIndex: 'invoiceNo',
                    key: 'invoiceNo',
                    width: 190,
                }, {
                    title: '开票日期',
                    width: 120,
                    dataIndex: 'invoiceDate',
                    key: 'invoiceDate',
                    ellipsis: true,
                    render: text => {
                        return text && moment(text).format('YYYY-MM-DD')
                    }
                }, {
                    title: '申诉时间',
                    dataIndex: 'appealTime',
                    key: 'appealTime',
                    ellipsis: true,
                    width: 160,
                    render: (text) => {
                        return text && moment(text).format('YYYY-MM-DD HH:mm');
                    }
                },
                {
                    title: '提交用途',
                    width: 150,
                    ellipsis: true,
                    dataIndex: 'submitPurpose',
                    key: 'submitPurpose'
                }, {
                    title: '申诉人',
                    width: 100,
                    ellipsis: true,
                    dataIndex: 'petitioner',
                    key: 'petitioner',
                }, {
                    title: '处理时间',
                    width: 160,
                    dataIndex: 'processTime',
                    key: 'processTime',
                    ellipsis: true,
                    render: (text) => {
                        return text && moment(text).format('YYYY-MM-DD HH:mm');
                    }
                }, {
                    title: '处理人',
                    width: 100,
                    ellipsis: true,
                    dataIndex: 'processor',
                    key: 'processor',
                }, {
                    title: '拒绝原因',
                    width: 100,
                    ellipsis: true,
                    dataIndex: 'appealRefusalCause',
                    key: 'appealRefusalCause',
                },
                {
                    title: '任务单号',
                    dataIndex: columnEnum['任务单号'],
                    key: columnEnum['任务单号'],
                    width: 160,
                    ellipsis: true,
                    render: (text, record) => {
                        if (record.originPartyType === 1) {
                            return <span>{text}</span>
                        }
                    }
                },
                {
                    title: '关联单据',
                    width: 120,
                    dataIndex: 'goodsDocRelationList',
                    key: 'goodsDocRelationList',
                    ellipsis: true,
                    render: (text) => {
                        if (text.length > 0) {
                            let originalDocuments = text.reduce((acc, obj) => {
                                acc.push(obj.originalDocument);
                                return acc;
                            }, [])
                            let str = originalDocuments.join('/');
                            return str
                        }
                    }
                },

            ],
            columnsMok: [
                {
                    title: '商品id',
                    dataIndex: 'lineUuid',
                    key:'lineUuid',
                    width: 340,
                },
                {
                    title: '处理状态',
                    dataIndex: 'appealStatus',
                    key: 'appealStatus',
                    type: 'string',
                },
                {
                    title: '业务有效性',
                    dataIndex: columnEnum['有效性状态'],
                    key: columnEnum['有效性状态'],
                    type: 'string',
                },
                {
                    title: '证明结果',
                    dataIndex: columnEnum['证明标识'],
                    key: columnEnum['证明标识'],
                    type: 'string',
                }, {
                    title: '采集方',
                    dataIndex: columnEnum['被核验方'],
                    key: columnEnum['被核验方'],
                    type: 'string',
                },
                {
                    title: '申诉原因',
                    dataIndex: 'appealReason',
                    key: 'appealReason',
                    type: 'string',
                }, {
                    title: '销售方',
                    dataIndex: columnEnum['销售方'],
                    key: columnEnum['销售方'],
                    type: 'string',
                }, {
                    title: '采购方',
                    dataIndex: columnEnum['采购方'],
                    key: columnEnum['采购方'],
                    type: 'string',
                }, {
                    title: '商品名称',
                    dataIndex: columnEnum['商品名称'],
                    key: columnEnum['商品名称'],
                    type: 'string',
                }, {
                    title: '规格型号',
                    dataIndex: columnEnum['规格型号'],
                    key: columnEnum['规格型号'],
                    type: 'string',
                    render: (text) => {
                        return <span style={{ whiteSpace: 'pre-wrap' }}>{text}</span>
                    }
                }, {
                    title: '数量',
                    dataIndex: columnEnum['数量'],
                    key: columnEnum['数量'],
                    type: 'string',
                }, {
                    title: '单位',
                    dataIndex: columnEnum['单位'],
                    key: columnEnum['单位'],
                    type: 'string',
                }, {
                    title: '发票类型',
                    dataIndex: 'invoiceType',
                    key: 'invoiceType',
                    type: 'string',
                }, {
                    title: '发票代码',
                    type: 'string',
                    dataIndex: 'invoiceCode',
                    key: 'invoiceCode',
                }, {
                    title: '发票号码',
                    dataIndex: 'invoiceNo',
                    key: 'invoiceNo',
                    type: 'string',
                }, {
                    title: '开票日期',
                    dataIndex: 'invoiceDate',
                    key: 'invoiceDate',
                    type: 'string',
                }, {
                    title: '申诉时间',
                    dataIndex: 'appealTime',
                    key: 'appealTime',
                    type: 'string',
                },
                {
                    title: '提交用途',
                    type: 'string',
                    dataIndex: 'submitPurpose',
                    key: 'submitPurpose'
                    // render:text=>text&&text.join(',')
                }, {
                    title: '申诉人',
                    type: 'string',
                    dataIndex: 'petitioner',
                    key: 'petitioner',
                }, {
                    title: '处理时间',
                    dataIndex: 'processTime',
                    key: 'processTime',
                    type: 'string'
                }, {
                    title: '处理人',
                    type: 'string',
                    dataIndex: 'processor',
                    key: 'processor',
                }, {
                    title: '拒绝原因',
                    type: 'string',
                    dataIndex: 'appealRefusalCause',
                    key: 'appealRefusalCause',
                },
                {
                    title: '任务单号',
                    dataIndex: columnEnum['任务单号'],
                    key: columnEnum['任务单号'],
                    type: 'string'
                },
                {
                    title: '关联单据',
                    dataIndex: 'goodsDocRelationList',
                    key: 'goodsDocRelationList',
                    type: 'string'
                },
            ],
            sortDataSource: []
        };
    }
    topExpand = () => {
        const { params } = this.state;
        let cloneData = JSON.parse(JSON.stringify(params));
        delete cloneData.minInvoiceDate
        delete cloneData.maxInvoiceDate
        delete cloneData.minAppealTime
        delete cloneData.maxAppealTime
        return (
            <AdvancedSearch
                width={480}
                height={44}
                initialValues={cloneData}
                compact={true}
                defaultKey="invoiceCode"
                placeholder="请输入发票代码"
                searchFormSubmit={this.onSearch}
            >
                <KtsForm
                    labelCol={9}
                    wrapperCol={15}
                    initialValues={cloneData}
                    labelAlign="left"
                    compact={true}
                    schema={{
                        type: 'object',
                        properties: {
                            [columnEnum['任务单号']]: {
                                type: 'string',
                                title: '任务单号',
                            },
                            'lineUuid': {
                                type: 'string',
                                title: '商品id',
                            },
                            [columnEnum['商品名称']]: {
                                type: 'string',
                                title: '商品名称',
                            },
                            [columnEnum['规格型号']]: {
                                type: 'string',
                                title: '规格型号(包含)',
                            },
                            'notContainSpecificationModel': {
                                type: 'string',
                                title: '规格型号(不包含)',
                            },
                            [columnEnum['被核验方']]: {
                                type: 'string',
                                title: '采集方',
                            },
                            [columnEnum['销售方']]: {
                                type: 'string',
                                title: '销售方',
                            },
                            [columnEnum['采购方']]: {
                                type: 'string',
                                title: '采购方',
                            },
                            kaipiao: {
                                type: 'daterange',
                                title: '开票日期',
                                'x-props': {
                                    extendsFields: ['minInvoiceDate', 'maxInvoiceDate'],
                                }
                            },
                            shensu: {
                                type: 'daterange',
                                title: '申诉时间',
                                'x-props': {
                                    extendsFields: ['minAppealTime', 'maxAppealTime'],
                                }
                            },
                            submitPurpose: {
                                type: 'string',
                                title: '提交用途',
                            },
                            invoiceCode: {
                                type: 'string',
                                title: '发票代码',
                            },
                            invoiceNo: {
                                type: 'string',
                                title: '发票号码',
                            },
                            appealStatus: {
                                type: 'string',
                                title: '申诉状态',
                                enum: appealStatusEnum
                            },
                            refusalCause: {
                                type: 'string',
                                title: '无效原因',
                                enum: [
                                    { label: '客户无效', value: '客户无效' },
                                    { label: '商品无效', value: '商品无效' },
                                ]
                            },
                            originalDocument: {
                                type: 'string',
                                title: '关联单据',
                            },
                        },
                    }}
                >
                </KtsForm>
            </AdvancedSearch>
        );
    }
    showHistory = (text) => {
        this.setState({
            historyModal: true,
            viewId: text
        })
    }
    /**
     * 单个接受
     * @param keys 
     */
    onYesHandler = (keys: string[]) => {
        const passed2 = this.checkPreHandle2(keys, false);
        if (!passed2) {
            return;
        }  
        // this.onAccept(keys);
    }
    /**
     * 批量接受
     * @list 数据列表 
     * @appealStatus 1=拒绝，3=接受
     * @appealRefusalCause 拒绝时要传入拒绝原因 必填
     */
    onAccept = async (list: string[], appealStatus: number = 3, appealRefusalCause?: any) => {
        const params = {
            includeManyId: list,
            appealStatus,
            ...appealRefusalCause
        }
        const res: any = await DigitalAssetVerification.server.post(`${DigitalAssetVerification.prefix_path}/web/verifier/appeal/handleAppeal`, params).resFs(DigitalAssetVerification.server.resFs.filter(v => v !== DigitalAssetVerification.serviceTools.verificationResponse)).end(this);
        if (res.err) {
            if (res.err.body.status.description.indexOf('发票状态异常，无法通过核验') >= 0) {
                Modal.info({
                    content: (
                        <div>
                            {res.err.body.status.description}
                        </div>
                    ),
                })
            } else {
                message.error(res.err.body.status.message);
            }
            return;
        } else {
            message.success('操作成功');
            this.setState({
                selectedRowKeys: [],
                processList: []
            }, () => {
                this.onRefresh();
                this.closeModal();
            });

        }
    }

    /**
     * 拒绝提交
     * @param data 
     */
    onSuccess = (data) => {
        this.onAccept(this.state.processList, 1, data);
    }
    /**
     * 单个拒绝
     * @param keys 
     */
    onDenyHandler = (keys: string[]) => { 
        this.setState({
            processList: keys,
            denyModal: true
        })
    }
    onDownload = async () => {
        // this.props.data.commonDownloadCb && this.props.data.commonDownloadCb();
    } 
    downloadFile = async (downloadPath) => {
        if (downloadPath.indexOf('http') >= 0 || downloadPath.indexOf('//') === 0) {
            window.open(this.state.downloadFilePath);
        } else {
            //航天环境必须采用下载二进制流的形式，不再使用下载链接
            const res=await agentDig.server.post(`${agentDig.prefix_path}/web/verifiedTask/downloadFile`,{fileName:downloadPath}).reqFs(agentDig.server.reqFs.filter(v => v !== agentDig.serviceTools.addContentType)).resFs([]).responseType('blob').end(null);
            if (res.err) {
                return;
            } else {
                const blob = res.res.body;
                let url = URL.createObjectURL(blob);
                let link = document.createElement('a');
                link.style.display = 'none';
                link.href = url;
                link.setAttribute('download', `下载文件-${moment(new Date()).format('YYYYMMDDHHmmss')}.xls`);
                link.click();
            } 
        }
    } 
    /** 
     * 
     * 同意之前的校验接口1 
     * */
    checkPreHandle1 = async (ids: string[], isBatch: boolean) => {
        const res: any = await agent.post('/web/verifier/appeal/appealRepeatCheck', {includeManyId: ids, batchHandle: isBatch}, this);
        if (res.err) {
            return false;
        } else {
            if(res.res.checkPass === false){
                // false时，弹窗提示
                const downloadPath = res.res.errorDataFileUrl;
                let title = '提示';  
                let icon = <InfoCircleOutlined style={{ color: '#FFD900', fontSize: 30 }} />;
                let download = <a href={downloadPath} target='_self' onClick={() => setTimeout(()=>{Modal.destroyAll()}, 300) }>下载重复商品 </a> 
                Modal.info({
                    className:'infomodal',
                    width: '396px',  
                    maskClosable:false, 
                    okButtonProps: { style: { display: 'none' } },
                    content: (
                        <div>
                           <p style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 18, textAlign: 'center', marginBottom: 15, fontWeight: 500, color: '#212223' }}>{icon} <span style={{ paddingLeft: 5 }}>{title}</span></p>
                                <span>勾选商品重复，无法批量同意，请重新勾选</span>
                            <div style={{ display: 'flex', justifyContent: 'space-between', padding: '35px 0 0' }}>
                                <div>
                                    {download}
                                </div>
                                <div>
                                    <Space size={20}>
                                        {/* <a onClick={() =>{ Modal.destroyAll(); }}>下载重复商品</a> */}
                                        <a onClick={() => Modal.destroyAll()}>取消</a>
                                    </Space>
                                </div>
                            </div>
                        </div>
                    ),
                }) 

            } 
            return res.res.checkPass;
        }
    }

    /** 
     * 
     * 同意之前的校验接口2
     * */
    checkPreHandle2 = async (ids: string[], isBatch: boolean) => {
        const res: any = await agent.post('/web/verifier/appeal/preHandleAppeal', {includeManyId: ids, batchHandle: isBatch}, this);
        if (res.err) {
            return false;
        } else { 
            if(res.res.passCheck == false){
                const { totalNo, handleAppealNo, existEffectiveNo, downloadPath, includeManyId } = res.res;
                let title = '处理结果'; 
                let download =  <a href={downloadPath} target='_self' onClick={() => setTimeout(()=>{Modal.destroyAll()}, 300) }>下载“未同意”申诉 </a>  
                let icon = <InfoCircleOutlined style={{ color: '#FFD900', fontSize: 30 }} />;
                let info = <span>勾选申诉<span style={{ color: '#0074ff' }}>{totalNo}条</span>，已同意<span style={{ color: '#0074ff' }}>{handleAppealNo}条</span>，申诉商品已存在“有效”<span style={{ color: '#0074ff' }}>{existEffectiveNo}条</span>，无法再次同意，是否拒绝相关申诉？</span>
                if(isBatch) {
                    Modal.info({
                        className:'infomodal',
                        width: '396px',  
                        maskClosable:false, 
                        okButtonProps: { style: { display: 'none' } },
                        content: (
                            <div>
                            <p style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 18, textAlign: 'center', marginBottom: 15, fontWeight: 500, color: '#212223' }}>{icon} <span style={{ paddingLeft: 5 }}>{title}</span></p>
                                {info}
                                <div style={{ display: 'flex', justifyContent: 'space-between', padding: '35px 0 0' }}>
                                    <div>
                                        {download}
                                    </div>
                                    <div>
                                        <Space size={20}>
                                            <a onClick={() =>{ Modal.destroyAll(); this.onDenyHandler(includeManyId) }}>拒绝</a>
                                            <a onClick={() => Modal.destroyAll()}>取消</a>
                                        </Space>
                                    </div>
                                </div>
                            </div>
                        ),
                    });
                }else{
                    Modal.info({
                        className:'infomodal',
                        width: '396px',  
                        maskClosable:false, 
                        okButtonProps: { style: { display: 'none' } },
                        content: (
                            <div>
                            <p style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 18, textAlign: 'center', marginBottom: 15, fontWeight: 500, color: '#212223' }}>{icon} <span style={{ paddingLeft: 5 }}>{title}</span></p>
                                <span>同意失败！该商品之前已存在”有效“，无法再次同意；是否拒绝本条申诉？</span>
                                <div style={{ display: 'flex', justifyContent: 'space-between', padding: '35px 0 0' }}>
                                    <div> 
                                    </div>
                                    <div>
                                        <Space size={20}>
                                            <a onClick={() =>{ Modal.destroyAll(); this.onDenyHandler(ids) }}>拒绝</a>
                                            <a onClick={() => Modal.destroyAll()}>取消</a>
                                        </Space>
                                    </div>
                                </div>
                            </div>
                        ),
                    });
                }
                
            } else {
                message.success('操作成功');
                this.setState({
                    selectedRowKeys: [],
                    processList: []
                }, () => {
                    this.onRefresh();
                    this.closeModal();
                });
            }
            return res.res.passCheck;
        }
    }
    /**
     * 批量拒绝
     */
    onDeny = () => {
        this.setState({
            denyModal: true,
            processList: [...this.state.selectedRowKeys]
        })
    }
    componentDidMount() {
        const params = {
            pageNum: 1,
            pageSize: 10,
            ...this.state.params,
        };
        this.getData(params);
        this.getLocalSort();
    }
    onPageChange = (pageNum, pageSize) => {
        this.setState({
            pageMeta: {
                ...this.state.pageMeta,
                pageNum,
                pageSize
            }
        }, () => {
            this.onRefresh();
        });
    }
    onRefresh = () => {
        const params = {
            ...this.state.params,
            ...this.state.pageMeta,
        };
        this.getData(params);
    }
    onSearch = (data = {}) => {
        this.setState({
            params: data
        });
        const params = {
            ...data,
            ...this.state.pageMeta,
            pageNum: 1
        };
        this.getData(params);
    }
    getData = async (params?) => {
        params = {
            ...params,
            minAppealTime: params['minAppealTime'] && moment(params['minAppealTime']).format('YYYY-MM-DD 00:00:00'),
            maxAppealTime: params['maxAppealTime'] && moment(params['maxAppealTime']).format('YYYY-MM-DD 23:59:59'),
        }
        const res: any = await agent.post('/web/verifier/appeal/pageRecord', params, this);
        if (res.err) {
            return;
        } else {
            this.setState({
                pageMeta: res.res.pageMeta,
                list: res.res.items
            });
        }
    }



    closeModal = () => {
        this.setState({
            denyModal: false,
            processList: []
        })
    }
    closeHistoryModal = () => {
        this.setState({
            historyModal: false,
        })
    }
    onExport = async () => {
        const { params } = this.state;
        const data = {
            ...this.state.params,
            minAppealTime: params['minAppealTime'] && moment(params['minAppealTime']).format('YYYY-MM-DD 00:00:00'),
            maxAppealTime: params['maxAppealTime'] && moment(params['maxAppealTime']).format('YYYY-MM-DD 23:59:59'),
            minInvoiceDate: params['minInvoiceDate'] && moment(params['minInvoiceDate']).format('YYYY-MM-DD 00:00:00'),
            maxInvoiceDate: params['maxInvoiceDate'] && moment(params['maxInvoiceDate']).format('YYYY-MM-DD 23:59:59'),
        };
        // const res: any = await DigitalAssetVerification.server.post(`${DigitalAssetVerification.prefix_path}//web/verifier/appeal/export`, data).reqFs(DigitalAssetVerification.server.reqFs.filter(v => v !== DigitalAssetVerification.serviceTools.addContentType)).resFs([]).responseType('blob').end(null);
        const res: any = await DigitalAssetVerification.server.post(`${DigitalAssetVerification.prefix_path}/web/verifier/appeal/export`, data).end(null);
        if (res.err) {
            return;
        } else {
            if(res.res){  
                Modal2.info({
                    title: '数据导出中',
                    content: <div style={{textAlign: 'center'}}>导出为异步操作，请稍后查看</div>,
                    onOk: () => {
                        this.props.history.push({ pathname: '/task/list/export', state: {fileType: 'APPEAL_RECORD'} })
                    },
                    okType: 'link',
                    okText: '查看导出记录',
                    closable: true,     // 显示右上角关闭按钮
                });
            } else {
                message.error('导出失败')
            }
        } 
    }
    setDataSource = (data) => {
        const keys = Sort.filter(this.state.columnsMok, data) || [];
        const checkedKeys = keys.map((item) => {
            return {
                key: item.key,
                checked: true
            }
        })
        this.setState({
            sortDataSource: checkedKeys
        })
        window.localStorage.setItem('masterresponse', JSON.stringify(data))
    }
    getLocalSort = () => {
        const d = window.localStorage.getItem('masterresponse');
        let checkedKeys = []
        if (d) {
            checkedKeys = JSON.parse(d);
            this.setDataSource(checkedKeys);
        } else {
            checkedKeys = this.state.columns.map((item) => {
                return {
                    key: item.key,
                    checked: true
                }
            })
        }
        this.setState({
            sortDataSource: checkedKeys
        })

    }
    batchAccept = async (selectedRowKeys) => {
        // passed为false时不再往下执行
        const passed1 = await this.checkPreHandle1(selectedRowKeys, true);  
        if (!passed1) {
            return;
        } 
        const passed2 = await this.checkPreHandle2(selectedRowKeys, true);  
        if (!passed2) {
            return;
        } 
        // this.onAccept(selectedRowKeys); 
    }
    render() {
        const dataSource = this.state.list;
        const { pageMeta, selectedRowKeys, sortDataSource } = this.state;
        const columns = Sort.filter(this.state.columns, this.state.sortDataSource) || [];
        const rowSelection = {
            selectedRowKeys:selectedRowKeys,
            onChange: (selectedRowKeys, selectedRows) => {
                this.setState({
                    selectedRowKeys
                });
            },
            getCheckboxProps: (record) => ({
                disabled: record.appealStatus !== 2
            }),
        }
        const menu = (<Menu>
            <Menu.Item disabled={selectedRowKeys.length === 0 ? true : false} key='0' onClick={() => { this.batchAccept(this.state.selectedRowKeys) }}>
                批量同意
            </Menu.Item>
            <Menu.Item disabled={selectedRowKeys.length === 0 ? true : false} key='1' onClick={this.onDeny}>
                批量拒绝
            </Menu.Item>
        </Menu>)
        return (
            <div style={{ height: 'calc(100vh - 97px)', display: 'flex', flexDirection: 'column' }}>
                <div style={{ flex: 'none', position: 'relative', zIndex: 1 }}>
                    <PageHeaderFoot
                        expandLeft={this.topExpand()}
                        expandRight={[
                            <WrapperDrop overlay={menu} key='0'><Button type="primary">批量操作</Button></WrapperDrop>,
                            <Button onClick={this.onExport} type="primary">导出</Button>,
                            <Sort
                                key='2'
                                columns={this.state.columnsMok}
                                dataSource={sortDataSource}
                                onChange={this.setDataSource}
                                mustShows={['appealStatus', 'effectiveStatus', 'proveStatus', 'verifiedParty', 'salerName', 'buyerName']}
                            >
                                <Button icon={<SettingOutlined />} />
                            </Sort>
                            // <Button disabled={selectedRowKeys.length === 0 ? true : false} key='0' type="primary" onClick={() => { this.onAccept(this.state.selectedRowKeys); }}>批量同意</Button>,
                            // <Button disabled={selectedRowKeys.length === 0 ? true : false} key='1' type="primary" onClick={this.onDeny}>批量拒绝</Button>,
                        ]}
                        onRefresh={this.onRefresh}
                    >

                    </PageHeaderFoot>
                </div>
                <AutoTableContainer style={{ flex: 1, padding: '0 20px', background: '#F4F4F4' }} >
                    <TableManual
                        id="masterresponse"
                        className='fixheight'
                        bordered={true}
                        dataSource={dataSource}
                        columns={[...columns, ...this.columnAction] as any}
                        rowSelection={rowSelection}
                        scroll={{ y: 'max-content' }}
                        pagination={false}
                        rowKey='id'
                    />
                </AutoTableContainer>
                {pageMeta && <Pagination onChange={this.onPageChange} showTotal={(total, range) => `第 ${range[0]}-${range[1]} 条,  共有 ${total} 条`} style={{ padding: '16px 0', flex: 'none', background: 'white', textAlign: 'center' }} total={pageMeta.total} pageSize={pageMeta.pageSize} current={pageMeta.pageNum} showSizeChanger={true} />}
                {
                    this.state.historyModal && <HistoryModal id={this.state.viewID} onClose={this.closeHistoryModal} />
                }
                {
                    this.state.denyModal && <DenyModal list={this.state.processList} onClose={this.closeModal} onSuccess={this.onSuccess} />
                }
            </div>
        );
    }
}
export default withRouter(UIComponents as any)