index.vue 16 KB

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