Blame view

src/components/inspection/EditInspectionRoute.vue 3.3 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
d367e130   wuxw   巡检功能测试
2
3
4
5
6
    <el-dialog :title="$t('inspectionRoute.editRouteTitle')" :visible.sync="visible" width="40%" @close="handleClose">
      <el-form ref="form" :model="editInspectionRouteInfo" :rules="rules" label-width="120px">
        <el-form-item :label="$t('inspectionRoute.routeName')" prop="routeName">
          <el-input v-model.trim="editInspectionRouteInfo.routeName"
            :placeholder="$t('inspectionRoute.routeNamePlaceholder')" clearable />
48ea9c43   wuxw   巡检开发完成
7
        </el-form-item>
d367e130   wuxw   巡检功能测试
8
9
10
        <el-form-item :label="$t('inspectionRoute.sequence')" prop="seq">
          <el-input v-model.number="editInspectionRouteInfo.seq" :placeholder="$t('inspectionRoute.sequencePlaceholder')"
            clearable />
48ea9c43   wuxw   巡检开发完成
11
        </el-form-item>
d367e130   wuxw   巡检功能测试
12
13
14
        <el-form-item :label="$t('inspectionRoute.remark')" prop="remark">
          <el-input v-model.trim="editInspectionRouteInfo.remark" :placeholder="$t('inspectionRoute.remarkPlaceholder')"
            type="textarea" :rows="3" clearable />
48ea9c43   wuxw   巡检开发完成
15
16
17
18
19
20
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose">
          {{ $t('common.cancel') }}
        </el-button>
d367e130   wuxw   巡检功能测试
21
        <el-button type="primary" @click="editInspectionRoute">
48ea9c43   wuxw   巡检开发完成
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
          {{ $t('common.save') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { getCommunityId } from '@/api/community/communityApi'
  import { updateInspectionRoute } from '@/api/inspection/inspectionRouteApi'
  
  export default {
    name: 'EditInspectionRoute',
    data() {
      return {
        visible: false,
        editInspectionRouteInfo: {
          inspectionRouteId: '',
          routeName: '',
          seq: 1,
          remark: ''
        },
        communityId: '',
        rules: {
          routeName: [
            { required: true, message: this.$t('inspectionRoute.routeNameRequired'), trigger: 'blur' },
            { max: 100, message: this.$t('inspectionRoute.routeNameMaxLength'), trigger: 'blur' }
          ],
          seq: [
            { required: true, message: this.$t('inspectionRoute.sequenceRequired'), trigger: 'blur' },
48ea9c43   wuxw   巡检开发完成
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
          ],
          remark: [
            { max: 200, message: this.$t('inspectionRoute.remarkMaxLength'), trigger: 'blur' }
          ],
          inspectionRouteId: [
            { required: true, message: this.$t('inspectionRoute.routeIdRequired'), trigger: 'blur' }
          ]
        }
      }
    },
    created() {
      this.communityId = getCommunityId()
    },
    methods: {
      open(route) {
        this.visible = true
        this.editInspectionRouteInfo = { ...route }
        this.editInspectionRouteInfo.communityId = this.communityId
        this.$nextTick(() => {
          this.$refs.form.clearValidate()
        })
      },
      async editInspectionRoute() {
        try {
          await this.$refs.form.validate()
d367e130   wuxw   巡检功能测试
76
  
48ea9c43   wuxw   巡检开发完成
77
          await updateInspectionRoute(this.editInspectionRouteInfo)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
78
          this.$message.success(this.$t('common.operationSuccess'))
48ea9c43   wuxw   巡检开发完成
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
          this.$emit('success')
          this.handleClose()
        } catch (error) {
          if (error !== 'validate') {
            console.error('修改巡检路线失败:', error)
            this.$message.error(this.$t('inspectionRoute.editFailed'))
          }
        }
      },
      handleClose() {
        this.visible = false
        this.editInspectionRouteInfo = {
          inspectionRouteId: '',
          routeName: '',
          seq: 1,
          remark: ''
        }
        this.$refs.form.clearValidate()
      }
    }
  }
  </script>