serviceOrder.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. // const update = require('../../../api/update.js');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. showjz:false,
  10. isSearchResult:false,
  11. isMonthCalender:false,
  12. isHistoryMonth:false,
  13. calendarBoardShow:false,
  14. schedueBoardShow:false,
  15. serviceOrderList:[],
  16. totalPage:1,
  17. page:1,
  18. weather:{},
  19. orderType:1,
  20. today: util.chineseDate(new Date()),
  21. todayTag: util.formetdate(new Date()),
  22. currentDay: util.formetdate(new Date()),
  23. currentMonth: moment(new Date()).format('YYYY-MM'),
  24. dayTeamName:'',
  25. dayTeam:[],
  26. leaveList:[],
  27. avgDay:'',
  28. futureThirtyDays:[],
  29. futureThirtyDaysStr:'',
  30. futureThirtyDaysEnd:'',
  31. futureOrderCount:'',
  32. monthOrderCount:[],
  33. lastMonthCount:'',
  34. timer: "",
  35. dayCalendar: {
  36. bookTradeNo: '',
  37. workerNo: '',
  38. star: 0,
  39. evalMasterShow: false,
  40. masterComment: '',
  41. evalDiscipleShow: false,
  42. discipleComment: '',
  43. radioDisciple: '通过',
  44. askForLeaveDTOS: [],
  45. workerOrderInfoDTOList: [],
  46. leaveNum: '',
  47. finishWorkerOrder: '',
  48. questionNum: '',
  49. looseOrder: '',
  50. looseOrderCount: '',
  51. cycleOrder: '',
  52. cycleOrderCount: '',
  53. rebuyNum: '',
  54. looseRebuyNum: '',
  55. cycleRebuyNum: '',
  56. },
  57. calcendarFold: false,
  58. stickShow: false,
  59. isLeaveFold: true,
  60. orderDisable: true,
  61. orderDisable1: false,
  62. activeTab: 1,
  63. ticketList: [{}, {}],
  64. monthInfo: {
  65. finishWorkerOrder: 0,
  66. orderBonus: 0,
  67. questionNum: 0,
  68. looseOrder: 0,
  69. cycleOrder: 0,
  70. rebuyBonus: 0,
  71. looseRebuyNum: 0,
  72. cycleRebuyNum: 0,
  73. },
  74. workerDayInfoList: [],
  75. weekCalendar: [],
  76. wholeCalendar: [],
  77. },
  78. addpreview(){
  79. wx.navigateTo({
  80. url: '/pages/pre/diyPreviewing/diypreviewing',
  81. })
  82. },
  83. onPageScroll(e) {
  84. // console.log(e.scrollTop);
  85. // if(e.scrollTop > 200){
  86. // this.setData({
  87. // stickShow: true
  88. // });
  89. // } else {
  90. // this.setData({
  91. // stickShow: false
  92. // });
  93. // }
  94. },
  95. leaveFold() {
  96. let fold = this.data.isLeaveFold;
  97. this.setData({
  98. isLeaveFold: !fold
  99. });
  100. },
  101. copyNum(e) {
  102. let bookno = e.currentTarget.dataset.bookno;
  103. console.log(bookno);
  104. wx.setClipboardData({
  105. data: bookno,
  106. success: function (res) {
  107. wx.showToast({
  108. title: '复制成功',
  109. icon: 'none',
  110. duration: 2000
  111. });
  112. }
  113. })
  114. },
  115. callUp(e) {
  116. let status = e.currentTarget.dataset.status;
  117. let phone = e.currentTarget.dataset.phone;
  118. if (status == '待上门' || status == '待履约' || status == '已预约') {
  119. wx.makePhoneCall({
  120. phoneNumber: phone
  121. });
  122. }
  123. },
  124. getQrCode(e) { //加企微
  125. let channel = e.currentTarget.dataset.channel;
  126. let id = e.currentTarget.dataset.id;
  127. if (channel && channel == '盒马')
  128. channel = 'hm';
  129. else channel = 'p';
  130. wx.navigateTo({
  131. url: '/pages/upgrade/cp/join?channel=' + channel + '&id=' + id,
  132. })
  133. },
  134. openMap(e) { //打开地图
  135. let status = e.currentTarget.dataset.status;
  136. let address = e.currentTarget.dataset.address;
  137. if (status == '待上门' || status == '待履约' || status == '已预约') {
  138. let lnglat = e.currentTarget.dataset.lnglat.split(',');
  139. let lng = '';
  140. let lat = "";
  141. if (lnglat.length > 0) {
  142. lng = Number(lnglat[0]);
  143. lat = Number(lnglat[1]);
  144. }
  145. console.log(lng, lat);
  146. wx.openLocation({
  147. latitude: lat,
  148. longitude: lng,
  149. // name: address,
  150. address: address,
  151. scale: 28
  152. });
  153. }
  154. },
  155. goSchedule() {
  156. wx.navigateTo({
  157. url: '/pages/upgrade/scheduleCalc/scheduleCalc',
  158. })
  159. },
  160. goApplySche(){
  161. wx.navigateTo({
  162. url: '/pages/new/changeSchedue/changeSchedue',
  163. });
  164. },
  165. goDetail(e) {
  166. let id = e.currentTarget.dataset.id;
  167. let detailServantId=e.currentTarget.dataset.detailservantid;
  168. wx.navigateTo({
  169. url: '/pages/new/ticketDetail/ticketDetail?bookTradeNo=' + id+'&detailServantId='+detailServantId,
  170. });
  171. },
  172. evalMaster(e) {
  173. let id = e.currentTarget.dataset.id;
  174. let workerno = e.currentTarget.dataset.workerno;
  175. this.setData({
  176. evalMasterShow: true,
  177. star: 0,
  178. masterComment: '',
  179. bookTradeNo: id,
  180. workerNo: workerno
  181. });
  182. },
  183. onClickMsterOverlay() {
  184. this.setData({
  185. evalMasterShow: false,
  186. });
  187. },
  188. onClickDiscipleOverlay() {
  189. this.setData({
  190. evalDiscipleShow: false,
  191. });
  192. },
  193. onStarChange(event) {
  194. this.setData({
  195. star: event.detail,
  196. });
  197. },
  198. onRadioChange(event) {
  199. this.setData({
  200. radioDisciple: event.detail,
  201. });
  202. },
  203. bindMasterComment(e) {
  204. this.setData({
  205. masterComment: e.detail.value
  206. })
  207. },
  208. bindDiscipleComment(e) {
  209. this.setData({
  210. discipleComment: e.detail.value
  211. })
  212. },
  213. stop: function () {
  214. //阻止弹框冒泡和捕获的空事件,不要删除!!!
  215. },
  216. submitEvalMaster() {
  217. if (this.data.star == 0) {
  218. wx.showToast({
  219. title: '请选择评价星级',
  220. icon: 'none'
  221. })
  222. } else if (this.data.masterComment == '') {
  223. wx.showToast({
  224. title: '请输入跟单体会',
  225. icon: 'none'
  226. })
  227. } else {
  228. util.request(api.discipleFeedback, {
  229. feedback: this.data.discipleComment,
  230. level: this.data.star,
  231. bookTradeNo: this.data.bookTradeNo,
  232. workerNo: this.data.workerNo
  233. }, 'GET').then(res => {
  234. if (res.errno === 0) {
  235. wx.showToast({
  236. title: '评价成功',
  237. icon: 'none'
  238. })
  239. this.setData({
  240. evalMasterShow: false,
  241. });
  242. this.getDayCalendar();
  243. } else {
  244. wx.showToast({
  245. title: res.errmsg,
  246. icon: 'none'
  247. })
  248. }
  249. });
  250. }
  251. },
  252. evalDisciple(e) {
  253. let id = e.currentTarget.dataset.id;
  254. let workerno = e.currentTarget.dataset.workerno;
  255. this.setData({
  256. evalDiscipleShow: true,
  257. radioDisciple: '通过',
  258. discipleComment: '',
  259. bookTradeNo: id,
  260. workerNo: workerno
  261. });
  262. },
  263. submitEvalDisciple() {
  264. if (this.data.radioDisciple == '') {
  265. wx.showToast({
  266. title: '请选择是否通过',
  267. icon: 'none'
  268. })
  269. } else if (this.data.discipleComment == '') {
  270. wx.showToast({
  271. title: '请输入内容',
  272. icon: 'none'
  273. })
  274. } else {
  275. util.request(api.masterFeedback, {
  276. remark: this.data.discipleComment,
  277. feedback: this.data.radioDisciple,
  278. bookTradeNo: this.data.bookTradeNo,
  279. workerNo: this.data.workerNo
  280. }, 'GET').then(res => {
  281. if (res.errno === 0) {
  282. wx.showToast({
  283. title: '评价成功',
  284. icon: 'none'
  285. })
  286. this.setData({
  287. evalDiscipleShow: false,
  288. });
  289. this.getDayCalendar();
  290. } else {
  291. wx.showToast({
  292. title: res.errmsg,
  293. icon: 'none'
  294. })
  295. }
  296. });
  297. }
  298. },
  299. goProblemList(e) {
  300. // this.setData({
  301. // navigateType: 1
  302. // })
  303. let id = e.currentTarget.dataset.id;
  304. wx.navigateTo({
  305. url: '/pages/problem/list/list?bookTradeNo=' + id,
  306. })
  307. },
  308. /**
  309. * 生命周期函数--监听页面加载
  310. */
  311. onLoad: function (options) {
  312. // let current=this.data.wholeCalendar.filter(item=>{return item.day==this.data.currentDay});
  313. // if(current.length==0){
  314. // return false;
  315. // }
  316. // let week=current[0].weekOfYear;
  317. // let weekCalendar=this.data.wholeCalendar.filter(item=>{
  318. // return item.weekOfYear==week;
  319. // });
  320. // this.setData({
  321. // workerDayInfoList:weekCalendar,
  322. // weekCalendar:weekCalendar
  323. // });
  324. // this.getMonthCalender(false, 'first');
  325. // this.getDayCalendar();
  326. },
  327. /**
  328. * 生命周期函数--监听页面显示
  329. */
  330. onShow: function () {
  331. let userInfo = wx.getStorageSync('userInfo');
  332. if (userInfo && userInfo.ofJz == 293) {
  333. this.setData({
  334. showjz:true
  335. })
  336. }
  337. // if(!this.data.isMonthCalender){
  338. // }
  339. this.setData({
  340. page:1,
  341. serviceOrderList:[],
  342. });
  343. this.getOrderList();
  344. this.getWorkerNearTeam();
  345. // this.getDayCalendar();
  346. // let timer = setInterval(() => {
  347. // console.log('定时刷新日历数据', new Date());
  348. // this.getMonthCalender();
  349. // this.getDayCalendar();
  350. // }, 1 * 60 * 1000);
  351. // this.setData({
  352. // timer: timer
  353. // });
  354. },
  355. onHide: function () {
  356. // console.log('onHide');
  357. // clearInterval(this.data.timer);
  358. },
  359. onUnload: function () {
  360. // console.log('onunload');
  361. // clearInterval(this.data.timer);
  362. },
  363. /**
  364. * 页面相关事件处理函数--监听用户下拉动作
  365. */
  366. onPullDownRefresh: function () {
  367. this.setData({
  368. page:1,
  369. serviceOrderList:[],
  370. });
  371. this.getOrderList();
  372. this.getWorkerNearTeam();
  373. },
  374. showFuture(){
  375. this.setData({
  376. calendarBoardShow:false,
  377. isSearchResult:true,
  378. isMonthCalender:true,
  379. orderType:3,
  380. calcendarFold:false,
  381. });
  382. this.getOrderList('first');
  383. },
  384. getOrderList(tag) {
  385. wx.showLoading({
  386. title: '加载中...',
  387. });
  388. util.request(api.workerServiceOrderList, {
  389. date: this.data.orderType==2?'':this.data.currentDay,
  390. pageNo:this.data.page,
  391. pageSize:10,
  392. queryType:this.data.orderType,
  393. month:this.data.orderType==2?this.data.currentMonth:''
  394. }, 'POST').then(res => {
  395. wx.hideLoading();
  396. if (res.errno == 0) {
  397. console.log(res);
  398. if(this.data.orderType==3){
  399. let wholeList=res.data.futureThirtyDays;
  400. let current = wholeList.filter(item => {
  401. return item.day == this.data.currentDay
  402. });
  403. if (current.length == 0) {
  404. return false;
  405. }
  406. let week = current[0].weekOfYear;
  407. let weekCalendar = wholeList.filter(item => {
  408. return item.weekOfYear == week;
  409. });
  410. this.setData({
  411. weekCalendar: weekCalendar,
  412. wholeCalendar:res.data.futureThirtyDays,
  413. avgDay:res.data.avgDay,
  414. futureThirtyDaysStr:res.data.futureThirtyDaysStr,
  415. futureThirtyDaysEnd:res.data.futureThirtyDaysEnd
  416. })
  417. if(tag=='first'){
  418. this.setData({
  419. futureThirtyDays:res.data.futureThirtyDays,
  420. });
  421. }else{
  422. // this.setData({
  423. // futureThirtyDays:weekCalendar
  424. // });
  425. }
  426. }
  427. this.setData({
  428. serviceOrderList: this.data.serviceOrderList.concat(res.data.serviceOrderList),
  429. weather:res.data.weather,
  430. totalPage:res.data.totalPage,
  431. leaveList:res.data.leaveList
  432. });
  433. }
  434. }).catch(err => {
  435. wx.hideLoading();
  436. });
  437. },
  438. goLeavepost: function () {
  439. wx.navigateTo({
  440. url: '/pages/servant/leavepost/leavepost'
  441. })
  442. },
  443. getMonthOrderCount() {
  444. wx.showLoading({
  445. title: '加载中...',
  446. });
  447. util.request(api.workerServiceMonthOrderCount, {
  448. }, 'GET').then(res => {
  449. wx.hideLoading();
  450. if (res.errno === 0) {
  451. this.setData({
  452. futureOrderCount:res.data.futureOrderCount,
  453. monthOrderCount:res.data.monthOrderCount
  454. });
  455. }
  456. }).catch(err => {
  457. wx.hideLoading();
  458. });
  459. },
  460. getWorkerNearTeam() {
  461. wx.showLoading({
  462. title: '加载中...',
  463. });
  464. util.request(api.getWokerNearTeam, {
  465. dateDay: this.data.currentDay,
  466. }, 'GET').then(res => {
  467. wx.hideLoading();
  468. if (res.errno === 0) {
  469. console.log(res);
  470. this.setData({
  471. dayTeam:res.data.dayTeam,
  472. dayTeamName:res.data.dayTeamName
  473. });
  474. }
  475. }).catch(err => {
  476. wx.hideLoading();
  477. });
  478. },
  479. backStart(){
  480. this.setData({
  481. currentDay:this.data.todayTag,
  482. isSearchResult:false,
  483. isMonthCalender:false
  484. })
  485. this.setData({
  486. page:1,
  487. serviceOrderList:[],
  488. orderType:1
  489. });
  490. this.getOrderList();
  491. },
  492. switchDayItem(e){
  493. let day=e.currentTarget.dataset.day;
  494. let name=e.currentTarget.dataset.name;
  495. let week=e.currentTarget.dataset.week;
  496. let weekCalendar = this.data.wholeCalendar.filter(item => {
  497. return item.weekOfYear == week;
  498. });
  499. if(name=='请假'||day<this.data.todayTag){
  500. return false;
  501. }else{
  502. this.setData({
  503. currentDay:day,
  504. page:1,
  505. serviceOrderList:[],
  506. orderType:1,
  507. calcendarFold:true,
  508. futureThirtyDays:weekCalendar
  509. });
  510. this.getOrderList();
  511. }
  512. },
  513. switchMonthItem(e){
  514. let month=e.currentTarget.dataset.month;
  515. let count=e.currentTarget.dataset.count;
  516. this.setData({
  517. calendarBoardShow:false,
  518. currentMonth:month,
  519. isSearchResult:true,
  520. orderType:2,
  521. lastMonthCount:count
  522. });
  523. this.setData({
  524. page:1,
  525. serviceOrderList:[]
  526. });
  527. this.getOrderList();
  528. },
  529. getDayCalendar() {
  530. wx.showLoading({
  531. title: '加载中...',
  532. });
  533. util.request(api.dayCalender, {
  534. date: this.data.currentDay,
  535. }, 'GET').then(res => {
  536. wx.hideLoading();
  537. if (res.errno === 0) {
  538. console.log(res);
  539. this.setData({
  540. dayCalendar: res.data
  541. });
  542. }
  543. }).catch(err => {
  544. wx.hideLoading();
  545. });
  546. },
  547. getMonthCalender(flag, tag) {
  548. wx.showLoading({
  549. title: '加载中...',
  550. });
  551. util.request(api.monthCalender, {
  552. month: this.data.currentMonth,
  553. }, 'GET').then(res => {
  554. wx.hideLoading();
  555. if (res.errno === 0) {
  556. console.log(res);
  557. this.setData({
  558. monthInfo: res.data,
  559. wholeCalendar: res.data.workerDayInfoList
  560. });
  561. if (flag) {
  562. this.setData({
  563. calcendarFold: false,
  564. workerDayInfoList: this.data.wholeCalendar,
  565. });
  566. }
  567. let current = this.data.wholeCalendar.filter(item => {
  568. return item.day == this.data.currentDay
  569. });
  570. if (current.length == 0) {
  571. return false;
  572. }
  573. let week = current[0].weekOfYear;
  574. let weekCalendar = this.data.wholeCalendar.filter(item => {
  575. return item.weekOfYear == week;
  576. });
  577. this.setData({
  578. weekCalendar: weekCalendar
  579. });
  580. if (tag == 'first') {
  581. this.setData({
  582. workerDayInfoList: weekCalendar,
  583. });
  584. }
  585. if (this.data.calcendarFold) {
  586. this.setData({
  587. workerDayInfoList: weekCalendar,
  588. });
  589. } else {
  590. this.setData({
  591. workerDayInfoList: this.data.wholeCalendar,
  592. });
  593. }
  594. } else {
  595. wx.showToast({
  596. title: res.errmsg,
  597. duration: 3000,
  598. icon: 'none'
  599. });
  600. }
  601. }).catch(err => {
  602. wx.hideLoading();
  603. });
  604. },
  605. switchDay(e) {
  606. let day = e.currentTarget.dataset.day;
  607. this.setData({
  608. currentDay: day
  609. });
  610. this.getDayCalendar();
  611. },
  612. calcendarCollapse() {
  613. let calcendarFold = this.data.calcendarFold;
  614. this.setData({
  615. futureThirtyDays: this.data.wholeCalendar,
  616. calcendarFold: !calcendarFold
  617. });
  618. },
  619. lastMonth() {
  620. console.log(this.data);
  621. let params = util.getYearMonth(this.data.currentMonth, '-');
  622. this.setData({
  623. currentMonth: params
  624. });
  625. this.getMonthCalender(true);
  626. },
  627. nextMonth() {
  628. let params = util.getYearMonth(this.data.currentMonth, '+');
  629. console.log(params);
  630. this.setData({
  631. currentMonth: params
  632. });
  633. this.getMonthCalender(true);
  634. },
  635. goIssueTicket() {
  636. wx.navigateTo({
  637. url: '/pages/upgrade/issueTicket/issueTicket',
  638. })
  639. },
  640. supplyCode(e) {
  641. let bookno = e.currentTarget.dataset.bookno;
  642. if (bookno.startsWith('JZ')) {
  643. bookno = bookno.substr(2);
  644. }
  645. util.request(api.createMakeUpQRCode, {
  646. serviceId: bookno
  647. }, 'GET').then(res => {
  648. if (res.errno === 0) {
  649. let url = res.data;
  650. wx.previewImage({
  651. current: url, // 当前显示图片的http链接
  652. urls: [url] // 需要预览的图片http链接列表
  653. })
  654. } else {
  655. wx.showToast({
  656. title: res.errmsg,
  657. icon: 'none'
  658. })
  659. }
  660. });
  661. },
  662. supplyCode(e){
  663. let bookno = e.currentTarget.dataset.bookno;
  664. if (bookno.startsWith('JZ')) {
  665. bookno = bookno.substr(2);
  666. }
  667. app.globalData.diffId=0;
  668. wx.navigateTo({
  669. url: '/pages/serviceSupply/serviceSupply?bookno='+bookno,
  670. });
  671. },
  672. supplyRecord(e){
  673. let bookno = e.currentTarget.dataset.bookno;
  674. if (bookno.startsWith('JZ')) {
  675. bookno = bookno.substr(2);
  676. }
  677. wx.navigateTo({
  678. url: '/pages/supplyRecord/supplyRecord?bookno='+bookno,
  679. });
  680. },
  681. showCalendarBoard(){
  682. this.setData({
  683. calendarBoardShow:true
  684. });
  685. this.getMonthOrderCount();
  686. },
  687. onCalendarOverlay(){
  688. this.setData({
  689. calendarBoardShow:false
  690. });
  691. },
  692. showSchedueBoard(){
  693. this.setData({
  694. schedueBoardShow:true
  695. });
  696. this.getWorkerNearTeam();
  697. },
  698. onSchedueOverlay(){
  699. this.setData({
  700. schedueBoardShow:false
  701. });
  702. },
  703. goLeaveHistory(){
  704. wx.navigateTo({
  705. url: '/pages/servant/leave/leave',
  706. });
  707. },
  708. preventClick(){
  709. //不要删,阻止事件冒泡
  710. },
  711. onReachBottom() {
  712. if (this.data.totalPage > this.data.page) {
  713. this.setData({
  714. page: this.data.page + 1
  715. });
  716. this.getOrderList();
  717. } else{
  718. if(this.data.totalPage>1){
  719. wx.showToast({
  720. title: '没有更多工单了',
  721. icon: 'none',
  722. duration: 2000
  723. });
  724. }
  725. return false;
  726. }
  727. },
  728. /**
  729. * 生命周期函数--监听页面初次渲染完成
  730. */
  731. onReady: function () {
  732. },
  733. /**
  734. * 用户点击右上角分享
  735. */
  736. onShareAppMessage: function () {
  737. },
  738. })