index.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. // pages/reservationLoadAppoint/index.js
  2. const app = getApp()
  3. var startPoint
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. str:' ',
  10. str2: ' ',
  11. filterWidth: 0, //获取顶部筛选宽度
  12. filterHeight: 0, //获取顶部筛选高度
  13. safeAreaHeight: 0, //底部安全区域的高度
  14. //按钮位置参数
  15. buttonTop: 0,
  16. buttonLeft: 0,
  17. windowHeight: '',
  18. windowWidth: '',
  19. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  20. roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '',
  21. searchVal: '',
  22. appointmentStatusArray: [{
  23. dictValue: "",
  24. dictLabel: "全部状态"
  25. }],
  26. appointmentStatusIndex: 0,
  27. //分页
  28. limit: 10,
  29. requestStatu: '加载中...',
  30. page: 1,
  31. totalPages: 1,
  32. more: false,
  33. nomore: '',
  34. type: '5',// 管桩预约类型
  35. resData:[],
  36. show: false,
  37. auditFlag:true,
  38. orderReason:'',//审核备注
  39. requestStatu2: '加载中...',
  40. page2: 1,
  41. totalPages2: 1,
  42. more2: false,
  43. nomore2: '',
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad(options) {
  49. //预约审核状态
  50. let treeData = app.globalData.treeArr
  51. for (const element of treeData) {
  52. let arrStr;
  53. switch (element.dictValue) {
  54. case 'appointment_status':
  55. arrStr = "appointmentStatusArray";
  56. break;
  57. }
  58. let getArray =[{
  59. dictValue: "",
  60. dictLabel: "全部状态"
  61. }]
  62. this.setData({
  63. [arrStr]: getArray.concat(element.children)
  64. })
  65. }
  66. this.setData({
  67. safeAreaHeight: app.globalData.windowInfo.screenHeight - app.globalData.systemInfo.safeArea.bottom
  68. })
  69. // 使用选择器选择节点
  70. this.getFilterHeight()
  71. //获取页面高度设置新增按钮的初始位置
  72. var that = this;
  73. wx.getSystemInfo({
  74. success: function (res) {
  75. // 高度,宽度 单位为px
  76. that.setData({
  77. windowHeight: res.windowHeight, //屏幕宽度、高度
  78. windowWidth: res.windowWidth,
  79. buttonTop: res.windowHeight * 0.8 - that.data.safeAreaHeight-50, //这里定义按钮的初始位置
  80. buttonLeft: res.windowWidth * 0.80, //这里定义按钮的初始位置
  81. })
  82. }
  83. })
  84. },
  85. //获取顶部筛选区域的高度
  86. getFilterHeight:function(){
  87. let that = this;
  88. // 使用顶部筛选高度选择器选择节点的高度
  89. const query = wx.createSelectorQuery();
  90. query.select('.topSeach').boundingClientRect(function (rect) {
  91. if(rect){
  92. that.setData({
  93. filterWidth: rect.width,
  94. filterHeight: rect.height,
  95. });
  96. }
  97. }).exec();
  98. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow() {
  108. const roleCodeList = wx.getStorageSync('roleCodeList')
  109. let loginStatus = wx.getStorageSync('loginStatus')
  110. this.setData({
  111. searchVal: '',
  112. roleCodeList: roleCodeList ? roleCodeList : '',
  113. loginStatus: loginStatus ? loginStatus : false
  114. })
  115. this.setData({
  116. requestStatu:'加载中...',
  117. })
  118. if (wx.getStorageSync('loginStatus')) {
  119. this.getListFun();
  120. }
  121. },
  122. //下拉选择
  123. bindPickerChange: function (e) { //下拉菜单
  124. //方法一动态的
  125. let getIndex = e.target.dataset.pickername + 'Index'
  126. app.util.getPickerIndex(this, getIndex, e);
  127. this.getListFun()
  128. },
  129. //搜索框请求S
  130. onChange(e) {
  131. this.setData({
  132. searchVal: e.detail,
  133. });
  134. },
  135. onSearch: function (event) {
  136. this.setData({
  137. searchVal: event.detail
  138. })
  139. this.getListFun();
  140. },
  141. onCancel: function () {
  142. this.setData({})
  143. },
  144. toSearch: function (event) {
  145. this.getListFun();
  146. },
  147. //列表
  148. getListFun: function () {
  149. this.setData({
  150. page: 1
  151. })
  152. let params = {
  153. current : this.data.page,
  154. size : this.data.limit,
  155. type : this.data.type,
  156. searchKey : this.data.searchVal,
  157. status : this.data.appointmentStatusArray[this.data.appointmentStatusIndex].dictValue
  158. }
  159. app.request.pageFirst({
  160. url: app.API.appointmentPipePage,
  161. page: this,
  162. params: params,
  163. })
  164. },
  165. //页面跳转
  166. toLink: function (e) {
  167. let { url } = e.currentTarget.dataset
  168. wx.navigateTo({
  169. url: url
  170. })
  171. },
  172. //删除
  173. delFun: function (e) {
  174. let _this = this
  175. let { id, planNumber } = e.currentTarget.dataset
  176. wx.showModal({
  177. title: '提示!',
  178. content: `删除管桩预约号【${planNumber}】后不可恢复。确定要删除吗?`,
  179. confirmColor: '#FF5B5B',
  180. success: function (res) {
  181. if (res.confirm) {
  182. app.request.POST({
  183. url: app.API.appointmentDelete,
  184. params: [{
  185. id: id
  186. }],
  187. page: _this,
  188. isLoadingTxt: '删除中...',
  189. successFun: true
  190. }).then(res => {
  191. wx.showToast({
  192. title: '删除成功',
  193. icon: 'success',
  194. duration: 1000,
  195. mask: true
  196. })
  197. _this.getListFun(); //刷新列表
  198. })
  199. } else if (res.cancel) {
  200. }
  201. }
  202. })
  203. },
  204. //取消
  205. cancelFun: function (e) {
  206. let _this = this
  207. let { id, planNumber } = e.currentTarget.dataset
  208. wx.showModal({
  209. title: '提示!',
  210. content: `管桩预约号【${planNumber}】,确定取消该预约吗?`,
  211. confirmColor: '#FF5B5B',
  212. success: function (res) {
  213. if (res.confirm) {
  214. app.request.POST({
  215. url: app.API.appointmentCancel,
  216. params: {
  217. id: id
  218. },
  219. page: _this,
  220. isLoadingTxt: '提交中...',
  221. successFun: true
  222. }).then(res => {
  223. wx.showToast({
  224. title: '取消成功',
  225. icon: 'success',
  226. duration: 1000,
  227. mask: true
  228. })
  229. _this.getListFun(); //刷新列表
  230. })
  231. } else if (res.cancel) {
  232. }
  233. }
  234. })
  235. },
  236. // 审核S
  237. showPopup(e) {
  238. let { id } = e.currentTarget.dataset
  239. this.setData({
  240. show: true,
  241. orderReason: '',
  242. id: id,
  243. });
  244. },
  245. onClose() {
  246. this.setData({
  247. show: false,
  248. auditFlag:'false',
  249. orderReason:'',
  250. id: ''
  251. });
  252. },
  253. // 单选
  254. dangerStatusChange: function (e) {
  255. this.setData({
  256. [e.currentTarget.dataset.radiotype]: e.detail.value
  257. })
  258. if (e.detail.value == '1') {
  259. this.setData({
  260. appointmentReason: ''
  261. })
  262. }
  263. },
  264. //审核
  265. formSubmit: function (e) {
  266. let formData = e.detail.value;
  267. var warn = ""; //弹框时提示的内容
  268. if (formData.auditFlag=='true' && formData.arriveReason == '') {
  269. warn = "审核不通过时备注不能为空!";
  270. }
  271. formData.auditFlag = formData.auditFlag=='true'
  272. if (warn != '') {
  273. app.util.checkForm(warn);
  274. } else {
  275. app.request.POST({
  276. url: app.API.bizloadarriveAudit,
  277. params: formData,
  278. page: this,
  279. isLoadingTxt: '审核中...',
  280. successFun: true
  281. }).then(res => {
  282. wx.showToast({
  283. title: '审核成功',
  284. icon: 'success',
  285. duration: 1000,
  286. mask: true
  287. })
  288. this.onClose()
  289. this.getListFun(); //刷新列表
  290. })
  291. }
  292. },
  293. // 审核E
  294. //申请
  295. changeAdd() {
  296. wx.navigateTo({
  297. url: 'add'
  298. })
  299. },
  300. /**
  301. * 生命周期函数--监听页面隐藏
  302. */
  303. onHide() {
  304. },
  305. /**
  306. * 生命周期函数--监听页面卸载
  307. */
  308. onUnload() {
  309. },
  310. /**
  311. * 页面相关事件处理函数--监听用户下拉动作
  312. */
  313. onPullDownRefresh: function () {
  314. this.setData({
  315. searchVal: ''
  316. })
  317. if (wx.getStorageSync('loginStatus')) {
  318. this.getListFun();
  319. } else {
  320. wx.stopPullDownRefresh();
  321. }
  322. },
  323. /**
  324. * 页面上拉触底事件的处理函数
  325. */
  326. onReachBottom: function () {
  327. this.data.page++;
  328. let params = {
  329. current : this.data.page,
  330. size : this.data.limit,
  331. type : this.data.type,
  332. searchKey : this.data.searchVal,
  333. status : this.data.appointmentStatusArray[this.data.appointmentStatusIndex].dictValue
  334. }
  335. app.request.pageOther({
  336. url: app.API.bizloadarrivePage,
  337. page: this,
  338. params: params,
  339. loadType: true //加载类型,是否是下拉加载
  340. });
  341. },
  342. //以下是按钮拖动事件
  343. buttonStart: function (e) {
  344. startPoint = e.touches[0] //获取拖动开始点
  345. },
  346. buttonMove: function (e) {
  347. var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
  348. //计算在X轴上拖动的距离和在Y轴上拖动的距离
  349. var translateX = endPoint.clientX - startPoint.clientX
  350. var translateY = endPoint.clientY - startPoint.clientY
  351. startPoint = endPoint //重置开始位置
  352. var buttonTop = this.data.buttonTop + translateY
  353. var buttonLeft = this.data.buttonLeft + translateX
  354. //判断是移动否超出屏幕
  355. if (buttonLeft + 60 >= this.data.windowWidth) {
  356. buttonLeft = this.data.windowWidth - 60;
  357. }
  358. if (buttonLeft <= 0) {
  359. buttonLeft = 0;
  360. }
  361. if (buttonTop <= this.data.filterHeight) {
  362. buttonTop = this.data.filterHeight
  363. }
  364. if (buttonTop + 60 + 48 + this.data.safeAreaHeight >= this.data.windowHeight) {
  365. buttonTop = this.data.windowHeight - 60 - 48 - this.data.safeAreaHeight;
  366. }
  367. this.setData({
  368. buttonTop: buttonTop,
  369. buttonLeft: buttonLeft
  370. })
  371. },
  372. buttonEnd: function (e) {},
  373. /**
  374. * 用户点击右上角分享
  375. */
  376. onShareAppMessage() {
  377. }
  378. })