Station.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. createEquip, //数据中心创建设备
  16. createPart, //数据中心创建部件
  17. updateProperty, //数据中心更新资产
  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 pa = {
  46. Content:[{
  47. BuildingId: this.itemObj.BuildingId,
  48. Category: this.value,
  49. BIMID: this.itemObj.BIMID || '',
  50. BIMLocation: this.itemObj.BIMLocation || '',
  51. FloorId: this.itemObj.FloorId || ''
  52. }]
  53. }
  54. if (pa.Content[0].Category.length == 6) {
  55. createPart(pa, res => {
  56. this.upDateTableMain(res.EntityList[0].EquipID)
  57. })
  58. } else {
  59. createEquip(pa, res => {
  60. this.upDateTableMain(res.EntityList[0].EquipID)
  61. })
  62. }
  63. } else {
  64. this.$message({
  65. message: '请选择设备类后再进行关联',
  66. type: 'warning'
  67. })
  68. }
  69. },
  70. //关联资产
  71. upDateTableMain(id) {
  72. let pa = {
  73. Content:[this.itemObj]
  74. };
  75. let that = this
  76. pa.Content[0].EquipmentId = id
  77. updateProperty(pa, res => {
  78. that.dialogVisible = false;
  79. that.$emit('refresh')
  80. })
  81. }
  82. },
  83. watch: {
  84. options: {
  85. deep: true,
  86. handler(val) {
  87. this.value = ''
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped lang='less'>
  94. .add-box {
  95. height: 100px;
  96. }
  97. </style>