<template>
  <!-- 商机管理我关注的客户 - 采购单位画像关注 -->
  <ListCard
    class="customer-watcher"
    :list="list"
    title="业主监控"
    @clickListItem="clickListItem"
    @linkMore="linkMore"
    :loading="loading"
    :loaded="loaded">
    <div slot="empty-content" class="empty-content">暂未关注任何客户</div>
  </ListCard>
</template>

<script>
import { mapState, mapActions } from 'vuex'
import ListCard from '../ui/ListCard'
import { getPowerUrl } from '@/utils/power/redirect'
import { openSelfLink } from '@/utils'

export default {
  name: 'CustomerWatcher',
  components: {
    ListCard
  },
  computed: {
    ...mapState({
      loading: state => state.workspace.customerWatcher.loading,
      loaded: state => state.workspace.customerWatcher.loaded,
      list: state => state.workspace.customerWatcher.list
    })
  },
  created () {
    this.getList()
  },
  methods: {
    ...mapActions('workspace/customerWatcher', [
      'getList'
    ]),
    resolveLink (link) {
      const { href } = this.$router.resolve(link)
      return href
    },
    clickListItem (item) {
      // this.pathVisiting(
      //   this.createPathItem(
      //     '/unit_portrayal/*',
      //     `id=${item.name}`
      //   )
      // )
      // window.open(`/entpc/unit_portrayal/${item.name}`)
      const { url } = getPowerUrl('buyerDesc', { id: item.name })
      window.open(url)
    },
    linkMore () {
      // window.open('/entpc/newBus/client_follow')
      openSelfLink(this.$router.resolve('/my_client'))
    }
  }
}
</script>
