<template>
    <div>
        <el-button type="primary" size="small" style="margin-bottom: 10px" icon="el-icon-check" @click="examine">
            审核台账
        </el-button>
        <Timeinterval v-show="false" :interval="1" ref="Timeinterval"></Timeinterval>
        <div class="boxS">
            <div class="boxTableS">
                <el-table
                    stripe
                    :data="tableData"
                    v-loading="loading"
                    highlight-current-row
                    border
                    :height="vh - 46"
                    header-cell-class-name="table_header"
                    @selection-change="handleSelectionChange"
                >
                    <el-table-column type="selection" width="55"></el-table-column>
                    <el-table-column
                        prop="monitorName"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="监测点名称"
                    ></el-table-column>
                    <el-table-column
                        prop="monitorSort"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="监测点类别"
                        :formatter="formatter"
                    ></el-table-column>
                    <el-table-column
                        prop="status"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="监测点状态"
                    >
                        <template slot-scope="scope">
                            <span>
                                {{
                                    scope.row.status == 0
                                        ? '删除'
                                        : scope.row.status == 1
                                        ? '待审核'
                                        : scope.row.status == 2
                                        ? '已审核'
                                        : ''
                                }}
                            </span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        prop="createTime"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="提交时间"
                    ></el-table-column>
                    <el-table-column
                        prop="auditName"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="审核成员"
                    ></el-table-column>
                    <el-table-column
                        prop="auditContent"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="事件描述"
                    ></el-table-column>
                    <el-table-column
                        prop="terminalCount"
                        show-overflow-tooltip
                        min-width="120px"
                        align="center"
                        label="操作"
                    >
                        <template slot-scope="scope">
                            <el-button
                                :disabled="scope.row.status != 1"
                                type="primary"
                                icon="el-icon-check"
                                size="mini"
                                @click="examine(1, scope.row)"
                            >
                                审核
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</template>
<script>
import { dicData } from '@/assets/commjs/dictypeData'
import { getAllMonitorAuditList, updateStatus } from '@/api/Accountreview/index.js'
import Timeinterval from '@/views/components/Timeinterval.vue'
export default {
    components: { Timeinterval },
    props: {},
    data() {
        return {
            form: {
                type: 0,
                orgId: '',
                monitorTags: []
            },

            multipleSelection: [],
            interferenceSource: [], //干扰源类型
            loading: false,
            vh: 0,
            zoom: '', //图表焦点校验

            tableData: []
        }
    },
    created() {},
    mounted() {
        this.form.orgId = JSON.parse(window.sessionStorage.getItem('Info')).deptId
        this.zoom = 1 / document.body.style.zoom

        this.setHeight()
        window.addEventListener('resize', this.setHeight)

        this.interferenceSource = dicData('Monitoring_Labels', [])
        this.interferenceSource.forEach(item => {
            this.form.monitorTags.push(item.id)
        })
        this.info()
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
            this.zoom = 1 / document.body.style.zoom
            this.vh = window.sessionStorage.getItem('appheight') - 83
        },
        info() {
            this.loading = true
            let id = ''
            dicData('Data_Type', []).forEach(item => {
                if (item.code == 'Mainnet_Point') {
                    id = item.id
                }
            })
            getAllMonitorAuditList({
                dataType: id,
                searchBeginTime: this.$refs.Timeinterval.timeValue[0] + ' 00:00:00',
                searchEndTime: this.$refs.Timeinterval.timeValue[1] + ' 23:59:59',
                status: 0
            }).then(res => {
                this.tableData = res.data
                this.loading = false
            })
        },
        // 审核
        examine(flag, val) {
            let id = []
            if (flag == 1) {
                id = [val.id]
            } else {
                this.multipleSelection.forEach(item => {
                    id.push(item.id)
                })
            }
            updateStatus({
                id: id,
                status: 2
            }).then(res => {
                if (res.code === 'A0000') {
                    this.$message({
                        type: 'success',
                        message: '审核成功!'
                    })

                    this.info()
                }
            })
        },
        handleSelectionChange(val) {
            this.multipleSelection = val
        },
        // 字典处理
        formatter(row, column) {
            let title = ''
            dicData('Line_Sort', []).forEach(item => {
                if (item.id == row.monitorSort) {
                    title = item.name
                }
            })
            return title
        }
    },

    computed: {},

    watch: {}
}
</script>

<style lang="less" scoped>
// @import url("../../../../styles/comStyle.less");
</style>

<style lang="scss" scoped>
.boxS {
    width: 100%;
    // display: flex !important;

    // justify-content: space-between;
}
</style>
