<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            size="70%">
        <el-form ref="form" :model="form" :rules="rules" label-width="140px">
            <el-row>
                            <Field label="追踪Id"  prop="traceID" v-model="form.traceID" placeholder="请输入追踪Id"/>
                            <Field label="应用名称" prop="appName" v-model="form.appName" placeholder="请输入应用名称，宿主客户端运行唯一标识。"/>
                            <Field label="主机名" prop="hostName" v-model="form.hostName" placeholder="请输入主机名"/>
                            <Field label="消息标识" prop="message" v-model="form.message"  placeholder="请输入消息标识，如用户登录异常。"/>
                            <Field label="客户端使用平台" prop="platform" v-model="form.platform" type="select" :enumData="dict.platform" placeholder="请选择当前客户端使用平台"/>
                            <Field label="异常函数名" prop="culprit" v-model="form.culprit"  placeholder="请输入主要导致异常函数或方法调用名称"/>
                            <Field label="异常事件标记。" prop="tags" v-model="form.tags" placeholder="请输入异常事件标记，多个逗号分隔。用以归集异常事件种类。"/>
                            <Field label="告警等级" prop="level" v-model="form.level" type="select" :enumData="dict.level" placeholder="请选择等级"/>
                            <Field label="环境变量信息" prop="environment" v-model="form.environment"  placeholder="请输入客户端运行环境变量信息"/>
                            <Field label="版本信息" prop="releaseVersion" v-model="form.releaseVersion" placeholder="请输入客户端运行版本信息"/>
                            <Field label="指纹标识" prop="fingerprint" v-model="form.fingerprint" placeholder="请输入指纹标识，对于相同异常事件归集数量使用。"/>
                            <Field label="线程号" prop="threadNo" v-model="form.threadNo" placeholder="请输入线程号"/>
                            <Field label="异常事件数量" prop="checkNum" v-model="form.checkNum" placeholder="请输入针对同一个异常事件，数量加1"/>
                                 <Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" />
                            <Field label="异常堆栈信息" :span="24" prop="errorStack" v-model="form.errorStack" rows="8" type="textarea" placeholder="请输入异常堆栈信息"/>
                            <Field label="上下文信息" :span="24" prop="context" v-model="form.context" type="textarea" rows="6" placeholder="请输入上下文信息，如js中发送异常事件，定位源码中信息。"/>
                            <Field label="扩展信息" :span="24" prop="extra" v-model="form.extra" type="textarea" placeholder="请输入扩展信息"/>
                      

            </el-row>
        </el-form>

    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
//     import hljs from "highlight.js/lib/highlight";
// import "highlight.js/styles/github-gist.css";
// hljs.registerLanguage("java", require("highlight.js/lib/languages/java"));
    export default {
        name: "ErrorLogDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("error/log")
        },
        data() {
            return {
                // 遮罩层
                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 ="error/log/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改异常日志";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "error/log/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增异常日志";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="error/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 : "",
                    message : "",
                    platform : "java",
                    culprit : "",
                    tags : "",
                    level : "",
                    environment : "",
                    releaseVersion : "",
                    fingerprint : "",
                    threadNo : "",
                    checkNum : null,
                    errorStack : "",
                    context : "",
                    extra : "",
                    logTime : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
