<template>
    <div class="app-container">
        <el-tabs v-model="activeTab" @tab-click="changeTab">
            <el-tab-pane v-for="item in tabList" :key="item.key" :name="item.key">
                <span slot="label"><i :class="item.icon" /> {{ item.label }}</span>
                <div v-if="item.key!=='gr'&&item.key!=='zt'" class="tab-container">
                    <div slot="west" class="kind">
                        <ibps-type-tree
                            :width="width"
                            :height="height"
                            title=""
                            category-key="FLOW_TYPE"
                            :has-permission="true"
                            @node-click="handleNodeClick"
                            @expand-collapse="handleExpandCollapse"
                        />
                    </div>
                    <div class="table-container">
                        <div class="search-container">
                            <div class="search-box">
                                <span class="label">事务名称</span>
                                <el-input
                                    v-model="searchParams.subject"
                                    class="input"
                                    placeholder="请输入内容"
                                    clearable
                                    @keyup.enter.native="search"
                                />
                            </div>
                            <div class="search-box">
                                <span class="label">{{ item.time }}时间</span>
                                <el-date-picker
                                    v-model="searchParams.createTime"
                                    type="daterange"
                                    class="input"
                                    start-placeholder="请选择"
                                    end-placeholder="请选择"
                                    size="mini"
                                    clearable
                                    @keyup.enter.native="search"
                                />
                            </div>
                            <el-button class="btn" type="primary" @click="search">
                                <i class="ibps-icon-search" />查询
                            </el-button>
                            <el-button v-if="activeTab === 'save'" :key="Date.now() + Math.random()" class="btn" type="danger" @click="remove">
                                <i class="ibps-icon-close" />删除
                            </el-button>
                        </div>
                        <el-table
                            ref="dataTable"
                            v-loading="loading"
                            :data="dataList"
                            style="color: #000"
                            align="center"
                            size="mini"
                            border
                            class="jbd-home-task"
                            :row-class-name="tableRowClassName"
                            @row-click="handleLinkClick"
                            @selection-change="val => selection = val"
                        >
                            <el-table-column v-if="activeTab === 'save'" :key="Date.now() + Math.random()" type="selection" width="55" />
                            <el-table-column
                                prop="subject"
                                label="事务名称"
                                width="250"
                                show-overflow-tooltip
                            >
                                <template slot-scope="scope">{{ scope.row.subject | getWorkInfo('name') }}</template>
                            </el-table-column>
                            <el-table-column label="事务说明" show-overflow-tooltip>
                                <template slot-scope="scope">{{ scope.row.subject | getWorkInfo('desc') }}</template>
                            </el-table-column>
                            <template v-if="['wait'].includes(activeTab)">
                                <el-table-column
                                    show-overflow-tooltip
                                    width="120"
                                    label="事务状态"
                                >
                                    <template slot-scope="scope">{{ '待' + scope.row.name }}</template>
                                </el-table-column>
                                <el-table-column show-overflow-tooltip width="100">
                                    <template slot="header" slot-scope="scope">
                                        <span>办理进度</span>
                                        <el-tooltip effect="dark" placement="top">
                                            <div slot="content">
                                                1、检验能力范围调整，区分常规、加急、特急情况下的检验时限，以及对应的即将超时时限。检测项目依据项目是否加急及其对应的检验时限判定超时状态，检测报告的超时状态根据报告中检测时限最长的项目判定。
                                                <br>
                                                2、周期性推送事务:每周推送的事务在每周四状态变更为即将超时，次周的周一变更为超时;每月推送的事务在每月20日变更为即将超时，次月1日变更为已超时。
                                                <br>
                                                3、不符合项(含内审)、改进项增加对应的改进截止时间，用于判断是否超时以及即将超时。具体规则为截止日期前7天内状态变更为即将超时，截止日期后变更为已超时。
                                                <br>
                                                4、内审计划以及部分计划(仪器设备的检定、校准计划以及期间核查计划)的推送时间调整，在计划日期前两个月推在计划月的20日变更为即将超时，次月一日变更为已超内审检查表在内市首次会议前3天内状态变更为即将超，首次会议当天状态变更为已超时。
                                                <br>
                                                5、管理评审汇报材料:管理评审的评审时间前7天内变更为即将超时，会议前1天内变更为已超时;管理评审报告编制:管理评审会议纪要提交后7天，状态变更为即将超时，会议纪要提交10天后变更为已超时
                                                <br>
                                                6、岗前培训计划时间前三天变更为即将超时，超过计划培训时间后变更为已超时。
                                                <br>
                                                7、所有超时状态按具体时间计算，不在以上规则内的事务不做超时判走，办理状态固定为待处理。
                                            </div>
                                            <i class="el-icon-info" />
                                        </el-tooltip>
                                    </template>
                                    <template slot-scope="scope">
                                        <el-tag :type="scope.row.state ? stateOption[scope.row.state].type : ''">{{ scope.row.state ? stateOption[scope.row.state].label : '待办理' }}</el-tag>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="startDept"
                                    show-overflow-tooltip
                                    width="120"
                                    label="发起部门"
                                />
                                <el-table-column
                                    :key="Date.now() + Math.random()"
                                    prop="submitBy"
                                    show-overflow-tooltip
                                    width="100"
                                >
                                    <template slot="header" slot-scope="scope">
                                        <span>发起人</span>
                                        <el-tooltip effect="dark" placement="top">
                                            <div slot="content">
                                                该事务对应流程的发起人
                                            </div>
                                            <i class="el-icon-info" />
                                        </el-tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    :key="Date.now() + Math.random()"
                                    prop="forwardBy"
                                    show-overflow-tooltip
                                    width="100"
                                >
                                    <template slot="header" slot-scope="scope">
                                        <span>上节点</span><br>
                                        <span>提交人</span>
                                        <el-tooltip effect="dark" placement="top">
                                            <div slot="content">
                                                该事务对应流程上一节点的提交人
                                            </div>
                                            <i class="el-icon-info" />
                                        </el-tooltip>
                                    </template>
                                </el-table-column>
                            </template>
                            <template v-else-if="['over', 'finish'].includes(activeTab)">
                                <el-table-column
                                    show-overflow-tooltip
                                    label="事务状态"
                                    width="100"
                                >
                                    <template slot-scope="scope">{{ scope.row.curNode ? scope.row.status == 'running' ? '已发起' : '已' + scope.row.curNode : contOfValue(scope.row.status) }}</template>
                                </el-table-column>
                                <el-table-column
                                    show-overflow-tooltip
                                    label="发起部门"
                                    width="100"
                                >
                                    <template slot-scope="scope">{{ getParenthesesStr(scope.row.subject)[1] }}</template>
                                </el-table-column>
                                <el-table-column
                                    show-overflow-tooltip
                                    label="发起人"
                                    width="100"
                                >
                                    <template slot-scope="scope">{{ scope.row.createBy | getUserName(userList) }}</template>
                                </el-table-column>
                                <el-table-column
                                    show-overflow-tooltip
                                    label="提交人"
                                    width="100"
                                >
                                    <template slot-scope="scope">{{ getName(scope.row) }}</template>
                                </el-table-column>
                            </template>
                            <el-table-column :key="Date.now() + Math.random()" show-overflow-tooltip width="160">
                                <template slot="header" slot-scope="scope">
                                    <template v-if="['wait'].includes(activeTab)">
                                        <span>上节点</span><br>
                                    </template>
                                    <span>{{ item.time + '时间' }}</span>
                                </template>
                                <template slot-scope="scope">{{ scope.row[item.field] ? scope.row[item.field].slice(0, 16) : scope.row.createTime.slice(0, 16) }}</template>
                            </el-table-column>
                        </el-table>
                        <div v-if="dataList.length">
                            <el-pagination
                                :current-page.sync="paginate.page"
                                :page-size="paginate.limit"
                                layout="total, prev, pager, next"
                                :total="paginate.totalCount"
                                @current-change="changePage"
                            />
                        </div>
                    </div>
                </div>
                <div v-if="item.key==='gr'">
                    <el-card class="ibps-desktop-dashboard">
                        <el-row ref="row" :gutter="12">
                            <template v-if="grdata && grdata.length >0">
                                <el-col v-for="item in grdata" :key="item.id" :span="24" :sm="12" :md="6" :lg="6" :xl="6">
                                    <div :class="'bg-'+item.color" class="item">
                                        <div class="item-header">
                                            <h3>{{ item.dataContent }}</h3>
                                        </div>
                                        <div class="item-body">
                                            <h2><count-to :end-val="parseInt(item.dataText,10)" :duration="4000" /></h2>
                                        </div>
                                        <p class="item-tip">{{ item.dataContent[0] }}</p>
                                    </div>
                                </el-col>
                            </template>
                            <template v-else>
                                <el-col v-for="(item,i) in 8" :key="i" :span="24" :sm="12" :md="6" :lg="6" :xl="6">
                                    <div class="item bg-grey-steel">
                                        <div class="item-header">&nbsp;</div>
                                        <div class="item-body">
                                            <h2>&nbsp;</h2>
                                        </div>
                                        <p class="item-tip">&nbsp;</p>
                                    </div>
                                </el-col>
                            </template>
                        </el-row>
                    </el-card>
                </div>
                <div v-if="item.key==='zt'">
                    <el-row ref="row" :gutter="12">

                        <el-col :span="12">
                            <div>检测任务统计</div>
                            <div id="a1" style="height:500px;" />
                        </el-col>
                        <el-col :span="12">
                            <div>任务事宜统计</div>
                            <div id="a2" style="height:500px;" />
                        </el-col>
                    </el-row>
                </div>
            </el-tab-pane>
        </el-tabs>
        <bpmn-formrender
            :visible="dialogFormVisible"
            :task-id="activeTab === 'wait' ? taskId : null"
            :wai-jian="activeTab === 'wait' ? waiJian : null"
            :instance-id="['over', 'finish'].includes(activeTab) ? instanceId : null"
            :def-id="activeTab === 'save' ? defId : null"
            :pro-inst-id="activeTab === 'save' ? proInstId : null"
            :title="['wait', 'save'].includes(activeTab) ? FlowName : null"
            :process-name="processName"
            @callback="loadData"
            @close="visible => (dialogFormVisible = visible)"
        />
    </div>
</template>

<script>
import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
import homeCalendar from './home-calendar'
import { pending, handledTask } from '@/api/platform/office/bpmReceived'
import { myDraft, removeDraft } from '@/api/platform/office/bpmInitiated'
import { queryOrgManager } from '@/api/platform/org/employee'
import { save } from '@/api/platform/message/innerMessage'
import BpmnFormrender from '@/business/platform/bpmn/form/dialog'
import ActionUtils from '@/utils/action'
import IbpsTypeTree from '@/business/platform/cat/type/tree'
import { dateFormat } from '@/filters'
import * as echarts from 'echarts'

const tabList = [
    {
        label: '待办事宜',
        key: 'wait',
        icon: 'el-icon-edit',
        time: '提交',
        field: 'createTime'
    },
    {
        label: '已办事宜',
        key: 'over',
        icon: 'el-icon-document-remove',
        time: '创建',
        field: 'updateTime'
    },
    {
        label: '办结事宜',
        key: 'finish',
        icon: 'el-icon-paperclip',
        time: '结束',
        field: 'updateTime'
    },
    {
        label: '暂存事宜',
        key: 'save',
        icon: 'el-icon-receiving',
        time: '暂存',
        field: 'createTime'
    },
    {
        label: '个人任务统计',
        key: 'gr',
        icon: 'el-icon-receiving',
        time: '个人任务',
        field: 'createTime'
    },
    {
        label: '总体任务统计',
        key: 'zt',
        icon: 'el-icon-receiving',
        time: '总体任务',
        field: 'createTime'
    }
]
const taskState = {
    running: '已发起',
    end: '已结束',
    manualend: '人工结束'
}
const paramsType = {
    wait: 'temp.',
    over: '',
    finish: 'inst.',
    save: ''
}
const stateOption = {
    wait: {
        label: '待办理',
        type: ''
    },
    soon: {
        label: '即将超时',
        type: 'warning'
    },
    overtime: {
        label: '已超时',
        type: 'danger'
    }
}
const operate = {
    wait: pending,
    over: handledTask,
    finish: handledTask,
    save: myDraft
}
const grdata = [
    {
        dataContent: '待办事宜',
        url: '',
        color: 'blue',
        dataText: '0'
    },
    {
        dataContent: '已办事宜',
        url: '',
        color: 'green',
        dataText: '0'
    },
    {
        dataContent: '办结事宜',
        url: '',
        color: 'green-meadow',
        dataText: '0'
    },
    {
        dataContent: '暂存事宜',
        url: '',
        color: 'blue',
        dataText: '0'
    }
]
export default {
    name: 'calendar',
    components: { BpmnFormrender, homeCalendar, IbpsTypeTree },
    filters: {
        getWorkInfo (v, type) {
            const hasDesc = v.includes('#')
            const res = {
                name: {
                    '0': v.includes('{') ? v.split('{')[0] : v.includes('(') ? v.split('(')[0] : v,
                    '1': v.split('#')[0]
                },
                // 无#返回空，有#返回(左边的字符串,
                desc: {
                    '0': '',
                    '1': v.split('#')[1]
                }
            }
            if (!hasDesc) {
                return res[type]['0']
            }
            return res[type]['1']
        },
        getUserName (v, list) {
            const user = list.find(i => i.userId === v)
            return user ? user.userName : ''
        }
    },
    props: {
        plan: {
            type: Array,
            default: () => []
        }
    },
    data () {
        return {
            option: {
                title: {
                    text: ''
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    show: true

                },
                xAxis: {
                    type: 'category',
                    name: '检测人员',
                    data: []

                },
                yAxis: {
                    type: 'value',
                    name: '任务数量'

                },
                series: [
                    {
                        name: '检测未完成数',
                        type: 'bar',
                        data: [],
                        // barCategoryGap: '0',
                        barGap: '0',
                        barWidth: 30,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#ee6666']
                            }
                        }
                    },
                    {
                        name: '检测已完成数',
                        type: 'bar',
                        data: [],
                        // barCategoryGap: '0',
                        barGap: '0',
                        barWidth: 30,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#91cc75']
                            }
                        }
                    },
                    {
                        name: '复核未完成数',
                        type: 'bar',
                        data: [],
                        // barCategoryGap: '0',
                        barGap: '0',
                        barWidth: 30,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#fac858']
                            }
                        }
                    },
                    {
                        name: '复核已完成数',
                        type: 'bar',
                        data: [],
                        // barCategoryGap: '0',
                        barGap: '0',
                        barWidth: 30,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#5470c6']
                            }
                        }
                    }
                ]
            },
            optionPerson: {
                title: {
                    text: ''
                },

                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    show: true
                },

                xAxis: {
                    type: 'category',
                    name: '人员',
                    data: []

                },
                yAxis: {
                    type: 'value',
                    name: '任务数量'

                },
                series: [
                    {
                        name: '待办事宜数',
                        type: 'bar',
                        data: [],
                        barGap: '0',
                        barWidth: 20,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#3598dc']
                            }
                        }
                    },
                    {
                        name: '已办事宜数',
                        type: 'bar',
                        data: [],
                        barGap: '0',
                        barWidth: 20,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#32c5d2']
                            }
                        }
                    },
                    {
                        name: '办结事宜',
                        type: 'bar',
                        data: [],
                        barGap: '0',
                        barWidth: 20,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#1bbc9b']
                            }
                        }
                    },
                    {
                        name: '暂存事宜',
                        type: 'bar',
                        data: [],
                        barGap: '0',
                        barWidth: 20,
                        label: {
                            show: true,
                            position: 'top',
                            valueAnimation: true
                        },
                        itemStyle: {
                            normal: {
                                color: ['#3598dc']
                            }
                        }
                    }
                ]
            },
            grdata,
            tabList,
            stateOption,
            dataList: [],
            paginate: {},
            searchParams: {
                typeId: '',
                subject: '',
                createTime: ''
            },
            selection: [],
            taskId: '', // 编辑dialog需要使用
            waiJian: '', // 编辑dialog需要使用
            instanceId: '',
            defId: '',
            proInstId: '',
            loading: false,
            drawer: false,
            dialogFormVisible: false,
            orgName: '',
            roleName: '',
            FlowName: '',
            posName: '',
            defaultPagination: { page: 1, limit: 15 },
            sorts: { CREATE_TIME_: 'DESC' },
            timer: null,
            processName: '',
            userList: [],
            orgInfo: {},
            activeTab: 'wait',
            width: 250,
            height: document.body.clientHeight - 130
        }
    },
    mounted: function () {
        this.loadData()
        this.getUserList()
        this.getOrgInfo()
        if (this.timer) {
            clearInterval(this.timer)
        }
        // 轮询刷新公告数据和任务数据
        this.timer = setInterval(() => {
            // 仅待办事宜自动更新数据
            if (this.activeTab === 'wait') {
                this.getData(this.activeTab)
            }
        }, 30 * 1000)
    },
    beforeDestroy () {
        clearInterval(this.timer)
    },
    // 路由离开时
    beforeRouteLeave (to, from, next) {
        clearInterval(this.timer)
    },
    methods: {
        // 图表数据加载
        async chartLoading () {
            // 获取所有检测人员任务统计
            const this_ = this
            const sql = `select  *FROM (SELECT ie.ID_ AS jcId,ie.NAME_ AS jcName,COUNT(tj.zhuang_tai_ = '待数据输入' OR NULL) AS jianCeWeiWanCheng,COUNT(tj.zhuang_tai_ = '待数据校验' OR tj.zhuang_tai_ = '已完成' OR NULL) AS jianCeYiWanCheng FROM 
                          t_lhjczb tj,ibps_party_employee ie 
                          WHERE  ie.status_ = 'actived' and ie.group_id_ LIKE '%1040707841519779840%' and tj.jian_ce_yuan_ = ie.ID_ GROUP BY jian_ce_yuan_ 
                          ) jc  LEFT JOIN 
                          (
                          SELECT ie.ID_ AS fhId,ie.NAME_ AS fhName,COUNT(tj.zhuang_tai_ = '待数据校验' OR NULL) AS fuHeWeiWanCheng,COUNT(tj.zhuang_tai_ = '已完成' OR NULL) AS fuHeYiWanCheng FROM 
                          t_lhjczb tj,ibps_party_employee ie 
                          WHERE ie.status_ = 'actived' and ie.group_id_ LIKE '%1040707841519779840%' and tj.fu_he_yuan_ = ie.ID_ GROUP BY fu_he_yuan_ 
                          ) fh ON jc.jcName = fh.fhName
                          UNION (
                          SELECT  *FROM (SELECT ie.ID_ AS jcId, ie.NAME_ AS jcName,COUNT(tj.zhuang_tai_ = '待数据输入' OR NULL) AS jianCeWeiWanCheng,COUNT(tj.zhuang_tai_ = '待数据校验' OR tj.zhuang_tai_ = '已完成' OR NULL) AS jianCeYiWanCheng FROM 
                          t_lhjczb tj,ibps_party_employee ie 
                          WHERE ie.status_ = 'actived' and tj.jian_ce_yuan_ = ie.ID_ GROUP BY jian_ce_yuan_ 
                          ) jc  RIGHT JOIN 
                          (
                          SELECT ie.ID_ AS fhId,ie.NAME_ AS fhName,COUNT(tj.zhuang_tai_ = '待数据校验' OR NULL) AS fuHeWeiWanCheng,COUNT(tj.zhuang_tai_ = '已完成' OR NULL) AS fuHeYiWanCheng FROM 
                          t_lhjczb tj,ibps_party_employee ie 
                          WHERE ie.status_ = 'actived' and ie.group_id_ LIKE '%1040707841519779840%' and tj.fu_he_yuan_ = ie.ID_ GROUP BY fu_he_yuan_ 
                          ) fh ON jc.jcName = fh.fhName
                          )`
            this.option.xAxis.data = []
            this.option.series[0].data = []
            this.option.series[1].data = []
            this.option.series[2].data = []
            this.option.series[3].data = []

            this.chartData = []
            let dataAll = []
            var dataAllName = ''
            await curdPost('sql', sql)
                .then((res) => {
                    const data = res.variables.data
                    dataAll = data
                    for (const i of data) {
                        dataAllName += i.jcName + i.fhName
                        this_.option.xAxis.data.push(i.jcName ? i.jcName : i.fhName)
                        // 检测未完成数
                        this_.option.series[0].data.push(
                            i.jianCeWeiWanCheng ? i.jianCeWeiWanCheng : 0
                        )
                        // 检测已完成数
                        this_.option.series[1].data.push(
                            i.jianCeYiWanCheng ? i.jianCeYiWanCheng : 0
                        )
                        // 复核未完成数
                        this_.option.series[2].data.push(
                            i.fuHeWeiWanCheng ? i.fuHeWeiWanCheng : 0
                        )
                        // 复核已完成数
                        this_.option.series[3].data.push(
                            i.fuHeYiWanCheng ? i.fuHeYiWanCheng : 0
                        )
                        this_.chartData.push(i)
                    }
                })
                .catch((error) => {
                    console.log(error)
                })
            // console.log(dataAllName, '12321')
            const len = this_.option.xAxis.data.length
            let wuData = []
            const sql1 = `select id_,name_ FROM ibps_party_employee WHERE  status_ = 'actived' AND group_id_ LIKE '%1040707841519779840%'`
            await curdPost('sql', sql1).then((res) => {
                wuData = res.variables.data
                if (wuData.length !== len) {
                    for (const item of wuData) {
                        if (!dataAllName.includes(item.name_)) {
                            this_.option.xAxis.data.push(item.name_)
                            this_.option.series[0].data.push(0)
                            this_.option.series[1].data.push(0)
                            this_.option.series[2].data.push(0)
                            this_.option.series[3].data.push(0)
                        }
                    }
                }
            })
        },

        async getTtaskMattersData () {
            const this_ = this

            this_.optionPerson.xAxis.data = []
            this_.optionPerson.series[0].data = []
            this_.optionPerson.series[1].data = []
            let create_by_ = ''
            let datary = []
            let data = []
            const csData = []
            let banjie = []
            let zhancun = []
            let yiban1 = []
            let personIds = ''
            // 待办
            const sqlry = `select a.id_,a.parent_id_,b.name_,a.zui_gao_xue_li_x_,a.zhi_cheng_deng_ji,b.jian_ding_zi_ge_z,a.ru_zhi_shi_jian_ from  t_ryjbqk as a join  ibps_party_employee as b on a.parent_id_= b.id_ where a.id_ !='861622496187645952' AND b.status_ = 'actived' and  b.GROUP_ID_ != ''`
            await curdPost('sql', sqlry).then((res) => {
                datary = res.variables.data
            })
            for (const item of datary) {
                create_by_ += create_by_ + ',' + item.id_
            }
            create_by_ = create_by_.slice(0, create_by_.length - 1)
            const sql = `select  executor_,count(executor_) as num ,c.name_ FROM  IBPS_BPM_TASKS as a join IBPS_BPM_TASK_ASSIGN as b  on a.task_id_ = b.task_id_ join ibps_party_employee as c on b.executor_ = c.id_ and  c.STATUS_= 'actived' and c.ID_ != '1' and c.ID_ != '-1' and c.ID_ != '702117247933480960' and c.GROUP_ID_ not like '%1041786072788369408%'   GROUP BY  executor_ order by c.CREATE_TIME_ asc `
            await curdPost('sql', sql).then((res) => {
                data = res.variables.data
            })
            for (var i = 0; i < data.length; i++) {
                this_.optionPerson.xAxis.data.push(data[i].name_)
                this_.optionPerson.series[0].data.push(data[i].num)
                if (i === data.length - 1) {
                    personIds += "'" + data[i].executor_ + "'"
                } else {
                    personIds += "'" + data[i].executor_ + "',"
                }
            }

            // 超时
            // const cssql = `select  executor_ ,count(executor_) as num ,c.name_,a.create_time_ FROM  IBPS_BPM_TASKS as a join IBPS_BPM_TASK_ASSIGN as b  on a.task_id_ = b.task_id_ join ibps_party_employee as c on b.executor_ = c.id_
            //       where now()> SUBDATE(a.create_time_,interval - 3 day) and  c.STATUS_= 'actived' and c.ID_ != '1' and c.ID_ != '-1' and c.ID_ != '702117247933480960' and c.GROUP_ID_ not like '%1041786072788369408%'  GROUP BY  executor_  order by  c.CREATE_TIME_ asc `
            // await curdPost('sql', cssql).then((res) => {
            //     csData = res.variables.data
            // })
            // for (const it of csData) {
            //     // this_.optionPerson.series[2].data.push(it.num)
            //     personIds += "'" + it.executor_ + "',"
            //     console.log(personIds)
            // }

            // 办结
            const banjiesql = `select  count(AUDITOR_) as num, NAME_, AUDITOR_ FROM (select a.PROC_INST_ID_,a.AUDITOR_ ,d.NAME_ from (select * FROM ibps_bpm_approval_his group by PROC_INST_ID_,AUDITOR_) as a join ibps_bpm_inst_his as b on a.PROC_INST_ID_ = b.ID_  join  ibps_party_employee as d on a.AUDITOR_ = d.ID_ ) as aa WHERE AUDITOR_ in(${personIds}) group by AUDITOR_ `
            await curdPost('sql', banjiesql).then((res) => {
                banjie = res.variables.data
            })

            for (const it of banjie) {
                this_.optionPerson.series[2].data.push(it.num)
            }
            // 已办未办结
            const yibansql2 = `select count(NAME_) as num, NAME_, AUDITOR_  from ( select aa.NAME_,aa.ID_,bb.PROC_INST_ID_,bb.AUDITOR_ from ibps_party_employee as aa left join (select b.AUDITOR_,b.PROC_INST_ID_,b.OPINION_ FROM ibps_bpm_inst as a join ibps_bpm_approval as b on b.PROC_INST_ID_ = a.ID_) as bb on aa.ID_ = bb.AUDITOR_  GROUP BY PROC_INST_ID_, ID_) as zz WHERE ID_ in(${personIds}) group by ID_`
            await curdPost('sql', yibansql2).then((res) => {
                yiban1 = res.variables.data
            })

            for (const items of yiban1) {
                for (const el of banjie) {
                    if (items.AUDITOR_ === el.AUDITOR_) {
                        this_.optionPerson.series[1].data.push(
                            Number(items.num) + Number(el.num)
                        )
                    }
                }
            }

            // 暂存
            const zhancunsql = `select * from ( SELECT aa.num,bb.NAME_,bb.ID_ FROM  ibps_party_employee as bb left join (select count(ID_) as num, NAME_,ID_ FROM (select b.NAME_,b.ID_ FROM (select * FROM ibps_bpm_inst WHERE STATUS_ = 'draft' ) as a join ibps_party_employee as b on b.ID_ = a.CREATE_BY_) as zz  group by NAME_ ) as aa   on bb.ID_ = aa.ID_ ) as cc WHERE ID_ in(${personIds}) `
            await curdPost('sql', zhancunsql).then((res) => {
                zhancun = res.variables.data
            })

            for (const it of zhancun) {
                this_.optionPerson.series[3].data.push(it.num)
            }
        },
        loadData () {
            // let user = this.$store.getters.userInfo
            // let pos, role
            // this.orgName = user.employee.orgName
            // for (let i in user.positions) {
            //     if (i == 0) pos = user.positions[0].name
            //     else pos = pos + ',' + user.positions[i].name
            // }

            // let contRole = this.unique(user.role) //去重
            // for (let i in contRole) {
            //     if (i == 0) role = contRole[0].name
            //     else role = role + ',' + contRole[i].name
            // }
            // this.posName = pos
            // this.roleName = role

            // this.getMessage()
            // 获取任务数据
            this.getData(this.activeTab)
        },
        // 获取系统用户信息
        getUserList () {
            const { userList } = this.$store.getters
            // store中有则无需请求
            if (userList && userList.length) {
                this.userList = userList
                return
            }
            const sql = 'select id_ as userId, name_ as userName, mobile_ as phone from ibps_party_employee'
            curdPost('sql', sql).then(res => {
                this.userList = res.variables && res.variables.data
            })
        },
        // 获取用户部门信息
        getOrgInfo () {
            const { org = {}} = this.$store.getters
            if (!org || !org.id) {
                return
            }
            const params = {
                parameters: [{ key: 'Q^MANAGER_ORG_ID_^S', value: org.id }]
            }
            queryOrgManager(params).then(res => {
                this.orgInfo = {}
                const data = res.data.dataResult
                if (data && data.length) {
                    const { id, name, mobile, account, gender, groupID } = data[0]
                    this.orgInfo = { id, name, mobile, account, gender, groupID, orgName: org.name }
                }
            })
        },
        handleNodeClick (typeId) {
            this.dataList = []
            this.paginate = {}
            this.searchParams.typeId = typeId
            this.loadData()
        },
        handleExpandCollapse (isExpand) {
            this.width = isExpand ? 230 : 30
        },
        getName ({ createBy, updateBy }) {
            const id = updateBy || createBy
            const { name = '' } = this.$store.getters
            if (this.activeTab === 'finish') {
                const t = this.userList.find(i => i.userId === id)
                return t ? t.userName : ''
            }
            return name
        },
        tableRowClassName ({ row, rowIndex }) {
            if (rowIndex % 2 === 1) return 'warning-row'
            return 'success-row'
        },
        // 获取表格数据
        getData (type) {
            this.loading = true
            operate[this.activeTab](this.getFormatParams(null, this.defaultPagination)).then(response => {
                const { dataResult, pageResult } = response.data
                if (dataResult && dataResult.length) {
                    // 待办事宜对任务发起人做额外处理
                    if (type === 'wait') {
                        const instList = []
                        dataResult.forEach(item => {
                            instList.push(item.bpmnInstId)
                        })
                        const sql = `select b.bpmn_inst_id_, b.create_by_, a.name_ from ibps_bpm_inst b left join ibps_party_employee a on a.id_ = b.create_by_ where b.bpmn_inst_id_ in (${instList.join(',')}) order by find_in_set(b.bpmn_inst_id_,'${instList.join(',')}')`
                        const currentTime = Date.now()
                        curdPost('sql', sql).then(res => {
                            const data = res.variables && res.variables.data
                            data.forEach((item, index) => {
                                dataResult[index].submitBy = item.name_
                                dataResult[index].workName = dataResult[index].subject.includes('#') ? dataResult[index].subject.split('#')[0] : dataResult[index].subject.split('(')[0]
                                dataResult[index].workType = this.plan.includes(dataResult[index].procDefKey) ? 'plan' : 'normal'

                                if (dataResult[index].procDefKey === 'Process_0idt26n' || dataResult[index].procDefKey === 'Process_05lkhio' || dataResult[index].procDefKey === 'Process_1rwhy1r' || dataResult[index].procDefKey === 'Process_140upmu' || dataResult[index].procDefKey === 'Process_0bx4cg1') {
                                    // 检测项目，检测报告办理进度处理
                                    const time = dataResult[index].subject.match(/收样日期：(.*?)，/) ? dataResult[index].subject.match(/收样日期：(.*?)，/)[1] : null
                                    const dataNum = dataResult[index].subject.match(/检测时限：(.*?)，/) ? dataResult[index].subject.match(/检测时限：(.*?)，/)[1] : null
                                    if (time && dataNum) {
                                        const j = Math.round(dataNum / 3 * 2) > 1 ? Math.ceil(dataNum / 3 * 2) - 1 : 0
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(time).setDate(new Date(time).getDate() + j)
                                        const overtimeTime = new Date(time).setDate(new Date(time).getDate() + Number(dataNum))
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime), dataNum, j)

                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_0oo8gzf') {
                                    // 周期性推送事务办理进度处理-周
                                    const time = dataResult[index].createTime.match(/\d{4}-\d{2}-\d{2}/g) ? dataResult[index].createTime.match(/\d{4}-\d{2}-\d{2}/)[0] : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(this.getWeekDataList(time)[3] + ' 01:00:00').getTime()
                                        const overtimeTime = new Date(this.getWeekDataList(time)[7] + ' 01:00:00').getTime()
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_1h50uwi' || dataResult[index].procDefKey === 'Process_0x3emzx') {
                                    // 周期性推送事务办理进度处理-月
                                    const time = dataResult[index].createTime.match(/\d{4}-\d{2}-\d{2}/g) ? dataResult[index].createTime.match(/\d{4}-\d{2}-\d{2}/)[0] : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = this.getMonthDataList(time)[0].getTime()
                                        const overtimeTime = this.getMonthDataList(time)[1].getTime()
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_0mn0pk4' || dataResult[index].procDefKey === 'Process_1ve13oo') {
                                    // 改进不符合项
                                    const time = dataResult[index].subject.match(/改进截至日期:(.*?)#/) ? dataResult[index].subject.match(/改进截至日期:(.*?)#/)[1] + ' 00:00:00' : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(time).setDate(new Date(time).getDate() - 7)
                                        const overtimeTime = new Date(time).setDate(new Date(time).getDate() + 1)
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_0w9fzlq') {
                                    // 管理评审汇报材料  计划评审时间
                                    const time = dataResult[index].subject.match(/评审时间:(.*?),/) ? dataResult[index].subject.match(/评审时间:(.*?),/)[1] + ' 00:00:00' : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(time).setDate(new Date(time).getDate() - 7)
                                        const overtimeTime = new Date(time).setDate(new Date(time).getDate() - 1)
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_129f4hh') {
                                    // 管理评审报告编制  纪要提交时间
                                    const time = dataResult[index].createTime
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(time).setDate(new Date(time).getDate() + 7)
                                        const overtimeTime = new Date(time).setDate(new Date(time).getDate() + 10)
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_1c7w93s') {
                                    // 年度人员培训计划  生成记录定时任务
                                    const time = dataResult[index].subject.match(/计划时间：(.*?)#/) ? dataResult[index].subject.match(/计划时间：(.*?)#/)[1] + ' 00:00:00' : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(time).setDate(new Date(time).getDate() - 3)
                                        const overtimeTime = new Date(time).setDate(new Date(time).getDate() + 1)
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_1aamj6j' || dataResult[index].procDefKey === 'Activity_0drpspe') {
                                    // 设备检定,期间核查
                                    const time = dataResult[index].subject.match(/(?<=计划日期：)\d{4}-\d{2}-\d{2}/g) ? dataResult[index].subject.match(/(?<=计划日期：)\d{4}-\d{2}-\d{2}/)[0] : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = this.getMonthDataList(time)[0].getTime()
                                        const overtimeTime = this.getMonthDataList(time)[1].getTime()
                                        console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else if (dataResult[index].procDefKey === 'Process_1q2uqjq') {
                                    // 内审检查表  常规附加
                                    const time = dataResult[index].subject.match(/(?<=首次会议开始时间：)\d{4}-\d{2}-\d{2}/g) ? dataResult[index].subject.match(/(?<=首次会议开始时间：)\d{4}-\d{2}-\d{2}/)[0] : null
                                    if (time) {
                                        const currentTime = new Date().getTime()
                                        const soonTime = new Date(time).setDate(new Date(time).getDate() - 3)
                                        const overtimeTime = new Date(time).setDate(new Date(time).getDate())
                                        // console.log(this.TimestampToDate2(currentTime), this.TimestampToDate2(soonTime), this.TimestampToDate2(overtimeTime))
                                        dataResult[index].state = currentTime < soonTime ? 'wait' : currentTime < overtimeTime ? 'soon' : currentTime > overtimeTime ? 'overtime' : ''
                                    }
                                } else {
                                    dataResult[index].state = 'wait'
                                }
                                // else {
                                //     dataResult[index].state = this.judgeExpire(dataResult[index].createTime, currentTime, dataResult[index].workType, '1')
                                // }
                                // console.log(dataResult[index].procDefKey, dataResult[index].state)
                            })
                            this.dataList = dataResult.sort((a, b) => b.createTime.localeCompare(a.createTime))
                            this.paginate = pageResult
                        })
                        // this.urgeToManager()
                    } else {
                        this.dataList = dataResult
                        this.paginate = pageResult
                    }
                }
                this.loading = false
            }).catch(() => {
                this.loading = false
                // 请求出错清除轮询
                clearInterval(this.timer)
            })
        },
        // 延迟更新列表数据
        updateList () {
            setTimeout(() => {
                this.getData(this.activeTab)
            }, 750)
        },
        // 查询
        search () {
            this.dataList = []
            this.paginate = {}
            this.getData(this.activeTab)
        },
        // 删除暂存数据
        remove () {
            if (!this.selection.length) {
                this.$message.warning('请选择暂存事务！')
                return
            }
            const idList = []
            this.selection.forEach(i => idList.push(i.id))
            ActionUtils.removeRecord(idList).then(ids => {
                removeDraft({ ids }).then(() => {
                    ActionUtils.removeSuccessMessage()
                    this.selection = []
                    this.search()
                })
            }).catch(() => { })
        },

        async changeTab () {
            // 数据、筛选条件初始化
            this.dataList = []
            this.paginate = {}
            this.selection = []
            this.typeId = ''
            this.defaultPagination.page = 1
            if (this.activeTab === 'gr') {
                // this.getDpmInfo()
                tabList.forEach((item, index) => {
                    if (item.key !== 'gr' && item.key !== 'zt') {
                        operate[item.key](this.getFormatParams(null, this.defaultPagination)).then(response => {
                            grdata[index].dataText = response.data.pageResult.totalCount
                        })
                    }
                })
            } else if (this.activeTab === 'zt') {
                await this.chartLoading()
                await this.getTtaskMattersData()
                console.log(this.optionPerson)

                var chartDom1 = document.getElementById('a1')
                var myChart1 = echarts.init(chartDom1)
                myChart1.setOption(this.option)

                var chartDom2 = document.getElementById('a2')
                var myChart2 = echarts.init(chartDom2)
                myChart2.setOption(this.optionPerson)
            } else {
                this.getData(this.activeTab)
            }
        },
        // 数组去重
        unique (arr) {
            const res = new Map()
            return arr.filter(arr => !res.has(arr.id) && res.set(arr.id, 1))
        },
        // 分页
        changePage (val) {
            this.dataList = []
            this.paginate = {}
            this.defaultPagination.page = val
            this.getData(this.activeTab)
        },
        // 转换状态码
        contOfValue (cont) {
            const s = taskState[cont]
            return s || '暂停'
        },
        getFormatParams (v, pagination) {
            const params = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}

            if (this.$utils.isNotEmpty(this.searchParams.typeId)) {
                params[`Q^${paramsType[this.activeTab]}TYPE_ID_^S`] = this.searchParams.typeId
            }
            if (this.$utils.isNotEmpty(this.searchParams.subject)) {
                params[`Q^${paramsType[this.activeTab]}subject_^SL`] = this.searchParams.subject
            }
            if (this.searchParams.createTime && this.searchParams.createTime.length) {
                params[`Q^${paramsType[this.activeTab]}create_time_^DL`] = dateFormat(this.searchParams.createTime[0]).slice(0, 10)
                params[`Q^${paramsType[this.activeTab]}create_time_^DG`] = dateFormat(this.searchParams.createTime[1]).slice(0, 10)
            }
            if (this.activeTab === 'finish') {
                params.end = '1'
            }
            return ActionUtils.formatParams(params, pagination, this.sorts)
        },
        // 处理表格点击事件
        handleLinkClick (data) {
            this.taskId = data.id || ''
            this.waiJian = data.waiJian || ''
            this.instanceId = data.id || ''
            this.defId = data.procDefId || ''
            this.proInstId = data.id || ''
            this.FlowName = data.name
            this.processName = this.getProjectName(data.procDefKey, data.subject)
            this.dialogFormVisible = true
        },
        // 开关右侧栏抽屉
        handleClose () {
            this.drawer = !this.drawer
        },
        // 文字替换
        getParenthesesStr (text) {
            let result = ''
            if (!text) return result
            const regex1 = /\{(.+?)\}/g
            const regex2 = /\((.+?)\)/g
            const options1 = text.match(regex1)
            const options2 = text.match(regex2)
            const options = options1 && options1.length ? options1 : options2
            if (options) {
                const option = options[0]
                if (option) {
                    result = option.substring(1, option.length - 1)
                }
                if (options[1]) {
                    const yersOption = options[1]
                    if (yersOption) {
                        result = result + '/' + yersOption.substring(1, yersOption.length - 1)
                    }
                }
            }
            return result.split('/')
        },
        // 判断是否为检测项目流程，是则截取流程标题为表单名称
        getProjectName (key, subject) {
            // 从store中获取保存的检测流程信息数组，默认设置已知的四个流程key（三非通用一通用），流程key有变化需修改此处默认值
            const { testingList = ['Process_0idt26n', 'Process_1rwhy1r', 'Process_05lkhio', 'Process_140upmu'] } = this.$store.getters
            const res = testingList.includes(key)
            return res ? subject.includes('#') ? subject.split('#')[0] : '' : ''
        },
        /**
             * 主管提醒
             * 数据处理，将所有待办数据根据是否过期处理为两个数组
             * 过期判断依据：普通事务-创建时间到当前时间超过三天即为过期；计划事务【事务名称中含计划】-创建当月月末前七天
             * 逻辑说明：过期数组中不存于在主管提醒表中的数据插入主管提醒表，并发送内部通知，主管提醒表删除不存在于未过期数组中的数据
             */
        urgeToManager () {
            const { userId } = this.$store.getters
            const params = {
                parameters: [],
                sorts: []
            }
            const sql = `select id_, shi_wu_id_ as taskId from t_gqswb where position('${userId}' in chu_li_ren_id_) FOR UPDATE`
            // Promise.all([pending(params), curdPost('sql', sql)]).then(([res1, res2]) => {
            //     let workData = res1.data && res1.data.dataResult
            //     let noticeData = res2.variables && res2.variables.data
            //     if (!workData || !workData.length) {
            //         return
            //     }
            //     this.dealData(workData, noticeData)
            // })
            pending(params).then(res1 => {
                const workData = res1.data && res1.data.dataResult
                curdPost('sql', sql).then(res2 => {
                    const noticeData = res2.variables && res2.variables.data
                    if (!workData || !workData.length) {
                        return
                    }
                    this.dealData(workData, noticeData)
                })
            })
        },
        // 处理数据
        dealData (workList, noticeList) {
            const result = {
                expire: [],
                unexpire: [],
                all: []
            }
            const currentTime = Date.now()
            // 筛选已过期数据
            workList.forEach(item => {
                // 截取流程名
                item.workName = item.subject.includes('#') ? item.subject.split('#')[0] : item.subject.split('(')[0]
                item.workType = this.plan.includes(item.procDefKey) ? 'plan' : 'normal'
                const isExpire = this.judgeExpire(item.createTime, currentTime, item.workType)
                if (isExpire) {
                    result.expire.push(item)
                } else {
                    result.unexpire.push(item)
                }
                result.all.push(item)
            })
            // console.log('处理后数据：', result)
            // 有过期数据才执行过期数据处理
            if (result.expire.length) {
                this.dealExpile(result.expire, noticeList)
            }
            // 主管提醒表中有数据才执行数据删除
            if (noticeList && noticeList.length) {
                this.dealUnexpile(result.all, noticeList)
            }
        },
        // 判断是否过期、获取办理状态
        judgeExpire (time, current, type, isState) {
            const D = new Date(time)
            const a = new Date(time).getTime()
            const b = new Date(current).getTime()
            // 创建时间当月最后一天的时间戳
            const c = new Date(D.getFullYear(), D.getMonth() + 1, 0).getTime() + 86400000
            // 返回办理状态
            if (isState) {
                let state = ''
                if (type === 'plan') {
                    state = b >= c ? 'overtime' : b + (86400000 * 7) > c ? 'soon' : 'wait'
                } else {
                    state = a + (86400000 * 3) < b ? 'overtime' : 'wait'
                }
                return state
            }
            // 返回是否过期
            if (type === 'plan') {
                return b + (86400000 * 7) > c
            } else {
                return a + (86400000 * 3) < b
            }
        },
        // 处理已过期数据
        dealExpile (data, noticeList) {
            // console.log('已过期流程数据：', data)
            // console.log('过期事务表数据：', noticeList)
            const { userId } = this.$store.getters
            const addList = []
            const sendList = []
            const msgContent = {
                plan: '距离过期还剩七天，请及时处理！',
                normal: '至今三天未处理，已超时，请及时处理！'
            }
            const msgTitle = {
                plan: '计划事务即将到期提醒',
                normal: '事务超时提醒'
            }
            const nowTime = new Date(new Date().getTime() + 28800000).toJSON().slice(0, 16).replace('T', ' ')
            data.forEach(item => {
                const isExist = !!noticeList.find(i => i.taskId === item.taskId)
                // 筛选出不存在于主管提醒表的过期数据
                if (!isExist) {
                    // 无部门信息的用户不往过期事务表加数据
                    if (this.orgInfo.groupID) {
                        const obj = {
                            // 事务ID
                            shi_wu_id_: item.taskId,
                            // 完整名称
                            wan_zheng_ming_ch: item.subject,
                            // 事务说明
                            shi_wu_shuo_ming_: item.subject.includes('#') ? item.subject.split('#')[1] : '',
                            // 事务名称
                            shi_wu_ming_cheng: item.workName,
                            // 事务状态
                            shi_wu_zhuang_tai: `待${item.name}`,
                            // 事务类型
                            shi_wu_lei_xing_: item.workType,
                            chu_li_ren_ming_: item.ownerName,
                            chu_li_ren_id_: this.getInfoByName(item.ownerName, 'id'),
                            chu_li_ren_dian_h: this.getInfoByName(item.ownerName, 'phone'),
                            bu_men_: this.orgInfo.orgName,
                            bu_men_id_: this.orgInfo.groupID,
                            // 主管ID与当前用户id相等时将主管ID设置为主任【】的ID，主管电话设为空
                            zhu_guan_id_: this.orgInfo.id === userId ? '990927120278487040' : this.orgInfo.id,
                            zhu_guan_dian_hua: this.orgInfo.id === userId ? '' : this.orgInfo.mobile,
                            bian_zhi_shi_jian: item.createTime,
                            ti_xing_ci_shu_: 1,
                            duan_xin_ci_shu_: 0,
                            ti_xing_shi_jian_: nowTime
                        }
                        addList.push(obj)
                    }
                    const msg = {
                        subject: msgTitle[item.workType],
                        content: `<p>事务【${item.workName}】${msgContent[item.workType]}<p>`,
                        receiverId: userId,
                        canreply: '0',
                        taskId: item.taskId
                    }
                    sendList.push(msg)
                }
            })
            const addParams = {
                tableName: 't_gqswb',
                paramWhere: addList
            }
            // console.log('新增过期事务表数据：', addList, '发送消息数据', sendList)
            if (addList.length) {
                curdPost('add', JSON.stringify(addParams))
            }
            if (sendList.length) {
                this.sendMsg(sendList)
            }
        },
        // 删除已办的提醒表数据
        dealUnexpile (data, noticeList) {
            // 清除存在于主管提醒表中【处理人含我】，但是不存在于待办中的数据
            const deleteList = []
            noticeList.forEach(item => {
                const isExist = !!data.find(i => i.taskId === item.taskId)
                if (!isExist) {
                    deleteList.push(item.id_)
                }
            })
            // console.log('过期事务表中需删除的数据：', deleteList)
            if (!deleteList.length) {
                return
            }
            const params = `{"tableName": "t_gqswb","paramWhere":"{id_:'${deleteList.join(',')}'}"}`
            curdPost('batchDelete', params).then(() => {}).catch(err => {
                console.log(err)
            })
        },
        // 发送站内消息
        sendMsg (data) {
            data.forEach(item => {
                save(item).then(() => {}).catch(err => {
                    console.log(err)
                })
            })
        },
        // 通过名字获取id/电话
        getInfoByName (names, type) {
            const res = {
                id: [],
                phone: []
            }
            const temp = names.split(',')
            temp.forEach(item => {
                const t = this.userList.find(i => i.userName === item)
                if (t) {
                    res.id.push(t.userId)
                    res.phone.push(t.phone)
                }
            })
            return res[type].filter(i => i).join(',')
        },
        // 时间戳转时间
        TimestampToDate2 (Timestamp) {
            const now = new Date(Timestamp)
            const y = now.getFullYear()
            const m = now.getMonth() + 1
            const d = now.getDate()
            return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + now.toTimeString().substr(0, 8)
        },
        // 根据指定日期获取本周一到下周一日期
        getWeekDataList (data) {
            // 根据日期获取本周周一~周日的年-月-日
            var weekList = []
            var date = new Date(data)
            // 判断本日期是否为周日，获取本周一日期
            if (date.getDay() === '0') {
                date.setDate(date.getDate() - 6)
            } else {
                date.setDate(date.getDate() - date.getDay() + 1)
            }
            var myDate = date.getDate()
            var myMonth = date.getMonth() + 1
            if (date.getDate() < 10) {
                myDate = '0' + myDate
            }
            if (date.getMonth() + 1 < 10) {
                myMonth = '0' + myMonth
            }
            weekList.push(date.getFullYear() + '-' + myMonth + '-' + myDate)
            // 获取周二到下周一日期
            for (var i = 0; i < 7; i++) {
                date.setDate(date.getDate() + 1)
                myDate = date.getDate()
                myMonth = date.getMonth() + 1
                if (date.getDate() < 10) {
                    myDate = '0' + myDate
                }
                if (date.getMonth() + 1 < 10) {
                    myMonth = '0' + myMonth
                }
                weekList.push(date.getFullYear() + '-' + myMonth + '-' + myDate)
            }
            // console.log(weekList)
            return weekList
        },
        // 根据指定日期获取本本月20号下月1号日期
        getMonthDataList (data) {
            var date = new Date(data)
            // 获取该日期所在的年份和月份
            var year = date.getFullYear()
            var month = date.getMonth() // 注意：月份是从0开始的，所以10月是9

            // 创建一个新的日期对象，设置为该年的该月的20号
            var twentyFifth = new Date(year, month, 20, 1, 0, 0)

            // 计算下个月的年份和月份
            var nextMonth = month + 1
            var nextMonthYear = year
            if (nextMonth > 11) { // 如果月份超过11（即12月），则年份加1，月份重置为0（即1月）
                nextMonth = 0
                nextMonthYear += 1
            }

            // 创建一个新的日期对象，设置为下个月的1号
            var firstDayOfNextMonth = new Date(nextMonthYear, nextMonth, 1, 1, 0, 0)
            // console.log(twentyFifth, firstDayOfNextMonth)

            return [twentyFifth, firstDayOfNextMonth]
        }
    }
}
</script>
<style lang="scss" scoped>
    .el-completing {
        background: #409eff !important;
    }
    .el-col {
        min-height: 1px;
    }
    .firstcol {
        padding-right: 10px;
    }
    .el-nothing {
        font-size: 13px;
    }
    .calendar-day {
        text-align: center;
        color: #202535;
        line-height: 30px;
        font-size: 12px;
    }
    .is-selected {
        color: #f8a535;
        font-size: 10px;
        margin-top: 5px;
    }
    #calendar .el-button-group > .el-button:not(:first-child):not(:last-child):after {
        content: '当月';
    }
    #calendar .item {
        position: relative;
        margin: 0;
        padding: 0;
        height: auto;
        border-radius: 4px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        overflow: hidden;
        color: #f8a535;
    }
    .ibps-list-split .ibps-list-item {
        border-bottom: 1px solid #dcdfe6;
        padding: 6px 0;
    }
    .jbd-font-style {
        font-weight: bold;
    }
    .home-text-border {
        color: #999999;
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(0, 0, 0, 0.1), 0 1px 0px 0 rgba(0, 0, 0, 0.1);
        min-height: 20px;
        font-size: 14px;
        margin-left: 60px;
        margin-bottom: 5px;
    }
    .jbd-home-card {
        overflow: auto;
    }
    .jbd-home-task {
        width: 100%;
        padding: 10px;
        cursor: pointer;
        font-size: 12px;
        margin-bottom: 35px;
    }
    .jbd-home-card::-webkit-scrollbar {
        display: none;
    }
    .jbd-control-cont {
        text-align: center;
        position: absolute;
        z-index: 10;
        right: 0px;
        top: 50%;
    }
    .tab-container {
        >div {
            display: inline-block;
        }
        .table-container {
            width: calc(100% - 250px);
            vertical-align: top;
            .search-container {
                display: flex;
                margin-bottom: 10px;
                .search-box {
                    display: flex;
                    align-items: center;
                    height: 30px;
                    margin-right: 20px;
                    .label {
                        margin: 0 6px 0 6px;
                        color: #606266;
                        font-size: 12px;
                    }
                    .input {
                        width: 200px;
                        font-size: 12px;
                        height: 28px !important;
                        line-height: 28px;
                        color: #606266;
                        ::v-deep .el-input__inner {
                            height: 28px;
                            line-height: 28px;
                        }
                    }
                }
                .btn {
                    height: 30px;
                    margin-left: 10px;
                    background-color: #409eff;
                    border-color: #409eff;
                    font-size: 12px;
                    border-radius: 3px;
                    padding: 7px 15px;
                }
                .el-button--danger {
                    background-color: #f56c6c;
                    border-color: #f56c6c;
                }
            }
        }
    }
</style>
<style>
    .ibps-desktop-dashboard{
        padding: 100px 200px;

    }
    .ibps-desktop-dashboard .item{
        height: 150px !important;
    }
    .app-container .el-drawer.rtl {
        overflow: scroll;
    }
    .app-container .el-table th {
        background-color: #a7d6f8 !important;
        font-size: 14px;
        font-weight: bold;
        color: #000000;
        border: 0px;
    }
    .app-container .el-table td {
        padding: 4px;
    }
    .app-container .el-table .warning-row {
        background: #d3ebfc;
        color: #000000;
    }
    .app-container .el-table .success-row {
        background: #f9ffff;
        color: #000000;
    }
</style>
