index.js 5.2 KB

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