index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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',
  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. }
  71. })
  72. }
  73. })
  74. this.productmx()
  75. },
  76. async productmx() {
  77. const res = await api._post({
  78. "id": "20230206161903",
  79. "version": 1,
  80. "content": {
  81. "sa_serviceorderid": this.data.id
  82. }
  83. })
  84. this.setData({
  85. list: res.data
  86. })
  87. },
  88. /* 底部按钮回调 */
  89. tabbarOnClick(e) {
  90. let that = this,
  91. dialogConfig = null,
  92. res = null;
  93. switch (e.detail.label) {
  94. case "编辑":
  95. getApp().globalData.handelSelect = this
  96. wx.navigateTo({
  97. url: '/Eservice/agent/editServiceBill/index',
  98. })
  99. break;
  100. case "提交":
  101. dialogConfig = {
  102. context: this,
  103. title: '提示',
  104. content: '确认提交当前申请单吗',
  105. confirmBtn: '确定',
  106. cancelBtn: '取消',
  107. };
  108. Dialog.confirm(dialogConfig)
  109. .then(async () => {
  110. res = await api._post({
  111. "id": "20230206101403",
  112. "version": 1,
  113. "content": {
  114. "sa_serviceorderid": that.data.id,
  115. "issumbit": 1,
  116. }
  117. });
  118. that.mainData()
  119. })
  120. .catch((err) => console.log(err))
  121. .finally(() => Dialog.close());
  122. break;
  123. case "删除":
  124. dialogConfig = {
  125. context: this,
  126. title: '提示',
  127. content: '确认删除当前申请单吗',
  128. confirmBtn: '确定',
  129. cancelBtn: '取消',
  130. };
  131. Dialog.confirm(dialogConfig)
  132. .then(async () => {
  133. res = await api._post({
  134. "id": "20230206091803",
  135. "version": 1,
  136. "content": {
  137. "sa_serviceorderids": [that.data.id],
  138. }
  139. })
  140. wx.navigateBack()
  141. })
  142. .catch((err) => console.log(err))
  143. .finally(() => Dialog.close());
  144. break;
  145. }
  146. },
  147. async linkWorkOrder() {
  148. const res = await api._post({
  149. "id": "20230207154203",
  150. "version": 1,
  151. "content": {
  152. "sa_serviceorderid": this.data.id
  153. }
  154. })
  155. this.setData({
  156. linkWorkOrders: res.data
  157. })
  158. },
  159. tolinkWorkOrder(e) {
  160. let id = e.currentTarget.dataset.item.sa_workorderid
  161. let app = getApp()
  162. app.globalData.action = ['editLeader']
  163. wx.navigateTo({
  164. url: '/Eservice/workOrderDetail/index?class=stopClick&id=' + id
  165. })
  166. },
  167. /**
  168. * 生命周期函数--监听页面加载
  169. */
  170. onLoad(options) {
  171. this.setData({
  172. id: options.id
  173. })
  174. this.productmx()
  175. },
  176. onShow() {
  177. this.mainData()
  178. },
  179. async onUnload() {
  180. let page = getCurrentPages().find(v => v.__route__ == 'Eservice/agent/serviceBillList/index');
  181. if (!page) return;
  182. let param = JSON.parse(JSON.stringify(page.data.param));
  183. param.content.pageSize = param.content.pageNumber * param.content.pageSize;
  184. param.content.pageNumber = 1;
  185. const res = await api._post(param);
  186. page.setData({
  187. list: res.data
  188. })
  189. },
  190. })