Blame view

src/components/room/editUnit.vue 3.81 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
af1bcbd6   wuxw   房屋页面开发中
2
3
4
5
6
7
    <el-dialog
      :title="$t('editUnit.title')"
      :visible.sync="visible"
      width="50%"
      :before-close="handleClose"
    >
7caa1e00   wuxw   v1.9 优化添加单元乱码问题
8
9
      <el-form ref="form" :model="editUnitInfo" :rules="rules" label-width="120px">
        <el-form-item :label="$t('editUnit.unitNum')" prop="unitNum">
af1bcbd6   wuxw   房屋页面开发中
10
11
12
13
14
15
          <el-input
            v-model="editUnitInfo.unitNum"
            :placeholder="$t('editUnit.unitNumPlaceholder')"
          ></el-input>
        </el-form-item>
        
7caa1e00   wuxw   v1.9 优化添加单元乱码问题
16
        <el-form-item :label="$t('editUnit.layerCount')" prop="layerCount">
af1bcbd6   wuxw   房屋页面开发中
17
18
19
20
21
22
23
          <el-input
            v-model.number="editUnitInfo.layerCount"
            type="number"
            :placeholder="$t('editUnit.layerCountPlaceholder')"
          ></el-input>
        </el-form-item>
        
7caa1e00   wuxw   v1.9 优化添加单元乱码问题
24
        <el-form-item :label="$t('editUnit.unitArea')" prop="unitArea">
af1bcbd6   wuxw   房屋页面开发中
25
26
27
28
29
30
          <el-input
            v-model="editUnitInfo.unitArea"
            :placeholder="$t('editUnit.unitAreaPlaceholder')"
          ></el-input>
        </el-form-item>
        
7caa1e00   wuxw   v1.9 优化添加单元乱码问题
31
        <el-form-item :label="$t('editUnit.lift')" prop="lift">
af1bcbd6   wuxw   房屋页面开发中
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
          <el-select 
            v-model="editUnitInfo.lift" 
            :placeholder="$t('editUnit.liftPlaceholder')"
            style="width: 100%"
          >
            <el-option 
              :label="$t('editUnit.liftOption1')" 
              value="1010"
            ></el-option>
            <el-option 
              :label="$t('editUnit.liftOption2')" 
              value="2020"
            ></el-option>
          </el-select>
        </el-form-item>
        
        <el-form-item :label="$t('editUnit.remark')">
          <el-input
            v-model="editUnitInfo.remark"
            type="textarea"
            :rows="3"
            :placeholder="$t('editUnit.remarkPlaceholder')"
          ></el-input>
        </el-form-item>
      </el-form>
      
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">{{ $t('editUnit.cancel') }}</el-button>
        <el-button type="primary" @click="editUnit">{{ $t('editUnit.save') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { updateUnit } from '@/api/room/editUnitApi'
  
  export default {
    name: 'EditUnit',
    data() {
      return {
        visible: false,
        editUnitInfo: {
          floorId: '',
          unitId: '',
          unitNum: '',
          layerCount: '',
          lift: '',
          remark: '',
          communityId: '',
          unitArea: ''
7caa1e00   wuxw   v1.9 优化添加单元乱码问题
82
83
84
85
86
87
88
89
90
91
92
93
94
95
        },
        rules: {
          unitNum: [
            { required: true, message: this.$t('editUnit.unitNumRequired'), trigger: 'blur' }
          ],
          layerCount: [
            { required: true, message: this.$t('editUnit.layerCountRequired'), trigger: 'blur' }
          ],
          unitArea: [
            { required: true, message: this.$t('editUnit.unitAreaRequired'), trigger: 'blur' }
          ],
          lift: [
            { required: true, message: this.$t('editUnit.liftRequired'), trigger: 'change' }
          ]
af1bcbd6   wuxw   房屋页面开发中
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        }
      }
    },
    methods: {
      open(params) {
        Object.assign(this.editUnitInfo, params)
        this.editUnitInfo.communityId = this.getCommunityId()
        this.visible = true
      },
      handleClose() {
        this.visible = false
      },
      validateForm() {
        return new Promise((resolve) => {
          this.$refs.form.validate((valid) => {
            resolve(valid)
          })
        })
      },
      async editUnit() {
        const isValid = await this.validateForm()
        if (!isValid) return
        
        if (this.editUnitInfo.unitNum === '0') {
          this.$message.warning(this.$t('editUnit.zeroUnitWarning'))
          return
        }
        
        try {
          await updateUnit(this.editUnitInfo)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
126
          this.$message.success(this.$t('common.operationSuccess'))
81955f61   wuxw   优化房屋页面
127
128
          this.$emit('handleRefreshTree', {})
  
af1bcbd6   wuxw   房屋页面开发中
129
130
131
132
133
134
135
136
137
          this.handleClose()
        } catch (error) {
          console.error('修改单元失败:', error)
          this.$message.error(error.message || this.$t('editUnit.errorMessage'))
        }
      }
    }
  }
  </script>