diff --git a/src/api/checkCode/index.ts b/src/api/checkCode/index.ts index 0e1ce24..40f7e01 100644 --- a/src/api/checkCode/index.ts +++ b/src/api/checkCode/index.ts @@ -26,4 +26,20 @@ export function fetchCodeDetail(query?: Object) { method: 'get', params: query, }); +} +// 执行条码 +export function fetchCodeExec(query?: Object) { + return request({ + url: '/zyreq/exec', + method: 'get', + params: query, + }); +} +// 获取申请单主表信息 +export function fetchCodeReqmain(query?: Object) { + return request({ + url: 'zyreq/reqmain', + method: 'get', + params: query, + }); } \ No newline at end of file diff --git a/src/plugins/download.js b/src/plugins/download.js index 1a89efd..a4a0377 100644 --- a/src/plugins/download.js +++ b/src/plugins/download.js @@ -1,11 +1,21 @@ import axios from 'axios' -import { ElLoading, ElMessage } from 'element-plus' -import { saveAs } from 'file-saver' -import { getToken } from '@/utils/auth' +import { + ElLoading, + ElMessage +} from 'element-plus' +import { + saveAs +} from 'file-saver' +import { + getToken +} from '@/utils/auth' import errorCode from '@/utils/errorCode' -import { blobValidate } from '@/utils/ruoyi' +import { + blobValidate +} from '@/utils/ruoyi' -const baseURL = import.meta.env.VITE_APP_BASE_API +const baseURL = + import.meta.env.VITE_APP_BASE_API let downloadLoadingInstance; export default { @@ -15,7 +25,14 @@ export default { method: 'get', url: url, responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } + headers: { + 'Authorization': 'Bearer ' + getToken() + }, + onDownloadProgress: (progressEvent) => { + console.log(progressEvent) + //progressEvent.loaded 下载文件的当前大小 + //progressEvent.total 下载文件的总大小 如果后端没有返回 请让他加上 + } }).then((res) => { const isBlob = blobValidate(res.data); if (isBlob) { @@ -32,7 +49,9 @@ export default { method: 'get', url: url, responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } + headers: { + 'Authorization': 'Bearer ' + getToken() + } }).then((res) => { const isBlob = blobValidate(res.data); if (isBlob) { @@ -45,16 +64,23 @@ export default { }, zip(url, name) { var url = baseURL + url - downloadLoadingInstance = ElLoading.service({ text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)", }) + downloadLoadingInstance = ElLoading.service({ + text: "正在下载数据,请稍候", + background: "rgba(0, 0, 0, 0.7)", + }) axios({ method: 'get', url: url, responseType: 'blob', - headers: { 'Authorization': 'Bearer ' + getToken() } + headers: { + 'Authorization': 'Bearer ' + getToken() + } }).then((res) => { const isBlob = blobValidate(res.data); if (isBlob) { - const blob = new Blob([res.data], { type: 'application/zip' }) + const blob = new Blob([res.data], { + type: 'application/zip' + }) this.saveAs(blob, name) } else { this.printErrMsg(res.data); @@ -75,5 +101,4 @@ export default { const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] ElMessage.error(errMsg); } -} - +} \ No newline at end of file diff --git a/src/utils/hiprintPrinter.ts b/src/utils/hiprintPrinter.ts index a752904..98d3805 100644 --- a/src/utils/hiprintPrinter.ts +++ b/src/utils/hiprintPrinter.ts @@ -2,7 +2,9 @@ import { io, Socket } from "socket.io-client"; import { ElMessage, ElMessageBox } from 'element-plus' import { usePrintStore } from '@/store/modules/printStore' - +import { onUnmounted } from "vue" +// @ts-ignore +import Download from '@/plugins/download'; // ... 类型定义 ... type PrinterInfo = { name: string; @@ -61,7 +63,7 @@ function initSocket(onPrinterUpdate?: OnPrinterUpdate) { socket.on("connect_error", (err: Error) => { console.log('连接错误', err); ElMessageBox.alert( - `连接失败!请确保目标服务器已 下载 并运行 打印服务!`, + `连接失败!请确保目标服务器已 下载 并运行 打印服务!`, "客户端未连接", { dangerouslyUseHTMLString: true, @@ -70,8 +72,19 @@ function initSocket(onPrinterUpdate?: OnPrinterUpdate) { printStore.setConnected(false); socket?.close(); }); + + } + +const downExe = () => { + // 下载逻辑实现 + console.log('开始下载打印服务'); + Download.name('hiprint_win_x64-1.0.13.exe') +}; + +// 挂载到window,使其能被全局访问 +(window as any).downExe = downExe function silentPrintPdf(url: string, printOptions?: object) { const printStore = usePrintStore(); if (!url) { @@ -143,4 +156,10 @@ export const HiprintPrinter = { const printStore = usePrintStore(); return printStore.defaultPrinter; }, -}; \ No newline at end of file +}; + +onUnmounted(() => { + if ('downExe' in window) { + delete (window as any).downExe; + } +}); \ No newline at end of file diff --git a/src/views/checkCode/index.vue b/src/views/checkCode/index.vue index 5468e7b..f9c081b 100644 --- a/src/views/checkCode/index.vue +++ b/src/views/checkCode/index.vue @@ -4,7 +4,7 @@ - @@ -15,12 +15,12 @@ - + - + @@ -54,10 +54,10 @@ 打印 - 采样登记 + 采样登记 - 送检登记 + 送检登记 报告查询 @@ -76,7 +76,7 @@ + @row-click="rowHandle" @selection-change="selectionChange"> {{ row.jzbz == '1' ? '急诊' : '非急诊' }} @@ -87,7 +87,7 @@ {{ formatDict(row.brly, 'PT') }} - {{ formatDict(row.zt, 'ST') }} + {{ formatDict(row.zt.trim(), 'ST') }} {{ formatDict(row.yljg, 'HOS') }} @@ -111,15 +111,15 @@ - + - + - 读取 + 读取 删除选中行 @@ -128,35 +128,13 @@ 打印 - 保存 + - + + + {{ formatDict(row.zt, 'ST') }} + - - - - - - - - - - - 读取 - - - 删除选中行 - - - 打印 - - - 保存 - - - - @@ -169,8 +147,9 @@ import { classCom } from '@/utils/classCom'; import CustomTable from '@/components/tableCom/index.vue' import { useRouter } from 'vue-router' import { usePrintStore } from '@/store/modules/printStore' -import { fetchCodeList, addObj, fetchCodeDetail } from '@/api/checkCode/index' +import { fetchCodeList, addObj, fetchCodeDetail, fetchCodeExec, fetchCodeReqmain } from '@/api/checkCode/index' import { TableColumnCtx } from 'element-plus'; +import dayjs from 'dayjs'; //@ts-ignore import { comDict } from '@/utils/dict' import { ElMessage, ElMessageBox } from 'element-plus' @@ -179,17 +158,20 @@ const printStore = usePrintStore(); const compactForm = ref(null); const heightForm = ref(90); const dialogVisible = ref(false) -const openBlock = () => { - dialogVisible.value = true -} +const title = ref('采样登记') +const sqhText = ref('') -const dialogSjVisible = ref(false) -const openSj = () => { - dialogSjVisible.value = true +interface QueryParams { + times: string[]; // 明确类型为字符串元组 + yljg: string; + zt: string; + failed4: string; + failed5: string; } // 提交表单数据 -const queryParams = reactive({ - failed1: ['2025-07-18 00:00:00', '2025-07-18 23:59:59'], +const queryParams = reactive({ + times: ['2025-07-18 00:00:00', '2025-07-18 23:59:59'], + // times: [], yljg: '1', zt: '', failed4: '', @@ -210,14 +192,17 @@ const queryRules = ref({ }) const options = [ { - value: 'Option1', - label: 'Option1', + value: '1', + label: '通过姓名搜索', }, { - value: 'Option2', - label: 'Option2', + value: '2', + label: '通过病人号搜索', + }, + { + value: '3', + label: '通过床号搜索', }, - ] interface DictData { SX?: Array; @@ -267,6 +252,9 @@ const columns = ref([ { prop: 'yljg', label: '医疗机构', align: 'center', visible: true, slot: 'yljg', key: 18, width: '170px' }, ]) +const single = ref(true); +const multiple = ref(true); +const sqhs = ref([]); // 单元格样式 const cellStyleHd = ({ row, column, rowIndex, columnIndex }: { row: any; @@ -298,11 +286,15 @@ const rowClassNameHd = ({ row, rowIndex }: { }; // 点击行 const rowHandle = (row: any, column: TableColumnCtx, event: Event) => { - console.log(row); getRightTable(row) - }; +const selectionChange = (selection: any) => { + sqhs.value = selection; + single.value = selection.length != 1; + multiple.value = !selection.length; +} + // 左侧表格配置 const tableConfig = ref({ // stripe: true, // 斑马纹 @@ -337,6 +329,84 @@ const rightTableConfig = ref({ highlightCurrentRow: true, // 高亮当前行 }) +// 采样数据源 +const cyTableData = ref([]) +// 配置项 +const cyColumns = ref([ + { prop: 'sqh', label: '申请号/条形码', visible: true, key: 0, sortable: true, width: '140px' }, + { prop: 'ksdh', label: '科室病区', visible: true, key: 1, width: '120px' }, + { prop: 'ch', label: '床号', visible: true, key: 2, sortable: true, }, + { prop: 'brxm', label: '姓名', visible: true, key: 3, }, + { prop: 'brdh', label: '病人号', visible: true, key: 4, }, + { prop: 'brxb', label: '性别', align: 'center', visible: true, key: 5, }, + { prop: 'yblx', label: '样本类型', align: 'center', visible: true, key: 6 }, + { prop: 'zt', label: '状态', align: 'center', visible: true, slot: 'zt', key: 7 }, + { prop: 'jzbz', label: '急诊', align: 'center', visible: true, key: 8 }, + { prop: 'jjzt', label: '采样人', align: 'center', visible: true, key: 8 }, + { prop: 'cysj', label: '采样时间', align: 'center', visible: true, key: 8 }, + { prop: 'zxysname', label: '执行医生', align: 'center', visible: true, key: 8 }, + { prop: 'zxsj', label: '执行时间', align: 'center', visible: true, key: 8 }, +]) +// 表格配置 +const cyTableConfig = ref({ + // stripe: true, // 斑马纹 + border: false, // 边框 + selection: true, // 多选框 + index: false, // 序号 + height: '100%', // 高度 + highlightCurrentRow: true, // 高亮当前行 +}) + +// 采样登记 +const openBlock = async (value: string) => { + if (sqhs.value.length > 0) { + try { + // 生成请求Promise数组 + const requests = sqhs.value.map((item: any) => fetchCodeExec({ + sqh: item.sqh, + userid: 'lis', + status: 12, + yljg: 1 + })); + const results = await Promise.all(requests); + console.log('所有请求成功:', results); + return results; + } catch (error: any) { + console.error('至少一个请求失败:', error.message); + throw error; + } + + } else { + title.value = value + dialogVisible.value = true + } + + +} +// 采样读取 +const sqdQuery = () => { + const index = cyTableData.value.findIndex((item: any) => item.sqh == sqhText.value) + if (index !== -1) return ElMessage.warning('该申请单数据已存在!') + + fetchCodeReqmain({ sqh: sqhText.value }).then((res: any) => { + if (res.code == 0 && res.data.sqh) { + fetchCodeExec({ + sqh: res.data.sqh, + userid: 'lis', + status: 12, + yljg: 1 + }) + cyTableData.value = cyTableData.value.concat(res.data) + } + }) +} +// 关闭弹窗清空 +const closeDialog = () => { + cyTableData.value = [] + sqhText.value = '' +} + + interface ColumnItem { prop: string; label: string; @@ -367,8 +437,13 @@ const goReport = () => { }; onMounted(async () => { - adjustTableHeight(); + // 初始化3天区间(今天-前两天) + // const end = dayjs().format('YYYY-MM-DD HH:mm:ss'); + // const start = dayjs().subtract(2, 'day').format('YYYY-MM-DD HH:mm:ss'); //add 时间往后 + // queryParams.times = [start, end]; + // console.log(queryParams.times); getList() + adjustTableHeight(); // 加载病人来源字典 const dictRefs = await comDict('PT', 'HOS', 'ST'); @@ -378,11 +453,13 @@ onMounted(async () => { HOS: toRaw(dictRefs.HOS.value) || [], ST: toRaw(dictRefs.ST.value) || [], }; + + + }); // 字典格式化方法 const formatDict = (v: string, dictType: string) => { - // 从全局字典中获取映射值 return dictData.value[dictType]?.find((item: any) => item.value == v)?.label; }; @@ -397,14 +474,13 @@ function adjustTableHeight() { if (compactForm.value) { // 获取高度 heightForm.value = compactForm.value.offsetHeight; - tableConfig.value.height = `calc(75vh - ${heightForm.value}px)`; // 设置表格容器的高度 - rightTableConfig.value.height = `calc(79vh - ${heightForm.value}px)`; + tableConfig.value.height = `calc(72vh - ${heightForm.value}px)`; // 设置表格容器的高度 + rightTableConfig.value.height = `calc(76vh - ${heightForm.value}px)`; } } const handletime = (val: Array) => { - console.log(val); - + console.log('时间', val); } // 生成条码 @@ -412,8 +488,8 @@ const printHandle = () => { const data = { dept: '0235', userid: 'lis', - st: queryParams.failed1[0], - et: queryParams.failed1[1], + st: queryParams.times[0], + et: queryParams.times[1], yljg: queryParams.yljg } addObj(data).then((res: any) => { @@ -430,8 +506,8 @@ const getList = () => { const data = { dept: '0235', userid: 'lis', - st: queryParams.failed1[0], - et: queryParams.failed1[1], + st: queryParams.times[0], + et: queryParams.times[1], yljg: queryParams.yljg } fetchCodeList(data).then((response: any) => { @@ -444,6 +520,7 @@ const getList = () => { } const printHandle1 = () => { const url = 'http://47.97.125.165:8904/lis.pdf' + // const url = sqhs.value[0]?.pdfUrl HiprintPrinter.silentPrintPdf( url, { @@ -451,6 +528,7 @@ const printHandle1 = () => { orientation: "portrait", // 纵向(landscape=横向) copies: 1, monochrome: false, // 是否黑白打印 + // paperName: 'A4', // 纸张大小 A2, A3, A4, A5, A6, letter, legal, tabloid, statement }, );