<template>
  <div class="app-container">
    <div>
      <TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="tableList" @fnRenderList="getList">
        <template #tempCopy="{ row, column}">
          {{row.clientId}}<el-link :underline="false" icon="el-icon-document-copy" title="复制" v-clipboard:copy="row.clientId" v-clipboard:success="clipboardSuccess" style="margin-left: 10px;color: #409EFF;"></el-link>
        </template>
        <template #tempResult="{row, column}">
          <i v-if="row.resultFlag === 1" class="el-icon-check" style="color: #2ba870;font-weight: 700;"></i>
          <i v-if="row.resultFlag === 0" class="el-icon-close" style="color: #f00;font-weight: bold;"></i>
        </template>
      </TableList>
    </div>
    <div style="float: right;margin-top: 20px;">
      <el-button @click="goBack">返回</el-button>
    </div>
  </div>
</template>

<script>
  import TableList from '@/components/table/index.vue';
  import {getScriptResultList} from "@/api/disRevenue/resource"
  export default {
    name: "resultView",
    components: {TableList},
    data() {
        return {
          paramsData: {},
          // 列显隐信息
          columns: {
            id: { label: `ID`,width: '50'},
            clientId: { label: `ClientID`, minWidth: '220', visible: true, slotName: 'tempCopy'},
            resultFlag: {label: `执行结果`, minWidth: '80', visible: true, slotName: 'tempResult'},
            content: {label: `结果详情`, minWidth: '150', visible: true},
            createTime: {label: `结果返回时间`, minWidth: '150', visible: true},
          },
          config: {colTopHiddenIcon: true},
          tableList: [],
          queryParams: {
            pageNum: 1,
            pageSize: 10,
            total: 0
          }
        }
    },
    created() {
      this.paramsData = this.$route && this.$route.query;
      this.getList();
    },
    methods: {
      /** 复制代码成功 */
      clipboardSuccess() {
        this.$modal.msgSuccess("复制成功")
      },
      getList() {
        getScriptResultList(Object.assign({}, this.queryParams,{scriptId: this.paramsData.id})).then(res => {
          this.tableList = res.rows;
          this.queryParams.total = res.total;
        });
      },
      goBack() {
        this.$router.push("/resource/serverScriptStrat");
      },
    }
  }
</script>

<style scoped>

</style>
