<template>
  <div class="page_employeeList">
    <div class="editRoleTitle">
      <i class="iconfont icon-zuojiantou jiantou"></i>
      <span class="titleName">员工列表</span>
      <span>保存</span>
    </div>
    <div class="allCheckBox">
      <div class="allCheck">
        <van-checkbox v-model="allChecked" @click="checkAll"></van-checkbox>
        <div style="margin-left:1.25rem">全选</div>
      </div>
      <van-checkbox-group
        v-model="result"
        ref="checkboxGroup"
        @change="onChange"
      >
        <div class="checkOne">
          <van-checkbox name="a"></van-checkbox>
          <div class="checkUserBox">
            <img src="../../assets/images/one.jpg" alt="" />
            <p>名字</p>
          </div>
        </div>
        <div class="checkOne">
          <van-checkbox name="b"></van-checkbox>
          <div class="checkUserBox">
            <img src="../../assets/images/one.jpg" alt="" />
            <p>名字</p>
          </div>
        </div>
      </van-checkbox-group>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      allChecked: false,
      list: ["a", "b"],
      result: []
    };
  },
  methods: {
    checkAll() {
      if (this.allChecked == false) {
        this.result = this.list;
        this.allChecked = true;
      } else {
        this.result = [];
      }
    },
    onChange() {
      if (this.result.length == this.list.length) {
        this.allChecked = true;
        this.$refs.checkboxes.toggle();
      } else {
        this.allChecked = false;
        this.$refs.checkboxes.toggle();
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.page_employeeList {
  height: 100%;
  overflow-y: auto;
  background: #fafafa;
  .editRoleTitle {
    background: #fff;
    padding: 0 1.125rem;
    height: 3.125rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .jiantou {
    font-size: 1.5rem;
    font-weight: 600;
    margin-right: 1.5rem;
  }
  .titleName {
    font-size: 1.125rem;
    font-weight: 600;
  }
  .allCheckBox {
    .allCheck {
      height: 2.8125rem;
      display: flex;
      align-items: center;
      background: #fff;
      padding-left: 0.75rem;
      margin: 1rem 0;
    }
    .checkOne {
      background: #fff;
      height: 3.75rem;
      display: flex;
      align-items: center;
      padding-left: 0.75rem;
    }
    .checkUserBox {
      display: flex;
      align-items: center;
      img {
        width: 2.5rem;
        height: 2.5rem;
        margin: 0 0.75rem 0 1.25rem;
      }
    }
  }
}
</style>
