<template>
    <div>
        <fullscreen :fullscreen.sync="fullscreen" class="container">
            <div class="ifram" v-if="ifstatus">
                <div class="flow">
                    <iframe height="100%" width="100%" :src="agdataurl" frameborder="0"></iframe>
                    <div class="closeif" @click="ifstatus=false"><i class="el-icon-close"></i></div>
                </div>

            </div>
            <div class="container-box">
                <toolList @iconCli='iconCli' :tooltit='tooltit'></toolList>
                <div class="search">
                    <mySearch :searchList="searchList" @searchInfo="searchInfo"></mySearch>
                </div>
                <div class="tabbox">
                    <el-table height="calc(100% - 40px)" class="com-table" ref="multipleTable"
                        :data="tableData" tooltip-effect="dark" size="small" border style="width: 100%" v-loading="loading">
                        <el-table-column prop="woNo" label="工单编号">
                        </el-table-column>
                        <el-table-column prop="procName" label="工单标题">
                        </el-table-column>
                        <el-table-column prop="assigneeName" label="处理人">
                        </el-table-column>
                        <el-table-column prop="assigneeNo" label="处理人姓名">
                        </el-table-column>
                        <el-table-column prop="createTime" label="发起时间">
                        </el-table-column>
                        <el-table-column prop="taskName" label="当前环节">
                        </el-table-column>
                        <el-table-column prop="roleName" label="当前处理人">
                        </el-table-column>
                        <el-table-column label="操作" width="160px" align="center">
                            <template slot-scope="scope">
                                <el-button size="mini" type="primary" @click="dialogCheck(scope.row)">处理</el-button>
                                <el-button size="mini" type="primary" @click="trajectory(scope.row)">轨迹</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination class="pageBox" @current-change="currchange" layout="prev, pager, next" background
                        :total="total">
                    </el-pagination>
                </div>



                <el-dialog title="申请终端" :visible.sync="dialogStatus" width="60%" :destroy-on-close="true"
                    :modal-append-to-body="false" :close-on-click-modal="false">

                    <div>


                        <terminal v-if="typestatsu === 1" :changeinfo="true" @closeEdio="closeEdio" :componentInfo="componentInfo" :componentStatus="componentStatus"></terminal>

                        <advert v-if="typestatsu === 2" :changeinfo="true" @closeEdio="closeEdio" :componentInfo="componentInfo" :componentStatus="componentStatus"></advert>


                    </div>

                </el-dialog>
            </div>
        </fullscreen>

    </div>
</template>
<script>
    import mySearch from "../../../components/search.vue";
    import toolList from "../../../components/toolList.vue";
    import terminal from "./components/terminal.vue"
    import advert from "./components/advert.vue"

    // import $ from 'jquery'


    export default {
        components: {
            mySearch,
            toolList,
            terminal,
            advert
        },
        data() {
            return {
                tooltit: '待办任务',
                agdataurl: '',
                searchList: [{
                        type: 'input',
                        tit: '工单标题',
                        value: '',
                        width: '49%',
                    },
                    {
                        type: 'input',
                        tit: '发起人',
                        value: '',
                        width: '49%',
                    }
                ],
                loading: false,
                fullscreen: false,
                total: 0,
                pageSize: 1,
                tableData: [{}],
                dialogStatus: false,
                titname: '终端',
                infolist: {},
                userInfo: {},
                params: {},
                ifstatus: false,
                typestatsu: 1,
                options: [],
                typeopt: [],
                componentInfo:{},
                componentStatus:false,
            }
        },
        methods: {
            //搜索数据
            searchInfo(v) {
                this.params = {};
                v[0] ? this.params.procName = v[0] : '';
                v[1] ? this.params.assigneeName = v[1] : '';
                this.getList(this.params, this.pageSize);
            },
            //获取列表
            getList(v, n) {
                this.pageSize = n;
                let _this = this;
                this.tableData = [];
                this.loading = true;
                this.$http({
                    url: "/bpm/api/queryToDoTaskList",
                    method: "post",
                    headers: {
                        "Content-Type": "application/json",
                        "page": '{"pageNo":"' + n + '","pageSize":"10"}'
                    },
                    data: v,
                }).then((res) => {
                    this.tableData = res.data.data;
                    this.total = res.data.totalRecord;
                    for (let i = 0; i < this.tableData.length; i++) {
                        this.tableData[i].opTime = _this.$formatDate(this.tableData[i].opTime,
                            "YYYY-MM-DD")
                    }
                    this.loading = false;
                });
            },
            // 分页
            currchange(v) {
                this.pageSize = v;
                this.getList(this.params, this.pageSize);
            },
            //轨迹
            trajectory(v) {

                this.agdataurl = '/static/views/flow/flowDesignPrew.html?prevFlag=false&woNo=' + v.woNo + '&taskName=' +
                    v.taskName + '&fqFlag=N&procId=' + v.procId + '&woTitle=测试终端申请&procName=' + v.procName +
                    '&procVersion=' + v.procVersion;
                // window.open(this.agdataurl);
                this.ifstatus = true;

            },
            //处理申请
            dialogCheck(n) {
                if ('广告申请' === n.procName) {
                    this.typestatsu = 2;
                } else if("测试终端申请" === n.procName){
                    this.typestatsu = 1;
                }
                this.dialogStatus = true;
                this.componentInfo = n;
                this.componentStatus = true;
            },
            closeEdio(){
                this.getList(this.params, this.pageSize);
                this.dialogStatus = false;
                this.componentStatus = false;
            },
            //功能栏
            iconCli(v) {
                if (v === 1) {
                    this.getList(this.params, this.pageSize);
                }
                if (v === 2) {
                    this.fullscreen = !this.fullscreen
                }
            },
            getUser() {
                this.userInfo = JSON.parse(window.sessionStorage.userInfo);
                this.infolist = {
                    opNo: '',
                    opName: '',
                };
                this.infolist.opNo = this.userInfo.loginNo;
                this.infolist.opName = this.userInfo.loginName;

            }
        },
        mounted() {
            this.getList({}, 1);
            this.getUser();
        },
        created() {

        }
    }
</script>
<style scoped lang="scss">
    .approval {
        .roval-box {
            padding: 0 20px;
            margin-bottom: 10px;

            .el-input {
                width: calc(100% - 200px);
                display: inline-block;
            }

            span {
                display: inline-block;
                width: 80px;
                font-size: 14px;
                margin-right: 20px;

                .el-input {
                    width: 100%;
                    display: inline-block;
                }
            }
        }
    }

    .onetab {
        margin-bottom: 20px;
        padding: 0 20px;
    }

    .titbox {
        div {
            float: right;

            i {
                font-size: 22px;
                margin-left: 20px;
                cursor: pointer;
            }
        }
    }

    .tabbox {
        margin-top: 15px;
    }

    .pageBox {
        text-align: right;
        margin-top: 10px;
    }

    .info-line {
        width: 100%;
        display: block;
        padding-left: 20px;
        // margin-bottom: 20px;

        div {
            width: 50%;
            display: inline-block;
        }

        span {
            width: 80px;
            display: inline-block;
            text-align: left;

            i {
                color: red;
                display: inline-block;
                padding-right: 5px;
            }
        }

        .el-select {
            width: calc(100% - 100px);
            // margin-right: 20px;
        }

        .el-input {
            width: calc(100% - 100px);
        }
    }

    .online {
        width: 100%;

        .el-select {
            width: calc(100% - 100px);
        }

        span {
            vertical-align: top;
        }

        .el-textarea {
            width: calc(100% - 100px);
        }
    }

    .ifram {
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 1000000;

        .flow {
            width: 80%;
            height: 80%;
            margin-left: 10%;
            margin-top: 5%;
            background: #fff;
            display: inline-block;
            position: relative;
        }

        .closeif {
            position: absolute;
            right: -40px;
            background: rgba(0, 0, 0, .4);
            display: inline-block;
            width: 40px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            cursor: pointer;
            color: #fff;
            font-size: 20px;
            font-weight: bold;
        }
    }
</style>
