<!--
 * @Title: 
 * @Description: 当天维修任务反馈记录列表
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
    <div>
        <basic-container>
            <el-row>
                <el-col :span="24">
                    <basic-container>
                        <avue-crud :option="option" :table-loading="loading" :page.sync="page" :data="data" ref="crud"
                            v-model="form" :permission="permissionList" @row-del="rowDel" @row-update="rowUpdate"
                            @row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
                            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
                            @refresh-change="refreshChange" @on-load="onLoad">
                            <template slot-scope="{ row }" slot="menu">
                                <el-button type="text" size="small" @click="openDetail(row)">查看详情
                                </el-button>
                            </template>
                        </avue-crud>
                    </basic-container>
                </el-col>
            </el-row>

            <!-- <div v-for="(item, index) in todayOrderList" :key="index" class="list-item">
                <div style="display: flex; flex-direction: row;align-items: center;">
                    <label>{{ item.rtuName }}</label>
                    <label style="margin-left: 5px;color: gray;">{{ item.rtuCode }}</label>
                </div>
                <div style="display: flex; flex-direction: row;align-items: center;margin-top: 4px;">
                    <label style="margin-right: 10px;">维修状态：{{ item.orderStatusName }}</label>
                                                                            </div>
                                                                            <div style="display: flex; flex-direction: row;align-items: center;margin-top: 4px;">
                                                                                <label>更新时间：{{ item.updateTime }}</label>
                                                                            </div>
                                                                            <div style="margin-top: 4px;margin-bottom: 5px;">
                                                                                <label>备注：{{ item.processDesc }}</label>
                                                                            </div>
                                                                        </div> -->
        </basic-container>
        <el-drawer :visible.sync="detailDialog" v-if="detailDialog" title="维修处理详情" direction="rtl" size="50%"
            append-to-body="true">
            <checkorderprocessdetail :orderId="id" ref="checkorderprocessdetail"></checkorderprocessdetail>
        </el-drawer>
    </div>
</template>
<script>
import { todayOrderProcessPage, getDetail } from "@/api/business/order/process.js"
import checkorderprocessdetail from "./checkorderprocessdetail.vue";
export default {
    components: {
        checkorderprocessdetail
    },
    name: 'todaycheckorderprocesslist',
    data() {
        return {
            detailDialog: false,
            id: "",
            form: {},
            selectionList: [],
            query: {},
            loading: true,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            option: {
                labelWidth: 120,
                viewLabelWidth: 100,
                searchlabelWidth: 100,
                height: "auto",
                calcHeight: 80,
                align: "center",
                headerAlign: "center",
                tip: false,
                simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                addBtn: false,
                tree: true,
                border: true,
                index: true,
                editBtn: false,
                delBtn: false,
                menuWidth: 160,
                dialogType: "drawer",
                dialogClickModal: false,
                columnBtn: false,
                menu: true,
                column: [
                    {
                        label: "测站编码",
                        prop: "rtuCode",
                        span: 24,
                        search: true,
                        width: 120,
                    },
                    {
                        label: "测站名称",
                        prop: "rtuName",
                        span: 24,
                        search: true,
                    },
                    {
                        label: "行政区",
                        prop: "adCity",
                        span: 12,
                        html: true,
                        formatter: (val) => {
                            if (val.adDist) {
                                return '<b>' + val.adCity + '</b>/' + '<b>' + val.adDist + '</b>'
                            } else {
                                return '<b>' + val.adCity + '</b>'
                            }
                        }
                    },
                    {
                        label: "运维单位",
                        prop: "manageCompany",
                        span: 12,
                    },
                    {
                        label: "维修状态",
                        prop: "orderStatusName",
                        span: 24,
                    },
                    {
                        label: "反馈时间",
                        prop: "updateTime",
                        span: 24,
                    },
                    {
                        label: "处理说明",
                        prop: "processDesc",
                        span: 24,
                    },

                ],
            },
            data: [],
        };
    },
    props: {

    },
    create() {

    },
    methods: {
        init() {
            this.onLoad(this.page);
        },
        openDetail(item) {
            this.id = item.orderId;
            this.detailDialog = true;
            this.$nextTick(() => {
                this.$refs["checkorderprocessdetail"].init();
            });
        },
        searchReset() {
            this.query = {};
            this.page.currentPage = 1;
            this.onLoad(this.page);
        },
        searchChange(params, done) {
            this.query = params;
            this.page.currentPage = 1;
            this.onLoad(this.page, params);
            done();
        },
        selectionChange(list) {
            this.selectionList = list;
        },
        selectionClear() {
            this.selectionList = [];
            this.$refs.crud.toggleSelection();
        },
        beforeOpen(done, type) {
            if (["edit", "view"].includes(type)) {
                getDetail(this.form.id).then((res) => {
                    this.form = res.data.data;
                });
            }
            done();
        },
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
        },
        refreshChange() {
            var params = {};
            this.onLoad(this.page, params);
        },
        onLoad(page, params = {}) {
            this.loading = true;
            console.log(params)
            todayOrderProcessPage(
                page.currentPage,
                page.pageSize,
                Object.assign(params, this.query)
            ).then((res) => {

                const data = res.data.data;
                this.page.total = data.total;
                this.data = data.records;

                this.loading = false;
                this.selectionClear();
            });
        },
    },
};
</script>
