导出药房 医生关联表
This commit is contained in:
@@ -116,3 +116,20 @@ export function getPharmacyDoctorList(pharmacy_id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出药房关联医生列表
|
||||||
|
* @param {Object} data - 请求参数
|
||||||
|
* @param {1|2|3} data.type - 1:当前筛选导出, 2:选中的数据导出, 3:全部导出
|
||||||
|
* @param {string} [data.pharmacy_id] - 药房 ID
|
||||||
|
* @param {string} [data.doctor_name] - 医生姓名
|
||||||
|
* @param {string} [data.mobile] - 医生手机号
|
||||||
|
* @param {string} [data.id] - 选中的数据 ID,多条用英文逗号分隔
|
||||||
|
* @returns {Promise}
|
||||||
|
*/
|
||||||
|
export function exportPharmacyDoctor(data) {
|
||||||
|
return request({
|
||||||
|
url: '/admin/export/pharmacy/doctor',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -83,6 +83,39 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|
||||||
|
<!-- 工具栏:数据统计与导出操作 -->
|
||||||
|
<div class="table-toolbar">
|
||||||
|
<div class="table-toolbar-left">
|
||||||
|
<span class="table-total-tip">共找到 {{ pager.total }} 位关联医生</span>
|
||||||
|
</div>
|
||||||
|
<div class="table-toolbar-right">
|
||||||
|
<a-dropdown
|
||||||
|
v-if="hasPermission('admin:doctorPharmacy:export') || hasPermission('admin:sysPharmacy:doctor')"
|
||||||
|
@select="handleExportCommand"
|
||||||
|
>
|
||||||
|
<a-button type="outline" size="small" :loading="exportLoading">
|
||||||
|
<template #icon><icon-download /></template>
|
||||||
|
导出医生数据
|
||||||
|
<icon-down style="margin-left: 4px" />
|
||||||
|
</a-button>
|
||||||
|
<template #content>
|
||||||
|
<a-doption :value="1">
|
||||||
|
<template #icon><icon-filter /></template>
|
||||||
|
导出当前筛选数据
|
||||||
|
</a-doption>
|
||||||
|
<a-doption :value="2" :disabled="selectedRowKeys.length === 0">
|
||||||
|
<template #icon><icon-check-square /></template>
|
||||||
|
导出已选数据 {{ selectedRowKeys.length ? `(${selectedRowKeys.length})` : '' }}
|
||||||
|
</a-doption>
|
||||||
|
<a-doption :value="3">
|
||||||
|
<template #icon><icon-layers /></template>
|
||||||
|
导出该药房全部医生
|
||||||
|
</a-doption>
|
||||||
|
</template>
|
||||||
|
</a-dropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 医生列表表格 -->
|
<!-- 医生列表表格 -->
|
||||||
<a-table
|
<a-table
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
@@ -90,8 +123,10 @@
|
|||||||
:loading="loading"
|
:loading="loading"
|
||||||
:pagination="paginationProps"
|
:pagination="paginationProps"
|
||||||
row-key="doctor_pharmacy_id"
|
row-key="doctor_pharmacy_id"
|
||||||
|
:row-selection="rowSelection"
|
||||||
|
v-model:selected-keys="selectedRowKeys"
|
||||||
:scroll="{ x: 860 }"
|
:scroll="{ x: 860 }"
|
||||||
style="margin-top: 14px"
|
style="margin-top: 10px"
|
||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
>
|
>
|
||||||
@@ -164,7 +199,7 @@
|
|||||||
import { ref, reactive, computed } from 'vue';
|
import { ref, reactive, computed } from 'vue';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Message } from '@arco-design/web-vue';
|
||||||
import { usePermissionStore } from '@/store/permission';
|
import { usePermissionStore } from '@/store/permission';
|
||||||
import { getPharmacyDoctorPage } from '@/api/basic/pharmacy';
|
import { getPharmacyDoctorPage, exportPharmacyDoctor } from '@/api/basic/pharmacy';
|
||||||
import { removeDoctorPharmacy } from '@/api/doctor/pharmacy';
|
import { removeDoctorPharmacy } from '@/api/doctor/pharmacy';
|
||||||
import DoctorModal from '@/components/doctorModal.vue';
|
import DoctorModal from '@/components/doctorModal.vue';
|
||||||
|
|
||||||
@@ -178,8 +213,17 @@ const hasPermission = (permission) => {
|
|||||||
|
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const exportLoading = ref(false);
|
||||||
const currentPharmacy = ref(null);
|
const currentPharmacy = ref(null);
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
|
const selectedRowKeys = ref([]);
|
||||||
|
|
||||||
|
// 表格多选配置
|
||||||
|
const rowSelection = reactive({
|
||||||
|
type: 'checkbox',
|
||||||
|
showCheckedAll: true,
|
||||||
|
onlyCurrentPage: false,
|
||||||
|
});
|
||||||
|
|
||||||
// 医生弹窗查看状态
|
// 医生弹窗查看状态
|
||||||
const doctorModalVisible = ref(false);
|
const doctorModalVisible = ref(false);
|
||||||
@@ -263,6 +307,7 @@ const handleResetQuery = () => {
|
|||||||
queryForm.doctor_name = '';
|
queryForm.doctor_name = '';
|
||||||
queryForm.mobile = '';
|
queryForm.mobile = '';
|
||||||
pager.page = 1;
|
pager.page = 1;
|
||||||
|
selectedRowKeys.value = [];
|
||||||
fetchTableData();
|
fetchTableData();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -304,17 +349,80 @@ const handleRemoveBinding = async (record) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 通用文件安全下载方法
|
||||||
|
const triggerDownload = (fileUrl, fileName = '药房关联医生列表') => {
|
||||||
|
if (!fileUrl) return;
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
link.setAttribute('download', fileName);
|
||||||
|
link.target = '_blank';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 药房关联医生列表导出
|
||||||
|
const handleExport = async (type) => {
|
||||||
|
const pharmacyId = currentPharmacy.value?.pharmacy_id;
|
||||||
|
if (!pharmacyId) {
|
||||||
|
Message.warning('未能获取当前药房信息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 场景 2:按选中导出需校验勾选项
|
||||||
|
if (type === 2 && (!selectedRowKeys.value || selectedRowKeys.value.length === 0)) {
|
||||||
|
Message.warning('请先勾选需要导出的医生数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
type,
|
||||||
|
pharmacy_id: String(pharmacyId),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (type === 1) {
|
||||||
|
if (queryForm.doctor_name) params.doctor_name = queryForm.doctor_name.trim();
|
||||||
|
if (queryForm.mobile) params.mobile = queryForm.mobile.trim();
|
||||||
|
} else if (type === 2) {
|
||||||
|
params.id = selectedRowKeys.value.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
exportLoading.value = true;
|
||||||
|
try {
|
||||||
|
const res = await exportPharmacyDoctor(params);
|
||||||
|
if (res.code === 200 && res.data) {
|
||||||
|
Message.success('导出成功,正在下载文件...');
|
||||||
|
const pharmacyName = currentPharmacy.value?.pharmacy_name || '药房';
|
||||||
|
triggerDownload(res.data, `${pharmacyName}_关联医生.xlsx`);
|
||||||
|
} else {
|
||||||
|
Message.error(res.message || '导出失败,请稍后重试');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('导出异常:', error);
|
||||||
|
Message.error('导出请求异常,请联系系统管理员');
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 下拉菜单导出命令分发
|
||||||
|
const handleExportCommand = (value) => {
|
||||||
|
handleExport(Number(value));
|
||||||
|
};
|
||||||
|
|
||||||
// 打开抽屉
|
// 打开抽屉
|
||||||
const open = (pharmacy) => {
|
const open = (pharmacy) => {
|
||||||
currentPharmacy.value = pharmacy;
|
currentPharmacy.value = pharmacy;
|
||||||
queryForm.doctor_name = '';
|
queryForm.doctor_name = '';
|
||||||
queryForm.mobile = '';
|
queryForm.mobile = '';
|
||||||
pager.page = 1;
|
pager.page = 1;
|
||||||
|
selectedRowKeys.value = [];
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
fetchTableData();
|
fetchTableData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
selectedRowKeys.value = [];
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -324,6 +432,19 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.table-toolbar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 0 2px;
|
||||||
|
|
||||||
|
.table-total-tip {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #86909c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.pharmacy-summary-card {
|
.pharmacy-summary-card {
|
||||||
background-color: #f7f8fa;
|
background-color: #f7f8fa;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|||||||
@@ -228,7 +228,7 @@
|
|||||||
<template #icon><icon-user-group /></template>
|
<template #icon><icon-user-group /></template>
|
||||||
关联医生
|
关联医生
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-popconfirm
|
<!-- <a-popconfirm
|
||||||
v-if="hasPermission('admin:sysPharmacy:remove')"
|
v-if="hasPermission('admin:sysPharmacy:remove')"
|
||||||
content="确定要删除此药房吗?删除后不可恢复!"
|
content="确定要删除此药房吗?删除后不可恢复!"
|
||||||
type="warning"
|
type="warning"
|
||||||
@@ -238,7 +238,7 @@
|
|||||||
<template #icon><icon-delete /></template>
|
<template #icon><icon-delete /></template>
|
||||||
删除
|
删除
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-popconfirm>
|
</a-popconfirm> -->
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
|
|||||||
Reference in New Issue
Block a user