<template>
	<view class="sales-list-wrap">
		<u-dropdown>
			<u-dropdown-item v-model="billStatus" title="业务状态" :options="billStatusOpt"></u-dropdown-item>
		</u-dropdown>
	</view>
</template>

<script>
	import { getLookUpItem } from '@/api/data'
	import { salesList } from '@/api/sales'
	export default{
		data(){
			return{
				listData: [],
				pageNo: 1,
				pageSize: 6,
				totalNum: 0,
				noDataText: '暂无数据',
				billStatus: undefined,
				financialStatus: undefined,
				billStatusOpt: [],
				financialStatusOpt: [],
			}
		},
		onLoad() {
			this.getLookUpItem('SALES_BILL_STATUS')
			this.getLookUpItem('FINANCIAL_RECEIVE_STATUS')
			this.getList()
		},
		methods: {
			// 列表
			getList(pageNo){
				const _this = this
				if (pageNo) {
					this.pageNo = pageNo
				}
				salesList({ pageNo: this.pageNo, pageSize: this.pageSize }).then(res => {
					if (res.status == 200) {
						if(this.pageNo>1){
							this.listData = this.listData.concat(res.data.list || [])
						}else{
							this.listData = res.data.list || []
						}
						this.totalNum = res.data.count || 0
					} else {
						this.listData = []
						this.totalNum = 0
						this.noDataText = res.message
					}
				})
			},
			// scroll-view到底部加载更多
			onreachBottom() {
				if(this.listData.length < this.totalNum){
					this.pageNo += 1
					this.getList()
				}
			},
			handleChange(){},
			// 配送方式
			getLookUpItem (type) {
				getLookUpItem({ lookupCode: type, pageNo: 1, pageSize: 1000 }).then(res => {
					if (res.status == 200 && res.data && res.data.list) {
						res.data.list.map(item => {
							item.label = item.dispName
							item.value = item.code
						})
						if(type == 'SALES_BILL_STATUS'){
							this.billStatusOpt = res.data.list
						}else if(type == 'FINANCIAL_RECEIVE_STATUS'){
							this.financialStatusOpt = res.data.list
						}
					} else {
						if(type == 'SALES_BILL_STATUS'){
							this.billStatusOpt = []
						}else if(type == 'FINANCIAL_RECEIVE_STATUS'){
							this.financialStatusOpt = []
						}
					}
				})
			}
		}
	}
</script>

<style>
</style>
