<template>
  <!-- 选择地点 -->
  <main-page
    left-arrow
    @click-left="$router.go(-1)"
  >
    <div class="pt-14 px-4 pb-16">
      <div v-for="(tag,index) in tags" :key="index" class="rounded">
        <div class="border-b pl-2.5 pr-1 w-full  flex items-center bg-white" :class="classBorder(index)" @click="clickIcon(index)">
          <app-icon
            slot="icon"
            :icon-name="checked === index+'' ? 'radio-checked': 'radio'"
            class-name="w-4 h-4 mr-2 flex items-center"
          />
          <div class="flex rounded px-1 flex items-center my-2" :class="tagColor(tag)">
            <van-icon name="success" />
            <div class="text-sm"> {{ tag.condition }}</div>
          </div>
        </div>
      </div>
    </div>
  </main-page>
</template>

<script lang="ts">
import Vue from 'vue'
import { Icon } from 'vant'

Vue.use(Icon)
export default Vue.extend({
  name: 'KRState',
  components: {
    'main-page': () => import('@/layout/main-page.vue'),
    'app-icon': () => import('@/components/common/Icon.vue')
  },
  data() {
    return {
      checked: '',
      tags: [
        { key: 'start', condition: '未开始' },
        { key: 'doing', condition: '进行中' },
        { key: 'end', condition: '已完成' },
        { key: 'stop', condition: '已搁置' }
      ],
      count: 0
    }
  },
  computed: {

  },
  created() {
    // console.log(Mock, 'mock')

  },
  methods: {
    clickIcon(index:number) {
      this.count = this.tags.length
      if (this.checked === index + '') {
        this.checked = ''
      } else {
        this.checked = index + ''
      }
    },
    classBorder(index:number) {
      if (index === this.tags.length - 1) {
        return 'border-none '
      }
      if (index === 0) {
        return 'mt-3'
      }
    },
    tagColor(object: {key: string, condition: string}) {
      if (object.key === 'start') {
        return 'text-tag-red bg-tag-red-lighter'
      } else if (object.key === 'doing') {
        return 'text-tag-yellow bg-tag-yellow-lighter'
      } else if (object.key === 'end') {
        return 'text-tag-green bg-tag-green-lighter'
      } else if (object.key === 'stop') {
        return 'text-tag-primary bg-tag-primary-lighter'
      } else {
        return ' '
      }
    }
  }
})
</script>

<style lang="less" scoped>

</style>
