serviceTicket.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. var util = require('../../../utils/util.js')
  2. const app = getApp()
  3. Page({
  4. data: {
  5. currentTab: '1',
  6. noData: '../../../images/noData.png',
  7. dataListTips: '暂无数据',
  8. serviceStaffname: '',
  9. showModal: false, // 控制弹窗显示
  10. form: {
  11. estimatedCompleteTime: '', // 存储选择的日期
  12. acceptName: wx.getStorageSync('username'),
  13. acceptTime: util.getRealToday(),
  14. },
  15. //表格请求参数~~
  16. table1: {
  17. name: 'getInstallationOrderList',
  18. page: 1,
  19. offset: 1,
  20. pagecount: 9999,
  21. returntype: 'Map',
  22. parammaps: {
  23. statusName: '待处理',
  24. roleId: app.globalData.g_roleId,
  25. userId: app.globalData.g_userId,
  26. },
  27. },
  28. table2: {
  29. name: 'getInstallationOrderList',
  30. page: 1,
  31. offset: 1,
  32. pagecount: 9999,
  33. returntype: 'Map',
  34. parammaps: {
  35. serviceStaffIds: '',
  36. customerName: '',
  37. statusName: '已完成',
  38. roleId: app.globalData.g_roleId,
  39. userId: app.globalData.g_userId,
  40. completeStartTime: util.get15daysAgo(),
  41. completeEndTime: util.getRealToday(),
  42. },
  43. },
  44. itemObj: {},
  45. installerList: [],
  46. pendingList: [],
  47. processedList: [],
  48. },
  49. onLoad: function () {
  50. this.getList()
  51. this.getinstallerList()
  52. },
  53. onShow: function () {
  54. // 根据当前选中的tab刷新对应的列表
  55. if (this.data.currentTab === '1') {
  56. this.getList()
  57. } else {
  58. this.getList2()
  59. }
  60. },
  61. // 服务人员
  62. getinstallerList() {
  63. var send_data = [
  64. {
  65. name: 'getUsersSelect',
  66. offset: 0,
  67. pagecount: 0,
  68. parammaps: {
  69. enable: '1',
  70. },
  71. },
  72. ]
  73. util.getDataByNames(send_data, this.handleInstallerList)
  74. },
  75. handleInstallerList(res) {
  76. console.log(res, '服务人员')
  77. const obj = res.data
  78. if (obj.getUsersSelect) {
  79. this.setData({
  80. installerList: obj.getUsersSelect.list,
  81. })
  82. }
  83. },
  84. //加载表格
  85. getList() {
  86. this.setData({
  87. ['table1.parammaps.roleId']: app.globalData.g_roleId,
  88. ['table1.parammaps.userId']: app.globalData.g_userId,
  89. })
  90. util.getDataByName(this.data.table1, this.getListSuccess1)
  91. },
  92. getList2() {
  93. this.setData({
  94. ['table2.parammaps.roleId']: app.globalData.g_roleId,
  95. ['table2.parammaps.userId']: app.globalData.g_userId,
  96. })
  97. util.getDataByName(this.data.table2, this.getListSuccess2)
  98. },
  99. getListSuccess1: function (res) {
  100. const obj = res.data
  101. if (obj.list != null) {
  102. this.setData({
  103. pendingList: res.data.list,
  104. ['table1.parammaps.offset']: res.data.pageNum,
  105. ['table1.total']: res.data.total,
  106. })
  107. } else {
  108. this.setData({
  109. pendingList: [],
  110. ['table1.parammaps.offset']: 1,
  111. })
  112. }
  113. },
  114. getListSuccess2: function (res) {
  115. const obj = res.data
  116. if (obj.list != null) {
  117. this.setData({
  118. processedList: res.data.list,
  119. ['table2.parammaps.offset']: res.data.pageNum,
  120. ['table2.total']: res.data.total,
  121. })
  122. } else {
  123. this.setData({
  124. processedList: [],
  125. ['table2.parammaps.offset']: 1,
  126. })
  127. }
  128. },
  129. //日期1
  130. bindDateChange1: function (e) {
  131. this.setData({
  132. ['table2.parammaps.completeStartTime']: e.detail.value,
  133. })
  134. },
  135. //日期2
  136. bindDateChange2: function (e) {
  137. this.setData({
  138. ['table2.parammaps.completeEndTime']: e.detail.value,
  139. })
  140. },
  141. onInstallerChange: function (e) {
  142. console.log(e, 'eee')
  143. this.setData({
  144. serviceStaffname: this.data.installerList[e.detail.value].name,
  145. ['table2.parammaps.serviceStaffIds']: this.data.installerList[e.detail.value].id,
  146. })
  147. },
  148. onInputChangeClear: function (e) {
  149. console.log(e, 'eee')
  150. this.setData({
  151. serviceStaffname: '',
  152. ['table2.parammaps.serviceStaffIds']: '',
  153. })
  154. },
  155. onInputChange: function (e) {
  156. console.log(e, 'eee')
  157. this.setData({
  158. ['table2.parammaps.customerName']: e.detail.value,
  159. })
  160. },
  161. changeTab(e) {
  162. this.setData({
  163. currentTab: e.detail.activeKey,
  164. serviceStaffname: '',
  165. ['table2.parammaps.serviceStaffIds']: '',
  166. })
  167. // 可以在这里根据tab加载不同的数据
  168. if (this.data.currentTab == '1') {
  169. this.getList()
  170. } else {
  171. this.getList2()
  172. }
  173. },
  174. // 隐藏弹窗
  175. hideDatePicker() {
  176. this.setData({
  177. showModal: false,
  178. })
  179. wx.showToast({
  180. title: '已取消接单',
  181. icon: 'none',
  182. duration: 5000,
  183. })
  184. },
  185. // 处理日期选择
  186. handleDateChange(e) {
  187. const estimatedCompleteTime = e.detail.value // 获取选择的日期
  188. this.setData({
  189. ['form.estimatedCompleteTime']: estimatedCompleteTime,
  190. })
  191. console.log('选择的日期:', estimatedCompleteTime)
  192. },
  193. handleAccept(e) {
  194. var obj = e.target.dataset.id
  195. this.setData({
  196. showModal: true,
  197. ['form.id']: obj.id,
  198. ['form.statusName']: obj.statusName,
  199. })
  200. },
  201. handleAcceptConfirm() {
  202. if (!this.data.form.estimatedCompleteTime) {
  203. wx.showToast({
  204. title: '预计时间必填',
  205. icon: 'none',
  206. duration: 5000,
  207. })
  208. return
  209. }
  210. var send_data = {
  211. common: { returnmap: '0' },
  212. data: [
  213. {
  214. name: 'acceptInstallationOrder',
  215. type: 'e',
  216. parammaps: {
  217. orderId: this.data.form.id,
  218. acceptName: wx.getStorageSync('username'),
  219. acceptId: wx.getStorageSync('g_userId'),
  220. acceptTime: this.data.form.acceptTime,
  221. estimatedCompleteTime: this.data.form.estimatedCompleteTime,
  222. },
  223. },
  224. {
  225. name: 'insertInstallationOrderProcessLog',
  226. type: 'e',
  227. parammaps: {
  228. orderId: this.data.form.id,
  229. operationType: 'accept',
  230. operationUserId: wx.getStorageSync('g_userId'),
  231. operationUserName: wx.getStorageSync('username'),
  232. beforeStatus: this.data.form.statusName,
  233. afterStatus: '处理中',
  234. operationContent: '接单处理',
  235. },
  236. },
  237. ],
  238. }
  239. util.execDataByConfig(send_data, this.handleAcceptList)
  240. },
  241. handleAcceptList(res) {
  242. console.log(res, '99999')
  243. if (res.code == 200) {
  244. wx.showToast({
  245. title: '已成功接单',
  246. icon: 'success',
  247. duration: 5000,
  248. })
  249. this.setData({
  250. showModal: false,
  251. })
  252. this.getList()
  253. }
  254. },
  255. handleReject(e) {
  256. var obj = e.target.dataset.id
  257. wx.showModal({
  258. title: '驳回原因',
  259. editable: true,
  260. placeholderText: '请输入驳回原因',
  261. success: (res) => {
  262. if (res.confirm) {
  263. const rejectReason = res.content
  264. if (!rejectReason) {
  265. wx.showToast({
  266. title: '请输入驳回原因',
  267. icon: 'none',
  268. duration: 5000,
  269. })
  270. return
  271. }
  272. // 处理驳回逻辑
  273. var send_data = {
  274. common: { returnmap: '0' },
  275. data: [
  276. {
  277. name: 'rejectInstallationOrder',
  278. type: 'e',
  279. parammaps: {
  280. orderId: obj.id,
  281. rejectReason: rejectReason,
  282. rejectId: wx.getStorageSync('g_userId'),
  283. },
  284. },
  285. {
  286. name: 'insertInstallationOrderProcessLog',
  287. type: 'e',
  288. parammaps: {
  289. orderId: obj.id,
  290. operationType: 'reject',
  291. operationUserId: wx.getStorageSync('g_userId'),
  292. operationUserName: wx.getStorageSync('username'),
  293. beforeStatus: obj.statusName,
  294. afterStatus: '接单驳回',
  295. operationContent: `驳回原因:${rejectReason}`,
  296. },
  297. },
  298. ],
  299. }
  300. util.execDataByConfig(send_data, this.handleRejectList)
  301. } else if (res.cancel) {
  302. console.log('用户取消驳回')
  303. wx.showToast({
  304. title: '已取消驳回',
  305. icon: 'none',
  306. duration: 5000,
  307. })
  308. }
  309. },
  310. })
  311. },
  312. handleRejectList(res) {
  313. console.log(res, '已驳回')
  314. if (res.code == 200) {
  315. wx.showToast({
  316. title: '已驳回',
  317. icon: 'success',
  318. duration: 5000,
  319. })
  320. this.getList()
  321. }
  322. },
  323. handleSuccess(e) {
  324. var obj = e.target.dataset.id
  325. wx.showModal({
  326. title: '提示',
  327. content: '是否确认完成?',
  328. success: (res) => {
  329. if (res.confirm) {
  330. // 处理驳回逻辑
  331. var send_data = {
  332. common: { returnmap: '0' },
  333. data: [
  334. {
  335. name: 'completeInstallationOrder',
  336. type: 'e',
  337. parammaps: {
  338. orderId: obj.id,
  339. },
  340. },
  341. {
  342. name: 'insertInstallationOrderProcessLog',
  343. type: 'e',
  344. parammaps: {
  345. orderId: obj.id,
  346. operationType: 'complete',
  347. operationUserId: wx.getStorageSync('g_userId'),
  348. operationUserName: wx.getStorageSync('username'),
  349. beforeStatus: obj.statusName,
  350. afterStatus: '已完成未验收',
  351. operationContent: '完成服务工单',
  352. },
  353. },
  354. ],
  355. }
  356. util.execDataByConfig(send_data, this.handleSuccessList)
  357. // 这里可以添加驳回的具体逻辑
  358. } else if (res.cancel) {
  359. wx.showToast({
  360. title: '已取消完成',
  361. icon: 'none',
  362. duration: 5000,
  363. })
  364. }
  365. },
  366. })
  367. },
  368. handleSuccessList(res) {
  369. if (res.code == 200) {
  370. wx.showToast({
  371. title: '已完成',
  372. icon: 'success',
  373. duration: 3000,
  374. })
  375. this.getList()
  376. }
  377. },
  378. handleReport1(e) {
  379. const id = e.currentTarget.dataset.id
  380. wx.navigateTo({
  381. url: `/pages/workbench/dailyFill/dailyFill?id=${id}`,
  382. })
  383. },
  384. handleReport2(e) {
  385. const id = e.currentTarget.dataset.id
  386. wx.navigateTo({
  387. url: `/pages/workbench/acceptFill/acceptFill?id=${id}`, // 正确跳转到验收填写页面并传入id参数
  388. })
  389. },
  390. handleDetail(e) {
  391. const id = e.currentTarget.dataset.id
  392. wx.navigateTo({
  393. url: `/pages/workbench/serviceOrderDetail/serviceOrderDetail?id=${id}`,
  394. })
  395. },
  396. })