PowerConfigDialog.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <confirm-dialog
  3. ref="configDialog"
  4. title="电源标签"
  5. @confirm="onSave"
  6. >
  7. <div class="c-grid-form auto u-align-self--center">
  8. <div class="c-grid-form__label">屏体电源标签</div>
  9. <el-input v-model.trim="config.power1" />
  10. <div class="c-grid-form__label">风机电源标签</div>
  11. <el-input v-model.trim="config.power2" />
  12. </div>
  13. </confirm-dialog>
  14. </template>
  15. <script>
  16. import {
  17. POWERTYPE,
  18. getTenantAttribute,
  19. updateTenantAttribute
  20. } from '../api'
  21. export default {
  22. name: 'PowerConfigDialog',
  23. data () {
  24. return {
  25. config: {
  26. power1: '',
  27. power2: ''
  28. }
  29. }
  30. },
  31. methods: {
  32. show () {
  33. getTenantAttribute(POWERTYPE).then(({ data }) => {
  34. if (data) {
  35. this.$temp = data.attributeValue
  36. this.$temp.split(',').forEach((val, index) => {
  37. this.config[`power${index + 1}`] = val
  38. })
  39. } else {
  40. this.$temp = ''
  41. }
  42. this.$refs.configDialog.show()
  43. })
  44. },
  45. onSave (done) {
  46. if (!this.config.power1) {
  47. this.$message({
  48. type: 'warning',
  49. message: '请配置屏体电源标签'
  50. })
  51. }
  52. if (!this.config.power2) {
  53. this.$message({
  54. type: 'warning',
  55. message: '请配置风机电源标签'
  56. })
  57. }
  58. const val = [
  59. this.config.power1,
  60. this.config.power2
  61. ].join(',')
  62. if (this.$temp === val) {
  63. done()
  64. return
  65. }
  66. updateTenantAttribute(POWERTYPE, val).then(done)
  67. }
  68. }
  69. }
  70. </script>