<template>
  <div class="staffDetails-wrap common-set-wrap">
    <nav-crumb :navpath="navpath"></nav-crumb>
    <div class="right-content">
      <div class="right-box">
        <div class="staffDetails-cell">
          <h2 class="m-b-25">{{adminStruct.name}}</h2>
          <div class="staffDetails-cell-fixed">
            <template v-for="(item,index) in adminStruct.fixedList">
              <el-button disabled class="staffDetails-cell-btn">{{item.name}}</el-button>
            </template>
          </div>
          <div class="staffDetails-cell-add">
            <template v-for="(item,index) in adminStruct.defineList">
              <el-tag class="staffDetails-cell-btn">{{item.name}} <i class="el-icon-circle-close" @click.stop="delField(index,item,adminStruct.defineList)"></i></el-tag>
            </template>
            <el-button class="el-tag m-l-8 staffDetails-cell-btn" @click.stop="showDialogLayer('admin')"><i class="el-icon-plus"></i>添加字段</el-button>
          </div>
        </div>
        <div class="staffDetails-cell">
          <h2 class="m-b-25">{{storeStruct.name}}</h2>
          <div class="staffDetails-cell-fixed">
            <template v-for="(item,index) in storeStruct.fixedList">
              <el-button disabled class="staffDetails-cell-btn">{{item.name}}</el-button>
            </template>
          </div>
          <div class="staffDetails-cell-add">
            <template v-for="(item,index) in storeStruct.defineList">
              <el-tag class="staffDetails-cell-btn">{{item.name}} <i class="el-icon-circle-close" @click.stop="delField(index,item,storeStruct.defineList)"></i></el-tag>
            </template>
            <el-button class="el-tag m-l-8 staffDetails-cell-btn" @click.stop="showDialogLayer('store')"><i class="el-icon-plus"></i>添加字段</el-button>
          </div>
        </div>
      </div>
    </div>
    <vue-gic-footer></vue-gic-footer>
    <!-- 自定义字段 -->
    <staff-detail-field :showCustomDialog="showCustomDialog" @customHandleConfirm="customHandleConfirm"></staff-detail-field>
  </div>
</template>
<script>
import navCrumb from '@/components/nav/nav.vue';
import staffDetailField from '@/components/set/staff-detail-field.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: "staffDetails",
  data() {
    return {
       // 面包屑参数
      navpath: [
        {
          name: '首页',
          path: '/index',
          relocation: true
        },
        {
          name: '设置',
          path: '/companyAddress'
        },
        {
          name: '通讯录信息',
          path: '/staffDetails'
        },
        {
          name: '员工详细字段',
          path: ''
        }
      ],

      // 行政架构
      adminStruct: {

        name: '行政架构通讯录员工详情字段',
        fixedList: [
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          }
        ],
        defineList: [
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
        ],
      },

      // 门店架构'
      storeStruct: {
        name: '门店架构通讯录员工详情字段',
        fixedList: [
          {
            name: '姓名'
          }
        ],
        defineList: [
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
          {
            name: '姓名'
          },
        ]
      },

      showCustomDialog: false, // 自定义弹框显示标志
    }
  },
  computed: {

  },
  methods: {
    /**
     * 自定义弹窗显示事件
     */
    showDialogLayer() {
      const that = this
      that.showCustomDialog = true;
      console.log(1)
    },

    /**
     * 自定义弹框触发事件
     */
    customHandleConfirm(val) {
      const that = this
      that.showCustomDialog = false;
    },

    /**
     * 删除字段
     */
    delField(index,item,list) {
      const that = this
      that.$alert('确定要删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({ value }) => {
        list.splice(index,1)
      }).catch(() => {

      });
    }
  },
  mounted() {

  },
  components: {
    navCrumb,
    staffDetailField
  }
}

</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;
    }

    .m-l-8 {
      margin-left: 8px;
    }

    .m-r-20 {
      margin-left: 20px;
    }

    .m-b-25 {
      margin-bottom: 25px;
    }

    .staffDetails-cell {
      &+.staffDetails-cell {
        margin-top: 14px;
        padding-top: 36px;
        border-top: 1px solid #E4E7ED;
      }
    }

    .el-tag {
      position: relative;
      cursor: pointer;

      .el-icon-circle-close {
        position: absolute;
        top: -10px;
        right: -10px;
        font-size: 16px;
        color: #808995;
        cursor: pointer;
      }
    }

    .staffDetails-cell-btn {
      width: 110px;
      height: 32px;
      margin: 0 20px 20px 0;
      text-align: center;
      vertical-align: top;
    }
  }
}
</style>
