<template>
    <div class="app-container">
        <div class="title-container">
            <breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
        </div>
        <y-page-list-layout :page-list="pageData" :page-para="listQuery" :get-page-list="getAssetsTaskDoneList">
            <template slot="left">
                <el-input style="margin-left: 20px;width: 300px;float: left;" class="filter-item"
                    v-model="listQuery.keyWord" placeholder="项目编号/报告号/项目名称/业务来源" clearable>
                </el-input>
                <el-select v-model="listQuery.nodeCode" filterable placeholder="流程节点（可搜索）"
                    style=" width: 200px;margin-left: 10px;float: left;">
                    <el-option v-for="item in nodes" :label="item.name" :value="item.code">
                    </el-option>
                </el-select>
                <el-select v-model="listQuery.departmentId" filterable placeholder="接单部门"
                    style=" width: 200px;margin-left: 10px;float: left;">
                    <el-option v-for="(d, id) in allotDepartment" :label="d.name" :value="d.id"></el-option>
                </el-select>
                <el-button class="filter-item" style="margin-left: 10px;float: left;" type="primary" @click="searchList"
                    round>搜索
                </el-button>
                <el-button class="filter-item" style="float: left;" round type="success" @click="resetParams()">重置
                </el-button>
            </template>
            <parentTable ref="table" v-loading="listLoading" :data="pageData.records" slot="table" style="width: 100%;">
                <el-table-column label="项目编号" align="center" width="150">
                    <template slot-scope="{row}">
                        <span>{{ row.orderId }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="项目名称" align="center" width="300">
                    <template slot-scope="{row}">
                        <span>{{ row.reportName || row.statementName || row.name }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="意见书号" align="center" width="250">
                    <template slot-scope="{row}">
                        <span>{{ row.statementNo }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="报告号" align="center" width="250">
                    <template slot-scope="{row}">
                        <span>{{ row.reportNo }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="处理人" align="center" width="150">
                    <template slot-scope="{row}">
                        <span>{{ row.handlerName }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="处理的节点" align="center" width="150">
                    <template slot-scope="{row}">
                        <span>{{ row.nodeName }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="处理意见" align="center" width="150">
                    <template slot-scope="{row}">
                        <span>{{ row.comments }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作状态" align="center" width="150">
                    <template slot-scope="{row}">
                        <span>{{ row.state }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="开始时间" align="center" width="200">
                    <template slot-scope="{row}">
                        <span>{{ row.startDate }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="完成时间" align="center" width="200">
                    <template slot-scope="{row}">
                        <span>{{ row.finishTime }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="处理时长" align="center" width="180">
                    <template slot-scope="{row}">
                        <span>{{ row.handingTime }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="节点完成状态" align="center" width="150">
                    <template slot-scope="{row}">
                        <el-tag v-if="row.instanceState === 'FINISHED'" type="success">已完成</el-tag>
                        <el-tag v-if="row.instanceState === 'PENDING'" type="warning">进行中</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="操作" align="center" width="120" fixed="right">
                    <template slot-scope="{row}">
                        <el-button type="success" size="mini" @click="orderDetail(row)">查看</el-button>
                    </template>
                </el-table-column>
            </parentTable>
        </y-page-list-layout>
    </div>
</template>

<script>
import YPageListLayout from '@/components/YPageListLayout'
import Breadcrumb from '@/components/Breadcrumb'
import PermissionButton from '@/components/PermissionButton/PermissionButton'

export default {
    name: 'AssetsDepartmentDoneList',
    components: {
        Breadcrumb,
        YPageListLayout,
        PermissionButton,
    },
    data() {
        return {
            pageData: { records: [] },
            listLoading: false,
            listQuery: {
                page: 1,
                size: 10,
                current: 1,
                // 节点code
                nodeCode: null,
                // 关键字
                keyWord: null,
                //是否以部门id查询
                selectByDepartment: true,
                departmentId: null
            },
            // 接单部门
            allotDepartment: [],
            nodes: []
        }
    },
    created() {
        // 获取节点下拉列表
        this.getNodes();
        // 获取分单部门
        this.getAllotDepartment();
        // 获取资产业务订单
        this.getAssetsTaskDoneList();
    },
    methods: {
        // 无条件分页查询
        getAssetsTaskDoneList() {
            this.listQuery.selectByDepartment = true;
            this.$api.workNodeTaskRecord.getAssetsTaskDoneList(this.listQuery).then(res => {
                if (res.code === 200) {
                    this.pageData = res.data;
                }
            })
        },
        // 条件查询
        searchList() {
            // 重置分页
            this.listQuery.page = 1
            this.listQuery.size = 10
            this.getAssetsTaskDoneList()
        },
        // 重置搜索条件
        resetParams() {
            this.$router.push({ query: {} });
            this.listQuery = {
                current: 1,
                size: 10,
            }
            this.getAssetsTaskDoneList();
        },
        getNodes() {
            this.$api.workNode.enum().then(res => {
                if (res.code === 200) {
                    this.nodes = res.data
                }
            })
        },
        orderDetail(row) {
            this.$router.push({
                path: "/assets/orderDetail",
                query: {
                    row: JSON.stringify(row),
                    back: '/assets/archivedList',
                    couldEdit: false,
                    couldBack: false,
                    disabledStatus: true
                }
            })
        },
        // 获取部门下拉列表
        getAllotDepartment() {
            this.$api.department.allot().then(res => {
                if (res.code === 200) {
                    this.allotDepartment = res.data;
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped></style>