From a33907b698d54eda47449f912070f482a6ae066f Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期五, 26 九月 2025 15:37:59 +0800
Subject: [PATCH] 原材料订单拆分功能调整v2
---
src/views/business/inspectionTask/inspection.vue | 247 ++++++++++++++++++++++++++++--------------------
1 files changed, 144 insertions(+), 103 deletions(-)
diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue
index f26bb54..40ff3d9 100644
--- a/src/views/business/inspectionTask/inspection.vue
+++ b/src/views/business/inspectionTask/inspection.vue
@@ -141,7 +141,7 @@
<el-button :loading="dataAcquisitionLoading" v-if="state == 1" size="small" type="primary"
@click="getDataAcquisitionDevice">鏁版嵁閲囬泦</el-button>
<el-button :type="dataAcquisitionEidtAble ? '' : 'primary'" v-if="state == 1" size="small"
- @click="dataAcquisitionEidtAble = !dataAcquisitionEidtAble">{{ dataAcquisitionEidtAble ? "鍏抽棴缂栬緫" : "缂栬緫鏁伴噰"
+ @click="dataAcquisitionEidtAble = !dataAcquisitionEidtAble,disconnect()">{{ dataAcquisitionEidtAble ? "鍏抽棴缂栬緫" : "缂栬緫鏁伴噰"
}}</el-button>
</div>
</div>
@@ -406,24 +406,24 @@
<el-button :loading="submitLoading" type="primary" @click="submit()">纭� 瀹�</el-button>
</span>
</el-dialog>
- <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"
- :visible.sync="dataGetDia" title="鏁版嵁閲囬泦" width="80%">
- <div>
- <table border="1" cellpadding="10" class="thermal-table">
- <tr>
- <td style="width: 120px">妫�楠岄」鍒嗙被</td>
- <td style="width: 120px">妫�楠岄」</td>
- <td style="width: 120px">妫�楠屽瓙椤�</td>
- <td>鏁伴噰鏁版嵁</td>
- </tr>
- <template v-for="(item, index) in getData">
+ <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"
+ :visible.sync="dataGetDia" title="鏁版嵁閲囬泦" width="80%">
+ <div>
+ <table border="1" cellpadding="10" class="thermal-table">
<tr>
- <td :rowspan="item.child.length">{{ item.sortName }}</td>
- <td :rowspan="item.child.length">{{ item.faName }}</td>
- <td>{{ item.child[0].name }}</td>
- <td style="text-align: left">
- <!-- 娣诲姞瀹瑰櫒 div -->
- <div class="data-collection-items">
+ <td style="width: 120px">妫�楠岄」鍒嗙被</td>
+ <td style="width: 120px">妫�楠岄」</td>
+ <td style="width: 120px">妫�楠屽瓙椤�</td>
+ <td>鏁伴噰鏁版嵁</td>
+ </tr>
+ <template v-for="(item, index) in getData">
+ <tr>
+ <td :rowspan="item.child.length">{{ item.sortName }}</td>
+ <td :rowspan="item.child.length">{{ item.faName }}</td>
+ <td>{{ item.child[0].name }}</td>
+ <td style="text-align: left">
+ <!-- 娣诲姞瀹瑰櫒 div -->
+ <div class="data-collection-items">
<el-select v-if="item.child[0].isShowSelect" v-model="item.child[0].getDataIndex1"
:multiple-limit="item.child[0].maxNum" clearable filterable multiple placeholder="璇烽�夋嫨"
@change="setData(item)">
@@ -447,7 +447,7 @@
<el-checkbox-group v-if="!item.child[0].isShowSelect" v-model="item.child[0].getDataIndex1"
:max="item.child[0].maxNum">
<el-checkbox v-for="(n, j) in item.child[0].arr" :key="index + '-' + j + 'aaaaaa'" :label="j + '^' + n"
- @change="handleGroupSelect(item.child[0], j)" >{{ n }}</el-checkbox>
+ @change="handleGroupSelect(item.child[0], j, item.child[0].arr.length)" >{{ n }}</el-checkbox>
</el-checkbox-group>
</div>
</td>
@@ -478,7 +478,7 @@
</el-select>
<el-checkbox-group v-if="!m.isShowSelect" v-model="m.getDataIndex1" :max="m.maxNum">
<el-checkbox v-for="(n, j) in m.arr" :key="index + '-' + j + 'dddddddd'" :label="j + '^' + n"
- @change="handleGroupSelect(m, j)" >{{ n }}</el-checkbox>
+ @change="handleGroupSelect(m, j, m.arr.length)" >{{ n }}</el-checkbox>
</el-checkbox-group>
</div>
</td>
@@ -536,6 +536,8 @@
import AddUnPass from "../unpass/components/addUnPass.vue";
import InspectionWord from "./components/InspectionWord.vue";
import PurchaseVerification from "../unpass/components/PurchaseVerification.vue";
+
+
import {
doInsOrder,
getCableTag,
@@ -559,6 +561,7 @@
import DataWorker from '@/workers/DataWorker.worker.js';
import html2canvas from "html2canvas";
import { mapGetters } from "vuex";
+import { connect,disconnect,weightList } from "@/utils/connect.js";
import viewManHourDia from "@/views/business/inspectionTask/components/viewManHourDia.vue";
export default {
name: 'Inspection',
@@ -596,6 +599,8 @@
sampleName: null,
state: null,
},
+ isSerialConnected: false, // 鏂板鐘舵�佸彉閲忥紝涓插彛杩炴帴鐘舵��
+ serialPort: null, // 瀛樺偍涓插彛瀵硅薄
id: null,
changeType: null,
insOrder: {},
@@ -661,18 +666,10 @@
{
name: "1285nm~1330nm",
arr: [12, 13, 14, 15],
- // 鍒濆鍖� getDataIndex1 涓烘暟缁�
- getDataIndex1: [],
- isShowSelect: false,
- maxNum: 5
},
{
name: "1525nm~1575nm",
arr: [12, 13, 14, 15],
- // 鍒濆鍖� getDataIndex1 涓烘暟缁�
- getDataIndex1: [],
- isShowSelect: false,
- maxNum: 5
},
],
},
@@ -682,10 +679,6 @@
{
name: "鎴嚦娉㈤暱",
arr: [12, 13, 14, 15],
- // 鍒濆鍖� getDataIndex1 涓烘暟缁�
- getDataIndex1: [],
- isShowSelect: false,
- maxNum: 5
},
],
},
@@ -756,7 +749,6 @@
size: 10,
current: 0,
},
- tableLoading: false,
// 鏂囦欢鍒楄〃鐩稿叧--缁撴潫
// 浠诲姟鍒囨崲鍒楄〃--寮�濮�
tableData0: [],
@@ -791,6 +783,7 @@
},
tableLoading0: false,
// 浠诲姟鍒囨崲鍒楄〃--缁撴潫
+ isSplit: 0, // 鏄惁鏄媶鍗曡繃鏉ョ殑
};
},
// 鐢ㄤ簬涓婁紶鏂囦欢鐨勪俊鎭�
@@ -801,7 +794,7 @@
},
},
created() {
- let { sonLaboratory, orderId, state, inspectorList, typeSource } =
+ let { sonLaboratory, orderId, state, inspectorList, typeSource,isSplit } =
this.$route.query;
this.sonLaboratory = sonLaboratory;
this.orderId = orderId;
@@ -809,6 +802,7 @@
this.state = state;
this.inspectorList = inspectorList;
this.typeSource = typeSource;
+ this.isSplit = isSplit;
},
mounted() {
this.getTypeDicts(); // 鑾峰彇绱ф�ョ▼搴︿笅鎷夋閫夐」
@@ -897,8 +891,16 @@
beforeDestroy() {
// 鍦ㄧ粍浠堕攢姣佸墠纭繚鍋滄 Worker锛岄伩鍏嶅唴瀛樻硠婕�
this.stopWorker();
+ disconnect();
+ // 璋冪敤鍓嶅厛鍒ゆ柇鏂规硶鏄惁瀛樺湪锛岄伩鍏嶆姤閿�
+ if (this.closeSerialPort) {
+ this.closeSerialPort();// 缁勪欢閿�姣佸墠鍏抽棴涓插彛
+ }
},
methods: {
+ sss() {
+ console.log(this.$store.state.weightList) //
+ },
// 鏂囦欢绠$悊--寮�濮�
getList() {
this.tableLoading = true;
@@ -934,14 +936,19 @@
}).catch(() => { });
},
// 鏂囦欢绠$悊--缁撴潫
- // 澶勭悊鏁寸粍鍕鹃�夐�昏緫鐨勬柟娉�
- handleGroupSelect(childItem, clickedIndex) {
+ // 澶勭悊鏁寸粍鍕鹃�夐�昏緫鐨勬柟娉�
+ handleGroupSelect(childItem, clickedIndex, groupSize = 5) {
+ if(groupSize == 6){
+ groupSize = 6;
+ }else{
+ groupSize = 5;
+ }
// 璁$畻鎵�鍦ㄧ粍鐨勮捣濮嬬储寮�
- const groupStartIndex = Math.floor(clickedIndex / 5) * 5;
+ const groupStartIndex = Math.floor(clickedIndex / groupSize) * groupSize;
// 娓呯┖褰撳墠宸查��
childItem.getDataIndex1 = [];
- // 閬嶅巻褰撳墠缁勭殑 5 涓厓绱狅紝娣诲姞鍒伴�変腑鍒楄〃
- for (let i = groupStartIndex; i < groupStartIndex + 5 && i < childItem.arr.length; i++) {
+ // 閬嶅巻褰撳墠缁勭殑 groupSize 涓厓绱狅紝娣诲姞鍒伴�変腑鍒楄〃
+ for (let i = groupStartIndex; i < groupStartIndex + groupSize && i < childItem.arr.length; i++) {
childItem.getDataIndex1.push(i + '^' + childItem.arr[i]);
}
},
@@ -1126,31 +1133,59 @@
this.$refs.purchaseDialog.$refs["purchaseForm"].resetFields();
this.purchaseDialog = false;
},
+
// 鏁版嵁閲囬泦
- getDataAcquisitionDevice() {
- let itemIds = [];
- this.currentSample.insProduct.forEach((item) => {
- if (item.inspectionItemType === "1") {
- itemIds.push(item.id);
+
+ getDataAcquisitionDevice() {
+ (async () => {
+ try {
+ // 妫�鏌ラ〉闈腑妫�娴嬮」鏄惁鍖呭惈瀵嗗害
+ const hasDensityItem = this.currentSample.insProduct.some(item => {
+ // 鍋囪瀵嗗害鐩稿叧鐨勬娴嬮」鍚嶇О鍖呭惈 "瀵嗗害" 鍏抽敭瀛楋紝鍙寜闇�淇敼
+ return item.inspectionItem && item.inspectionItem.includes('瀵嗗害');
+ });
+ if (hasDensityItem) {
+ // 妫�鏌ユ槸鍚︽敮鎸� Web Serial API
+ if ('serial' in navigator) {
+ // 璇锋眰鍙敤涓插彛
+ const ports = await navigator.serial.getPorts();
+ if (ports.length > 0) {
+ await connect();
+ } else {
+ console.log('娌℃湁鍙敤鐨勪覆鍙�');
+ }
+ } else {
+ console.log('褰撳墠娴忚鍣ㄤ笉鏀寔 Web Serial API');
+ }
+ }
+ } catch (error) {
+ console.error('妫�娴嬩覆鍙f椂鍑洪敊:', error);
}
- });
- const params = {
- entrustCode: this.insOrder.entrustCode,
- sampleCode: this.currentSample.sampleCode,
- id: this.currentSample.id,
- itemIds: itemIds,
- };
- this.dataAcquisitionLoading = true;
- dataCollection(params).then((res) => {
- this.dataAcquisitionLoading = false;
- if (res.code != 200) {
- return;
- }
- this.dataAcquisitionInfoNew = this.HaveJson(res.data);
- // 瀵规暟閲囧洖鏉ョ殑鍊艰繘琛屽鐞�
- this.handleDataAcquisition(res.data);
- }).catch(err => {
- this.dataAcquisitionLoading = false;
+ })().then(() => {
+ let itemIds = [];
+ this.currentSample.insProduct.forEach((item) => {
+ if (item.inspectionItemType === "1") {
+ itemIds.push(item.id);
+ }
+ });
+ const params = {
+ entrustCode: this.insOrder.entrustCode,
+ sampleCode: this.currentSample.sampleCode,
+ id: this.currentSample.id,
+ itemIds: itemIds,
+ };
+ this.dataAcquisitionLoading = true;
+ dataCollection(params).then((res) => {
+ this.dataAcquisitionLoading = false;
+ if (res.code != 200) {
+ return;
+ }
+ this.dataAcquisitionInfoNew = this.HaveJson(res.data);
+ // 瀵规暟閲囧洖鏉ョ殑鍊艰繘琛屽鐞�
+ this.handleDataAcquisition(res.data);
+ }).catch(err => {
+ this.dataAcquisitionLoading = false;
+ });
});
},
objectOrder(obj) {
@@ -1281,7 +1316,6 @@
}
};
let list = this.tableList[0].arr;
- console.log(this.tableList[0]);
let maxNum = 0;
list.forEach((item, index) => {
let num0 = 0;
@@ -1386,7 +1420,6 @@
} else {
// 濡傛灉閮戒笉瀛樺湪锛屽垯锛岃繘鍏ュ鐞嗘暟閲囩嚎绋嬮噷鍘诲鐞嗘暟鎹�
try {
- console.log(this.dataAcquisitionInfo);
// 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
this.getDataIndexLoading = false;
this.dataGetDia = false;
@@ -2588,6 +2621,26 @@
openAddVerifyDia() {
this.addVerifyDia = true;
},
+ confirmSubmit(registerInsResults){
+ submitPlan({
+ orderId: this.orderId,
+ laboratory: this.sonLaboratory,
+ verifyUser: this.verifyUser,
+ entrustCode: this.insOrder.entrustCode,
+ registerInsResults: registerInsResults
+ }).then((res) => {
+ if (res.code === 200) {
+ this.$message.success("鎿嶄綔鎴愬姛");
+ this.goback();
+ this.submitLoading = false;
+ this.addVerifyDia = false;
+ }
+ })
+ .catch((error) => {
+ console.error(error);
+ this.submitLoading = false;
+ });
+ },
submit() {
if (this.verifyUser === null || this.verifyUser === "") {
this.$message.error("璇锋寚瀹氬鏍镐汉鍛�");
@@ -2606,39 +2659,39 @@
orderId: this.orderId,
laboratory: this.sonLaboratory,
}).then((res) => {
+ console.log(res)
if (res.code === 200) {
- if (!res.data || res.data.length == 0) {
+ if (!res.data || res.data.errorMsg.length == 0) {
this.submitLoading = true;
- submitPlan({
- orderId: this.orderId,
- laboratory: this.sonLaboratory,
- verifyUser: this.verifyUser,
- entrustCode: this.insOrder.entrustCode,
- }).then((res) => {
- if (res.code === 200) {
- this.$message.success("鎿嶄綔鎴愬姛");
- this.goback();
- this.submitLoading = false;
- this.addVerifyDia = false;
- }
- })
- .catch((error) => {
- console.error(error);
- this.submitLoading = false;
+ //妫�楠岀被鍨嬩负鍘熸潗鏂�
+ if(this.typeSource==1 && res.data.unInsOrderCount==0 && this.isSplit==1){
+ const htmlStr = "鏄惁鐧昏IFS閲囪喘妫�楠岀粨鏋滃苟绉诲簱锛熻鎿嶄綔浼氱櫥璁�<span style='color:#ff4949'>鍚屼竴闆朵欢鍚屼竴璁㈠崟鐨勬墍鏈夋媶鍒嗘壒娆�</span>锛岃璋ㄦ厧閫夋嫨銆�"
+ this.$confirm(htmlStr, '鎻愮ず', {
+ confirmButtonText: '鏄�',
+ cancelButtonText: '鍚�',
+ type: 'warning',
+ dangerouslyUseHTMLString: true
+ }).then(() => {
+ this.confirmSubmit(true)
+ }).catch(() => {
+ this.confirmSubmit(false)
});
+ }else{
+ this.confirmSubmit(false)
+ }
} else {
let newData = [];
const h = this.$createElement;
- for (let i in res.data) {
- const lastChar = res.data[i].slice(-1);
+ for (let i in res.data.errorMsg) {
+ const lastChar = res.data.errorMsg[i].slice(-1);
if (lastChar == "-") {
- res.data[i] = res.data[i].slice(0, -1);
+ res.data.errorMsg[i] = res.data.errorMsg[i].slice(0, -1);
}
newData.push(
h(
"p",
{ style: "font-size: 14px;color: red;" },
- Number(i) + 1 + "銆�" + res.data[i]
+ Number(i) + 1 + "銆�" + res.data.errorMsg[i]
)
);
}
@@ -2661,22 +2714,7 @@
})
.then(() => {
this.submitLoading = true;
- submitPlan({
- orderId: this.orderId,
- laboratory: this.sonLaboratory,
- verifyUser: this.verifyUser,
- }).then((res) => {
- if (res.code === 200) {
- this.$message.success("鎿嶄綔鎴愬姛");
- this.addVerifyDia = false;
- this.goback();
- }
- this.submitLoading = false;
- })
- .catch((error) => {
- console.error(error);
- this.submitLoading = false;
- });
+ this.confirmSubmit(false)
})
.catch(() => { });
}
@@ -2913,6 +2951,9 @@
goback() {
this.$router.go(-1)
}
+ },
+ destroyed() {
+ disconnect()
},
};
</script>
@@ -3190,11 +3231,11 @@
.data-collection-items {
display: flex;
- flex-wrap: wrap;
+ flex-wrap: wrap;
}
.data-collection-items .el-select,
.data-collection-items .el-checkbox {
- flex-basis: 20% ;
+ flex-basis: 20% ;
box-sizing: border-box;
padding: 5px 2%;
}
--
Gitblit v1.9.3