<template>
  <div class="app-container" style="background: #f5f6f8;">
    <div class="fx-biz-container">
      <div class="panel-header">
        <div class="header-left">
          <div class="header-title">基础信息</div>
          <div class="header-tip"></div>
        </div>
      </div>
      <div class="panel-wrapper">
        <div class="basic-content">
          <div class="fx-row-info-panel">
            <div class="label">企业名称</div>
            <div class="content" v-if="!showComp">
              <span class="team-name-wrapper">{{ tenantData.name }}</span>
              <el-button type="text" style="padding: 0 16px;" @click="editComp()">
                <span>修改</span>
              </el-button>
            </div>
            <div class="content" v-if="showComp">
              <div style="display: flex;">
                <el-input v-model="newCompanyName" style="width: 600px;">
                </el-input>
                <el-button size="mini" type="primary" @click="saveComp()" style="margin-left: 20px;">确定</el-button>
                <el-button size="mini" @click="showComp = false">取消</el-button>
              </div>

            </div>
          </div>
          <div class="fx-row-info-panel">
            <div class="label">账号模式</div>
            <div class="content">
              <div class="fx-corp-account-mode">
                <div class="account-mode-header">
                  <div class="fx-corp-mode-tag">
                    <div class="x-tag mode-tag single-line is-rounded-rec has-border" title="公共模式">
                      <div class="text-wrapper">{{ tenantData.accountMode==1 ? '公共模式' : '集成模式' }}</div>
                    </div>
                  </div>
                </div>
                <div class="corp-detail-wrapper">
                  <div class="info-item">
                    <span class="item-name">CorpID</span>
                    <span class="item-value">
                      <span>{{ tenantData.corpId }}</span>
                      <i class="el-icon-document-copy copy-btn" style="cursor: pointer;
    font-size: 16px;
    margin-left: 16px;"></i>
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { updateTenant,tenantInfo } from "@/api/system/tenant";
import ClipboardJS from 'clipboard'
export default {
  components: {
  },
  data() {
    return {
      // 租户信息
      showComp:false,
      newCompanyName:'',
      tenantData: {},
    };
  },
  created() {
    this.getTenantInfo();
  },
  mounted() {
    const clipboard = new ClipboardJS('.copy-btn', {
      text: trigger => {
        this.$message({
          message: '复制成功',
          type: 'success'
        });
        return this.tenantData.corpId;
      }
    })
    clipboard.on('error', e => {
      this.$message.error('复制失败')
    })
  },
  methods: {
    editComp() {
      this.showComp = true;
      this.newCompanyName = this.tenantData.name;
    },
    saveComp() {
      updateTenant({name:this.newCompanyName,status:0}).then(response => {
        this.showComp = false;
        this.$modal.msgSuccess("修改成功");
        this.getTenantInfo();
      });
    },
    /** 当前租户信息 */
    getTenantInfo() {
      tenantInfo().then(response => {
        this.tenantData = response.data;
        console.log(this.tenantData);
      })
    },
  }
};
</script>
<style scoped lang="scss">
.fx-biz-container {
  margin-bottom: 20px;
  font-size: 14px;
}

.fx-biz-container .panel-header,
.fx-biz-container .panel-header .header-left {
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}

.fx-biz-container .panel-header {
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 32px;
}

.fx-biz-container .panel-wrapper {
  background: #fff;
  border-radius: 6px;
  padding: 20px;
}

.fx-biz-container .panel-wrapper .fx-row-info-panel:first-child {
  padding-top: 0;
}

.fx-biz-container .panel-wrapper .fx-row-info-panel {
  min-height: 36px;
  padding: 16px 0;
}

.fx-row-info-panel {
  border-bottom: 1px solid #ebecee;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  min-height: 70px;
}

.fx-biz-container .panel-wrapper .fx-row-info-panel .label {
  background: transparent;
  font-weight: 500;
  margin-right: 48px;
  padding: 6px 0;
  text-align: left;
  width: 140px;
}

.fx-row-info-panel .label {
  -webkit-box-flex: 0;
  background-color: #f5f6f8;
  -ms-flex: none;
  flex: none;
  padding: 25px 0;
  text-align: center;
  width: 145px;
}

.fx-biz-container .panel-wrapper .fx-row-info-panel .content {
  padding: 0;
}

.fx-row-info-panel .content {
  -webkit-box-flex: 1;
  -ms-flex: auto;
  flex: auto;
  line-height: 36px;
  overflow: hidden;
  padding: 17px 20px;
}

.fx-corp-account-mode {
  display: inline-block;
}

.fx-corp-account-mode .account-mode-header {
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  align-items: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.fx-corp-mode-tag {
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
}

.fx-corp-mode-tag .mode-tag {
  background: #e6f8f5;
  border-color: #00b899;
  cursor: default;
}

.x-tag.single-line {
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.x-tag.has-border {
  border-color: #D7D9DC;
}

.x-tag.is-rounded-rec {
  border-radius: 4px;
}

.x-tag {
  -webkit-box-align: start;
  -ms-flex-align: start;
  align-items: flex-start;
  background: rgba(5, 30, 80, .04);
  border: 1px solid transparent;
  border-radius: 12px;
  color: #141E31;
  cursor: pointer;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  font-size: 14px;
  line-height: 22px;
  max-width: 100%;
  overflow: hidden;
  padding: 0 6px;
  -webkit-transform-origin: left;
  transform-origin: left;
  white-space: nowrap;
}

.fx-corp-account-mode .corp-detail-wrapper {
  border: 1px solid #d7d9dc;
  border-radius: 4px;
  margin-top: 16px;
  padding: 20px;
}

.fx-corp-account-mode .corp-detail-wrapper .info-item:last-child {
  margin-bottom: 0;
}

.fx-corp-account-mode .corp-detail-wrapper .info-item {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  line-height: 20px;
  margin-bottom: 16px;
}

.fx-corp-account-mode .corp-detail-wrapper .info-item .item-name {
  -webkit-box-flex: 0;
  word-wrap: break-word;
  -ms-flex: none;
  flex: none;
  width: 200px;
  word-break: break-word;
}

.fx-corp-account-mode .corp-detail-wrapper .info-item .item-value {
  -webkit-box-flex: 1;
  word-wrap: break-word;
  -ms-flex: auto;
  flex: auto;
  word-break: break-word;
}

.fx-biz-container .panel-wrapper .fx-row-info-panel:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
</style>