<template>
  <div>
    <el-form label-position="top" :model="data" v-loading="loading" ref="form ">
      <el-row>
        <el-col :span="12 ">
          <el-form-item label="服务器地址 " prop="svrIp ">
            <el-input v-model="data.svrIp " readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12 ">
          <el-form-item label="服务器名称 " prop="svrName ">
            <el-input v-model="data.svrName " readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12 ">
          <el-form-item label="处理代码 " prop="respCode ">
            <el-input v-model="data.respCode " readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12 ">
          <el-form-item label="处理描述 " prop="respDesc ">
            <el-input v-model="data.respDesc " readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12 ">
          <el-form-item label="服务定义 " prop="reqIp ">
            <el-input v-model="data.servDefn " readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12 ">
          <el-form-item label="服务描述 " prop="acttype ">
            <el-input v-model="data.servDesc " readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12 ">
          <el-form-item label="操作开始时间 " prop="actSta ">
            <el-input v-model="servSta " readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12 ">
          <el-form-item label="操作结束时间 " prop="actEnd ">
            <el-input v-model="servEnd " readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="会话标识 " prop="sesId ">
        <el-input v-model="data.sesId " readonly></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  import BaseApi from '@/api/base/BaseApi';

  export default {
    props: {
      // 一定要暴露一个UUID属性,用来做编辑操作.
      uuid: String,
      // 暴露出去一个属性用来显示服务器校验失败错误
      error: Object
    },
    data() {
      return {
        LogsServLogApi: BaseApi('/logs/LogsServLog'),
        loading: false,
        data: Object.assign({}),
        servSta: "",
        servEnd: ""
      };
    },
    watch: {
      uuid(val) {
        this.loadData();
      }
    },
    mounted() {
      // 最开始显示的时候要加载数据
      this.loadData();
    },
    methods: {
      // 因为表单里面没有按钮,所以需要暴露方法
      // 提供一个校验方法 ,
      validate() {
        return this.$refs.form.validate().then(() => this.data);
      },
      // 加载数据方法,如果有UUID,就加载数据,如果没有,就重置表单
      async loadData() {
        if (!this.uuid) {
          this.$refs.form.resetFields();
        } else {
          try {
            this.loading = true;
            this.data = await this.LogsServLogApi.doGet(this.uuid);
            this.servSta = this.formatterDateTime(
              null,
              null,
              this.data.servSta
            );
            this.servEnd = this.formatterDateTime(
              null,
              null,
              this.data.servEnd
            );
          } finally {
            this.loading = false;
          }
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
</style>
