diff --git a/src/api/basic/pharmacy.js b/src/api/basic/pharmacy.js
index afde052..24be1b6 100644
--- a/src/api/basic/pharmacy.js
+++ b/src/api/basic/pharmacy.js
@@ -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,
+ });
+}
diff --git a/src/views/basic/pharmacy/components/pharmacyDoctorDrawer.vue b/src/views/basic/pharmacy/components/pharmacyDoctorDrawer.vue
index 478d98e..0f596ac 100644
--- a/src/views/basic/pharmacy/components/pharmacyDoctorDrawer.vue
+++ b/src/views/basic/pharmacy/components/pharmacyDoctorDrawer.vue
@@ -83,6 +83,39 @@
+
+
+
@@ -164,7 +199,7 @@
import { ref, reactive, computed } from 'vue';
import { Message } from '@arco-design/web-vue';
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 DoctorModal from '@/components/doctorModal.vue';
@@ -178,8 +213,17 @@ const hasPermission = (permission) => {
const visible = ref(false);
const loading = ref(false);
+const exportLoading = ref(false);
const currentPharmacy = ref(null);
const tableData = ref([]);
+const selectedRowKeys = ref([]);
+
+// 表格多选配置
+const rowSelection = reactive({
+ type: 'checkbox',
+ showCheckedAll: true,
+ onlyCurrentPage: false,
+});
// 医生弹窗查看状态
const doctorModalVisible = ref(false);
@@ -263,6 +307,7 @@ const handleResetQuery = () => {
queryForm.doctor_name = '';
queryForm.mobile = '';
pager.page = 1;
+ selectedRowKeys.value = [];
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) => {
currentPharmacy.value = pharmacy;
queryForm.doctor_name = '';
queryForm.mobile = '';
pager.page = 1;
+ selectedRowKeys.value = [];
visible.value = true;
fetchTableData();
};
const handleClose = () => {
+ selectedRowKeys.value = [];
visible.value = false;
};
@@ -324,6 +432,19 @@ defineExpose({