| | |
| | | } |
| | | }, |
| | | async piliangPrint() { |
| | | // 检查是否有选中的数据 |
| | | if (this.piliangList.length === 0) { |
| | | this.$message.warning('请先选择要打印的数据'); |
| | | return; |
| | | } |
| | | |
| | | const loadingInstance = this.$loading({ |
| | | lock: true, |
| | | text: '打印中...', |
| | |
| | | // 获取数据,并等待数据更新完成 |
| | | const tableList = await this.fetchData(item.tjNumber); |
| | | |
| | | // 只保留最新两个元素 |
| | | if (tableList.length > 0) { |
| | | this.selectList = tableList.slice(0, 2); |
| | | } else { |
| | | this.selectList = []; // 如果没有数据,清空selectList |
| | | // 检查 tableList 是否有数据 |
| | | if (!tableList || tableList.length === 0) { |
| | | console.error(`体检号 ${item.tjNumber} 无相关数据`); |
| | | continue; |
| | | } |
| | | |
| | | // 使用更新后的tableList获取ids |
| | | // 直接使用所有数据 |
| | | this.selectList = tableList; |
| | | |
| | | // 检查 selectList 是否有数据 |
| | | if (this.selectList.length === 0) { |
| | | console.error(`体检号 ${item.tjNumber} 的 selectList 为空,跳过 WebSocket 操作`); |
| | | continue; |
| | | } |
| | | |
| | | // 使用更新后的 tableList 获取 ids |
| | | let ids = this.selectList.map(row => row.id); |
| | | if (ids.length === 0) { |
| | | console.error(`体检号 ${item.tjNumber} 无有效 ID`); |
| | | continue; |
| | | } |
| | | |
| | | // 确认采样 |
| | | await this.Confirmreceipt1(ids); |
| | | |
| | | // 等待一段时间 |
| | |
| | | } |
| | | } |
| | | } finally { |
| | | this.ids = []; // 清空ids |
| | | this.selectList = []; // 清空selectList |
| | | this.ids = []; // 清空 ids |
| | | this.selectList = []; // 清空 selectList |
| | | loadingInstance.close(); |
| | | } |
| | | }, |
| | |
| | | const selectedCount = selection.length; |
| | | const totalCount = this.samplingList.length; |
| | | |
| | | // 如果只有一条数据,不要禁用选择 |
| | | if (selectedCount === 1 && totalCount === 1) { |
| | | // 如果只有一条数据,不要禁用选择,并展示右侧列表 |
| | | if (selectedCount === 1) { |
| | | this.disableSelections = false; |
| | | |
| | | } else if (selectedCount === totalCount && selectedCount > 0) { |
| | | const selectedPerson = selection[0]; |
| | | const tjNumber = selectedPerson.tjNumber; |
| | | console.log(`选中的体检号: ${tjNumber}`); |
| | | this.fetchData(tjNumber); |
| | | } else if (selectedCount === totalCount && selectedCount > 1) { |
| | | // 全选时禁用选择新行 |
| | | this.disableSelections = true; |
| | | this.tableList = []; |
| | |
| | | } else { |
| | | // 非全选时启用选择 |
| | | this.disableSelections = false; |
| | | |
| | | if (selectedCount === 1) { |
| | | const selectedPerson = selection[0]; |
| | | const tjNumber = selectedPerson.tjNumber; |
| | | console.log(`选中的体检号: ${tjNumber}`); |
| | | this.fetchData(tjNumber); |
| | | } else if (selectedCount > 1) { |
| | | if (selectedCount > 1) { |
| | | // 保留单选功能,取消多选 |
| | | let del_row = selection.shift(); |
| | | this.$refs.tb.toggleRowSelection(del_row, false); |