<template>
<!-- 初稿意见反馈 -->
<div class="planningFirstFeedback pageContent">
<a-space class="search">
	规划名称:<a-input v-model:value="SearchForm._规划名称" />
	<div class="btnBox">
		<a-button type="primary" @click="onSearch"> 查询 </a-button>
		<a-button @click="onReset"> 重置 </a-button>
	</div>
</a-space>
<div class="list">
	<a-table :dataSource="tableData" :pagination="tablePage" :columns="tableColumns" @change="onChangePage">
		<template #bodyCell="{ column, record,index }">
			<template v-if="column.key === 'INDEX'">{{index+1}}</template>
			<template v-else-if="column.key === 'CZ'">
				<a-button class="view" @click="onFeedbackRow(record)">反馈</a-button>
			</template>
		</template>
	</a-table>
</div>
<a-modal v-model:visible="FeedbackDialog.open" :title="FeedbackDialog.title" @ok="onDialogOk" width="800px">
	<a-descriptions>
		<a-descriptions-item v-for="item in FeedbackDialog.planOptions"
			:label="item.label" :key="item.label" :span="item.span"
		>{{FeedbackDialog.form[item.prop]}}</a-descriptions-item>
	</a-descriptions>
	<a-form ref="DialogForm" :model="FeedbackDialog.form" :rules="FeedbackDialog.formRules">
		<a-form-item v-for="item in FeedbackDialog.formOptions" :key="item.label"
			:label="item.label" :name="item.prop" 
		>
			<a-input v-if="item.type === 'input'" v-model:value="FeedbackDialog.form[item.prop]"></a-input>
			<a-textarea v-if="item.type === 'textarea'" :auto-size="{minRows:3}" v-model:value="FeedbackDialog.form[item.prop]"></a-textarea>
			<a-select v-else-if="item.type === 'select'" v-model:value="FeedbackDialog.form[item.prop]">
				<a-select-option v-for="citem in item.values" :key="citem.valiue" :value="citem.value">{{citem.label}}</a-select-option>
			</a-select>
			<a-date-picker v-else-if="item.type === 'date'" v-model:value="FeedbackDialog.form[item.prop]"></a-date-picker>
			<DIYUPLoad v-else-if="item.type === 'upload'" v-model="FeedbackDialog.form[item.prop]" :change="changeUpload" :disabled="item.disabled" />
		</a-form-item>
	</a-form>
</a-modal>
</div>
</template>
<script setup name="planningFirstFeedback">
import global from "@/api/basic.info/global.js";
import { useRouter } from "vue-router";

const router = useRouter();
const SearchForm = reactive({
	_规划名称:'',
	_截止日期:'',
});
const tableColumns = [
	{title:'序号',width:100,align:'center',key:'INDEX'},
	{title:'规划名称',dataIndex:'_规划名称'},
	{title:'截止日期',dataIndex:'_截止日期'},
	{title:'操作',width:400,key:'CZ'},
];
const tablePage = reactive({
	total:0,
	current:1,
	size:20,
});
const tableData = ref([{'':'12456789'}]);
const DialogForm = ref(null);
const FeedbackDialog = reactive({
	open:false,
	title:'',
	row:undefined,
	formRules:{
		'_处室名称':[{required:true,trigger:'change',message:'请输入填写处室名称！'}],
		'_人员名称':[{required:true,trigger:'change',message:'请输入填写人员名称！'}],
		'_时间':[{required:true,trigger:'change',message:'请输入选择时间！'}],
		'_处室建议':[{required:true,trigger:'change',message:'请输入处室建议！'}],
	},
	formOptions:[
		{label:'处室名称',prop:'_处室名称',type:'input',span:1},
		{label:'人员名称',prop:'_人员名称',type:'input',span:1},
		{label:'时间',prop:'_时间',type:'date',span:1},
		{label:'处室建议',prop:'_处室建议',type:'textarea',span:1},
		{label:'附件',prop:'_附件',type:'upload',span:1},
	],
	planOptions:[
		{label:'规划名称',prop:'_规划名称',type:'input',span:1},
		{label:'收集处室',prop:'_收集处室',type:'select',span:1},
		{label:'规划正文',prop:'_规划正文',type:'textarea',span:2},
		{label:'附件',prop:'_附件',type:'upload',span:2},
	],
	form:{}
});
function onSearch(){

}
function onReset(){
	SearchForm._规划名称 = '';
	SearchForm._截止日期 = '';
}
function onChangePage(ev){
	Object.assign(tablePage,ev);
	onSearch();
}

function onFeedbackRow(row){
	FeedbackDialog.form = row;
	FeedbackDialog.title = '填写意见';
	FeedbackDialog.open = true;
}
function changeUpload(fd){
	return global.uploadFile(fd).then(reg=>{
		return reg;
	})
}
function onDialogOk(){
	DialogForm.value.validate().then(reg=>{

	})
}
</script>
<style lang="less" scoped>
.view { background-color: rgba(112, 125, 233); color: #fff; }
.edit { background-color: rgba(210, 176, 61); color: #fff; }
.remove { background-color: rgba(255, 70, 70); color: #fff; }
.opinion { background-color: rgba(83, 184, 36); color: #fff; }
.pageContent{
	background:#fff; padding:10px 20px;
	.search{
		padding:10px 0;
		.btnBox{
			display:flex;
			>*{ margin-right:10px; }
		}
	}
}

</style>