index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. // pages/salesOrderMan/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. orderStatusArray: [{
  23. dictValue: "",
  24. dictLabel: "全部状态"
  25. }],
  26. orderStatusIndex: 0,
  27. //分页
  28. limit: 10,
  29. requestStatu: '加载中...',
  30. page: 1,
  31. totalPages: 1,
  32. more: false,
  33. nomore: '',
  34. resData:[],
  35. show: false,
  36. auditFlag:true,
  37. orderReason:'',//审核备注
  38. orderLoadShow:false, //调度列表弹窗
  39. orderId:'',
  40. requestStatu2: '加载中...',
  41. page2: 1,
  42. totalPages2: 1,
  43. more2: false,
  44. nomore2: '',
  45. saleArr:[],
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad(options) {
  51. //订单状态
  52. let treeData = app.globalData.treeArr
  53. for (const element of treeData) {
  54. let arrStr;
  55. switch (element.dictValue) {
  56. case 'order_status':
  57. arrStr = "orderStatusArray";
  58. break;
  59. }
  60. let getArray =[{
  61. dictValue: "",
  62. dictLabel: "全部状态"
  63. }]
  64. this.setData({
  65. [arrStr]: getArray.concat(element.children)
  66. })
  67. }
  68. this.setData({
  69. safeAreaHeight: app.globalData.windowInfo.screenHeight - app.globalData.systemInfo.safeArea.bottom
  70. })
  71. // 使用选择器选择节点
  72. this.getFilterHeight()
  73. //获取页面高度设置新增按钮的初始位置
  74. var that = this;
  75. wx.getSystemInfo({
  76. success: function (res) {
  77. // 高度,宽度 单位为px
  78. that.setData({
  79. windowHeight: res.windowHeight, //屏幕宽度、高度
  80. windowWidth: res.windowWidth,
  81. buttonTop: res.windowHeight * 0.8 - that.data.safeAreaHeight-50, //这里定义按钮的初始位置
  82. buttonLeft: res.windowWidth * 0.80, //这里定义按钮的初始位置
  83. })
  84. }
  85. })
  86. },
  87. //获取顶部筛选区域的高度
  88. getFilterHeight:function(){
  89. let that = this;
  90. // 使用顶部筛选高度选择器选择节点的高度
  91. const query = wx.createSelectorQuery();
  92. query.select('.topSeach').boundingClientRect(function (rect) {
  93. if(rect){
  94. that.setData({
  95. filterWidth: rect.width,
  96. filterHeight: rect.height,
  97. });
  98. }
  99. }).exec();
  100. },
  101. /**
  102. * 生命周期函数--监听页面初次渲染完成
  103. */
  104. onReady() {
  105. },
  106. /**
  107. * 生命周期函数--监听页面显示
  108. */
  109. onShow() {
  110. const roleCodeList = wx.getStorageSync('roleCodeList')
  111. let loginStatus = wx.getStorageSync('loginStatus')
  112. this.setData({
  113. searchVal: '',
  114. roleCodeList: roleCodeList ? roleCodeList : '',
  115. loginStatus: loginStatus ? loginStatus : false
  116. })
  117. //动态tabbar
  118. // let selected = 1
  119. // if (roleCodeList == 'bizAdmin') {
  120. // this.getTabBar().setData({
  121. // list: app.globalData.allList[0].list2,
  122. // })
  123. // } else if(roleCodeList == 'send') {
  124. // this.getTabBar().setData({
  125. // list: app.globalData.allList[0].list3,
  126. // })
  127. // } else if(roleCodeList == 'sale') {
  128. // this.getTabBar().setData({
  129. // list: app.globalData.allList[0].list4,
  130. // })
  131. // selected = 0
  132. // } else if(roleCodeList == 'customer') {
  133. // this.getTabBar().setData({
  134. // list: app.globalData.allList[0].list5,
  135. // })
  136. // } else if (roleCodeList=='driver'||roleCodeList==''){
  137. // this.getTabBar().setData({
  138. // list: app.globalData.allList[0].list1,
  139. // })
  140. // }
  141. // if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  142. // this.getTabBar().setData({
  143. // selected: selected
  144. // })
  145. // }
  146. this.setData({
  147. requestStatu:'加载中...',
  148. })
  149. if (wx.getStorageSync('loginStatus')) {
  150. this.getListFun();
  151. }
  152. },
  153. //下拉选择
  154. bindPickerChange: function (e) { //下拉菜单
  155. //方法一动态的
  156. let getIndex = e.target.dataset.pickername + 'Index'
  157. app.util.getPickerIndex(this, getIndex, e);
  158. this.getListFun()
  159. },
  160. //搜索框请求S
  161. onChange(e) {
  162. this.setData({
  163. searchVal: e.detail,
  164. });
  165. },
  166. onSearch: function (event) {
  167. this.setData({
  168. searchVal: event.detail
  169. })
  170. this.getListFun();
  171. },
  172. onCancel: function () {
  173. this.setData({})
  174. },
  175. toSearch: function (event) {
  176. this.getListFun();
  177. },
  178. //列表
  179. getListFun: function () {
  180. this.setData({
  181. page: 1
  182. })
  183. let params = {
  184. current: this.data.page,
  185. size: this.data.limit,
  186. searchKey:this.data.searchVal,
  187. orderStatus:this.data.orderStatusArray[this.data.orderStatusIndex].dictValue
  188. }
  189. app.request.pageFirst({
  190. url: app.API.orderList,
  191. page: this,
  192. params: params,
  193. })
  194. },
  195. //调度列表显示
  196. orderLoadShow:function(event){
  197. let { orderId } = event.currentTarget.dataset
  198. this.setData({
  199. orderLoadShow:true,
  200. orderId:orderId
  201. })
  202. this.getRecordListFun()
  203. },
  204. //调度列表隐藏
  205. orderLoadClose:function(){
  206. this.setData({
  207. orderLoadShow:false
  208. })
  209. },
  210. //装载车调度列表
  211. getRecordListFun: function () {
  212. this.setData({
  213. page2: 1
  214. })
  215. let params = {
  216. current: this.data.page2,
  217. size: this.data.limit,
  218. orderId:this.data.orderId
  219. }
  220. app.request.pageFirst({
  221. url: app.API.bizorderloadList,
  222. page: this,
  223. params: params,
  224. Array:'saleArr',
  225. pageNo:'page2',
  226. totalPages:'totalPages2',
  227. more: 'more2',
  228. nomore:'nomore2',
  229. requestStatu:'requestStatu2',
  230. })
  231. },
  232. //装载车调度滑动加载列表
  233. bindscrolltolowerFun() {
  234. this.data.page2++;
  235. let params = {
  236. current: this.data.page2,
  237. size: this.data.limit,
  238. orderId:this.data.orderId
  239. }
  240. app.request.pageOther({
  241. url: app.API.api.bizorderloadList,
  242. page: this,
  243. Array:'saleArr',
  244. params: params,
  245. loadType:true, //加载类型,是否是下拉加载
  246. pageNo:'page2',
  247. totalPages:'totalPages2',
  248. more: 'more2',
  249. nomore:'nomore2',
  250. requestStatu:'requestStatu2',
  251. });
  252. },
  253. //删除调度记录
  254. delOrderFun: function (e) {
  255. let _this = this
  256. let { id, loadPoint } = e.currentTarget.dataset
  257. wx.showModal({
  258. title: '提示!',
  259. content: `删除【${loadPoint}】调度后不可恢复。确定要删除吗?`,
  260. confirmColor: '#FF5B5B',
  261. success: function (res) {
  262. if (res.confirm) {
  263. app.request.POST({
  264. url: app.API.orderloadDelete,
  265. params: [{
  266. id: id
  267. }],
  268. page: _this,
  269. isLoadingTxt: '删除中...',
  270. successFun: true
  271. }).then(res => {
  272. wx.showToast({
  273. title: '删除成功',
  274. icon: 'success',
  275. duration: 1000,
  276. mask: true
  277. })
  278. //_this.orderLoadClose()
  279. _this.getRecordListFun()
  280. _this.getListFun(); //刷新列表
  281. })
  282. } else if (res.cancel) {
  283. }
  284. }
  285. })
  286. },
  287. //页面跳转
  288. toLink: function (e) {
  289. let { url } = e.currentTarget.dataset
  290. wx.navigateTo({
  291. url: url
  292. })
  293. },
  294. //删除
  295. delFun: function (e) {
  296. let _this = this
  297. let { id, orderNumber } = e.currentTarget.dataset
  298. wx.showModal({
  299. title: '提示!',
  300. content: `删除【${orderNumber}】后不可恢复。确定要删除吗?`,
  301. confirmColor: '#FF5B5B',
  302. success: function (res) {
  303. if (res.confirm) {
  304. app.request.POST({
  305. url: app.API.orderDelete,
  306. params: [{
  307. id: id
  308. }],
  309. page: _this,
  310. isLoadingTxt: '删除中...',
  311. successFun: true
  312. }).then(res => {
  313. wx.showToast({
  314. title: '删除成功',
  315. icon: 'success',
  316. duration: 1000,
  317. mask: true
  318. })
  319. _this.getListFun(); //刷新列表
  320. })
  321. } else if (res.cancel) {
  322. }
  323. }
  324. })
  325. },
  326. //业务员进行确认
  327. comform: function (e) {
  328. let _this = this
  329. let { id, orderNumber } = e.currentTarget.dataset
  330. wx.showModal({
  331. title: '提示!',
  332. content: `确认【${orderNumber}】后不可取消。确定现在确认订单吗?`,
  333. confirmColor: '#FF5B5B',
  334. success: function (res) {
  335. if (res.confirm) {
  336. app.request.POST({
  337. url: app.API.orderConfirm,
  338. params: {
  339. id: id
  340. },
  341. page: _this,
  342. isLoadingTxt: '确认中...',
  343. successFun: true
  344. }).then(res => {
  345. wx.showToast({
  346. title: '确认成功',
  347. icon: 'success',
  348. duration: 1000,
  349. mask: true
  350. })
  351. _this.getListFun(); //刷新列表
  352. })
  353. } else if (res.cancel) {
  354. }
  355. }
  356. })
  357. },
  358. // 审核S
  359. showPopup(e) {
  360. let { id } = e.currentTarget.dataset
  361. this.setData({
  362. show: true,
  363. orderReason: '',
  364. id: id,
  365. });
  366. /*wx.navigateTo({
  367. url: '/pages/appointment/review?id='+e.currentTarget.dataset.id
  368. })*/
  369. },
  370. onClose() {
  371. this.setData({
  372. show: false,
  373. auditFlag:'false',
  374. orderReason:'',
  375. id: ''
  376. });
  377. },
  378. // 单选
  379. dangerStatusChange: function (e) {
  380. this.setData({
  381. [e.currentTarget.dataset.radiotype]: e.detail.value
  382. })
  383. if (e.detail.value == '1') {
  384. this.setData({
  385. appointmentReason: ''
  386. })
  387. }
  388. },
  389. //审核
  390. formSubmit: function (e) {
  391. let formData = e.detail.value;
  392. var warn = ""; //弹框时提示的内容
  393. if (formData.auditFlag=='true' && formData.orderReason == '') {
  394. warn = "审核不通过时备注不能为空!";
  395. }
  396. formData.auditFlag = formData.auditFlag=='true'
  397. if (warn != '') {
  398. app.util.checkForm(warn);
  399. } else {
  400. app.request.POST({
  401. url: app.API.orderAudit,
  402. params: formData,
  403. page: this,
  404. isLoadingTxt: '审核中...',
  405. successFun: true
  406. }).then(res => {
  407. wx.showToast({
  408. title: '审核成功',
  409. icon: 'success',
  410. duration: 1000,
  411. mask: true
  412. })
  413. this.onClose()
  414. this.getListFun(); //刷新列表
  415. })
  416. }
  417. },
  418. // 审核E
  419. //结束
  420. endFun: function (e) {
  421. let _this = this
  422. let { id, orderNumber } = e.currentTarget.dataset
  423. wx.showModal({
  424. title: '提示!',
  425. content: `结束【${orderNumber}】订单后不可取消。确定现在结束订单吗?`,
  426. confirmColor: '#FF5B5B',
  427. success: function (res) {
  428. if (res.confirm) {
  429. app.request.POST({
  430. url: app.API.orderEnd,
  431. params: {
  432. id: id
  433. },
  434. page: _this,
  435. isLoadingTxt: '操作中...',
  436. successFun: true
  437. }).then(res => {
  438. wx.showToast({
  439. title: '结束成功',
  440. icon: 'success',
  441. duration: 1000,
  442. mask: true
  443. })
  444. _this.getListFun(); //刷新列表
  445. })
  446. } else if (res.cancel) {
  447. }
  448. }
  449. })
  450. },
  451. //提交
  452. orderSubmit: function (e) {
  453. let _this = this
  454. let { id, orderNumber } = e.currentTarget.dataset
  455. wx.showModal({
  456. title: '提示!',
  457. content: `确认提交【${orderNumber}】订单?`,
  458. confirmColor: '#FF5B5B',
  459. success: function (res) {
  460. if (res.confirm) {
  461. app.request.POST({
  462. url: app.API.orderSubmit,
  463. params: {
  464. id: id
  465. },
  466. page: _this,
  467. isLoadingTxt: '操作中...',
  468. successFun: true
  469. }).then(res => {
  470. wx.showToast({
  471. title: '提交成功',
  472. icon: 'success',
  473. duration: 1000,
  474. mask: true
  475. })
  476. _this.getListFun(); //刷新列表
  477. })
  478. } else if (res.cancel) {
  479. }
  480. }
  481. })
  482. },
  483. //扫码预约申请
  484. changeAdd() {
  485. wx.navigateTo({
  486. url: 'add'
  487. })
  488. },
  489. /**
  490. * 生命周期函数--监听页面隐藏
  491. */
  492. onHide() {
  493. },
  494. /**
  495. * 生命周期函数--监听页面卸载
  496. */
  497. onUnload() {
  498. },
  499. /**
  500. * 页面相关事件处理函数--监听用户下拉动作
  501. */
  502. onPullDownRefresh: function () {
  503. this.setData({
  504. searchVal: ''
  505. })
  506. if (wx.getStorageSync('loginStatus')) {
  507. this.getListFun();
  508. } else {
  509. wx.stopPullDownRefresh();
  510. }
  511. },
  512. /**
  513. * 页面上拉触底事件的处理函数
  514. */
  515. onReachBottom: function () {
  516. this.data.page++;
  517. let params = {
  518. current: this.data.page,
  519. size: this.data.limit,
  520. searchKey:this.data.searchVal,
  521. orderStatus:this.data.orderStatusArray[this.data.orderStatusIndex].dictValue
  522. }
  523. app.request.pageOther({
  524. url: app.API.bizparkconfigPage,
  525. page: this,
  526. params: params,
  527. loadType: true //加载类型,是否是下拉加载
  528. });
  529. },
  530. //以下是按钮拖动事件
  531. buttonStart: function (e) {
  532. startPoint = e.touches[0] //获取拖动开始点
  533. },
  534. buttonMove: function (e) {
  535. var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
  536. //计算在X轴上拖动的距离和在Y轴上拖动的距离
  537. var translateX = endPoint.clientX - startPoint.clientX
  538. var translateY = endPoint.clientY - startPoint.clientY
  539. startPoint = endPoint //重置开始位置
  540. var buttonTop = this.data.buttonTop + translateY
  541. var buttonLeft = this.data.buttonLeft + translateX
  542. //判断是移动否超出屏幕
  543. if (buttonLeft + 60 >= this.data.windowWidth) {
  544. buttonLeft = this.data.windowWidth - 60;
  545. }
  546. if (buttonLeft <= 0) {
  547. buttonLeft = 0;
  548. }
  549. if (buttonTop <= this.data.filterHeight) {
  550. buttonTop = this.data.filterHeight
  551. }
  552. if (buttonTop + 60 + 48 + this.data.safeAreaHeight >= this.data.windowHeight) {
  553. buttonTop = this.data.windowHeight - 60 - 48 - this.data.safeAreaHeight;
  554. }
  555. this.setData({
  556. buttonTop: buttonTop,
  557. buttonLeft: buttonLeft
  558. })
  559. },
  560. buttonEnd: function (e) {},
  561. /**
  562. * 用户点击右上角分享
  563. */
  564. onShareAppMessage() {
  565. }
  566. })