index.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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. this.getRecordListFun();
  152. }
  153. },
  154. //下拉选择
  155. bindPickerChange: function (e) { //下拉菜单
  156. //方法一动态的
  157. let getIndex = e.target.dataset.pickername + 'Index'
  158. app.util.getPickerIndex(this, getIndex, e);
  159. this.getListFun()
  160. },
  161. //搜索框请求S
  162. onChange(e) {
  163. this.setData({
  164. searchVal: e.detail,
  165. });
  166. },
  167. onSearch: function (event) {
  168. this.setData({
  169. searchVal: event.detail
  170. })
  171. this.getListFun();
  172. },
  173. onCancel: function () {
  174. this.setData({})
  175. },
  176. toSearch: function (event) {
  177. this.getListFun();
  178. },
  179. //列表
  180. getListFun: function () {
  181. this.setData({
  182. page: 1
  183. })
  184. let params = {
  185. current: this.data.page,
  186. size: this.data.limit,
  187. searchKey:this.data.searchVal,
  188. orderStatus:this.data.orderStatusArray[this.data.orderStatusIndex].dictValue
  189. }
  190. app.request.pageFirst({
  191. url: app.API.orderList,
  192. page: this,
  193. params: params,
  194. })
  195. },
  196. //调度列表显示
  197. orderLoadShow:function(event){
  198. let { orderId } = event.currentTarget.dataset
  199. let { orderNumber } = event.currentTarget.dataset
  200. let { deliveryTimeId } = event.currentTarget.dataset
  201. let { confStartTime } = event.currentTarget.dataset
  202. let { confEndTime } = event.currentTarget.dataset
  203. this.setData({
  204. orderLoadShow:true,
  205. orderId:orderId,
  206. orderNumber:orderNumber,
  207. deliveryTimeId:deliveryTimeId,
  208. confStartTime:confStartTime,
  209. confEndTime:confEndTime
  210. })
  211. this.getRecordListFun()
  212. },
  213. //调度列表隐藏
  214. orderLoadClose:function(){
  215. this.setData({
  216. orderLoadShow:false
  217. })
  218. },
  219. //装载车调度列表
  220. getRecordListFun: function () {
  221. this.setData({
  222. page2: 1
  223. })
  224. let params = {
  225. current: this.data.page2,
  226. size: this.data.limit,
  227. orderId:this.data.orderId
  228. }
  229. app.request.pageFirst({
  230. url: app.API.bizorderloadList,
  231. page: this,
  232. params: params,
  233. Array:'saleArr',
  234. pageNo:'page2',
  235. totalPages:'totalPages2',
  236. more: 'more2',
  237. nomore:'nomore2',
  238. requestStatu:'requestStatu2',
  239. })
  240. },
  241. //装载车调度滑动加载列表
  242. bindscrolltolowerFun() {
  243. this.data.page2++;
  244. let params = {
  245. current: this.data.page2,
  246. size: this.data.limit,
  247. orderId:this.data.orderId
  248. }
  249. app.request.pageOther({
  250. url: app.API.api.bizorderloadList,
  251. page: this,
  252. Array:'saleArr',
  253. params: params,
  254. loadType:true, //加载类型,是否是下拉加载
  255. pageNo:'page2',
  256. totalPages:'totalPages2',
  257. more: 'more2',
  258. nomore:'nomore2',
  259. requestStatu:'requestStatu2',
  260. });
  261. },
  262. //删除调度记录
  263. delOrderFun: function (e) {
  264. let _this = this
  265. let { id, loadPoint } = e.currentTarget.dataset
  266. wx.showModal({
  267. title: '提示!',
  268. content: `删除【${loadPoint}】调度后不可恢复。确定要删除吗?`,
  269. confirmColor: '#FF5B5B',
  270. success: function (res) {
  271. if (res.confirm) {
  272. app.request.POST({
  273. url: app.API.orderloadDelete,
  274. params: [{
  275. id: id
  276. }],
  277. page: _this,
  278. isLoadingTxt: '删除中...',
  279. successFun: true
  280. }).then(res => {
  281. wx.showToast({
  282. title: '删除成功',
  283. icon: 'success',
  284. duration: 1000,
  285. mask: true
  286. })
  287. //_this.orderLoadClose()
  288. _this.getRecordListFun()
  289. _this.getListFun(); //刷新列表
  290. })
  291. } else if (res.cancel) {
  292. }
  293. }
  294. })
  295. },
  296. //页面跳转
  297. toLink: function (e) {
  298. let { url } = e.currentTarget.dataset
  299. wx.navigateTo({
  300. url: url
  301. })
  302. },
  303. //删除
  304. delFun: function (e) {
  305. let _this = this
  306. let { id, orderNumber } = e.currentTarget.dataset
  307. wx.showModal({
  308. title: '提示!',
  309. content: `删除【${orderNumber}】后不可恢复。确定要删除吗?`,
  310. confirmColor: '#FF5B5B',
  311. success: function (res) {
  312. if (res.confirm) {
  313. app.request.POST({
  314. url: app.API.orderDelete,
  315. params: [{
  316. id: id
  317. }],
  318. page: _this,
  319. isLoadingTxt: '删除中...',
  320. successFun: true
  321. }).then(res => {
  322. wx.showToast({
  323. title: '删除成功',
  324. icon: 'success',
  325. duration: 1000,
  326. mask: true
  327. })
  328. _this.getListFun(); //刷新列表
  329. })
  330. } else if (res.cancel) {
  331. }
  332. }
  333. })
  334. },
  335. //业务员进行确认
  336. comform: function (e) {
  337. let _this = this
  338. let { id, orderNumber } = e.currentTarget.dataset
  339. wx.showModal({
  340. title: '提示!',
  341. content: `确认【${orderNumber}】后不可取消。确定现在确认订单吗?`,
  342. confirmColor: '#FF5B5B',
  343. success: function (res) {
  344. if (res.confirm) {
  345. app.request.POST({
  346. url: app.API.orderConfirm,
  347. params: {
  348. id: id
  349. },
  350. page: _this,
  351. isLoadingTxt: '确认中...',
  352. successFun: true
  353. }).then(res => {
  354. wx.showToast({
  355. title: '确认成功',
  356. icon: 'success',
  357. duration: 1000,
  358. mask: true
  359. })
  360. _this.getListFun(); //刷新列表
  361. })
  362. } else if (res.cancel) {
  363. }
  364. }
  365. })
  366. },
  367. // 审核S
  368. showPopup(e) {
  369. let { id } = e.currentTarget.dataset
  370. this.setData({
  371. show: true,
  372. orderReason: '',
  373. id: id,
  374. });
  375. /*wx.navigateTo({
  376. url: '/pages/appointment/review?id='+e.currentTarget.dataset.id
  377. })*/
  378. },
  379. onClose() {
  380. this.setData({
  381. show: false,
  382. auditFlag:'false',
  383. orderReason:'',
  384. id: ''
  385. });
  386. },
  387. // 单选
  388. dangerStatusChange: function (e) {
  389. this.setData({
  390. [e.currentTarget.dataset.radiotype]: e.detail.value
  391. })
  392. if (e.detail.value == '1') {
  393. this.setData({
  394. appointmentReason: ''
  395. })
  396. }
  397. },
  398. //审核
  399. formSubmit: function (e) {
  400. let formData = e.detail.value;
  401. var warn = ""; //弹框时提示的内容
  402. if (formData.auditFlag=='true' && formData.orderReason == '') {
  403. warn = "审核不通过时备注不能为空!";
  404. }
  405. formData.auditFlag = formData.auditFlag=='true'
  406. if (warn != '') {
  407. app.util.checkForm(warn);
  408. } else {
  409. app.request.POST({
  410. url: app.API.orderAudit,
  411. params: formData,
  412. page: this,
  413. isLoadingTxt: '审核中...',
  414. successFun: true
  415. }).then(res => {
  416. wx.showToast({
  417. title: '审核成功',
  418. icon: 'success',
  419. duration: 1000,
  420. mask: true
  421. })
  422. this.onClose()
  423. this.getListFun(); //刷新列表
  424. })
  425. }
  426. },
  427. // 审核E
  428. //结束
  429. endFun: function (e) {
  430. let _this = this
  431. let { id, orderNumber } = e.currentTarget.dataset
  432. wx.showModal({
  433. title: '提示!',
  434. content: `结束【${orderNumber}】订单后不可取消。确定现在结束订单吗?`,
  435. confirmColor: '#FF5B5B',
  436. success: function (res) {
  437. if (res.confirm) {
  438. app.request.POST({
  439. url: app.API.orderEnd,
  440. params: {
  441. id: id
  442. },
  443. page: _this,
  444. isLoadingTxt: '操作中...',
  445. successFun: true
  446. }).then(res => {
  447. wx.showToast({
  448. title: '结束成功',
  449. icon: 'success',
  450. duration: 1000,
  451. mask: true
  452. })
  453. _this.getListFun(); //刷新列表
  454. })
  455. } else if (res.cancel) {
  456. }
  457. }
  458. })
  459. },
  460. //提交
  461. orderSubmit: function (e) {
  462. let _this = this
  463. let { id, orderNumber } = e.currentTarget.dataset
  464. wx.showModal({
  465. title: '提示!',
  466. content: `确认提交【${orderNumber}】订单?`,
  467. confirmColor: '#FF5B5B',
  468. success: function (res) {
  469. if (res.confirm) {
  470. app.request.POST({
  471. url: app.API.orderSubmit,
  472. params: {
  473. id: id
  474. },
  475. page: _this,
  476. isLoadingTxt: '操作中...',
  477. successFun: true
  478. }).then(res => {
  479. wx.showToast({
  480. title: '提交成功',
  481. icon: 'success',
  482. duration: 1000,
  483. mask: true
  484. })
  485. _this.getListFun(); //刷新列表
  486. })
  487. } else if (res.cancel) {
  488. }
  489. }
  490. })
  491. },
  492. //扫码预约申请
  493. changeAdd() {
  494. wx.navigateTo({
  495. url: 'add'
  496. })
  497. },
  498. //客户驳回
  499. rejectFun: function (e) {
  500. let _this = this
  501. let { id, orderNumber } = e.currentTarget.dataset
  502. wx.showModal({
  503. title: '提示!',
  504. content: `物流订单号【${orderNumber}】,确定驳回该订单吗?`,
  505. confirmColor: '#FF5B5B',
  506. success: function (res) {
  507. if (res.confirm) {
  508. app.request.POST({
  509. url: app.API.rejectOrder,
  510. params: {
  511. id: id
  512. },
  513. page: _this,
  514. isLoadingTxt: '确认中...',
  515. successFun: true
  516. }).then(res => {
  517. wx.showToast({
  518. title: '确认成功',
  519. icon: 'success',
  520. duration: 1000,
  521. mask: true
  522. })
  523. _this.getListFun(); //刷新列表
  524. })
  525. } else if (res.cancel) {
  526. }
  527. }
  528. })
  529. },
  530. //管理员发货确认
  531. sendConfirmFun: function (e) {
  532. let _this = this
  533. let { id, orderNumber } = e.currentTarget.dataset
  534. wx.showModal({
  535. title: '提示!',
  536. content: `物流订单号【${orderNumber}】,确定现在进行发货确认吗?`,
  537. confirmColor: '#FF5B5B',
  538. success: function (res) {
  539. if (res.confirm) {
  540. app.request.POST({
  541. url: app.API.sendConfirmOrder,
  542. params: {
  543. id: id
  544. },
  545. page: _this,
  546. isLoadingTxt: '确认中...',
  547. successFun: true
  548. }).then(res => {
  549. wx.showToast({
  550. title: '确认成功',
  551. icon: 'success',
  552. duration: 1000,
  553. mask: true
  554. })
  555. _this.getListFun(); //刷新列表
  556. })
  557. } else if (res.cancel) {
  558. }
  559. }
  560. })
  561. },
  562. /**
  563. * 生命周期函数--监听页面隐藏
  564. */
  565. onHide() {
  566. },
  567. /**
  568. * 生命周期函数--监听页面卸载
  569. */
  570. onUnload() {
  571. },
  572. /**
  573. * 页面相关事件处理函数--监听用户下拉动作
  574. */
  575. onPullDownRefresh: function () {
  576. this.setData({
  577. searchVal: ''
  578. })
  579. if (wx.getStorageSync('loginStatus')) {
  580. this.getListFun();
  581. } else {
  582. wx.stopPullDownRefresh();
  583. }
  584. },
  585. /**
  586. * 页面上拉触底事件的处理函数
  587. */
  588. onReachBottom: function () {
  589. this.data.page++;
  590. let params = {
  591. current: this.data.page,
  592. size: this.data.limit,
  593. searchKey:this.data.searchVal,
  594. orderStatus:this.data.orderStatusArray[this.data.orderStatusIndex].dictValue
  595. }
  596. app.request.pageOther({
  597. url: app.API.orderList,
  598. page: this,
  599. params: params,
  600. loadType: true //加载类型,是否是下拉加载
  601. });
  602. },
  603. //以下是按钮拖动事件
  604. buttonStart: function (e) {
  605. startPoint = e.touches[0] //获取拖动开始点
  606. },
  607. buttonMove: function (e) {
  608. var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
  609. //计算在X轴上拖动的距离和在Y轴上拖动的距离
  610. var translateX = endPoint.clientX - startPoint.clientX
  611. var translateY = endPoint.clientY - startPoint.clientY
  612. startPoint = endPoint //重置开始位置
  613. var buttonTop = this.data.buttonTop + translateY
  614. var buttonLeft = this.data.buttonLeft + translateX
  615. //判断是移动否超出屏幕
  616. if (buttonLeft + 60 >= this.data.windowWidth) {
  617. buttonLeft = this.data.windowWidth - 60;
  618. }
  619. if (buttonLeft <= 0) {
  620. buttonLeft = 0;
  621. }
  622. if (buttonTop <= this.data.filterHeight) {
  623. buttonTop = this.data.filterHeight
  624. }
  625. if (buttonTop + 60 + 48 + this.data.safeAreaHeight >= this.data.windowHeight) {
  626. buttonTop = this.data.windowHeight - 60 - 48 - this.data.safeAreaHeight;
  627. }
  628. this.setData({
  629. buttonTop: buttonTop,
  630. buttonLeft: buttonLeft
  631. })
  632. },
  633. buttonEnd: function (e) {},
  634. /**
  635. * 用户点击右上角分享
  636. */
  637. onShareAppMessage() {
  638. }
  639. })