SMTaskDetails.vue 18 KB

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