|
@@ -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) {
|