You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
657 lines
18 KiB
657 lines
18 KiB
<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>
|
|
|