<!-- 交互日志管理页面 -->
<template>
  <div>
    <PageTable ref="dataTable" v-loading="loading" :auto-load="false" :page-size="10" @load-data="dataTableLoad" :data="table.data" highlight-current-row stripe border>
      
      <el-table-column type="expand">
        <template slot-scope="scope">
          <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap;white-space: -o-pre-wrap; word-wrap: break-word;">{{scope.row.opdata}}</pre>
        </template>
      </el-table-column>
      <el-table-column prop="opname" label="操作表名" show-overflow-tooltip></el-table-column>
      <el-table-column prop="optype" label="操作类型" :formatter="optypeFormat" show-overflow-tooltip></el-table-column>
    </PageTable>
  </div>
</template>
<script>
import OperDataAPI from "@/api/base/logs/LogsOper";

export default {
  props: {
    uuid: null,
    flag: null
  },
  data() {
    return {
      loading: false,
      table: {
        data: []
      },
      detailedData: false,
      data: {},
      opdata: []
    };
  },
  mounted() {
    this.loadInfo(this.flag, this.uuid);
  },
  watch: {
    uuid(uuid) {
      this.loadInfo(this.flag, this.uuid);
    }
  },
  methods: {
    //  加载数据
    loadInfo(flag, uuid) {
      if (flag === 1) {
        this.$refs.dataTable.load({ opid: uuid });
      } else if (flag === 2) {
        this.$refs.dataTable.load({ seid: uuid });
      }
    },
    dataTableLoad(params, resolve) {
      this.loading = true;
      OperDataAPI.queryLogsOperData(params)
        .then(resolve) //  让表格解析你提供的数据 (主要解析页码等)
        .then(respData => {
          this.table.data = respData.datarows;
          this.loading = false;
        });
    },
    optypeFormat: function(row, column) {
      var par = row[column.property];
      var stat = "";
      //没有字典缓存 则刷新
      if (this.sysCode.operDataOpType === undefined) {
        this.refresh();
      }
      this.sysCode.operDataOpType.forEach(val => {
        if (par == val.value) {
          stat = val.label;
          return;
        }
      });
      return stat;
    },
    refresh() {
      this.$store.dispatch("base/refreshSysCode", "operDataOpType");
    }
  }
};
</script>
<style>
.showDataDialog {
  word-wrap: break-word;
  word-break: break-all;
  overflow: hidden;
}
</style>

