瀏覽代碼

修复一些已知问题

liling 1 年之前
父節點
當前提交
ef37d63b93

+ 3 - 4
src/utils/request.js

@@ -1,7 +1,6 @@
 import axios from 'axios'
 // import { MessageBox, Message } from 'element-ui'
 import { Message } from 'element-ui'
-import store from '@/store'
 import { getToken } from '@/utils/auth'
 
 // create an axios instance
@@ -99,11 +98,11 @@ service.interceptors.response.use(
     } */
   },
   error => {
-    console.log('request.js err=', error) // for debug
+    console.log(error) // for debug
     console.log('request.js err.response=', error.response) // for debug
-    error.response.data.message = error.response.data.message || '未知错误'
+    // error.response.data.message = error.response.data.message || '未知错误'
     Message({
-      message: '' + error.response.data.message,
+      message: error.toString().indexOf('Network') > -1 ? '网络请求失败' : '' + error.response.data.message,
       type: 'error',
       duration: 3 * 1000,
       offset: window.screen.height / 3

+ 59 - 8
src/views/device/components/ModelFormFileTransferOpt104.vue

@@ -32,6 +32,7 @@
                   @click="getDeviceFileList()"
                 >获取目录文件</el-button>
                 <el-button class="light-button" icon="el-icon-refresh" size="big" @click="refreshFileList()">刷新</el-button>
+                <el-button style="float: right;" class="light-button" icon="el-icon-add" size="big" @click="addFileRecord()">添加文件信息</el-button>
               </el-col>
             </el-row>
             <el-row type="flex" style="float:left;width: 100%;margin-top: 10px;">
@@ -70,10 +71,10 @@
                             size="small"
                           >上传文件</el-button>
                         </el-upload>
-                        <a v-if="scope.row.download==true" target="new" :href="`/test/file/${scope.row.id}/bytes`"><el-button class="table-act" type="text" icon="el-icon-download" size="small">下载文件</el-button></a>
-                        <el-button v-if="scope.row.writeable==true" class="table-act" type="text" icon="el-icon-download" size="small" @click="sendFile(scope.row)">写文件</el-button>
-                        <el-button v-if="scope.row.readable==true" class="table-act" type="text" icon="el-icon-download" size="small" @click="readFile(scope.row)">读文件</el-button>
-                        <el-button v-if="scope.row.deletable==true" class="table-act" type="text" icon="el-icon-delete" size="small" @click="deleteFile(scope.row)">删除</el-button>
+                        <a v-if="scope.row.download==true" style="float: left;margin-right: 20px;" target="new" :href="`/test/file/${scope.row.id}/bytes`"><el-button class="table-act" type="text" icon="el-icon-download" size="small">下载文件</el-button></a>
+                        <el-button v-if="scope.row.writeable==true" style="float: left;margin-right: 20px;" class="table-act" type="text" icon="el-icon-download" size="small" @click="sendFile(scope.row)">写文件</el-button>
+                        <el-button v-if="scope.row.readable==true" style="float: left;margin-right: 20px;" class="table-act" type="text" icon="el-icon-download" size="small" @click="readFile(scope.row)">读文件</el-button>
+                        <el-button v-if="scope.row.deletable==true" style="float: left;" class="table-act" type="text" icon="el-icon-delete" size="small" @click="deleteFile(scope.row)">删除</el-button>
                         <!--<el-button v-if="scope.row.pos==null || scope.row.size==null || scope.row.pos==scope.row.size" class="table-act" type="text" icon="el-icon-delete" size="small" @click="deleteFile(scope.row)">删除</el-button>-->
                       </template>
                     </el-table-column>
@@ -84,7 +85,7 @@
           </el-tab-pane>
         </el-tabs>
         <el-tabs v-model="fileSendTabname" type="border-card" style="margin-top: 20px;">
-          <el-tab-pane label="文件下发" name="tab3" style="text-align: center;">
+          <el-tab-pane label="文件直接下发" name="tab3" style="text-align: center;">
             <el-row>
               <el-col>
                 <el-upload
@@ -206,7 +207,7 @@ export default {
     // 初始化
     async initFunctions() {
       this.comonentVar.modelTitle = '文件传输'
-      this.fileUrl = window.STATIC_CONFIG.proxyUrl
+      // this.fileUrl = window.STATIC_CONFIG.proxyUrl
       this.getList()
     },
     // 关闭model时执行
@@ -251,8 +252,12 @@ export default {
         }
         this.dbFileList = resLst
       }).catch(res => {
-        this.dbFileList = []
         this.isLoading2 = false
+        this.$message({
+          message: res.message,
+          type: 'error',
+          offset: window.screen.height / 3
+        })
       })
     },
     refreshFileList() {
@@ -266,12 +271,43 @@ export default {
       this.sendFileProcessNumber = '0 %'
       this.$refs.sendFileProcess2.style.width = 0 * (300 / 100) + 'px'
     },
+    addFileRecord() {
+      this.$prompt('文件名称', '文件信息', {
+        inputAttrs: {
+          maxlength: 50,
+          placeholder: '请输入50个字符以内的文件名'
+        }
+      }).then((obj) => {
+        // 确认
+        const v = obj.value == null ? '' : obj.value.replace(/ /gi, '')
+        if (v === '') {
+          this.$message('文件名称不能为空')
+          return
+        }
+        if (v.length > 50) {
+          this.$message('文件名称不能超过50字符')
+          return
+        }
+        // 先创建文件记录
+        putData('/test/file', { 'runnerId': this.modelParames.curPlanId, 'name': v, 'size': 0 }).then(res => {
+          this.$message('文件信息创添加成功')
+          this.getList()
+        }).catch(res => {
+          this.$message({
+            message: '文件信息添加失败:' + res.message,
+            type: 'error',
+            offset: window.screen.height / 3
+          })
+        })
+      }).catch({
+        // 取消
+      })
+    },
     submitUpload() {
       // 上传文件
       this.isUploadFileIng = true
       // 先创建文件记录
       putData('/test/file', { 'runnerId': this.modelParames.curPlanId, 'name': this.selectFileName, 'size': this.uploadSize }).then(res => {
-        console.log(res)
         this.fid = res.id
         // /test/file/{id}/bytes
         // this.uploadFileUrl = window.STATIC_CONFIG.proxyUrl + '/test/file/' + fid + '/bytes' // 文件上传地址
@@ -316,6 +352,11 @@ export default {
         })
         this.getList()
       }).catch(res => {
+        this.$message({
+          message: res.message,
+          type: 'error',
+          offset: window.screen.height / 3
+        })
       })
     },
     downloadFile(row) {
@@ -341,6 +382,11 @@ export default {
         }, 3000)
       }).catch(res => {
         this.isReadFileId = 0
+        this.$message({
+          message: res.message,
+          type: 'error',
+          offset: window.screen.height / 3
+        })
       })
     },
     sendFile(row) {
@@ -359,6 +405,11 @@ export default {
         }, 3000)
       }).catch(res => {
         this.isSendFileId = 0
+        this.$message({
+          message: res.message,
+          type: 'error',
+          offset: window.screen.height / 3
+        })
       })
     },
     // 表单取消按钮

+ 2 - 0
src/views/device/tables/Example.vue

@@ -349,6 +349,8 @@ export default {
         this.deviceExamples.paginationNumber = response.number * 1 + 1
         // 刷新一次用例状态
         this.refreshManual(false)
+      }).catch((res) => {
+        this.vloading = false
       })
     },
     // 编辑

+ 8 - 3
src/views/device/tables/Sample_master104.vue

@@ -440,9 +440,12 @@ export default {
           if (groupingNamelist[element.groupingName]) {
             const aryLen = groupingNamelist[element.groupingName].length
             if (aryLen > 0) {
-              const prveEle = groupingNamelist[element.groupingName][aryLen - 1]
-              if (prveEle.id === '-1' && prveEle.range !== element.range) {
-              // 换行元素
+              let prveEle = groupingNamelist[element.groupingName][aryLen - 1]
+              if (prveEle.id === '-1') {
+                prveEle = groupingNamelist[element.groupingName][aryLen - 2]
+              }
+              if (prveEle.range !== element.range) {
+                // 换行元素
                 groupingNamelist[element.groupingName].push({ 'id': '-1' })
               }
             }
@@ -456,6 +459,8 @@ export default {
         // this.requestData.deviceProtocolOptions = response
         // 刷新一次状态
         this.refreshManual(false)
+      }).catch((res) => {
+        this.vLoading = false
       })
     },
     // 编辑