Browse Source

feat:代码提交

dev-V1.2
ht 2 weeks ago
parent
commit
b6240e29c7
  1. 6
      zdxt-web-client/zdxt-admin-plus-ui/src/views/nos/certificateLibrary/assets/document-placeholder.svg
  2. 512
      zdxt-web-client/zdxt-admin-plus-ui/src/views/nos/certificateLibrary/index.vue
  3. 657
      zdxt-web-client/zdxt-admin-plus-ui/src/views/nos/nosFiling/add.vue

6
zdxt-web-client/zdxt-admin-plus-ui/src/views/nos/certificateLibrary/assets/document-placeholder.svg

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="160" height="64" viewBox="0 0 160 64">
<rect width="160" height="64" fill="#f5f6f7"/>
<circle cx="124" cy="13" r="4" fill="#d8dbdf"/>
<path d="M24 51V32l20-23 22 29 15-14 31 27h-88Z" fill="#138dbb"/>
<path d="M91 51V38l21-21 22 22 15 12H91Z" fill="#0c82b1"/>
</svg>

After

Width:  |  Height:  |  Size: 321 B

512
zdxt-web-client/zdxt-admin-plus-ui/src/views/nos/certificateLibrary/index.vue

@ -0,0 +1,512 @@
<template>
<div class="certificate-library-page">
<section class="search-panel">
<el-form :model="searchForm" class="filter-form" inline @submit.prevent>
<el-form-item label="企业名称:">
<el-input v-model="searchForm.enterpriseName" class="filter-input" placeholder="请输入关键字" clearable @keyup.enter="handleSearch" />
</el-form-item>
<el-form-item label="时间筛选:">
<el-date-picker
v-model="searchForm.timeRange"
class="filter-date"
type="datetimerange"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="截止时间"
format="YYYY-MM-DD HH:mm"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item class="filter-actions">
<el-button type="primary" :loading="loading" @click="handleSearch">搜索</el-button>
<el-button type="primary" :disabled="loading" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</section>
<section class="table-panel">
<el-table
v-loading="loading"
:data="tableData"
class="certificate-table"
height="100%"
border
row-key="id"
empty-text="暂无证照数据"
:header-cell-style="{ backgroundColor: '#f5f7fa', fontWeight: 'bold' }"
>
<el-table-column prop="enterpriseName" label="企业名称" min-width="230" show-overflow-tooltip />
<el-table-column label="企业信用代码" min-width="190" show-overflow-tooltip>
<template #default="{ row }">
{{ getCreditCode(row) }}
</template>
</el-table-column>
<el-table-column label="营业执照" min-width="165" align="center">
<template #default="{ row }">
<DocumentThumbnails :documents="getDocumentsByCategory(row, 'business-license')" @preview="openPreview(row, $event)" />
</template>
</el-table-column>
<el-table-column label="许可证书" min-width="165" align="center">
<template #default="{ row }">
<DocumentThumbnails :documents="getDocumentsByCategory(row, 'license')" @preview="openPreview(row, $event)" />
</template>
</el-table-column>
<el-table-column label="其它证书" min-width="270" align="center">
<template #default="{ row }">
<DocumentThumbnails :documents="getDocumentsByCategory(row, 'other')" @preview="openPreview(row, $event)" />
</template>
</el-table-column>
<el-table-column label="企业提交时间" min-width="180">
<template #default="{ row }">
{{ formatDateTime(row.enterpriseHandleTime) || '--' }}
</template>
</el-table-column>
</el-table>
</section>
<footer class="pagination-container">
<span class="total-text">共 {{ total }} 项数据</span>
<el-pagination
v-model:current-page="currentPage"
v-model:page-size="pageSize"
:total="total"
:page-sizes="[10, 20, 50, 100]"
layout="prev, pager, next, jumper, ->, total, sizes"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</footer>
<el-dialog v-model="previewVisible" :title="previewTitle" width="680px" append-to-body destroy-on-close align-center>
<div class="preview-dialog">
<img
v-if="previewDocument"
:src="buildFileUrl(previewDocument.src)"
class="document-preview-art"
:alt="previewDocument.itemName"
@error="handleImageError"
/>
<p class="preview-caption">{{ previewDocument?.itemName || '证照预览' }}</p>
</div>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { computed, defineComponent, h, onMounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { getTaskPage } from '@/api/nos/index';
import type { NosLawEnforcementTaskItem, NosLawEnforcementTaskPageVO, Response as TaskPageResponse, TaskPageRequest } from '@/api/nos/type';
import { parseTime } from '@/utils/ruoyi';
import documentPlaceholder from './assets/document-placeholder.svg';
type CertificateCategory = 'business-license' | 'license' | 'other';
interface CertificateDocument {
id: string;
itemName: string;
src: string;
category: CertificateCategory;
}
interface SearchForm {
enterpriseName: string;
timeRange: string[];
}
const IMAGE_EXTENSIONS = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg', 'avif']);
const COMPLETED_TASK_STATUS = 4;
const VERIFY_TASK_TYPE_ID = 3;
const BASE_API = import.meta.env.VITE_APP_BASE_API || '';
const FILE_SERVER_PREFIX = import.meta.env.VITE_APP_FILE_SERVER_PREFIX || '';
const getFileExtension = (value: string) => {
const clean = value.trim().split(/[?#]/)[0];
const dotIndex = clean.lastIndexOf('.');
return dotIndex === -1 ? '' : clean.slice(dotIndex + 1).toLowerCase();
};
const isImageFile = (value?: string) => {
return typeof value === 'string' && IMAGE_EXTENSIONS.has(getFileExtension(value));
};
const getItemCategory = (itemName?: string): CertificateCategory => {
const normalizedName = (itemName || '').replace(/\s+/g, '');
if (normalizedName.includes('营业执照')) return 'business-license';
if (normalizedName.includes('许可证书') || normalizedName.includes('许可证')) return 'license';
return 'other';
};
const getImageFiles = (item: NosLawEnforcementTaskItem) => {
return Array.isArray(item.itemValue) ? item.itemValue.filter((file): file is string => isImageFile(file)) : [];
};
const getDocumentsByCategory = (row: NosLawEnforcementTaskPageVO, category: CertificateCategory): CertificateDocument[] => {
const documents: CertificateDocument[] = [];
(row.taskItemList || []).forEach((item) => {
if (getItemCategory(item.itemName) !== category) return;
getImageFiles(item).forEach((src, index) => {
documents.push({
id: `${item.id || item.itemName || category}-${index}`,
itemName: item.itemName || (category === 'other' ? '其他证书' : '证照'),
src,
category
});
});
});
return documents;
};
const isOssId = (value: string) => /^[0-9]+$/.test(value.trim());
const toRelativeFilePath = (value: string) => {
const raw = value.trim();
if (!raw) return '';
const prefix = FILE_SERVER_PREFIX.replace(/\/+$/, '');
let path = raw.startsWith('/') ? raw : `/${raw}`;
const normalizedPrefix = prefix.startsWith('http') ? prefix : `/${prefix}`;
while (path === normalizedPrefix || path.startsWith(`${normalizedPrefix}/`)) {
path = path.slice(normalizedPrefix.length) || '/';
if (!path.startsWith('/')) path = `/${path}`;
}
return path;
};
const buildFileUrl = (value?: string) => {
if (!value) return '';
const raw = value.trim();
if (raw.startsWith('http://') || raw.startsWith('https://') || raw.startsWith('data:')) return raw;
if (isOssId(raw)) return `${BASE_API}/resource/oss/download/${raw}`;
return `${FILE_SERVER_PREFIX.replace(/\/+$/, '')}${toRelativeFilePath(raw)}`;
};
const handleImageError = (event: Event) => {
const target = event.target as HTMLImageElement;
if (target?.src.endsWith('document-placeholder.svg')) return;
if (target) target.src = documentPlaceholder;
};
const DocumentThumbnails = defineComponent({
name: 'DocumentThumbnails',
props: {
documents: {
type: Array as () => CertificateDocument[],
default: () => []
}
},
emits: ['preview'],
setup(props, { emit }) {
return () =>
props.documents.length
? h(
'div',
{ class: 'document-thumbnails' },
props.documents.map((document) =>
h(
'button',
{
key: document.id,
type: 'button',
class: 'document-thumb',
title: document.itemName,
'aria-label': `预览${document.itemName}`,
onClick: () => emit('preview', document)
},
[
h('img', {
class: 'document-art',
src: buildFileUrl(document.src),
alt: document.itemName,
draggable: false,
onError: handleImageError
})
]
)
)
)
: h('span', { class: 'empty-document' }, '--');
}
});
const loading = ref(false);
const tableData = ref<NosLawEnforcementTaskPageVO[]>([]);
const total = ref(0);
const currentPage = ref(1);
const pageSize = ref(10);
const searchForm = reactive<SearchForm>({
enterpriseName: '',
timeRange: []
});
const previewVisible = ref(false);
const previewDocument = ref<CertificateDocument>();
const previewEnterpriseName = ref('');
const previewTitle = computed(() => (previewDocument.value ? `${previewEnterpriseName.value} - ${previewDocument.value.itemName}` : '证照预览'));
const formatDateTime = (time?: string) => {
if (!time) return '';
return parseTime(time, '{y}-{m}-{d} {h}:{i}') || '';
};
const getCreditCode = (row: NosLawEnforcementTaskPageVO) => {
return row.usciCode || row.creditCode || row.enterpriseNumber || '--';
};
const buildQueryParams = (): TaskPageRequest => ({
taskTypeId: VERIFY_TASK_TYPE_ID,
taskStatus: COMPLETED_TASK_STATUS,
startTime: searchForm.timeRange[0] || undefined,
endTime: searchForm.timeRange[1] || undefined,
enterpriseName: searchForm.enterpriseName.trim() || undefined,
pageNo: currentPage.value,
pageSize: pageSize.value
});
const getList = async () => {
loading.value = true;
try {
const res = (await getTaskPage(buildQueryParams())) as unknown as TaskPageResponse;
tableData.value = res.rows || [];
total.value = res.total || 0;
} catch (error) {
console.error('获取证照库数据失败:', error);
tableData.value = [];
total.value = 0;
ElMessage.error('获取证照库数据失败,请检查网络连接');
} finally {
loading.value = false;
}
};
const handleSearch = () => {
currentPage.value = 1;
getList();
};
const handleReset = () => {
searchForm.enterpriseName = '';
searchForm.timeRange = [];
currentPage.value = 1;
getList();
};
const handleSizeChange = (value: number) => {
pageSize.value = value;
currentPage.value = 1;
getList();
};
const handleCurrentChange = (page: number) => {
currentPage.value = page;
getList();
};
const openPreview = (row: NosLawEnforcementTaskPageVO, document: CertificateDocument) => {
previewEnterpriseName.value = row.enterpriseName || '';
previewDocument.value = document;
previewVisible.value = true;
};
onMounted(() => {
getList();
});
</script>
<style scoped>
.certificate-library-page {
box-sizing: border-box;
display: flex;
flex-direction: column;
height: 100%;
padding: 20px;
overflow: hidden;
background: #f5f7fa;
}
.search-panel {
flex-shrink: 0;
padding: 16px 20px;
margin-bottom: 16px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.filter-form {
display: flex;
flex-wrap: wrap;
align-items: center;
}
.filter-form :deep(.el-form-item) {
margin-right: 30px;
margin-bottom: 0;
}
.filter-form :deep(.el-form-item__label) {
padding-right: 8px;
color: #303133;
white-space: nowrap;
}
.filter-input {
width: 150px;
}
.filter-date {
width: 360px;
}
.filter-form :deep(.filter-actions) {
margin-right: 0;
}
.filter-form :deep(.filter-actions .el-form-item__content) {
display: flex;
gap: 34px;
}
.filter-actions :deep(.el-button) {
width: 68px;
height: 33px;
margin-left: 0;
border-radius: 4px;
}
.filter-actions :deep(.el-button + .el-button) {
margin-left: 0;
}
.table-panel {
flex: 1;
min-height: 0;
padding: 16px;
overflow: hidden;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.certificate-table {
width: 100%;
height: 100%;
color: #303133;
}
.certificate-table :deep(.el-table__header th.el-table__cell) {
height: 64px;
color: #303133;
}
.certificate-table :deep(.el-table__body td.el-table__cell) {
min-height: 66px;
padding-top: 7px;
padding-bottom: 7px;
}
.certificate-table :deep(.document-thumbnails) {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
min-height: 54px;
gap: 8px;
}
.certificate-table :deep(.document-thumb) {
box-sizing: border-box;
width: 118px;
height: 54px;
padding: 4px;
overflow: hidden;
cursor: pointer;
background: #fafafa;
border: 3px solid #d9dde2;
border-radius: 2px;
transition:
border-color 0.2s ease,
box-shadow 0.2s ease;
}
.certificate-table :deep(.document-thumb:hover),
.certificate-table :deep(.document-thumb:focus-visible) {
border-color: #9fc9db;
box-shadow: 0 0 0 2px rgba(19, 142, 187, 0.14);
outline: none;
}
.certificate-table :deep(.document-art) {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
.certificate-table :deep(.empty-document) {
color: #a8abb2;
}
.pagination-container {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 20px;
margin-top: 16px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.total-text {
color: #909399;
}
.preview-dialog {
display: flex;
flex-direction: column;
align-items: center;
}
.document-preview-art {
box-sizing: border-box;
display: block;
max-width: 100%;
max-height: 70vh;
object-fit: contain;
background: #f4f5f6;
border: 1px solid #e4e7ed;
}
.preview-caption {
margin: 12px 0 0;
color: #606266;
font-size: 13px;
}
@media (max-width: 1200px) {
.filter-form :deep(.el-form-item) {
margin-right: 20px;
}
.filter-date {
width: 330px;
}
}
</style>

657
zdxt-web-client/zdxt-admin-plus-ui/src/views/nos/nosFiling/add.vue

@ -0,0 +1,657 @@
<template>
<div class="filing-add-page">
<div class="filing-card">
<h2 class="page-title">云备案</h2>
<el-divider class="title-divider" />
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" class="filing-form">
<div class="section-title">检查对象</div>
<el-form-item label="执法单位:" prop="lawEnforcementAgencyId">
<div class="field-column">
<el-select
v-model="form.lawEnforcementAgencyId"
filterable
placeholder="请选择"
class="field-control"
:loading="agencyLoading"
@change="handleAgencyChange"
>
<el-option
v-for="item in agencyOptions"
:key="item.deptId"
:label="item.deptName"
:value="String(item.deptId)"
/>
</el-select>
<div class="form-tip">温馨提示:开展非现场执法,同1个单位,仅需提交1次法制和技术材料</div>
</div>
</el-form-item>
<el-form-item label="执法人员:" prop="lawEnforcerIds">
<el-select
v-model="form.lawEnforcerIds"
multiple
filterable
remote
reserve-keyword
collapse-tags
collapse-tags-tooltip
placeholder="请选择"
class="field-control"
:remote-method="searchLawEnforcers"
:loading="lawEnforcerLoading"
:disabled="!form.lawEnforcementAgencyId"
@visible-change="handleLawEnforcerVisible"
>
<el-option
v-for="item in lawEnforcerOptions"
:key="item.lawEnforcerId"
:label="formatLawEnforcerLabel(item)"
:value="item.lawEnforcerId"
>
<span>{{ item.lawEnforcerName }}</span>
<span v-if="item.lawCertificateNum || item.lawEnforcerPhone" class="option-extra">
{{ item.lawCertificateNum || item.lawEnforcerPhone }}
</span>
</el-option>
</el-select>
</el-form-item>
<div class="section-title section-title--spaced">执法信息</div>
<el-form-item label="企业名称:" prop="enterpriseId">
<el-select
v-model="form.enterpriseId"
filterable
remote
reserve-keyword
placeholder="请选择"
class="field-control"
:remote-method="searchEnterprises"
:loading="enterpriseLoading"
@change="handleEnterpriseChange"
>
<el-option
v-for="item in enterpriseOptions"
:key="item.enterpriseId"
:label="item.enterpriseName"
:value="item.enterpriseId"
>
<span>{{ item.enterpriseName }}</span>
<span v-if="item.usciCode" class="option-extra">{{ item.usciCode }}</span>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="备案文件:">
<div class="check-item-list">
<div v-for="(item, index) in checkItems" :key="item.id" class="check-item-row">
<el-checkbox v-model="item.checked">
<span v-if="item.fixed">{{ item.name }}</span>
</el-checkbox>
<el-input
v-if="!item.fixed"
v-model="item.name"
maxlength="100"
placeholder="输入文件名称"
class="check-item-input"
/>
<el-button
v-if="index === checkItems.length - 1"
class="add-check-item"
@click="addCheckItem"
>
+ 添加
</el-button>
</div>
</div>
</el-form-item>
<el-form-item label="截止日期:" prop="deadline">
<div class="date-row">
<el-date-picker
ref="deadlinePickerRef"
v-model="form.deadline"
type="date"
placeholder="请选择"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
:disabled-date="disablePastDate"
class="date-picker"
/>
<el-button @click="openDeadlinePicker">选择日期</el-button>
</div>
</el-form-item>
</el-form>
<div class="form-actions">
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" :loading="submitLoading" @click="handleSubmit">提交</el-button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, nextTick, onMounted, reactive, ref } from 'vue';
import { useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import type { FormInstance, FormRules } from 'element-plus';
import {
addLawEnforcementTask,
getBureauUnitUsers,
queryEnterpriseList,
selectLawEnforcementAgency
} from '@/api/nos/index';
import type {
BureauUnitUserOption,
EnterpriseInfoOption,
LawEnforcementAgencyOption,
LawEnforcer,
NosLawEnforcementTaskSaveRequest
} from '@/api/nos/type';
import { useUserStore } from '@/store/modules/user';
interface LawEnforcerOption {
lawEnforcerId: string;
lawEnforcerName: string;
lawEnforcerPhone: string;
lawEnforcerIdCard: string;
lawCertificateNum: string;
}
interface EnterpriseOption {
enterpriseId: string;
enterpriseName: string;
usciCode: string;
}
interface CheckItem {
id: number;
name: string;
checked: boolean;
fixed: boolean;
}
const FIXED_TASK_SOURCE_ID = '7';
const FIXED_TASK_TYPE_ID = 2;
const FIXED_LEGAL_BASIS = ['《中华人民共和国标准化法实施条例》'];
const router = useRouter();
const userStore = useUserStore();
const formRef = ref<FormInstance>();
const deadlinePickerRef = ref<any>();
const loading = reactive({
agency: false,
lawEnforcer: false,
enterprise: false,
submit: false
});
const agencyLoading = computed(() => loading.agency);
const lawEnforcerLoading = computed(() => loading.lawEnforcer);
const enterpriseLoading = computed(() => loading.enterprise);
const submitLoading = computed(() => loading.submit);
const agencyOptions = ref<LawEnforcementAgencyOption[]>([]);
const lawEnforcerOptions = ref<LawEnforcerOption[]>([]);
const enterpriseOptions = ref<EnterpriseOption[]>([]);
let checkItemSeed = 4;
const form = reactive({
lawEnforcementAgencyId: '',
lawEnforcementAgency: '',
lawEnforcerIds: [] as string[],
enterpriseId: '',
enterpriseName: '',
usciCode: '',
deadline: ''
});
const checkItems = ref<CheckItem[]>([
{ id: 1, name: '营业执照', checked: true, fixed: true },
{ id: 2, name: '许可证', checked: true, fixed: true },
{ id: 3, name: '', checked: true, fixed: false }
]);
const rules: FormRules = {
lawEnforcementAgencyId: [{ required: true, message: '请选择执法单位', trigger: 'change' }],
lawEnforcerIds: [
{ required: true, type: 'array', min: 2, message: '请至少选择2名执法人员', trigger: 'change' }
],
enterpriseId: [{ required: true, message: '请选择企业', trigger: 'change' }],
deadline: [{ required: true, message: '请选择截止日期', trigger: 'change' }]
};
const selectedAgency = computed(() =>
agencyOptions.value.find((item) => String(item.deptId) === form.lawEnforcementAgencyId)
);
const currentUserKeyword = computed(() => userStore.nickname || '');
const selectedEnterprise = computed(() =>
enterpriseOptions.value.find((item) => item.enterpriseId === form.enterpriseId)
);
const selectedLawEnforcers = computed(() =>
form.lawEnforcerIds
.map((id) => lawEnforcerOptions.value.find((item) => item.lawEnforcerId === id))
.filter((item): item is LawEnforcerOption => !!item)
);
const selectedCheckItemNames = computed(() => {
const names = checkItems.value
.filter((item) => item.checked)
.map((item) => item.name.trim())
.filter(Boolean);
return [...new Set(names)];
});
const formatLawEnforcerLabel = (item: LawEnforcerOption) => {
const identity = item.lawCertificateNum || item.lawEnforcerPhone;
return identity ? `${item.lawEnforcerName}(${identity})` : item.lawEnforcerName;
};
const disablePastDate = (date: Date) => {
const today = new Date();
today.setHours(0, 0, 0, 0);
return date.getTime() <= today.getTime();
};
const openDeadlinePicker = async () => {
await nextTick();
if (typeof deadlinePickerRef.value?.handleOpen === 'function') {
deadlinePickerRef.value.handleOpen();
return;
}
deadlinePickerRef.value?.focus?.();
};
const addCheckItem = () => {
checkItems.value.push({
id: checkItemSeed++,
name: '',
checked: true,
fixed: false
});
};
const loadAgencyOptions = async () => {
loading.agency = true;
try {
const res: any = await selectLawEnforcementAgency();
agencyOptions.value = Array.isArray(res?.data) ? res.data : [];
} catch (error) {
console.error('加载执法单位失败:', error);
} finally {
loading.agency = false;
}
};
let lawEnforcerRequestId = 0;
const normalizeLawEnforcerOption = (item: BureauUnitUserOption): LawEnforcerOption => ({
lawEnforcerId: String(item.userId),
lawEnforcerName: item.userName || item.nickName || item.fullname || '',
lawEnforcerPhone: item.mobileNumber || item.phonenumber || '',
lawEnforcerIdCard: item.lawCertificateNum || '',
lawCertificateNum: item.lawCertificateNum || ''
});
const mergeLawEnforcerOptions = (options: LawEnforcerOption[]) => {
const selectedIds = new Set(form.lawEnforcerIds);
const selectedOptions = lawEnforcerOptions.value.filter((item) => selectedIds.has(item.lawEnforcerId));
const merged = new Map<string, LawEnforcerOption>();
[...selectedOptions, ...options].forEach((item) => {
if (item.lawEnforcerName && !merged.has(item.lawEnforcerId)) {
merged.set(item.lawEnforcerId, item);
}
});
lawEnforcerOptions.value = [...merged.values()];
};
const loadLawEnforcers = async (keyword: string, autoSelectCurrentUser = false) => {
const searchKeyword = keyword.trim();
if (!selectedAgency.value || !searchKeyword) {
return;
}
const requestId = ++lawEnforcerRequestId;
loading.lawEnforcer = true;
try {
const res: any = await getBureauUnitUsers({
sysDeptId: String(selectedAgency.value.sysDeptId || selectedAgency.value.deptId || ''),
userName: searchKeyword,
globalSearch: 'false',
pageNum: 1,
pageSize: 50,
dataScopeId: userStore.userId || '',
isShowCardId: '0'
});
if (requestId !== lawEnforcerRequestId) return;
const rows: BureauUnitUserOption[] = Array.isArray(res?.data)
? res.data
: res?.data?.rows || res?.rows || [];
const options = rows.map(normalizeLawEnforcerOption);
mergeLawEnforcerOptions(options);
if (autoSelectCurrentUser && form.lawEnforcerIds.length === 0) {
const currentUser = options.find((item) => item.lawEnforcerName === searchKeyword);
if (currentUser) {
form.lawEnforcerIds = [currentUser.lawEnforcerId];
}
}
} catch (error) {
console.error('加载执法人员失败:', error);
} finally {
if (requestId === lawEnforcerRequestId) {
loading.lawEnforcer = false;
}
}
};
const searchLawEnforcers = (keyword: string) => {
loadLawEnforcers(keyword);
};
const handleLawEnforcerVisible = (visible: boolean) => {
if (visible && lawEnforcerOptions.value.length === 0 && currentUserKeyword.value) {
loadLawEnforcers(currentUserKeyword.value);
}
};
const handleAgencyChange = async () => {
form.lawEnforcementAgency = selectedAgency.value?.deptName || '';
form.lawEnforcerIds = [];
lawEnforcerOptions.value = [];
if (currentUserKeyword.value) {
await loadLawEnforcers(currentUserKeyword.value, true);
}
};
let enterpriseRequestId = 0;
const normalizeEnterpriseOption = (item: EnterpriseInfoOption): EnterpriseOption => ({
enterpriseId: String(item.id ?? item.enterpriseId ?? ''),
enterpriseName: item.enterpriseName || '',
usciCode: item.usciCode || item.enterpriseNumber || item.creditCode || ''
});
const mergeEnterpriseOptions = (options: EnterpriseOption[]) => {
const merged = new Map<string, EnterpriseOption>();
const selected = enterpriseOptions.value.filter((item) => item.enterpriseId === form.enterpriseId);
[...selected, ...options].forEach((item) => {
if (item.enterpriseId && item.enterpriseName && !merged.has(item.enterpriseId)) {
merged.set(item.enterpriseId, item);
}
});
enterpriseOptions.value = [...merged.values()];
};
const loadEnterprises = async (keyword = '') => {
const requestId = ++enterpriseRequestId;
loading.enterprise = true;
try {
const res: any = await queryEnterpriseList({
pageNum: 1,
pageSize: 50,
enterpriseName: keyword.trim() || undefined
});
if (requestId !== enterpriseRequestId) return;
const rows: EnterpriseInfoOption[] = res?.rows || res?.data?.rows || [];
mergeEnterpriseOptions(rows.map(normalizeEnterpriseOption));
} catch (error) {
console.error('加载企业信息失败:', error);
} finally {
if (requestId === enterpriseRequestId) {
loading.enterprise = false;
}
}
};
const searchEnterprises = (keyword: string) => {
loadEnterprises(keyword);
};
const handleEnterpriseChange = () => {
form.enterpriseName = selectedEnterprise.value?.enterpriseName || '';
form.usciCode = selectedEnterprise.value?.usciCode || '';
};
const buildPayload = (): NosLawEnforcementTaskSaveRequest => ({
checkItemList: selectedCheckItemNames.value,
deadline: form.deadline,
enterpriseName: form.enterpriseName,
enterpriseId: form.enterpriseId,
lawEnforcementAgency: form.lawEnforcementAgency,
lawEnforcementMatters: '',
lawEnforcer: selectedLawEnforcers.value.map(
(item): LawEnforcer => ({
lawEnforcerId: Number(item.lawEnforcerId),
lawEnforcerName: item.lawEnforcerName,
lawEnforcerPhone: item.lawEnforcerPhone,
lawEnforcerIdCard: item.lawEnforcerIdCard,
lawCertificateNum: item.lawCertificateNum
})
),
legalBasis: [...FIXED_LEGAL_BASIS],
proclamation: [],
taskSourceId: FIXED_TASK_SOURCE_ID,
taskTypeId: FIXED_TASK_TYPE_ID,
usciCode: form.usciCode
});
const handleSubmit = async () => {
if (!formRef.value || loading.submit) return;
const valid = await formRef.value.validate().catch(() => false);
if (!valid) return;
if (selectedCheckItemNames.value.length === 0) {
ElMessage.warning('请至少选择或填写一项备案文件');
return;
}
try {
await ElMessageBox.confirm('确认提交该备案任务吗?', '提交确认', {
confirmButtonText: '确认提交',
cancelButtonText: '取消',
type: 'warning'
});
} catch {
return;
}
loading.submit = true;
try {
const res: any = await addLawEnforcementTask(buildPayload());
if (res?.code === 200 || res?.code === 0 || res?.success === true) {
ElMessage.success('新增备案成功');
router.back();
} else {
ElMessage.error(res?.msg || '提交失败');
}
} catch (error) {
console.error('新增备案失败:', error);
} finally {
loading.submit = false;
}
};
const handleCancel = () => {
router.back();
};
onMounted(async () => {
await Promise.all([loadAgencyOptions(), loadEnterprises()]);
});
</script>
<style scoped>
.filing-add-page {
box-sizing: border-box;
min-height: 100%;
padding: 20px;
background: #f5f7fa;
}
.filing-card {
box-sizing: border-box;
width: 100%;
max-width: 1180px;
min-height: calc(100vh - 140px);
margin: 0 auto;
padding: 18px 24px 24px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.page-title {
margin: 0;
color: #303133;
font-size: 20px;
font-weight: 600;
line-height: 30px;
}
.title-divider {
margin: 14px 0 20px;
}
.filing-form {
max-width: 900px;
margin-left: 20px;
}
.section-title {
margin: 8px 0 16px;
color: #303133;
font-size: 16px;
font-weight: 600;
}
.section-title--spaced {
margin-top: 34px;
}
.field-column {
width: 100%;
}
.field-control {
width: 100%;
max-width: 720px;
}
.form-tip {
margin-top: 4px;
color: #909399;
font-size: 13px;
line-height: 20px;
}
.check-item-list {
width: 100%;
max-width: 540px;
}
.check-item-row {
display: flex;
align-items: center;
min-height: 34px;
gap: 4px;
}
.check-item-row :deep(.el-checkbox) {
flex: none;
margin-right: 2px;
}
.check-item-input {
width: 330px;
}
.add-check-item {
flex: none;
min-width: 76px;
}
.date-row {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
max-width: 520px;
}
.date-picker {
width: 320px;
}
.option-extra {
float: right;
max-width: 55%;
margin-left: 18px;
overflow: hidden;
color: #909399;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
max-width: 900px;
margin: 36px 0 0 20px;
padding-top: 20px;
border-top: 1px solid #ebeef5;
}
:deep(.el-form-item) {
margin-bottom: 18px;
}
:deep(.el-form-item__label) {
color: #303133;
font-weight: 500;
white-space: nowrap;
}
@media (max-width: 768px) {
.filing-add-page {
padding: 12px;
}
.filing-card {
padding: 16px;
}
.filing-form,
.form-actions {
margin-left: 0;
}
.filing-form :deep(.el-form-item) {
display: block;
}
.filing-form :deep(.el-form-item__label) {
justify-content: flex-start;
width: auto !important;
}
.date-row {
flex-wrap: wrap;
}
.date-picker {
width: 100%;
}
}
</style>
Loading…
Cancel
Save