index.vue 15 KB

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