Procházet zdrojové kódy

39748 【象屿】【自助打印】提货单页面和送货单页面增加无操作自动返回主页面功能

panxuejun před 1 rokem
rodič
revize
9738c0822f

+ 41 - 4
src/renderer/components/views/receiveDeliveryNote.vue

@@ -27,9 +27,19 @@
         </a-form-model-item>
       </a-form-model>
       <div class="table-operator">
-        <a-button type="primary" @click="createAndPrint"  style="width: 120px;height:40px" size="large" :loading="loading">
-          创建并打印
-        </a-button>
+        <a-row>
+          <a-col :span="10">
+            <a-button type="primary" @click="createAndPrint"  style="width: 120px;height:40px" size="large" :loading="loading">
+              创建并打印
+            </a-button>
+          </a-col>
+          <a-col :span="8">
+            <div class="time">
+              {{ txt }} 秒后自动返回主界面!
+            </div>
+          </a-col>
+        </a-row>
+
 <!--        <a-button type="primary" @click="print" style="height:60px;width: 100px;margin-left: 1080px" size="large">-->
 <!--          补打-->
 <!--        </a-button>-->
@@ -175,10 +185,30 @@ export default {
       video2:undefined,
       canvas2:undefined,
       video3:undefined,
-      canvas3:undefined
+      canvas3:undefined,
+      txt: 30,
+      inactivityTimer: ''
     }
   },
+  created() {
+    setInterval(() => {
+      this.txt = this.txt -1;
+    }, 1000)
+    this.resetTimer()
+    // 在用户活动时调用 resetTimer 重置定时器
+    document.addEventListener('mousedown', this.resetTimer)
+    document.addEventListener('keydown', this.resetTimer)
+  },
   methods: {
+    resetTimer() {
+      this.txt = 30;
+      const self = this
+      clearTimeout(this.inactivityTimer)
+      this.inactivityTimer = setTimeout(() => {
+        // 执行注销操作或者跳转到登录页面的代码
+        self.$router.push('/');
+      }, 0.5 * 60 * 1000) // 30分钟
+    },
     tablePaginationChange (pagination) {
       // console.log(pagination)
       this.pagination.current = pagination.current  // 重新设置当前页
@@ -742,4 +772,11 @@ export default {
 /deep/ .tableClass1 {
   font-size: 16px;
 }
+
+.time {
+  color: #333;
+  font-size: 22px;
+  font-weight: 700;
+  color: red;
+}
 </style>

+ 39 - 3
src/renderer/components/views/sendDeliveryNote.vue

@@ -13,9 +13,18 @@
                 </a-form-model-item>
             </a-form-model>
             <div class="table-operator">
-                <a-button type="primary" @click="print" size="large" :loading="loading">
+              <a-row>
+                <a-col :span="10">
+                  <a-button type="primary" @click="print" size="large" :loading="loading">
                     打印交货单
-                </a-button>
+                  </a-button>
+                </a-col>
+                <a-col :span="8">
+                  <div class="time">
+                    {{ txt }} 秒后自动返回主界面!
+                  </div>
+                </a-col>
+              </a-row>
             </div>
             <a-table :columns="columns" :data-source="list" :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: handleChange }"
                      :customHeaderRow="customHeaderRow" :custom-row="customRow" size="default">
@@ -105,14 +114,34 @@ export default {
             video2:undefined,
             canvas2:undefined,
             video3:undefined,
-            canvas3:undefined
+            canvas3:undefined,
+            txt: 30,
+            inactivityTimer: ''
         }
     },
     components: {
         sendPrintSock,
         webSock
     },
+    created() {
+      setInterval(() => {
+        this.txt = this.txt -1;
+      }, 1000)
+      this.resetTimer()
+      // 在用户活动时调用 resetTimer 重置定时器
+      document.addEventListener('mousedown', this.resetTimer)
+      document.addEventListener('keydown', this.resetTimer)
+    },
     methods: {
+        resetTimer() {
+          this.txt = 30;
+          const self = this
+          clearTimeout(this.inactivityTimer)
+          this.inactivityTimer = setTimeout(() => {
+            // 执行注销操作或者跳转到登录页面的代码
+            self.$router.push('/');
+          }, 0.5 * 60 * 1000) // 30分钟
+        },
         search() {
             const self = this
             if (self.searchModel.deliveryNote === undefined || self.searchModel.deliveryNote === null) {
@@ -358,4 +387,11 @@ export default {
     /deep/ .tableClass2 {
         font-size: 20px;
     }
+
+    .time {
+      color: #333;
+      font-size: 22px;
+      font-weight: 700;
+      color: red;
+    }
 </style>