<template>
  <el-container>
    <el-dialog
      title="查看地址"
      :visible.sync="dialogVisible"
      append-to-body
      :close-on-click-modal="false"
      class="urgent-text"
    >
      <el-form v-form class="copy-form">
        <ht-form-item label="接口地址" label-width="120px">
          <el-input v-model="manageUrl" :disabled="true"/>
          <el-button
            class="copy-btn"
            type="text"
            v-clipboard:copy="manageUrl"
            v-clipboard:success="onCopy"
            v-clipboard:error="onError"
          >复制地址</el-button>
        </ht-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" icon="el-icon-close" size="mini" @click="cloase()">关闭</el-button>
      </div>
    </el-dialog>
  </el-container>
</template>

<script>
export default {
  name: "portal-inteface-address",
  data() {
    return {
      dialogVisible: false,
      alias: "",
      basicUrl: "",
      manageUrl: "",
    };
  },
  mounted() {
    this.basicUrl = window.context.portal;
  },
  methods: {
    showDialog(alias) {
      this.alias = alias;
      this.manageUrl = this.basicUrl + "/portal/portalInterfaceManager/v1/" + "data_" + alias;
      this.dialogVisible = true;
    },
    // 复制成功时的回调函数
    onCopy(e) {
      this.$message.success("内容已复制到剪切板！");
    },
    // 复制失败时的回调函数
    onError(e) {
      this.$message.error("抱歉，复制失败！");
    },
    cloase() {
      this.dialogVisible = false;
    }
  }
};
</script>
<style lang="scss" scoped>
>>> .el-dialog {
  width: 700px;
  height: 300px;
}
>>> .el-dialog__header {
  border-bottom: 1px solid darkgrey;
}
>>> .el-dialog__body {
  padding: 0px;
  height: 380px;
}
>>> .el-dialog__footer {
  position: absolute;
  text-align: right;
  bottom: 0px;
  left: 0px;
  right: 0px;
}
>>> .copy-form {
  margin: 8px 15px;
}
>>> .copy-btn {
  margin-left: 15px;
  padding: 3px 8px;
}

/deep/ .el-form-item__content > .el-input--small{
    width: 450px;
}
</style>
