<template>
  <div class="newrole">
    <p class="dialog-header">
      <span>新建单位</span>
    </p>
    <div class="company-content" style="text-align: center; margin-top: 4px;">
      <p class="new">
        <span class="addVal">
            <span>单位名称：</span>
            <el-input v-model="name" size="medium" placeholder="请输入"></el-input>
        </span>
        <span class="addVal" style="width: 450px;">
            <span>单位类别：</span>
            <el-radio-group v-model="type" size="small" style="padding-top: 11px;width: 100%;text-align: left">
              <el-radio label="1">AK中心 </el-radio>
              <el-radio label="3">监理方</el-radio>
              <el-radio label="6">专家</el-radio>
              <el-radio label="7">测试机构 </el-radio>
              <el-radio label="4">集成商</el-radio>
              <el-radio label="5">建设方</el-radio>
              <el-radio label="8">开发商 </el-radio>
              <el-radio label="2">实施系统管理员</el-radio>
            </el-radio-group>
        </span>
        <span class="addVal" style="margin-top: 4px">
            <span>是否准入：</span>
            <el-radio-group v-model="status" size="small" style="padding-top: 11px; width: 100%;text-align: left">
              <el-radio label="1">是</el-radio>
              <el-radio label="2">否</el-radio>
            </el-radio-group>
        </span>
        <span class="addVal">
            <span>单位地址：</span>
            <el-input v-model="address" size="medium" placeholder="请输入"></el-input>
        </span>
        <span class="addVal">
            <span>负责人：</span>
            <el-input v-model="principal" size="medium" placeholder="请输入"></el-input>
        </span>
        <span class="addVal">
            <span>联系方式：</span>
            <el-input v-model="number" size="medium" placeholder="请输入"></el-input>
        </span>
      </p>
    </div>
    <p class="line"></p>
    <p class="buttonClick">
      <span class="buttonCancl" @click="cancel">取消</span>
      <span class="buttonSave" @click="save">确定</span>
    </p>
  </div>
</template>

<script>
export default {
    data () {
        return {
            type: '',
            name: '',
            status: '',
            address: '',
            number: '',
            principal: ''
        }
    },
    created() {
    },
    mounted(){
    },
    methods: {
        cancel() {
            this.$emit('on-cancel')
        },
        save() {
            if (!this.name) {
                this.$message.error('单位名称不可为空！');
                return;
            };
            let data = {
                address: this.address,
                name: this.name,
                number: this.number,
                principal: this.principal,
                score: '',
                status: parseInt(this.status),
                type: parseInt(this.type)
            };
            this.$server.postUnitAdd(data).then(res => {
                if (res.data.code === 200) {
                    this.$message.success('单位新建成功！');
                    this.$emit('on-cancel', true)
                } else {
                    this.$message.error('单位新建失败！');
                }
            }).catch(err => {
                this.$message.error('单位新建失败！');
            })
        }
    },
    components: {
    },
    watch: {
    }
}
</script>
<style scoped>
  .newrole .new{
    display: inline-block;
  }
  .new{
    right: 220px;
  }
  .newrole .addVal{
    width: 390px;
    display: flex;
    font-size: 18px;
    color: #666;
    text-align: center;
    margin-top: 15px;
  }
  .newrole .addVal>span{
    width: 140px;
    display: inline-block;
    line-height: 34px;
  }
  .newrole>>>.el-input__inner{
    border: 1px solid rgba(8,104,157,.3);
    border-radius: 2px;
    font-size: 18px;
    color: #999;
    height: 34px;
    line-height: 34px;
    width: 180px;
  }
  .newrole .line{
    margin: 25px 30px 0 30px;
    height: 1px;
    background: rgba(72,119,230,0.2);
  }
  .newrole .buttonClick{
    display: flex;
    justify-content: space-evenly;
    margin-top: 13px;
  }
  .newrole .company-content>>>.el-radio{
    margin-right: 22px;
    margin-bottom: 11px;
    width: 49px;
  }
  .newrole .company-content>>>.el-input__inner{
    width: 290px;
  }
</style>
