| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="是否采样" prop="isSignFor"> |
| | | <el-select style="width:100px" v-model="queryParams.isSignFor" placeholder="是否采样"> |
| | | <el-select1 style="width:100px" v-model="queryParams.isSignFor" placeholder="是否采样"> |
| | | <el-option v-for="dict in dict.type.sampling_type" :key="dict.value" :label="dict.label" |
| | | :value="dict.value"></el-option> |
| | | </el-select> |
| | | </el-select1> |
| | | </el-form-item> --> |
| | | <!-- <el-form-item label="体检时间" prop="tjTime"> |
| | | <el-date-picker clearable v-model="queryParams.tjTime" type="date" value-format="yyyy-MM-dd" |
| | |
| | | </div> |
| | | <div style="width: 50%"> |
| | | <!-- v-if="this.rightTabShow" --> |
| | | <el-table v-loading="loading" :data="tableList" @selection-change="handleChange" :span-method="objectSpanMethod" |
| | | ref="tab1" :row-class-name="tableRowClassName" border height="520px"> |
| | | <el-table :key="tableKey" :row-key="getRowKey" v-if="tableList.length > 0" v-loading="loading" :data="tableList" |
| | | @selection-change="handleChange" :span-method="objectSpanMethod" ref="tab1" |
| | | :row-class-name="tableRowClassName" border height="520px"> |
| | | <el-table-column type="selection" width="40" align="center" /> |
| | | <!-- :selectable="selectEnable" --> |
| | | <!-- <el-table-column label="是否签收" align="center" prop="isSignFor" /> --> |
| | |
| | | :limit.sync="queryParams.pageSize" @pagination="getList" /> |
| | | </div> --> |
| | | |
| | | <div style="margin-right: 70%"> |
| | | <div style="margin-right: 50%"> |
| | | <!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :pager-count="5" :current-page.sync="currentPage1" :current-page="page" |
| | | :page-sizes="pageSize" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="total"> |
| | | </el-pagination> --> |
| | |
| | | piliangList: [], |
| | | msg: "", |
| | | getNumbr: null, |
| | | valueUrl: "ws://192.168.1.138:6789/websocket", |
| | | valueUrl: "ws://127.0.0.1:6789/websocket", |
| | | webSocket: null, |
| | | list: [], |
| | | selectList: [], |
| | |
| | | }, |
| | | // 表单参数 |
| | | form: {}, |
| | | tableKey: "", |
| | | // 表单校验 |
| | | rules: {}, |
| | | // rightTabShow: false |
| | |
| | | } |
| | | }, |
| | | 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(); |
| | | } |
| | | }, |
| | |
| | | return ""; // 如果 applicationTime 无效,返回空字符串 |
| | | }, |
| | | /** 查询体检采样管理列表 */ |
| | | /** 查询体检采样管理列表 */ |
| | | getList() { |
| | | this.queryParams.compId = this.CheckBox.drugManufacturerId; |
| | | this.loading1 = true; |
| | |
| | | if (this.createTimeList) { |
| | | this.queryParams.beginTime = this.createTimeList[0]; |
| | | this.queryParams.endTime = this.createTimeList[1]; |
| | | } else if (this.createTimeList == null) { |
| | | } else { |
| | | this.queryParams.beginTime = null; |
| | | this.queryParams.endTime = null; |
| | | } |
| | | |
| | | getList(this.queryParams).then((response) => { |
| | | this.loading1 = false; |
| | | if (response.data) { |
| | | if (!response.data.list || response.data.list.length === 0) { |
| | | this.samplingList = []; |
| | | this.tableList = []; |
| | | this.loading1 = false; |
| | | this.loading = false; |
| | | return; |
| | | } else { |
| | | this.samplingList = response.data.list; |
| | | // 判断是否需要刷新右边表格 |
| | | this.$nextTick(() => { |
| | | this.$refs.tb.toggleRowSelection(this.samplingList[0], true); |
| | | // 检查是否全选 |
| | | if (this.samplingList.length === this.selectedRows.length) { |
| | | this.disableSelections = true; |
| | | } else { |
| | | this.disableSelections = false; |
| | | } |
| | | }); |
| | | } |
| | | if (response.data && response.data.list && response.data.list.length > 0) { |
| | | this.samplingList = response.data.list; |
| | | this.total = response.data.total; |
| | | this.loading1 = false; |
| | | } else { |
| | | this.samplingList = []; |
| | | this.tableList = []; |
| | | this.loading1 = false; |
| | | } |
| | | }); |
| | | this.$nextTick(() => { |
| | | if (this.$refs.tb) { |
| | | |
| | | /* getList(this.queryParams).then((response) => { |
| | | if (response.data) { |
| | | if (response.data.list == null) { |
| | | this.samplingList = []; |
| | | this.tableList = []; |
| | | this.loading = false; |
| | | } else { |
| | | this.samplingList = response.data.list; |
| | | console.log(this.samplingList,888); |
| | | |
| | | this.loading = false; |
| | | if (this.samplingList.length != 0) { |
| | | this.$nextTick(() => { |
| | | this.$refs.tb.toggleRowSelection(this.samplingList[0], true); |
| | | }); |
| | | } else { |
| | | this.$refs.tb.clearSelection(); |
| | | const headerCheckbox = this.$refs.tb.$el.querySelector('.el-table__header .el-checkbox'); |
| | | if (headerCheckbox) headerCheckbox.style.display = 'none'; |
| | | |
| | | } |
| | | } |
| | | this.total = response.data.total; |
| | | this.loading = false; |
| | | }); |
| | | // 移除默认选中第一行的逻辑 |
| | | // this.$nextTick(() => { |
| | | // this.$refs.tb.toggleRowSelection(this.samplingList[0], true); // 默认选中第一行 |
| | | // this.fetchData(this.samplingList[0].tjNumber); // 刷新右侧表格 |
| | | // }); |
| | | } else { |
| | | this.samplingList = []; |
| | | this.tableList = []; |
| | | this.loading = false; |
| | | this.selectList = []; // 清空 selectList |
| | | this.ids = []; // 清空 ids |
| | | if (this.$refs.tab1) { |
| | | this.$refs.tab1.clearSelection(); // 清空右侧表格选中状态 |
| | | } |
| | | } |
| | | }); */ |
| | | this.loading1 = false; |
| | | }); |
| | | }, |
| | | // 取消按钮 |
| | | cancel() { |
| | |
| | | }, |
| | | /** 重置按钮操作 */ |
| | | resetQuery() { |
| | | this.createTimeList = []; |
| | | this.handleQuery(); |
| | | this.createTimeList = []; // 清空日期范围 |
| | | this.queryParams.tjNumber = null; // 清空体检号 |
| | | this.queryParams.name = null; // 清空姓名 |
| | | this.queryParams.tjCompName = null; // 清空单位名称 |
| | | this.selectList = []; // 清空右侧选中项 |
| | | this.selectedRows = []; // 清空左侧选中项 |
| | | this.tableList = []; // 清空右侧表格数据 |
| | | this.ids = []; // 清空选中的 ID |
| | | this.$refs.tb.clearSelection(); // 清空左侧表格选中状态 |
| | | if (this.$refs.tab1) { |
| | | this.$refs.tab1.clearSelection(); // 清空右侧表格选中状态 |
| | | } |
| | | this.handleQuery(); // 重新查询 |
| | | }, |
| | | |
| | | handleSelectionChange(selection) { |
| | |
| | | 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); |
| | |
| | | console.log(`是否禁用选择: ${this.disableSelections}`); |
| | | }, |
| | | |
| | | getRowKey(row) { |
| | | return row.id; // 必须唯一且稳定 |
| | | }, |
| | | |
| | | fetchData(tjNumber) { |
| | | return new Promise((resolve, reject) => { |
| | | this.loading = true; |
| | |
| | | .then((response) => { |
| | | if (response.data) { |
| | | this.tableList = response.data; |
| | | this.tableKey = Date.now() |
| | | this.$nextTick(() => { |
| | | if (this.$refs.tab1) { |
| | | this.$refs.tab1.doLayout(); // 修改为正确的 ref 名称 |
| | | this.$refs.tab1.clearSelection(); // 清空选中状态 |
| | | const headerCheckbox = this.$refs.tab1.$el.querySelector('.el-table__header .el-checkbox'); |
| | | if (headerCheckbox) headerCheckbox.style.display = 'inline'; |
| | | } |
| | | }); |
| | | resolve(this.tableList); |
| | | this.loading = false; |
| | | } else { |
| | | this.tableList = []; |
| | | this.selectList = []; |
| | | this.ids = []; |
| | | if (this.$refs.tab1) { |
| | | this.$refs.tab1.clearSelection(); |
| | | } |
| | | resolve([]); |
| | | } |
| | | }) |
| | |
| | | }, |
| | | |
| | | handleChange(selection) { |
| | | // console.log(selection); |
| | | |
| | | this.selectList = selection; |
| | | console.log(this.selectList, 9977); |
| | | var array = selection; |
| | | this.ids = array.map((item) => item.id); |
| | | }, |
| | |
| | | }; |
| | | websocket.onopen = () => { |
| | | this.websocket = websocket; |
| | | console.log(this.selectList, "this.selectList") |
| | | this.dayinData = this.selectList.map((item) => ({ |
| | | jyxh: item.jyxh, |
| | | proName: item.proName, |
| | |
| | | cardId: item.cardId, |
| | | tjTime: item.createTime, |
| | | })); |
| | | |
| | | |
| | | // 连接设备 |
| | | this.jsonObj = { |
| | | type: "3", |
| | |
| | | }, |
| | | }; |
| | | var jStr = JSON.stringify(this.jsonObj); |
| | | console.log(jStr, "jStr"); |
| | | |
| | | this.websocket.send(jStr); |
| | | this.$refs.tab1.clearSelection(); // 清除右侧表格的选中状态 |
| | | this.selectList = []; // 清空 selectList |
| | | this.ids = []; // 清空 ids |
| | | this.jsonObj = {}; |
| | | // this.dialogVisible = false; |
| | | }; |
| | |
| | | // 确认采样 |
| | | Confirmreceipt() { |
| | | const loadingInstance = this.$loading({ |
| | | lock: true, // 锁定屏幕 |
| | | text: "加载中...", // 加载文本 |
| | | spinner: "el-icon-loading", // 自定义加载图标 |
| | | background: "rgba(255, 255, 255, 0.7)", // 背景颜色 |
| | | lock: true, |
| | | text: "加载中...", |
| | | spinner: "el-icon-loading", |
| | | background: "rgba(255, 255, 255, 0.7)", |
| | | }); |
| | | confirmSampling(this.ids) |
| | | .then((res) => { |
| | | console.log(this.selectList, 2222); |
| | | |
| | | if (res.code === 200) { |
| | | this.buda(); |
| | | this.getList(); |
| | | this.buda(); // 打印条码 |
| | | |
| | | this.getList(); // 刷新左侧表格 |
| | | console.log("采样后 - selectList:", this.selectList, "qiehuan:", this.qiehuan); |
| | | } else { |
| | | this.$message.error(res.msg); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.error("采样失败:", error); |
| | | }) |
| | | .finally(() => { |
| | | loadingInstance.close(); |
| | |
| | | }); |
| | | }, |
| | | // 单选按钮 |
| | | // 单选按钮 |
| | | radioChange(value) { |
| | | this.loading = true; |
| | | this.queryParams.isSignFor = value; |
| | |
| | | this.loading = false; |
| | | } else { |
| | | this.samplingList = response.data.list; |
| | | this.loading = false; |
| | | if (this.samplingList.length != 0) { |
| | | this.$nextTick(() => { |
| | | this.$refs.tb.toggleRowSelection(this.samplingList[0], true); |
| | | }); |
| | | } else { |
| | | this.$refs.tb.clearSelection(); |
| | | this.$nextTick(() => { |
| | | if (this.$refs.tb) { |
| | | |
| | | const headerCheckbox = this.$refs.tb.$el.querySelector('.el-table__header .el-checkbox'); |
| | | if (headerCheckbox) headerCheckbox.style.display = 'none'; |
| | | |
| | | } |
| | | }); |
| | | this.loading = false; |
| | | // 移除默认选中第一行的逻辑 |
| | | // if (this.samplingList.length != 0) { |
| | | // this.$nextTick(() => { |
| | | // this.$refs.tb.toggleRowSelection(this.samplingList[0], true); |
| | | // }); |
| | | // } else { |
| | | // this.$refs.tb.clearSelection(); |
| | | // } |
| | | } |
| | | this.total = response.data.total; |
| | | this.loading = false; |