Эх сурвалжийг харах

更改样式、文件上传名称验证

Rmengdi 2 сар өмнө
parent
commit
ef9191c608

+ 4 - 4
src/layout/components/NavBar/index.scss

@@ -1,7 +1,7 @@
 .nav-bar {
   // padding: 0 30px;
   padding-right: 30px;
-  // background: $theme-color;
+  background: $theme-color;
   box-sizing: border-box;
   box-shadow: 0 2px 10px rgb(0 0 0 / 5%);
   position: relative;
@@ -207,7 +207,7 @@
     overflow: scroll;
     
     // width: 150px !important;
-    background: rgb(15, 79, 99) !important;
+    background: $theme-color !important;
     border-radius: 0 !important;
     position: absolute;
     left: 50%;
@@ -226,11 +226,11 @@
     }
     .el-menu-item.is-active {
       color: #30daff !important;
-      background: rgb(26, 26, 26) !important;
+      background: $theme-color !important;
     }
     .el-submenu__title {
       color: #fff !important;
-      background: rgb(15, 79, 99) !important;
+      background: $theme-color !important;
       font-size: 1.1rem;
       .el-icon-arrow-right {
         display: none !important;

+ 1 - 1
src/style/color.scss

@@ -1,7 +1,7 @@
 // 主题颜色
 // #0074bd
 
-$theme-color: rgba(13, 128, 164, 1);
+$theme-color: rgba(1, 133, 118, 1);
 $nav-color: #bdcdd8;
 $nav-hover-color: #ffffff;
 $boeder-color: #185668;

+ 10 - 10
src/style/element-variables.scss

@@ -90,7 +90,7 @@
 }
 
 .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
-  background-color: #03171f !important;
+  background-color: #1e1e1e !important;
 }
 .el-table .el-table__cell {
   padding: 8px 4px !important;
@@ -226,8 +226,8 @@
 .el-input-group__prepend button.el-button,
 .el-input-group__prepend div.el-select .el-input__inner,
 .el-input-group__prepend div.el-select:hover .el-input__inner {
-  border-color: #34d9ff;
-  background-color: #34d9ff;
+  border-color: $theme-color;
+  background-color: $theme-color;
 }
 ::v-deep .el-icon-search {
   color: #fff;
@@ -241,12 +241,12 @@
 }
 
 .el-input-group__append {
-  border-color: rgba(13, 128, 164, 1) !important;
-  background-color: rgba(13, 128, 164, 1) !important;
+  border-color: $theme-color !important;
+  background-color: $theme-color !important;
 }
 .el-input-group__append .el-button {
-  border-color: rgba(13, 128, 164, 1) !important;
-  background-color: rgba(13, 128, 164, 1) !important;
+  border-color: $theme-color !important;
+  background-color: $theme-color !important;
   color: #fff !important;
 }
 .el-input--suffix i {
@@ -332,7 +332,7 @@
   background-color: #03171f !important;
 }
 .el-dialog__header {
-  background-color: rgba(13, 128, 164, 1) !important;
+  background-color: $theme-color !important;
 }
 .el-dialog__title {
   color: #fff !important;
@@ -397,7 +397,7 @@
 .el-message-box {
   background-color: rgb(15, 79, 99) !important;
   border-radius: 0 !important;
-  border-color: rgba(13, 128, 164, 1) !important;
+  border-color: rgba(13, 128, 164, 0.5) !important;
 }
 .el-message-box__title {
   color: #fff;
@@ -527,7 +527,7 @@ textarea {
 .el-date-table td.in-range div:hover,
 .el-date-table.is-week-mode .el-date-table__row.current div,
 .el-date-table.is-week-mode .el-date-table__row:hover div {
-  background-color: #03171f !important;
+  background-color: #1e1e1e !important;
 }
 .el-date-table td.end-date span,
 .el-date-table td.start-date span {

+ 15 - 22
src/views/als/components/FileUpload/index.vue

@@ -175,29 +175,21 @@ export default {
             message: '上传文件名称不符合规则!'
           })
           return false
-        } else {
-          if (this.isAirType === 'KJ') {
-            const airTime = fileName[0].split('_')[0]
-            const isTime = this.isValidDateTime(airTime)
-            if (!isTime) {
-              this.$message({
-                type: 'error',
-                message: '上传文件名称不符合规则!'
-              })
-              return false
-            }
-          } else if (this.isAirType === 'J') {
-            const airTime = fileName[0].split('_').slice(-2).join('')
-            const isTime = this.isValidDateTime(airTime)
-            if (!isTime) {
-              this.$message({
-                type: 'error',
-                message: '上传文件名称不符合规则!'
-              })
-              return false
-            }
-          }
         }
+        //  else {
+        //   const nameData = fileName[0].split('_')
+        //   nameData[3] = nameData[3].substring(0, 6)
+        //   const airTime = nameData.slice(-2).join('')
+        //   console.log('airTime', airTime)
+        //   const isTime = this.isValidDateTime(airTime)
+        //   if (!isTime) {
+        //     this.$message({
+        //       type: 'error',
+        //       message: '上传文件名称不符合规则!'
+        //     })
+        //     return false
+        //   }
+        // }
       }
       this.loading = this.$loading({
         lock: true,
@@ -277,6 +269,7 @@ export default {
       delOssApi(ossId)
       this.fileList.splice(index, 1)
       this.$emit('input', this.fileList)
+      this.$emit('handleDelFile')
     },
     // 上传结束处理
     uploadedSuccessfully() {

+ 57 - 14
src/views/als/flightData/index.vue

@@ -24,7 +24,7 @@
           <el-row>
             <el-col :span="12">
               <el-form-item label="上传飞参数据" label-width="110px" prop="ossId">
-                <FileUpload v-model="form.ossId" :limit="1" :fileSize="500" :fileType="['xls', 'xlsx', 'csv', 'txt']" :isNameCheck="false" :isAirType="isAirType" @uploadValue="uploadValue" />
+                <FileUpload v-model="form.ossId" :limit="1" :fileSize="500" :fileType="['xls', 'xlsx', 'csv', 'txt']" :isNameCheck="true" :isAirType="isAirType" @uploadValue="uploadValue" @handleDelFile="handleDelFile" />
               </el-form-item>
             </el-col>
             <!-- <el-col :span="12">
@@ -381,7 +381,7 @@ export default {
     openDialog() {
       this.dialogTitle = '新增'
       this.dialogVisible = true
-      this.judgeFileType(this.currentNode.parentId)
+      // this.judgeFileType(this.currentNode.parentId)
       this.form.aircraftId = this.currentNodeKey
     },
 
@@ -397,20 +397,64 @@ export default {
       }
     },
 
+    // 删除文件后调用
+    handleDelFile() {
+      this.form.sortieNo = null
+      this.form.flightDate = null
+    },
+
     uploadValue(uploadList) {
       const name = uploadList[0].fileName.split('.')
       const fileName = name.slice(0, name.length - 1)
-      const aircraft = this.aircaftCatalogAll.find((item) => {
-        return item.aircaftCatalogId == this.currentNodeKey
-      })
-      let airTime
-      if (this.isAirType == 'KJ') {
-        airTime = fileName[0].split('_')[0]
-      } else if (this.isAirType == 'J') {
-        airTime = fileName[0].split('_').slice(-2).join('')
+      const nameData = fileName[0].split('_')
+      if (nameData.length >= 4) {
+        // 大于等于四才可能对,如果大于四个,只取前四个
+        const name = nameData.slice(0, 4)
+        if (name[3].length >= 6) {
+          name[3] = name[3].substring(0, 6)
+          const airTime = name.slice(-2).join('')
+          const isTime = this.isValidDateTime(airTime)
+          if (isTime) {
+            this.form.sortieNo = name[1]
+            this.form.flightDate = this.formatDateString(airTime)
+          } else {
+            return
+          }
+        } else {
+          return
+        }
+      } else {
+        // 名称不符合
+        return
+      }
+    },
+
+    // 判断是否为时间
+    isValidDateTime(str) {
+      // 正则表达式匹配规则
+      const regex = /^\d{4}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])[0-5]\d[0-5]\d$/
+
+      if (!regex.test(str)) {
+        return false // 字符串格式不正确
       }
-      this.form.sortieNo = aircraft.aircaftCatalogCode + airTime
-      this.form.flightDate = this.formatDateString(airTime)
+
+      // 提取日期时间部分
+      const year = parseInt(str.substring(0, 4), 10)
+      const month = parseInt(str.substring(4, 6), 10)
+      const day = parseInt(str.substring(6, 8), 10)
+      const hour = parseInt(str.substring(8, 10), 10)
+      const minute = parseInt(str.substring(10, 12), 10)
+      const second = parseInt(str.substring(12, 14), 10)
+
+      // 创建日期对象,检查日期是否有效
+      const date = new Date(year, month - 1, day, hour, minute, second)
+
+      // 检查日期的年月日时分秒是否与输入的字符串匹配
+      if (date.getFullYear() === year && date.getMonth() + 1 === month && date.getDate() === day && date.getHours() === hour && date.getMinutes() === minute && date.getSeconds() === second) {
+        return true
+      }
+
+      return false
     },
 
     // 时间转换
@@ -441,11 +485,10 @@ export default {
       this.dialogTitle = '编辑'
       this.form = deepClone(row)
       this.dialogVisible = true
-      this.judgeFileType(this.currentNode.parentId)
+      // this.judgeFileType(this.currentNode.parentId)
     },
 
     submit() {
-      console.log('this.form', this.form)
       this.$refs['form'].validate((valid) => {
         if (valid) {
           switch (this.dialogTitle) {

+ 6 - 0
src/views/als/index.scss

@@ -14,6 +14,12 @@
     display: flex;
     .input1 {
       width: 340px;
+      
+    }
+    .el-input-group__append {
+      button{
+        background: $theme-color !important;
+      }
     }
   }
 }