Blame view

src/components/machine/moveEquipment.vue 2.53 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
439c1b56   wuxw   开发完成设备台账功能
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    <el-dialog
      :title="$t('equipmentAccount.moveEquipment')"
      :visible.sync="dialogVisible"
      width="50%"
      @close="handleClose">
      <el-form ref="form" :model="formData" label-width="150px">
        <el-form-item :label="$t('equipmentAccount.newLocation')" prop="locationObjId" required>
          <el-input 
            v-model="formData.locationObjName" 
            :placeholder="$t('equipmentAccount.selectLocation')"
            readonly
            @click.native="showSpaceTree">
            <el-button slot="append" icon="el-icon-search" @click="showSpaceTree"></el-button>
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
      </span>
  
      <!-- 空间树选择器 -->
      <space-tree-dialog 
        ref="spaceTreeDialog"
        @select="handleSpaceSelect">
      </space-tree-dialog>
    </el-dialog>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { moveEquipment } from '@/api/machine/equipmentAccountApi'
  import SpaceTreeDialog from '@/components/common/SpaceTreeDialog'
  
  export default {
    name: 'MoveEquipment',
    components: {
      SpaceTreeDialog
    },
    data() {
      return {
        dialogVisible: false,
        communityId: '',
        formData: {
          machineId: '',
          locationObjId: '',
          locationObjName: '',
          communityId: ''
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
    },
    methods: {
      open(data) {
        this.formData = {
          machineId: data.machineId,
          locationObjId: '',
          locationObjName: '',
          communityId: this.communityId
        }
        this.dialogVisible = true
      },
      handleClose() {
        this.$refs.form.resetFields()
      },
      showSpaceTree() {
        this.$refs.spaceTreeDialog.open()
      },
      handleSpaceSelect(space) {
        this.formData.locationObjId = space.id
        this.formData.locationObjName = space.text
      },
      async handleSubmit() {
        try {
          if (!this.formData.locationObjId) {
            this.$message.warning(this.$t('equipmentAccount.selectLocationFirst'))
            return
          }
  
          await moveEquipment(this.formData)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
84
          this.$message.success(this.$t('common.operationSuccess'))
439c1b56   wuxw   开发完成设备台账功能
85
86
87
88
89
90
91
92
93
          this.dialogVisible = false
          this.$emit('success')
        } catch (error) {
          console.error('移动设备失败:', error)
        }
      }
    }
  }
  </script>