<!--
 * @Title: 
 * @Description: 维修任务填报内容列表
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
    <div>
        <basic-container>
            <avue-crud :option="option" :table-loading="loading" :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"
                @before-open="beforeOpen">
                <template slot-scope="{ row }" slot="menu">
                    <el-button type="text" size="small" @click="openDetail(row)">查看详情
                    </el-button>
                    <!-- <el-button type="text" size="small" @click="openPicture(row)"
                                            >图片
                                          </el-button> -->
            </template>
        </avue-crud>
    </basic-container>
    <el-dialog title="维修处理详情" :visible.sync="detailDialog" v-if="detailDialog" width="80%" :close-on-click-modal="false"
        append-to-body>
        <checkorderprocessdetail :id="processId" ref="checkorderprocessdetail"></checkorderprocessdetail>
    </el-dialog>
    <!-- <el-dialog
                                      title="图片"
                                      :visible.sync="pictureDialog"
                                      width="80%"
                                      :close-on-click-modal="false"
                                      append-to-body
                                    >
                                      <record-picture :id="id" ref="recordPicture"></record-picture>
                                    </el-dialog> -->
    </div>
</template>

<script>
import { getPage, getDetail } from "@/api/business/order/process.js";

import checkorderprocessdetail from "./checkorderprocessdetail.vue";
export default {
    components: { checkorderprocessdetail },
    name: 'swp',
    data() {
        return {
            pictureDialog: false,
            detailDialog: false,
            processId: "",
            editForm: {},
            editDialog: 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: false,
                searchMenuSpan: 6,
                addBtn: false,
                border: true,
                index: true,
                editBtn: false,
                delBtn: false,
                menuWidth: 160,
                dialogType: "drawer",
                dialogClickModal: false,
                column: [
                    {
                        label: "维修状态",
                        prop: "orderStatusKey",
                        span: 12,
                        props: {
                            label: 'dictValue',
                            value: 'id'
                        },
                        dicUrl: '/api/galaxy-system/dict-biz/dictionary?code=rtu_check_order_status',
                    },
                    {
                        label: "反馈时间",
                        prop: "createTime",
                        span: 12,
                    },
                    {
                        label: "处理人",
                        prop: "orderProcessUserName",
                        span: 12,
                    },
                    {
                        label: "处理说明",
                        prop: "processDesc",
                        span: 12,
                    },
                ],
            },
            data: [],
        };
    },
    props: {
        id: {
            type: [String],
            required: true
        },
    },
    create() {
        this.init();
    },
    methods: {
        init() {

            this.onLoad(this.page);
            this.$refs.crud.doLayout();
        },
        openDetail(item) {
            this.processId = item.id;
            this.detailDialog = true;
            this.$nextTick(() => {
                this.$refs["checkorderprocessdetail"].init();
            });
        },
        openPicture() {
            this.pictureDialog = true;
            this.$nextTick(() => { });
        },

        searchReset() {
            this.query = {};
            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() {
            this.onLoad(this.page, this.query);
        },
        onLoad(page, params = {}) {
            this.loading = true;
            params['id'] = this.id;
            getPage(
                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>
