<script setup name="fumigationFilingApproval">
import Form from './form.vue'
import {list} from '@/api/basic.info/fumigationFilingApi'

const columns = [
	{
		title: '熏蒸作业单号',
		dataIndex: 'orderNumber'
	},
	{
		title: '熏蒸作业单位',
		dataIndex: 'orgName'
	},
	{
		title: '负责人',
		dataIndex: 'dwfzr'
	},
	{
		title: '计划熏蒸日期',
		dataIndex: 'jhxzrq'
	},
	{
		title: '仓容',
		dataIndex: 'cfrl'
	},
	{
		title: '数量',
		dataIndex: 'numberUpdate'
	},
	{
		title: '备案日期',
		dataIndex: 'createTime'
	},
	...(hasPerm(['fumigationFilingApprovalView', 'doFumigationFilingApproval']) ? [{
		title: '操作',
		dataIndex: 'action',
		align: 'center',
		width: 150
	}] : [])
]
const loadData = (parameter) => {
	console.log('ppp ', parameter)
	// return Promise.resolve([])
	return list(parameter)
}
const addShow = ref(false)

const openForm = () => {
	addShow.value = true
	console.log('123123')
}
const editData = ref(null)
const action = ref(null)
const view = (data) => {
	action.value = 'view'
	editData.value = data
	addShow.value = true
}
const approve = (data) => {
	action.value = 'approve'
	editData.value = data
	addShow.value = true
}
const tableRef = ref(null)
const refresh = () => {
	tableRef.value.refresh()
}
</script>

<template>
	<a-card :bordered="false">
		<s-table ref="tableRef" :columns="columns" :data="loadData" bordered :row-key="(record) => record.id">
			<template #bodyCell="{ column, record }">
				<template v-if="column.dataIndex === 'action'">
					<a-space>
						<a @click="view(record)" v-if="hasPerm('fumigationFilingApprovalView')">查看</a>
						<a-divider
							type="vertical"
							v-if="hasPerm(['fumigationFilingApprovalView', 'doFumigationFilingApproval'], 'and') &&
								record.statusType === 1
							"
						/>
						<a @click="approve(record)" v-if="hasPerm('doFumigationFilingApproval')">审批</a>
					</a-space>
				</template>
			</template>
		</s-table>
	</a-card>
	<Form v-model:visible="addShow" :edit-data="editData" :action="action" @on-approve="refresh"/>
</template>

<style scoped>

</style>
