| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <template>
- <div class="safety-platform-container">
- <header class="safety-platform-container__header">
- <div class="breadcrumb-title"> 隐患上报审核 </div>
- </header>
- <main class="safety-platform-container__main">
- <div class="search-table-container">
- <header>
- <div style="position: relative">
- <!-- <el-button type="primary" class="search-table-container--button" @click="handleCreate">
- 新增
- </el-button> -->
- <!-- <el-button plain class="search-table-container--button" @click="handleImport"> 导入 </el-button> -->
- </div>
- <div class="act-search">
- <section class="select-box">
- <div class="select-box--item">
- <span>隐患问题:</span>
- <el-input
- v-model="tableQuery.queryParam.hazardDesc"
- placeholder="请输入隐患问题"
- class="act-search-input"
- />
- </div>
- <!-- <div class="select-box--item">
- <span>状态:</span>
- <el-select v-model="tableQuery.queryParam.statusType" placeholder="请选择状态" clearable>
- <el-option label="待审批" :value="1" />
- <el-option label="已审批" :value="2" />
- <el-option label="他人已审批" :value="4" />
- </el-select>
- </div> -->
- <div class="select-box--item">
- <span>提交类型:</span>
- <el-select v-model="tableQuery.queryParam.sourceTypeName" placeholder="请选择提交类型" clearable>
- <el-option label="员工提交" value="员工提交" />
- <el-option label="供应商提交" value="供应商提交" />
- <el-option label="第三方提交" value="第三方提交" />
- </el-select>
- </div>
- </section>
- <section class="search-btn">
- <el-button type="primary" @click="handleSearch">查询</el-button>
- <el-button @click="handleReset">重置</el-button>
- <el-button plain @click="handleDownload"> 导出 </el-button>
- </section>
- </div>
- </header>
- <div class="batch-table">
- <BasicTable
- ref="basicTableRef"
- :tableData="tableData"
- :tableConfig="tableConfig"
- @update:pageSize="handleSizeChange"
- @update:pageNumber="handleCurrentChange"
- >
- <template #status="scope">
- <span>
- {{ getStatusTypeName(scope.row.approvalStatus) }}
- </span>
- </template>
- <template #action="scope">
- <div class="action-container--div" style="justify-content: left">
- <!-- 待审核:显示审核和查看 -->
- <template v-if="scope.row.status === 1">
- <ActionButton text="审核" @click="handleApprove(scope.row.id)" v-if="scope.row.canApprove"/>
- <ActionButton text="查看" @click="handleView(scope.row.id)" />
- </template>
- <!-- 审核通过(需求部门通过或安全部门通过):显示查看和入账 -->
- <template v-else-if="scope.row.status === 2 || scope.row.status === 4">
- <ActionButton text="查看" @click="handleView(scope.row.id)" />
- <ActionButton text="入账" @click="handleAccount(scope.row.id)" />
- </template>
- <!-- 审核不通过(需求部门驳回或安全部门驳回):显示查看 -->
- <template v-else-if="scope.row.status === 3 || scope.row.status === 5">
- <ActionButton text="查看" @click="handleView(scope.row.id)" />
- </template>
- <!-- 其他状态:显示查看 -->
- <template v-else>
- <ActionButton text="查看" @click="handleView(scope.row.id)" />
- </template>
- </div>
- </template>
- </BasicTable>
- </div>
- </div>
- </main>
- <BatchImport
- v-if="batchImportVisible"
- :visible="batchImportVisible"
- :import-api-url="importApiUrl"
- :template-url="templateUrl"
- template-name="员工上报导入模版"
- :show-template="true"
- @close="batchImportVisible = false"
- @update="handleUpdate"
- />
- </div>
- </template>
- <script setup lang="ts">
- import { onMounted, reactive, ref } from 'vue';
- import { ElMessage } from 'element-plus';
- import BasicTable from '@/components/BasicTable.vue';
- import useTableConfig from '@/hooks/useTableConfigHook';
- import ActionButton from '@/components/ActionButton.vue';
- import { TABLE_OPTIONS, INVENTORY_TABLE_COLUMNS } from './configs/tables';
- import { useRouter } from 'vue-router';
- import type { QueryPageRequest } from '@/types/basic-query';
- import {
- queryEmployeeHazardReportPendingPage,
- exportHiddenDanger,
- accountEmployeeHazardReport,
- type QueryHiddenDangerReq,
- type HiddenDanger,
- } from '@/api/production-safety';
- import { downloadByData } from '@/utils/file/download';
- import BatchImport from '@/components/batch-import/BatchImport.vue';
- import { useGlobSetting } from '@/hooks/setting';
- import urlJoin from 'url-join';
- const router = useRouter();
- // 表格
- const basicTableRef = ref<InstanceType<typeof BasicTable>>();
- const { tableConfig, pagination } = useTableConfig(INVENTORY_TABLE_COLUMNS, TABLE_OPTIONS);
- const tableData = ref<HiddenDanger[]>([]);
- // 将 status (1-7) 转换为 statusType (1-3)
- const getStatusType = (status: number): number => {
- if (status === 1) return 1;
- if (status === 2 || status === 4 || status === 6) return 2;
- if (status === 3 || status === 5 || status === 7) return 3;
- return 0;
- };
- const getStatusTypeName = (statusType: number): string => {
- if (statusType === 1) return '待审批';
- if (statusType === 2) return '已审批';
- if (statusType === 4) return '他人已审批';
- return '-';
- };
- const tableQuery = reactive<QueryPageRequest<QueryHiddenDangerReq>>({
- pageNumber: pagination.pageNumber,
- pageSize: pagination.pageSize,
- queryParam: {
- hazardDesc: undefined,
- statusType: undefined,
- sourceTypeName: undefined,
- },
- });
- const handleSizeChange = (value: number) => {
- pagination.pageSize = value;
- tableQuery.pageSize = value;
- getTableData();
- };
- const handleCurrentChange = (value: number) => {
- pagination.pageNumber = value;
- tableQuery.pageNumber = value;
- getTableData();
- };
- async function getTableData() {
- tableConfig.loading = true;
- try {
- const res = await queryEmployeeHazardReportPendingPage(tableQuery);
- if (res) {
- tableData.value = res.records || [];
- pagination.total = res.totalRow || 0;
- }
- } catch (e) {
- console.error('获取隐患上报列表失败:', e);
- tableData.value = [];
- pagination.total = 0;
- } finally {
- tableConfig.loading = false;
- }
- }
- const handleSearch = () => {
- pagination.pageNumber = 1;
- tableQuery.pageNumber = 1;
- getTableData();
- };
- const handleReset = () => {
- tableQuery.queryParam.hazardDesc = undefined;
- tableQuery.queryParam.statusType = undefined;
- tableQuery.queryParam.sourceTypeName = undefined;
- handleSearch();
- };
- const batchImportVisible = ref(false);
- const { urlPrefix } = useGlobSetting();
- const importApiUrl = ref(urlJoin(urlPrefix, '/api/employeeHazardReport/importEmployeeHazardReport'));
- const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/员工上报导入模版.xlsx');
- const handleImport = () => {
- batchImportVisible.value = true;
- };
- const handleUpdate = () => {
- batchImportVisible.value = false;
- getTableData();
- };
- const handleDownload = async () => {
- try {
- const exportParams: QueryHiddenDangerReq = {
- hazardDesc: tableQuery.queryParam.hazardDesc || undefined,
- statusType: tableQuery.queryParam.statusType,
- sourceTypeName: tableQuery.queryParam.sourceTypeName || undefined,
- };
- const response = await exportHiddenDanger(exportParams);
- if (response) {
- const fileName = `员工上报隐患管理_${new Date().toISOString().split('T')[0]}.xlsx`;
- downloadByData(response, fileName);
- ElMessage.success('导出成功');
- }
- } catch (e:any) {
- console.error('导出隐患上报失败:', e);
- ElMessage.error(e?.message || e?.data || '导出失败,请重试');
- }
- };
- const handleCreate = () => {
- router.push({
- name: 'hiddenTroubleReviewManagementItem',
- query: {
- operate: 'hidden-trouble-review-create',
- },
- });
- };
- const handleView = (id: number) => {
- router.push({
- name: 'hiddenTroubleReviewManagementItem',
- query: {
- id,
- operate: 'hidden-trouble-review-view',
- },
- });
- };
- const handleApprove = (id: number) => {
- router.push({
- name: 'hiddenTroubleReviewManagementItem',
- query: {
- id,
- operate: 'hidden-trouble-review-approve',
- },
- });
- };
- const handleAccount = async (hazardId: number) => {
- try {
- await accountEmployeeHazardReport(hazardId);
- ElMessage.success('入账成功');
- getTableData();
- } catch (e:any) {
- console.error('入账失败:', e);
- ElMessage.error(e?.message || e?.data || '入账失败,请重试');
- }
- };
- onMounted(() => {
- getTableData();
- });
- </script>
- <style scoped lang="scss">
- @use '@/styles/page-details-layout.scss' as *;
- @use '@/styles/page-main-layout.scss' as *;
- @use '@/styles/basic-table-action.scss' as *;
- @use '@/views/traffic/violation/style/act-search-table.scss' as *;
- </style>
|