<template>
	<div class="sensitive-words">
		<pageSearch ref="searchTableRef" :searchConfig="searchConfig">
			<template #messageType="scope">
				<el-select
					v-model="scope.value"
					placeholder="请选择消息类型"
					@change="newVal => onMessageChange(scope, newVal)"
				>
					<el-option label="通知" value="notice"></el-option>
					<el-option label="警告" value="warning"></el-option>
					<el-option label="错误" value="error"></el-option>
				</el-select>
			</template>
			<template #reportType="scope">
				<el-select
					v-model="scope.value"
					placeholder="请选择通报事项类别"
					@change="newVal => onMessageChange(scope, newVal)"
				>
					<el-option label="通知" value="notice"></el-option>
					<el-option label="警告" value="warning"></el-option>
					<el-option label="错误" value="error"></el-option>
				</el-select>
			</template>
			<template #reportEvent="scope">
				<el-select
					v-model="scope.value"
					placeholder="请选择通报事项"
					@change="newVal => onMessageChange(scope, newVal)"
				>
					<el-option label="通知" value="notice"></el-option>
					<el-option label="警告" value="warning"></el-option>
					<el-option label="错误" value="error"></el-option>
				</el-select>
			</template>
		</pageSearch>

		<pageContent ref="tableListRef" :total="total" :contentConfig="contentConfig" :pageList="tableData">
			<template #button>
				<el-button type="primary" @click="handleExport()">导出</el-button>
			</template>
			<template #operate="scope">
				<el-button type="primary" plain @click="handleCheck(scope.row.releasedId)"> 查看 </el-button>
				<el-button type="primary" plain @click="handlePublish(scope.row.releasedId)"> 发布通报 </el-button>
				<el-button type="primary" @click="handleStatus(scope.row.releasedId, '2', '不予通报')">
					不予通报
				</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 systemStore = useSystemStore();

import {
	categoryOnm,
	notificationStatus,
	isFeedback,
	overdueStatus,
	takeMeasures,
	bj_notification_type,
	bj_ship_delayed,
	bj_hand_opinion,
	bj_lssuing_unit,
	bj_initial_review_mark,
} from '@/plugins/dictData';

const bj_ship_port_registration = outTypeList('bj_ship_port_registration'); // 船港籍
const bj_ship_type = outTypeList('bj_ship_type'); // 船舶种类

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 handleCheck = async (id?: string) => {
	router.push({
		path: '/notificationInfoInquiry/shipRegistrationDetail',
		query: { type: 'detail' },
	});
};
const handleExport = () => {
	ElMessage.success('小编在努力开发中。。。');
	return;
};
const onMessageChange = (scope, newVal) => {
	scope.onInput(newVal);
};
// 通报发布
const handlePublish = releasedId => {
	ElMessage.success('小编在努力开发中。。。');
	return;
	router.push({
		path: '/notificationInfoInquiry/publish',
		query: { type: 'edit', releasedId: releasedId },
	});
};
const searchTableRef = ref();
// 状态按钮
function handleStatus(value: string, status: string, str: string) {
	ElMessage.success('小编在努力开发中。。。');
	return;
	// ElMessageBox.confirm(`是否${str}这条数据？`, '状态提示', {
	// 	confirmButtonText: '确定',
	// 	cancelButtonText: '取消',
	// 	type: 'warning',
	// })
	// 	.then(async () => {
	// 		const postData: any = await changeInventoryStatus(value, status);
	// 		if (postData.code === 200) {
	// 			tableListRef.value[0].fetchPageListData();
	// 			ElMessage.success('操作成功！');
	// 		} else {
	// 			ElMessage.error('操作失败！');
	// 		}
	// 	})
	// 	.catch(() => {
	// 		ElMessage({
	// 			type: 'info',
	// 			message: '取消操作',
	// 		});
	// 	});
}
// 删除按钮
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 === 'status') {
			// item.options = searchList.value;
		}
	});
}
searchItem();
</script>

<style scoped lang="scss">
.sensitive-words {
	margin: 20px;
	// background-color: #fff;
}

.status {
	cursor: pointer;
	position: relative;

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

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