<template>
  <view class="list-wrapper">
    <list-filter
      crm-type="contacts"
      @filter="handleFilter" />

    <wk-scroll-view
      :status="listStatus"
      class="list-scroll"
      @refresh="getList({}, true)"
      @loadmore="getList()">
      <contacts-item
        v-for="(item, index) in listData"
        :key="item.contactsId"
        :index="index"
        :item-data="item" />
    </wk-scroll-view>

    <wk-drag-button
      v-if="showAddBtn"
      @click="handleAdd">
      <view class="wk-drag-btn">
        <text class="wk wk-plus icon" />
      </view>
    </wk-drag-button>
  </view>
</template>

<script>
  import { GetList } from 'API/crm/concat'

  import ContactsItem from '../contacts/components/contactsItem'
  import ListFilter from '../components/listFilter/index.vue'

  import mainListMixins from '../../mixins/mainList.js'

  export default {
    name: 'ContactsList',
    components: {
      ContactsItem,
      ListFilter
    },
    mixins: [mainListMixins],
    data() {
      return {
        GetListFn: GetList, // 获取列表数据接口
        listType: 'crm_contacts'
      }
    },
    computed: {
      showAddBtn() {
        return this.$auth('crm.contacts.save')
      }
    },
    methods: {
      handleFilter(opt) {
        this.listParams = {
          page: 0,
          limit: 15
        }
        this.getList(opt, true)
      },

      getParams() {
        return {search: ''}
      },
      handleAdd() {
        this.$Router.navigateTo({
          url: '/pages_crm/contacts/create'
        })
      }
    }
  }
</script>

<style scoped lang="scss">
	.list-wrapper {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		overflow: hidden;

		.list-scroll {
			flex: 1;
			overflow: hidden;
		}
	}
</style>
