index.js 6.3 KB

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