index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. const api = require("../../api/api");
  2. import Dialog from 'tdesign-miniprogram/dialog/index';
  3. // pages/workOrderDetail/index.js
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. workLeaderDialog: false
  10. },
  11. async mainData() {
  12. const res = await api._post({
  13. "id": "20230208140103",
  14. "content": {
  15. "sa_workorderid": this.data.id
  16. }
  17. })
  18. this.setData({
  19. billData: res.data
  20. })
  21. this.workerData()
  22. },
  23. changeBillStatus(data) {
  24. let id = data.currentTarget.dataset.id
  25. const dialogConfig = {
  26. context: this,
  27. title: '提示',
  28. content: '确认执行当前操作吗?',
  29. confirmBtn: '确定',
  30. cancelBtn: '取消',
  31. }
  32. Dialog.confirm(dialogConfig)
  33. .then(async () => {
  34. const res = await api._post({
  35. "id": id,
  36. "content": {
  37. "sa_workorderid": this.data.id
  38. }
  39. })
  40. this.mainData()
  41. })
  42. .catch(() => console.log('点击了取消'))
  43. .finally(() => Dialog.close())
  44. },
  45. async addConfirmBill() {
  46. const res = await api._post({
  47. "id": "20230211105703",
  48. "version": 1,
  49. "content": {
  50. "sa_workorder_confirmationid": 0,
  51. "sa_workorderid": this.data.id,
  52. "attitudescore": 0,
  53. "responsescore": 0,
  54. }
  55. })
  56. if (this.data.billData.type === '安装培训') {
  57. wx.navigateTo({
  58. url: '/Eservice/trainConfirmBill/index?id=' + res.data.sa_workorder_confirmationid,
  59. })
  60. } else if (this.data.billData.type === '安装调试') {
  61. wx.navigateTo({
  62. url: '/Eservice/installConfirmBill/index?id=' + res.data.sa_workorder_confirmationid,
  63. })
  64. } else {}
  65. },
  66. toConfirmBill(data) {
  67. if (this.data.billData.type === '安装培训') {
  68. wx.navigateTo({
  69. url: '/Eservice/trainConfirmBill/index?class=stopClick&id=' + data.currentTarget.dataset.item.sa_workorder_confirmationid,
  70. })
  71. }
  72. },
  73. async confirmBillList() {
  74. const res = await api._post({
  75. "id": "20230211105903",
  76. "content": {
  77. "where": {
  78. "condition": "",
  79. "sa_workorderid": this.data.id
  80. }
  81. }
  82. })
  83. this.setData({
  84. confirmBills: res.data
  85. })
  86. },
  87. toWorkConfirmInfo() {
  88. getApp().globalData.handelSelect = this
  89. wx.navigateTo({
  90. url: '/Eservice/workBillConfirmInfo/index?class=stopClick'
  91. })
  92. },
  93. async workerData() {
  94. const res = await api._post({
  95. "id": "20230213143003",
  96. "version": 1,
  97. "content": {
  98. "where": {
  99. "condition": ""
  100. }
  101. }
  102. })
  103. this.setData({
  104. workers: res.data
  105. })
  106. },
  107. showWorkerDialog() {
  108. this.setData({
  109. workLeaderDialog: !this.data.workLeaderDialog
  110. })
  111. },
  112. selectLeader(data) {
  113. this.setData({
  114. actLeader: data.currentTarget.dataset.item
  115. })
  116. },
  117. async toWorker() {
  118. if (!this.data.actLeader) {
  119. wx.showToast({
  120. title: '未选择负责人',
  121. icon: 'none'
  122. })
  123. } else {
  124. this.data.billData.projectlearders = [this.data.actLeader.userid]
  125. const res = api._post({
  126. "id": "20230208140003",
  127. "content": this.data.billData
  128. })
  129. this.setData({
  130. showToWoker: false
  131. })
  132. this.mainData()
  133. }
  134. },
  135. /**
  136. * 生命周期函数--监听页面加载
  137. */
  138. onLoad(options) {
  139. this.setData({
  140. id: options.id
  141. })
  142. },
  143. /**
  144. * 生命周期函数--监听页面初次渲染完成
  145. */
  146. onReady() {
  147. },
  148. /**
  149. * 生命周期函数--监听页面显示
  150. */
  151. onShow() {
  152. this.mainData()
  153. this.confirmBillList()
  154. },
  155. /**
  156. * 生命周期函数--监听页面隐藏
  157. */
  158. onHide() {
  159. },
  160. /**
  161. * 生命周期函数--监听页面卸载
  162. */
  163. onUnload() {
  164. },
  165. /**
  166. * 页面相关事件处理函数--监听用户下拉动作
  167. */
  168. onPullDownRefresh() {
  169. },
  170. /**
  171. * 页面上拉触底事件的处理函数
  172. */
  173. onReachBottom() {
  174. },
  175. /**
  176. * 用户点击右上角分享
  177. */
  178. onShareAppMessage() {
  179. }
  180. })