<!-- 查看功能 -->
<template>
	<div style="height: 100%">
		<a-form
			:label-col="labelCol"
			:wrapper-col="wrapperCol"
			layout="horizontal"
			:disabled="componentDisabled"
			style="max-width: 1000px"
			class="form-box"
		>
			<a-row :gutter="42">
				<a-col :span="8">
					<a-form-item label="监测点名称"><a-input :disabled="true" v-model:value="typeObj.monitorName" /></a-form-item
				></a-col>
				<a-col :span="8">
					<a-form-item label="所属市州"> <a-input :disabled="true" v-model:value="typeObj.orgName" /> </a-form-item
				></a-col>
				<a-col :span="8"
					><a-form-item label="详细地址"> <a-input :disabled="true" v-model:value="typeObj.address" /> </a-form-item
				></a-col>
			</a-row>
			<a-row :gutter="42">
				<a-col :span="8"
					><a-form-item label="价格采集人">
						<a-input :disabled="true" v-model:value="typeObj.userCollectName" /> </a-form-item
				></a-col>
				<a-col :span="8"
					><a-form-item label="联系方式"> <a-input :disabled="true" v-model:value="information" /> </a-form-item
				></a-col>
			</a-row>
		</a-form>
		<table style="width: 100%; height: 76%">
			<tr>
				<td colspan="3">品种</td>
				<td>收购价</td>
				<td>入库价</td>
				<td>出库价</td>
				<td>出厂价</td>
				<td>批发价</td>
				<td>零售价</td>
			</tr>
			<tr>
				<td rowspan="3">原粮</td>
				<td colspan="2">小麦</td>
				<td>{{ xm[0] }}</td>
				<td>{{ xm[1] }}</td>
				<td>{{ xm[2] }}</td>
				<td>{{ xm[3] }}</td>
				<td>{{ xm[4] }}</td>
				<td>{{ xm[5] }}</td>
			</tr>
			<tr>
				<td colspan="2">青稞</td>
				<td>{{ qk[0] || ' ' }}</td>
				<td>{{ qk[1] || ' ' }}</td>
				<td>{{ qk[2] || ' ' }}</td>
				<td>{{ qk[3] || ' ' }}</td>
				<td>{{ qk[4] || ' ' }}</td>
				<td>{{ qk[5] || ' ' }}</td>
			</tr>
			<tr>
				<td colspan="2">油菜籽</td>
				<td>{{ ycz[0] || ' ' }}</td>
				<td>{{ ycz[1] || ' ' }}</td>
				<td>{{ ycz[2] || ' ' }}</td>
				<td>{{ ycz[3] || ' ' }}</td>
				<td>{{ ycz[4] || ' ' }}</td>
				<td>{{ ycz[5] || ' ' }}</td>
			</tr>
			<tr>
				<td rowspan="3">杂粮</td>
				<td colspan="2">黄豆</td>
				<td>{{ hd[0] || ' ' }}</td>
				<td>{{ hd[1] || ' ' }}</td>
				<td>{{ hd[2] || ' ' }}</td>
				<td>{{ hd[3] || ' ' }}</td>
				<td>{{ hd[4] || ' ' }}</td>
				<td>{{ hd[5] || ' ' }}</td>
			</tr>
			<tr>
				<td colspan="2">玉米面</td>
				<td>{{ ymm[0] || ' ' }}</td>
				<td>{{ ymm[1] || ' ' }}</td>
				<td>{{ ymm[2] || ' ' }}</td>
				<td>{{ ymm[3] || ' ' }}</td>
				<td>{{ ymm[4] || ' ' }}</td>
				<td>{{ ymm[5] || ' ' }}</td>
			</tr>
			<tr>
				<td colspan="2">小米</td>
				<td>{{ xiaom[0] || ' ' }}</td>
				<td>{{ xiaom[1] || ' ' }}</td>
				<td>{{ xiaom[2] || ' ' }}</td>
				<td>{{ xiaom[3] || ' ' }}</td>
				<td>{{ xiaom[4] || ' ' }}</td>
				<td>{{ xiaom[5] || ' ' }}</td>
			</tr>
			<tr>
				<td rowspan="9">成品粮</td>
				<td rowspan="3">菜籽油</td>
				<td>一级菜籽油</td>
				<td>{{ yjczy[0] || ' ' }}</td>
				<td>{{ yjczy[1] || ' ' }}</td>
				<td>{{ yjczy[2] || ' ' }}</td>
				<td>{{ yjczy[3] || ' ' }}</td>
				<td>{{ yjczy[4] || ' ' }}</td>
				<td>{{ yjczy[5] || ' ' }}</td>
			</tr>
			<tr>
				<td>三级菜籽油</td>
				<td>{{ sjczy[0] || ' ' }}</td>
				<td>{{ sjczy[1] || ' ' }}</td>
				<td>{{ sjczy[2] || ' ' }}</td>
				<td>{{ sjczy[3] || ' ' }}</td>
				<td>{{ sjczy[4] || ' ' }}</td>
				<td>{{ sjczy[5] || ' ' }}</td>
			</tr>
			<tr>
				<td>小榨菜籽油</td>
				<td>{{ xzczy[0] || ' ' }}</td>
				<td>{{ xzczy[1] || ' ' }}</td>
				<td>{{ xzczy[2] || ' ' }}</td>
				<td>{{ xzczy[3] || ' ' }}</td>
				<td>{{ xzczy[4] || ' ' }}</td>
				<td>{{ xzczy[5] || ' ' }}</td>
			</tr>
			<tr>
				<td rowspan="2">面粉</td>
				<td>特一粉</td>
				<td>{{ tyf[0] || ' ' }}</td>
				<td>{{ tyf[1] || ' ' }}</td>
				<td>{{ tyf[2] || ' ' }}</td>
				<td>{{ tyf[3] || ' ' }}</td>
				<td>{{ tyf[4] || ' ' }}</td>
				<td>{{ tyf[5] || ' ' }}</td>
			</tr>
			<tr>
				<td>牛肉面粉</td>
				<td>{{ nrmf[0] || ' ' }}</td>
				<td>{{ nrmf[1] || ' ' }}</td>
				<td>{{ nrmf[2] || ' ' }}</td>
				<td>{{ nrmf[3] || ' ' }}</td>
				<td>{{ nrmf[4] || ' ' }}</td>
				<td>{{ nrmf[5] || ' ' }}</td>
			</tr>
			<tr>
				<td rowspan="2">粳米</td>
				<td>一级长粒粳米</td>
				<td>{{ yjclgm[0] || ' ' }}</td>
				<td>{{ yjclgm[1] || ' ' }}</td>
				<td>{{ yjclgm[2] || ' ' }}</td>
				<td>{{ yjclgm[3] || ' ' }}</td>
				<td>{{ yjclgm[4] || ' ' }}</td>
				<td>{{ yjclgm[5] || ' ' }}</td>
			</tr>
			<tr>
				<td>一级圆粒粳米</td>
				<td>{{ yjylgm[0] || ' ' }}</td>
				<td>{{ yjylgm[1] || ' ' }}</td>
				<td>{{ yjylgm[2] || ' ' }}</td>
				<td>{{ yjylgm[3] || ' ' }}</td>
				<td>{{ yjylgm[4] || ' ' }}</td>
				<td>{{ yjylgm[5] || ' ' }}</td>
			</tr>
			<tr></tr>
			<tr></tr>
			<tr>
				<td rowspan="3">储备粮</td>
				<td colspan="2">省级储备小麦</td>
				<td>{{ sjcbxm[0] || ' ' }}</td>
				<td>{{ sjcbxm[1] || ' ' }}</td>
				<td>{{ sjcbxm[2] || ' ' }}</td>
				<td>{{ sjcbxm[3] || ' ' }}</td>
				<td>{{ sjcbxm[4] || ' ' }}</td>
				<td>{{ sjcbxm[5] || ' ' }}</td>
			</tr>
			<tr>
				<td colspan="2">省级储备青稞</td>
				<td>{{ sjcbqk[0] || ' ' }}</td>
				<td>{{ sjcbqk[1] || ' ' }}</td>
				<td>{{ sjcbqk[2] || ' ' }}</td>
				<td>{{ sjcbqk[3] || ' ' }}</td>
				<td>{{ sjcbqk[4] || ' ' }}</td>
				<td>{{ sjcbqk[5] || ' ' }}</td>
			</tr>
			<tr>
				<td colspan="2">省级储备菜籽油</td>
				<td>{{ sjcbczy[0] || ' ' }}</td>
				<td>{{ sjcbczy[1] || ' ' }}</td>
				<td>{{ sjcbczy[2] || ' ' }}</td>
				<td>{{ sjcbczy[3] || ' ' }}</td>
				<td>{{ sjcbczy[4] || ' ' }}</td>
				<td>{{ sjcbczy[5] || ' ' }}</td>
			</tr>
			<tr rowspan="3">
				<td colspan="9" class="remark">
					<a-textarea class="text-input" :disabled="true" v-model:value="remark" placeholder="备注" :rows="9" />
				</td>
			</tr>
		</table>
	</div>
</template>

<script setup>
	// import bizGrainPriceCollectApi from '@/api/basic.info/bizGrainPriceCollectApi'
	const remark = ref('')
	const information = ref('')
	const props = defineProps({
		detailsData: {
			type: Object,
			default: () => {}
		}
	})
	const arrList = ref([])
	const xm = ref([])
	const qk = ref([])
	const ycz = ref([])
	const hd = ref([])
	const ymm = ref([])
	const xiaom = ref([])
	const yjczy = ref([]) //三级分类
	const sjczy = ref([]) //三级分类
	const xzczy = ref([]) //三级分类
	const tyf = ref([]) //三级分类
	const nrmf = ref([]) //三级分类
	const yjclgm = ref([]) //三级分类
	const yjylgm = ref([]) //三级分类
	const sjcbxm = ref([]) //省级
	const sjcbqk = ref([])
	const sjcbczy = ref([])
	// const typeObj = computed(() => props.detailsData)
	const typeObj = ref({ monitorName: '', userCollectName: '', orgName: '', address: '' })
	// 查看详情数据
	const getDetailData = () => {
		const id = typeObj.value.id
		bizGrainPriceCollectApi.bizGrainPriceCollectDetail({ id }).then((res) => {
			xm.value = []
			qk.value = []
			ycz.value = []
			hd.value = []
			ymm.value = []
			xiaom.value = []
			yjczy.value = []
			sjczy.value = []
			xzczy.value = []
			tyf.value = []
			nrmf.value = []
			yjclgm.value = []
			yjylgm.value = []
			sjcbxm.value = []
			sjcbqk.value = []
			sjcbczy.value = []
			remark.value = res.remark
			information.value = res.userCollectPhone
			arrList.value = res.collectCategoryList

			const priceMap = {
				11: {
					1: xm,
					2: xm,
					3: xm,
					4: xm,
					5: xm,
					6: xm
				},
				12: {
					1: qk,
					2: qk,
					3: qk,
					4: qk,
					5: qk,
					6: qk
				},
				13: {
					2: ycz,
					3: ycz,
					4: ycz,
					5: ycz,
					6: ycz
				},
				21: {
					1: hd,
					2: hd,
					3: hd,
					4: hd,
					5: hd,
					6: hd
				},
				22: {
					1: ymm,
					2: ymm,
					3: ymm,
					4: ymm,
					5: ymm,
					6: ymm
				},
				31: {
					1: xiaom,
					2: xiaom,
					3: xiaom,
					4: xiaom,
					5: xiaom,
					6: xiaom
				},
				41: {
					1: sjcbxm,
					2: sjcbxm,
					3: sjcbxm,
					4: sjcbxm,
					5: sjcbxm,
					6: sjcbxm
				},
				42: {
					1: sjcbqk,
					2: sjcbqk,
					3: sjcbqk,
					4: sjcbqk,
					5: sjcbqk,
					6: sjcbqk
				},
				43: {
					1: sjcbczy,
					2: sjcbczy,
					3: sjcbczy,
					4: sjcbczy,
					5: sjcbczy,
					6: sjcbczy
				},
				311: {
					1: yjczy,
					2: yjczy,
					3: yjczy,
					4: yjczy,
					5: yjczy,
					6: yjczy
				},
				312: {
					1: sjczy,
					2: sjczy,
					3: sjczy,
					4: sjczy,
					5: sjczy,
					6: sjczy
				},
				313: {
					1: xzczy,
					2: xzczy,
					3: xzczy,
					4: xzczy,
					5: xzczy,
					6: xzczy
				},
				321: {
					1: tyf,
					2: tyf,
					3: tyf,
					4: tyf,
					5: tyf,
					6: tyf
				},
				322: {
					1: nrmf,
					2: nrmf,
					3: nrmf,
					4: nrmf,
					5: nrmf,
					6: nrmf
				},
				331: {
					1: yjclgm,
					2: yjclgm,
					3: yjclgm,
					4: yjclgm,
					5: yjclgm,
					6: yjclgm
				},
				332: {
					1: yjylgm,
					2: yjylgm,
					3: yjylgm,
					4: yjylgm,
					5: yjylgm,
					6: yjylgm
				}
			}

			arrList.value.forEach((item) => {
				if (item.threeLevel === 0 && priceMap[item.secondLevel] && priceMap[item.secondLevel][item.priceType]) {
					if (item.price) {
						priceMap[item.secondLevel][item.priceType].value[item.priceType - 1] = item.price
					} else if (priceMap[item.secondLevel][item.priceType].value.length <= item.priceType - 1) {
						priceMap[item.secondLevel][item.priceType].value[item.priceType - 1] = null
					}
				}
			})
		})
	}
	onMounted(() => {})
	watch(
		() => props.detailsData,
		async (newValue, oldvalue) => {
			await nextTick()
			// getDetailData()
		},
		{ deep: true, immediate: true }
	)
</script>
<style lang="less" scoped>
	table {
		text-align: center;
		border: 1px solid #000;
	}
	td {
		border: 1px solid #000;
	}
	.ant-form-item-control-input {
		width: 260px;
	}
	.form-box {
		margin-bottom: 24px;
	}
	.text-input {
		background-color: initial;
		border: none;
	}
</style>
