工单状态变更完成

加入成功信息提示
This commit is contained in:
Yudong
2014-05-16 22:29:04 +08:00
parent 13d256237b
commit 585c3fb2ec
8 changed files with 43 additions and 26 deletions

View File

@@ -14,4 +14,4 @@ $ ->
.fail (reply) ->
if reply.status is 400
error = reply.responseJSON.error
ErrorHandle.flushError error
ErrorHandle.flushInfo 'error', error

View File

@@ -2,7 +2,7 @@ $ ->
$('.signup-btn').on 'click', (e) ->
e.preventDefault()
if $('#passwd').val() isnt $('#passwd2').val()
ErrorHandle.flushError '两次密码不一致'
ErrorHandle.flushInfo 'error', '两次密码不一致'
else
data =
username: $('#username').val()
@@ -17,4 +17,4 @@ $ ->
.fail (reply) ->
if reply.status is 400
error = reply.responseJSON.error
ErrorHandle.flushError error
ErrorHandle.flushInfo 'error', error

View File

@@ -1,18 +1,21 @@
$ ->
window.ErrorHandle =
addError: (error) ->
$('#page-alert').append "<p>#{error}</p>"
addInfo: (type, info) ->
$("#page-#{type}").append "<p>#{info}</p>"
clearError: ->
$('#page-alert').empty()
clearInfo: (type) ->
$("#page-#{type}").empty()
showError: ->
$('#page-alert').show()
showInfo: (type, callback) ->
$("#page-#{type}").show 400, if callback? then callback or null
hideInfo: (type) ->
$("#page-#{type}").hide()
flushInfo: (type, error, callback = null) ->
@clearInfo type
@addInfo type, error
@showInfo type, callback
hideError: ->
$('#page-alert').hide()
flushError: (error) ->
@clearError()
@addError error
@showError()

View File

@@ -14,4 +14,4 @@ $ ->
.fail (reply) ->
if reply.status is 400
error = reply.responseJSON.error
ErrorHandle.flushError error
ErrorHandle.flushInfo 'error', error

View File

@@ -17,4 +17,4 @@ $ ->
.fail (reply) ->
if reply.status is 400
error = reply.responseJSON.error
ErrorHandle.flushError error
ErrorHandle.flushInfo 'error', error

View File

@@ -1,8 +1,9 @@
$ ->
id = $('#ticketid').data 'id'
$('#reply-btn').on 'click', (e) ->
e.preventDefault()
data = {
id: $('#ticketid').data 'id'
id: id
content: $('#reply-content').val()
}
console.log data
@@ -17,15 +18,25 @@ $ ->
.fail (r) ->
if reply.status is 400
error = reply.responseJSON.error
ErrorHandle.flushError error
ErrorHandle.flushInfo 'error', error
#return a promise
changeStatus = (status) ->
$.post '/ticket/update/', {
id: id
status: status
}
$('#close-btn').on 'click', (e) ->
e.preventDefault()
changeStatus 'closed'
.done (r) ->
ErrorHandle.flushInfo 'success', '关闭工单成功', ->
location.reload true
$.post '/ticket/update/', {
id: $('#ticketid').data 'id'
status: 'closed'
}
.done (r) ->
console.log r
$('#reopen-btn').on 'click', (e) ->
e.preventDefault()
changeStatus 'open'
.done (r) ->
ErrorHandle.flushInfo 'success', '重开工单成功', ->
location.reload true