<template>
	<a-card :bordered="false" class="xn-mb10">
		<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
			<a-row :gutter="24">
				<a-col :span="6">
					<a-form-item label="推荐人" name="searchKey">
						<a-input v-model:value="searchFormState.searchKey" placeholder="请输入推荐人姓名或手机号" />
					</a-form-item>
				</a-col>
				<a-col :span="6">
					<a-button type="primary" @click="tableRef.refresh()">查询</a-button>
					<a-button style="margin: 0 8px" @click="reset">重置</a-button>
				</a-col>
			</a-row>
		</a-form>
	</a-card>
	<a-card :bordered="false">
		<s-table ref="tableRef" :columns="columns" :data="loadData" bordered :row-key="(record) => record.id">
			<template #bodyCell="{ column, record, index }">
				<template v-if="column.dataIndex === 'serial'">
					{{ index + 1 }}
				</template>
				<!--				<template v-if="column.dataIndex === 'action'">-->
				<!--					<a-space>-->
				<!--						<a @click="formRef.onOpen(record)" v-if="hasPerm('bizRecommendRecordEdit')">编辑</a>-->
				<!--						<a-divider type="vertical" v-if="hasPerm(['bizRecommendRecordEdit', 'bizRecommendRecordDelete'], 'and')" />-->
				<!--						<a-popconfirm title="确定要删除吗？" @confirm="deleteBizRecommendRecord(record)">-->
				<!--							<a-button type="link" danger size="small" v-if="hasPerm('bizRecommendRecordDelete')">删除</a-button>-->
				<!--						</a-popconfirm>-->
				<!--					</a-space>-->
				<!--				</template>-->
			</template>
		</s-table>
	</a-card>
</template>

<script setup name="recommendrecord">
	import bizRecommendRecordApi from '@/api/biz/bizRecommendRecordApi'
	import { cloneDeep } from 'lodash-es'
	const tableRef = ref()
	const searchFormState = ref({})
	const searchFormRef = ref()
	const columns = [
		{
			title: '序号',
			dataIndex: 'serial',
			width: 80,
			align: 'center'
		},
		{
			title: '推荐人',
			dataIndex: 'recommendUserName',
			align: 'center'
		},
		{
			title: '推荐人手机号',
			dataIndex: 'recommendUserPhone',
			align: 'center'
		},
		{
			title: '被推荐人',
			dataIndex: 'acceptUserName',
			align: 'center'
		},
		{
			title: '被推荐人手机号',
			dataIndex: 'acceptUserPhone',
			align: 'center'
		},
		{
			title: '推荐时间',
			dataIndex: 'createTime',
			align: 'center'
		}
	]
	const loadData = (parameter) => {
		const searchFormParam = cloneDeep(searchFormState.value)
		return bizRecommendRecordApi.bizRecommendRecordPage(Object.assign(parameter, searchFormParam)).then((data) => {
			return data
		})
	}
	// 重置
	const reset = () => {
		searchFormRef.value.resetFields()
		tableRef.value.refresh(true)
	}
</script>
