<template>
	<div class="sensitive-words">
		<pageSearch ref="searchTableRef" :searchConfig="searchConfig"> </pageSearch>
		<pageContent ref="tableListRef" :total="total" :contentConfig="contentConfig" :pageList="tableData">
			<template #button>
				<el-button type="primary" @click="handleAdd()">导出</el-button>
			</template>
			<template #operate="scope">
				<el-button type="primary" link @click="handleDetails(scope.row.rentalCompanyId)"> 查看 </el-button>
				<!-- <el-button type="primary" link @click="handleDelete(scope.row.rentalCompanyId)"> 处理 </el-button> -->
			</template>
		</pageContent>
	</div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
import contentConfig from './config/content.config';
import pageContent from '@/components/components/pageContent.vue';
import searchConfig from './config/search.config';
import pageSearch from '@/components/components/pageSearch.vue';
import useSystemStore from '@/store/main';
import { outTypeList } from '@/libs/commonMeth';

const allNotificationStatus = outTypeList('bj_notify_os'); // 通报整体状态
const bj_notification_type = outTypeList('bj_notification_type'); //通报类型
const categoryOnm = outTypeList('bj_category_onm'); // 通报事项类别
const notificationStatus = outTypeList('bj_notification_status'); // 通报状态
const isFeedback = outTypeList('bj_is_feedback'); // 是否需要反馈
const overdueStatus = outTypeList('bj_overdue_status'); // 超期状态
const takeMeasures = outTypeList('bj_take_measures'); // 采取措施
const bj_lssuing_unit = outTypeList('bj_lssuing_unit'); //发出单位

const systemStore = useSystemStore();

const total = ref(0);
const pageSize = ref([10, 20, 30]);
const tableData = ref([]);
const tableListRef = ref();
const router = useRouter();

// 操作弹框
import usePageModal from '@/components/components/hooks/usePageDetails';
const { modalRef, handleNewDataClick, handleEditDataClick, handleCheckDataClick, handlePageDetail } =
	usePageModal();

const handleDetails = async (id: string) => {
	router.push({
		name: 'viewHistoricalDataDetail',
		query: { type: 'detail' },
	});
};

// 新增按钮
const handleAdd = () => {
	router.push({
		name: 'addPublish',
		query: { type: 'add' },
	});
};
const searchTableRef = ref();
const onClickDeleta = async (row: any) => {
	ElMessageBox.confirm('确认删除此条数据吗？', '删除', {
		confirmButtonText: '确认',
		cancelButtonText: '取消',
		type: 'warning',
	}).then(() => {
		// 删除后的回调
	});
};
// 删除按钮
function handleDelete(value: any) {
	ElMessageBox.confirm('是否删除这条数据？', '删除提示', {
		confirmButtonText: '确定',
		cancelButtonText: '取消',
		type: 'warning',
	})
		.then(() => {
			systemStore.deletePageDataAction(contentConfig.pageName, value);
		})
		.catch(() => {
			ElMessage({
				type: 'info',
				message: '取消删除',
			});
		});
}

// 筛选-状态赋值
async function searchItem() {
	searchConfig.formItems.forEach(item => {
		if (item.prop === 'notificationType') {
			item.options = bj_notification_type;
		}
		if (item.prop === 'conm') {
			item.options = categoryOnm;
		}
		if (item.prop === 'publishingUnit') {
			item.options = bj_lssuing_unit;
		}
		if (item.prop === 'notificationStatus') {
			item.options = notificationStatus;
		}
		if (item.prop === 'takeMeasures') {
			item.options = takeMeasures;
		}
		if (item.prop === 'overdueStatus') {
			item.options = overdueStatus;
		}
		if (item.prop === 'wfir') {
			item.options = isFeedback;
		}
	});
}
searchItem();
</script>

<style scoped lang="scss">
.sensitive-words {
	margin: 20px;
}

.status {
	cursor: pointer;
	position: relative;

	.status-tip {
		position: absolute;
		top: 2px;
		left: 60px;
	}
}

.dialog-tip {
	text-align: center;
}
</style>
