<template>
	<!--人才培养规划 -->
	<a-card :bordered="false">
		<div class="pricemoitorrecord">
			<a-form :model="formState" name="basic" autocomplete="off" @finish="onFinish" @finishFailed="onFinishFailed">
				<div class="form">
					<a-form-item
						class="form-item"
						label="姓名"
						name="swls"
						:label-col="{ span: 10 }"
						:rules="[{ required: true, message: 'Please input your username!' }]"
					>
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item
						class="form-item"
						label="性别"
						name="username"
						:label-col="{ span: 10 }"
						:rules="[{ required: true, message: 'Please input your username!' }]"
					>
						<a-select v-model:value="formState.swls" @change="handleChange" :options="options"></a-select>
					</a-form-item>

					<a-form-item class="form-item" label="年龄" name="swls" :label-col="{ span: 10 }">
						<a-input v-model:value="formState.username" />
					</a-form-item>

					<!--  -->
					<a-form-item class="form-item" label="当前所属岗位" name="username" :label-col="{ span: 10 }">
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item
						class="form-item"
						label="联系方式"
						name="username"
						:label-col="{ span: 10 }"
						:rules="[{ required: true, message: 'Please input your username!' }]"
					>
						<a-input v-model:value="formState.username" />
					</a-form-item>

					<a-form-item class="form-item" label="邮箱" name="username" :label-col="{ span: 10 }">
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item class="form-item" label="工作年限" name="username" :label-col="{ span: 10 }">
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item
						class="form-item"
						label="身份证号"
						name="username"
						:label-col="{ span: 10 }"
						:rules="[{ required: true, message: 'Please input your username!' }]"
					>
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item
						class="form-item"
						label="籍贯"
						name="username"
						:label-col="{ span: 10 }"
						:rules="[{ required: true, message: 'Please input your username!' }]"
					>
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item
						class="form-item"
						label="民族"
						name="username"
						:label-col="{ span: 10 }"
						:rules="[{ required: true, message: 'Please input your username!' }]"
					>
						<a-select v-model:value="formState.swls" @change="handleChange" :options="options"></a-select>
					</a-form-item>
					<a-form-item class="form-item" label="称号名称" name="username" :label-col="{ span: 10 }">
						<a-input v-model:value="formState.username" />
					</a-form-item>
					<a-form-item class="form-item" label="获得时间" name="username" :label-col="{ span: 10 }">
						<a-select v-model:value="formState.swls" @change="handleChange" :options="options"></a-select>
					</a-form-item>

					<!--  -->
				</div>
				<a-form-item class="form-item" label="" name="username" :label-col="{ span: 10 }">
					<div class="attachment">
						<div><span>*</span>附件:</div>
						<div>
							<a-upload
								:action="uploadUrl"
								:before-upload="handleBeforeUpload"
								:on-success="handleUploadSuccess"
								:on-error="handleUploadError"
								:file-list="fileList"
								multiple
							>
								<a-button icon="upload">选择文件</a-button>
							</a-upload>
							<!-- <p>附件支持在线预览、下载、打印。</p> -->
						</div>
					</div>
				</a-form-item>

				<a-form-item>
					<div class="item-submit">
						<a-button class="btn1" html-type="submit">取消</a-button>
						<a-button class="btn1" type="primary" html-type="submit">保存</a-button>
					</div>
				</a-form-item>
			</a-form>
		</div>
		<!-- <Form ref="formRef" @successful="tableRef.refresh()" /> -->
	</a-card>
</template>
<script lang="js">
	import { onMounted } from 'vue'
	// import Form from './form.vue'
	import { reactive, ref } from 'vue'
	import { useRouter } from 'vue-router'
	import { defineComponent } from 'vue'
	export default {
		name: 'ApplicationExtension',
		components: {},
		setup(props, { emit }) {
			const formRef = ref(null)
			onMounted(() => {
				onSearch()
			})
			const dataSource = ref([]) // 响应式表格数据
			const total = ref(0) // 总记录数
			const currentPage = ref(1) // 当前页码
			const pageSize = ref(10) // 每页显示的记录数
			const pageSizeOptions = ['1', '2', '30', '40'] // 每页显示记录数选项

			const handlePageChange = (current, size) => {
				// 更新当前页码和每页显示的记录数
				pagination.current = current
				pagination.pageSize = size
				// 根据新的页码和每页显示的记录数获取数据
			}
			const router = useRouter()
			const tableColumns = [
				{ title: '序号', key: 'INDEX' },
				{ title: '品种', dataIndex: 'dataIndex1' },
				{ title: '性质', dataIndex: 'dataIndex2' },
				{ title: '生产年限', dataIndex: 'dataIndex3' },
				{ title: '计划数量', dataIndex: 'dataIndex4' }
				// { title: '操作', key: '操作' }
			]
			const tableData = ref([
				{
					INDEX: 1,
					dataIndex1: '企业名称1',
					dataIndex2: '企业代码1',
					dataIndex3: '法定代表人1',
					dataIndex4: '企业性质1'
				},
				{
					INDEX: 2,
					dataIndex1: '企业名称2',
					dataIndex2: '企业代码2',
					dataIndex3: '法定代表人2',
					dataIndex4: '企业性质2'
				}
			])
			const SiteOptions = []
			const username = ref('')
			const SearchForm = reactive({
				siteName: ''
			})
			function onSearch() {
				// let fd = JSON.parse(JSON.stringify(SearchForm))
				// fd.current = tablePage.current
				// fd.size = tablePage.size
				// priceMoitorRecordApi.priceMoitorRecordPage(fd).then((reg) => {
				// 	console.log(reg.records, 123)
				// 	tableData.value = reg.records
				// 	tablePage.total = reg.total
				// })
			}
			function onReset() {
				SearchForm.siteName = ''
				tablePage.current = 1
				onSearch()
			}
			const handleInput = () => {}

			function onViewRow() {
				// router.push('/basic.info/pricemoitorrecordDetail')
			}
			function onChangePage(ev) {
				// Object.assign(tablePage, ev)
				onSearch()
			}

			const pagination = reactive({
				current: currentPage.value,
				pageSize: pageSize.value,
				total: total.value,
				showSizeChanger: true,
				pageSizeOptions: pageSizeOptions,
				showTotal: (total, range) => `共 ${total} 条`,
				onChange: handlePageChange
			})

			const handleExpand = (expanded, record) => {
				// 处理展开分页的逻辑
				// 可以根据 record 的信息进行展开分页的操作
				// 例如根据 record 的 ID 获取分页数据等
				// 更新分页数据
				record.paginationData = [] // 假设 record.paginationData 是用于存储分页数据的属性
			}

			// 查看表单数据
			const onView = (record) => {
				// formRef.value.onOpen(record, true)
				router.push('/basic.info/applicationQualificationNew')
			}
			const formState = reactive({
				username: '',
				swls: ''
			})
			const onFinish = (values) => {
				console.log('Success:', values)
			}
			const onFinishFailed = (errorInfo) => {
				console.log('Failed:', errorInfo)
			}

			const options = ref([
				{
					value: 1
				}
			])

			const handleChange = (val) => {
				console.log(val)
			}
			const uploadUrl = 'https://your-upload-api-url' // 替换为实际的上传接口地址
			const fileList = ref([])

			// 处理文件上传前的操作 ,// 可以在此处对文件进行校验或处理
			// 返回 true 表示继续上传，返回 false 表示取消上传
			const handleBeforeUpload = (file) => {
				console.log('文件上传前的操作', file)
				return true
			}

			// 处理文件上传成功的操作
			const handleUploadSuccess = (response, file) => {
				const formData = new FormData()
				formData.append('file', file)
				console.log('文件上传成功', response, formData)
				// axios
				// 	.post('https://your-api-url', formData)
				// 	.then((response) => {
				// 		console.log('请求成功', response)
				// 		// 在此处处理请求成功后的逻辑
				// 	})
				// 	.catch((error) => {
				// 		console.log('请求失败', error)
				// 		// 在此处处理请求失败的逻辑
				// 	})
			}
			// 处理文件上传失败的操作
			const handleUploadError = (error, file) => {
				// 文件上传失败后的处理
				console.log('文件上传失败', error)
			}

			return {
				fileList,
				uploadUrl,
				handleBeforeUpload,
				handleUploadSuccess,
				handleUploadError,
				handleChange,
				formState,
				onFinish,
				onFinishFailed,
				pageSizeOptions,
				pageSize,
				currentPage,
				total,
				dataSource,
				handlePageChange,
				tableColumns,
				tableData,
				SiteOptions,
				username,
				SearchForm,
				onSearch,
				onViewRow,
				handleInput,
				onReset,
				formRef,
				onView,
				handleExpand,
				pagination,
				onChangePage,
				options
			}
		}
	}
</script>
<style lang="less" scoped>
	.search {
		padding-top: 20px;
		padding-left: 50px;
		margin-bottom: 32px;
		.btnBox {
			display: inline-block;
			width: 200px;
			display: flex;
			justify-content: space-around;
			align-items: center;
		}
	}
	.silt-title {
		display: flex;
	}
	.form {
		display: flex;
		flex-wrap: wrap;
		// justify-content: center;
		.form-item {
			width: 350px;
			margin-right: 20px;
		}
	}
	.item-submit {
		display: flex;
		justify-content: center;
		margin-top: 100px;
		.btn1 {
			width: 100px;
			margin-right: 20px;
		}
	}
	.ant-select {
		width: 250px;
	}
	.ant-input {
		width: 250px;
	}
	.ant-form-item-label {
		width: 150px;
	}
	.input {
		margin-right: 10px;
		margin-left: 40px;
		margin-top: 20px;
		.ant-input-affix-wrapper {
			height: 100px;
		}
	}
	.attachment {
		display: flex;
		// margin-top: 30px;
		div:first-child {
			width: 137px;
			text-align: right;
			margin-right: 9px;
		}
		span {
			color: red;
			margin-right: 3px;
		}
		p {
			font-size: 12px;
			color: #eb4897;
		}
	}
</style>
