<template>
  <div class="list-item">
    <div class="item-box">
      <div class="item-left">
        <div class="icon-box">
          <IconFontSymbol icon="jiaoseguanli1-copy" :fill-color="primaryColor"
        /></div>
      </div>
      <div class="item-role-box1">
        <a-tooltip v-if="props.item?.name.length > 6" :title="props.item?.name">
          <div class="item-form-name"> {{ `${props.item?.name.slice(0, 6)}...` }}</div>
        </a-tooltip>
        <div class="item-form-name" v-else> {{ props.item?.name }}</div>
        <div class="item-title">{{ t('角色名称') }}</div>
      </div>
      <div class="item-role-box2">
        <div class="item-form-name"> {{ props.item?.count ? props.item.count : 0 }}人</div>
        <div class="item-title">{{ t('角色人数') }}</div>
      </div>
      <div class="fixed-checked">
        <slot name="check"></slot>
      </div>
      <div class="fixed-icon">
        <IconFontSymbol icon="role1-copy" fill-color="#f8f8f8" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import IconFontSymbol from '/@/components/IconFontSymbol/Index.vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { primaryColor } from '../../../../../build/config/themeConfig';
  const { t } = useI18n();
  let props = defineProps({
    item: Object,
  });
</script>

<style lang="less" scoped>
  @custom-color: @primary-color;
  @bg-color: #ffffff;

  .list-item {
    width: 280px;
    height: 100px;
    background: @bg-color;
    border-color: transparent;
    border-radius: 16px;
    margin: 16px 0 0 16px;
    overflow: hidden;

    &:hover {
      border: 1px solid @custom-color;

      :deep(.ant-checkbox-inner) {
        border-color: @custom-color;
      }
    }

    .item-box {
      display: flex;
      align-items: center;
      margin: 14px;
      position: relative;

      .item-left {
        .icon-box {
          width: 53px;
          height: 53px;
          font-size: 32px;
          border: 1px solid @custom-color;
          border-radius: 50%;
          display: flex;
          justify-content: center;
          align-items: center;
        }
      }

      .fixed-checked {
        position: absolute;
        bottom: -20px;
        z-index: 1;
        right: -6px;
      }

      .fixed-icon {
        position: absolute;
        right: -34px;
        font-size: 64px;
        transform: rotate(-30deg);
        top: -34px;
      }
    }
  }

  :deep(.ant-checkbox-inner) {
    border-color: #ddd;
  }

  :deep(.ant-checkbox-checked .ant-checkbox-inner) {
    background-color: @custom-color;
    border-color: @custom-color;
  }

  :deep(.ant-checkbox-checked::after),
  :deep(.ant-checkbox-wrapper:hover .ant-checkbox-inner, .ant-checkbox:hover),
  :deep(.ant-checkbox:hover),
  :deep(.ant-checkbox-input:focus + .ant-checkbox-inner) {
    border-color: @custom-color;
  }

  .picked {
    border-width: 1px;
    border-style: solid;
    border-color: @custom-color;

    :deep(.ant-checkbox-inner) {
      border-color: @custom-color;
    }
  }

  .not-picked {
    border-width: 1px;
    border-style: solid;
    border-color: #ddd;
  }

  .item-title {
    font-size: 14px;
    color: #636e80;
  }

  .item-form-name {
    font-weight: bold;
    font-size: 14px;
    color: #1d2129;
  }

  .item-role-box1 {
    position: absolute;
    z-index: 1;
    left: 72px;
    top: 0;
    display: flex;
    flex-direction: column;
  }

  .item-role-box2 {
    position: absolute;
    z-index: 1;
    left: 178px;
    top: 0;
  }
</style>
