index.js 4.9 KB

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