69
69
align =" center"
70
70
>
71
71
<template slot-scope="scope">
72
+ <el-button
73
+ v-if =" authType === 'target' && scope.row.status=== 'accepted'"
74
+ plain
75
+ size =" mini"
76
+ class =" filter-item"
77
+ type =" primary"
78
+ @click =" showReplicasForm(scope.row)"
79
+ >
80
+ 部署
81
+ </el-button >
72
82
<el-button
73
83
v-if =" authType === 'source' && scope.row.status !== 'accepted'"
74
84
size =" mini"
108
118
</el-button >
109
119
</div >
110
120
</el-dialog >
121
+
122
+ <el-dialog :visible.sync =" replicasDialogVisible" title =" 请求部署" >
123
+ <el-form
124
+ ref =" createForm"
125
+ :rules =" rules"
126
+ :model =" replicasForm"
127
+ label-position =" left"
128
+ label-width =" 120px"
129
+ style =" width : 400px ; margin-left :20px ;"
130
+ >
131
+ <el-form-item label =" 目标 appid" prop =" target_appid" >
132
+ <el-input v-model =" replicasForm.target_appid" disabled />
133
+ </el-form-item >
134
+ <el-form-item label =" 部署权限" prop =" permissions" >
135
+ <el-checkbox-group v-model =" replicasForm.permissions" >
136
+ <el-checkbox label =" function" border >云函数</el-checkbox >
137
+ <el-checkbox label =" policy" border >访问策略</el-checkbox >
138
+ </el-checkbox-group >
139
+ </el-form-item >
140
+ </el-form >
141
+ <div slot =" footer" class =" dialog-footer" >
142
+ <el-button @click =" replicasDialogVisible = false" >
143
+ 取消
144
+ </el-button >
145
+ <el-button type =" primary" @click =" handleCreateRequest" >
146
+ 确定
147
+ </el-button >
148
+ </div >
149
+ </el-dialog >
111
150
</div >
112
151
</template >
113
152
114
153
<script >
115
154
import store from ' @/store'
116
155
import dayjs from ' dayjs'
117
- import { getReplicateAuths , createReplicateAuth , acceptReplicateAuth , deleteReplicateAuth } from ' ../../api/replicate'
156
+ import { getReplicateAuths , createReplicateAuth , acceptReplicateAuth , deleteReplicateAuth , createReplicateRequest } from ' ../../api/replicate'
118
157
119
158
export default {
120
159
data () {
@@ -136,7 +175,12 @@ export default {
136
175
},
137
176
dialogFormVisible: false ,
138
177
139
- authType: ' target' // target | source
178
+ authType: ' target' , // target | source
179
+ replicasDialogVisible: false ,
180
+ replicasForm: {
181
+ target_appid: ' ' ,
182
+ permissions: []
183
+ },
140
184
}
141
185
},
142
186
created () {
@@ -155,6 +199,55 @@ export default {
155
199
this .tableList = this .list .filter (item => item .target_appid === this .appid )
156
200
}
157
201
},
202
+ showReplicasForm (row ) {
203
+ this .replicasForm .target_appid = row .target_appid
204
+ this .replicasDialogVisible = true
205
+ },
206
+ async handleCreateRequest () {
207
+ this .$refs [' createForm' ].validate (async (valid) => {
208
+ if (! valid) { return }
209
+
210
+ if (this .replicasForm .permissions .length === 0 ) {
211
+ this .$message .warning (' 请至少选择一个部署权限' )
212
+ return
213
+ }
214
+
215
+ const params = {
216
+ target_appid: this .replicasForm .target_appid
217
+ }
218
+ if (this .replicasForm .permissions .includes (' function' )) {
219
+ params .functions = {
220
+ type: ' all' ,
221
+ items: []
222
+ }
223
+ }
224
+ if (this .replicasForm .permissions .includes (' policy' )) {
225
+ params .policies = {
226
+ type: ' all' ,
227
+ items: []
228
+ }
229
+ }
230
+
231
+ const res = await createReplicateRequest (params)
232
+
233
+ if (res .code ) {
234
+ this .$notify ({
235
+ type: ' error' ,
236
+ title: ' 操作失败' ,
237
+ message: res .message
238
+ })
239
+ return
240
+ }
241
+
242
+ this .$notify ({
243
+ type: ' success' ,
244
+ title: ' 操作成功' ,
245
+ message: ' 部署成功,等待目标应用接受。'
246
+ })
247
+
248
+ this .replicasDialogVisible = false
249
+ })
250
+ },
158
251
showCreateForm () {
159
252
this .dialogFormVisible = true
160
253
},
0 commit comments