index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <div class="view-table-content">
  3. <div class="view-dataSpecies-left">
  4. <MenuTree :currentNodeKey="currentNodeKey" nodeKey="id" :treedata="menuTreeData" @TreeNodeclick="treeNodeClick" v-bind="treeObj"> </MenuTree>
  5. </div>
  6. <div class="view-dataSpecies-right">
  7. <div class="view-dataType-title">
  8. <div class="view-dataType-title-btn"></div>
  9. <div class="view-dataType-title-search">
  10. <el-input placeholder="请输入架次号" v-model="keyWordData" class="input1">
  11. <el-button slot="append" icon="el-icon-search" @click="searchClick"></el-button>
  12. </el-input>
  13. </div>
  14. </div>
  15. <div class="view-dataType-table">
  16. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  17. </div>
  18. <el-dialog title="诊断结果" :visible.sync="resultVisible" width="1200px">
  19. <LTable ref="resultTable" :showColumnSetting="false" :defaultFetch="false" :columns="resultColumns" :dataSource="resultTableData" :options="resultOptions" :pagination="resultTableRequset"></LTable>
  20. </el-dialog>
  21. <el-dialog title="执行进度" :visible.sync="progressVisible" width="800px">
  22. <el-progress :text-inside="true" :stroke-width="24" :percentage="percentage" status="success"></el-progress>
  23. </el-dialog>
  24. <el-dialog title="结果展示" :visible.sync="resultShowVisible" :before-close="resultShowDialogClose" width="800px">
  25. <div style="margin: 10px 0px">{{ resultShowData.result }}</div>
  26. <el-image style="width: 500px" v-if="resultShowData.url !== ''" :src="resultShowData.url" :preview-src-list="[resultShowData.url]"></el-image>
  27. <span slot="footer" class="dialog-footer">
  28. <el-button @click="resultShowDialogClose">取 消</el-button>
  29. <el-button type="primary" @click="resultShowDialogClose">确 定</el-button>
  30. </span>
  31. </el-dialog>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { getDataImport } from '@/api/als/dataImport'
  37. import { getFaultDiagnosis } from '@/api/als/faultDiagnosis'
  38. import { getFaultDiagnosisResult } from '@/api/als/faultDiagnosisResult'
  39. import { getAircaftCatalogTree } from '@/api/als/sideTree'
  40. import { getAircaftCatalogAll } from '@/api/als/aircraft'
  41. import { deepClone, debounce } from '@/utils/index'
  42. import { handleTree, flattenTree } from '../utils/common'
  43. import { getAirConfiguration } from '@/api/als/airConfiguration'
  44. import { executeFault } from '@/api/als/algorithm'
  45. import { getListByIdsApi } from '@/api/als/oss'
  46. export default {
  47. name: 'FaultDiagnosis',
  48. data() {
  49. // 这里存放数据
  50. return {
  51. resultVisible: false,
  52. progressVisible: false,
  53. resultShowVisible: false,
  54. keyWordData: '',
  55. aircaftModelIdList: [],
  56. currentNodeKey: '',
  57. currentNode: {},
  58. menuTreeData: [],
  59. treeObj: {
  60. title: '所属机种',
  61. activityheight: '275px',
  62. searchIcon: false,
  63. configure: {
  64. children: 'children',
  65. label: 'label'
  66. }
  67. },
  68. typeTree: {
  69. children: 'children',
  70. label: 'label'
  71. },
  72. searchValue: '',
  73. columns: [
  74. {
  75. prop: 'aircraftId',
  76. label: '编目',
  77. render: (h, params) => {
  78. const matchedItem = this.aircaftCatalogAll.find((item) => params.row.aircraftId.trim() === item.aircaftCatalogId.trim())
  79. if (matchedItem) {
  80. return h('span', matchedItem.aircaftCatalogCode)
  81. } else {
  82. return h('span', {}, '')
  83. }
  84. }
  85. },
  86. {
  87. prop: 'sortieNo',
  88. label: '架次号'
  89. },
  90. {
  91. prop: 'flightDate',
  92. label: '飞行时间'
  93. },
  94. {
  95. prop: 'source',
  96. label: '数据源',
  97. render: (h, params) => {
  98. if (params.row.source == 1) {
  99. return h('span', '飞参数据')
  100. } else {
  101. return h('span', 'MDC数据')
  102. }
  103. }
  104. },
  105. {
  106. prop: 'status',
  107. label: '状态',
  108. // 1 未处理,2 已处理
  109. render: (h, params) => {
  110. if (params.row.status == '1') {
  111. return h('span', '未处理')
  112. } else if (params.row.status == '2') {
  113. return h('span', { class: 'success-state' }, '已处理')
  114. } else {
  115. return h('span', { class: 'warning-state' }, '异常')
  116. }
  117. }
  118. },
  119. {
  120. button: true,
  121. label: '操作',
  122. width: '240px',
  123. group: [
  124. {
  125. name: '故障诊断',
  126. type: 'text',
  127. statusKey: 'status',
  128. disableKey: '2',
  129. round: false,
  130. plain: false,
  131. onClick: (row, index, scope) => {
  132. this.faultExecute(row)
  133. }
  134. },
  135. {
  136. name: '查看',
  137. type: 'text',
  138. statusKey: 'status',
  139. unDisableKey: '2',
  140. round: false,
  141. plain: false,
  142. onClick: (row, index, scope) => {
  143. this.checkRelustList(row)
  144. }
  145. }
  146. ]
  147. }
  148. ],
  149. options: {
  150. stripe: false, // 斑马纹
  151. mutiSelect: true, // 多选框
  152. index: false, // 显示序号, 多选则 mutiSelect
  153. loading: false, // 表格动画
  154. initTable: false, // 是否一挂载就加载数据
  155. border: true,
  156. height: 'calc(100vh - 300px)'
  157. },
  158. tableCheckItems: [],
  159. tableData: [],
  160. tableRequset: {
  161. total: 0,
  162. pageIndex: 1,
  163. pageSize: 20,
  164. searchValue: ''
  165. },
  166. resultColumns: [
  167. {
  168. prop: 'modelType',
  169. label: '算法名称'
  170. },
  171. {
  172. prop: 'param',
  173. label: '部件',
  174. render: (h, params) => {
  175. const matchedItem = this.allAirConfig.find((item) => params.row.param === item.id)
  176. if (matchedItem) {
  177. return h('span', matchedItem.name)
  178. } else {
  179. return h('span', {}, '')
  180. }
  181. }
  182. },
  183. {
  184. prop: 'remarks',
  185. label: '参数特征'
  186. },
  187. {
  188. prop: 'columnData',
  189. label: '数据列'
  190. },
  191. {
  192. prop: 'resultContent',
  193. label: '结果',
  194. render: (h, params) => {
  195. const result = JSON.parse(params.row.resultContent).result
  196. if (result) {
  197. return h('span', result)
  198. } else {
  199. return h('span', {}, '-')
  200. }
  201. }
  202. },
  203. {
  204. button: true,
  205. label: '操作',
  206. width: '240px',
  207. group: [
  208. {
  209. name: '查看结果',
  210. type: 'text',
  211. round: false,
  212. plain: false,
  213. onClick: (row, index, scope) => {
  214. this.checkRelustShow(row)
  215. }
  216. }
  217. ]
  218. }
  219. ],
  220. resultOptions: {
  221. stripe: false, // 斑马纹
  222. mutiSelect: true, // 多选框
  223. index: false, // 显示序号, 多选则 mutiSelect
  224. loading: false, // 表格动画
  225. initTable: false, // 是否一挂载就加载数据
  226. border: true,
  227. height: 'calc(100vh - 600px)'
  228. },
  229. resultTableCheckItems: [],
  230. resultTableData: [],
  231. resultTableRequset: {
  232. total: 0,
  233. pageIndex: 1,
  234. pageSize: 10,
  235. searchValue: ''
  236. },
  237. debounceFn: debounce(this.fetch, 500),
  238. aircaftCatalogAll: [],
  239. form: {
  240. id: '',
  241. sortieNo: '',
  242. ossId: '',
  243. aircraftId: '',
  244. aircraftType: '',
  245. flightDate: '',
  246. status: '',
  247. result: '',
  248. partId: null
  249. },
  250. currentSortieNo: '',
  251. partsData: [],
  252. allAirConfig: [],
  253. percentage: 0,
  254. resultShowData: {
  255. url: '',
  256. result: ''
  257. }
  258. }
  259. },
  260. watch: {
  261. keyWord() {
  262. this.tableRequset.pageIndex = 1
  263. this.debounceFn()
  264. }
  265. },
  266. computed: {},
  267. mounted() {
  268. this.getAircaftCatalogTreeAPI()
  269. },
  270. methods: {
  271. async getAircaftCatalogTreeAPI(params) {
  272. try {
  273. const { data } = await getAircaftCatalogTree(params)
  274. this.menuTreeData = data
  275. const getAircaftCatalogAllParams = {
  276. keyWord: '',
  277. aircaftModelIdList: []
  278. }
  279. const { data: data2 } = await getAircaftCatalogAll(getAircaftCatalogAllParams)
  280. this.aircaftCatalogAll = data2
  281. const { data: airConfigData } = await getAirConfiguration()
  282. this.allAirConfig = airConfigData
  283. if (data.length) {
  284. this.currentNodeKey = data[0].id
  285. this.currentNode = data[0]
  286. this.aircaftModelIdList = this.getTreeLeafData(data[0]?.children)
  287. .map((e) => e.id)
  288. .toString()
  289. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  290. }
  291. } catch (error) {}
  292. },
  293. getTreeLeafData(list) {
  294. const newArr = []
  295. function getLeaf(data, arr) {
  296. data.forEach((e) => {
  297. if (e.type === 2) {
  298. arr.push(e)
  299. }
  300. if (e.children.length) {
  301. getLeaf(e.children, arr)
  302. }
  303. })
  304. }
  305. getLeaf(list, newArr)
  306. return newArr
  307. },
  308. async getFaultDiagnosisResultAPI(params) {
  309. if (this.$refs.resultTable) this.$refs.resultTable.clearSelection()
  310. const { keyWord } = this
  311. const { pageSize, pageIndex } = this.resultTableRequset
  312. const {
  313. data: { list, total }
  314. } = await getFaultDiagnosisResult({ pageSize, pageNum: pageIndex, ...params })
  315. this.resultTableData = list
  316. this.resultTableRequset.total = total
  317. },
  318. async getDataImportAPI(params) {
  319. if (this.$refs.table) this.$refs.table.clearSelection()
  320. const { keyWord } = this
  321. const { pageSize, pageIndex } = this.tableRequset
  322. const {
  323. data: { list, total }
  324. } = await getDataImport({ pageSize, pageNum: pageIndex, ...params, source: 1 })
  325. this.tableData = list
  326. this.tableRequset.total = total
  327. },
  328. fetch() {
  329. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  330. },
  331. async searchClick() {
  332. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList, sortieNo: this.keyWordData })
  333. },
  334. treeNodeClick(data) {
  335. this.$refs.table.clearSelection()
  336. this.currentNodeKey = data.id
  337. this.currentNode = data
  338. this.aircaftModelIdList = this.getTreeLeafData(data.children.length ? data.children : [data])
  339. .map((e) => e.id)
  340. .toString()
  341. if (!this.aircaftModelIdList) {
  342. this.aircaftModelIdList = '#'
  343. }
  344. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  345. },
  346. async getAirConfigurationAPI(params) {
  347. try {
  348. const { data } = await getAirConfiguration(params)
  349. const treeData = handleTree(data, 'id')
  350. this.partsData = treeData
  351. } catch (error) {}
  352. },
  353. faultExecute(row) {
  354. this.form = deepClone(row)
  355. const allAir = flattenTree(this.menuTreeData)
  356. const item = allAir.find((item) => item.id === this.form.aircraftId)
  357. this.form.aircraftType = item.parentId
  358. this.currentSortieNo = row.sortieNo
  359. this.beginExecute(row)
  360. },
  361. partIdSelect(node) {
  362. this.form.partId = node.id
  363. },
  364. normalizer(node) {
  365. if (node.children && !node.children.length) {
  366. delete node.children
  367. }
  368. return {
  369. id: node.id,
  370. label: node.name,
  371. children: node.children
  372. }
  373. },
  374. handleClose() {
  375. this.currentSortieNo = ''
  376. this.form = {
  377. id: '',
  378. sortieNo: '',
  379. ossId: '',
  380. aircraftId: '',
  381. aircraftType: '',
  382. flightDate: '',
  383. status: '',
  384. result: '',
  385. partId: null
  386. }
  387. },
  388. resultShowDialogClose() {
  389. this.resultShowVisible = false
  390. this.resultShowData = {
  391. url: '',
  392. result: ''
  393. }
  394. },
  395. submit() {
  396. this.beginExecute(row)
  397. },
  398. selection(val) {
  399. this.tableCheckItems = val
  400. },
  401. checkRelustList(row) {
  402. this.getFaultDiagnosisResultAPI({ sortieNo: row.sortieNo })
  403. this.resultVisible = true
  404. },
  405. async checkRelustShow(row) {
  406. const { data } = await getListByIdsApi(JSON.parse(row.resultContent).ossId)
  407. this.resultShowData.url = data[0].url
  408. this.resultShowData.result = JSON.parse(row.resultContent).result
  409. this.resultShowVisible = true
  410. },
  411. async getImgUrl(ossId) {
  412. const { data } = await getListByIdsApi(ossId)
  413. const newUrl = data[0].url
  414. return newUrl
  415. },
  416. async beginExecute(row) {
  417. this.progressVisible = true
  418. let myTimer = setInterval(() => {
  419. if (this.percentage < 100) {
  420. if (this.percentage === 99) {
  421. this.percentage = 99
  422. } else {
  423. this.percentage += 1
  424. }
  425. }
  426. }, 30)
  427. try {
  428. this.form.dataId = row.id
  429. const res = await executeFault(this.form)
  430. clearInterval(myTimer)
  431. if (res?.code === 200) {
  432. this.percentage = 100
  433. this.$message({
  434. type: 'success',
  435. message: '执行成功!'
  436. })
  437. // const { data } = await getListByIdsApi(JSON.parse(res.data).ossId)
  438. // this.resultShowData.url = data[0].url
  439. // this.resultShowData.result = JSON.parse(res.data).result
  440. // this.resultShowVisible = true
  441. this.resultVisible = true
  442. this.getFaultDiagnosisResultAPI({ sortieNo: this.currentSortieNo })
  443. this.getDataImportAPI({ aircraftId: this.aircaftModelIdList })
  444. this.handleClose()
  445. }
  446. } catch (error) {
  447. clearInterval(myTimer)
  448. } finally {
  449. this.progressVisible = false
  450. this.percentage = 0
  451. }
  452. }
  453. }
  454. }
  455. </script>
  456. <style lang="scss" scoped>
  457. @import '../index.scss';
  458. </style>