|
@@ -126,9 +126,13 @@ import {
|
|
|
rejectInspection,
|
|
|
confirmInspection,
|
|
|
checkFurnace,
|
|
|
- checkMultiplyFurnace
|
|
|
+ checkMultiplyFurnace,
|
|
|
+ exportAsync
|
|
|
} from "@/api/business/beforeCheckoutVerify";
|
|
|
+
|
|
|
import { nextTick } from "vue";
|
|
|
+import { getToken } from '@/utils/auth'
|
|
|
+import useUserStore from '@/store/modules/user'
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
/** 字典数组区 */
|
|
|
const { outsource_before_checkout_verify_status } = proxy.useDict(
|
|
@@ -148,6 +152,11 @@ const total = ref(0);
|
|
|
const selections = ref([])
|
|
|
const printCarriers = ref([]);
|
|
|
const confirmLoading = ref(false)
|
|
|
+const exportSuccess = ref(false)
|
|
|
+const doingExport = ref(false)
|
|
|
+const wsUrl = 'ws://localhost:8081/wsExport/'
|
|
|
+let ws = null
|
|
|
+
|
|
|
const webHost = import.meta.env.VITE_APP_PRODUCTION_API;
|
|
|
/** 查询对象 */
|
|
|
const queryParams = ref({
|
|
@@ -170,7 +179,6 @@ const queryParams = ref({
|
|
|
/** 查询外协单主 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子列表 */
|
|
|
function getList() {
|
|
|
loading.value = true;
|
|
|
-
|
|
|
listCheckoutInspection(queryParams.value).then((response) => {
|
|
|
orderList.value = response.rows;
|
|
|
total.value = response.total;
|
|
@@ -204,12 +212,12 @@ function handlePass() {
|
|
|
})
|
|
|
.then(() => {
|
|
|
confirmInspection(res.data).then((res) => {
|
|
|
- getList();
|
|
|
+ getList()
|
|
|
confirmLoading.value = false
|
|
|
}).catch(e => {
|
|
|
confirmLoading.value = false
|
|
|
- });
|
|
|
- });
|
|
|
+ })
|
|
|
+ })
|
|
|
} else {
|
|
|
proxy
|
|
|
.$confirm("该炉已全部质检,是否全部确认通过?", "提示", {
|
|
@@ -229,7 +237,7 @@ function handlePass() {
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
- proxy.$msgError(res.msg);
|
|
|
+ proxy.$msgError(res.msg)
|
|
|
confirmLoading.value = false
|
|
|
}
|
|
|
}).catch(e => {
|
|
@@ -331,9 +339,110 @@ function handleReject(row) {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+/** 异步导出excel */
|
|
|
+async function exportForYear() {
|
|
|
+ if (ws == null) {
|
|
|
+ // 启动一个websocket
|
|
|
+ console.log(useUserStore().user.userId)
|
|
|
+ await createWebSocket(useUserStore().user.userId, getToken())
|
|
|
+ initWebsocket()
|
|
|
+ } else {
|
|
|
+ initWebsocket()
|
|
|
+ }
|
|
|
+ // 发送请求要求导出excel
|
|
|
+ exportAsync(queryParams.value).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ doingExport.value = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
-function exportForYear(row) {
|
|
|
+async function createWebSocket(id, token) {
|
|
|
+ try {
|
|
|
+ // const options = { headers: { Authorization: 'Bearer ' + token } }
|
|
|
+ // console.log(options)
|
|
|
+ ws = new WebSocket(wsUrl + id, [token])
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ reconnection()
|
|
|
+ }
|
|
|
+}
|
|
|
+let lockReconnect = false
|
|
|
+let timerReconnect = undefined
|
|
|
+let timerHeart = undefined
|
|
|
+let timerServerHeart = undefined
|
|
|
+const heartTimeOut = 40000
|
|
|
+let handClose = false
|
|
|
+function reconnection() {
|
|
|
+ console.log("重新连接")
|
|
|
+ if (lockReconnect) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ lockReconnect = true
|
|
|
+ if (timerReconnect) {
|
|
|
+ clearTimer(timerReconnect)
|
|
|
+ }
|
|
|
+ //没连上会一直重连, 设置迟延,避免请求过多
|
|
|
+ timerReconnect = setTimeout(() => {
|
|
|
+ //setTimeout 到点了执行
|
|
|
+ connection(useUserStore().user.userId, getToken())
|
|
|
+ lockReconnect = false
|
|
|
+ }, 5000);
|
|
|
+}
|
|
|
+
|
|
|
+async function connection(id, token) {
|
|
|
+ await createWebSocket(id, token)
|
|
|
+}
|
|
|
+
|
|
|
+function clearTimer() {
|
|
|
+ timerReconnect && clearTimeout(timerReconnect)
|
|
|
+ timerHeart && clearTimeout(timerHeart)
|
|
|
+ timerServerHeart && clearTimeout(timerServerHeart)
|
|
|
+}
|
|
|
+
|
|
|
+function initWebsocket() {
|
|
|
+ ws.onopen = (e) => {
|
|
|
+ ws.send("open server")
|
|
|
+ console.log("链接成功")
|
|
|
+ heartCheck()
|
|
|
+ }
|
|
|
+ ws.onmessage = (message) => {
|
|
|
+ console.log(message)
|
|
|
+ heartCheck()
|
|
|
+ }
|
|
|
+ ws.onerror = (e) => {
|
|
|
+ console.log('链接失败')
|
|
|
+ reconnection()
|
|
|
+ }
|
|
|
+ ws.onclose = (e) => {
|
|
|
+ console.log("关闭连接")
|
|
|
+ if (!handClose) {
|
|
|
+ reconnection()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function sentMessage(message) {
|
|
|
+ ws.send(message)
|
|
|
+}
|
|
|
+
|
|
|
+function closeWs() {
|
|
|
+ handClose = true
|
|
|
+ clearTimer()
|
|
|
+ ws.close()
|
|
|
+ ws = null
|
|
|
+}
|
|
|
|
|
|
+function heartCheck() {
|
|
|
+ console.log('心跳检测')
|
|
|
+ if (timerHeart) {
|
|
|
+ clearTimeout(timerHeart)
|
|
|
+ }
|
|
|
+ timerHeart = setTimeout(() => {
|
|
|
+ // console.log("ping")
|
|
|
+ ws.send("ping")
|
|
|
+ lockReconnect = false
|
|
|
+ }, heartTimeOut)
|
|
|
}
|
|
|
|
|
|
getList();
|