<template>
  <div class="companyAddress-wrap common-set-wrap">
    <nav-crumb :navpath="navpath"></nav-crumb>
    <div class="right-content">
      <div class="right-box">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-form-item label="角色名称" prop="name" class="">
            <!-- <el-input v-model="ruleForm.name" disabled placeholder="" class="w-380"></el-input> -->
            <limitInput
              :inputWidth="500"
              :inputValue.sync="ruleForm.name"
              :holder="'请输入角色名称'"
              :maxLength="20">
            </limitInput>
          </el-form-item>
          <el-form-item label="角色说明" prop="" class="">
            <limitTextarea
              :inputWidth="500"
              :inputValue.sync="ruleForm.name"
              :holder="'请输入角色说明'"
              :maxLength="50">
            </limitTextarea>
          </el-form-item>
          <el-form-item label="菜单权限" prop="" class="">
            <el-transfer
              :titles="['一级权限', '二级权限']"
              :left-default-checked="ruleForm.leftChecked"
              :data="ruleForm.left"
              @left-check-change="leftChange">
            </el-transfer>
            <el-transfer
              :titles="['二级权限', '二级权限']"
              :left-default-checked="ruleForm.rightChecked"
              :data="ruleForm.right"
              @left-check-change="rightChange">
            </el-transfer>
          </el-form-item>
          <el-form-item label="应用权限" prop="" class="">
            <el-transfer
              :titles="['一级权限', '二级权限']"
              :left-default-checked="ruleForm.leftCheckedApp"
              :data="ruleForm.leftApp"
              @left-check-change="leftChangeApp">
            </el-transfer>
            <el-transfer
              :titles="['二级权限', '二级权限']"
              :left-default-checked="ruleForm.rightCheckedApp"
              :data="ruleForm.rightApp"
              @left-check-change="rightChangeApp">
            </el-transfer>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <vue-gic-footer></vue-gic-footer>
  </div>
</template>
<script>
import navCrumb from '@/components/nav/nav.vue';
import limitInput from '@/components/limit-input.vue';
import limitTextarea from '@/components/limit-textarea.vue';

import strLength from '@/common/js/strlen';
import showMsg from '@/common/js/showmsg';
import errMsg  from '@/common/js/error';
import { _debounce } from "@/common/js/public";
import { getRequest, postRequest, postJson, postForm } from '@/api/api';
export default {
  name: "addAdminRole",
  data() {

    return {
      // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index',
          relocation: true
        },
        {
          name: '设置',
          path: '/companyAddress'
        },
        {
          name: '设置子管理员',
          path: '/setChildAdmin'
        },
        {
          name: '新增管理员',
          path: ''
        }
      ],

      ruleForm: {
        name: '企业管理员',
        leftChecked: [],
        left: [
          {
            key: 'index',
            label: '首页'
          },
          {
            key: 'center',
            label: '审核中心'
          },
          {
            key: 'set',
            label: '设置'
          }
        ],
        rightChecked: [],
        right: [
          {
            key: 'index',
            label: '首页'
          },
          {
            key: 'center',
            label: '审核中心'
          },
          {
            key: 'set',
            label: '设置'
          }
        ],
        leftCheckedApp: [],
        leftApp: [
          {
            key: 'index',
            label: '首页'
          },
          {
            key: 'center',
            label: '审核中心'
          },
          {
            key: 'set',
            label: '设置'
          }
        ],
        rightCheckedApp: [],
        rightApp: [
          {
            key: 'index',
            label: '首页'
          },
          {
            key: 'center',
            label: '审核中心'
          },
          {
            key: 'set',
            label: '设置'
          }
        ]
      },
      rules: {

      }

    }
  },
  computed: {

  },
  methods: {
    /**
     * 保存
     */
    submitForm: _debounce(function(formName) {
      const that = this;
      that.$refs[formName].validate((valid) => {
        console.log(valid)
        if (valid) {

        } else {
          return false;
        }
      });
    },500),

    /**
     * 保存---api
     */
    postSave() {
      const that = this;

    },

    /**
     * 选择
     */
    leftChange(value, direction) {
      console.log(value, direction)
    },

    /**
     * 选择
     */
    rightChange(value, direction) {
      console.log(value, direction)
    },

    /**
     * 选择
     */
    leftChangeApp(value, direction) {
      console.log(value, direction)
    },

    /**
     * 选择
     */
    rightChangeApp(value, direction) {
      console.log(value, direction)
    },
  },
  mounted() {

  },
  components: {
    navCrumb,
    limitInput,
    limitTextarea
  }
}

</script>
<style lang="less" scoped>
.right-content {
  /*width: 100%;*/
  padding: 24px;
  min-height: calc(100% - 240px);

  .right-box {
    background: #fff;
    padding: 24px;
    min-height: 500px;

    h2 {
      font-size: 16px;
      color: #303133;
    }

    p {
      font-size: 14px;
      color: #909399;
    }

    .m-t-24 {
      margin-top: 24px;
    }

    .w-380 {
      width: 380px;
    }

    .el-transfer {
      display: inline-block;
      vertical-align: top;
      /deep/ .el-transfer-panel:last-child {
        display: none;
      }
      /deep/ .el-transfer__buttons {
        padding: 0 5px;
        .el-button {
          display: none;
        }
      }
    }
  }
}
</style>
