我正在尝试设置一个提示,接受用户输入,然后在后端调用查询。第一次输入代码时,它会给我'null'的值,但是当我再次输入它时,它会给我正确的值。
updateStatus() {
let update = {
"status_id": this.status_id
}
this.$root.$dialog.prompt({
title: "Update status to: ",
body: 'Enter a status id number: 1 - open, 450 - In Progress, 900 - Closed'
})
.then(dialog => {
this.status_id = dialog.data
if(this.status_id == 1 || this.status_id == 450 || this.status_id == 900) {
this.$http.put(`/someurl/?quote_number=${this.query_number}`, update).then(res => {
this.$root.$dialog.alert(`You entered status: ${this.status_id}`)
if(res.data.error) {
this.$root.updateError(res.data.error)
} else {
this.$root.updateSuccess(res.data.message)
}
})
} else {
this.$root.$dialog.alert("You entered an invalid status code")
this.status_id = null
}
})
.catch(error => {
this.$root.updateError(error)
})
}