index.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. showWithInput: false,
  10. showProgress: false,
  11. showToWoker: false,
  12. orderMainData: {},
  13. list: [],
  14. templist: [],
  15. actTemp: null,
  16. actLeader: null
  17. },
  18. async mainData() {
  19. const res = await api._post({
  20. "id": "20230206091603",
  21. "version": 1,
  22. "content": {
  23. "sa_serviceorderid": this.data.id
  24. }
  25. })
  26. let tabbarsList = [];
  27. if (res.data.status == '新建') {
  28. tabbarsList = [{
  29. label: "编辑",
  30. icon: "icon-dibu-bianji"
  31. }, {
  32. label: "提交",
  33. icon: "icon-tijiao",
  34. }, {
  35. label: "删除",
  36. icon: "icon-guanlian-shanchu"
  37. }];
  38. } else if (res.data.status == '待指派') {
  39. tabbarsList = [{
  40. label: "转工单",
  41. icon: "icon-shenhe"
  42. }, {
  43. label: "退回",
  44. icon: "icon-a-fanshenhetuihui",
  45. }];
  46. }
  47. this.setData({
  48. orderMainData: res.data,
  49. tabbarsList
  50. })
  51. this.productmx()
  52. this.fileData()
  53. this.workOrderTemp()
  54. this.workerData()
  55. },
  56. async fileData() {
  57. const res = await api._post({
  58. "method": "queryFileLink",
  59. "classname": "system.attachment.Attachment",
  60. "content": {
  61. "ownertable": "sa_serviceorder",
  62. "ownerid": this.data.id,
  63. "usetype": "附件" //传空返回有所
  64. }
  65. })
  66. this.setData({
  67. filelist: res.data,
  68. refresh: true
  69. })
  70. },
  71. addProduct() {
  72. wx.navigateTo({
  73. url: '/Eservice/workerLeader/billCanUseProduct/index',
  74. })
  75. },
  76. async getAdd(selection) {
  77. const res = await api._post({
  78. "id": "20230206161803",
  79. "version": 1,
  80. "content": {
  81. "sa_serviceorderid": this.data.id,
  82. "iteminfos": selection.map(e => {
  83. return {
  84. "sa_serviceorderitemsid": 0,
  85. "itemid": e,
  86. "reason": ""
  87. }
  88. })
  89. }
  90. })
  91. this.productmx()
  92. },
  93. async productmx() {
  94. const res = await api._post({
  95. "id": "20230206161903",
  96. "version": 1,
  97. "content": {
  98. "sa_serviceorderid": this.data.id
  99. }
  100. })
  101. this.setData({
  102. list: res.data
  103. })
  104. },
  105. async onMXDelete(data) {
  106. let itemid = data.detail.sa_serviceorderitemsid
  107. const res = await api._post({
  108. "id": "20230206162003",
  109. "content": {
  110. "sa_serviceorderitemsids": [itemid]
  111. }
  112. })
  113. this.productmx()
  114. },
  115. /* 底部按钮回调 */
  116. tabbarOnClick(e) {
  117. let that = this,
  118. dialogConfig = null,
  119. res = null;
  120. switch (e.detail.label) {
  121. case "编辑":
  122. getApp().globalData.handelSelect = this
  123. wx.navigateTo({
  124. url: '/Eservice/workerLeader/editServiceBill/index',
  125. })
  126. break;
  127. case "提交":
  128. dialogConfig = {
  129. context: this,
  130. title: '提示',
  131. content: '确认提交当前申请单吗',
  132. confirmBtn: '确定',
  133. cancelBtn: '取消',
  134. };
  135. Dialog.confirm(dialogConfig)
  136. .then(async () => {
  137. res = await api._post({
  138. "id": "20230206101403",
  139. "version": 1,
  140. "content": {
  141. "sa_serviceorderid": that.data.id,
  142. "issumbit": 1,
  143. }
  144. })
  145. that.mainData()
  146. })
  147. .catch((err) => console.log(err))
  148. .finally(() => Dialog.close());
  149. break;
  150. case "删除":
  151. dialogConfig = {
  152. context: this,
  153. title: '提示',
  154. content: '确认删除当前申请单吗',
  155. confirmBtn: '确定',
  156. cancelBtn: '取消',
  157. };
  158. Dialog.confirm(dialogConfig)
  159. .then(async () => {
  160. res = await api._post({
  161. "id": "20230206091803",
  162. "version": 1,
  163. "content": {
  164. "sa_serviceorderids": [that.data.id],
  165. }
  166. })
  167. wx.navigateBack()
  168. })
  169. .catch((err) => console.log(err))
  170. .finally(() => Dialog.close());
  171. break;
  172. case "转工单":
  173. this.setData({
  174. showToWoker: !this.data.showToWoker
  175. })
  176. break;
  177. case "退回":
  178. this.setData({
  179. showWithInput: !this.data.showWithInput
  180. })
  181. break;
  182. }
  183. },
  184. /* 取消按钮 */
  185. showBackReason() {
  186. this.setData({
  187. showWithInput: false,
  188. showToWoker: false
  189. })
  190. },
  191. inputReason(data) {
  192. console.log(data)
  193. this.data.backreason = data.detail.value
  194. },
  195. async onBack() {
  196. let that = this
  197. if (!that.data.backreason) return;
  198. const res = await api._post({
  199. "id": "20230206101403",
  200. "version": 1,
  201. "content": {
  202. "sa_serviceorderid": that.data.id,
  203. "issumbit": 0,
  204. "backreason": that.data.backreason
  205. }
  206. })
  207. that.mainData()
  208. that.showBackReason()
  209. },
  210. async workOrderTemp() {
  211. const res = await api._post({
  212. "id": "20230206155803",
  213. "version": 1,
  214. "content": {}
  215. })
  216. this.setData({
  217. templist: res.data
  218. })
  219. },
  220. selectTemp(data) {
  221. this.setData({
  222. actTemp: data.currentTarget.dataset.item
  223. })
  224. },
  225. async workerData() {
  226. const res = await api._post({
  227. "id": "20230213143003",
  228. "version": 1,
  229. "content": {
  230. "where": {
  231. "condition": ""
  232. }
  233. }
  234. })
  235. this.setData({
  236. workers: res.data
  237. })
  238. },
  239. selectLeader(data) {
  240. this.setData({
  241. actLeader: data.currentTarget.dataset.item
  242. })
  243. },
  244. async toWorker() {
  245. console.log(this.data.actTemp)
  246. if (!this.data.actTemp && !this.data.actLeader) {
  247. wx.showToast({
  248. title: '未选择工单模板或负责人',
  249. icon: 'none'
  250. })
  251. } else {
  252. const res = await api._post({
  253. "id": "20230207091003",
  254. "content": {
  255. "type": this.data.actTemp.type,
  256. "sa_serviceorderid": this.data.id,
  257. "sa_workorder_templateid": this.data.actTemp.sa_workorder_templateid,
  258. "projectlearders": [this.data.actLeader.userid]
  259. }
  260. })
  261. this.mainData()
  262. this.showBackReason()
  263. }
  264. },
  265. async linkWorkOrder() {
  266. const res = await api._post({
  267. "id": "20230207154203",
  268. "version": 1,
  269. "content": {
  270. "sa_serviceorderid": this.data.id
  271. }
  272. })
  273. this.setData({
  274. linkWorkOrders: res.data
  275. })
  276. },
  277. tolinkWorkOrder(e) {
  278. let id = e.currentTarget.dataset.item.sa_workorderid
  279. let app = getApp()
  280. app.globalData.action = ['editLeader']
  281. wx.navigateTo({
  282. url: '/Eservice/workerLeader/editworkOrderDetail/index?id=' + id
  283. })
  284. },
  285. async showProgressDialog() {
  286. const res = await api._post({
  287. id: "20230208140203",
  288. content: {}
  289. })
  290. this.setData({
  291. showProgress: !this.data.showProgress,
  292. progress: res.data
  293. })
  294. },
  295. /**
  296. * 生命周期函数--监听页面加载
  297. */
  298. onLoad(options) {
  299. this.setData({
  300. id: options.id
  301. })
  302. this.linkWorkOrder()
  303. },
  304. /**
  305. * 生命周期函数--监听页面初次渲染完成
  306. */
  307. onReady() {
  308. },
  309. /**
  310. * 生命周期函数--监听页面显示
  311. */
  312. onShow() {
  313. this.mainData()
  314. },
  315. /**
  316. * 生命周期函数--监听页面隐藏
  317. */
  318. onHide() {
  319. },
  320. /**
  321. * 生命周期函数--监听页面卸载
  322. */
  323. onUnload() {
  324. },
  325. /**
  326. * 页面相关事件处理函数--监听用户下拉动作
  327. */
  328. onPullDownRefresh() {
  329. },
  330. /**
  331. * 页面上拉触底事件的处理函数
  332. */
  333. onReachBottom() {
  334. },
  335. /**
  336. * 用户点击右上角分享
  337. */
  338. onShareAppMessage() {
  339. }
  340. })