From 07317dfd4ba3af0b2e58daec9ea0c776ac3181ec Mon Sep 17 00:00:00 2001
From: rjg <746338628@qq.com>
Date: Tue, 03 Jun 2025 16:11:27 +0800
Subject: [PATCH] Merge branch 'feature_0.2_add_expire_num' into test

---
 src/views/system/user.vue |  131 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 105 insertions(+), 26 deletions(-)

diff --git a/src/views/system/user.vue b/src/views/system/user.vue
index 2ac2490..ffe6b58 100644
--- a/src/views/system/user.vue
+++ b/src/views/system/user.vue
@@ -66,6 +66,7 @@
           <template #userTypeName="{ row }">
             <el-tag>{{ row.userTypeName }}</el-tag>
           </template>
+         
         </avue-crud>
         <el-dialog title="用户角色配置" append-to-body v-model="roleBox" width="345px">
           <el-tree :data="roleGrantList" show-checkbox check-strictly default-expand-all node-key="id" ref="treeRole"
@@ -153,7 +154,10 @@
       }
     };
     return {
-      form: {},
+      form: {
+        flightStartTime: null, // 飞行事件开始时间
+        flightEndTime: null, // 飞行事件结束时间
+      },
       search: {},
       roleBox: false,
       excelBox: false,
@@ -363,13 +367,7 @@
                 viewDisplay: false,
                 rules: [{ required: true, validator: validatePass2, trigger: 'blur' }],
               },
-              {
-                label: '到期时间',
-                prop: 'expireTime',
-                type: 'datetime',
-                format: 'YYYY-MM-DD HH:mm:ss',
-                valueFormat: 'YYYY-MM-DD HH:mm:ss',
-              },
+            
             ],
           },
           {
@@ -503,24 +501,58 @@
                   },
                 ],
               },
-              // {
-              //   label: '所属岗位',
-              //   prop: 'postId',
-              //   type: 'tree',
-              //   multiple: true,
-              //   dicData: [],
-              //   props: {
-              //     label: 'postName',
-              //     value: 'id',
-              //   },
-              //   rules: [
-              //     {
-              //       required: true,
-              //       message: '请选择所属岗位',
-              //       trigger: 'click',
-              //     },
-              //   ],
-              // },
+             
+            ],
+          },
+           {
+            label: '登录限制',
+            prop: '',
+            icon: 'el-icon-s-custom',
+            column: [
+               {
+                label: '到期时间',
+                prop: 'expireTime',
+                type: 'datetime',
+                format: 'YYYY-MM-DD HH:mm:ss',
+                valueFormat: 'YYYY-MM-DD HH:mm:ss',
+              },
+                {
+                label: '次数限制',
+                prop: 'maxLoginNum',
+                type: 'input',
+              },
+
+               {
+                label: '飞行开始时间',
+                prop: 'flightStartTime',
+               type: 'time',
+                 format: 'HH:mm',
+                valueFormat: 'HH:mm',
+                rules: [
+                  {
+                    required: false,
+                    message: '请输入飞行开始时间',
+                    trigger: 'blur',
+                  },
+                ],
+              },
+              {
+                label: '飞行结束时间',
+                prop: 'flightEndTime',
+                type: 'time',
+                format: 'HH:mm',
+                valueFormat: 'HH:mm',
+                rules: [
+                  {
+                    required: false,
+                    message: '请输入飞行结束时间',
+                    trigger: 'blur',
+                  },
+                ],
+              },
+        
+               
+      
             ],
           },
         ],
@@ -732,6 +764,23 @@
       });
     },
     rowSave(row, done, loading) {
+      // 格式化时间数据
+     
+       if (row.flightStartTime && row.flightEndTime) {
+    // 验证 flightEndTime 是否小于 flightStartTime
+   const [startHours, startMinutes] = row.flightStartTime.split(':').map(Number);
+    const [endHours, endMinutes] = row.flightEndTime.split(':').map(Number);
+
+    const startTotalMinutes = startHours * 60 + startMinutes;
+    const endTotalMinutes = endHours * 60 + endMinutes;
+
+    if (endTotalMinutes < startTotalMinutes) {
+        this.$message.error('飞行结束时间不能小于飞行开始时间');
+            loading();
+        return;
+    }
+       }
+    
       row.deptId = func.join(row.deptId);
       row.roleId = func.join(row.roleId);
       row.postId = func.join(row.postId);
@@ -753,6 +802,28 @@
       );
     },
     rowUpdate(row, index, done, loading) {
+         // 格式化时间数据
+      // if (row.flightStartTime) {
+      //   row.flightStartTime = this.formatTime(row.flightStartTime);
+      // }
+      // if (row.flightEndTime) {
+      //   row.flightEndTime = this.formatTime(row.flightEndTime);
+      // }
+       if (row.flightStartTime && row.flightEndTime) {
+    // 验证 flightEndTime 是否小于 flightStartTime
+   const [startHours, startMinutes] = row.flightStartTime.split(':').map(Number);
+    const [endHours, endMinutes] = row.flightEndTime.split(':').map(Number);
+
+    const startTotalMinutes = startHours * 60 + startMinutes;
+    const endTotalMinutes = endHours * 60 + endMinutes;
+
+    if (endTotalMinutes < startTotalMinutes) {
+        this.$message.error('飞行结束时间不能小于飞行开始时间');
+           loading();
+        return ;
+      }
+       }
+    
       row.deptId = func.join(row.deptId);
       row.roleId = func.join(row.roleId);
       row.postId = func.join(row.postId);
@@ -987,6 +1058,7 @@
           if (this.form.hasOwnProperty('postId')) {
             this.form.postId = func.split(this.form.postId);
           }
+
         });
       }
       this.initFlag = true;
@@ -1081,6 +1153,13 @@
         this.selectionClear();
       });
     },
+    formatTime(time) {
+      // 格式化时间为 HH:mm
+      const date = new Date(time);
+      const hours = String(date.getHours()).padStart(2, '0');
+      const minutes = String(date.getMinutes()).padStart(2, '0');
+      return `${hours}:${minutes}`;
+    },
   },
 };
 </script>

--
Gitblit v1.9.3