From cb1f69717eed3b6a61b6c61a8934bac752782b2d Mon Sep 17 00:00:00 2001 From: wwl <xchao828@163.com> Date: 星期三, 05 三月 2025 17:00:38 +0800 Subject: [PATCH] 1 --- src/views/sampling/sampling/index.vue | 100 ++++++++++++++++++++++++++++++++----------------- 1 files changed, 65 insertions(+), 35 deletions(-) diff --git a/src/views/sampling/sampling/index.vue b/src/views/sampling/sampling/index.vue index 4fc83f2..925f7e6 100644 --- a/src/views/sampling/sampling/index.vue +++ b/src/views/sampling/sampling/index.vue @@ -14,17 +14,17 @@ format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡" :picker-options="pickerOptions"></el-date-picker> </el-form-item> - <el-form-item label="鍗曚綅鍚嶇О" prop="tjCompName" style="margin-left: 20px; margin-right: 500px"> + <el-form-item label="鍗曚綅鍚嶇О" prop="compName" style="margin-left: 20px; margin-right: 500px"> <el-select :remote-method="getRemoteData" v-model="queryParams.tjCompName" value-key="drugManufacturerId" style="width: 200px" remote filterable placeholder="璇烽�夋嫨鍗曚綅鍚嶇О" clearable @change="searchSelect"> <el-option v-for="dict in CompanyList" :key="dict.drugManufacturerId" :label="dict.cnName" :value="dict" /> </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" @@ -95,7 +95,7 @@ </template> </el-table-column> <el-table-column label="鎵嬫満鍙�" align="center" prop="cusPhone" width="120px" /> - <el-table-column label="鍗曚綅鍚嶇О" align="center" prop="firmName" width="120px" /> + <el-table-column label="鍗曚綅鍚嶇О" align="center" prop="compName" width="120px" /> <el-table-column label="鐢宠鏃堕棿" align="center" prop="applicationTime" width="210"> <template slot-scope="scope"> <span>{{ parseTime(scope.row.applicationTime) }}</span> @@ -249,7 +249,7 @@ piliangList: [], msg: "", getNumbr: null, - valueUrl: "ws://192.168.1.138:6789/websocket", + valueUrl: "ws://127.0.0.1:6789/websocket", webSocket: null, list: [], selectList: [], @@ -378,7 +378,7 @@ // 閫夋鏁版嵁 searchSelect(val) { this.CheckBox = val; - this.queryParams.dw = this.CheckBox.cnName; + this.queryParams.dw = this.CheckBox.drugManufacturerId; console.log(this.CheckBox, 9999); }, getRemoteData(query) { @@ -393,27 +393,60 @@ } }, async piliangPrint() { - for (const item of this.piliangList) { - try { - // 鑾峰彇鏁版嵁锛屽苟绛夊緟鏁版嵁鏇存柊瀹屾垚 - const tableList = await this.fetchData(item.tjNumber); + // 妫�鏌ユ槸鍚︽湁閫変腑鐨勬暟鎹� + if (this.piliangList.length === 0) { + this.$message.warning('璇峰厛閫夋嫨瑕佹墦鍗扮殑鏁版嵁'); + return; + } - // 鍙繚鐣欐渶鏂颁袱涓厓绱� - if (tableList.length > 0) { - this.selectList = tableList.slice(0, 2); - } else { - this.selectList = []; // 濡傛灉娌℃湁鏁版嵁锛屾竻绌簊electList + const loadingInstance = this.$loading({ + lock: true, + text: '鎵撳嵃涓�...', + spinner: 'el-icon-loading', + background: 'rgba(255, 255, 255, 0.7)' + }); + + try { + for (const item of this.piliangList) { + try { + // 鑾峰彇鏁版嵁锛屽苟绛夊緟鏁版嵁鏇存柊瀹屾垚 + const tableList = await this.fetchData(item.tjNumber); + + // 妫�鏌� tableList 鏄惁鏈夋暟鎹� + if (!tableList || tableList.length === 0) { + console.error(`浣撴鍙� ${item.tjNumber} 鏃犵浉鍏虫暟鎹甡); + continue; + } + + // 鐩存帴浣跨敤鎵�鏈夋暟鎹� + 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); + + // 绛夊緟涓�娈垫椂闂� + await new Promise(resolve => setTimeout(resolve, 5000)); + } catch (error) { + console.error(`澶勭悊浣撴鍙� ${item.tjNumber} 鏃跺嚭閿�:`, error); } - - // 浣跨敤鏇存柊鍚庣殑tableList鑾峰彇ids - let ids = this.selectList.map(row => row.id); - await this.Confirmreceipt1(ids); - - // 绛夊緟涓�娈垫椂闂� - await new Promise(resolve => setTimeout(resolve, 5000)); - } catch (error) { - console.error(`澶勭悊浣撴鍙� ${item.tjNumber} 鏃跺嚭閿�:`, error); } + } finally { + this.ids = []; // 娓呯┖ ids + this.selectList = []; // 娓呯┖ selectList + loadingInstance.close(); } }, getTruncatedName(proName) { @@ -615,11 +648,14 @@ 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 = []; @@ -627,13 +663,7 @@ } 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); -- Gitblit v1.8.0