Blame view

src/components/work/dispatchRepair.vue 4.1 KB
4927ce37   wuxw   开发完成报修功能
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  <template>
    <el-dialog :title="$t('repairPoolManage.dispatch')" :visible.sync="visible" width="50%" @close="resetForm">
      <el-form ref="form" :model="formData" label-width="120px">
        <el-form-item v-if="formData.action === 'BACK'" :label="$t('repairPoolManage.repairPerson')" prop="staffName">
          <el-input v-model="formData.staffName" disabled />
        </el-form-item>
  
        <el-form-item v-else :label="$t('repairPoolManage.repairPerson')" prop="staffId"
          :rules="[{ required: true, message: $t('repairPoolManage.selectRepairPerson'), trigger: 'blur' }]">
          <el-select v-model="formData.staffId" style="width:100%">
            <el-option v-for="item in repairTypeUsers" :key="item.staffId" :label="item.staffName" :value="item.staffId" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('repairPoolManage.operationSuggestions')" prop="context"
          :rules="[{ required: true, message: $t('repairPoolManage.operationSuggestions'), trigger: 'blur' }]">
          <el-input v-model="formData.context" type="textarea" :rows="4"
72de60dc   wuxw   优化报修完成
18
            :placeholder="$t('repairPoolManage.operationSuggestions')" />
4927ce37   wuxw   开发完成报修功能
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        </el-form-item>
      </el-form>
  
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
        <el-button type="primary" @click="submitForm">{{ $t('common.submit') }}</el-button>
      </span>
    </el-dialog>
  </template>
  
  <script>
  import { dispatchRepair } from '@/api/work/repairPoolManageApi'
  import {listRepairTypeUsers} from '@/api/work/repairTypeUserApi'
  import { getCommunityId } from '@/api/community/communityApi'
72de60dc   wuxw   优化报修完成
33
  import { getUserId } from '@/api/user/userApi'  
4927ce37   wuxw   开发完成报修功能
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
  
  export default {
    name: 'DispatchRepair',
    data() {
      return {
        visible: false,
        formData: {
          repairId: '',
          repairType: '',
          staffId: '',
          staffName: '',
          context: '',
          action: '',
          repairTypeUsers: [],
          currentUserId: ''
        },
        repairTypeUsers: []
      }
    },
    methods: {
      open(repair) {
        this.formData = {
          ...this.formData,
          repairId: repair.repairId,
          repairType: repair.repairType,
72de60dc   wuxw   优化报修完成
59
60
          action: repair.action || 'DISPATCH',
          currentUserId: getUserId()
4927ce37   wuxw   开发完成报修功能
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
126
127
128
        }
  
        if (repair.action === 'BACK') {
          this.formData.staffId = repair.preStaffId
          this.formData.staffName = repair.preStaffName
        }
  
        this.listRepairTypeUsers()
        this.visible = true
      },
  
      async listRepairTypeUsers() {
        try {
          const params = {
            page: 1,
            row: 50,
            communityId: getCommunityId(),
            repairType: this.formData.repairType,
            state: '9999'
          }
  
          const res = await listRepairTypeUsers(params)
          this.repairTypeUsers = res.data || []
        } catch (error) {
          console.error('Failed to fetch repair type users:', error)
        }
      },
  
      async submitForm() {
        this.$refs.form.validate(async valid => {
          if (valid) {
            try {
              const staff = this.repairTypeUsers.find(item => item.staffId === this.formData.staffId)
              if (staff) {
                this.formData.staffName = staff.staffName
              }
  
              if (this.formData.action === 'TRANSFER' && this.formData.currentUserId === this.formData.staffId) {
                this.$message.error(this.$t('repairPoolManage.cannotTransferSelf'))
                return
              }
  
              const data = {
                ...this.formData,
                communityId: getCommunityId()
              }
  
              await dispatchRepair(data)
              this.$message.success(this.$t('common.operationSuccess'))
              this.visible = false
              this.$emit('success')
            } catch (error) {
              console.error('Dispatch repair failed:', error)
            }
          }
        })
      },
  
      resetForm() {
        this.$refs.form.resetFields()
        this.formData = {
          repairId: '',
          repairType: '',
          staffId: '',
          staffName: '',
          context: '',
          action: '',
          repairTypeUsers: [],
19bafb73   wuxw   v1.9 优化采购相关bug
129
          currentUserId: getUserId()
4927ce37   wuxw   开发完成报修功能
130
131
132
133
134
        }
      }
    }
  }
  </script>