<template>
	<div class="planningPreparationView">
		<h3 class="view_title">意见查看</h3>
		<div class="list">
			<a-table :dataSource="tableData" :columns="tableColumns" v-if="tableData[0]">
				<template #bodyCell="{ column, record }">
					<template v-if="column.key === 'attachment'">
						<DIYUPLoad
							v-for="(item, index) in record.attachment"
							:key="index"
							:change="changeUpload"
							:urls="item"
							disabled
						/>
						<!-- <div class="file_row" v-for="(item, index) in record._附件" :key="index">
							<file-text-outlined style="color: #666" />
							<span class="file_name">{{ item }}</span>
							<eye-outlined class="icon" style="color: rgb(24, 144, 255)" />
							<cloud-download-outlined class="icon" @click="onDownloadFile(item)" style="color: rgb(24, 144, 255)" />
						</div> -->
					</template>
				</template>
			</a-table>
			<div class="view_title" v-else>初稿意见反馈尚未提交</div>
		</div>
	</div>
</template>
<script setup name="planningPreparationView">
	import ORG from '@/api/basic.info/unReporCityApi.js'
	import tools from '../../../utils/utils.js'
	import API from '@/api/policy.info/planningFirstOpinion'
	import { useRoute } from 'vue-router'
	import { messages } from '@/locales/index.js'
	import global from '@/api/basic.info/global.js'
	const route = useRoute()
	const ORGList = ref([])
	const tableColumns = [
		{ title: '处室名称', align: 'center', width: 150, dataIndex: 'sysOrgName' },
		{ title: '反馈时间', align: 'center', width: 200, dataIndex: 'feedbackTime' },
		{ title: '意见', dataIndex: 'adviceContent' },
		{ title: '附件', width: 400, key: 'attachment' }
	]
	const tableData = ref([])

	onMounted(() => {
		CGYJFKviewAsync()
	})

	const CGYJFKviewAsync = async () => {
		const res = await ORG.CGYJFKview({ id: route.query?.id })
		res.forEach((v) => {
			return (v.attachment = (v.attachment || '').split(',').filter((v) => v))
		})
		// res.attachment = (res.attachment || '').split(',').filter((v) => v)
		// console.log(res.attachment)
		tableData.value = res
		console.log(res)
	}

	function onDownloadFile(row) {
		tools.downloadFile(row.url, { name: row.name })
	}
	function changeUpload(fd) {
		return global.uploadFile(fd).then((reg) => {
			return reg
		})
	}
</script>
<style lang="less" scoped>
	.view_title {
		font-size: 24px;
		color: #333;
		margin: 20px;
	}
	.list {
		.file_row {
			margin: 4px;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			.icon {
				margin: 0 10px;
				cursor: pointer;
			}
		}
		.file_name {
			margin: 0 10px;
			max-width: 300px;
			text-overflow: ellipsis;
			overflow: hidden;
			white-space: nowrap;
		}
	}
</style>
