index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // pages/agent/serviceBillDetail/index.js
  2. import api from '../../api/api'
  3. import Dialog from 'tdesign-miniprogram/dialog/index';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. refresh: true,
  10. orderMainData: {},
  11. list: [],
  12. tabbarsList: [{
  13. label: "编辑",
  14. icon: "icon-dibu-bianji"
  15. }, {
  16. label: "提交",
  17. icon: "icon-tijiao",
  18. }, {
  19. label: "删除",
  20. icon: "icon-guanlian-shanchu"
  21. }]
  22. },
  23. async mainData() {
  24. const res = await api._post({
  25. "id": "20230206091603",
  26. "version": 1,
  27. "content": {
  28. "sa_serviceorderid": this.data.id
  29. }
  30. })
  31. this.setData({
  32. orderMainData: res.data
  33. })
  34. this.fileData()
  35. this.linkWorkOrder()
  36. },
  37. async fileData() {
  38. const res = await api._post({
  39. "method": "queryFileLink",
  40. "classname": "system.attachment.Attachment",
  41. "content": {
  42. "ownertable": "sa_serviceorder",
  43. "ownerid": this.data.id,
  44. "usetype": "附件" //传空返回有所
  45. }
  46. })
  47. this.setData({
  48. filelist: res.data,
  49. refresh: true
  50. })
  51. },
  52. addProduct() {
  53. wx.navigateTo({
  54. url: '/Eservice/saler/billCanUseProduct/index',
  55. })
  56. },
  57. async getAdd(selection) {
  58. const res = await api._post({
  59. "id": "20230206161803",
  60. "version": 1,
  61. "content": {
  62. "sa_serviceorderid": this.data.id,
  63. "iteminfos": selection.map(e => {
  64. return {
  65. "sa_serviceorderitemsid": 0,
  66. "itemid": e,
  67. "reason": ""
  68. }
  69. })
  70. }
  71. })
  72. this.productmx()
  73. },
  74. async productmx() {
  75. const res = await api._post({
  76. "id": "20230206161903",
  77. "version": 1,
  78. "content": {
  79. "sa_serviceorderid": this.data.id
  80. }
  81. })
  82. this.setData({
  83. list: res.data
  84. })
  85. },
  86. /* 底部按钮回调 */
  87. tabbarOnClick(e) {
  88. let that = this,
  89. dialogConfig = null,
  90. res = null;
  91. switch (e.detail.label) {
  92. case "编辑":
  93. getApp().globalData.handelSelect = this
  94. wx.navigateTo({
  95. url: '/Eservice/saler/editServiceBill/index',
  96. })
  97. break;
  98. case "提交":
  99. dialogConfig = {
  100. context: this,
  101. title: '提示',
  102. content: '确认提交当前申请单吗',
  103. confirmBtn: '确定',
  104. cancelBtn: '取消',
  105. };
  106. Dialog.confirm(dialogConfig)
  107. .then(async () => {
  108. res = await api._post({
  109. "id": "20230206101403",
  110. "version": 1,
  111. "content": {
  112. "sa_serviceorderid": that.data.id,
  113. "issumbit": 1,
  114. }
  115. })
  116. that.mainData()
  117. })
  118. .catch((err) => console.log(err))
  119. .finally(() => Dialog.close());
  120. break;
  121. case "删除":
  122. dialogConfig = {
  123. context: this,
  124. title: '提示',
  125. content: '确认删除当前申请单吗',
  126. confirmBtn: '确定',
  127. cancelBtn: '取消',
  128. };
  129. Dialog.confirm(dialogConfig)
  130. .then(async () => {
  131. res = await api._post({
  132. "id": "20230206091803",
  133. "version": 1,
  134. "content": {
  135. "sa_serviceorderids": [that.data.id],
  136. }
  137. })
  138. wx.navigateBack()
  139. })
  140. .catch((err) => console.log(err))
  141. .finally(() => Dialog.close());
  142. break;
  143. }
  144. },
  145. async linkWorkOrder() {
  146. const res = await api._post({
  147. "id": "20230207154203",
  148. "version": 1,
  149. "content": {
  150. "sa_serviceorderid": this.data.id
  151. }
  152. })
  153. this.setData({
  154. linkWorkOrders: res.data
  155. })
  156. },
  157. tolinkWorkOrder(e) {
  158. let id = e.currentTarget.dataset.item.sa_workorderid
  159. let app = getApp()
  160. app.globalData.action = ['editLeader']
  161. wx.navigateTo({
  162. url: '/Eservice/workOrderDetail/index?class=stopClick&id=' + id
  163. })
  164. },
  165. /**
  166. * 生命周期函数--监听页面加载
  167. */
  168. onLoad(options) {
  169. this.setData({
  170. id: options.id
  171. })
  172. this.productmx()
  173. },
  174. /**
  175. * 生命周期函数--监听页面初次渲染完成
  176. */
  177. onReady() {
  178. },
  179. /**
  180. * 生命周期函数--监听页面显示
  181. */
  182. onShow() {
  183. this.mainData()
  184. },
  185. /**
  186. * 生命周期函数--监听页面隐藏
  187. */
  188. onHide() {
  189. },
  190. /**
  191. * 生命周期函数--监听页面卸载
  192. */
  193. onUnload() {
  194. },
  195. /**
  196. * 页面相关事件处理函数--监听用户下拉动作
  197. */
  198. onPullDownRefresh() {
  199. },
  200. /**
  201. * 页面上拉触底事件的处理函数
  202. */
  203. onReachBottom() {
  204. },
  205. /**
  206. * 用户点击右上角分享
  207. */
  208. onShareAppMessage() {
  209. }
  210. })