index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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. * 生命周期函数--监听页面隐藏
  500. */
  501. onHide() {
  502. },
  503. /**
  504. * 生命周期函数--监听页面卸载
  505. */
  506. onUnload() {
  507. },
  508. /**
  509. * 页面相关事件处理函数--监听用户下拉动作
  510. */
  511. onPullDownRefresh: function () {
  512. this.setData({
  513. searchVal: ''
  514. })
  515. if (wx.getStorageSync('loginStatus')) {
  516. this.getListFun();
  517. } else {
  518. wx.stopPullDownRefresh();
  519. }
  520. },
  521. /**
  522. * 页面上拉触底事件的处理函数
  523. */
  524. onReachBottom: function () {
  525. this.data.page++;
  526. let params = {
  527. current: this.data.page,
  528. size: this.data.limit,
  529. searchKey:this.data.searchVal,
  530. orderStatus:this.data.orderStatusArray[this.data.orderStatusIndex].dictValue
  531. }
  532. app.request.pageOther({
  533. url: app.API.orderList,
  534. page: this,
  535. params: params,
  536. loadType: true //加载类型,是否是下拉加载
  537. });
  538. },
  539. //以下是按钮拖动事件
  540. buttonStart: function (e) {
  541. startPoint = e.touches[0] //获取拖动开始点
  542. },
  543. buttonMove: function (e) {
  544. var endPoint = e.touches[e.touches.length - 1] //获取拖动结束点
  545. //计算在X轴上拖动的距离和在Y轴上拖动的距离
  546. var translateX = endPoint.clientX - startPoint.clientX
  547. var translateY = endPoint.clientY - startPoint.clientY
  548. startPoint = endPoint //重置开始位置
  549. var buttonTop = this.data.buttonTop + translateY
  550. var buttonLeft = this.data.buttonLeft + translateX
  551. //判断是移动否超出屏幕
  552. if (buttonLeft + 60 >= this.data.windowWidth) {
  553. buttonLeft = this.data.windowWidth - 60;
  554. }
  555. if (buttonLeft <= 0) {
  556. buttonLeft = 0;
  557. }
  558. if (buttonTop <= this.data.filterHeight) {
  559. buttonTop = this.data.filterHeight
  560. }
  561. if (buttonTop + 60 + 48 + this.data.safeAreaHeight >= this.data.windowHeight) {
  562. buttonTop = this.data.windowHeight - 60 - 48 - this.data.safeAreaHeight;
  563. }
  564. this.setData({
  565. buttonTop: buttonTop,
  566. buttonLeft: buttonLeft
  567. })
  568. },
  569. buttonEnd: function (e) {},
  570. /**
  571. * 用户点击右上角分享
  572. */
  573. onShareAppMessage() {
  574. }
  575. })