<template>
	<div class="app-content">
		<sel-search-module :list="list.data" :isMember="true" @search="searchFn" @change="changeFn"></sel-search-module>
	</div>
</template>

<script>
import SelSearchModule from '@/admin/home/components/sel-search'
import { list } from '@/mixins'
// api
import { getList } from '@/api/member'
export default {
	name: 'staff-sel-member',
	components: {
		SelSearchModule
	},
	mixins: [list],
	data() {
		return {
			search: ''
		}
	},
	onPullDownRefresh() {
		this.resetList()
		this._list().then(res => {
			uni.stopPullDownRefresh()
		})
	},
	onReachBottom() {
		if (this.list.data.length < this.list.total) {
			this._list().then(res => {
				uni.stopPullDownRefresh()
			})
		} else {
			uni.stopPullDownRefresh()
		}
	},
	onLoad: function() {
		// this.init()
	},
	methods: {
		async init() {
			this._list()
		},
		_list() {
			let params = {
				page: this.list.page,
				goodsName: this.search
			}
			return getList(params).then(res => {
				this.completes(res)
			})
		},
		// 搜索
		searchFn(val) {
			if (!val) return false
			this.search = val
			this.resetList()
			this._list()
		},
		// 选择员工
		changeFn(e) {
			uni.setStorageSync('addSelMember', e)
			this.$util.pageTo({
				url: '/admin/staff/add',
				query: {
					...this.option
				},
				type: 2
			})
		}
	}
}
</script>

<style lang="scss" scoped>
</style>
