|
20 | 20 | @submit="handleSubmit"> |
21 | 21 | <dynamic-form |
22 | 22 | :schema="schema" |
| 23 | + :value="formData" |
23 | 24 | @input="handleInput"> |
24 | 25 | </dynamic-form> |
25 | 26 | <a-form-item |
@@ -131,6 +132,38 @@ export default { |
131 | 132 | HRequest.get('/api/action/' + this.actionName).then( |
132 | 133 | (response) => this.formDefinitionHandler(response) |
133 | 134 | ) |
| 135 | +
|
| 136 | + const queryParams = this.$route.query |
| 137 | + if (queryParams.backfill && Number(queryParams.backfill) > 0) { |
| 138 | + const notificationTitle = "Rerun ticket " + queryParams.backfill + " error" |
| 139 | + HRequest.get('/api/ticket/' + queryParams.backfill).then( |
| 140 | + (response) => { |
| 141 | + const ticketsLen = response.data.data.tickets.length |
| 142 | + if (ticketsLen == 1) { |
| 143 | + const isTheSameAction = this.$route.path.endsWith(response.data.data.tickets[0].provider_object) |
| 144 | + const ticket = response.data.data.tickets[0] |
| 145 | + if (isTheSameAction) { |
| 146 | + this.handleInput(ticket.params) |
| 147 | + } else { |
| 148 | + this.errorAsNotification( |
| 149 | + notificationTitle, |
| 150 | + "The backfill ticket should be the same action ticket, but ticket " + queryParams.backfill + "'s action was: " + ticket.provider_object |
| 151 | + ) |
| 152 | + } |
| 153 | + } else { |
| 154 | + this.errorAsNotification( |
| 155 | + "Rerun ticket " + queryParams.backfill + " error", |
| 156 | + "Expect exactly 1 ticket info but got " + ticketsLen + "item(s)" |
| 157 | + ) |
| 158 | + } |
| 159 | + } |
| 160 | + ).catch((error) => { |
| 161 | + this.errorAsNotification( |
| 162 | + notificationTitle, |
| 163 | + error.response.data.data.description |
| 164 | + ) |
| 165 | + }) |
| 166 | + } |
134 | 167 | }, |
135 | 168 | resetForm () { |
136 | 169 | this.form.resetFields() |
@@ -223,7 +256,16 @@ export default { |
223 | 256 | }, |
224 | 257 | gotoTicketDetail () { |
225 | 258 | this.$router.push({ name: 'HTicketDetail', params: { id: this.submitResponse.ticket.id }}) |
226 | | - } |
| 259 | + }, |
| 260 | + errorAsNotification (title, rawMsg) { |
| 261 | + const msg = rawMsg.length > 300 ? rawMsg.slice(0, 300) + '... ' : rawMsg |
| 262 | + this.$notification.title = rawMsg |
| 263 | + this.$notification.open({ |
| 264 | + message: title, |
| 265 | + description: msg, |
| 266 | + duration: 0 |
| 267 | + }) |
| 268 | + }, |
227 | 269 | }, |
228 | 270 |
|
229 | 271 | mounted () { |
|
0 commit comments