index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. sa_serviceorderid: res.data.sa_serviceorderid,
  34. sa_orderid: res.data.sa_orderid,
  35. })
  36. this.fileData()
  37. this.linkWorkOrder()
  38. },
  39. async fileData() {
  40. const res = await api._post({
  41. "method": "queryFileLink",
  42. "classname": "system.attachment.Attachment",
  43. "content": {
  44. "ownertable": "sa_serviceorder",
  45. "ownerid": this.data.id,
  46. "usetype": "" //传空返回有所
  47. }
  48. })
  49. this.setData({
  50. filelist: res.data,
  51. refresh: true
  52. })
  53. },
  54. addProduct() {
  55. wx.navigateTo({
  56. url: '/Eservice/agent/billCanUseProduct/index?id=' + this.data.id,
  57. })
  58. },
  59. async getAdd(selection) {
  60. const res = await api._post({
  61. "id": "20230206161803",
  62. "version": 1,
  63. "content": {
  64. "sa_serviceorderid": this.data.id,
  65. "iteminfos": selection.map(e => {
  66. return {
  67. "sa_serviceorderitemsid": 0,
  68. "itemid": e,
  69. "reason": "",
  70. "qty": 1
  71. }
  72. })
  73. }
  74. })
  75. this.productmx()
  76. },
  77. async productmx() {
  78. const res = await api._post({
  79. "id": "20230206161903",
  80. "version": 1,
  81. "content": {
  82. "sa_serviceorderid": this.data.id
  83. }
  84. })
  85. this.setData({
  86. list: res.data
  87. })
  88. },
  89. /* 底部按钮回调 */
  90. tabbarOnClick(e) {
  91. let that = this,
  92. dialogConfig = null,
  93. res = null;
  94. switch (e.detail.label) {
  95. case "编辑":
  96. getApp().globalData.handelSelect = this
  97. wx.navigateTo({
  98. url: '/Eservice/agent/editServiceBill/index',
  99. })
  100. break;
  101. case "提交":
  102. dialogConfig = {
  103. context: this,
  104. title: '提示',
  105. content: '确认提交当前申请单吗',
  106. confirmBtn: '确定',
  107. cancelBtn: '取消',
  108. };
  109. Dialog.confirm(dialogConfig)
  110. .then(async () => {
  111. res = await api._post({
  112. "id": "20230206101403",
  113. "version": 1,
  114. "content": {
  115. "sa_serviceorderid": that.data.id,
  116. "issumbit": 1,
  117. }
  118. });
  119. that.mainData()
  120. })
  121. .catch((err) => console.log(err))
  122. .finally(() => Dialog.close());
  123. break;
  124. case "删除":
  125. dialogConfig = {
  126. context: this,
  127. title: '提示',
  128. content: '确认删除当前申请单吗',
  129. confirmBtn: '确定',
  130. cancelBtn: '取消',
  131. };
  132. Dialog.confirm(dialogConfig)
  133. .then(async () => {
  134. res = await api._post({
  135. "id": "20230206091803",
  136. "version": 1,
  137. "content": {
  138. "sa_serviceorderids": [that.data.id],
  139. }
  140. })
  141. wx.navigateBack()
  142. })
  143. .catch((err) => console.log(err))
  144. .finally(() => Dialog.close());
  145. break;
  146. }
  147. },
  148. async linkWorkOrder() {
  149. const res = await api._post({
  150. "id": "20230207154203",
  151. "version": 1,
  152. "content": {
  153. "sa_serviceorderid": this.data.id
  154. }
  155. })
  156. this.setData({
  157. linkWorkOrders: res.data
  158. })
  159. },
  160. tolinkWorkOrder(e) {
  161. let id = e.currentTarget.dataset.item.sa_workorderid
  162. let app = getApp()
  163. app.globalData.action = ['editLeader']
  164. wx.navigateTo({
  165. url: '/Eservice/workOrderDetail/index?class=stopClick&id=' + id
  166. })
  167. },
  168. /**
  169. * 生命周期函数--监听页面加载
  170. */
  171. onLoad(options) {
  172. this.setData({
  173. id: options.id
  174. })
  175. this.productmx()
  176. },
  177. onShow() {
  178. this.mainData()
  179. },
  180. async onUnload() {
  181. let page = getCurrentPages().find(v => v.__route__ == 'Eservice/agent/serviceBillList/index');
  182. if (!page) return;
  183. let param = JSON.parse(JSON.stringify(page.data.param));
  184. param.content.pageSize = param.content.pageNumber * param.content.pageSize;
  185. param.content.pageNumber = 1;
  186. const res = await api._post(param);
  187. page.setData({
  188. list: res.data
  189. })
  190. },
  191. })