<script setup name="fumigation">
	import Details from './fumigationEdit.vue'
	import { getList } from '@/api/storageJob/fumigation'

	const columns = [
		{
			title: '序号',
			customRender: ({ text, record, index }) => `${index + 1}`
		},
		{
			title: '企业名称',
			dataIndex: 'someField'
		},
		{
			title: '库区名称',
			dataIndex: 'orgName'
		},
		{
			title: '作业单号',
			dataIndex: 'orderNumber'
		},
		{
			title: '仓房名称',
			dataIndex: 'storehouseName'
		},
		{
			title: '熏蒸开始时间',
			dataIndex: 'startTime'
		},
		{
			title: '熏蒸结束时间',
			dataIndex: 'endTime'
		},
		{
			title: '作业负责人',
			dataIndex: 'xzfzr'
		},
		{
			title: '作业人员',
			dataIndex: 'xzzyrr'
		},
		...(hasPerm(['fumigationFilingApprovalView', 'doFumigationFilingApproval'])
			? [
					{
						title: '操作',
						dataIndex: 'action',
						align: 'center',
						width: 150
					}
			  ]
			: [])
	]
	const loadData = (parameter) => {
		return getList({ ...parameter, ...searchForm.value })
	}
	const addShow = ref(false)

	const openForm = () => {
		addShow.value = true
	}
	const editData = ref(null)
	const action = ref(null)
	const view = (data) => {
		action.value = 'view'
		editData.value = data
		addShow.value = true
	}

	const tableRef = ref()
	const refresh = () => {
		tableRef.value.refresh()
	}
	const searchForm = ref({
		orderNumber: null
	})
	const formRef = ref()
	const search = () => {
		refresh()
	}
	const reset = () => {
		formRef.value.resetFields()
	}
	const add = () => {
		action.value = 'add'
		addShow.value = true
	}
</script>

<template>
	<a-card :bordered="false">
		<s-table ref="tableRef" :columns="columns" :data="loadData" bordered :row-key="(record) => record.id">
			<template #operator class="table-operator">
				<a-space>
					<a-form ref="formRef" :model="searchForm" layout="inline">
						<a-form-item label="作业单号" name="orgName">
							<a-input v-model:value="searchForm.orderNumber" />
						</a-form-item>
					</a-form>

					<a-button type="primary" @click="search">
						<template #icon><plus-outlined /></template>
						查询
					</a-button>
					<a-button @click="reset">
						<template #icon><plus-outlined /></template>
						重置
					</a-button>
				</a-space>
			</template>
			<template #bodyCell="{ column, record }">
				<template v-if="column.dataIndex === 'action'">
					<a-space>
						<a @click="view(record)" v-if="hasPerm('fumigationFilingApprovalView')">查看</a>
					</a-space>
				</template>
			</template>
		</s-table>
	</a-card>
	<Details v-model:visible="addShow" :edit-data="editData" :action="action" />
	<!--	<Form v-model:visible="addShow" :edit-data="editData" :action="action" @on-approve="refresh"/>-->
</template>

<style scoped></style>
