<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" placeholder="请输入追踪Id"/>
                            <Field label="应用名称" prop="appName" v-model="form.appName" placeholder="请输入应用名称"/>
                            <Field label="实例IP" prop="hostName" v-model="form.hostName" placeholder="请输入实例IP"/>
                            <Field label="请求者IP" prop="requestIp" v-model="form.requestIp" placeholder="请输入请求者IP"/>
                            <Field label="请求方式" prop="method" v-model="form.method" placeholder="请输入请求方式"/>
                            <Field label="用户浏览器UA" prop="ua" v-model="form.ua" placeholder="请输入用户浏览器UA"/>
                            <Field label="请求URI" prop="uri" v-model="form.uri" placeholder="请输入请求URI"/>
                            <Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" />
                            <Field label="持续时间" prop="duration" v-model="form.duration+'ms'" placeholder="请输入持续时间，单位毫秒"/>
                             <Field label="请求参数" :span="22" prop="requestData" v-model="form.requestData" type="textarea" placeholder="请输入请求参数，json序列化"/>
                           
                            <Field label="响应结果" :span="22" prop="responseData" v-model="form.responseData" rows=6 type="textarea" placeholder="请输入响应结果"/>
                            

            </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>
