<template>
	<view class="dmodel-table">
			<view class="search">
				<u-form :model="tableParams" labelAlign="right" class="tableForm">
					<u-form-item label="编号" label-width="60px"  name="userName">
						<uni-easyinput type="text" v-model="tableParams.userName" placeholder="请输入编号" />
					</u-form-item>
					<u-form-item label="名称" label-width="60px"  name="nickName">
						<uni-easyinput type="text" v-model="tableParams.nickName" placeholder="请输入名称" />
					</u-form-item>
					<u-form-item>
						<u-button class="btn" @click="getList" type="primary" size="medium">搜索</u-button>
					</u-form-item>
				</u-form>
			</view>
	      <zb-table ref="zbTable" rowKey="recordId"
             :columns="tableColumn" :data="tableData" :stripe="true"
			@toggleRowSelection="toggleRowSelection">
		</zb-table>
	</view>
</template>

<script>
	export default {
		props: {
			data: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {
				tableParams: {
          nickName: null,
				  userName: null,
				},
				tableData: [],
				tableSelectData: [],
				tableColumn: [{
						type: 'radio',
						width: 40
					},
					{
						name: 'userName',
						label: '编号',
						width: 160,
					},
					{
						name: 'nickName',
						label: '名称',
						width: 200,
					},

					{
						name: 'workstationName',
						label: '工作站',
						width: 160,
					},
				
				],
			}
		},
		// computed: {
		// 	tableData() {
		// 		return this.data || []
		// 	}
		// },
		mounted() {
		  this.getList()
		  // this.data.workstationName
		},
		methods: {
			async getList() {
			  let params = {
			  	pageNum: 1,
			  	pageSize: 10, 
				workstationId: this.data.workstationId
			  }
			  if (this.userName) {
				  params.userName = this.tableParams.userName
			  }
			  if (this.nickName) {
			  	params.nickName = this.tableParams.nickName
			  }
			  const res = await this.$u.api.userQuery(params)
			  console.log(res, 'res')
			  if (res.code == 200) {
			  	this.tableData=res.rows.map(item => {
					return {
						...item,
						workstationName: this.data.workstationName
					}
				})
				
			  }	
			},
			toggleRowSelection(checked, arr) {
				this.tableSelectData = arr
			},
		}
	}
</script>

<style scoped>
	.dmodel-table {
		height: 500rpx;
		margin-top: 20rpx;
		padding: 0 20rpx;
	}
	.tableForm{
		display: flex;
		margin-bottom:20rpx;
	}
	.btn{
		margin-left:10px;
	}
</style>
