Station.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <el-dialog title='添加对应岗位' :visible.sync='dialogVisible' width='500px'>
  3. <div class='add-box'>
  4. <el-select v-model='value' placeholder='资产设备族对应的设备类' clearable style="width: 300px">
  5. <el-option v-for='item in options' :key='item.code' :label='item.name' :value='item.code'></el-option>
  6. </el-select>
  7. </div>
  8. <span slot='footer' class='dialog-footer'>
  9. <el-button type='primary' @click='save'>确定创建对应岗位</el-button>
  10. </span>
  11. </el-dialog>
  12. </template>
  13. <script>
  14. import {
  15. createPost, //新建岗位
  16. upDateTableMain, //关联资产
  17. createComponent //新建岗位(部件)
  18. } from '@/api/scan/request'
  19. import { mapGetters } from 'vuex'
  20. export default {
  21. name: 'saga-station',
  22. data() {
  23. return {
  24. dialogVisible: false,
  25. value: ''
  26. }
  27. },
  28. computed: {
  29. ...mapGetters('layout', ['projectId', 'secret', 'userId'])
  30. },
  31. props: {
  32. options: {
  33. default: []
  34. },
  35. itemObj: {
  36. default: {}
  37. }
  38. },
  39. methods: {
  40. show() {
  41. this.dialogVisible = true
  42. },
  43. save() {
  44. if (this.value) {
  45. let param = {
  46. BuildId: this.itemObj.BuildId,
  47. category: this.value,
  48. secret: this.secret,
  49. perjectId: this.projectId,
  50. BIMID: this.itemObj.FloorId,
  51. BIMLocation: (this.itemObj.X || 0) + ',' + (this.itemObj.Y || 0) + ',' + (this.itemObj.Z || 0)
  52. }
  53. if (param.category.length == 6) {
  54. createComponent(param).then(res => {
  55. if (res.data.Result == 'success') {
  56. this.upDateTableMain(res.data.id)
  57. } else {
  58. this.$message({
  59. message: res.data.ResultMsg,
  60. type: 'warning'
  61. })
  62. }
  63. })
  64. } else {
  65. createPost(param).then(res => {
  66. if (res.data.Result == 'success') {
  67. this.upDateTableMain(res.data.id)
  68. } else {
  69. this.$message({
  70. message: res.data.ResultMsg,
  71. type: 'warning'
  72. })
  73. }
  74. })
  75. }
  76. } else {
  77. this.$message({
  78. message: '请选择设备类后再进行关联',
  79. type: 'warning'
  80. })
  81. }
  82. },
  83. //关联资产
  84. upDateTableMain(id) {
  85. let param = {
  86. ProjId: this.projectId,
  87. UserId: this.userId
  88. },
  89. paramList = {}
  90. paramList.EquipmentId = id
  91. paramList.FmId = this.itemObj.FmId
  92. paramList.Family = this.itemObj.Family
  93. upDateTableMain(param, [paramList]).then(res => {
  94. if (res.data.Result == 'success') {
  95. this.$message({
  96. message: '保存成功',
  97. type: 'success'
  98. })
  99. this.dialogVisible = false
  100. this.$emit('refresh')
  101. } else {
  102. this.$message.error('请求失败')
  103. }
  104. })
  105. }
  106. },
  107. watch: {
  108. options: {
  109. deep: true,
  110. handler(val) {
  111. this.value = ''
  112. }
  113. }
  114. }
  115. }
  116. </script>
  117. <style scoped lang='less'>
  118. .add-box {
  119. height: 100px;
  120. }
  121. </style>