<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-10-21 14:27:29
 * @LastEditors: 无尘
 * @LastEditTime: 2019-10-24 17:14:36
 -->

<!--
<review-result
  :resultShow="resultShow"
  @showResultDetail="showResultDetail"
  @hideResultDialog="hideResultDialog">
</review-result>

import reviewResult from '@/components/review/review-result.vue'
 -->
<template>
  <div v-show="customDialog">
    <el-dialog class="edit-dialog" title="提示" :visible.sync="customDialog" width="600px" :before-close="handleClose">
      <div class="edit-dialog-body">
        <div class="result-content">
          <span>{{ resultText }}</span> <el-button type="text" @click="showDetail">查看详情</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getRequest } from '@/api/api';
import errMsg from '@/common/js/error';
export default {
  name: 'record-list',
  props: {
    resultText: {
      type: String,
      default: ''
    },
    resultShow: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      customDialog: this.resultShow, // 弹框显示
      tableData: [
        /* {
          interfaceVersionId: '1',
          version: '测试',
          remark: '描述内容',
          createTime: 1564455643252
        } */
      ],
      pageSize: 5,
      currentPage: 1,
      totalCount: 0
    };
  },
  methods: {
    /**
     *   关闭
     */
    handleClose(done) {
      const that = this;
      done();
      that.hideDialog();
    },
    /**
     *  取消
     */
    customCancel() {
      const that = this;
      that.hideDialog();
    },
    hideDialog() {
      const that = this;
      that.customDialog = false;
      that.$emit('hideResultDialog');
    },
    /**
     *  显示详情
     */
    showDetail() {
      const that = this;
      that.$emit('showResultDetail');
    },
    /**
     *  获取数据
     */
    getData() {
      const that = this;
      let para = {
        pageNum: that.currentPage,
        pageSize: that.pageSize,
        version: that.formData.version,
        sceneCode: that.formData.sceneCode,
        interfaceId: that.formData.interfaceId
      };
      getRequest('/gateway-manage/page-api-publish-record', para)
        .then(res => {
          let resData = res.data;
          if (resData.code == '0000') {
            that.tableData = resData.result.result || [];
            that.totalCount = resData.result.totalCount;
            return;
          }
          errMsg.errorMsg(resData);
        })
        .catch(function(error) {
          that.$message.error({
            duration: 1000,
            message: error.message
          });
        });
    }
  },
  watch: {
    resultShow: function(newData, oldData) {
      const that = this;
      that.customDialog = newData;
    }
  },

  /* 接收数据 */
  mounted() {
    const that = this;
    that.customDialog = that.resultShow;
  }
};
</script>

<style lang="less" scoped>
.bg-82C5FF {
  background: #82c5ff;
}
.edit-dialog {
  /deep/ .el-dialog__body {
    padding: 25px 20px 17px 20px;
    min-height: 54px;
  }

  /deep/ .el-dialog__footer {
    border: none;
    padding-top: 3px;
  }

  &__title {
    width: 100%;
    height: 38px;
    padding: 12px 15px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    background: rgba(235, 238, 245, 1);
  }

  .el-alert--info {
    width: 400px;
    font-size: 14px;
    color: #606266;
    background: #e6f7ff;
    border: 1px solid rgba(145, 213, 255, 1);
  }
  .el-icon-info {
    width: 12px;
    font-size: 12px;
    color: #1890ff;
  }
  .el-form {
    margin-top: 40px;
  }
}
</style>
