index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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">
  9. <el-button type="success" @click="openDialog()" :disabled="!(currentNode.type == 1 && currentNode.children.length == 0)">新增</el-button>
  10. <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length == 0">删除</el-button>
  11. </div>
  12. <div class="view-dataType-title-search">
  13. <el-input placeholder="请输入架次号" v-model="keyWordData" class="input1">
  14. <el-button slot="append" icon="el-icon-search" @click="searchClick" :disabled="!(currentNode.type == 1 && currentNode.children.length == 0)"></el-button>
  15. </el-input>
  16. </div>
  17. </div>
  18. <div class="view-dataType-table">
  19. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  20. </div>
  21. <!-- 添加或修改故障诊断对话框 -->
  22. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="1000px" :before-close="handleClose">
  23. <el-form ref="executeForm" :model="executeForm" label-width="80px">
  24. <el-row>
  25. <el-col :span="8">
  26. <el-form-item label="编目" prop="aircraftId">
  27. <el-select v-model="executeForm.aircraftId" placeholder="请选择编目" @change="changeAircraftId(executeForm.aircraftId)" disabled>
  28. <el-option v-for="item in aircaftCatalogAll" :key="item.aircaftCatalogId" :label="item.aircaftCatalogCode" :value="item.aircaftCatalogId"> </el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="8">
  33. <el-form-item label="模型类型" prop="modelType">
  34. <el-select v-model="executeForm.modelType" placeholder="请选择模型类型" @change="changeModelType(executeForm.modelType)">
  35. <el-option v-for="item in algoTypeList" :key="item.id" :label="item.name" :value="item.id" />
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="模型" prop="modelId">
  41. <el-select v-model="executeForm.modelId" placeholder="请选择模型" @change="changeModelId(executeForm.modelId)">
  42. <el-option v-for="item in modelList" :key="item.id" :label="item.name" :value="item.id" />
  43. </el-select> </el-form-item
  44. ></el-col>
  45. </el-row>
  46. <el-form-item label="架次号" prop="sortieNo">
  47. <LTable ref="sortieNoTableRef" @current-change="sortieNoSelection" class="single-select-table" :columns="sortieNoColumns" :dataSource="sortieNoList" :options="sortieNoOptions" :pagination="SortieNoTableRequset"></LTable>
  48. </el-form-item>
  49. <el-form-item label="参数" prop="param">
  50. <el-input v-model="executeForm.param" type="textarea" :rows="2" placeholder="请输入参数" />
  51. </el-form-item>
  52. <el-form-item label="数据列" prop="columnData">
  53. <el-transfer v-model="transferRightData" :data="transferData" @change="changeColumnData"></el-transfer>
  54. </el-form-item>
  55. <!-- <el-form-item label="文件Id" prop="ossId">
  56. <el-input v-model="form.ossId" placeholder="请输入文件Id" />
  57. </el-form-item>
  58. <el-form-item label="结果">
  59. <editor v-model="form.resultContent" :min-height="192" />
  60. </el-form-item>-->
  61. </el-form>
  62. <span slot="footer" class="dialog-footer">
  63. <el-button @click="handleClose">取 消</el-button>
  64. <el-button type="primary" @click="submit">确 定</el-button>
  65. </span>
  66. </el-dialog>
  67. <el-dialog title="执行进度" :visible.sync="progressVisible" width="800px" :before-close="handleClose">
  68. <el-progress :text-inside="true" :stroke-width="24" :percentage="percentage" status="success"></el-progress>
  69. </el-dialog>
  70. <el-dialog title="结果展示" :visible.sync="resultVisible" width="800px">
  71. 展示结果
  72. <span slot="footer" class="dialog-footer">
  73. <el-button @click="resultVisible = false">取 消</el-button>
  74. <el-button type="primary" @click="resultVisible = false">确 定</el-button>
  75. </span>
  76. </el-dialog>
  77. </div>
  78. </div>
  79. </template>
  80. <script>
  81. import { getFaultDiagnosis, addFaultDiagnosis, updateFaultDiagnosis, removeFaultDiagnosis } from '@/api/als/faultDiagnosis'
  82. import { getColumnDataAPI, executeFault } from '@/api/als/algorithm'
  83. import { getAircaftCatalogTree } from '@/api/als/sideTree'
  84. import { deepClone, debounce } from '@/utils/index'
  85. import { getAircaftCatalogAll } from '@/api/als/aircraft'
  86. import { getDataImport } from '@/api/als/dataImport'
  87. import { getModel } from '@/api/als/model'
  88. export default {
  89. name: 'FaultDiagnosis',
  90. components: {},
  91. data() {
  92. // 这里存放数据
  93. return {
  94. dialogTitle: '新增',
  95. dialogVisible: false,
  96. resultVisible: false,
  97. progressVisible: false,
  98. keyWordData: '',
  99. aircaftModelIdList: [],
  100. currentNodeKey: '',
  101. currentNode: {},
  102. menuTreeData: [],
  103. treeObj: {
  104. title: '所属机种',
  105. activityheight: '275px',
  106. searchIcon: false,
  107. configure: {
  108. children: 'children',
  109. label: 'label'
  110. }
  111. },
  112. typeTree: {
  113. children: 'children',
  114. label: 'label'
  115. },
  116. searchValue: '',
  117. columns: [
  118. { prop: 'id', label: '编号' },
  119. {
  120. prop: 'sortieNo',
  121. label: '架次号'
  122. },
  123. {
  124. prop: 'aircraftId',
  125. label: '编目',
  126. render: (h, params) => {
  127. const matchedItem = this.aircaftCatalogAll.find((item) => params.row.aircraftId.trim() === item.aircaftCatalogId.trim())
  128. if (matchedItem) {
  129. return h('span', matchedItem.aircaftCatalogCode)
  130. } else {
  131. return h('span', {}, '')
  132. }
  133. }
  134. },
  135. {
  136. prop: 'modelType',
  137. label: '模型类型'
  138. },
  139. {
  140. prop: 'param',
  141. label: '参数'
  142. },
  143. {
  144. prop: 'columnData',
  145. label: '数据列'
  146. },
  147. // {
  148. // prop: 'ossId',
  149. // label: '文件Id'
  150. // },
  151. {
  152. prop: 'resultContent',
  153. label: '结果'
  154. },
  155. {
  156. prop: 'status',
  157. label: '状态'
  158. },
  159. {
  160. prop: 'modelType1',
  161. label: '模型类型'
  162. },
  163. {
  164. prop: 'param1',
  165. label: '参数'
  166. },
  167. {
  168. prop: 'columnData1',
  169. label: '数据列'
  170. },
  171. {
  172. button: true,
  173. label: '操作',
  174. width: '240px',
  175. group: [
  176. {
  177. name: '查看',
  178. type: 'text',
  179. round: false,
  180. plain: false,
  181. onClick: (row, index, scope) => {
  182. this.checkResultList(row)
  183. }
  184. },
  185. {
  186. name: '执行',
  187. type: 'text',
  188. round: false,
  189. plain: false,
  190. onClick: (row, index, scope) => {
  191. this.executeAglo(row)
  192. }
  193. },
  194. {
  195. name: '删除',
  196. type: 'text',
  197. round: false,
  198. plain: false,
  199. onClick: (row, index, scope) => {
  200. this.remove([row])
  201. }
  202. }
  203. ]
  204. }
  205. ],
  206. sortieNoColumns: [
  207. {
  208. prop: 'sortieNo',
  209. label: '架次号'
  210. },
  211. {
  212. prop: 'source',
  213. label: '数据来源'
  214. },
  215. {
  216. prop: 'ossId',
  217. label: '文件Id'
  218. }
  219. ],
  220. options: {
  221. stripe: true, // 斑马纹
  222. mutiSelect: true, // 多选框
  223. index: false, // 显示序号, 多选则 mutiSelect
  224. loading: false, // 表格动画
  225. initTable: false, // 是否一挂载就加载数据
  226. border: true,
  227. height: 'calc(100vh - 300px)'
  228. },
  229. sortieNoOptions: {
  230. stripe: true, // 斑马纹
  231. mutiSelect: false, // 多选框
  232. index: true, // 显示序号, 多选则 mutiSelect
  233. loading: false, // 表格动画
  234. initTable: false, // 是否一挂载就加载数据
  235. border: true,
  236. height: '250px'
  237. },
  238. SortieNoTableRequset: {
  239. total: 0,
  240. pageIndex: 1,
  241. pageSize: 10,
  242. searchValue: ''
  243. },
  244. tableCheckItems: [],
  245. tableData: [],
  246. tableRequset: {
  247. total: 0,
  248. pageIndex: 1,
  249. pageSize: 10,
  250. searchValue: ''
  251. },
  252. form: {
  253. id: '',
  254. sortieNo: '',
  255. aircraftId: '',
  256. modelType: '',
  257. param: '',
  258. columnData: [],
  259. ossId: '',
  260. resultContent: '',
  261. status: '',
  262. tenantId: '',
  263. version: '',
  264. delFlag: '',
  265. createBy: '',
  266. createTime: '',
  267. updateBy: '',
  268. updateTime: ''
  269. },
  270. debounceFn: debounce(this.fetch, 500),
  271. executeForm: {
  272. sortieNo: '',
  273. aircraftId: '',
  274. ossId: '',
  275. modelId: '',
  276. param: '',
  277. columnData: []
  278. },
  279. aircaftCatalogAll: [],
  280. transferData: [],
  281. transferRightData: [],
  282. algoTypeList: [{ id: 5, name: '故障诊断' }],
  283. modelList: [],
  284. percentage: 0,
  285. sortieNoList: []
  286. }
  287. },
  288. watch: {
  289. keyWord() {
  290. this.tableRequset.pageIndex = 1
  291. this.debounceFn()
  292. }
  293. },
  294. mounted() {
  295. this.getAircaftCatalogTreeAPI()
  296. },
  297. methods: {
  298. async getAircaftCatalogTreeAPI(params) {
  299. try {
  300. const { data } = await getAircaftCatalogTree(params)
  301. this.menuTreeData = data
  302. const getAircaftCatalogAllParams = {
  303. keyWord: '',
  304. aircaftModelIdList: []
  305. }
  306. const { data: data2 } = await getAircaftCatalogAll(getAircaftCatalogAllParams)
  307. this.aircaftCatalogAll = data2
  308. if (data.length) {
  309. this.currentNodeKey = data[0].id
  310. this.currentNode = data[0]
  311. this.aircaftModelIdList = this.getTreeLeafData(data[0]?.children)
  312. .map((e) => e.id)
  313. .toString()
  314. this.getFaultDiagnosisAPI({ aircraftId: this.aircaftModelIdList })
  315. // this.getDataImportAPI()
  316. }
  317. } catch (error) {}
  318. },
  319. async removeFaultDiagnosisAPI(params) {
  320. try {
  321. const { code } = await removeFaultDiagnosis(params)
  322. if (code === 200) {
  323. this.$message({
  324. type: 'success',
  325. message: '操作成功!'
  326. })
  327. await this.getFaultDiagnosisAPI({ aircraftId: this.aircaftModelIdList })
  328. this.handleClose()
  329. }
  330. } catch (error) {}
  331. },
  332. getTreeLeafData(list) {
  333. const newArr = []
  334. function getLeaf(data, arr) {
  335. data.forEach((e) => {
  336. if (e.type === 1) {
  337. arr.push(e)
  338. }
  339. if (e.children.length) {
  340. getLeaf(e.children, arr)
  341. }
  342. })
  343. }
  344. getLeaf(list, newArr)
  345. return newArr
  346. },
  347. async getFaultDiagnosisAPI(params) {
  348. if (this.$refs.table) this.$refs.table.clearSelection()
  349. const { keyWord } = this
  350. const { pageSize, pageIndex } = this.tableRequset
  351. const {
  352. data: { list, total }
  353. } = await getFaultDiagnosis({ pageSize, pageNum: pageIndex, ...params })
  354. this.tableData = list
  355. this.tableRequset.total = total
  356. },
  357. fetch() {
  358. this.getFaultDiagnosisAPI(this.currentNodeKey)
  359. },
  360. searchClick() {
  361. this.getFaultDiagnosisAPI({ aircraftId: this.aircaftModelIdList, sortieNo: this.keyWordData })
  362. },
  363. async addFaultDiagnosisAPI() {
  364. try {
  365. delete this.form.aircaftModelName
  366. const { code } = await addFaultDiagnosis({ ...this.form })
  367. if (code === 200) {
  368. this.$message({
  369. type: 'success',
  370. message: '操作成功!'
  371. })
  372. }
  373. } catch (error) {}
  374. },
  375. async updateFaultDiagnosisAPI() {
  376. try {
  377. const { code } = await updateFaultDiagnosis({ ...this.form })
  378. if (code === 200) {
  379. this.$message({
  380. type: 'success',
  381. message: '操作成功!'
  382. })
  383. this.getFaultDiagnosisAPI({ aircraftId: this.aircaftModelIdList })
  384. }
  385. } catch (error) {}
  386. },
  387. treeNodeClick(data) {
  388. this.$refs.table.clearSelection()
  389. this.currentNodeKey = this.executeForm.aircraftId = data.id
  390. this.currentNode = data
  391. this.aircaftModelIdList = this.getTreeLeafData(data.children.length ? data.children : [data])
  392. .map((e) => e.id)
  393. .toString()
  394. this.getFaultDiagnosisAPI({ aircraftId: this.aircaftModelIdList })
  395. // this.getDataImportAPI(this.currentNodeKey)
  396. },
  397. openDialog() {
  398. this.executeForm.aircraftId = this.currentNodeKey
  399. if (this.executeForm.aircraftId !== '') {
  400. this.changeAircraftId(this.executeForm.aircraftId)
  401. }
  402. this.dialogTitle = '新增'
  403. this.dialogVisible = true
  404. },
  405. handleClose() {
  406. this.dialogVisible = false
  407. this.executeForm = {
  408. sortieNo: '',
  409. aircraftId: '',
  410. ossId: '',
  411. modelId: '',
  412. param: '',
  413. columnData: []
  414. }
  415. },
  416. handUpdate(row) {
  417. this.dialogTitle = '编辑'
  418. this.form = deepClone(row)
  419. this.dialogVisible = true
  420. },
  421. changeColumnData(value) {
  422. const data = []
  423. this.transferData.forEach((item) => {
  424. value.forEach((rightData) => {
  425. if (rightData === item.key) {
  426. data.push(item.label)
  427. }
  428. })
  429. })
  430. this.executeForm.columnData = data
  431. },
  432. changeModelId(modelId) {
  433. const modelColumnData = JSON.parse(
  434. this.modelList.find((item) => {
  435. return item.id === modelId
  436. }).columnData
  437. )
  438. const labelToKeyMap = this.transferData.reduce((acc, item) => {
  439. acc[item.label] = item.key
  440. return acc
  441. }, {})
  442. modelColumnData?.forEach((item) => {
  443. if (labelToKeyMap.hasOwnProperty(item)) {
  444. this.executeForm.columnData.push(item)
  445. this.transferRightData.push(labelToKeyMap[item])
  446. }
  447. })
  448. },
  449. checkResultList(row) {
  450. this.form = deepClone(row)
  451. this.resultVisible = true
  452. },
  453. executeAglo(row) {
  454. // this.executeVisible = true
  455. // this.agloForm.sortieNo = row.sortieNo
  456. // this.agloForm.aircraftId = row.aircraftId
  457. },
  458. async beginExecute() {
  459. this.progressVisible = true
  460. try {
  461. const res = await executeFault(this.executeForm)
  462. this.percentage += 1
  463. const myTimer = setInterval(() => {
  464. if (res?.code === 200 && this.percentage == 100) {
  465. this.progressVisible = false
  466. clearInterval(myTimer)
  467. this.percentage = 0
  468. this.handleClose()
  469. this.$message({
  470. type: 'success',
  471. message: '执行成功!'
  472. })
  473. this.getFaultDiagnosisAPI({ aircraftId: this.aircaftModelIdList })
  474. } else {
  475. this.percentage += 1
  476. }
  477. }, 30)
  478. } catch (error) {
  479. this.progressVisible = false
  480. clearInterval(myTimer)
  481. this.percentage = 0
  482. }
  483. },
  484. async changeModelType(type) {
  485. try {
  486. const {
  487. data: { list }
  488. } = await getModel({ type })
  489. this.modelList = list
  490. } catch (error) {}
  491. },
  492. async changeAircraftId(aircraftId) {
  493. try {
  494. const {
  495. data: { list }
  496. } = await getDataImport({ aircraftId })
  497. this.sortieNoList = list
  498. } catch (error) {}
  499. },
  500. async sortieNoSelection(val) {
  501. this.executeForm.ossId = val.ossId
  502. this.executeForm.sortieNo = val.sortieNo
  503. if (val.ossId) {
  504. const res = await getColumnDataAPI(val.ossId)
  505. if (res.code === 200) {
  506. this.transferData = []
  507. res.data.forEach((item, index) => {
  508. this.transferData.push({
  509. key: index,
  510. label: item
  511. })
  512. })
  513. }
  514. }
  515. },
  516. submit() {
  517. switch (this.dialogTitle) {
  518. case '编辑':
  519. this.updateFaultDiagnosisAPI()
  520. this.handleClose()
  521. break
  522. case '新增':
  523. this.beginExecute()
  524. break
  525. }
  526. },
  527. selection(val) {
  528. this.tableCheckItems = val
  529. },
  530. remove(row) {
  531. this.$confirm('是否删除该数据', '提示', {
  532. confirmButtonText: '确定',
  533. cancelButtonText: '取消',
  534. type: 'warning'
  535. })
  536. .then(() => {
  537. this.removeFaultDiagnosisAPI(row.map((e) => e.id))
  538. })
  539. .catch(() => {})
  540. }
  541. }
  542. }
  543. </script>
  544. <style lang="scss" scoped>
  545. @import '../index.scss';
  546. </style>