diff --git a/auto-imports.d.ts b/auto-imports.d.ts index c2047c2..21b8307 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -6,5 +6,6 @@ // biome-ignore lint: disable export {} declare global { + const ElMessage: typeof import('element-plus/es')['ElMessage'] const ElMessageBox: typeof import('element-plus/es')['ElMessageBox'] } diff --git a/components.d.ts b/components.d.ts index 4be7cb0..cdd5939 100644 --- a/components.d.ts +++ b/components.d.ts @@ -20,7 +20,6 @@ declare module 'vue' { Keyboard: typeof import('./src/components/Keyboard.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] - ShowErrorModal: typeof import('./src/components/dialogs/ShowErrorModal.vue')['default'] SimpleKeyboard: typeof import('./src/components/SimpleKeyboard.vue')['default'] StackInfoModal: typeof import('./src/components/dialogs/StackInfoModal.vue')['default'] } diff --git a/src/assets/Index/History/success.svg b/src/assets/Index/History/success.svg new file mode 100644 index 0000000..c3bf8a5 --- /dev/null +++ b/src/assets/Index/History/success.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/dialogs/StackInfoModal.vue b/src/components/dialogs/StackInfoModal.vue index 945c318..72aaa6d 100644 --- a/src/components/dialogs/StackInfoModal.vue +++ b/src/components/dialogs/StackInfoModal.vue @@ -204,19 +204,19 @@ const closeStackInfoModal = () => { showStackInfo.value = false } -const copyStackInfo = () => { - if (stackInfo.value?.stackTraceElements) { - const text = stackInfo.value.stackTraceElements.join('\n') - navigator.clipboard.writeText(text) - .then(() => { - // 可以添加一个复制成功的提示 - alert('错误信息已复制到剪贴板') - }) - .catch(err => { - console.error('复制失败:', err) - }) - } -} +// const copyStackInfo = () => { +// if (stackInfo.value?.stackTraceElements) { +// const text = stackInfo.value.stackTraceElements.join('\n') +// navigator.clipboard.writeText(text) +// .then(() => { +// // 可以添加一个复制成功的提示 +// alert('错误信息已复制到剪贴板') +// }) +// .catch(err => { +// console.error('复制失败:', err) +// }) +// } +// } onMounted(() => { eventBus.on('show-stack-modal', handleStackModal) diff --git a/src/pages/Index/History.vue b/src/pages/Index/History.vue index 93bcc7e..cf9dc02 100644 --- a/src/pages/Index/History.vue +++ b/src/pages/Index/History.vue @@ -13,15 +13,16 @@
- 搜索 + 搜索 重置
- +
@@ -43,36 +44,87 @@ @confirm="handleWarnClose" /> -
-
-
    -
  • 日期:
  • -
    -
  • SampleID
  • -
    -
  • ProjectShortName
  • -
  • subResult1
  • -
  • subResult2
  • -
  • subResult3
  • -
      -
    • 样本种类:
    • -
    • 操次:
    • -
    • Rec:
    • -
    • 有效期:
    • -
      - -
    • 操作人:
    • -
    • 序列号:
    • -
    • App Wer:
    • -
    • F/W Ver:
    • -
      -
    • 参考值:
    • -
    -
+
+
+
+ 日期: + 2024-01-01 +
+
+ +
+ SampleID: + 12345 +
+
+ +
+ ProjectShortName: + Test Project +
+ +
+ subResult1: + Result 1 +
+ +
+ subResult2: + Result 2 +
+ +
+ subResult3: + Result 3 +
+
+ +
+
+ 样本种类: + Type A +
+ +
+ 操次: + 1 +
+ +
+ Rec: + Record 1 +
+ +
+ 有效期: + 2024-12-31 +
+
+ +
+ 操作人: + John Doe +
+ +
+ 序列号: + SN12345 +
+ +
+ App Ver: + 1.0.0 +
+ +
+ F/W Ver: + 2.0.0 +
+
+ + -
- -
@@ -89,6 +141,9 @@ import { import HistoryMessage from './components/History/HistoryMessage.vue' import type { TableItem } from '../../types/Index' +// 添加表格引用 +const historyTableRef = ref() + //选中弹出框 const isVisible = ref(false) @@ -199,17 +254,23 @@ const tableKey = ref(0)//控制重新渲染 const tableContainer = ref(null as HTMLElement | null) const hasMore = ref(true) const loadingText = ref("加载中...") -const getTableData = async () => { - hasMore.value = true +const getTableData = async (isReset: boolean = false) => { + if (isReset) { + // 重置数据和页码 + tableData.value = [] + currentPage.value = 1 + hasMore.value = true + } + if (loading.value || !hasMore.value) return loading.value = true + try { const res = await getHistoryInfoApi() if (currentPage.value > totalPage.value) { hasMore.value = false loadingText.value = "没有更多数据了" } else { - tableData.value = [...tableData.value, ...res.data.list] currentPage.value++; loadingText.value = "加载中..." @@ -248,13 +309,15 @@ const onScroll = (event: any) => { // 搜索功能 const handleSearch = async () => { - // 这里根据 inputValue 进行搜索,更新 tableData console.log('搜索内容:', inputValue.value) - // 根据实际需求实现搜索功能 try { const res = await searchHistoryInfo(inputValue.value) console.log(res.data.list) + // 直接替换数据,不进行累加 tableData.value = res.data.list as TableItem[] + // 重置分页相关状态 + currentPage.value = 1 + hasMore.value = false } catch (error) { console.error('搜索失败', error) } @@ -263,7 +326,7 @@ const handleSearch = async () => { // 重置功能 const handleReset = () => { inputValue.value = '' - getTableData() + getTableData(true) // 传入 true 表示需要重置 } // 确认操作时的回调函数 @@ -272,7 +335,6 @@ const handleConfirm = async () => { showWarn.value = false const actionType = currentAction.value.type if (actionType === 'delete') { - console.log('调用删除接口') await handleDelete() } else if (actionType === 'print') { // 执行打印操作 @@ -283,6 +345,7 @@ const handleConfirm = async () => { } } const handleWarnClose = () => { + getTableData() showWarn.value = false } @@ -295,22 +358,27 @@ const handleCancel = () => { // 删除功能 const handleDelete = async () => { try { - // 调用删除接口,传入要删除的ID数组 if (selectedIds.value.length > 0) { - selectedIds.value.forEach(async item => { + for (const item of selectedIds.value) { const res = await deleteHistoryInfo(item) if (res.success) { tableKey.value++ - getTableData() - // 清空选中的项 + // 清空选中状态 selectedItems.value = [] + selectedIds.value = [] + // 手动清除表格的选中状态 + if (historyTableRef.value?.clearSelection) { + historyTableRef.value.clearSelection() + } + // 重新获取数据,传入 true 表示需要重置 + await getTableData(true) // 提示删除成功 warnMessage.value = '删除成功' showWarn.value = true } else { throw new Error(res.message || '删除失败') } - }) + } } } catch (error) { console.error('删除失败', error) @@ -324,33 +392,29 @@ const handlePrint = async () => { try { if (selectedItems.value.length > 10) { warnMessage.value = '一次最多只能打印 10 条记录' - warnIcon = new URL('@/assets/Index/History/warn.svg', import.meta.url) - .href + warnIcon = new URL('@/assets/Index/History/warn.svg', import.meta.url).href showWarn.value = true return } - const idsToPrint = selectedItems.value.map((item) => item.id) - - // 调用打印接口,获取打印所需的数据 - const res = await printHistoryInfo(idsToPrint) - - if (res.success) { - // 获取打印数据 - const printData = res.data.list - - // 调用打印方法 - await executePrint(printData) - // 提示打印成功 - warnMessage.value = '打印成功' - warnIcon = new URL('@/assets/Index/History/success.svg', import.meta.url) - .href - showWarn.value = true - - // 清空选中的项(可选) - selectedItems.value = [] - } else { - throw new Error(res.message || '打印失败') + const idsToPrint = selectedItems.value.map((item) => item.id) + for (const item of idsToPrint) { + const res = await printHistoryInfo(item) + if (res.success && res.ecode === "SUC") { + warnMessage.value = '打印成功' + warnIcon = new URL('@/assets/Index/History/success.svg', import.meta.url).href + showWarn.value = true + + // 清空选中状态 + selectedItems.value = [] + selectedIds.value = [] + // 手动清除表格的选中状态 + if (historyTableRef.value?.clearSelection) { + historyTableRef.value.clearSelection() + } + } else { + throw new Error(res.message || '打印失败') + } } } catch (error) { console.error('打印失败', error) @@ -360,70 +424,70 @@ const handlePrint = async () => { } } // 执行打印的方法 -const executePrint = async (data: any) => { - // 创建打印内容的模板 - const printContent = createPrintTemplate(data) - - // 创建一个新窗口用于打印 - const printWindow = window.open('', '_blank') - if (printWindow) { - printWindow.document.write(printContent) - printWindow.document.close() - printWindow.focus() - printWindow.print() - printWindow.close() - } else { - throw new Error('无法打开打印窗口') - } -} -// 创建打印模板 -const createPrintTemplate = (data: any) => { - // 根据数据生成打印内容的HTML字符串 - let content = ` - - - 打印 - - - -

打印内容

- - - - - - - - - - - ` - - data.forEach((item: any) => { - content += ` - - - - - - - ` - }) - - content += ` - -
ID用户ID项目名称
${item.id}${item.sampleUserid}${item.projName}
- - - ` - - return content -} +// const executePrint = async (data: any) => { +// // 创建打印内容的模板 +// const printContent = createPrintTemplate(data) + +// // 创建一个新窗口用于打印 +// const printWindow = window.open('', '_blank') +// if (printWindow) { +// printWindow.document.write(printContent) +// printWindow.document.close() +// printWindow.focus() +// printWindow.print() +// printWindow.close() +// } else { +// throw new Error('无法打开打印窗口') +// } +// } +// 创建打印模��� +// const createPrintTemplate = (data: any) => { +// // 根据数据生成打印内容的HTML符串 +// let content = ` +// +// +// 打印 +// +// +// +//

打印内容

+// +// +// +// +// +// +// +// +// +// +// ` + +// data.forEach((item: any) => { +// content += ` +// +// +// +// +// +// +// ` +// }) + +// content += ` +// +//
ID用户ID项目名称
${item.id}${item.sampleUserid}${item.projName}
+// +// +// ` + +// return content +// } // 导出功能 const handleExport = () => { // 执行导出操作 @@ -441,145 +505,237 @@ onMounted(() => { diff --git a/src/pages/Index/components/Consumables/ChangeNum.vue b/src/pages/Index/components/Consumables/ChangeNum.vue index a6fd8f6..387f58b 100644 --- a/src/pages/Index/components/Consumables/ChangeNum.vue +++ b/src/pages/Index/components/Consumables/ChangeNum.vue @@ -12,15 +12,7 @@