<style>
  .groupEmpower .mimitBody {
    padding: 20px;
    background-color: #fff;
    margin: 10px 0 20px 0;
    display: table;
    width: 100%;
  }

  .groupEmpower .mimitList {
    margin-bottom: 15px;
    display: flex;
    flex-direction: row;
  }

  .groupEmpower .mimitBody .el-tag {
    min-width: 120px;
    padding-right: 50px;
  }

  .groupEmpower .el-button--small {
    padding: 9px 25px;
  }

</style>
<template>
  <div class="groupEmpower">
    <div class="CommonHeader">集团授权</div>
    <div class="mimitBody">
      <div class="el-col el-col-12">
        <el-form :model="msg" :rules="rules" ref="msg" label-width="150px">
          <el-form-item label="集团域名" size="small" prop="DomainName">
            <el-input type="text" size="small" :disabled="msg.Status==3 || !msg.Status ? false: true" maxlength="200"
              v-model="msg.DomainName">
            </el-input>
          </el-form-item>
          <el-form-item label="审核状态" size="small">
            <span v-if="msg.Status ==1 ">待审核</span>
            <span v-if="msg.Status ==2 ">已审核</span>
            <span v-if="msg.Status ==3 ">已拒绝</span>
            <span v-if="msg.Status ==4 ">已作废</span>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <el-button size="small" type="primary" @click="submitForm('msg')" v-if=" (msg.Status==3)  || !msg.Status">保存
    </el-button>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        msg: {},
        rules: {
          DomainName: [{
            required: true,
            message: "请输入集团域名",
            trigger: "blur"
          }],

        }
      };
    },
    created() {},
    methods: {
      //获取集团授权信息
      GetWeiXinAppConfig() {
        // type 1-个人，2-集团
        this.assetsApipost(
          "/api/Authorize/GetAuthorizeModel", {
            Type: 2
          },
          res => {
            if (res.data.resultCode == 1) {
              if (res.data.data != null) {
                this.msg = res.data.data
              }

            } else {
              this.Info(res.data.message);
            }
          }
        );
      },
      submitForm(msg) {
        this.$refs[msg].validate(valid => {
          if (valid) {
            this.assetsApipost(
              "/api/Authorize/SetAuthorize", {
                ID: this.msg.ID ? this.msg.ID : 0,
                DomainName: this.msg.DomainName,
                Account: '',
                Password: '',
                Type: 2
              },
              res => {
                if (res.data.resultCode == 1) {
                  this.Success(res.data.message);
                  this.GetWeiXinAppConfig()
                } else {
                  this.Info(res.data.message);
                }
              }
            );
          } else {
            return false;
          }
        });
      }
    },
    mounted() {
      this.GetWeiXinAppConfig();
    }
  };

</script>
