<!--
 * @Title: 
 * @Description: 无信号上报列表
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
    <div>
        <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, index }" slot="menu">
                            <el-button type="text" size="small" @click="openReportDetail(row)"
                                icon="el-icon-edit-outline">维修详情
                            </el-button>
                            <el-button
                                v-if="permission.checkorder_photo_submit_close == 1 && row.photoSupplementSubmitStatus == 0"
                                type="text" size="small" @click="toPhotoSubmit(row)" icon="el-icon-upload2">图片补交
                            </el-button>
                            <el-button
                                v-if="permission.checkorder_photo_submit_close == 1 && row.photoSupplementSubmitStatus === 0"
                                type="text" size="small" style="color:lightcoral" @click="closePhotoSubmit(row)"
                                icon="el-icon-circle-close">关闭问题
                            </el-button>
                        </template>
                    </avue-crud>
                </basic-container>
            </el-col>
        </el-row>
        <el-drawer :visible.sync="recordDialog" v-if="recordDialog" title="维修详情" direction="rtl" size="50%"
            append-to-body="true">
            <div slot="title" class="header-title">
                <span class="name">{{ dialogTitle }}</span>
            </div>
            <checkorderprocessdetail :orderId="orderId" ref="checkorderprocessdetail"></checkorderprocessdetail>
        </el-drawer>
        <el-drawer title="图片补交操作" :visible.sync="checkorderphotosubmitDialog" v-if="checkorderphotosubmitDialog"
            :size="drawerSize" :direction="direction" :close-on-click-modal="false" append-to-body>
            <checkorderphotosubmit :id="id" ref="checkorderphotosubmit" :visible.sync="checkorderphotosubmitDialog">
            </checkorderphotosubmit>
        </el-drawer>
    </div>
</template>
<script>

import {
    getNoNetworkSignalReportPage, closeNonetworksignalPhotoSubmit
} from "@/api/business/order/process.js";


import { mapGetters } from "vuex";
import checkorderprocessdetail from "../checkorderprocessdetail.vue";
import checkorderphotosubmit from "./checkorderphotosubmit.vue";
export default {
    components: {
        getNoNetworkSignalReportPage,
        checkorderprocessdetail,
        closeNonetworksignalPhotoSubmit,
        checkorderphotosubmit
    },
    data() {
        return {
            id: 0,
            orderId: 0,
            drawerSize: '50%',
            recordDialog: false,
            checkorderphotosubmitDialog: false,
            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,
                border: true,
                index: true,
                editBtn: false,
                delBtn: false,
                viewBtn: false,
                menuWidth: 300,
                dialogType: "drawer",
                columnBtn: false,
                dialogClickModal: false,
                column: [
                    {
                        label: "测站编码",
                        prop: "rtuCode",
                        span: 12,
                        search: true,
                        searchSpan: 4,
                        width: 120,
                    },
                    {
                        label: "测站名称",
                        prop: "rtuName",
                        span: 12,
                        search: true,
                        searchSpan: 4,
                        // html: true,
                        // formatter: (val) => {
                        //     if (val.rtuName) {
                        //         return '<b>' + val.rtuName + '</b>/' + '<b style="color:grey">' + val.rtuCode + '</b>'
                        //     } else {
                        //         return '<b>' + val.rtuName + '</b>'
                        //     }
                        // }
                    },
                    {
                        label: "行政区",
                        prop: "adCity",
                        span: 12,
                        editDisplay: false,
                        addDisplay: false,
                        html: true,
                        formatter: (val) => {
                            if (val.adCity && val.adDist) {
                                return '<b>' + val.adCity + '</b>/' + '<b>' + val.adDist + '</b>'
                            } else {
                                return '<b>' + val.adCity + '</b>'
                            }
                        }
                    },

                    {
                        label: "反馈时间",
                        prop: "createTime",
                        span: 12,
                    },
                    {
                        label: "处理人",
                        prop: "orderProcessUserName",
                        span: 12,
                    },
                    {
                        label: "处理说明",
                        prop: "processDesc",
                        span: 12,
                    },
                    {
                        label: "图片提交状态",
                        prop: "photoSupplementSubmitStatus",
                        span: 12,
                        slot: true,
                        width: 120,
                        html: true,
                        formatter: (val) => {
                            if (val.photoSupplementSubmitStatus == 0) {
                                return '<b style="color:red">图片补交中</b>'
                            } else if (val.photoSupplementSubmitStatus == 1) {
                                return '<b style="color:blue">图片补交完成</b>'
                            }
                        }
                    },
                ],
            },
            data: [],
        };
    },
    computed: {
        ...mapGetters(["userInfo", "permission"]),
        permissionList() {
            return {
                photoSubmitCloseBtn: this.vaildData(this.permission.checkorder_photo_submit_close, false),
            };
        },
    },
    created() {

    },
    watch: {
        // 'editForm.planId': {
        //     handler(val) {
        //         if (val != '' && val != undefined && val != null) {
        //             this.planId = val;
        //              this.$message.success(this.planId)
        //         }
        //     },
        //     immediate: true
        // }
    },
    methods: {
        toOss(path) {
            console.log("oss " + path);
            return this.website.ossServer + path;
        },
        toPhotoSubmit(item) {
            console.log(JSON.stringify(item));
            this.checkorderphotosubmitDialog = true;
            this.id = item.id;
            this.$nextTick(() => {
                this.$refs["checkorderphotosubmit"].init();
            });
        },
        closePhotoSubmit(item) {
            console.log(JSON.stringify(item));
            this.$confirm("确认完成图片补交操作？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    closeNonetworksignalPhotoSubmit({ id: item.id }).then((res) => {
                        if (res.data.code == 200) {
                            this.$message({
                                type: "success",
                                message: "操作成功",
                            });
                            this.refreshChange();
                        }
                    });

                })
                .catch(() => { });

        },
        openReportDetail(item) {
            //this.$message.success(JSON.stringify(item))
            //         } 
            this.recordDialog = true;
            this.orderId = item.orderId;
            this.$nextTick(() => {
                this.$refs["checkorderprocessdetail"].init();
            });
        },
        searchReset() {
            this.query = {};
            this.query['adCode'] = this.treeCode;
            this.page.currentPage = 1;
            this.onLoad(this.page);
        },
        searchChange(params, done) {
            console.log(JSON.stringify(params))
            this.query = params;
            this.page.currentPage = 1;
            this.onLoad(this.page);
            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;
            getNoNetworkSignalReportPage(
                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>

<style  lang="scss" scoped>
.common-dialog {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;

    .el-dialog {
        margin: 0 auto !important;
        position: relative;
        overflow: hidden;

        .el-dialog__header {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            width: 100%;
            height: 60px;
            z-index: 1;
        }

        .el-dialog__body {
            position: relative;
            left: 0;
            top: 60px;
            bottom: 0;
            right: 0;
            padding: 0;
            width: 100%;
            overflow: hidden;
            overflow-y: auto;
            max-height: 90vh;
            padding-top: 80px;
            padding-bottom: 100px;
            z-index: 1;
        }

        .el-dialog__footer {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            width: 100%;
            height: 80px;
            z-index: 1;
        }
    }
}
</style>
