index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. nocache: true,
  16. "sa_workorderid": this.data.id
  17. }
  18. })
  19. this.setData({
  20. billData: res.data
  21. })
  22. this.workerData()
  23. },
  24. changeBillStatus(e) {
  25. const {
  26. id,
  27. name
  28. } = e.target.dataset;
  29. if (!name) return;
  30. const dialogConfig = {
  31. context: this,
  32. title: '提示',
  33. content: `是否确定${name}当前工单?`,
  34. confirmBtn: name,
  35. cancelBtn: '取消',
  36. }
  37. Dialog.confirm(dialogConfig)
  38. .then(async () => {
  39. const res = await api._post({
  40. "id": id,
  41. "content": {
  42. "sa_workorderid": this.data.id
  43. }
  44. })
  45. wx.showToast({
  46. title: res.msg == '成功' ? `工单${name}成功` : res.msg,
  47. icon: "none",
  48. mask: true
  49. });
  50. if (name == '作废') {
  51. setTimeout(() => {
  52. wx.navigateBack()
  53. }, 500);
  54. } else {
  55. this.mainData()
  56. }
  57. })
  58. .catch(() => console.log('点击了取消'))
  59. .finally(() => Dialog.close())
  60. },
  61. async addConfirmBill() {
  62. const res = await api._post({
  63. "id": "20230211105703",
  64. "version": 1,
  65. "content": {
  66. "sa_workorder_confirmationid": 0,
  67. "sa_workorderid": this.data.id,
  68. "attitudescore": 0,
  69. "responsescore": 0,
  70. }
  71. })
  72. if (this.data.billData.type === '安装培训') {
  73. wx.navigateTo({
  74. url: '/Eservice/trainConfirmBill/index?id=' + res.data.sa_workorder_confirmationid,
  75. })
  76. } else if (this.data.billData.type === '安装调试') {
  77. wx.navigateTo({
  78. url: '/Eservice/installConfirmBill/index?id=' + res.data.sa_workorder_confirmationid,
  79. })
  80. } else {}
  81. },
  82. toConfirmBill(data) {
  83. if (this.data.billData.type === '安装培训') {
  84. wx.navigateTo({
  85. url: '/Eservice/trainConfirmBill/index?class=stopClick&id=' + data.currentTarget.dataset.item.sa_workorder_confirmationid,
  86. })
  87. }
  88. },
  89. async confirmBillList() {
  90. const res = await api._post({
  91. "id": "20230211105903",
  92. "content": {
  93. "where": {
  94. nocahce: true,
  95. "condition": "",
  96. "sa_workorderid": this.data.id
  97. }
  98. }
  99. })
  100. this.setData({
  101. confirmBills: res.data
  102. })
  103. },
  104. toWorkConfirmInfo() {
  105. getApp().globalData.handelSelect = this
  106. wx.navigateTo({
  107. url: '/Eservice/workBillConfirmInfo/index?class=stopClick'
  108. })
  109. },
  110. async workerData() {
  111. const res = await api._post({
  112. "id": "20230213143003",
  113. "version": 1,
  114. "content": {
  115. "where": {
  116. "condition": ""
  117. }
  118. }
  119. })
  120. this.setData({
  121. workers: res.data
  122. })
  123. },
  124. showWorkerDialog() {
  125. this.setData({
  126. workLeaderDialog: !this.data.workLeaderDialog
  127. })
  128. },
  129. selectLeader(data) {
  130. this.setData({
  131. actLeader: data.currentTarget.dataset.item
  132. })
  133. },
  134. async toWorker() {
  135. if (!this.data.actLeader) {
  136. wx.showToast({
  137. title: '未选择负责人',
  138. icon: 'none'
  139. })
  140. } else {
  141. this.data.billData.projectlearders = [this.data.actLeader.userid]
  142. const res = await api._post({
  143. "id": "20230208140003",
  144. "content": this.data.billData
  145. })
  146. this.setData({
  147. workLeaderDialog: false
  148. })
  149. if (res.msg != '成功') return wx.showToast({
  150. title: res.msg,
  151. icon: "none"
  152. });
  153. this.mainData()
  154. // this.confirmBillList()
  155. }
  156. },
  157. onLoad(options) {
  158. this.setData({
  159. id: options.id
  160. })
  161. },
  162. onShow() {
  163. this.mainData()
  164. this.confirmBillList()
  165. },
  166. })