ticket.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. const util = require("../../../utils/util");
  2. const api = require('../../../api/api.js');
  3. var app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. list: [],
  10. showType: 0,
  11. page: 1,
  12. limit: 10,
  13. totalPages: 0,
  14. myqr_show: false, //显示追加信息框
  15. myqr_blur: 1, //背景模糊值
  16. content: '',
  17. ticketSn: '', //当前处理的工单
  18. action: '' //操作工单动作 是处理 还是完结
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. this.getList();
  25. },
  26. ticketHandle() {
  27. if (this.data.action == "handle")
  28. this.saveHandle();
  29. else this.saveCompleted();
  30. },
  31. saveHandle() { //工单处理
  32. let that = this
  33. if (!that.data.content) {
  34. wx.showToast({
  35. title: '请输入处理内容',
  36. duration: 3000
  37. });
  38. return;
  39. }
  40. wx.showLoading();
  41. util.request(api.TicketHandle, {
  42. ticketSn: that.data.ticketSn,
  43. content: that.data.content
  44. }).then(function (res) {
  45. wx.hideLoading();
  46. that.handleFilter();
  47. if (res.errno === 0) {
  48. that.setData({
  49. content: '',
  50. myqr_blur: 1,
  51. myqr_show: false
  52. })
  53. wx.showToast({
  54. title: '处理成功',
  55. duration: 3000
  56. });
  57. } else {
  58. util.showErrorToast(res.errmsg);
  59. }
  60. });
  61. },
  62. saveCompleted(e) {
  63. let that = this
  64. if (!that.data.content) {
  65. wx.showToast({
  66. title: '请输入处理内容',
  67. duration: 3000
  68. });
  69. return;
  70. }
  71. wx.showLoading();
  72. util.request(api.TicketCompleted, {
  73. ticketSn: that.data.ticketSn,
  74. content: that.data.content
  75. }).then(function (res) {
  76. wx.hideLoading();
  77. that.handleFilter();
  78. if (res.errno === 0) {
  79. that.setData({
  80. content: '',
  81. myqr_blur: 1,
  82. myqr_show: false
  83. })
  84. wx.showToast({
  85. title: '工单完结',
  86. duration: 3000
  87. });
  88. } else {
  89. util.showErrorToast(res.errmsg);
  90. }
  91. });
  92. },
  93. handleFilter(){
  94. var showType=this.data.showType;
  95. this.setData({
  96. list: [],
  97. showType: showType,
  98. page: 1,
  99. limit: 10,
  100. totalPages: 1
  101. });
  102. this.getList();
  103. },
  104. switchTab(e) {
  105. let showType = e.currentTarget.dataset.index;
  106. this.setData({
  107. list: [],
  108. showType: showType,
  109. page: 1,
  110. limit: 10,
  111. totalPages: 1
  112. });
  113. this.getList();
  114. },
  115. goHandle(e) {
  116. wx.pageScrollTo({
  117. scrollTop: 0
  118. });
  119. this.setData({
  120. myqr_show: true,
  121. myqr_blur: 1,
  122. ticketSn: e.currentTarget.dataset.sn,
  123. content: '',
  124. action: 'handle'
  125. })
  126. },
  127. goCompleted(e) {
  128. wx.pageScrollTo({
  129. scrollTop: 0
  130. });
  131. this.setData({
  132. myqr_show: true,
  133. myqr_blur: 1,
  134. ticketSn: e.currentTarget.dataset.sn,
  135. content: '',
  136. action: 'completed'
  137. })
  138. },
  139. qrtouchstart: function () {
  140. this.setData({
  141. myqr_blur: 1,
  142. myqr_show: false,
  143. });
  144. },
  145. /**
  146. * 生命周期函数--监听页面初次渲染完成
  147. */
  148. onReady: function () {
  149. },
  150. bindContent(e) {
  151. this.setData({
  152. content: e.detail.value
  153. })
  154. },
  155. getList() {
  156. let that = this;
  157. wx.showLoading();
  158. util.request(api.TicketList, {
  159. showType: that.data.showType,
  160. page: that.data.page,
  161. limit: that.data.limit
  162. }).then(function (res) {
  163. wx.hideLoading();
  164. if (res.errno === 0) {
  165. console.log(res.data);
  166. that.setData({
  167. list: that.data.list.concat(res.data.list),
  168. totalPages: res.data.pages
  169. });
  170. }
  171. });
  172. },
  173. onReachBottom() {
  174. if (this.data.totalPages > this.data.page) {
  175. this.setData({
  176. page: this.data.page + 1
  177. });
  178. this.getList();
  179. } else {
  180. wx.showToast({
  181. title: '没有更多工单了',
  182. icon: 'none',
  183. duration: 2000
  184. });
  185. return false;
  186. }
  187. },
  188. /**
  189. * 生命周期函数--监听页面显示
  190. */
  191. onShow: function () {},
  192. viewTicket(e) {
  193. wx.navigateTo({
  194. url: '/pages/servant/crm/ticketAction?ticketSn=' + e.currentTarget.dataset.sn
  195. })
  196. },
  197. /**
  198. * 生命周期函数--监听页面隐藏
  199. */
  200. onHide: function () {
  201. },
  202. /**
  203. * 生命周期函数--监听页面卸载
  204. */
  205. onUnload: function () {
  206. },
  207. /**
  208. * 页面相关事件处理函数--监听用户下拉动作
  209. */
  210. onPullDownRefresh: function () {
  211. },
  212. /**
  213. * 用户点击右上角分享
  214. */
  215. onShareAppMessage: function () {
  216. }
  217. })