From 00865e5de8d4bc31caa931de063b71acdbb26266 Mon Sep 17 00:00:00 2001 From: wwl <xchao828@163.com> Date: 星期六, 08 二月 2025 18:15:29 +0800 Subject: [PATCH] qx --- src/views/sampling/sampling/index.vue | 483 ++++++++++++++++++++++------------------------------ 1 files changed, 205 insertions(+), 278 deletions(-) diff --git a/src/views/sampling/sampling/index.vue b/src/views/sampling/sampling/index.vue index ab8a88c..4fc83f2 100644 --- a/src/views/sampling/sampling/index.vue +++ b/src/views/sampling/sampling/index.vue @@ -1,46 +1,24 @@ <template> <div class="app-container"> - <el-form - :model="queryParams" - ref="queryForm" - size="small" - :inline="true" - v-show="showSearch" - label-width="68px" - > + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form-item label="浣撴鍙�" prop="tjNumber"> - <el-input - ref="inputName" - v-model="queryParams.tjNumber" - placeholder="璇疯緭鍏ヤ綋妫�鍙�" - clearable - @keyup.enter.native="handleQuery" - @blur="hb" - style="width: 170px" - /> + <el-input ref="inputName" v-model="queryParams.tjNumber" placeholder="璇疯緭鍏ヤ綋妫�鍙�" clearable + @keyup.enter.native="handleQuery" @blur="hb" style="width: 170px" /> </el-form-item> <el-form-item label="濮撳悕" prop="name"> - <el-input - v-model="queryParams.name" - placeholder="璇疯緭鍏ュ鍚�" - clearable - @keyup.enter.native="handleQuery" - style="width: 110px" - /> + <el-input v-model="queryParams.name" placeholder="璇疯緭鍏ュ鍚�" clearable @keyup.enter.native="handleQuery" + style="width: 110px" /> </el-form-item> <el-form-item label="鐢宠鏃堕棿" prop="applicationTime"> - <el-date-picker - v-model="createTimeList" - @change="dateChangebirthday1" - :default-time="['00:00:00', '23:00:00']" - 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-date-picker v-model="createTimeList" @change="dateChangebirthday1" :default-time="['00:00:00', '23:00:00']" + 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-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="鏄惁閲囨牱"> @@ -60,13 +38,7 @@ <el-input v-model="queryParams.proName" placeholder="璇疯緭鍏ラ」鐩悕绉�" clearable @keyup.enter.native="handleQuery" style="width: 140px;"/> </el-form-item> --> <el-form-item> - <el-button - type="primary" - icon="el-icon-search" - size="mini" - @click="handleQuery" - >鏌ヨ</el-button - > + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鏌ヨ</el-button> <!-- <el-button type="primary" icon="el-icon-thumb" @@ -74,31 +46,17 @@ @click="Confirmreceipt" >纭閲囨牱</el-button > --> - <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" - >閲嶇疆</el-button - > + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button> </el-form-item> </el-form> <el-row :gutter="10" class="mb8"> <el-col :span="10"> - <el-radio-group - v-model="tjStatus" - @input="radioChange" - style="margin: 10px 15px" - > - <el-radio-button label="1" :disabled="qiehuan && disabledId === 0" - >鏈噰鏍�</el-radio-button - > - <el-radio-button label="0" :disabled="qiehuan && disabledId === 1" - >宸查噰鏍�</el-radio-button - > + <el-radio-group v-model="tjStatus" @input="radioChange" style="margin: 10px 15px"> + <el-radio-button label="1" :disabled="qiehuan && disabledId === 0">鏈噰鏍�</el-radio-button> + <el-radio-button label="0" :disabled="qiehuan && disabledId === 1">宸查噰鏍�</el-radio-button> </el-radio-group> </el-col> - <el-col - :span="12" - style="margin: 10px 15px" - v-if="samplingList.length > 0 && tjStatus == 1" - > + <el-col :span="12" style="margin: 10px 15px" v-if="samplingList.length > 0 && tjStatus == 1"> <el-button type="primary" @click="Merging">鍚堝苟椤圭洰</el-button> <!-- <el-button type="primary" @@ -108,62 +66,25 @@ @click="Confirmreceipt" >纭閲囨牱</el-button > --> - <el-button type="primary" :disabled="!disabled" @click="Cancellation" - >鎾ら攢鍚堝苟</el-button - > - <el-button - type="primary" - @click="Confirmreceipt" - :disabled="!selectList.length" - >閲囨牱鎵撶爜</el-button - > + <el-button type="primary" :disabled="!disabled" @click="Cancellation">鎾ら攢鍚堝苟</el-button> + <el-button type="primary" @click="Confirmreceipt" :disabled="!selectList.length">閲囨牱鎵撶爜</el-button> + <el-button type="primary" @click="piliangPrint" :disabled="!isAllSelected">鎵归噺鎵撳嵃</el-button> </el-col> - <el-col - :span="12" - style="margin: 10px 15px" - v-show="samplingList.length > 0 && tjStatus == 0" - > - <el-button type="primary" :disabled="!selectList.length" @click="buda" - >琛ユ墦鏉$爜</el-button - > + <el-col :span="12" style="margin: 10px 15px" v-show="samplingList.length > 0 && tjStatus == 0"> + <el-button type="primary" :disabled="!selectList.length" @click="buda">琛ユ墦鏉$爜</el-button> <!-- @click="Collection" --> - <el-button type="primary" :disabled="!disabled" @click="Cancellation" - >鎾ら攢鍚堝苟</el-button - > + <el-button type="primary" :disabled="!disabled" @click="Cancellation">鎾ら攢鍚堝苟</el-button> </el-col> </el-row> <div style="width: 100%; margin-left: 10px; display: flex"> <div style="width: 40%; margin-right: 20px"> - <el-table - id="ta" - v-loading="loading1" - ref="tb" - :data="samplingList" - @selection-change="handleSelectionChange" - border - height="520px" - :row-class-name="tableRowClassName" - > - <el-table-column type="selection" width="40" align="center" /> - <el-table-column - label="浣撴鍙�" - align="center" - prop="tjNumber" - width="160px" - /> - <el-table-column - label="濮撳悕" - align="center" - prop="cusName" - width="80px" - /> - <el-table-column - label="鎬у埆" - align="center" - prop="cusSex" - width="60px" - > + <el-table id="ta" v-loading="loading1" ref="tb" :data="samplingList" @selection-change="handleSelectionChange" + border height="520px" :row-class-name="tableRowClassName"> + <el-table-column type="selection" width="40" align="center" :selectable="selectable" /> + <el-table-column label="浣撴鍙�" align="center" prop="tjNumber" width="160px" /> + <el-table-column label="濮撳悕" align="center" prop="cusName" width="80px" /> + <el-table-column label="鎬у埆" align="center" prop="cusSex" width="60px"> <!-- <template slot-scope="scope"> {{ scope.row.customer.cusSex === 0 ? "鐢�" : "濂�" }} </template> --> @@ -173,18 +94,9 @@ <span v-if="scope.row.cusSex == '2'">鏈煡</span> </template> </el-table-column> - <el-table-column - label="鎵嬫満鍙�" - align="center" - prop="cusPhone" - width="120px" - /> - <el-table-column - label="鐢宠鏃堕棿" - align="center" - prop="applicationTime" - width="210" - > + <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="applicationTime" width="210"> <template slot-scope="scope"> <span>{{ parseTime(scope.row.applicationTime) }}</span> </template> @@ -193,16 +105,8 @@ </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 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" /> --> @@ -211,20 +115,9 @@ <span>{{ parseTime(scope.row.tjTime, '{y}-{m}-{d}') }}</span> </template> </el-table-column> --> - <el-table-column - label="鏍囨湰绫诲瀷" - align="center" - prop="specimenType" - width="120" - > + <el-table-column label="鏍囨湰绫诲瀷" align="center" prop="specimenType" width="120"> </el-table-column> - <el-table-column - label="閲囨牱缂栧彿" - align="center" - prop="jyxh" - :show-overflow-tooltip="true" - width="120" - /> + <el-table-column label="閲囨牱缂栧彿" align="center" prop="jyxh" :show-overflow-tooltip="true" width="120" /> <el-table-column label="椤圭洰鍚嶇О" align="center" prop="proName" /> <!-- <el-table-column label="鎬у埆" @@ -232,16 +125,9 @@ prop="proSex" width="90" /> --> - <el-table-column - label="鏄惁鍚堝苟" - align="center" - prop="isMerge" - width="90" - > + <el-table-column label="鏄惁鍚堝苟" align="center" prop="isMerge" width="90"> <template slot-scope="scope"> - <span - :style="{ color: scope.row.isMerge === 0 ? '' : '#409EFF' }" - > + <span :style="{ color: scope.row.isMerge === 0 ? '' : '#409EFF' }"> {{ scope.row.isMerge === 0 ? "鏈悎骞�" : "宸插悎骞�" }} </span> </template> @@ -315,13 +201,8 @@ <!-- <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> --> - <pagination - v-show="total > 0" - :total="total" - :page.sync="queryParams.pageNum" - :limit.sync="queryParams.pageSize" - @pagination="getList" - /> + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" + @pagination="getList" /> </div> @@ -345,7 +226,12 @@ } from "@/api/sampling/sampling"; import { getNewDateList } from "@/api/hosp/order"; import moment from "moment"; - +import { + SubmitCompany, + getCompany, + queryCompany, + addbatch, +} from "@/api/team/tuanti"; export default { dicts: [ "sys_user_sex", @@ -357,9 +243,13 @@ name: "Sampling", data() { return { + CheckBox: {}, + + CompanyList: [], + piliangList: [], msg: "", getNumbr: null, - valueUrl: "ws://127.0.0.1:6789/websocket", + valueUrl: "ws://192.168.1.138:6789/websocket", webSocket: null, list: [], selectList: [], @@ -444,6 +334,8 @@ // 琛ㄥ崟鏍¢獙 rules: {}, // rightTabShow: false + allSelected: false, + disableSelections: false, // 鎺у埗閫夋嫨绂佺敤鐘舵�� }; }, created() { @@ -451,6 +343,11 @@ getTxmmccd().then((res) => { this.msg = Number(res.msg); console.log(res, 444); + }); + getCompany(this.queryParams).then((response) => { + this.CompanyList = response.data; + + this.loading = false; }); this.getdate(); }, @@ -472,9 +369,53 @@ disabledId() { return this.tjStatus == "1" ? 1 : 0; }, + isAllSelected() { + return this.samplingList.length > 0 && this.selectedRows.length === this.samplingList.length; + }, }, methods: { + // 閫夋鏁版嵁 + searchSelect(val) { + this.CheckBox = val; + this.queryParams.dw = this.CheckBox.cnName; + console.log(this.CheckBox, 9999); + }, + getRemoteData(query) { + if (query) { + let compName = query; + queryCompany(compName).then((response) => { + this.CompanyList = response.data; + this.CompanyList.forEach((item) => { + this.queryParams = item; + }); + }); + } + }, + async piliangPrint() { + for (const item of this.piliangList) { + try { + // 鑾峰彇鏁版嵁锛屽苟绛夊緟鏁版嵁鏇存柊瀹屾垚 + const tableList = await this.fetchData(item.tjNumber); + + // 鍙繚鐣欐渶鏂颁袱涓厓绱� + if (tableList.length > 0) { + this.selectList = tableList.slice(0, 2); + } else { + this.selectList = []; // 濡傛灉娌℃湁鏁版嵁锛屾竻绌簊electList + } + + // 浣跨敤鏇存柊鍚庣殑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); + } + } + }, getTruncatedName(proName) { // 鍘绘帀鎵�鏈夌┖鏍� const trimmedProName = proName.replace(/\s+/g, ""); @@ -559,6 +500,7 @@ }, /** 鏌ヨ浣撴閲囨牱绠$悊鍒楄〃 */ getList() { + this.queryParams.compId = this.CheckBox.drugManufacturerId; this.loading1 = true; this.queryParams.isSignFor = this.tjStatus; @@ -580,13 +522,15 @@ return; } else { this.samplingList = response.data.list; - // console.log(this.samplingList, 888); // 鍒ゆ柇鏄惁闇�瑕佸埛鏂板彸杈硅〃鏍� this.$nextTick(() => { this.$refs.tb.toggleRowSelection(this.samplingList[0], true); - // this.fetchData(this.samplingList[0].tjNumber); - // ddddddddddddddd - // this.rightTabShow = true + // 妫�鏌ユ槸鍚﹀叏閫� + if (this.samplingList.length === this.selectedRows.length) { + this.disableSelections = true; + } else { + this.disableSelections = false; + } }); } this.total = response.data.total; @@ -665,76 +609,74 @@ this.createTimeList = []; this.handleQuery(); }, - // 鍗曢�夋閫変腑鏁版嵁 - /* handleSelectionChange(selection) { - this.selectList = selection; - selection.forEach((element) => { - this.tableList = element.list; - console.log(this.tableList, 111); - - if (this.tableList.length != 0) { - this.$nextTick(() => { - this.$refs.tab1.toggleAllSelection(this.tableList, true); - }); - } else { - this.$refs.tab1.clearSelection(); - } - }); - // this.ids = selection.map(item => item.id) - if (selection.length > 1) { - let del_row = selection.shift(); - this.$refs.tb.toggleRowSelection(del_row, false); //璁剧疆杩欎竴琛屽彇娑堥�変腑 - } - this.single = selection.length !== 1; - this.multiple = !selection.length; - }, */ handleSelectionChange(selection) { - // 娓呯┖鍙充晶琛ㄦ牸鐨勬暟鎹� - this.tableList = []; + this.piliangList = selection; + const selectedCount = selection.length; + const totalCount = this.samplingList.length; - // 鍙湁涓�涓汉琚�変腑鏃惰繘琛屾搷浣� - if (selection.length === 1) { - const selectedPerson = selection[0]; // 鑾峰彇閫変腑鐨勯偅涓汉 - const tjNumber = selectedPerson.tjNumber; - console.log(selectedPerson.tjNumber, 6363); + // 濡傛灉鍙湁涓�鏉℃暟鎹紝涓嶈绂佺敤閫夋嫨 + if (selectedCount === 1 && totalCount === 1) { + this.disableSelections = false; - this.fetchData(tjNumber); + } else if (selectedCount === totalCount && selectedCount > 0) { + // 鍏ㄩ�夋椂绂佺敤閫夋嫨鏂拌 + this.disableSelections = true; + this.tableList = []; + this.$message.info('宸插叏閫夋墍鏈夎'); } else { - // 濡傛灉閫変腑澶氫汉锛屽垯鍙栨秷閫変腑 - if (selection.length > 1) { + // 闈炲叏閫夋椂鍚敤閫夋嫨 + this.disableSelections = false; + + if (selectedCount === 1) { + const selectedPerson = selection[0]; + const tjNumber = selectedPerson.tjNumber; + console.log(`閫変腑鐨勪綋妫�鍙�: ${tjNumber}`); + this.fetchData(tjNumber); + } else if (selectedCount > 1) { + // 淇濈暀鍗曢�夊姛鑳斤紝鍙栨秷澶氶�� let del_row = selection.shift(); - this.$refs.tb.toggleRowSelection(del_row, false); // 璁剧疆杩欎竴琛屽彇娑堥�変腑 + this.$refs.tb.toggleRowSelection(del_row, false); } } - // 鏇存柊閫夋嫨鐘舵�� - this.single = selection.length === 1; - this.multiple = selection.length === 0; + if (selectedCount === 0) { + this.tableList = []; + } + // 鏇存柊鍗曢�夊拰澶氶�夌姸鎬� + this.single = selectedCount === 1; + this.multiple = selectedCount === 0; + + // 鏇存柊閫変腑鐨勮 this.selectedRows = selection; + + // 璋冭瘯鏃ュ織 + console.log(`褰撳墠閫変腑鏁伴噺: ${selectedCount}`); + console.log(`鏄惁绂佺敤閫夋嫨: ${this.disableSelections}`); }, fetchData(tjNumber) { - this.loading = true; // 鏄剧ず鍔犺浇鐘舵�� - - getCusCyList(tjNumber, this.tjStatus) // 璋冪敤API鑾峰彇鏁版嵁 - .then((response) => { - if (response.data) { - console.log(response, 2525); - - this.tableList = response.data; // 纭 list 瀛樺湪鍚庡啀杩涜璧嬪�� - } else { - // 濡傛灉娌℃湁鏁版嵁鎴� list 涓虹┖锛屾竻绌鸿〃鏍煎苟鎻愮ず - this.tableList = []; - } - }) - .catch((error) => { - console.error("Error fetching data:", error); - }) - .finally(() => { - this.loading = false; // 闅愯棌鍔犺浇鐘舵�� - }); + return new Promise((resolve, reject) => { + this.loading = true; + getCusCyList(tjNumber, this.tjStatus) + .then((response) => { + if (response.data) { + this.tableList = response.data; + resolve(this.tableList); + } else { + this.tableList = []; + resolve([]); + } + }) + .catch((error) => { + console.error("Error fetching data:", error); + reject(error); + }) + .finally(() => { + this.loading = false; + }); + }); }, /* 鐐瑰嚮鍚堝苟鎸夐挳 */ @@ -949,7 +891,6 @@ this.selectList = selection; console.log(this.selectList, 9977); var array = selection; - this.ids = array.map((item) => item.id); }, buda() { @@ -977,8 +918,6 @@ cardId: item.cardId, tjTime: item.createTime, })); - console.log(this.dayinData, 2222); - // 杩炴帴璁惧 this.jsonObj = { type: "3", @@ -993,7 +932,6 @@ }; // this.getList(); }, - // 纭閲囨牱 Confirmreceipt() { const loadingInstance = this.$loading({ @@ -1007,66 +945,34 @@ console.log(this.selectList, 2222); if (res.code === 200) { - // var websocket = null; this.buda(); - - /* var url = this.valueUrl; - if ("WebSocket" in window) { - websocket = new WebSocket(url); - } else if ("MozWebSocket" in window) { - websocket = new MozWebSocket(url); - } - if (websocket == null) { - alert("鍒涘缓WebSocket瀵硅薄澶辫触"); - } - websocket.onerror = function () { - alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父"); - }; - websocket.onopen = () => { - this.websocket = websocket; - var list = this.selectList; - var data = list.map((item) => ({ - jyxh: item.jyxh, - proName: item.proName, - cusName: item.cusName, - cusSex: item.customer.cusSex, - age: item.customer.age, - cardId: item.cardId, - tjTime: item.createTime, - })); - - // 杩炴帴璁惧 - var jsonObj = { - type: "3", - array: { - data: data, - }, - }; - var jStr = JSON.stringify(jsonObj); - this.websocket.send(jStr); - var jsonObj = {}; - this.dialogVisible = false; - }; - websocket.onmessage = (event) => { - var resultObj = eval("(" + event.data + ")"); - console.log(resultObj, 9988); - }; */ - - // this.Collection(); this.getList(); } else { this.$message.error(res.msg); } - // this.getList(); }) .catch((error) => { - // this.$message.error("閲囨牱澶辫触"); }) .finally(() => { loadingInstance.close(); }); }, - + Confirmreceipt1(ids) { + confirmSampling(ids) + .then((res) => { + if (res.code === 200) { + this.buda(); + this.getList(); + } else { + this.$message.error(res.msg); + } + }) + .catch((error) => { + }) + .finally(() => { + loadingInstance.close(); + }); + }, // 鍗曢�夋寜閽� radioChange(value) { this.loading = true; @@ -1120,14 +1026,35 @@ }, // 瀵煎嚭 - handleExport() {}, + handleExport() { }, + + /** 鎺у埗琛屾槸鍚﹀彲閫� */ + selectable(row, index) { + if (this.disableSelections) { + // 浠呭厑璁稿彇娑堝凡閫変腑鐨勮 + return this.selectedRows.some(selectedRow => selectedRow.id === row.id); + } + return true; // 鍏佽閫夋嫨鎵�鏈夎 + }, + + resetSelection() { + this.$refs.tb.clearSelection(); + this.disableSelections = false; + this.selectedRows = []; + this.single = false; + this.multiple = true; + this.tableList = []; + + // 璋冭瘯鏃ュ織 + console.log(`閲嶇疆閫夋嫨锛屾槸鍚︾鐢ㄩ�夋嫨: ${this.disableSelections}`); + }, }, }; </script> <style> #ta .el-table__header-wrapper .el-checkbox { - display: none; + /* display: none; */ } .el-table .warning-row { -- Gitblit v1.8.0