index.js 5.1 KB

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