index.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. // pages/agent/serviceBillDetail/index.js
  2. import api from '../../api/api'
  3. import Dialog from 'tdesign-miniprogram/dialog/index';
  4. Page({
  5. data: {
  6. refresh: true,
  7. orderMainData: {},
  8. list: [],
  9. tabbarsList: [{
  10. label: "编辑",
  11. icon: "icon-dibu-bianji"
  12. }, {
  13. label: "提交",
  14. icon: "icon-tijiao",
  15. }, {
  16. label: "删除",
  17. icon: "icon-guanlian-shanchu"
  18. }]
  19. },
  20. async mainData() {
  21. const res = await api._post({
  22. "id": "20230206091603",
  23. "version": 1,
  24. "content": {
  25. "sa_serviceorderid": this.data.id
  26. }
  27. })
  28. this.setData({
  29. orderMainData: res.data
  30. })
  31. this.fileData()
  32. this.linkWorkOrder()
  33. },
  34. async fileData() {
  35. const res = await api._post({
  36. "method": "queryFileLink",
  37. "classname": "system.attachment.Attachment",
  38. "content": {
  39. "ownertable": "sa_serviceorder",
  40. "ownerid": this.data.id,
  41. "usetype": "" //传空返回有所
  42. }
  43. })
  44. this.setData({
  45. filelist: res.data,
  46. refresh: true
  47. })
  48. },
  49. addProduct() {
  50. wx.navigateTo({
  51. url: '/Eservice/saler/billCanUseProduct/index',
  52. })
  53. },
  54. onDelete({
  55. detail
  56. }) {
  57. let that = this;
  58. wx.showModal({
  59. cancelText: getApp().globalData.Language.getMapText('取消'),
  60. confirmText: getApp().globalData.Language.getMapText('确定'),
  61. title: getApp().globalData.Language.getMapText('提示'),
  62. content: getApp().globalData.Language.getMapText('是否确定删除')+`“${detail.itemname}”`,
  63. complete: (res) => {
  64. if (res.confirm) api._post({
  65. "id": "20230206162003",
  66. "version": 1,
  67. "content": {
  68. sa_serviceorderitemsids: [detail.sa_serviceorderitemsid]
  69. }
  70. }).then(res => {
  71. console.log("删除明细", res)
  72. wx.showToast({
  73. title: res.code == '1' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
  74. icon: "none"
  75. });
  76. that.productmx()
  77. })
  78. }
  79. })
  80. },
  81. async getAdd(selection) {
  82. const res = await api._post({
  83. "id": "20230206161803",
  84. "version": 1,
  85. "content": {
  86. "sa_serviceorderid": this.data.id,
  87. "iteminfos": selection.map(e => {
  88. return {
  89. "sa_serviceorderitemsid": 0,
  90. "itemid": e,
  91. "reason": "",
  92. "qty": 1
  93. }
  94. })
  95. }
  96. })
  97. this.productmx()
  98. },
  99. async changeItem({
  100. detail
  101. }) {
  102. const res = await api._post({
  103. "id": "20230206161803",
  104. "version": 1,
  105. "content": {
  106. "sa_serviceorderid": this.data.id,
  107. "iteminfos": [{
  108. "sa_serviceorderitemsid": detail.sa_serviceorderitemsid,
  109. "itemid": detail.sa_serviceorderitemsid,
  110. "reason": detail.reason,
  111. "qty": detail.qty
  112. }]
  113. }
  114. })
  115. wx.showToast({
  116. title: res.code == '1' ? getApp().globalData.Language.getMapText('修改成功') : res.msg,
  117. icon: "none"
  118. })
  119. this.productmx()
  120. },
  121. async productmx() {
  122. const res = await api._post({
  123. "id": "20230206161903",
  124. "version": 1,
  125. "content": {
  126. nocache: true,
  127. "sa_serviceorderid": this.data.id
  128. }
  129. })
  130. this.setData({
  131. list: res.data.map(v => {
  132. v.oldQty = v.qty;
  133. return v
  134. })
  135. })
  136. },
  137. /* 底部按钮回调 */
  138. tabbarOnClick(e) {
  139. let that = this,
  140. dialogConfig = null,
  141. res = null;
  142. switch (e.detail.label) {
  143. case "编辑":
  144. getApp().globalData.handelSelect = this
  145. wx.navigateTo({
  146. url: '/Eservice/saler/editServiceBill/index',
  147. })
  148. break;
  149. case "提交":
  150. dialogConfig = {
  151. context: this,
  152. title: getApp().globalData.Language.getMapText('提示'),
  153. content:getApp().globalData.Language.getMapText('确认提交当前申请单吗'),
  154. confirmBtn:getApp().globalData.Language.getMapText('确定'),
  155. cancelBtn:getApp().globalData.Language.getMapText('取消'),
  156. };
  157. Dialog.confirm(dialogConfig)
  158. .then(async () => {
  159. res = await api._post({
  160. "id": "20230206101403",
  161. "version": 1,
  162. "content": {
  163. "sa_serviceorderid": that.data.id,
  164. "issumbit": 1,
  165. }
  166. })
  167. that.mainData()
  168. })
  169. .catch((err) => console.log(err))
  170. .finally(() => Dialog.close());
  171. break;
  172. case "删除":
  173. dialogConfig = {
  174. context: this,
  175. title: getApp().globalData.Language.getMapText('提示'),
  176. content:getApp().globalData.Language.getMapText('确认删除当前申请单吗'),
  177. confirmBtn:getApp().globalData.Language.getMapText('确定'),
  178. cancelBtn:getApp().globalData.Language.getMapText('取消'),
  179. };
  180. Dialog.confirm(dialogConfig)
  181. .then(async () => {
  182. res = await api._post({
  183. "id": "20230206091803",
  184. "version": 1,
  185. "content": {
  186. "sa_serviceorderids": [that.data.id],
  187. }
  188. })
  189. wx.navigateBack()
  190. })
  191. .catch((err) => console.log(err))
  192. .finally(() => Dialog.close());
  193. break;
  194. }
  195. },
  196. async linkWorkOrder() {
  197. const res = await api._post({
  198. "id": "20230207154203",
  199. "version": 1,
  200. "content": {
  201. "sa_serviceorderid": this.data.id
  202. }
  203. })
  204. this.setData({
  205. linkWorkOrders: res.data
  206. })
  207. },
  208. tolinkWorkOrder(e) {
  209. let id = e.currentTarget.dataset.item.sa_workorderid
  210. let app = getApp()
  211. app.globalData.action = ['editLeader']
  212. wx.navigateTo({
  213. url: '/Eservice/workOrderDetail/index?class=stopClick&id=' + id
  214. })
  215. },
  216. /**
  217. * 生命周期函数--监听页面加载
  218. */
  219. onLoad(options) {
  220. this.setData({
  221. id: options.id
  222. })
  223. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  224. this.productmx()
  225. },
  226. /**
  227. * 生命周期函数--监听页面初次渲染完成
  228. */
  229. onReady() {
  230. },
  231. /**
  232. * 生命周期函数--监听页面显示
  233. */
  234. onShow() {
  235. this.mainData()
  236. },
  237. /**
  238. * 生命周期函数--监听页面隐藏
  239. */
  240. onHide() {
  241. },
  242. /**
  243. * 生命周期函数--监听页面卸载
  244. */
  245. onUnload() {
  246. },
  247. /**
  248. * 页面相关事件处理函数--监听用户下拉动作
  249. */
  250. onPullDownRefresh() {
  251. },
  252. /**
  253. * 页面上拉触底事件的处理函数
  254. */
  255. onReachBottom() {
  256. },
  257. /**
  258. * 用户点击右上角分享
  259. */
  260. onShareAppMessage() {
  261. }
  262. })