index.js 8.2 KB

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