<template>
	<!-- 位置信息管理 -->
	<div class="pricemoitorrecord">
		<a-card :bordered="false">
			<div style="cursor: pointer; width: 80px" @click="delCode"><left-outlined />返回</div>
			<br />

			<a-form :model="tableList" name="basic" autocomplete="off" v-if="tableList">
				<h3>验收检验</h3>
				<a-row>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="质检报告单号"
							name="zjbgdh"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-select :disabled="codes" v-model:value="tableList.zjbgdh" @change="handleChange">
								<a-select-option v-for="item in optionsGender" :key="item.unitInfoId" :value="item.unitInfoId">{{
									item.unitName
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="库区名称"
							name="orgName"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" v-model:value="tableList.orgName" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="库区地址"
							name="registeredAddress"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-select disabled v-model:value="tableList.registeredAddress">
								<a-select-option v-for="item in optionsGender" :key="item.id" :value="item.id">{{
									item.dictLabel
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="检验类别"
							name="jylb"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" :value="cocJYLB(tableList.jylb)" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="仓房名称"
							name="storeHouseName"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-input placeholder="请输入" disabled v-model:value="tableList.storeHouseName" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
							label="货位名称"
							name="warehouseName"
							:label-col="{ span: 10 }"
						>
							<a-input placeholder="请输入" disabled v-model:value="tableList.warehouseName" />
						</a-form-item>
					</a-col>
				</a-row>
				<a-row>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="品种"
							name="grainVarietyId"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-select :disabled="codes" :value="cocName(tableList.grainVarietyId)" @change="handleChange">
								<a-select-option v-for="item in optionsGender" :key="item.unitInfoId" :value="item.unitInfoId">{{
									item.unitName
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label=" 粮食等级"
							name="grainGradeId"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" :value="cocName(tableList.grainGradeId)" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label=" 粮食性质"
							name="grainNatureId"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-select disabled :value="cocName(tableList.grainNatureId)">
								<a-select-option v-for="item in optionsGender" :key="item.id" :value="item.id">{{
									item.dictLabel
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="入库日期"
							name="rkrq"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" :value="getDateDEl(tableList.rkrq)" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="收获年度"
							name="receiveYear"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-input placeholder="请输入" disabled v-model:value="tableList.receiveYear" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
							label="产地"
							name="produceArea"
							:label-col="{ span: 10 }"
						>
							<a-input placeholder="请输入" disabled v-model:value="tableList.produceArea" />
						</a-form-item>
					</a-col>
				</a-row>
				<a-row>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="检验单位"
							name="jydw"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-select :disabled="codes" v-model:value="tableList.jydw" @change="handleChange">
								<a-select-option v-for="item in optionsGender" :key="item.unitInfoId" :value="item.unitInfoId">{{
									item.unitName
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="检验依据"
							name="jyyj"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-select disabled v-model:value="tableList.jyyj">
								<a-select-option :value="'1'"> 国标</a-select-option>
								<a-select-option :value="'0'"> 其他</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="检验结果" name="checkResult" :label-col="{ span: 10 }">
							<a-select disabled v-model:value="tableList.checkResult">
								<a-select-option :value="1"> 合格</a-select-option>
								<a-select-option :value="0"> 不合格</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="检验日期" name="jysj" :label-col="{ span: 10 }">
							<a-input disabled placeholder="请输入" :value="getDateDEl(tableList.jysj)" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="检验人" name="jyr" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled v-model:value="tableList.jyr" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="报告出具时间" name="bgcjsj" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled v-model:value="tableList.bgcjsj" />
						</a-form-item>
					</a-col>
				</a-row>
				<a-row>
					<a-col :span="8">
						<a-form-item class="form-item" label="签发日期" name="qfrq" :label-col="{ span: 10 }">
							<a-select :disabled="codes" :value="getDateDEl(tableList.qfrq)" @change="handleChange">
								<a-select-option v-for="item in optionsGender" :key="item.unitInfoId" :value="item.unitInfoId">{{
									item.unitName
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="审核人姓名"
							name="shrxm"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" v-model:value="tableList.shrxm" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="食品安全指标是否合格"
							name="spaqzbsfhg"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-select disabled v-model:value="tableList.spaqzbsfhg">
								<a-select-option :value="'1'"> 合格</a-select-option>
								<a-select-option :value="'0'"> 不合格</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="指标类别"
							name="zblbArr"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" v-model:value="tableList.zblbArr" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label=" 指标判定结果"
							name="zbjgpd"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-input placeholder="请输入" disabled v-model:value="tableList.zbjgpd" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
							label="是否正常存储年限"
							name="sfzcccnx"
							:label-col="{ span: 10 }"
						>
							<a-select disabled v-model:value="tableList.sfzcccnx">
								<a-select-option :value="'0'"> 是</a-select-option>
								<a-select-option :value="'1'"> 否</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>
				<!--  -->
				<h3>样品信息</h3>
				<!--  -->
				<a-row>
					<a-col :span="8">
						<a-form-item class="form-item" label="抽样日期" name="qysj" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled :value="getDateDEl(tableList.qysj)" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="抽样单编号" name="qydbh" :label-col="{ span: 10 }">
							<a-input disabled placeholder="请输入" v-model:value="tableList.qydbh" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="抽样人员" name="qyrxm" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled :value="tableList.qyrxm" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="扦样区域" name="qyqy" :label-col="{ span: 10 }">
							<a-input disabled placeholder="请输入" v-model:value="tableList.qyqy" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="监督人姓名" name="jdrxm" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled v-model:value="tableList.jdrxm" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="样品编号" name="ypbh" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled v-model:value="tableList.ypbh" />
						</a-form-item>
					</a-col>
				</a-row>
				<a-row>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="样品数量"
							name="ypsl"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!', trigger: 'change' }]"
						>
							<a-input placeholder="请输入" disabled :value="tableList.ypsl" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="代表数量"
							name="dbsl"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-input disabled placeholder="请输入" v-model:value="tableList.dbsl" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item
							class="form-item"
							label="样品等级"
							name="ypdj"
							:label-col="{ span: 10 }"
							:rules="[{ required: true, message: '请输入!' }]"
						>
							<a-select disabled v-model:value="tableList.ypdj">
								<a-select-option v-for="item in optionsGender" :key="item.id" :value="item.id">{{
									item.dictLabel
								}}</a-select-option>
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label="样品状态" name="sampleStatus" :label-col="{ span: 10 }">
							<a-input disabled placeholder="请输入" v-model:value="tableList.sampleStatus" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item class="form-item" label=" 样品包装型号" name="samplePackageModel" :label-col="{ span: 10 }">
							<a-input placeholder="请输入" disabled v-model:value="tableList.samplePackageModel" />
						</a-form-item>
					</a-col>
				</a-row>
				<a-form-item>
					<!-- <div class="item-submit">
					<a-button class="btn1" @click="delCode">取消</a-button>
					<a-button :disabled="code" class="btn1" type="primary" html-type="submit">保存</a-button>
				</div> -->
				</a-form-item>
			</a-form>
			<h3>检验项目及依据</h3>
			<a-table :columns="tableColumns" :data-source="tablleitem" :pagination="false" bordered> </a-table>

			<!-- <vxe-table
				border
				height="1000px"
				:column-config="{ resizable: true }"
				:align="allAlign"
				:merge-cells="mergeCells"
				:data="tableDataDel"
			>
				<vxe-column field="name" title="指标类别"></vxe-column>
				<vxe-column field="role" title="检验项目"></vxe-column>
				<vxe-column field="sex" title="检验值"></vxe-column>
				<vxe-column field="age" title="单项结论"></vxe-column>
				<vxe-column field="ages" title="检验方法"></vxe-column>
			</vxe-table> -->
		</a-card>
	</div>
</template>
<script setup>
	import { listPagination } from '@/hook/listlistPagination.js'
	import { reactive, ref, onMounted, watch } from 'vue'
	import { useRouter, useRoute } from 'vue-router'
	import { defineComponent } from 'vue'
	import business from '@/api/security/index.js'
	import uils from '@/utils/utils'
	import { enumMap } from '@/hook/enumMap.js'
	const {
		cocJYLB,
		cocName,
		getEnumByEnumCode,
		cocDEl,
		cocDElⅣ,
		cocDElⅣV,
		cocTFXTXS,
		cocDLMXS,
		cocBUG_INSPECTION_TYPE
	} = enumMap()
	const formRef = ref(null)
	const router = useRouter()
	const route = useRoute()
	const delCode = () => {
		router.back()
	}

	const allAlign = ref()
	const tableDataDel = ref([
		{ id: 10001, name: 'Test1', nickname: 'T1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
		{ id: 10002, name: 'Test2', nickname: 'T2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
		{ id: 10003, name: 'Test3', nickname: 'T3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
		{ id: 10004, name: 'Test4', nickname: 'T4', role: 'Designer', sex: 'Women', age: 23, address: 'test abc' },
		{ id: 10005, name: 'Test5', nickname: 'T5', role: 'Develop', sex: 'Women', age: 30, address: 'Shanghai' },
		{ id: 10006, name: 'Test6', nickname: 'T6', role: 'Designer', sex: 'Women', age: 21, address: 'test abc' },
		{ id: 10007, name: 'Test7', nickname: 'T7', role: 'Test', sex: 'Man', age: 29, address: 'test abc' },
		{ id: 10008, name: 'Test8', nickname: 'T8', role: 'Develop', sex: 'Man', age: 35, address: 'test abc' },
		{ id: 10009, name: 'Test9', nickname: 'T9', role: '3', sex: 'Man', age: 28, address: 'test abc' },
		{ id: 100010, name: 'Test10', nickname: 'T10', role: '3', sex: 'Women', age: 22, address: 'Guangzhou' },
		{ id: 100011, name: 'Test11', nickname: 'T11', role: '3', sex: 'Man', age: 32, address: 'Shanghai' },
		{ id: 100012, name: 'Test12', nickname: 'T12', role: '2', sex: 'Women', age: 23, address: 'test abc' },
		{ id: 100013, name: 'Test13', nickname: 'T13', role: '2', sex: 'Women', age: 30, address: 'Shanghai' },
		{ id: 100014, name: 'Test14', nickname: 'T14', role: '3', sex: 'Women', age: 21, address: 'test abc' },
		{ id: 100015, name: 'Test15', nickname: 'T15', role: '4', sex: 'Man', age: 29, address: 'test abc' },
		{ id: 100016, name: 'Test16', nickname: 'T16', role: '2', sex: 'Man', age: 35, address: 'test abc' },
		{ id: 100016, name: 'Test17', nickname: 'T16', role: '2', sex: 'Man', age: 35, address: 'test abc' },
		{ id: 100016, name: 'Test18', nickname: 'T16', role: '2', sex: 'Man', age: 35, address: 'test abc' }
	])
	const mergeCells = ref([
		{ row: 0, col: 0, rowspan: 6, colspan: 1 },
		// { row: 0, col: 1, rowspan: 6, colspan: 1 }
		{ row: 6, col: 0, rowspan: 6, colspan: 1 },
		{ row: 12, col: 0, rowspan: 6, colspan: 1 }
	])

	const tableColumns = [
		{
			title: '指标类别',
			align: 'center',
			colSpan: 1,
			dataIndex: 'parentInspectionItemName',
			ellipsis: true,
			customCell: (record, rowIndex, column) => ({
				rowSpan: record.index1ColSpan
			})
			// customCell: (record, rowIndex, column) => {
			// 	if (rowIndex == 0) {
			// 		return {
			// 			rowSpan: 5
			// 			// colSpan: 1
			// 		}
			// 	} else if (rowIndex == 5) {
			// 		return {
			// 			rowSpan: 5
			// 			// colSpan: 1
			// 		}
			// 	} else if (rowIndex == 10) {
			// 		return {
			// 			rowSpan: 5
			// 			// colSpan: 1
			// 		}
			// 	} else {
			// 		return {
			// 			rowSpan: 0
			// 		}
			// 	}
			// }
		},

		{
			title: '检验项目',
			align: 'center',
			ellipsis: true,
			dataIndex: 'inspectionItemName'
		},
		{
			title: '检验值',
			align: 'center',
			ellipsis: true,
			dataIndex: 'inspectionValue'
		},
		{
			title: '单项结论',
			align: 'center',
			ellipsis: true,
			dataIndex: 'singleConclusion'
		},
		{
			title: '检验方法',
			align: 'center',
			ellipsis: true,
			dataIndex: 'inspectionMethod'
		}
	]
	// const { DEl, change, tableData, onSearch, handlePageChange, pagination, Search, onReset, SearchFormDel } =
	// 	listPagination(
	// 		{ interfaceName: '', zcdzCityName: '', zcdzAreaName: '' },
	// 		business.SHUJULIANGlist,
	// 		{},
	// 		{ sortOrder: 'ASCEND', current: 1, size: 20 }
	// 	)
	const tableList = ref([])
	const tablleitem = ref([])
	const Dellist = async (v) => {
		const res = await business.TJFXviewgetByMasterId({ id: v })
		tableList.value = res
		function sortByParentInspectionItemId(data) {
			return data.sort((a, b) => a.parentInspectionItemId - b.parentInspectionItemId)
		}
		const sortedData = sortByParentInspectionItemId(res.item)
		tablleitem.value = sortedData.map((item, index) => {
			const count = res.item.filter((i) => i.parentInspectionItemId === item.parentInspectionItemId).length
			return {
				...item,
				index1ColSpan:
					index === res.item.findIndex((i) => i.parentInspectionItemId === item.parentInspectionItemId) ? count : 0
			}
		})
		console.log(tablleitem.value)
	}

	const table = ref({
		unitName: '',
		dwdm: '',
		dwlxName: '',
		fddbr: '',
		frlxfs: '',
		dzyx: '',
		zcrq: '',
		zcdz: '',
		zczb: '',
		unitInfoId: '',
		creditScore: '',
		creditLevel: '',
		fulfilmentTimes: '',
		breachTimes: '',
		evaluationUnit: '',
		administrativePenaltyInfo: '',
		businessAbnormalInfo: '',
		illegalDishonestyInfo: ''
	})
	const code = ref(true)
	const codes = ref(true)
	const handleChange = (val) => {}
	const optionsGender = ref([])

	watch(
		() => route.query.codeOOPP,
		async (newVal) => {
			const codeDel = route.query.codeOOPP
			if (codeDel == 1) {
				// console.log(3)
			} else if (Boolean(route.query.codeOOPP) == true) {
				// console.log(3)
				Dellist(route.query.id)
			} else {
				// console.log(3)
			}
		},
		{ immediate: true, deep: true }
	)
	const getDateDEl = (v) => {
		const formattedDate = uils.getDate('YYYY-MM-DD', v)
		return formattedDate
	}
</script>
<style lang="less" scoped></style>
