<template>
	<view class="dialog_out" >
		<view class="dialog_container">
			<uni-icons type="closeempty" size="40" class="close_icon" @click="choose()"></uni-icons>
			<view class="dialog_title">选择供应商</view>
			<view class="search_container">
				<view class="search_text">
					<input type="search" placeholder="请输入供应商" v-model="search_data.name"/>
				</view>
				<button @click="search(1)" type="primary">查询</button>
			</view>
			<view class="table_container">
				<t-table border=0>
					<t-tr font-size="18">
						<t-th>供应商代码</t-th>
						<t-th>供应商名称</t-th>
						<t-th>联系人</t-th>
						<t-th>电话</t-th>
						<t-th>操作</t-th>
					</t-tr>
					<span @click="choose(items)" v-for="items in tableList" :key="items.userId" class="t-tr-span">
					<t-tr font-size="17" >
						<t-td>{{items.code}}</t-td>
						<t-td>{{items.unit_name}}</t-td>
						<t-td>{{items.linkman_name}}</t-td>
						<t-td>{{items.company_phone}}</t-td>
						<t-td style="color: #007AFF;" ><button @click="choose(items)" type="primary" plain="true">选择</button></t-td>
					</t-tr>
					</span>
					<view v-if="show_nodata" class="nodata" style="text-align: center;font-size: 18px;color: #999;line-height: 40px;">暂无数据</view>

				</t-table>
				<uni-pagination show-icon="true" :pageSize="search_data.pagesize" :total="total_pages" :current="search_data.pageno" class="pagination" @change="changePages"></uni-pagination>
			</view>
		</view>
	</view>
</template>

<script>
import 'static/css/chooseDialog.css'
	import uniIcons from '@/components/uni-icons/uni-icons.vue'
	import tTable from '@/components/t-table/t-table.vue';
	import tTh from '@/components/t-table/t-th.vue';
	import tTr from '@/components/t-table/t-tr.vue';
	import tTd from '@/components/t-table/t-td.vue';
	import uniPagination from '@/components/uni-pagination/uni-pagination.vue';
	export default {
		components: {
			tTable,
			tTh,
			tTr,
			tTd,
			uniIcons,
			uniPagination
		},
		  props: {
		   
		  },
		data() {
			return {
				search_data:{
					userName:"",
					pageno:1,//当前页数
					pagesize:4,//1页几条数据
				},
				tableList: [],
				total_pages: 0, //总页数
				show_nodata: false,
				}
		},
		mounted(){
		this.search()	
		},
		methods: {
			search(n) {
				if(n==1){
					this.search_data.pageno=1;
				}
			this.$http.request({
					url: '/apis/supplier/listServiceGroup',
					method: 'post',
					params: this.search_data,
				}).then(res => {
					if (res) {
						if (res.data.code == 0) {
							this.tableList = res.data.data ? res.data.data.datas : []
							if (this.tableList.length == 0) {
								this.show_nodata = true
							}
							this.total_pages = res.data.data ? res.data.data.totalPages * this.search_data.pagesize : 0
						}
					}
				});		
			},
			changePages(e) {
				this.search_data.pageno = e.current;
				this.search();

			},
			//点击选择
			choose(val){
				this.$emit("change", val);
			}
		},
		
		
	}
</script>
