Browse Source

上报到市增加进度条显示

wanger 1 month ago
parent
commit
710bf7abda

+ 2 - 1
website/src/utils/websocket.js

@@ -18,10 +18,11 @@ export const socket = {
     serverTimeout: null,
     //初始化方法,根据url创建websocket对象封装基本连接方法,并重置心跳检测
     initWebSocket(newUrl) {
+        debugger
         socket.url = newUrl;
         // socket.websocket = new WebSocket(`ws://` + baseUrl.replace("http://", "") + `/apply/sbjd/` + socket.url);
         if (location.hostname == "localhost") {
-            socket.websocket = new WebSocket(`ws://192.168.60.52:8080/apply/sbjd/` + socket.url);
+            socket.websocket = new WebSocket(`ws://192.168.60.240:8080/apply/sbjd/` + socket.url);
         } else {
             socket.websocket = new WebSocket(`ws://` + baseUrl.replace("http://", "") + `/apply/sbjd/` + socket.url);
         }

+ 37 - 9
website/src/views/ghcgscygl/ghcgsb/xxgh/Czgh/Qxyh.vue

@@ -11,8 +11,7 @@
               ...props,
               checkStrictly: true,
               expandTrigger: 'hover',
-            }" v-model="formInline.xzqCode" clearable ref="cascader" class="cascader-style" 
-              @change="setXzqdm"
+            }" v-model="formInline.xzqCode" clearable ref="cascader" class="cascader-style" @change="setXzqdm"
               popper-class="popper-cascader" :filterable="true" :show-all-levels="false"></el-cascader>
           </el-form-item>
           <el-form-item label="流程状态:">
@@ -91,8 +90,8 @@
                 </slot>
                 <slot name="bj">
                   <el-button type="text" class="caozuo" @click="edit(scope.row)" :disabled="!(
-                      uploadStatus(scope.row.status) === '未上报'
-                    )
+                    uploadStatus(scope.row.status) === '未上报'
+                  )
                     ">编辑</el-button>
                 </slot>
                 <slot name="sbzzzq">
@@ -114,9 +113,9 @@
                   $store.getters.roles.indexOf('admin') < 0
                 ">
                   <el-button type="text" class="caozuo" @click="showDialog(scope.row, 2, scope.$index)" :disabled="!(
-                      uploadStatus1(scope.row.uploadStatus) === '上报失败' ||
-                      uploadStatus(scope.row.status) === '未上报'
-                    )
+                    uploadStatus1(scope.row.uploadStatus) === '上报失败' ||
+                    uploadStatus(scope.row.status) === '未上报'
+                  )
                     ">删除</el-button>
                 </slot>
                 <slot name="delete" v-if="
@@ -150,6 +149,10 @@
       <span>{{ dialogMessage1 + name + dialogMessage2 }}</span>
       <template #footer>
         <span class="dialog-footer">
+          <span class="dialog-footer" v-show="sbjdProgress" style="line-height: 40px">
+            <el-progress :text-inside="true" :stroke-width="20" :percentage="sbjdPercentage"
+              :format="sbjdFormat"></el-progress>
+          </span>
           <el-button @click="editDialogVisible = false" style="margin-right: 20px">
             取消
           </el-button>
@@ -189,6 +192,7 @@
 </template>
 
 <script>
+import { socket } from "@/utils/websocket.js";
 import { reactive, toRefs, ref } from "@vue/reactivity";
 import { getCurrentInstance, onMounted, watch } from "@vue/runtime-core";
 import { GetXzq } from "@/api/homeApi.js";
@@ -236,6 +240,9 @@ export default {
         ],
         cgid: [{ required: true, message: "请输入成果编号", trigger: "blur" }],
       },
+      sbjdText: "0/0",
+      sbjdPercentage: 0,
+      sbjdProgress: false,
       scmxList: [],
       xzoptions: [],
       cascader: ref(null),
@@ -292,14 +299,35 @@ export default {
         }
         qxyh.editDialogVisible = true;
       },
+      websocketOnMessage(msg1) {
+        let msg = msg1.data;
+        if (msg.indexOf("/") > -1) {
+          qxyh.sbjdText = msg;
+          let percentage =
+            parseInt(msg.split("/")[0]) / parseInt(msg.split("/")[1]);
+          qxyh.sbjdPercentage =
+            percentage == 0 ? 0 : Math.round(percentage * 10000) / 100;
+        }
+      },
       // 修改状态
       editQsStatus() {
         // 上报至市
         if (qxyh.editStatus === 1) {
+          let uuid = qxyh.tableData[qxyh.index].uuid
+          qxyh.sbjdPercentage = 0;
+          qxyh.sbjdText = "0/0";
+          qxyh.sbjdProgress = true;
+          socket.initWebSocket(uuid);
+          //socket.initWebSocket(`ws://${window.location.host}${import.meta.env.VITE_APP_BASE_API }/apply/sbjd/` + qxyh.editId);
+          //绑定接收消息方法
+          socket.websocket.onmessage = qxyh.websocketOnMessage;
           ReportSubmit({
-            uuid: qxyh.tableData[qxyh.index].uuid,
+            uuid: uuid,
             cglevel: 1,
           }).then((res) => {
+            socket.websocketOnClose();
+            qxyh.sbjdProgress = false;
+            qxyh.editDialogVisible = false;
             if (res.success) {
               qxyh.getlist();
               ElMessage.success("成功上报至市");
@@ -321,9 +349,9 @@ export default {
             ElMessage.success("删除成功");
             qxyh.getlist();
           });
+          qxyh.editDialogVisible = false;
           //上报至自治区
         }
-        qxyh.editDialogVisible = false;
       },
       // 筛选
       changeForm() {

+ 24 - 23
website/src/views/ghcgscygl/ghcgsb/ztgh/Qxjghcg/Qxyh.vue

@@ -371,26 +371,27 @@ export default {
       // 修改状态
       editQsStatus() {
         // 上报至市
-        if (qxyh.editStatus === 1) {
-          updateCgInfo({
-            id: qxyh.editId,
-            uploadstatus: 1,
-          }).then((res) => {
-            if (res.success) {
-              qxyh.getlist();
-              ElMessage.success("成功上报至市");
-            } else {
-              this.$message({
-                type: "error",
-                message: res.message,
-                showClose: true,
-                duration: 0,
-              });
-            }
-          });
-          qxyh.editDialogVisible = false;
-          // 删除
-        } else if (qxyh.editStatus === 2) {
+        // if (qxyh.editStatus === 1) {
+        //   updateCgInfo({
+        //     id: qxyh.editId,
+        //     uploadstatus: 1,
+        //   }).then((res) => {
+        //     if (res.success) {
+        //       qxyh.getlist();
+        //       ElMessage.success("成功上报至市");
+        //     } else {
+        //       this.$message({
+        //         type: "error",
+        //         message: res.message,
+        //         showClose: true,
+        //         duration: 0,
+        //       });
+        //     }
+        //   });
+        //   qxyh.editDialogVisible = false;
+        //   // 删除
+        // } else 
+        if (qxyh.editStatus === 2) {
           cgDelete({
             id: qxyh.editId,
           }).then((res) => {
@@ -401,7 +402,7 @@ export default {
           });
           qxyh.editDialogVisible = false;
           //上报至自治区
-        } else if (qxyh.editStatus === 3) {
+        } else if (qxyh.editStatus === 1) {
           qxyh.sbjdPercentage = 0;
           qxyh.sbjdText = "0/0";
           qxyh.sbjdProgress = true;
@@ -411,13 +412,13 @@ export default {
           socket.websocket.onmessage = qxyh.websocketOnMessage;
           updateCgInfo({
             id: qxyh.editId,
-            uploadstatus: 7,
+            uploadstatus: 1,
           }).then((res) => {
             socket.websocketOnClose();
             qxyh.sbjdProgress = false;
             if (res.success) {
               qxyh.getlist();
-              ElMessage.success("成功上报至自治区");
+              ElMessage.success("成功上报至");
             } else {
               this.$message({
                 type: "error",