瀏覽代碼

fix : 可勾选下载人员

master
leiyun 2 週之前
父節點
當前提交
3747d189ec
共有 3 個檔案被更改,包括 53 行新增8 行删除
  1. +17
    -3
      src/controller/admin/export_task.js
  2. +15
    -1
      src/service/export.js
  3. +21
    -4
      view/admin/patient_index.html

+ 17
- 3
src/controller/admin/export_task.js 查看文件

@@ -63,12 +63,20 @@ module.exports = class extends Base {

// 创建导出任务
async createAction() {
const { file_types, filter_params } = this.post();
const { file_types, filter_params, scope, patient_ids } = this.post();

if (!file_types || !file_types.length) {
return this.fail('请选择要导出的附件类型');
}

const exportScope = scope === 'selected' ? 'selected' : 'filter';
const selectedIds = Array.isArray(patient_ids)
? Array.from(new Set(patient_ids.map(id => parseInt(id, 10)).filter(Boolean)))
: [];
if (exportScope === 'selected' && !selectedIds.length) {
return this.fail('请选择要导出的患者');
}

// 全局只允许一个打包中的任务
const processing = await this.model('export_task').where({
is_deleted: 0,
@@ -83,14 +91,20 @@ module.exports = class extends Base {

// 构建标题
const typeLabels = { id_photos: '实名认证照片', documents: '上传资料', signs: '签字材料', sample_photos: '送检信息附件' };
const title = file_types.map(t => typeLabels[t] || t).join('、');
const fileTypeTitle = file_types.map(t => typeLabels[t] || t).join('、');
const title = exportScope === 'selected' ? `已选${selectedIds.length}名患者 - ${fileTypeTitle}` : fileTypeTitle;
const baseFilterParams = filter_params && typeof filter_params === 'object' && !Array.isArray(filter_params) ? filter_params : {};
const exportFilterParams = Object.assign({}, baseFilterParams, {
export_scope: exportScope,
patient_ids: exportScope === 'selected' ? selectedIds : []
});

const id = await model.add({
task_no: taskNo,
title,
status: 0,
file_types: JSON.stringify(file_types),
filter_params: JSON.stringify(filter_params || {}),
filter_params: JSON.stringify(exportFilterParams),
create_by: this.adminUser?.id || 0,
create_by_name: this.adminUser?.nickname || this.adminUser?.username || ''
});


+ 15
- 1
src/service/export.js 查看文件

@@ -61,7 +61,21 @@ module.exports = class extends think.Service {
}

// 查询患者列表
const patients = await patientModel.getAll(filterParams);
let patients = [];
const exportScope = filterParams.export_scope === 'selected' ? 'selected' : 'filter';
if (exportScope === 'selected') {
const patientIds = Array.isArray(filterParams.patient_ids)
? Array.from(new Set(filterParams.patient_ids.map(id => parseInt(id, 10)).filter(Boolean)))
: [];
if (patientIds.length) {
patients = await patientModel
.where({ id: ['in', patientIds], is_deleted: 0 })
.order('id DESC')
.select();
}
} else {
patients = await patientModel.getAll(filterParams);
}
if (!patients.length) {
await taskModel.where({ id: task.id }).update({
status: 2,


+ 21
- 4
view/admin/patient_index.html 查看文件

@@ -61,7 +61,7 @@
</el-tabs>

<el-table :data="tableData" v-loading="loading" stripe border @selection-change="onSelectionChange">
<el-table-column v-if="perms.canDelete" type="selection" width="45"></el-table-column>
<el-table-column v-if="perms.canDelete || perms.canExport" type="selection" width="45"></el-table-column>
<el-table-column prop="patient_no" label="编号" min-width="200"></el-table-column>
<el-table-column prop="name" label="姓名" min-width="80"></el-table-column>
<el-table-column label="身份证号" min-width="180">
@@ -295,7 +295,16 @@

<!-- 导出附件弹窗 -->
<el-dialog v-model="exportFilesVisible" title="异步下载附件" width="480px" destroy-on-close :close-on-click-modal="false">
<p style="color:#606266;margin-bottom:16px;">将按当前筛选条件导出患者附件,打包为 ZIP 文件。请选择需要导出的附件类型:</p>
<p style="color:#606266;margin-bottom:16px;">可按当前筛选条件或已选患者导出附件,打包为 ZIP 文件。</p>
<div style="margin-bottom:16px;">
<div style="font-weight:600;color:#303133;margin-bottom:8px;">导出范围</div>
<el-radio-group v-model="exportScope">
<el-radio label="filter">当前筛选结果(${ pagination.total }人)</el-radio>
<el-radio label="selected" :disabled="!selectedIds.length">已选患者(${ selectedIds.length }人)</el-radio>
</el-radio-group>
<div v-if="exportScope === 'selected'" style="margin-top:6px;color:#909399;font-size:12px;">仅导出当前页已勾选患者。</div>
</div>
<div style="font-weight:600;color:#303133;margin-bottom:8px;">附件类型</div>
<el-checkbox-group v-model="exportFileTypes">
<div style="display:flex;flex-direction:column;gap:12px;">
<el-checkbox label="id_photos">实名认证照片(身份证人像面、国徽面、免冠照片)</el-checkbox>
@@ -428,6 +437,7 @@ const app = createApp({
var res = await fetch('/admin/patient/list?' + params).then(function(r) { return r.json(); });
if (res.code === 0) {
tableData.value = res.data.data || [];
selectedIds.value = [];
pagination.total = res.data.count || 0;
if (res.data.counts) Object.assign(counts, res.data.counts);
} else {
@@ -731,10 +741,12 @@ const app = createApp({
const exportFilesVisible = ref(false);
const exportFilesLoading = ref(false);
const exportFileTypes = ref(['id_photos', 'documents', 'signs']);
const exportScope = ref('filter');
const exportSuccessVisible = ref(false);

function showExportFilesDialog() {
exportFileTypes.value = ['id_photos', 'documents', 'signs'];
exportScope.value = selectedIds.value.length ? 'selected' : 'filter';
exportFilesVisible.value = true;
}

@@ -742,6 +754,9 @@ const app = createApp({
if (!exportFileTypes.value.length) {
return ElementPlus.ElMessage.warning('请至少选择一种附件类型');
}
if (exportScope.value === 'selected' && !selectedIds.value.length) {
return ElementPlus.ElMessage.warning('请先勾选要下载附件的患者');
}
exportFilesLoading.value = true;
try {
var filterObj = {
@@ -762,7 +777,9 @@ const app = createApp({
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
file_types: exportFileTypes.value,
filter_params: filterObj
filter_params: filterObj,
scope: exportScope.value,
patient_ids: exportScope.value === 'selected' ? selectedIds.value : []
})
}).then(function(r) { return r.json(); });

@@ -801,7 +818,7 @@ const app = createApp({
uploadHeaders, addVisible, addSaving, addForm, exporting, editingId, perms, selectedIds,
regionTree, tagOptions, isMinorComputed, Plus, Download, Delete,
sampleReceiverVisible, sampleReceiverSaving, sampleReceiverForm,
exportFilesVisible, exportFilesLoading, exportFileTypes, exportSuccessVisible,
exportFilesVisible, exportFilesLoading, exportFileTypes, exportScope, exportSuccessVisible,
loadList, resetFilter, onTabChange, onSizeChange, onSelectionChange, viewDetail, showAddDialog, showEditDialog, handleExport,
onIdCardInput, onDocUpload, onSignUpload, submitAdd, handleDelete, handleBatchDelete,
showSampleReceiverDialog, saveSampleReceiverConfig, showExportFilesDialog, submitExportFiles, goExportTask


Loading…
取消
儲存