<template>
    <div class="war" style="padding:15px 10px 0 10px">
        <div class="task-container">
            <div class="task-left-menu">
                <el-tabs tab-position="left" style="height:100%" @tab-click="search">
                    <el-tab-pane label="我的任务">
                        <span slot="label"><i class="el-icon-user"></i> 我的任务</span>
                    </el-tab-pane>
                    <el-tab-pane label="历史任务">
                        <span slot="label"><i class="el-icon-time"></i> 历史任务</span>
                    </el-tab-pane>
                </el-tabs>
            </div>
            <div class="task-right-content">
                <el-form :model="queryParams" :inline="true" style="padding:0 0 0 0" size="small">
                </el-form>
                <el-table :data="tableData" v-loading="loading">
                    <el-table-column prop="year" label="年度" width="60" align="center" style="height: 20px;" />
                    <el-table-column prop="deptName" label="科室" align="center" />
                    <el-table-column label="填报人" align="center" prop="informant" />
                    <el-table-column label="分管领导" align="center" prop="leadershipName" />
                    <el-table-column label="填报时间" align="center" prop="tbTime" />
                    <el-table-column label="操作" align="center" width="80">
                        <template slot-scope="scope">
                            <el-button v-if="isTaskListe" type="text" size="mini" icon="el-icon-edit"
                                @click="handleResolve(scope.row, false)">办理
                            </el-button>
                            <el-button v-if="!isTaskListe" type="text" size="mini" icon="el-icon-edit"
                                @click="hisHandleResolve(scope.row, true)">历史
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <!--        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"-->
                <!--                    :limit.sync="queryParams.pageSize" @pagination="search"/>-->
                <div>
                    <HandleResolve v-if="process.open" :process-open.sync="process.open" :instanceId="process.instanceId"
                        :id="process.id" :taskId="process.taskId" :readOnly="process.readOnly" :revoke="process.revoke"
                        :row="rowData">
                    </HandleResolve>
                </div>
                <div>
                    <hisHandleResolve v-if="process.hisOpen" :process-open.sync="process.hisOpen"
                        :instanceId="process.instanceId" :id="process.id" :taskId="process.taskId"
                        :readOnly="process.readOnly" :revoke="process.revoke" :row="rowData">
                    </hisHandleResolve>
                </div>
            </div>
        </div>

    </div>
</template>

<script>
import {
    taskDoneList,// 查看科室预算已办列表
    complete,
    departiDetail,// 查看科室预算待办列表

} from "@/api/smartSchool/indexMould/myTask/depBudgetapproval";
import HandleResolve from "@/views/smartSchool/indexMould/myTask/depBudgetapproval/components/dehandleResolv.vue";
import hisHandleResolve from "@/views/smartSchool/indexMould/myTask/depBudgetapproval/components/dehishandleResolve.vue";

export default {
    name: '',
    components: {
        HandleResolve,
        hisHandleResolve
    },
    data() {
        return {
            // 遮罩层
            loading: false,
            queryParams: {
                // pageNum: 1,
                // pageSize: 10,
            },
            tableData: [
                {
                    hdmc: '活动',
                }
            ],
            // 存储行数据
            rowData: {},
            total: 0,
            // 办理流程
            process: {
                id: undefined,
                instanceId: undefined,
                taskId: undefined,
                open: false,
                hisOpen: false,
                title: '流程办理',
                readOnly: false,
                // 是否销假
                revoke: false
            },

            isTaskListe: true,
        }
    },
    methods: {
        /** 查询 */
        search(evl) {
            console.log(evl);
            if (evl.label == "历史任务") {
                console.log("历史人物")
                this.isTaskListe = false
                this.loading = true;
                taskDoneList().then((response) => {
                    this.tableData = response.rows
                    console.log('this.tableData', this.tableData);
                    this.total = response.total
                    this.loading = false
                });
            } else {
                console.log("金额人物")
                this.loading = true;
                this.isTaskListe = true
                departiDetail().then((response) => {
                    this.tableData = response.rows
                    console.log('this.tableData', this.tableData);
                    this.total = response.total
                    this.loading = false
                });
            }

        },
        // 一进入查询
        searchStart() {
            // this.loading = true;
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
            }
            this.isTaskListe = true
            departiDetail().then((response) => {
                this.tableData = response.rows
                // console.log(response.rows);
                this.loading = false

            });

        },
        // 搜索查询
        inputSearch() {
            // this.loading = true;
            this.isTaskListe = true
            // console.log(445566);
            departiDetail().then((response) => {
                this.tableData = response.rows
                console.log(response.rows);
                // this.loading = false

            });

        },
        /** 提交 */
        submit() {
            // this.loading = true;
            // getMyTable().then((response) => {
            //     this.tableData = response.rows
            //     console.log(response.rows);
            // this.loading=false
            // });
        },
        /** 办理 */
        handleResolve(row, readOnly) {
            this.process.open = true;
            this.process.instanceId = row.instanceId;
            this.process.id = row.id;
            this.process.taskId = row.taskId;
            this.process.readOnly = readOnly; // 主要用来判断是否为历史任务。或者是申请人查看
            this.rowData.year = row.year
            this.rowData.deptName = row.deptName
            this.rowData.informant = row.informant
            this.rowData.expectedDate = row.expectedDate
            this.rowData.leadershipName = row.leadershipName
            this.rowData.tbTime = row.tbTime

        },
        /**历史 */
        hisHandleResolve(row, readOnly) {
            this.process.hisOpen = true;
            this.process.open = false;
            this.process.instanceId = row.instanceId;
            this.process.id = row.id;
            this.process.taskId = row.taskId;
            this.process.readOnly = readOnly; // 主要用来判断是否为历史任务。或者是申请人查看
            this.rowData.year = row.year
            this.rowData.deptName = row.deptName
            this.rowData.informant = row.informant
            this.rowData.expectedDate = row.expectedDate
            this.rowData.leadershipName = row.leadershipName
            this.rowData.tbTime = row.tbTime

        },
    },
    created() {
        this.searchStart()

    },
}
</script>

<style scoped></style>

