viewDetails.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <template>
  2. <div class="view-table-content">
  3. <div style="width: 80%; margin: auto">
  4. <el-descriptions size="medium" border>
  5. <el-descriptions-item label="机型">{{ maintenanceaskForm.aircraftType }}</el-descriptions-item>
  6. <el-descriptions-item label="机号">{{ maintenanceaskForm.aircraftCode }}</el-descriptions-item>
  7. <el-descriptions-item label="数据来源">{{ maintenanceaskForm.dataType }}</el-descriptions-item>
  8. <el-descriptions-item label="故障代码">{{ maintenanceaskForm.faultCode }}</el-descriptions-item>
  9. <el-descriptions-item label="故障描述">{{ maintenanceaskForm.faultDescription }}</el-descriptions-item>
  10. <el-descriptions-item label="故障位置">{{ maintenanceaskForm.location }}</el-descriptions-item>
  11. <el-descriptions-item :span="1" label="故障等级">{{ maintenanceaskForm.level }}</el-descriptions-item>
  12. <el-descriptions-item :span="2" label="故障现象">{{ maintenanceaskForm.symptoms }}</el-descriptions-item>
  13. <el-descriptions-item :span="3" label="故障原因">{{ maintenanceaskForm.faultCause }}</el-descriptions-item>
  14. </el-descriptions>
  15. <el-tabs type="card" v-model="tabActiveName" style="margin-top: 30px">
  16. <el-tab-pane label="资源分配" name="first">
  17. <div class="view-dataType-title">
  18. <div class="view-dataType-title-btn">
  19. <el-button type="success" @click="openDialog()">新增</el-button>
  20. <el-button type="warning" @click="remove(tableCheckItems)" :disabled="tableCheckItems.length == 0">删除</el-button>
  21. </div>
  22. </div>
  23. <div class="view-dataType-table">
  24. <LTable ref="table" @selection-change="selection" :defaultFetch="false" :fetch="fetch" :columns="columns" :dataSource="tableData" :options="options" :pagination="tableRequset"></LTable>
  25. </div>
  26. </el-tab-pane>
  27. <el-tab-pane label="任务派遣" name="second">
  28. <div class="view-dataType-title">
  29. <div class="view-dataType-title-btn">
  30. <el-button type="success" @click="openDialog2()">新增</el-button>
  31. <el-button type="warning" @click="remove(tableCheckItems2)" :disabled="tableCheckItems2.length == 0">删除</el-button>
  32. </div>
  33. </div>
  34. <div class="view-dataType-table">
  35. <LTable ref="table2" @selection-change="selection2" :defaultFetch="false" :fetch="fetch2" :columns="columns2" :dataSource="tableData2" :options="options" :pagination="tableRequset2"></LTable>
  36. </div>
  37. </el-tab-pane>
  38. </el-tabs>
  39. <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px" :before-close="handleClose">
  40. <el-form ref="form" :model="form" label-width="80px" style="height: 50vh; overflow-y: scroll">
  41. <!-- <el-form-item label="任务" prop="taskId">
  42. <el-input v-model="form.taskId" placeholder="请输入任务" />
  43. </el-form-item> -->
  44. <el-form-item label="设备名称" prop="deviceName">
  45. <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
  46. </el-form-item>
  47. <el-form-item label="型号" prop="modelNumber">
  48. <el-input v-model="form.modelNumber" placeholder="请输入型号" />
  49. </el-form-item>
  50. <el-form-item label="设备编码" prop="deviceCode">
  51. <el-input v-model="form.deviceCode" placeholder="请输入设备编码" />
  52. </el-form-item>
  53. <el-form-item label="类型" prop="type">
  54. <el-input v-model="form.type" placeholder="请输入类型" />
  55. </el-form-item>
  56. <el-form-item label="数量" prop="quantity">
  57. <el-input v-model="form.quantity" placeholder="请输入数量" />
  58. </el-form-item>
  59. <el-form-item label="备注" prop="remarks">
  60. <el-input v-model="form.remarks" type="textarea" :rows="2" 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. </el-dialog>
  68. <el-dialog :title="dialogTitle2" :visible.sync="dialogVisible2" width="600px" :before-close="handleClose2">
  69. <el-form ref="form2" :model="form2" label-width="80px" style="height: 50vh; overflow-y: scroll">
  70. <!-- <el-form-item label="任务" prop="taskId">
  71. <el-input v-model="form.taskId" placeholder="请输入任务" />
  72. </el-form-item> -->
  73. <el-form-item label="人员" prop="deviceName">
  74. <el-input v-model="form2.personnel" placeholder="请输入人员" />
  75. </el-form-item>
  76. <el-form-item label="岗位" prop="position">
  77. <el-input v-model="form2.position" placeholder="请输入岗位" />
  78. </el-form-item>
  79. <el-form-item label="数量" prop="quantity">
  80. <el-input v-model="form2.quantity" placeholder="请输入数量" />
  81. </el-form-item>
  82. <el-form-item label="职责" prop="duties">
  83. <el-input v-model="form2.duties" placeholder="请输入职责" />
  84. </el-form-item>
  85. <el-form-item label="备注" prop="remarks">
  86. <el-input v-model="form2.remarks" placeholder="请输入备注" />
  87. </el-form-item>
  88. </el-form>
  89. <span slot="footer" class="dialog-footer">
  90. <el-button @click="handleClose2">取 消</el-button>
  91. <el-button type="primary" @click="submit2">确 定</el-button>
  92. </span>
  93. </el-dialog>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import { getResourceAllocation, addResourceAllocation, updateResourceAllocation, removeResourceAllocation } from '@/api/als/resourceAllocation'
  99. import { getPersonnelAllocation, addPersonnelAllocation, updatePersonnelAllocation, removePersonnelAllocation } from '@/api/als/personnelAllocation'
  100. import { getMaintenanceaskInfo } from '@/api/als/maintenanceask'
  101. import { deepClone, debounce } from '@/utils/index'
  102. export default {
  103. name: 'ViewDetails',
  104. components: {},
  105. data() {
  106. // 这里存放数据
  107. return {
  108. dialogTitle: '新增',
  109. dialogTitle2: '新增',
  110. dialogVisible: false,
  111. dialogVisible2: false,
  112. keyWord: '',
  113. searchValue: '',
  114. columns: [
  115. { prop: 'id', label: '编号' },
  116. {
  117. prop: 'deviceName',
  118. label: '名称'
  119. },
  120. {
  121. prop: 'modelNumber',
  122. label: '型号'
  123. },
  124. {
  125. prop: 'deviceCode',
  126. label: '设备编码'
  127. },
  128. {
  129. prop: 'type',
  130. label: '类型'
  131. },
  132. {
  133. prop: 'quantity',
  134. label: '数量'
  135. },
  136. {
  137. prop: 'remarks',
  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.handUpdate(row)
  152. }
  153. },
  154. {
  155. name: '删除',
  156. type: 'text',
  157. round: false,
  158. plain: false,
  159. onClick: (row, index, scope) => {
  160. this.remove([row])
  161. }
  162. }
  163. ]
  164. }
  165. ],
  166. columns2: [
  167. { prop: 'id', label: '编号' },
  168. {
  169. prop: 'personnel',
  170. label: '人员'
  171. },
  172. {
  173. prop: 'position',
  174. label: '岗位'
  175. },
  176. {
  177. prop: 'quantity',
  178. label: '数量'
  179. },
  180. {
  181. prop: 'duties',
  182. label: '职责'
  183. },
  184. {
  185. prop: 'remarks',
  186. label: '备注'
  187. },
  188. {
  189. button: true,
  190. label: '操作',
  191. width: '240px',
  192. group: [
  193. {
  194. name: '编辑',
  195. type: 'text',
  196. round: false,
  197. plain: false,
  198. onClick: (row, index, scope) => {
  199. this.handUpdate2(row)
  200. }
  201. },
  202. {
  203. name: '删除',
  204. type: 'text',
  205. round: false,
  206. plain: false,
  207. onClick: (row, index, scope) => {
  208. this.remove([row])
  209. }
  210. }
  211. ]
  212. }
  213. ],
  214. options: {
  215. stripe: true, // 斑马纹
  216. mutiSelect: true, // 多选框
  217. index: false, // 显示序号, 多选则 mutiSelect
  218. loading: false, // 表格动画
  219. initTable: false, // 是否一挂载就加载数据
  220. border: true,
  221. height: 'calc(100vh - 550px)'
  222. },
  223. tableCheckItems: [],
  224. tableCheckItems2: [],
  225. tableData: [],
  226. tableRequset: {
  227. total: 0,
  228. pageIndex: 1,
  229. pageSize: 10,
  230. searchValue: ''
  231. },
  232. tableRequset2: {
  233. total: 0,
  234. pageIndex: 1,
  235. pageSize: 10,
  236. searchValue: ''
  237. },
  238. tableData2: [],
  239. form: {
  240. id: '',
  241. taskId: '',
  242. deviceName: '',
  243. serialNumber: '',
  244. deviceCode: '',
  245. type: '',
  246. quantity: '',
  247. remarks: '',
  248. tenantId: '',
  249. version: '',
  250. delFlag: '',
  251. createBy: '',
  252. createTime: '',
  253. updateBy: '',
  254. updateTime: ''
  255. },
  256. form2: {
  257. id: '',
  258. taskId: '',
  259. personnel: '',
  260. position: '',
  261. quantity: '',
  262. remarks: '',
  263. tenantId: '',
  264. version: '',
  265. delFlag: '',
  266. createBy: '',
  267. createTime: '',
  268. updateBy: '',
  269. updateTime: ''
  270. },
  271. debounceFn: debounce(this.fetch, 500),
  272. maintenanceaskId: '',
  273. maintenanceaskForm: [],
  274. tabActiveName: 'first'
  275. }
  276. },
  277. watch: {
  278. keyWord() {
  279. this.tableRequset.pageIndex = 1
  280. this.debounceFn()
  281. },
  282. tabActiveName: {
  283. handler(val) {
  284. if (val === 'first') {
  285. this.getResourceAllocationAPI({ taskId: this.maintenanceaskId })
  286. } else {
  287. this.getPersonnelAllocationAPI({ taskId: this.maintenanceaskId })
  288. }
  289. }
  290. }
  291. },
  292. mounted() {
  293. this.getMaintenanceaskInfoAPI()
  294. },
  295. methods: {
  296. async getMaintenanceaskInfoAPI() {
  297. this.maintenanceaskId = this.$route.params.maintenanceaskId
  298. this.form.taskId = this.maintenanceaskId
  299. const res = await getMaintenanceaskInfo(this.maintenanceaskId)
  300. this.maintenanceaskForm = res.data
  301. console.log('this.maintenanceaskForm', this.maintenanceaskForm)
  302. this.getResourceAllocationAPI({ taskId: this.maintenanceaskId })
  303. },
  304. async removeResourceAllocationAPI(params) {
  305. try {
  306. const { code } = await removeResourceAllocation(params)
  307. if (code === 200) {
  308. this.$message({
  309. type: 'success',
  310. message: '操作成功!'
  311. })
  312. await this.getResourceAllocationAPI({ taskId: this.maintenanceaskId })
  313. this.handleClose()
  314. }
  315. } catch (error) {}
  316. },
  317. async removePersonnelAllocationAPI(params) {
  318. try {
  319. const { code } = await removePersonnelAllocation(params)
  320. if (code === 200) {
  321. this.$message({
  322. type: 'success',
  323. message: '操作成功!'
  324. })
  325. await this.getPersonnelAllocationAPI({ taskId: this.maintenanceaskId })
  326. this.handleClose()
  327. }
  328. } catch (error) {}
  329. },
  330. async getResourceAllocationAPI(params) {
  331. if (this.$refs.table) this.$refs.table.clearSelection()
  332. const { keyWord } = this
  333. const { pageSize, pageIndex } = this.tableRequset
  334. const {
  335. data: { list, totalCount }
  336. } = await getResourceAllocation({ pageSize, pageIndex, ...params })
  337. this.tableData = list
  338. this.tableRequset.total = totalCount
  339. },
  340. async getPersonnelAllocationAPI(params) {
  341. if (this.$refs.table2) this.$refs.table2.clearSelection()
  342. const { keyWord } = this
  343. const { pageSize, pageIndex } = this.tableRequset2
  344. const {
  345. data: { list, totalCount }
  346. } = await getPersonnelAllocation({ pageSize, pageIndex, ...params })
  347. this.tableData2 = list
  348. this.tableRequset2.total = totalCount
  349. },
  350. fetch() {
  351. this.getResourceAllocationAPI({ taskId: this.maintenanceaskId })
  352. },
  353. fetch2() {
  354. this.getPersonnelAllocationAPI({ taskId: this.maintenanceaskId })
  355. },
  356. async addResourceAllocationAPI() {
  357. try {
  358. delete this.form.aircaftModelName
  359. const { code } = await addResourceAllocation({ ...this.form })
  360. if (code === 200) {
  361. this.$message({
  362. type: 'success',
  363. message: '操作成功!'
  364. })
  365. this.getResourceAllocationAPI({ taskId: this.maintenanceaskId })
  366. }
  367. } catch (error) {}
  368. },
  369. async addPersonnelAllocationAPI() {
  370. try {
  371. delete this.form.aircaftModelName
  372. const { code } = await addPersonnelAllocation({ ...this.form2 })
  373. if (code === 200) {
  374. this.$message({
  375. type: 'success',
  376. message: '操作成功!'
  377. })
  378. this.getPersonnelAllocationAPI({ taskId: this.maintenanceaskId })
  379. }
  380. } catch (error) {}
  381. },
  382. async updateResourceAllocationAPI() {
  383. try {
  384. const { code } = await updateResourceAllocation({ ...this.form })
  385. if (code === 200) {
  386. this.$message({
  387. type: 'success',
  388. message: '操作成功!'
  389. })
  390. this.getResourceAllocationAPI({ taskId: this.maintenanceaskId })
  391. }
  392. } catch (error) {}
  393. },
  394. async updatePersonnelAllocationAPI() {
  395. try {
  396. const { code } = await updatePersonnelAllocation({ ...this.form2 })
  397. if (code === 200) {
  398. this.$message({
  399. type: 'success',
  400. message: '操作成功!'
  401. })
  402. this.getPersonnelAllocationAPI({ taskId: this.maintenanceaskId })
  403. }
  404. } catch (error) {}
  405. },
  406. openDialog() {
  407. this.dialogTitle = '新增'
  408. this.dialogVisible = true
  409. this.form.taskId = this.maintenanceaskId
  410. // this.form.aircraftId = { taskId: this.maintenanceaskId }
  411. // this.form.aircraftType = this.currentNode.label
  412. },
  413. openDialog2() {
  414. this.dialogTitle2 = '新增'
  415. this.dialogVisible2 = true
  416. this.form2.taskId = this.maintenanceaskId
  417. // this.form.aircraftId = { taskId: this.maintenanceaskId }
  418. // this.form.aircraftType = this.currentNode.label
  419. },
  420. handleClose() {
  421. this.dialogVisible = false
  422. this.form = {
  423. id: '',
  424. taskId: '',
  425. deviceName: '',
  426. serialNumber: '',
  427. deviceCode: '',
  428. type: '',
  429. quantity: '',
  430. remarks: '',
  431. tenantId: '',
  432. version: '',
  433. delFlag: '',
  434. createBy: '',
  435. createTime: '',
  436. updateBy: '',
  437. updateTime: ''
  438. }
  439. },
  440. handleClose2() {
  441. this.dialogVisible2 = false
  442. this.form2 = {
  443. id: '',
  444. taskId: '',
  445. personnel: '',
  446. position: '',
  447. quantity: '',
  448. remarks: '',
  449. tenantId: '',
  450. version: '',
  451. delFlag: '',
  452. createBy: '',
  453. createTime: '',
  454. updateBy: '',
  455. updateTime: ''
  456. }
  457. },
  458. handUpdate(row) {
  459. this.dialogTitle = '编辑'
  460. this.form = deepClone(row)
  461. this.dialogVisible = true
  462. },
  463. handUpdate2(row) {
  464. this.dialogTitle2 = '编辑'
  465. this.form2 = deepClone(row)
  466. this.dialogVisible2 = true
  467. },
  468. submit() {
  469. switch (this.dialogTitle) {
  470. case '编辑':
  471. this.updateResourceAllocationAPI()
  472. this.handleClose()
  473. break
  474. case '新增':
  475. this.addResourceAllocationAPI()
  476. this.handleClose()
  477. break
  478. }
  479. },
  480. submit2() {
  481. switch (this.dialogTitle) {
  482. case '编辑':
  483. this.updatePersonnelAllocationAPI()
  484. this.handleClose2()
  485. break
  486. case '新增':
  487. this.addPersonnelAllocationAPI()
  488. this.handleClose2()
  489. break
  490. }
  491. },
  492. selection(val) {
  493. this.tableCheckItems = val
  494. },
  495. selection2(val) {
  496. this.tableCheckItems2 = val
  497. },
  498. remove(row) {
  499. this.$confirm('是否删除该数据', '提示', {
  500. confirmButtonText: '确定',
  501. cancelButtonText: '取消',
  502. type: 'warning'
  503. })
  504. .then(() => {
  505. this.tabActiveName === 'first' ? this.removeResourceAllocationAPI(row.map((e) => e.id)) : this.removePersonnelAllocationAPI(row.map((e) => e.id))
  506. })
  507. .catch(() => {})
  508. }
  509. }
  510. }
  511. </script>
  512. <style lang="scss" scoped>
  513. @import '../index.scss';
  514. </style>