InspectionTaskTransfer.vue
2.92 KB
1
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
<el-dialog :title="$t('inspectionTaskTransfer.transfer')" :visible.sync="visible" width="50%" top="5vh">
<el-form ref="form" :model="form" label-width="120px">
<el-form-item :label="$t('inspectionTaskTransfer.transferObject')" required>
<el-select v-model="form.staffId" :placeholder="$t('inspectionTaskTransfer.required')">
<el-option v-for="item in staffs" :key="item.userId" :label="item.name" :value="item.userId"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('inspectionTaskTransfer.transferDesc')" required>
<el-input v-model="form.transferDesc" type="textarea" :rows="4"
:placeholder="$t('inspectionTaskTransfer.required')"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('inspectionTaskTransfer.cancel') }}</el-button>
<el-button type="primary" @click="handleSubmit">{{ $t('inspectionTaskTransfer.submit') }}</el-button>
</div>
</el-dialog>
</template>
<script>
import { updateInspectionTask } from '@/api/inspection/inspectionTaskApi'
import { queryStaffInfos } from '@/api/staff/staffApi.js'
export default {
name: 'InspectionTaskTransfer',
components: {},
data() {
return {
visible: false,
staffs: [],
form: {
taskId: '',
staffId: '',
staffName: '',
transferDesc: '',
currentUserId: '',
inspectionPlanId:''
}
}
},
methods: {
open(task) {
this.form = {
taskId: task.taskId,
staffId: '',
staffName: '',
transferDesc: '',
currentUserId: '',
inspectionPlanId:task.inspectionPlanId
}
this.loadStaffs()
this.visible = true
},
async loadStaffs() {
const { staffs } = await queryStaffInfos({
page: 1,
row: 1000
})
this.staffs = staffs
},
handleSwitchOrg(org) {
this.$refs.staffSelect.setOrg(org)
},
handleStaffChange(staff) {
this.form.staffId = staff.staffId
this.form.staffName = staff.staffName
},
async handleSubmit() {
if (!this.form.staffId) {
this.$message.warning(this.$t('inspectionTaskTransfer.chooseStaff'))
return
}
if (!this.form.transferDesc) {
this.$message.warning(this.$t('inspectionTaskTransfer.inputDesc'))
return
}
if (this.form.staffId === this.form.currentUserId) {
this.$message.warning(this.$t('inspectionTaskTransfer.cantTransferSelf'))
return
}
try {
await updateInspectionTask(this.form)
this.$message.success(this.$t('common.operationSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
console.error('任务流转失败:', error)
this.$message.error(error.message || this.$t('common.operateFail'))
}
}
}
}
</script>