index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. // pages/reservationMan/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. str:' ',
  9. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  10. roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '',
  11. searchVal: '', //筛选条件
  12. type:'',//预约类型
  13. appointmentClassifyArray: [
  14. { label:'充电预约',value:'1' },
  15. { label:'管桩预约',value:'2' },
  16. { label:'其他预约',value:'3' },
  17. ], //预约类型
  18. appointmentTypeArray: [{
  19. dictValue: "",
  20. dictLabel: "全部状态"
  21. }],
  22. appointmentTypeIndex: 0,
  23. appointmentStatusArray: [{
  24. dictValue: "",
  25. dictLabel: "全部状态"
  26. }],
  27. appointmentStatusIndex: 0,
  28. appointmentType: '', //切换显示
  29. appointmentTypeSha: '', //砂石
  30. appointmentTypeQi: '', //起卸
  31. appointmentTypeGuan: '', //管桩
  32. appointmentTypeChong: '', //充电桩
  33. appointmentTypeOther: '', //其他
  34. //分页
  35. limit: 10,
  36. requestStatu: '加载中...',
  37. page: 1,
  38. totalPages: 1,
  39. more: false,
  40. nomore: '',
  41. //筛选E
  42. setIndex: 0,
  43. resData: [],
  44. show:false,
  45. auditFlag:'false',
  46. appointmentReason:'',//审核备注
  47. showQrcode:false,
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad(options) {
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady() {
  58. },
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow() {
  63. const roleCodeList = wx.getStorageSync('roleCodeList')
  64. let loginStatus = wx.getStorageSync('loginStatus')
  65. this.setData({
  66. searchVal: '',
  67. roleCodeList: roleCodeList ? roleCodeList : '',
  68. loginStatus: loginStatus ? loginStatus : false
  69. })
  70. //动态tabbar
  71. // if (roleCodeList == 'bizAdmin') {
  72. // this.getTabBar().setData({
  73. // list: app.globalData.allList[0].list2,
  74. // })
  75. // } else if(roleCodeList == 'send') {
  76. // this.getTabBar().setData({
  77. // list: app.globalData.allList[0].list3,
  78. // })
  79. // } else if(roleCodeList == 'sale') {
  80. // this.getTabBar().setData({
  81. // list: app.globalData.allList[0].list4,
  82. // })
  83. // }else if(roleCodeList == 'customer') {
  84. // this.getTabBar().setData({
  85. // list: app.globalData.allList[0].list5,
  86. // })
  87. // } else if (roleCodeList=='driver'||roleCodeList==''){
  88. // this.getTabBar().setData({
  89. // list: app.globalData.allList[0].list1,
  90. // })
  91. // }
  92. // if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  93. // this.getTabBar().setData({
  94. // selected: 2
  95. // })
  96. // }
  97. if(wx.getStorageSync('loginStatus')){
  98. this.getListFun();
  99. }
  100. if(this.data.appointmentStatusArray.length==1 || this.data.appointmentTypeArray.length==1){
  101. this.getTree()
  102. }
  103. },
  104. //获取字典数据
  105. getTree:function(){
  106. app.request.GET({
  107. url:app.API.getTree,
  108. page:this,
  109. successFun:true
  110. }).then(res=>{
  111. if(this.data.appointmentStatusArray.length==1){
  112. let treeData = res.data.data
  113. for (const element of treeData) {
  114. let arrStr;
  115. switch (element.dictValue) {
  116. case 'appointment_status':
  117. arrStr = "appointmentStatusArray";
  118. break;
  119. }
  120. let getArray = this.data.appointmentStatusArray
  121. this.setData({
  122. [arrStr]: getArray.concat(element.children)
  123. })
  124. }
  125. }
  126. if(this.data.appointmentTypeArray.length==1){
  127. let treeData = res.data.data
  128. for (const element of treeData) {
  129. let arrStr;
  130. switch (element.dictValue) {
  131. case 'appointment_type':
  132. arrStr = "appointmentTypeArray";
  133. break;
  134. }
  135. let getArray = this.data.appointmentTypeArray
  136. this.setData({
  137. [arrStr]: getArray.concat(element.children)
  138. })
  139. }
  140. }
  141. })
  142. },
  143. //搜索框请求S
  144. onChange(e) {
  145. this.setData({
  146. searchVal: e.detail,
  147. });
  148. },
  149. onSearch: function (event) {
  150. this.setData({
  151. searchVal: event.detail
  152. })
  153. this.getListFun();
  154. },
  155. typeFun: function (e) {
  156. this.setData({
  157. appointmentType : e.currentTarget.dataset.type
  158. })
  159. this.getListFun()
  160. },
  161. onCancel: function () {
  162. this.setData({})
  163. },
  164. toSearch: function (event) {
  165. this.getListFun();
  166. },
  167. //列表
  168. getListFun: function () {
  169. this.setData({
  170. page: 1
  171. })
  172. let params = {
  173. current : this.data.page,
  174. size : this.data.limit,
  175. licenseNumber : this.data.searchVal,
  176. type : this.data.appointmentType
  177. //status:1
  178. }
  179. app.request.pageFirst({
  180. url: app.API.appointmentPage,
  181. page: this,
  182. params: params,
  183. })
  184. },
  185. //取消预约
  186. cancelFun: function (e) {
  187. let _this = this
  188. let { id, licenseNumber } = e.currentTarget.dataset
  189. wx.showModal({
  190. title: '提示!',
  191. content: `取消【${licenseNumber}】后不可恢复。确定要取消吗?`,
  192. confirmColor: '#FF5B5B',
  193. success: function (res) {
  194. if (res.confirm) {
  195. app.request.POST({
  196. url: app.API.appointmentCancel,
  197. params: {
  198. id: id
  199. },
  200. page: _this,
  201. isLoadingTxt: '取消中...',
  202. successFun: true
  203. }).then(res => {
  204. wx.showToast({
  205. title: '取消成功',
  206. icon: 'success',
  207. duration: 1000,
  208. mask: true
  209. })
  210. _this.getListFun(); //刷新列表
  211. })
  212. } else if (res.cancel) {
  213. }
  214. }
  215. })
  216. },
  217. // 授权出场
  218. exitFun: function (e) {
  219. let _this = this
  220. let { id, licenseNumber } = e.currentTarget.dataset
  221. wx.showModal({
  222. title: '提示!',
  223. content: `确定授权【${licenseNumber}】出场,操作后无法撤回,请确认?`,
  224. confirmColor: '#FF5B5B',
  225. success: function (res) {
  226. if (res.confirm) {
  227. app.request.POST({
  228. url: app.API.otherAuthorize,
  229. params: {
  230. id: id
  231. },
  232. page: _this,
  233. isLoadingTxt: '授权中...',
  234. successFun: true
  235. }).then(res => {
  236. wx.showToast({
  237. title: '授权成功',
  238. icon: 'success',
  239. duration: 1000,
  240. mask: true
  241. })
  242. _this.getListFun(); //刷新列表
  243. })
  244. } else if (res.cancel) {
  245. }
  246. }
  247. })
  248. },
  249. // 强制结束
  250. overFun: function (e) {
  251. let _this = this
  252. let { id, licenseNumber } = e.currentTarget.dataset
  253. wx.showModal({
  254. title: '提示!',
  255. content: `确定强制结束【${licenseNumber}】预约信息,操作后无法撤回,请确认?`,
  256. confirmColor: '#FF5B5B',
  257. success: function (res) {
  258. if (res.confirm) {
  259. app.request.POST({
  260. url: app.API.appointmentExit,
  261. params: {
  262. id: id
  263. },
  264. page: _this,
  265. isLoadingTxt: '授权中...',
  266. successFun: true
  267. }).then(res => {
  268. wx.showToast({
  269. title: '授权成功',
  270. icon: 'success',
  271. duration: 1000,
  272. mask: true
  273. })
  274. _this.getListFun(); //刷新列表
  275. })
  276. } else if (res.cancel) {
  277. }
  278. }
  279. })
  280. },
  281. // 审核S
  282. showPopup(e) {
  283. let { id,type } = e.currentTarget.dataset
  284. this.setData({
  285. show: true,
  286. appointmentReason: '',
  287. type:type,
  288. id: id
  289. });
  290. },
  291. onClose() {
  292. this.setData({
  293. show: false,
  294. auditFlag:'false',
  295. appointmentReason:'',
  296. id: ''
  297. });
  298. },
  299. // 单选
  300. dangerStatusChange: function (e) {
  301. this.setData({
  302. [e.currentTarget.dataset.radiotype]: e.detail.value
  303. })
  304. },
  305. //审核
  306. formSubmit: function (e) {
  307. let formData = e.detail.value;
  308. var warn = ""; //弹框时提示的内容
  309. if (formData.auditFlag=='true' && formData.appointmentReason == '') {
  310. warn = "审核不通过时备注不能为空!";
  311. }
  312. formData.auditFlag = formData.auditFlag=='true'
  313. if (warn != '') {
  314. app.util.checkForm(warn);
  315. } else {
  316. let url = app.API.appointmentAudit
  317. if(this.data.type == '2'){
  318. url = app.API.tempAudit
  319. }
  320. app.request.POST({
  321. url: url,
  322. params: formData,
  323. page: this,
  324. isLoadingTxt: '审核中...',
  325. successFun: true
  326. }).then(res => {
  327. wx.showToast({
  328. title: '审核成功',
  329. icon: 'success',
  330. duration: 1000,
  331. mask: true
  332. })
  333. this.onClose()
  334. this.getListFun(); //刷新列表
  335. })
  336. }
  337. },
  338. // 审核E
  339. /**
  340. * 生命周期函数--监听页面隐藏
  341. */
  342. onHide() {
  343. },
  344. /**
  345. * 生命周期函数--监听页面卸载
  346. */
  347. onUnload() {
  348. },
  349. /**
  350. * 页面相关事件处理函数--监听用户下拉动作
  351. */
  352. onPullDownRefresh: function () {
  353. this.setData({
  354. searchVal: ''
  355. })
  356. if (wx.getStorageSync('loginStatus')) {
  357. this.getListFun();
  358. } else {
  359. wx.stopPullDownRefresh();
  360. }
  361. },
  362. /**
  363. * 页面上拉触底事件的处理函数
  364. */
  365. onReachBottom: function () {
  366. this.data.page++;
  367. let params = {
  368. current: this.data.page,
  369. size: this.data.limit,
  370. licenseNumber:this.data.searchVal,
  371. //status:1
  372. }
  373. app.request.pageOther({
  374. url: app.API.appointmentPage,
  375. page: this,
  376. params: params,
  377. loadType: true //加载类型,是否是下拉加载
  378. });
  379. },
  380. /**
  381. * 用户点击右上角分享
  382. */
  383. onShareAppMessage() {
  384. }
  385. })