Ver código fonte

Merge branch 'dev-rmd2' of Rmengdi/LQBZ_web into master

www 4 meses atrás
pai
commit
23f0380482

+ 1 - 1
src/api/als/dataImport.js

@@ -30,7 +30,7 @@ export const getAircaftTypeAndModelTree = async (data) => {
  * @returns returns
  */
 export const importTemplateApi = () => {
-  return http.downloadPost('/als/dataImport/importTemplate', {})
+  return http.postFile('/als/dataImport/importTemplate', {})
 }
 
 /**

+ 11 - 1
src/api/als/faultCase.js

@@ -1,4 +1,4 @@
-import { get, put, post, deletes } from '@/http/index'
+import { get, put, post, deletes, postFile } from '@/http/index'
 
 // 查询故障案例列表
 export const getFaultCase = async (data) => {
@@ -19,3 +19,13 @@ export const updateFaultCase = async (data) => {
 export const removeFaultCase = async (id) => {
   return await deletes('/als/faultCase/' + id)
 }
+
+// 导出下载模板
+export const importTemplateApi = async () => {
+  return await postFile('/als/faultCase/importTemplate', {})
+}
+
+// 导出数据
+export const exportApi = async (data) => {
+  return await postFile('/als/faultCase/export', data)
+}

+ 1 - 1
src/api/als/faultStatistics.js

@@ -41,5 +41,5 @@ export const exportFaultStatisticsExcel = async (data) => {
 
 // 查询故障统计列表
 export const getFaultStatisticsListAll = async (data) => {
-  return await get('/als/faultStatistics/listAll', data)
+  return await post('/als/faultStatistics/listAll', data)
 }

+ 1 - 1
src/router/index.js

@@ -13,7 +13,7 @@ VueRouter.prototype.push = function push(location) {
 }
 
 const router = new VueRouter({
-  mode: 'history',
+  mode: 'hash',
   base: process.env.BASE_URL,
   routes: [...publicRoutes] // 做权限的时候 删除 ...privateRoutes
 })

+ 18 - 0
src/router/modules/system.js

@@ -218,6 +218,15 @@ export default [
           title: '历年航材消耗数据-汇总计算'
         }
       },
+      {
+        name: 'PreResult',
+        path: '/qualityManage/preProcessing',
+        component: () => import('@/views/als/preProcessing/index.vue'),
+        meta: {
+          parent: 'BasicData',
+          title: '数据预处理'
+        }
+      },
       {
         name: 'FlightData',
         path: '/dataManage/flightData',
@@ -236,6 +245,15 @@ export default [
           title: '判故逻辑管理'
         }
       },
+      {
+        name: 'AtlasFile',
+        path: '/knowledgeGraph/atlasFile',
+        component: () => import('@/views/als/atlasFile/index.vue'),
+        meta: {
+          parent: 'BasicData',
+          title: '文件管理'
+        }
+      },
       // {
       //   name: 'TrainingData',
       //   path: '/dataManage/trainingData',

+ 11 - 13
src/views/als/faultCase/index.vue

@@ -5,7 +5,7 @@
         <div class="view-dataType-title-btn">
           <el-button type="success" @click="openDialog()" :disabled="currentNode.type == 2">新增</el-button>
           <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length == 0">删除</el-button>
-          <el-dropdown split-button type="primary" style="margin-left: 10px" trigger="click" @command="handleExport">
+          <el-dropdown split-button type="primary" style="margin-left: 10px" trigger="click" @command="handleExportBtn">
             更多
             <el-dropdown-menu slot="dropdown">
               <el-dropdown-item command="handleImport">导入</el-dropdown-item>
@@ -95,14 +95,14 @@
 </template>
 
 <script>
-import { getFaultCase, addFaultCase, updateFaultCase, removeFaultCase } from '@/api/als/faultCase'
+import { getFaultCase, addFaultCase, updateFaultCase, removeFaultCase, importTemplateApi, exportApi } from '@/api/als/faultCase'
 import { deepClone, debounce } from '@/utils/index'
 import { getListByIdsApi } from '@/api/als/oss'
 import { getItem } from '@/utils/index'
 import { getAircaftTypeAndModelTree } from '@/api/als/sideTree'
 import Treeselect from '@riophae/vue-treeselect'
 import '@riophae/vue-treeselect/dist/vue-treeselect.css'
-import { flattenTree, download } from '../utils/common'
+import { flattenTree, useDownload, localResource } from '../utils/common'
 // import FileUpload from '@/views/als/components/FileUpload'
 
 export default {
@@ -329,6 +329,10 @@ export default {
       this.getFaultCaseAPI({ faultPhenomenon: keyWordData })
     },
 
+    //更多按钮
+    handleExportBtn(type) {
+      this[type]()
+    },
     async addFaultCaseAPI() {
       try {
         const { code } = await addFaultCase({ ...this.form })
@@ -466,12 +470,12 @@ export default {
 
     /** 导入按钮操作 */
     handleImport() {
-      this.upload.title = '警告列表导入'
+      this.upload.title = '故障字典导入'
       this.upload.open = true
     },
     /** 下载模板操作 */
     importTemplate() {
-      download('/faultCase/importTemplate', {}, `faultCase_template_${new Date().getTime()}.xlsx`)
+      useDownload(importTemplateApi, 'faultCase_template', {}, '.xlsx')
     },
     // 文件上传中处理
     handleFileUploadProgress(event, file, fileList) {
@@ -490,15 +494,9 @@ export default {
     submitFileForm() {
       this.$refs.upload.submit()
     },
-    // 导出
+    // 导出   faultPhenomenon
     handleExport() {
-      download(
-        '/faultCase/export',
-        {
-          ...this.form
-        },
-        `faultCase_${new Date().getTime()}.xlsx`
-      )
+      useDownload(exportApi, '故障字典数据_', { faultPhenomenon: this.keyWordData }, '.xlsx')
     }
   }
 }

+ 4 - 4
src/views/als/flightData/index.vue

@@ -52,12 +52,12 @@
           </el-row>
           <el-row>
             <el-col :span="12">
-              <el-form-item label="上传飞参数据" label-width="100px" prop="ossId">
+              <el-form-item label="上传飞参数据" label-width="110px" prop="ossId">
                 <FileUpload v-model="form.ossId" :limit="1" :fileSize="500" :fileType="['xls', 'xlsx']" />
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item label="警告列表导入" label-width="100px">
+              <el-form-item label="警告列表导入" label-width="110px">
                 <el-upload
                   ref="upload"
                   :limit="1"
@@ -92,7 +92,7 @@
 </template>
 
 <script>
-import { getDataImport, addDataImport, updateDataImport, removeDataImport } from '@/api/als/dataImport'
+import { getDataImport, addDataImport, updateDataImport, removeDataImport, importTemplateApi } from '@/api/als/dataImport'
 import { getAircaftCatalogTree } from '@/api/als/sideTree'
 import { getAircaftCatalogAll } from '@/api/als/aircraft'
 import { deepClone, debounce } from '@/utils/index'
@@ -462,7 +462,7 @@ export default {
     },
     /** 下载模板操作 */
     importTemplate() {
-      download('/warning/importTemplate', {}, `warning_template_${new Date().getTime()}.xlsx`)
+      useDownload(importTemplateApi, 'warning_template', {}, '.xlsx')
     },
     // 文件上传中处理
     handleFileUploadProgress(event, file, fileList) {

+ 39 - 34
src/views/als/intelligentQA/index.vue

@@ -58,7 +58,8 @@
         <div class="contentRight">
           <div>
             <div class="source">
-              <el-link :href="`${fileInfo.url}`" style="color: #209cc1" :underline="false" target="_blank">
+              <!-- <el-link :href="`${fileInfo.url}`" style="color: #209cc1" :underline="false" target="_blank"> -->
+              <el-link @click="downloadFile(fileInfo.url)" style="color: #209cc1" :underline="false" target="_blank">
                 <el-tooltip class="item" effect="dark" content="点击可下载" placement="top">
                   <span> 来源:《{{ moreData.file_name }}{{ moreData.fileName }}》</span>
                 </el-tooltip>
@@ -94,6 +95,7 @@ import { getListByIdsApi } from '@/api/als/oss'
 import VueOfficeDocx from '@vue-office/docx'
 import VueOfficePdf from '@vue-office/pdf'
 import '@vue-office/docx/lib/index.css'
+import { localResource } from '../utils/common'
 
 export default {
   name: 'IntelligentQA',
@@ -110,7 +112,7 @@ export default {
         user_id: '',
         answer: '',
         file_name: '',
-        ossID: '',
+        ossID: null,
         graph: {}
       },
       historyData: [],
@@ -193,38 +195,37 @@ export default {
           answer: '正在解析您的问题,请稍后......'
         })
         this.questionInput = ''
-        const { code, data } = await handlerAsk(sendInput)
-        // const { code, data } = {
-        //   code: 200,
-        //   msg: '',
-        //   data: {
-        //     user_id: 'user',
-        //     answer: '解决办法为:更换电池或遥控器',
-        //     file_name: '排故手册',
-        //     // ossID: '225825878820585472',//pdf
-        //     ossID: '225840762526433280', //word
-        //     graph: {
-        //       data: [
-        //         { name: '202310150010', category: 'HMC' },
-        //         { name: '电视', category: '成品' },
-        //         { name: '电视遥控器失灵', category: '故障描述' },
-        //         { name: '家用电器', category: '系统' },
-        //         { name: '更换电池或遥控器', category: '维修策略' }
-        //       ],
-        //       links: [
-        //         { source: '202310150010', target: '电视', value: '成品' },
-        //         { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
-        //         { source: '202310150010', target: '家用电器', value: '系统' },
-        //         { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
-        //       ]
-        //     }
-        //   }
-        // }
+        // const { code, data } = await handlerAsk(sendInput)
+        const { code, data } = {
+          code: 200,
+          msg: '',
+          data: {
+            user_id: 'user',
+            answer: '解决办法为:更换电池或遥控器',
+            file_name: '排故手册',
+            ossID: '227701077942149120', //pdf
+            // ossID: '227692224508796928', //word
+            graph: {
+              data: [
+                { name: '202310150010', category: 'HMC' },
+                { name: '电视', category: '成品' },
+                { name: '电视遥控器失灵', category: '故障描述' },
+                { name: '家用电器', category: '系统' },
+                { name: '更换电池或遥控器', category: '维修策略' }
+              ],
+              links: [
+                { source: '202310150010', target: '电视', value: '成品' },
+                { source: '202310150010', target: '电视遥控器失灵', value: '故障描述' },
+                { source: '202310150010', target: '家用电器', value: '系统' },
+                { source: '202310150010', target: '更换电池或遥控器', value: '维修策略' }
+              ]
+            }
+          }
+        }
 
         if (code == 200) {
-          console.log(1111)
-          const newData = this.handleData(JSON.parse(data))
-          // const newData = this.handleData(data)
+          // const newData = this.handleData(JSON.parse(data))
+          const newData = this.handleData(data)
           this.chatInfo.pop()
           this.chatInfo.push(newData)
           // this.getHistoryAll()
@@ -239,8 +240,8 @@ export default {
 
     handleData(data) {
       if (data.graph) {
-        const graphData = eval('(' + data.graph + ')')
-        data.graph = graphData
+        // const graphData = eval('(' + data.graph + ')')
+        // data.graph = graphData
         const categories = []
         data.graph.data.forEach((node) => {
           const flag = categories.find((item) => {
@@ -281,6 +282,10 @@ export default {
       } catch (error) {}
     },
 
+    downloadFile(url) {
+      localResource(url)
+    },
+
     deleteHistory(id) {
       this.$confirm('是否删除该条记录?', '提示', {
         confirmButtonText: '确定',

+ 10 - 2
src/views/als/model/index.vue

@@ -17,7 +17,7 @@
       </div>
       <!-- 添加或修改模型信息对话框 -->
       <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
-        <el-form ref="form" :model="form" label-width="80px">
+        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
           <el-form-item label="模型名称" prop="name">
             <el-input v-model="form.name" placeholder="请输入模型名称" />
           </el-form-item>
@@ -197,7 +197,14 @@ export default {
       debounceFn: debounce(this.fetch, 500),
       partsData: [],
       aircraftTypeTreeData: [],
-      allAirConfig: []
+      allAirConfig: [],
+      rules: {
+        name: [{ required: true, message: '模型名称不能为空', trigger: 'blur' }],
+        type: [{ required: true, message: '模型类型不能为空', trigger: 'change' }],
+        url: [{ required: true, message: '模型链接不能为空', trigger: 'blur' }],
+        aircraftType: [{ required: true, message: '机型不能为空', trigger: 'change' }],
+        partId: [{ required: true, message: '部件不能为空', trigger: 'change' }]
+      }
     }
   },
   watch: {
@@ -244,6 +251,7 @@ export default {
 
     aircraftTypeChange(node) {
       this.form.aircraftType = node.id
+      this.form.partId = null
       this.getAirConfigurationAPI({ aircraftType: this.form.aircraftType })
     },
 

+ 50 - 29
src/views/als/utils/common.js

@@ -2,6 +2,7 @@ import { Message, Loading } from 'element-ui'
 import { saveAs } from 'file-saver'
 import errorCode from '@/views/als/utils/errorCode'
 import axios from 'axios'
+import { getItem } from '@/utils/index'
 
 /**
  * 构造树型结构数据
@@ -77,65 +78,67 @@ export function flattenTree(treeNodes) {
 // 通用下载方法
 let downloadLoadingInstance
 const service = axios.create({
-  // axios中请求配置有baseURL选项,表示请求URL公共部分
   baseURL: '/api/als',
   // 超时
-  timeout: 10000
+  timeout: 100000
 })
-export async function download(url, params, filename, config) {
-  downloadLoadingInstance = Loading.service({ text: '正在下载数据,请稍候', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' })
+
+/**
+ * @description 接收数据流生成 blob,创建链接,下载文件
+ * @param {Function} api 导出表格的api方法 (必传)
+ * @param {String} tempName 导出的文件名 (必传)
+ * @param {Object} params 导出的参数 (默认{})
+ * @param {String} fileType 导出的文件格式 (默认为.xlsx)
+ * */
+export const useDownload = async (api, tempName, params, fileType, fileName) => {
   try {
-    const data = await service.post(url, params, {
-      transformRequest: [
-        (params_1) => {
-          return tansParams(params_1)
-        }
-      ],
-      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
-      responseType: 'blob',
-      ...config
-    })
-    const isBlob = blobValidate(data)
+    const res = await api(params)
+    const isBlob = blobValidate(res.data)
     if (isBlob) {
-      const blob = new Blob([data])
-      saveAs(blob, filename)
+      const blob = fileType == 'zip' ? new Blob([res.data], { type: 'application/zip' }) : new Blob([res.data])
+      const name = fileType == 'zip' ? fileName : `${tempName}_${new Date().getTime()}${fileType}`
+      saveAs(blob, name)
     } else {
-      const resText = await data.text()
-      const rspObj = JSON.parse(resText)
-      const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
-      Message.error(errMsg)
+      printErrMsg(res)
     }
-    downloadLoadingInstance.close()
-  } catch (r) {
-    console.error(r)
+  } catch (error) {
+    console.log(error)
     Message.error('下载文件出现错误,请联系管理员!')
-    downloadLoadingInstance.close()
   }
 }
 
+async function printErrMsg(data) {
+  const resText = await data.text()
+  const rspObj = JSON.parse(resText)
+  const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
+  Message.error(errMsg)
+}
+
 /**
  * 参数处理
  * @param {*} params  参数
  */
 export function tansParams(params) {
+  console.log('params', params)
   let result = ''
   for (const propName of Object.keys(params)) {
     const value = params[propName]
-    var part = encodeURIComponent(propName) + '='
+    var part = encodeURI(propName) + '='
     if (value !== null && value !== '' && typeof value !== 'undefined') {
       if (typeof value === 'object') {
         for (const key of Object.keys(value)) {
           if (value[key] !== null && value[key] !== '' && typeof value[key] !== 'undefined') {
             let params = propName + '[' + key + ']'
-            var subPart = encodeURIComponent(params) + '='
-            result += subPart + encodeURIComponent(value[key]) + '&'
+            var subPart = encodeURI(params) + '='
+            result += subPart + encodeURI(value[key]) + '&'
           }
         }
       } else {
-        result += part + encodeURIComponent(value) + '&'
+        result += part + encodeURI(value) + '&'
       }
     }
   }
+  console.log('result', result)
   return result
 }
 
@@ -143,3 +146,21 @@ export function tansParams(params) {
 export function blobValidate(data) {
   return data.type !== 'application/json'
 }
+
+export function localResource(resource) {
+  let url = '/common/download/resource?resource=' + encodeURI(resource)
+  service({
+    method: 'get',
+    url: url,
+    responseType: 'blob',
+    headers: { Authorization: getItem('token') }
+  }).then((res) => {
+    const isBlob = blobValidate(res.data)
+    if (isBlob) {
+      const blob = new Blob([res.data])
+      saveAs(blob, decodeURI(res.headers['download-filename']))
+    } else {
+      printErrMsg(res.data)
+    }
+  })
+}

+ 3 - 2
src/views/home/index.vue

@@ -10,7 +10,7 @@
                   <el-image style="width: 80px; height: 80px; margin-top: 10px" :src="imgUrl"></el-image>
                   <div class="info">
                     <p>{{ item.aircaftCatalogCode }}</p>
-                    <span class="success-state">健康 </span>
+                    <span :class="item.healthStatus == '故障' ? 'warning-state' : 'success-state'">{{ item.healthStatus }} </span>
                   </div>
                 </div>
               </div>
@@ -149,7 +149,7 @@ export default {
       this.fetchIndexAnalysis()
     },
     async maintainFetchTableData() {
-      const { data } = await getFaultStatisticsListAll()
+      const { data } = await getFaultStatisticsListAll({})
       this.maintainTableData = data.filter((item) => {
         return item.repairStatus !== '已完成'
       })
@@ -168,6 +168,7 @@ export default {
           }
         })
       })
+      console.log('this.aircaftCatalogAll', this.aircaftCatalogAll)
     },
     handleChange(item) {
       switch (item) {