index.js 14 KB

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