<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 :span="12" label="追踪Id"  prop="traceID" v-model="form.traceID" />
                            <Field label="应用名称" prop="appName" v-model="form.appName" />
                            <Field label="主机名" prop="hostName" v-model="form.hostName" />
                            <Field label="客户端使用平台" prop="platform" v-model="form.platform" type="select" :enumData="dict.platform" />
                            <Field label="异常函数名" prop="culprit" v-model="form.culprit" />
                            <Field label="异常事件标记" prop="tags" v-model="form.tags" />
                            <Field label="告警等级" prop="level" v-model="form.level" type="select" :enumData="dict.level" />
                            <Field label="环境变量信息" prop="environment" v-model="form.environment"  />
                            <Field label="版本信息" prop="releaseVersion" v-model="form.releaseVersion" />
                            <Field label="指纹标识" prop="fingerprint" v-model="form.fingerprint" />
                            <Field label="线程号" prop="threadNo" v-model="form.threadNo" />
                            <Field label="异常事件数量" prop="checkNum" v-model="form.checkNum"/>
                            <Field label="日志时间" prop="logTime" v-model="form.logTime" type="date" />
                             <Field label="消息标识" :span="24" prop="message" v-model="form.message"   textareaSize="true" type="textarea" />
                              <Field label="异常函数名" :span="24" prop="culprit" v-model="form.culprit"  textareaSize="true" type="textarea" />
                            <Field label="异常堆栈信息" :span="24" prop="errorStack" v-model="form.errorStack" textareaSize="true" type="textarea"/>
                            <Field label="上下文信息" :span="24" prop="context" v-model="form.context" type="textarea" rows="6" />
                            <Field label="扩展信息" :span="24" prop="extra" v-model="form.extra" type="textarea" />
                      

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