<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            size="70%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                            <Field label="追踪Id" prop="traceID" v-model="form.traceID" />
                            <Field label="应用名称" prop="appName" v-model="form.appName" />
                            <Field label="实例IP" prop="hostName" v-model="form.hostName" />
                            <Field label="请求者IP" prop="requestIp" v-model="form.requestIp" />
                            <Field label="请求方式" prop="method" v-model="form.method" />
                            <Field label="用户浏览器UA" prop="ua" v-model="form.ua" />
                            <Field label="请求URI" prop="uri" v-model="form.uri"/>
                            <Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" />
                            <Field label="持续时间" prop="duration" v-model="form.duration+'ms'" />
                             <Field label="请求参数" :span="22" prop="requestData" v-model="form.requestData" textareaSize="true" type="textarea" />
                           
                            <Field label="响应结果" :span="22" prop="responseData" v-model="form.responseData" textareaSize="{ minRows: 2, maxRows:20 }" type="textarea" />
                                
                            

            </el-row>

        </el-form>

    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        name: "AccessLogDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("access/log")
        },
        data() {
            return {
                row:6,
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "访问日志",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                ],
                toDate:[
                    "logTime",
                ],
                // 表单校验
                rules: {
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="access/log/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改访问日志";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "access/log/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增访问日志";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="access/log/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "访问日志详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    traceID : "",
                    appName : "",
                    hostName : "",
                    logLevel : "",
                    requestIp : "",
                    method : "",
                    ua : "",
                    uri : "",
                    requestParam : "",
                    response : "",
                    logTime : null,
                    duration : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
