Sfoglia il codice sorgente

修改一些bug
新增设备测试结果导出功能

liling 1 anno fa
parent
commit
d24358845c

+ 1 - 1
public/config.js

@@ -4,7 +4,7 @@ STATIC_CONFIG.lowpowerUrl = 'http://192.168.1.224:9910/#/detection'
 STATIC_CONFIG.golang = 'http://127.0.0.1:8006'
 // 后台服务接口地址
 //STATIC_CONFIG.proxyUrl = 'http://192.168.1.236:8080'
-STATIC_CONFIG.proxyUrl = 'http://192.168.1.51:8080'
+STATIC_CONFIG.proxyUrl = 'http://192.168.1.236:7070'
 // 添加配置代理ip
 // 首页资源
 // STATIC_CONFIG.logo = ''

+ 13 - 0
src/views/device/components/DeviceConfig.vue

@@ -348,6 +348,8 @@ export default {
   },
   data() {
     return {
+      // 数据提交标志
+      commitStateFlag: false,
       requestData: {},
       // 默认选项
       options: {
@@ -490,6 +492,15 @@ export default {
         // 如果有任何一个值为空,则直接返回,不提交数据
         return
       }
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      this.commitStateFlag = true
       const deviceSubmitData = this.clearSubmitData(this.requestData)
       // console.log('submitDeviceConfig deviceSubmitData = ', deviceSubmitData)
       deviceSubmitData.id = this.currentDeviceId || null
@@ -510,6 +521,8 @@ export default {
             offset: window.screen.height / 3
           })
         }
+      }).catch(res => {
+        this.commitStateFlag = false
       })
     },
     // 提交照片

+ 58 - 1
src/views/device/components/DeviceList.vue

@@ -76,6 +76,13 @@
               :disabled="!showDel"
               @click="multDelete()"
             >批量删除</el-button>
+            <el-button
+              :class="{'dark-button':showDel}"
+              icon="el-icon-download"
+              :disabled="!showDel"
+              @click="multExp()"
+            >导出检测结果</el-button>
+            <span style="font-size: 12px;color: #8f8e8e;"> (导出说明:仅导出所选设备已完成的方案检测结果数据;支持选择多台设备)</span>
           </div>
         </div>
         <div class="right">
@@ -317,6 +324,7 @@ export default {
   },
   data() {
     return {
+      commitStateFlag: false,
       // 是否具有设备检测执行权限
       has_btn_devicetest_run: false,
       tabledataloading: true,
@@ -442,7 +450,8 @@ export default {
         // 检测状态
         state: this.searchData.state,
         // 设备名称
-        serialNumber: this.searchData.serialNumber
+        serialNumber: this.searchData.serialNumber,
+        sort: 'createdDate,desc'
       }
       searchDeviceList(pageObj, searchParams).then(response => {
         this.tabledataloading = false
@@ -496,6 +505,54 @@ export default {
       }
       this.search()
     },
+    // 检测结果导出
+    multExp() {
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '正在导出数据中...',
+          type: 'warning',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      let hasNoCheck = false
+      const deviceIds = []
+      // 是否有未检查的设备,有则不允许 导出
+      for (let i = 0; i < this.multipleSelection.length; i++) {
+        const item = this.multipleSelection[i]
+        // 判断当前行数据是否被选中
+        if (item.state === 'NEW' || item.state === 'RUNNING') {
+          // 未检测或者检测中的不能导出检测结果
+          hasNoCheck = true
+          break
+        }
+        deviceIds.push(item.id)
+      }
+      if (hasNoCheck) {
+        this.$message({
+          message: '导出失败:所选择设备中有未检测设备,请重新选择!',
+          type: 'warning',
+          offset: window.screen.height / 3
+        })
+        this.commitStateFlag = false
+        return
+      }
+      if (deviceIds.length === 0) {
+        this.commitStateFlag = false
+        return
+      }
+      this.commitStateFlag = true
+      // 提交所选择设备id到后台
+      const getUrl = `/test/report/report.zip?id=` + deviceIds.join(',')
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = getUrl
+      link.target = '_blank'
+      document.body.appendChild(link)
+      link.click()
+      document.body.removeChild(link)
+      this.commitStateFlag = false
+    },
     // 设备检测 列表导出
     exportContentList() {
       this.$message({

+ 23 - 7
src/views/device/components/DevicePlan.vue

@@ -86,7 +86,7 @@
           <!-- 隐藏 列 -->
           <el-table-column type="selection" width="55" />
           <el-table-column prop="devicePlanName" label="方案名称" />
-          <el-table-column prop="devicePlanProtocol" label="设备类型" />
+          <el-table-column prop="devicePlanProtocol" label="协议类型" />
         </el-table>
       </div>
       <span slot="footer" class="dialog-footer">
@@ -134,6 +134,7 @@ export default {
   },
   data() {
     return {
+      commitStateFlag: false,
       // 提示框默认数据
       searchData: {
         name: ''
@@ -178,10 +179,10 @@ export default {
       this.addTableData.forEach((item, index) => {
         const getUrl = `/test/suite/${item.suiteId}`
         httpGet(getUrl).then(res => {
-          item.productType = res.productType
+          item.productType = res.productTypeName
         })
       })
-      this.getProductType(this.addTableData)
+      // this.getProductType(this.addTableData)
     },
     // 重置查询
     searchReset() {
@@ -190,7 +191,7 @@ export default {
     },
     // 添加方案查询
     async planListSearch() {
-      const getUrl = `/test/suite/search?name=${this.searchData.name}&size=999999`
+      const getUrl = `/test/suite/search?name=${this.searchData.name}&size=999999&sort=createdDate,desc&enable=1`
       const res = await httpGet(getUrl)
       this.tableData = []
       this.getTableData(res)
@@ -205,8 +206,12 @@ export default {
         page: 0,
         limit: 999999
       }
+      const searchParams = {
+        enable: 1,
+        sort: 'createdDate,desc'
+      }
       // 获取所有备选方案
-      searchPlanData(pageObj).then(response => {
+      searchPlanData(pageObj, searchParams).then(response => {
         this.getTableData(response)
       })
     },
@@ -220,7 +225,7 @@ export default {
         // this.addTableData[index].productType = '加载中...'
         httpGet(getUrl).then(res => {
           // console.log('当前方案协议: res.productType=', res.productType)
-          this.addTableData[index].productType = res.productType
+          this.addTableData[index].productType = res.productTypeName
         })
       })
     },
@@ -264,6 +269,15 @@ export default {
     },
     // 提交
     submitPlan() {
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      this.commitStateFlag = true
       // console.log(`this.tmpTableData=`, this.tmpTableData)
       // console.log('this.currentDeviceId=', this.currentDeviceId)
       // console.log('addTableData=', this.addTableData)
@@ -298,9 +312,11 @@ export default {
             }
           })
         })
-
+        this.commitStateFlag = false
         // console.log('reponse.code=', response.code)
         this.open = false
+      }).catch(res => {
+        this.commitStateFlag = false
       })
     },
     // 完成跳转

+ 1 - 1
src/views/device/components/ModelFormFileTransferOpt104.vue

@@ -80,7 +80,7 @@
                         >
                           <el-button
                             type="text"
-                            class="light-button"
+                            class="table-act"
                             icon="el-icon-upload2"
                             :disabled="isUploadFileIng"
                             size="small"

+ 1 - 1
src/views/device/components/ModelReport_master104.vue

@@ -25,7 +25,7 @@
       </div>
       <div class="right">
         <div class="export">
-          <a target="_blank" :href="`/test/execute/${reportParames.curPlanId}/message.xls`"><el-button icon="el-icon-download" class="light-button" size="small">导出</el-button></a>
+          <a target="_blank" :href="`/test/execute/${reportParames.curPlanId}/message.xls?period=${searchForm.selectVal}&page=0&size=10000`"><el-button icon="el-icon-download" class="light-button" size="small">导出</el-button></a>
         </div>
         <div class="refresh">
           <el-button class="light-button" icon="el-icon-refresh-left" size="small" @click="refreshReport({page:paginationNumber-1,limit:pageLimit},true)">刷新</el-button>

+ 1 - 1
src/views/device/tables/Example.vue

@@ -73,7 +73,7 @@
           <el-table-column prop="name" label="用例名称" width="150px" />
           <el-table-column prop="state" label="测试状态" width="120px">
             <template slot-scope="scope">
-              <span :style="{'color':scope.row.stateStyle}">{{ scope.row.state }}</span>
+              <span :style="{'color':scope.row.stateStyle}">{{ scope.row.stateName }}</span>
             </template>
           </el-table-column>
           <el-table-column v-if="false" prop="ruleName" label="测试规则" width="135px" />

+ 10 - 0
src/views/plan/components/PlanCheckPoint_master104.vue

@@ -601,7 +601,17 @@ export default {
         })
         return null
       }
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      this.commitStateFlag = true
       const res = await editRow(editPath, editData)
+      this.commitStateFlag = false
       if (res && ishint !== 'nohint') {
         this.$set(this.tableData[index], 'id', res.id)
         this.$set(this.tableData[index], 'modbus', res.modbus)

+ 12 - 15
src/views/plan/components/PlanConfig.vue

@@ -66,6 +66,7 @@ export default {
   },
   data() {
     return {
+      commitStateFlag: false,
       planName: '',
       protocolOptions: [],
       // 默认值
@@ -114,6 +115,14 @@ export default {
     },
     // 提交方案 下一步
     async submitPlan() {
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
       // 获取接收到的表单参数值,判断参数是否合法,是否需要提交
       const res = await searchPlanData({
         page: 0,
@@ -136,6 +145,7 @@ export default {
         })
         return
       }
+      this.commitStateFlag = true
       const planForm = {
         'name': this.planName,
         'productType': this.protocolValue
@@ -162,22 +172,9 @@ export default {
         this.$emit('changeStep', currentStep, res)
         this.$router.push({ path: `/plan/save?planId=${res.id}` })
         // }
+      }).catch(res => {
+        this.commitStateFlag = false
       })
-      // console.log('this.currentStep', this.currentStep)
-      // 参数合法,数据提交到后端,到下一步
-      // savePlanConfig(planForm).then(spRes => {
-      //   console.log('savePlanConfig spRes=', spRes)
-      //   // 需要把返回的 product 的值 传给下一步
-      //   let currentStep = this.currentStep
-      //   if (currentStep < 3) {
-      //       // 提交成功,下一步
-      //       currentStep = currentStep + 1
-      //       this.$emit('changeStep', currentStep, res)
-      //     this.$router.push({ path: `/plan/save?planId=${spRes.id}` })
-      //   } else {
-      //     // 已经是最后一步了
-      //   }
-      // })
     }
   }
 }

+ 21 - 64
src/views/plan/components/PlanExample.vue

@@ -233,6 +233,7 @@ export default {
   },
   data() {
     return {
+      commitStateFlag: false,
       tabledataloading: true,
       // 表格默认数据
       tableData: [],
@@ -467,53 +468,10 @@ export default {
     // 输入框失焦
     inputBlur(inputBlurData, index, isPro) {
       // console.log(`如果input失焦,则提交本行数据到后端`)
-      // console.log('inputBlur inputBlurData=', inputBlurData)
-      // console.log('inputBlur inputScope=', index)
-      // console.log('tableData', this.tableData)
       if (isPro) {
         // 根据当前 exampleTestRulesValue 获取相应规则中的 params
         this.tableData[index].exampleSetting = getParams(inputBlurData.exampleTestRulesValue, this.exampleTestRulesOptions)
       }
-
-      // 原: 如果 stepsId > 0 才执行提交
-      // 新: 后端 不支持批量提交数据 改为单条提交
-      // 如果 stepsId > 0 才执行提交
-      //     {
-      //        "id": "32",
-      //        "name": "值为123",
-      //        "suiteId": "999",
-      //        "planId": "999",
-      //        "ruleId": 10,
-      //        "ruleName": "采样数据是否等于某个值",
-      //        "not": false,
-      //        "value": 123,
-      //        "error": 0,
-      //        "params": {
-      //          "RANGE": "3",
-      //          "OFFSET": "0",
-      //          "VALUE": "123"
-      //        }
-      //      }
-
-      // 不再使用失焦保存
-      // const paramsJson = array2Json(inputBlurData.exampleSetting)
-
-      // const editPath = `/test/unit`
-      // const editData = {
-      //   id: inputBlurData.exampleId,
-      //   name: inputBlurData.exampleName,
-      //   suiteId: this.currentPlanData.id,
-      //   planId: null,
-      //   ruleId: inputBlurData.exampleTestRulesValue,
-      //   not: inputBlurData.exampleNegate,
-      //   value: inputBlurData.exampleExpectValue,
-      //   error: inputBlurData.exampleExpectValue,
-      //   params: paramsJson
-      // }
-      //
-      // editRow(editPath, editData).then(editRes => {
-      //   this.tableData[index].exampleId = editRes.id
-      // })
     },
     // 保存
     saveClick(row, index) {
@@ -539,6 +497,15 @@ export default {
         })
         return
       }
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      this.commitStateFlag = true
       this.tableData[index].jsonInputs = false
       const paramsJson = formatParams(row.exampleSetting)
       // console.log('savaRow = ', row.exampleSetting)
@@ -556,6 +523,7 @@ export default {
       }
 
       editRow(editPath, editData).then(editRes => {
+        this.commitStateFlag = false
         this.tableData[index].exampleId = editRes.id
         this.$message({
           message: `${editRes.name} 保存成功.`,
@@ -639,29 +607,17 @@ export default {
         })
         return
       }
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      this.commitStateFlag = true
       this.tableData.forEach(async(tmpRowData, index) => {
         const tableRowData = this.getSubmitTableRowData(tmpRowData)
-        // let isNotPassMesage = ''
-        // // console.log(tableRowData)
-        // let v = tableRowData.name.toString() || ''
-        // v = v.toString().replace(/ /gi, '')
-        // // console.log('name=', v)
-        // if (v === '') {
-        //   isNotPassMesage = '必填项(用例名称)不能为空'
-        // }
-        // v = tableRowData.ruleId.toString() || ''
-        // v = v.toString().replace(/ /gi, '')
-        // if (v === '') {
-        //   isNotPassMesage = '必填项(测试规则)不能为空'
-        // }
-        // if (isNotPassMesage !== '') {
-        //   this.$message({
-        //     type: 'error',
-        //     message: isNotPassMesage,
-        //     offset: window.screen.height / 3
-        //   })
-        //   return
-        // }
         await editRow(editPath, tableRowData).then(editRes => {
           tableRowData.exampleId = editRes.id
           if (index === this.tableData.length - 1) {
@@ -683,6 +639,7 @@ export default {
           }
         })
       })
+      this.commitStateFlag = false
     },
 
     // pop弹出框保存par

+ 2 - 1
src/views/plan/components/PlanList.vue

@@ -353,7 +353,8 @@ export default {
         end: this.dateValue ? this.dateValue[1] : null,
         name: this.searchName,
         // 未知 enable #TODO: 这里这个 enable 还不知道什么意思 先使用默认值 1
-        enable: 1
+        enable: 1,
+        sort: 'createdDate,desc'
       }
 
       // console.log('getDictOptions dictData=', dictData)

+ 21 - 5
src/views/plan/components/PlanSteps.vue

@@ -186,6 +186,7 @@ export default {
   },
   data() {
     return {
+      commitStateFlag: false,
       vloading: true,
       // 表格默认数据
       tableData: [],
@@ -483,11 +484,15 @@ export default {
         return
       }
       try {
-        // row.params = row.params.map(item => {
-        //   if (item.value == null) {
-        //     item.value = 0
-        //   }
-        // })
+        if (this.commitStateFlag) {
+          this.$message({
+            message: '数据正在提交中',
+            type: 'error',
+            offset: window.screen.height / 3
+          })
+          return
+        }
+        this.commitStateFlag = true
         const editPath = `/test/step`
         const editData = {
           ...row,
@@ -512,8 +517,10 @@ export default {
           message: `${res.id},保存成功`,
           offset: window.screen.height / 3
         })
+        this.commitStateFlag = false
         // this.getPlanSteps()
       } catch (error) {
+        this.commitStateFlag = false
         console.error('saveClick error:', error)
       }
     },
@@ -576,6 +583,15 @@ export default {
     },
     // 提交方案 下一步
     async submitPlan() {
+      if (this.commitStateFlag) {
+        this.$message({
+          message: '数据正在提交中',
+          type: 'error',
+          offset: window.screen.height / 3
+        })
+        return
+      }
+      this.commitStateFlag = true
       // console.log('submitPlan this.tmpTableData=', this.tmpTableData)
       const noName = this.tableData.some(item => (!item.name) || (!item.actionId.toString()))
       if (noName) {