index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. onDelete({
  58. detail
  59. }) {
  60. let that = this;
  61. wx.showModal({
  62. title: getApp().globalData.Language.getMapText('提示'),
  63. content: `是否确定删除“${detail.itemname}”`,
  64. complete: (res) => {
  65. if (res.confirm) api._post({
  66. "id": "20230206162003",
  67. "version": 1,
  68. "content": {
  69. sa_serviceorderitemsids: [detail.sa_serviceorderitemsid]
  70. }
  71. }).then(res => {
  72. console.log("删除明细", res)
  73. wx.showToast({
  74. title: res.msg == '成功' ? getApp().globalData.Language.getMapText('删除成功') : res.msg,
  75. icon: "none"
  76. });
  77. that.productmx()
  78. })
  79. }
  80. })
  81. },
  82. async getAdd(selection) {
  83. const res = await api._post({
  84. "id": "20230206161803",
  85. "version": 1,
  86. "content": {
  87. "sa_serviceorderid": this.data.id,
  88. "iteminfos": selection.map(e => {
  89. return {
  90. "sa_serviceorderitemsid": 0,
  91. "itemid": e,
  92. "reason": "",
  93. "qty": 1
  94. }
  95. })
  96. }
  97. })
  98. this.productmx()
  99. },
  100. async changeItem({
  101. detail
  102. }) {
  103. const res = await api._post({
  104. "id": "20230206161803",
  105. "version": 1,
  106. "content": {
  107. "sa_serviceorderid": this.data.id,
  108. "iteminfos": [{
  109. "sa_serviceorderitemsid": detail.sa_serviceorderitemsid,
  110. "itemid": detail.sa_serviceorderitemsid,
  111. "reason": detail.reason,
  112. "qty": detail.qty
  113. }]
  114. }
  115. })
  116. wx.showToast({
  117. title: res.msg == '成功' ? '修改成功' : res.msg,
  118. icon: "none"
  119. })
  120. this.productmx()
  121. },
  122. async productmx() {
  123. const res = await api._post({
  124. "id": "20230206161903",
  125. "version": 1,
  126. "content": {
  127. nocache: true,
  128. "sa_serviceorderid": this.data.id
  129. }
  130. })
  131. this.setData({
  132. list: res.data.map(v => {
  133. v.oldQty = v.qty;
  134. return v
  135. })
  136. })
  137. },
  138. /* 底部按钮回调 */
  139. tabbarOnClick(e) {
  140. let that = this,
  141. dialogConfig = null,
  142. res = null;
  143. switch (e.detail.label) {
  144. case "编辑":
  145. getApp().globalData.handelSelect = this
  146. wx.navigateTo({
  147. url: '/Eservice/saler/editServiceBill/index',
  148. })
  149. break;
  150. case "提交":
  151. dialogConfig = {
  152. context: this,
  153. title: getApp().globalData.Language.getMapText('提示'),
  154. content: '确认提交当前申请单吗',
  155. confirmBtn: '确定',
  156. cancelBtn: '取消',
  157. };
  158. Dialog.confirm(dialogConfig)
  159. .then(async () => {
  160. res = await api._post({
  161. "id": "20230206101403",
  162. "version": 1,
  163. "content": {
  164. "sa_serviceorderid": that.data.id,
  165. "issumbit": 1,
  166. }
  167. })
  168. that.mainData()
  169. })
  170. .catch((err) => console.log(err))
  171. .finally(() => Dialog.close());
  172. break;
  173. case "删除":
  174. dialogConfig = {
  175. context: this,
  176. title: getApp().globalData.Language.getMapText('提示'),
  177. content: '确认删除当前申请单吗',
  178. confirmBtn: '确定',
  179. cancelBtn: '取消',
  180. };
  181. Dialog.confirm(dialogConfig)
  182. .then(async () => {
  183. res = await api._post({
  184. "id": "20230206091803",
  185. "version": 1,
  186. "content": {
  187. "sa_serviceorderids": [that.data.id],
  188. }
  189. })
  190. wx.navigateBack()
  191. })
  192. .catch((err) => console.log(err))
  193. .finally(() => Dialog.close());
  194. break;
  195. }
  196. },
  197. async linkWorkOrder() {
  198. const res = await api._post({
  199. "id": "20230207154203",
  200. "version": 1,
  201. "content": {
  202. "sa_serviceorderid": this.data.id
  203. }
  204. })
  205. this.setData({
  206. linkWorkOrders: res.data
  207. })
  208. },
  209. tolinkWorkOrder(e) {
  210. let id = e.currentTarget.dataset.item.sa_workorderid
  211. let app = getApp()
  212. app.globalData.action = ['editLeader']
  213. wx.navigateTo({
  214. url: '/Eservice/workOrderDetail/index?class=stopClick&id=' + id
  215. })
  216. },
  217. /**
  218. * 生命周期函数--监听页面加载
  219. */
  220. onLoad(options) {
  221. this.setData({
  222. id: options.id
  223. })
  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. })