index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. })
  34. this.fileData()
  35. this.linkWorkOrder()
  36. },
  37. async fileData() {
  38. const res = await api._post({
  39. "method": "queryFileLink",
  40. "classname": "system.attachment.Attachment",
  41. "content": {
  42. "ownertable": "sa_serviceorder",
  43. "ownerid": this.data.id,
  44. "usetype": "附件" //传空返回有所
  45. }
  46. })
  47. this.setData({
  48. filelist: res.data,
  49. refresh: true
  50. })
  51. },
  52. addProduct() {
  53. wx.navigateTo({
  54. url: '/Eservice/saler/billCanUseProduct/index',
  55. })
  56. },
  57. async getAdd(selection) {
  58. const res = await api._post({
  59. "id": "20230206161803",
  60. "version": 1,
  61. "content": {
  62. "sa_serviceorderid": this.data.id,
  63. "iteminfos": selection.map(e => {
  64. return {
  65. "sa_serviceorderitemsid": 0,
  66. "itemid": e,
  67. "reason": "",
  68. "qty": 1
  69. }
  70. })
  71. }
  72. })
  73. this.productmx()
  74. },
  75. async changeItem({
  76. detail
  77. }) {
  78. const res = await api._post({
  79. "id": "20230206161803",
  80. "version": 1,
  81. "content": {
  82. "sa_serviceorderid": this.data.id,
  83. "iteminfos": [{
  84. "sa_serviceorderitemsid": detail.sa_serviceorderitemsid,
  85. "itemid": detail.sa_serviceorderitemsid,
  86. "reason": detail.reason,
  87. "qty": detail.qty
  88. }]
  89. }
  90. })
  91. wx.showToast({
  92. title: res.msg == '成功' ? '修改成功' : res.msg,
  93. icon: "none"
  94. })
  95. this.productmx()
  96. },
  97. async productmx() {
  98. const res = await api._post({
  99. "id": "20230206161903",
  100. "version": 1,
  101. "content": {
  102. "sa_serviceorderid": this.data.id
  103. }
  104. })
  105. this.setData({
  106. list: res.data.map(v => {
  107. v.oldQty = v.qty;
  108. return v
  109. })
  110. })
  111. },
  112. /* 底部按钮回调 */
  113. tabbarOnClick(e) {
  114. let that = this,
  115. dialogConfig = null,
  116. res = null;
  117. switch (e.detail.label) {
  118. case "编辑":
  119. getApp().globalData.handelSelect = this
  120. wx.navigateTo({
  121. url: '/Eservice/saler/editServiceBill/index',
  122. })
  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": "20230206101403",
  136. "version": 1,
  137. "content": {
  138. "sa_serviceorderid": that.data.id,
  139. "issumbit": 1,
  140. }
  141. })
  142. that.mainData()
  143. })
  144. .catch((err) => console.log(err))
  145. .finally(() => Dialog.close());
  146. break;
  147. case "删除":
  148. dialogConfig = {
  149. context: this,
  150. title: '提示',
  151. content: '确认删除当前申请单吗',
  152. confirmBtn: '确定',
  153. cancelBtn: '取消',
  154. };
  155. Dialog.confirm(dialogConfig)
  156. .then(async () => {
  157. res = await api._post({
  158. "id": "20230206091803",
  159. "version": 1,
  160. "content": {
  161. "sa_serviceorderids": [that.data.id],
  162. }
  163. })
  164. wx.navigateBack()
  165. })
  166. .catch((err) => console.log(err))
  167. .finally(() => Dialog.close());
  168. break;
  169. }
  170. },
  171. async linkWorkOrder() {
  172. const res = await api._post({
  173. "id": "20230207154203",
  174. "version": 1,
  175. "content": {
  176. "sa_serviceorderid": this.data.id
  177. }
  178. })
  179. this.setData({
  180. linkWorkOrders: res.data
  181. })
  182. },
  183. tolinkWorkOrder(e) {
  184. let id = e.currentTarget.dataset.item.sa_workorderid
  185. let app = getApp()
  186. app.globalData.action = ['editLeader']
  187. wx.navigateTo({
  188. url: '/Eservice/workOrderDetail/index?class=stopClick&id=' + id
  189. })
  190. },
  191. /**
  192. * 生命周期函数--监听页面加载
  193. */
  194. onLoad(options) {
  195. this.setData({
  196. id: options.id
  197. })
  198. this.productmx()
  199. },
  200. /**
  201. * 生命周期函数--监听页面初次渲染完成
  202. */
  203. onReady() {
  204. },
  205. /**
  206. * 生命周期函数--监听页面显示
  207. */
  208. onShow() {
  209. this.mainData()
  210. },
  211. /**
  212. * 生命周期函数--监听页面隐藏
  213. */
  214. onHide() {
  215. },
  216. /**
  217. * 生命周期函数--监听页面卸载
  218. */
  219. onUnload() {
  220. },
  221. /**
  222. * 页面相关事件处理函数--监听用户下拉动作
  223. */
  224. onPullDownRefresh() {
  225. },
  226. /**
  227. * 页面上拉触底事件的处理函数
  228. */
  229. onReachBottom() {
  230. },
  231. /**
  232. * 用户点击右上角分享
  233. */
  234. onShareAppMessage() {
  235. }
  236. })