index.vue 16 KB

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