<template>
	<div class="sensitive-words">
		<pageSearch ref="searchTableRef" :searchConfig="searchConfig" />

			<pageContent ref="tableListRef" :total="total" :contentConfig="contentConfig" :pageList="tableData">
					<template #button>
							<el-button type="primary" @click="handleAdd()">新增</el-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="handleEdit(scope.row.rentalCompanyId)">
									编辑
							</el-button>
							<el-button type="primary" link @click="handleDelete(scope.row.rentalCompanyId)">
									删除
							</el-button>
					</template>
			</pageContent>
			<router-view></router-view>
	</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 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 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 handleEdit = async (id: string) => {
	router.push({
    name: 'addPublish',
    query: { type: 'edit' }
  });
};

const handleDetails = async (id: string) => {
	router.push({
    name: 'addPublish',
    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 === 'notificationMattersTypes') {
					item.options = categoryOnm
			}
			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>
