LeaderDialog.vue
4.45 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<template>
<!-- 选择领导代审批,发起人弹窗 -->
<el-dialog
:title="dialogTitle"
:visible.sync="leaderDialogVisible"
:before-close="handleLeaderDialogClose"
:close-on-click-modal="false"
append-to-body
width="30%"
custom-class="leader-dialog"
>
<el-form data-vv-scope="leaderForm">
<ht-form-item>
<el-select
v-model="selectLeaderId"
validate="required"
placeholder="请选择"
>
<el-option
v-for="item in leaderList"
v-show="!(!hasStartRight && item.id == '0' && item.type == 'user')"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</ht-form-item>
<ht-form-item class="dialog-footer__btns">
<el-button @click="handleLeaderDialogClose">取消</el-button>
<el-button type="primary" @click="submitLeader">确定</el-button>
</ht-form-item>
</el-form>
</el-dialog>
</template>
<script>
import { mapState } from 'vuex'
import flow from '@/api/flow.js'
export default {
name: 'LeaderDialog',
props: {
dialogTitle: {
type: String,
default: '选择代审批领导',
},
},
data() {
return {
leaderDialogVisible: false,
selectLeaderId: '',
leaderList: [],
id: '', //当前点击流程id
isNewProcess: '',
isFromBatch: false,
isFromLeaderTodo: false,
hasStartRight: false,
defId: '',
}
},
computed: {
...mapState('user', ['currentUserDetail']),
...mapState('login',['currentUser']),
userId() {
return this.currentUserDetail&&this.currentUserDetail.user&&this.currentUserDetail.user.userId
},
token(){
return this.currentUser&&this.currentUser.token
}
},
watch: {
id: {
handler(val) {
if (val) {
this.initData()
} else {
this.hasStartRight = false
}
},
immediate: true,
},
},
methods: {
//选择领导后跳转
submitLeader() {
if (!this.selectLeaderId)
return this.$message.warning('请选择代为审批的领导')
if (this.isNewProcess) {
// 获取流程的主版本发起。
flow.getMainByDefIdOrKey(this.id).then((resp) => {
let defId = this.id
if (resp && resp.id) {
defId = resp.id
}
window.open(`${window.context.front}/matter/startProcess?defId=${defId}&leaderId=${this.selectLeaderId}&token=${this.token}`,'_blank')
})
} else {
const url = `${window.context.front}/matter/approvalForm?taskId=${this.id}&leaderId=${this.selectLeaderId}&token=${this.token}`
this.openNewPage(url)
}
this.leaderDialogVisible = false
},
openLeaderDialog() {
this.leaderDialogVisible = true
},
//处理新建流程可选择发起人时跳转
async handleNewProcessJumps(data) {
this.id = data.id
let response = await flow.checkStartRight(this.userId, data.id, '')
if (response.state) {
this.hasStartRight = response.value
}
this.isNewProcess = true
if (data.leaders && data.leaders.length > 0) {
this.leaderList = data.leaders
this.leaderDialogVisible = true
} else {
let resp = await flow.getMainByDefIdOrKey(this.id)
let defId = data.id
// 获取流程的主版本发起。
if (resp && resp.id) {
defId = resp.id
}
const url = `${window.context.front}/matter/startProcess?defId=${defId}&name=${data.name}&token=${this.token}`
this.openNewPage(url)
}
},
initData() {
if (this.defId) {
// 判断发起权限
flow.checkStartRight(this.userId, this.defId, '').then((response) => {
if (response.state) {
this.hasStartRight = response.value
}
})
}
},
openNewPage(url) {
window.open(url, '_blank')
},
//关闭选择领导弹窗
handleLeaderDialogClose() {
this.leaderDialogVisible = false
},
},
}
</script>
<style lang="scss" scoped>
.leader-dialog {
.dialog-footer__btns {
::v-deep .el-form-item__content {
text-align: right;
}
}
}
</style>