index.js 8.5 KB

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