<template>
  <div :class="$style.mainDiv">
    <a-spin tip="内容套打中..." :spinning="spinning">
      <ul :class="$style.templateUl">
        <li
          v-for="template in templateList"
          :key="template.id"
          :class="{ [$style.checkedLi]: checkedTemp.id === template.id }"
          @click="(e) => setChecked(template)"
        >
          <a-radio :checked="checkedTemp.id === template.id"></a-radio>{{ template.redheadName }}
        </li>
      </ul>
    </a-spin>
  </div>
</template>

<script>
import components from './_import-components/iam-audit-notice-template-select-import'

export default {
  name: 'IamAuditNoticeTemplateSelect',
  metaInfo: {
    title: 'IamAuditNoticeTemplateSelect',
  },
  components: {
    ...components,
  },
  props: {
    // 项目ID
    projectId: {
      type: String,
      default: '',
    },
    // 模板列表
    templateList: {
      type: Array,
      default: () => {
        return []
      },
    },
  },
  data() {
    return {
      searchform: 'searchform',
      checkedTemp: { id: null },
      spinning: false,
    }
  },
  methods: {
    // 设置单选选中
    setChecked(template) {
      this.checkedTemp = template
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.main-div {
  min-height: 300px;
  background: #ffffff;
}
.left-div {
  background: #ffffff;
  border: 1px solid #e8e8e8;
  margin-right: 15px;
}
.right-div {
  background: #ffffff;
}
.template-ul {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  border: 1px solid #e8e8e8;
  li {
    min-height: 32px;
    padding: 6px 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: all 0.3s;
    cursor: pointer;
    border-bottom: 1px solid #e8e8e8;
  }
  .checked-li {
    background-color: #e6f7ff;
  }
  li:hover {
    background-color: #e6f7ff;
    cursor: pointer;
  }
  li:last-child {
    border-bottom: none;
  }
}
</style>
