<style lang="scss" scoped>
.search-bar {
    display: flex;
    align-items: center;
}
.search-box p {
    display: inline-block;
    border: 1px solid #f2f2f2;
    border-radius: 5px;
    margin-right: 10px;
    padding: 5px 10px;
    cursor: pointer;
}
</style>
<style scoped>
.showNumBox {
    margin: 10px 0;
}
.showNumBox .ant-card-body {
    display: flex;
    justify-content: center;
}
.showNumBox p,
.showNumBox span {
    text-align: center;
    line-height: 40px;
    font-size: 30px;
    font-weight: 600;
    color: red;
    margin: 0;
}
.search-box .ant-card-body {
    padding: 5px 15px;
}
.showNumBox .ant-card-body .styleElse {
    line-height: 60px;
    height: 40px;
    font-size: 16px;
    font-weight: 400;
    margin-left: 10px;
}
.ant-modal-wrap .yincang .ant-modal-content .ant-modal-footer {
    display: none !important;
}
.yincang .ant-col-6 p {
    text-align: left;
    color: red;
    font-size: 16px;
    font-weight: 500;
}
.ant-table-thead div {
    font-weight: 700;
}
.tool-tip {
    position: absolute;
    top: 65px;
    right: 10px;
}
</style>
<style lang="less" scoped>
.ant-card-head .ant-tabs-bar {
    padding: 0;
}
.search-box .ant-card-body {
    padding: 5px 15px;
}
.search-box {
    padding: 15px 10px;
}
.search-box p {
    display: inline-block;
    border: 1px solid #f2f2f2;
    border-radius: 5px;
    margin-right: 10px;
    padding: 5px 10px;
    cursor: pointer;
}
.statistics .ant-col-6 .ant-card-body .styleElse {
    line-height: 60px;
    height: 40px;
    font-size: 16px;
    font-weight: 400;
    margin-left: 10px;
}
.ant-modal-wrap .yincang .ant-modal-content .ant-modal-footer {
    display: none !important;
}
.yincang .ant-col-6 p {
    text-align: left;
    color: red;
    font-size: 16px;
    font-weight: 500;
}
.ant-table-thead div {
    font-weight: 700;
}
.tool-tip {
    position: absolute;
    top: 65px;
    right: 10px;
}
.statistics {
    .ant-card-bordered {
        border: none;
    }
    .ant-card-head .ant-tabs {
        clear: both;
        margin-bottom: -13px;
        color: rgba(0, 0, 0, 0.65);
        font-weight: normal;
        font-size: 14px;
    }
    .duibi {
        position: absolute;
        right: 24px;
        top: 15px;
    }
    p {
        margin-bottom: 0;
    }
}
</style>

<style lang="less" scoped>
.middle-button {
    margin: 0 10px;
}
.newPlanStatic {
    .divider {
        height: 62px;
    }
    .showNumBox {
        background: white;
        overflow: hidden;
        margin: 15px 0;
        padding: 30px 0;
        text-align: center;
        .ant-card-body {
            padding-top: 0;
        }
        .title {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #999999;
            line-height: 22px;
            display: inline-block;
        }
    }
    .tabbody {
        background: white;
        padding: 0 24px;
        margin-bottom: 15px;
        .ant-tabs-bar {
            margin: 0;
        }
    }
    .chartBox {
        background: white;
        padding: 20px 0;
    }
    .tableBody {
        background: white;
        padding: 20px;
    }
}
</style>
<template>
    <div class="newPlanStatic config-project">
        <div class="tabbody">
            <a-tabs v-model="tabKey" @change="tabChange">
                <a-tab-pane :key="1" tab="清理模板列表"> </a-tab-pane>
                <a-tab-pane :key="2" tab="我的清理模板"> </a-tab-pane>
                <!-- <a-button slot="tabBarExtraContent" type="primary" @click="getHistroy(null)">
                    历史记录查询
                </a-button> -->
            </a-tabs>
        </div>
        <a-card>
            <div class="table-page-search-wrapper">
                <a-form layout="inline" :form="form" hide-required-mark :selfUpdate="true" @submit="handleQueryList">
                    <a-row :gutter="24" v-if="tabKey === 1">
                        <a-col :md="8" :sm="8" :xxl="6">
                            <a-form-item label="模板名称">
                                <a-input
                                    v-decorator="['templateName']"
                                    type="text"
                                    placeholder="请输入需要搜索的模板名称"
                                />
                            </a-form-item>
                            <!-- <selectTable :projectId.sync="projectIdAll" ref="selectTable"></selectTable> -->
                        </a-col>

                        <a-col :md="8" :sm="8" :xxl="6">
                            <a-form-item label="创建人">
                                <a-input
                                    v-decorator="['createUser']"
                                    type="text"
                                    placeholder="请输入创建模板的账号归属人名字"
                                />
                            </a-form-item>
                        </a-col>
                        <a-col :md="8" :sm="8" :xxl="6">
                            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                                <a-button type="primary" icon="search" @click="handleQueryList">查询</a-button>
                                <a-button type="primary" @click="handleResetForm" icon="reload" class="middle-button"
                                    >重置</a-button
                                >
                                <a-button type="primary" @click="newCreat(null)">
                                    新建清理模板
                                </a-button>
                            </span>
                        </a-col>
                    </a-row>
                    <a-row :gutter="24" v-else>
                        <a-col :md="8" :sm="8" :xxl="6">
                            <a-form-item label="账户名称">
                                <Treeselect
                                    :appId.sync="accountId"
                                    :multiple="false"
                                    request="2,4"
                                    ref="treeSelect"
                                    style="width:100%"
                                />
                            </a-form-item>
                        </a-col>
                        <a-col :md="8" :sm="8" :xxl="6">
                            <a-form-item label="绑定人">
                                <a-input v-decorator="['userName']" type="text" placeholder="请输入绑定的运营名称" />
                            </a-form-item>
                        </a-col>

                        <a-col :md="8" :sm="8" :xxl="6">
                            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                                <a-button type="primary" icon="search" @click="handleQueryList">查询</a-button>
                                <a-button type="primary" @click="handleResetForm" icon="reload" class="middle-button"
                                    >重置</a-button
                                >
                            </span>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
        </a-card>

        <a-row style="margin-bottom:15px;margin-top:12px">
            <a-col :span="24">
                <div class="tableBody" style="min-height:200px;padding-bottom: 50px">
                    <a-table
                        :columns="columns"
                        :dataSource="dataSource"
                        :pagination="false"
                        :loading="dataLoading"
                        bordered
                        @change="tableChange"
                        size="middle"
                        style="word-break: break-all;font-size:16px;font-weight:600"
                        id="outTable"
                        ref="accountTable"
                    >
                        <span slot="action" slot-scope="text, record">
                            <a @click="newCreat(record.id, 'preview')">预览</a>
                            <a-divider type="vertical" />
                            <a @click="matchingAccount(record)">推送</a>
                            <a-divider type="vertical" />
                            <a @click="newCreat(record.id, 'edit')">编辑</a>
                        </span>
                        <span slot="actionTwo" slot-scope="text, record">
                            <a @click="removeTemplate(record)">删除清理模板</a>
                            <a-divider type="vertical" />
                            <a @click="getHistroy(record)">历史记录查询</a>
                        </span>
                        <span slot="status" slot-scope="text, record">
                            <a-switch
                                :checked="text == '0'"
                                @change="onChangeStatus(text, record, 'status')"
                                :loading="spinning"
                                v-if="record.projectName !== '-'"
                            />
                        </span>
                    </a-table>
                    <a-pagination
                        size="small"
                        :showTotal="ipagination.showTotal"
                        style="float: right;margin-top:10px"
                        v-if="dataSource.length > 0"
                        showQuickJumper
                        :pageSize.sync="ipagination.pageSize"
                        :total="ipagination.total"
                        v-model="ipagination.current"
                        @change="getDataSource"
                    />
                </div>
            </a-col>
        </a-row>

        <a-modal
            title="推送账户选择"
            :width="800"
            v-if="accountVisible"
            :visible="accountVisible"
            @cancel="
                accountVisible = false
                accountIdPush = ''
            "
            dialog-class="push-modal"
            @ok="handleOkPrice"
            :confirm-loading="modifyPriceLoading"
        >
            <div v-if="accountProjectDetail" style="display:flex">
                <span>请选择账户：</span>
                <Treeselect
                    :appId.sync="accountIdPush"
                    :multiple="false"
                    request="2,4"
                    ref="treeSelect"
                    style="width:80%;position: relative;top: -5px;"
                />
            </div>
        </a-modal>
        <a-modal
            title="推送组清理记录"
            :width="800"
            v-if="unitVisible"
            :visible="unitVisible"
            @cancel="unitVisible = false"
            dialog-class="push-modal"
            :footer="null"
        >
            <a-table
                :columns="historyColumns"
                :dataSource="historyList"
                :pagination="ipaginationHistory"
                bordered
                size="middle"
                style="word-break: break-all;font-size:16px;font-weight:600"
            >
                <span slot="authStatus" slot-scope="text">
                    {{ text === 0 ? '失败' : '成功' }}
                </span>
            </a-table>
        </a-modal>
    </div>
</template>

<script>
import ARow from 'ant-design-vue/es/grid/Row'
import ACol from 'ant-design-vue/es/grid/Col'
import moment from 'moment'
import selectTable from '@/views/modules/Statistics/components/selectPagination.vue'
import { getKsAccountReport, getKsDetail, getReportList } from '@api/video.js'
import { getAction, postAction, downFile, downFilePost } from '@/api/manage'
import { mapGetters } from 'vuex'
import Treeselect from '@/views/modules/Statistics/components/Treeselect.vue'
import qs from 'qs'

let TTcolumns = [
    {
        title: '开关',
        dataIndex: 'status',
        scopedSlots: { customRender: 'status' },
        align: 'center',
        key: 'status'
    },
    {
        title: '模板id',
        dataIndex: 'id',
        scopedSlots: { customRender: 'id' },
        align: 'center',
        key: 'id'
    },
    {
        title: '模板名称',
        dataIndex: 'templateName',
        scopedSlots: { customRender: 'templateName' },
        align: 'center',
        key: 'templateName'
    },
    {
        title: '应用媒体',
        dataIndex: 'appliedMedia',
        scopedSlots: { customRender: 'appliedMedia' },
        align: 'center',
        key: 'appliedMedia'
    },

    {
        title: '创建人',
        dataIndex: 'createUser',
        scopedSlots: { customRender: 'createUser' },
        align: 'center',
        key: 'createUser'
    },
    {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        key: 'action'
    }
]

let KScolumns = [
    {
        title: '模板id',
        dataIndex: 'id',
        scopedSlots: { customRender: 'id' },
        align: 'center',
        key: 'id'
    },
    {
        title: '模板名称',
        dataIndex: 'templateName',
        scopedSlots: { customRender: 'templateName' },
        align: 'center',
        key: 'templateName'
    },

    {
        title: '应用媒体',
        dataIndex: 'appliedMedia',
        scopedSlots: { customRender: 'appliedMedia' },
        align: 'center',
        key: 'appliedMedia'
    },
    {
        title: '账户名称',
        dataIndex: 'accountName',
        scopedSlots: { customRender: 'accountName' },
        align: 'center',
        key: 'accountName'
    },
    {
        title: '账户ID',
        dataIndex: 'accountId',
        scopedSlots: { customRender: 'accountId' },
        align: 'center',
        key: 'accountId'
    },
    {
        title: '账户状态',
        dataIndex: 'accountStatus',
        customRender(t) {
            if (t == 0) {
                return '启用'
            } else {
                return '停用'
            }
        },
        align: 'center',
        key: 'accountStatus'
    },
    {
        title: '运营名称',
        dataIndex: 'userName',
        scopedSlots: { customRender: 'userName' },
        align: 'center',
        key: 'userName'
    },
    {
        title: '操作',
        dataIndex: 'actionTwo',
        scopedSlots: { customRender: 'actionTwo' },
        align: 'center',
        key: 'actionTwo'
    }
]

export default {
    components: {
        ACol,
        ARow,
        selectTable,
        Treeselect
    },

    data() {
        return {
            indexAll: 0,
            accountIdPush: '',
            spinning: false,
            form: this.$form.createForm(this),
            priceForm: this.$form.createForm(this),
            exportloading: false,
            accountId: null,
            noImg: require('@/assets/noImg.png'),
            ipagination: {
                current: 1,
                pageSize: 10,
                //   pageSizeOptions: ['10', '20', '30'],
                showTotal: (total, range) => {
                    return range[0] + '-' + range[1] + ' 共' + total + '条'
                },
                showQuickJumper: true,
                showSizeChanger: true,
                pageSizeOptions: ['10', '30', '50'],
                total: 0,
                onChange: (current, pageSize) => {
                    // 切换分页时的回调，
                    // 当在页面定义change事件时，切记要把此处的事件清除，因为这两个事件重叠了，可能到时候会导致一些莫名的bug
                    this.ipagination.current = current
                    this.ipagination.pageSize = pageSize
                }
            },
            ipaginationHistory: {
                current: 1,
                pageSize: 10,
                //   pageSizeOptions: ['10', '20', '30'],
                showTotal: (total, range) => {
                    return range[0] + '-' + range[1] + ' 共' + total + '条'
                },
                showQuickJumper: true,
                showSizeChanger: true,
                pageSizeOptions: ['10', '30', '50'],
                total: 0,
                onChange: (current, pageSize) => {
                    // 切换分页时的回调，
                    // 当在页面定义change事件时，切记要把此处的事件清除，因为这两个事件重叠了，可能到时候会导致一些莫名的bug
                    this.ipaginationHistory.current = current
                    this.ipaginationHistory.pageSize = pageSize
                    this.getHistroy({ userId: this.userName, id: this.accountIdSearch })
                }
            },
            historyColumns: [
                {
                    title: '账户id',
                    dataIndex: 'accountId',
                    scopedSlots: { customRender: 'accountId' },
                    align: 'center',
                    key: 'accountId'
                },
                {
                    title: '运营名称',
                    dataIndex: 'userName',
                    scopedSlots: { customRender: 'userName' },
                    align: 'center',
                    key: 'userName'
                },
                {
                    title: '操作类型',
                    dataIndex: 'operationType',
                    customRender(t) {
                        if (t == '3') {
                            return '删除'
                        } else if (t == '2'){
                            return '暂停'
                        }
                    },
                    align: 'center',
                    key: 'operationType'
                },

                {
                    title: '操作时间',
                    dataIndex: 'createTime',
                    scopedSlots: { customRender: 'createTime' },
                    align: 'center',
                    key: 'createTime'
                },
                {
                    title: '执行信息',
                    dataIndex: 'executiveInformation',
                    scopedSlots: { customRender: 'executiveInformation' },
                    align: 'center',
                    key: 'executiveInformation'
                }
            ],
            value: 'valid',

            operateDisabled: false,
            duration: 1000,
            //treeselect的参数
            treeValue: [],
            treeData: [],

            type: 3,

            operate: '',

            tabKey: 1,

            loading: false,
            TTcolumns,
            KScolumns,
            columns: [...TTcolumns],
            dataSource: [],

            tableTab: 1,

            newPlan: 0,
            effectPlan: 0,

            openOptions: false,

            dataLoading: false,
            url: '/accountClean/getTemplateList',
            modifyPriceVisible: false,
            modifyPriceLoading: false,
            modifyPriceDetail: null,
            accountVisible: false,
            againLoading: false,
            accountProjectDetail: null,
            userName: null,
            accountIdSearch: null,
            historyList: [],
            unitVisible: false
        }
    },
    methods: {
        moment,
        ...mapGetters(['userInfo']),
        getHistroy(item) {
            this.unitVisible = true
            this.userName = item.userId
            this.accountIdSearch = item.id
            let params = {}
            params.userId = this.userInfo().id
            params.templateId = item.id
            params.pageNum = this.ipaginationHistory.current
            params.pageSize = this.ipaginationHistory.pageSize

            this.getAction('/accountClean/getCleanUpLog', params).then(res => {
                if (res.success) {
                    this.historyList = res.result.list
                    this.ipaginationHistory.total = res.result.total
                }
            })
        },
        removeTemplate(item) {
            let that = this
            this.$confirm({
                title: '删除提示',
                content: '当前删除会解除此账户绑定模板，确定删除吗？',
                onOk() {
                    getAction('/accountClean/removeBinding', { templateId: item.id, accountId: item.accountId })
                        .then(result => {
                            if (result.success) {
                                const paramsData = that.form.getFieldsValue()
                                that.handleGetTableList(paramsData)

                                that.$message.success('删除成功')
                            } else {
                                that.$message.error(result.message)
                            }
                        })
                        .catch(error => {
                            console.log(error, 'eeee')
                        })
                }
            })
        },
        newCreat(id, type) {
            if (id) {
                if (type == 'edit') {
                    this.$router.push({
                        path: '/earlyWarningRules/createClear?id=' + id
                    })
                } else {
                    this.$router.push({
                        path: '/earlyWarningRules/createClear?preview=true&&id=' + id
                    })
                }
            } else {
                // window.open('/creat-material-test', '_blank')
                this.$router.push({
                    path: '/earlyWarningRules/createClear'
                })
            }
        },
        editPrice(item) {
            getAction('/kuaishouProjectStrategy/queryBidInfo', { id: item.id }).then(res => {
                if (res.success) {
                    this.modifyPriceVisible = true
                    this.modifyPriceDetail = { ...res.result, projectName: item.projectName, id: item.id }
                    console.log(this.modifyPriceDetail)
                    this.$nextTick(() => {
                        let cpaBid = ''
                        let changeBid = res.result.bidType === 2 ? res.result.bid : res.result.cpaBid
                        if ((changeBid + '').includes('/')) {
                            let bidArr = changeBid.split('/')
                            for (let index = 0; index < bidArr.length; index++) {
                                bidArr[index] = bidArr[index] / 1000
                            }
                            cpaBid = bidArr.join('/')
                        } else if ((changeBid + '').includes('-')) {
                            let bidArr = changeBid.split('-')
                            for (let index = 0; index < bidArr.length; index++) {
                                bidArr[index] = bidArr[index] / 1000
                            }
                            cpaBid = bidArr.join('-')
                        } else {
                            cpaBid = changeBid / 1000
                        }

                        let deepConversionBid = undefined
                        if (res.result.deepConversionBid && res.result.deepConversionBid != '') {
                            if ((res.result.deepConversionBid + '').includes('/')) {
                                let bidArr = res.result.deepConversionBid.split('/')
                                for (let index = 0; index < bidArr.length; index++) {
                                    bidArr[index] = bidArr[index] / 1000
                                }
                                deepConversionBid = bidArr.join('/')
                            } else if ((res.result.deepConversionBid + '').includes('-')) {
                                let bidArr = res.result.deepConversionBid.split('-')
                                for (let index = 0; index < bidArr.length; index++) {
                                    bidArr[index] = bidArr[index] / 1000
                                }
                                deepConversionBid = bidArr.join('-')
                            } else {
                                deepConversionBid = res.result.deepConversionBid / 1000
                            }
                        }

                        this.priceForm.setFieldsValue({
                            cpaBid: cpaBid,
                            deepConversionBid: deepConversionBid
                        })
                    })
                }
            })
        },
        handleOkPrice() {
            this.modifyPriceLoading = true
            let params = {}
            params.templateId = this.accountProjectDetail.id
            params.accountId = this.accountIdPush
            this.getAction('/accountClean/pushTemplate', params).then(res => {
                this.modifyPriceLoading = false
                if (res.success) {
                    this.accountVisible = false
                    this.accountIdPush = ''

                    if (res.message != '推送成功') {
                        this.$message.error(res.message)
                    } else {
                        this.$message.success(res.message)
                    }
                } else {
                }
            })
        },
        cpaBidValid(rule, value, callback) {
            let z = /-/g
            let a = /\//g
            let d = /\./g
            if (value === '' || value === undefined) {
                callback('出价必须填写')
            } else if (value.startsWith('.') || value.endsWith('.')) {
                callback('请填写正确出价')
            } else if (value.startsWith('-') || value.endsWith('-')) {
                callback('请填写正确出价')
            } else if (value.match(a) && value.match(z)) {
                callback('不允许出现除"-"和"/"之外的所有字符，并且二者不可同时出现')
            } else if (value.match(/[^0-9+-\/]/g)) {
                callback('请填写正确出价')
            } else {
                callback()
            }
        },
        btKeyUp(e) {
            //没有显示‘破折号’和 '.' 需要的可以手动加上
            // this.priceForm.setFieldsValue({
            //     cpaBid: e.target.value.replace(/[^0-9+-\/]/g, '')
            // })
            // (
            //         /[\u4e00-\u9fa5/\s+/]|[`~!@#$%^&*() \+ =<>?"{}|, \/ ;' \\ [ \] ·~！@#￥%……&*（）—— \+ ={}|《》？：“”【】、；‘’，。、]/g,
            //         ''
            //     )
        },
        getData(className) {
            return this.priceForm.getFieldValue(className)
        },
        matchingAccount(item) {
            this.accountVisible = true
            this.accountProjectDetail = { id: item.id }
        },
        getDataSource(current, pageSize) {
            // 切换分页时的回调，
            // 当在页面定义change事件时，切记要把此处的事件清除，因为这两个事件重叠了，可能到时候会导致一些莫名的bug
            this.ipagination.current = current
            this.ipagination.pageSize = pageSize
            const paramsData = this.form.getFieldsValue()
            this.handleGetTableList(paramsData)
        },
        onChangeStatus(text, record, type) {
            let status = text === '0' ? '1' : '0'
            let url = '/accountClean/updateTemplateStatus'
            let params = {}
            params.templateId = record.id
            params.status = status
            this.getAction(url, params).then(res => {
                if (res.success) {
                    const paramsData = this.form.getFieldsValue()
                    this.handleGetTableList(paramsData)
                } else {
                    this.$message.error(res.message)
                }
            })
        },
        handleQueryList(event) {
            this.ipagination.current = 1
            event.preventDefault()
            const paramsData = this.form.getFieldsValue()
            this.handleGetTableList(paramsData)
        },
        handleResetForm() {
            this.ipagination.current = 1
            this.form.resetFields()
            this.accountId = ''
            const paramsData = this.form.getFieldsValue()
            this.handleGetTableList(paramsData)
        },
        handleGetTableList(data) {
            let paramsData = {
                ...data,
                pageNum: this.ipagination.current,
                pageSize: this.ipagination.pageSize,
                userId: this.userInfo().id,
                accountId: this.accountId
            }
            this.dataSource = []
            this.dataLoading = true
            getAction(this.url, paramsData)
                .then(result => {
                    this.dataLoading = false
                    if (result.code === 200) {
                        this.dataSource = result.result.list || []

                        this.ipagination.total = result.result.total || 0
                    } else {
                        this.$message.error(result.message)
                    }
                })
                .catch(error => {
                    this.dataLoading = false
                    console.log(error, 'eeee')
                })
        },
        disabledDate(current) {
            // Can not select days before today and today
            return current && current > moment().endOf('day')
        },

        filterOption(input, option) {
            // console.log(input, option)
            return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        },

        // 快手头条的切换
        tabChange(key) {
            this.ipagination.current = 1
            this.columns = this.tabKey == 1 ? [...TTcolumns] : [...KScolumns]
            this.url = this.tabKey == 1 ? '/accountClean/getTemplateList' : '/accountClean/getMyselfTemplateList'
            this.target = this.tabKey == 1 ? 'createTime' : 'statDate'
            this.accountId = ''
            const paramsData = this.form.getFieldsValue()
            this.handleGetTableList(paramsData)
        },

        tableChange(pagination, filters, sorter, { currentDataSource }) {
            this.ipagination.current = pagination.current
            this.ipagination.pageSize = pagination.pageSize
            if (sorter.order) {
                this.order = sorter.order ? sorter.order : 'descend'
                this.target = sorter.columnKey
                const paramsData = this.form.getFieldsValue()
                this.handleGetTableList({
                    ...paramsData,
                    target: sorter.columnKey,
                    order: sorter.order ? sorter.order : 'descend'
                })
            }
        }
    },
    watch: {},
    computed: {
        newDate() {
            var myDate = new Date()
            myDate.getYear() //获取当前年份(2位)
            var n = myDate.getFullYear() //获取完整的年份(4位,1970-????)
            var m = myDate.getMonth() //获取当前月份(0-11,0代表1月)
            var d = myDate.getDate() //获取当前日(1-31)
            var day = myDate.getHours()
            return day
        }
    },
    mounted() {
        const paramsData = this.form.getFieldsValue()
        this.handleGetTableList(paramsData)
    },
    activated: function() {},

    filters: {
        toPercentage(val) {
            if (typeof val != 'string') {
                return (val * 100).toFixed(2) + '%'
            } else {
                return val
            }
        },
        //保留两位小数并且变成货币格式
        decimalsHandle(val) {
            if (val && typeof val != 'string') {
                if (val >= 0) {
                    val = parseFloat(val).toFixed(2)
                    let numberStr = val.toString()
                    let str = numberStr.split('.')

                    let str0 = str[0].split('').reverse()
                    for (let i = 0; i < str0.length; i++) {
                        if ((i + 1) % 4 === 0) {
                            str0.splice(i, 0, ',')
                        }
                    }
                    str0.reverse()
                    let handleResult = ''
                    for (let j = 0; j < str0.length; j++) {
                        handleResult += str0[j]
                    }

                    return handleResult + '.' + str[1]
                } else {
                    val = parseFloat(val).toFixed(2)
                    let numberStr = val.toString()
                    let str = numberStr.split('.')

                    let str0 = str[0]
                        .substr(1)
                        .split('')
                        .reverse()
                    for (let i = 0; i < str0.length; i++) {
                        if ((i + 1) % 4 === 0) {
                            str0.splice(i, 0, ',')
                        }
                    }
                    str0.reverse()
                    let handleResult = ''
                    for (let j = 0; j < str0.length; j++) {
                        handleResult += str0[j]
                    }

                    return '-' + handleResult + '.' + str[1]
                }
            } else if (typeof val == 'string') {
                return val
            } else {
                return 0
            }
        },
        //变成货币格式
        formatCurrency(val) {
            if (val) {
                let numberStr = val.toString()
                let str = numberStr.split('').reverse()
                for (let i = 0; i < str.length; i++) {
                    if ((i + 1) % 4 === 0) {
                        str.splice(i, 0, ',')
                    }
                }
                str.reverse()
                let handleResult = ''
                for (let j = 0; j < str.length; j++) {
                    handleResult += str[j]
                }
                return handleResult
            } else {
                return '-'
            }
        }
    }
}
</script>
