index.vue 13 KB

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