index.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. this.setData({
  27. orderMainData:res.data
  28. })
  29. this.productmx()
  30. this.fileData()
  31. this.workOrderTemp()
  32. this.workerData()
  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/workerLeader/billCanUseProduct/index',
  52. })
  53. },
  54. async getAdd(selection) {
  55. const res = await api._post({
  56. "id": "20230206161803",
  57. "version": 1,
  58. "content": {
  59. "sa_serviceorderid": this.data.id,
  60. "iteminfos":selection.map(e=>{
  61. return {
  62. "sa_serviceorderitemsid": 0,
  63. "itemid": e,
  64. "reason": ""
  65. }
  66. })
  67. }
  68. })
  69. this.productmx()
  70. },
  71. async productmx () {
  72. const res = await api._post({
  73. "id": "20230206161903",
  74. "version": 1,
  75. "content": {
  76. "sa_serviceorderid": this.data.id
  77. }
  78. })
  79. this.setData({
  80. list:res.data
  81. })
  82. },
  83. async onMXDelete (data) {
  84. let itemid = data.detail.sa_serviceorderitemsid
  85. const res = await api._post({
  86. "id": "20230206162003",
  87. "content": {
  88. "sa_serviceorderitemsids": [itemid]
  89. }
  90. })
  91. this.productmx()
  92. },
  93. onEdit () {
  94. getApp().globalData.handelSelect = this
  95. wx.navigateTo({
  96. url: '/Eservice/workerLeader/editServiceBill/index',
  97. })
  98. },
  99. onSubmit() {
  100. let that = this
  101. const dialogConfig = {
  102. context: this,
  103. title: '提示',
  104. content: '确认提交当前申请单吗',
  105. confirmBtn: '确定',
  106. cancelBtn: '取消',
  107. };
  108. Dialog.confirm(dialogConfig)
  109. .then(async () => {
  110. const res = await api._post({
  111. "id": "20230206101403",
  112. "version":1,
  113. "content": {
  114. "sa_serviceorderid":that.data.id,
  115. "issumbit":1,
  116. }
  117. })
  118. that.mainData()
  119. })
  120. .catch((err) => console.log(err))
  121. .finally(() => Dialog.close());
  122. },
  123. showBackReason () {
  124. this.setData({
  125. showWithInput:!this.data.showWithInput
  126. })
  127. },
  128. inputReason (data) {
  129. console.log(data)
  130. this.data.backreason = data.detail.value
  131. },
  132. async onBack() {
  133. let that = this
  134. const res = await api._post({
  135. "id": "20230206101403",
  136. "version":1,
  137. "content": {
  138. "sa_serviceorderid":that.data.id,
  139. "issumbit":0,
  140. "backreason":that.data.backreason
  141. }
  142. })
  143. that.mainData()
  144. },
  145. onDelete() {
  146. let that = this
  147. const dialogConfig = {
  148. context: this,
  149. title: '提示',
  150. content: '确认删除当前申请单吗',
  151. confirmBtn: '确定',
  152. cancelBtn: '取消',
  153. };
  154. Dialog.confirm(dialogConfig)
  155. .then(async () => {
  156. const res = await api._post({
  157. "id": "20230206091803",
  158. "version":1,
  159. "content": {
  160. "sa_serviceorderids":[that.data.id],
  161. }
  162. })
  163. wx.navigateBack()
  164. })
  165. .catch((err) => console.log(err))
  166. .finally(() => Dialog.close());
  167. },
  168. async workOrderTemp () {
  169. const res = await api._post({
  170. "id": "20230206155803",
  171. "version":1,
  172. "content": {
  173. }
  174. })
  175. this.setData({
  176. templist:res.data
  177. })
  178. },
  179. showWorkerDialog () {
  180. this.setData({
  181. showToWoker:!this.data.showToWoker
  182. })
  183. },
  184. selectTemp (data) {
  185. this.setData({
  186. actTemp:data.currentTarget.dataset.item
  187. })
  188. },
  189. async workerData () {
  190. const res = await api._post({
  191. "id": "20230213143003",
  192. "version":1,
  193. "content": {
  194. "where":{
  195. "condition":""
  196. }
  197. }
  198. })
  199. this.setData({
  200. workers:res.data
  201. })
  202. },
  203. selectLeader (data) {
  204. this.setData({
  205. actLeader:data.currentTarget.dataset.item
  206. })
  207. },
  208. async toWorker () {
  209. console.log(this.data.actTemp)
  210. if (!this.data.actTemp && !this.data.actLeader) {
  211. wx.showToast({
  212. title: '未选择工单模板或负责人',
  213. icon:'none'
  214. })
  215. } else {
  216. const res = api._post({
  217. "id": "20230207091003",
  218. "content": {
  219. "type":this.data.actTemp.type,
  220. "sa_serviceorderid":this.data.id,
  221. "projectlearders":[this.data.actLeader.userid]
  222. }
  223. })
  224. this.setData({
  225. showToWoker:false
  226. })
  227. this.mainData()
  228. }
  229. },
  230. async linkWorkOrder() {
  231. const res = await api._post({
  232. "id": "20230207154203",
  233. "version":1,
  234. "content": {
  235. "sa_serviceorderid":this.data.id
  236. }
  237. })
  238. this.setData({
  239. linkWorkOrders:res.data
  240. })
  241. },
  242. tolinkWorkOrder (e) {
  243. let id = e.currentTarget.dataset.item.sa_workorderid
  244. let app = getApp()
  245. app.globalData.action = ['editLeader']
  246. wx.navigateTo({
  247. url: '/Eservice/workerLeader/editworkOrderDetail/index?id=' + id
  248. })
  249. },
  250. async showProgressDialog () {
  251. const res = await api._post({
  252. id:"20230208140203",
  253. content:{}
  254. })
  255. this.setData({
  256. showProgress:!this.data.showProgress,
  257. progress:res.data
  258. })
  259. },
  260. /**
  261. * 生命周期函数--监听页面加载
  262. */
  263. onLoad(options) {
  264. this.setData({
  265. id:options.id
  266. })
  267. this.linkWorkOrder()
  268. },
  269. /**
  270. * 生命周期函数--监听页面初次渲染完成
  271. */
  272. onReady() {
  273. },
  274. /**
  275. * 生命周期函数--监听页面显示
  276. */
  277. onShow() {
  278. this.mainData()
  279. },
  280. /**
  281. * 生命周期函数--监听页面隐藏
  282. */
  283. onHide() {
  284. },
  285. /**
  286. * 生命周期函数--监听页面卸载
  287. */
  288. onUnload() {
  289. },
  290. /**
  291. * 页面相关事件处理函数--监听用户下拉动作
  292. */
  293. onPullDownRefresh() {
  294. },
  295. /**
  296. * 页面上拉触底事件的处理函数
  297. */
  298. onReachBottom() {
  299. },
  300. /**
  301. * 用户点击右上角分享
  302. */
  303. onShareAppMessage() {
  304. }
  305. })