orderDetails.js 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. import * as echarts from '../../ec-canvas/echarts';
  2. var dateTimePicker = require('../../utils/dateTimePicker');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. details: {
  10. chainName: '-',
  11. chainCode: '-',
  12. packageTypeName: '-',
  13. productName: '-',
  14. num: '-',
  15. startTime: '-',
  16. transportStatusName: '-',
  17. userName: '-',
  18. telephone: '-',
  19. productId: '',
  20. status: '',
  21. chainId: '',
  22. },
  23. boundDevice: {},
  24. ec: {
  25. lazyLoad: true,
  26. },
  27. nav: 0,
  28. startDate: "", //开始时间
  29. endDate: "", //结束时间
  30. isshow: true,
  31. isShowText: '显示冷链',
  32. deviceCode: '',
  33. modalHidden: true,
  34. modalVal: '', // 解除预警信息
  35. deptType: '',
  36. seleteType: [{
  37. transportStatus: '00',
  38. transportStatusName: '已入库'
  39. }, {
  40. transportStatus: '10',
  41. transportStatusName: '已出库'
  42. }, {
  43. transportStatus: '20',
  44. transportStatusName: '已结束'
  45. }],
  46. region: [],
  47. allMoer: false,
  48. chainBoundId: '',
  49. tableCoin: [{
  50. name: 'X201',
  51. img: '../../img/work_icon11.png',
  52. status: true,
  53. type: 'lableX201'
  54. },
  55. {
  56. name: 'X202',
  57. img: '../../img/X202.png',
  58. status: true,
  59. type: 'lableX202'
  60. },
  61. {
  62. name: 'X203',
  63. img: '../../img/work_icon11.png',
  64. status: true,
  65. type: 'lableX203'
  66. },
  67. {
  68. name: 'X101',
  69. img: '../../img/x1.png',
  70. status: true,
  71. type: 'lableX101'
  72. },
  73. {
  74. name: 'X102',
  75. img: '../../img/x102.png',
  76. status: true,
  77. type: 'lableX102'
  78. },
  79. {
  80. name: 'X103',
  81. img: '../../img/x2.png',
  82. status: true,
  83. type: 'lableX103'
  84. },
  85. {
  86. name: 'X104',
  87. img: '../../img/x1.png',
  88. status: true,
  89. type: 'lableX104'
  90. },
  91. {
  92. name: 'X105',
  93. img: '../../img/rfid.png',
  94. status: true,
  95. type: 'lableX105'
  96. },
  97. {
  98. name: 'X106',
  99. img: '../../img/x1.png',
  100. status: true,
  101. type: 'lableX106'
  102. },
  103. {
  104. name: 'X107',
  105. img: '../../img/x2.png',
  106. status: true,
  107. type: 'lableX107'
  108. },
  109. ],
  110. showDialog: false, //扫码弹窗
  111. transportOrder:{},
  112. allActive: '展开更多',
  113. isAll: false,
  114. showChainTimeStatus:false,// 运单补录展示状态
  115. // 时间
  116. dateTimeArray1: null,
  117. dateTime1: null,
  118. startYear: null,
  119. endYear: null,
  120. estiTime:null,
  121. },
  122. /**
  123. * 生命周期函数--监听页面加载
  124. */
  125. onLoad: function (options) {
  126. const that = this;
  127. //获取用户信息,判断userInfo是否过期
  128. let userInfo = wx.getStorageSync('userInfo');
  129. /**
  130. * status: 用户角色审核状态
  131. * 0 没有选择任何角色也没做任何认证
  132. * 10 审核中
  133. * 20 审核通过
  134. * ifOverFlow:是否通过验证
  135. * N 没有选择角色
  136. * Y 已选择角色
  137. * 非register时,如果是Y说明已经处于认证状态
  138. * admin创建企业,personnel选择了企业
  139. * loginRole:用户权限
  140. * admin 管理员
  141. * doctor 医生
  142. * register 自由注册 可申请为操作员
  143. * personnel 操作员 已选择企业未认证
  144. *
  145. */
  146. const {loginRole,ifOverFlow,status} = userInfo;
  147. that.setData({
  148. ispdfBut: loginRole == 'admin' ? true : loginRole == 'personnel' ? true : false,
  149. options,
  150. userInfo: wx.getStorageSync('userInfo')
  151. });
  152. this.getTime();
  153. //获取定位信息
  154. wx.getLocation({
  155. altitude: 'altitude',
  156. success(res) {
  157. that.setData({
  158. latitude: res.latitude,
  159. longitude: res.longitude,
  160. userLatitude: res.latitude,
  161. userLongitude: res.longitude,
  162. })
  163. },
  164. error() {
  165. app.showToptip(that, "worning", "获取位置信息失败")
  166. }
  167. })
  168. },
  169. onShow() {
  170. var options = this.data.options;
  171. this.getTransInfo(options);
  172. this.getInfo(options);
  173. this.getBoundDevice(options);
  174. var coinStatus = JSON.parse(wx.getStorageSync('labelStatus'));
  175. var tableCoin = this.data.tableCoin;
  176. var temp = '';
  177. tableCoin.map((coinType, index) => {
  178. Object.keys(coinStatus).forEach(key => {
  179. if (key == coinType.type) {
  180. temp = 'tableCoin[' + index + '].status'
  181. this.setData({
  182. [temp]: coinStatus[key]
  183. })
  184. }
  185. })
  186. })
  187. },
  188. getTransInfo(params = {}) {
  189. var that = this;
  190. wx.showLoading({
  191. title: '正在加载...',
  192. mask: true
  193. })
  194. app.requestP({
  195. url: "/transport/get?id="+params.cid,
  196. method: "get",
  197. }).then(res => {
  198. var transportOrder = res.data.transportOrder;
  199. that.setData({transportOrder})
  200. })
  201. },
  202. getInfo(params = {}) {
  203. var that = this;
  204. const { deviceType, deviceCode, pid, chainBoundId } = params;
  205. var seleteType = that.data.seleteType;
  206. wx.showLoading({
  207. title: '正在加载...',
  208. mask: true
  209. })
  210. app.requestP({
  211. url: "/chain/info",
  212. method: "post",
  213. data: {
  214. chainId: params.id || '',
  215. parentId: pid || 0,
  216. }
  217. }).then(res => {
  218. var data = res.data.data;
  219. const {
  220. chainId
  221. } = data;
  222. that.setData({
  223. details: data,
  224. // deptType:that.setTransportStatus(data.transportStatus),
  225. seleteType: that.setSeleteType(data.transportStatus),
  226. deviceCode,
  227. chainBoundId,
  228. })
  229. that.getHistory({
  230. chainId,
  231. searchTag: '0',
  232. deviceCode,
  233. chainBoundId,
  234. });
  235. that.getTempLine({
  236. chainId,
  237. searchTag: '0',
  238. deviceCode,
  239. deviceType,
  240. chainBoundId
  241. })
  242. }).catch(err => {
  243. app.showToptip(that, "error", "数据获取失败,请稍后再试")
  244. // 隐藏导航栏加载框
  245. wx.hideNavigationBarLoading();
  246. // 停止下拉动作
  247. wx.stopPullDownRefresh();
  248. })
  249. },
  250. setTransportStatus(transportStatus) {
  251. var seleteType = this.data.seleteType;
  252. var deptType;
  253. for (var i = 0; i < seleteType.length; i++) {
  254. if (seleteType[i].transportStatus == transportStatus) {
  255. deptType = i;
  256. break;
  257. }
  258. }
  259. return deptType;
  260. },
  261. setSeleteType(transportStatus) {
  262. var seleteType = this.data.seleteType;
  263. var type;
  264. for (var i = 0; i < seleteType.length; i++) {
  265. if (seleteType[i].transportStatus == transportStatus) {
  266. seleteType.splice(i, 1);
  267. break;
  268. }
  269. }
  270. this.setTransportStatus(transportStatus); //暂时不用
  271. return seleteType;
  272. },
  273. setType(e) {
  274. //数据
  275. var value = e.detail.value;
  276. var that = this;
  277. var chainId = that.data.details.chainId;
  278. var seleteType = that.data.seleteType;
  279. that.setData({
  280. deptType: value + ""
  281. })
  282. // app.requestP({
  283. // url:'/chain/editTransport',
  284. // method:'post',
  285. // data:{
  286. // addr:'',
  287. // chainId,
  288. // transportStatus:seleteType[value].transportStatus,
  289. // }
  290. // }).then(res=>{
  291. // that.setData({
  292. // deptType:value+''
  293. // })
  294. // app.showToptip(that,'success',res.data.msg)
  295. // }).catch(err=>{
  296. // app.showToptip(that,'error',err.data.msg)
  297. // })
  298. },
  299. setTransportStatus(transportStatus) {
  300. var seleteType = this.data.seleteType;
  301. var deptType;
  302. for (var i = 0; i < seleteType.length; i++) {
  303. if (seleteType[i].transportStatus == transportStatus) {
  304. deptType = i;
  305. break;
  306. }
  307. }
  308. return deptType;
  309. },
  310. getBoundDevice(params = {}) {
  311. var that = this;
  312. wx.showLoading({
  313. title: '正在加载...',
  314. mask: true
  315. })
  316. app.requestP({
  317. url: "/chainBound/boundDevice",
  318. method: 'post',
  319. data: {
  320. chainId: params.id
  321. }
  322. }).then(res => {
  323. const data = res.data.data;
  324. Object.keys(data).forEach(key => {
  325. if (data[key].length == 0) {
  326. delete data[key]
  327. }
  328. // 没有子冷链概念
  329. if(key == 'childNum'){
  330. delete data[key]
  331. }
  332. })
  333. that.setData({
  334. boundDevice: data
  335. })
  336. }).catch(err => {
  337. app.showToptip(that, 'error', err.data.msg)
  338. })
  339. },
  340. goDetails(e) {
  341. var that = this;
  342. var json = encodeURIComponent(JSON.stringify(e.currentTarget.dataset));
  343. wx.navigateTo({
  344. url: '/pages/query/vvmInfo?details=' + json + '&id=' + that.data.options.id,
  345. })
  346. },
  347. getHistory(params = {}) {
  348. var that = this;
  349. //chainId,deviceCode,endTime,searchTag,startTime
  350. app.requestP({
  351. url: '/chainLocal/localHistory',
  352. method: 'post',
  353. contentType: ' application/json',
  354. data: {
  355. ...params,
  356. }
  357. }).then(res => {
  358. that.setData({
  359. deviceCode: res.data.data.deviceCode || that.data.deviceCode || 'N/A',
  360. })
  361. that.setLocus(res.data.data);
  362. }).catch(err => {
  363. that.setLocus({
  364. points: []
  365. });
  366. // app.showToptip(that, 'error', err.data.msg)
  367. })
  368. },
  369. goChainCold() {
  370. var that = this;
  371. wx.navigateTo({
  372. url: '/pages/query/childlist/childlist?chainId=' + that.data.details.chainId
  373. })
  374. },
  375. setLocus(data) {
  376. const that = this;
  377. const {
  378. status,
  379. transportType,
  380. points
  381. } = data;
  382. let locations = points;
  383. for (let i in locations) { //设置起始marker
  384. locations[i].id = i - 0
  385. if (i == 0) {
  386. locations[i].iconPath = "/img/map_icon1.png";
  387. locations[i].width = 38;
  388. locations[i].height = 40;
  389. }
  390. if (i == locations.length - 1) {
  391. locations[i].iconPath = "/img/index_icon_" + transportType + '' + status + '' + ".png";
  392. locations[i].width = 54;
  393. locations[i].height = 54;
  394. }
  395. locations[i].latitude = locations[i].lat;
  396. locations[i].longitude = locations[i].lng;
  397. }
  398. that.mapCtx = wx.createMapContext('index_map');
  399. if (locations.length) {
  400. that.setData({
  401. latitude: locations[0].lat || that.data.userLatitude,
  402. longitude: locations[0].lng || that.data.userLongitude,
  403. markers: [locations[0], locations[locations.length - 1]],
  404. polyline: [{
  405. color: '#2D59E6',
  406. width: 2,
  407. points: points,
  408. // arrowLine:true
  409. }]
  410. })
  411. that.mapCtx.includePoints({
  412. points: points,
  413. padding: [50, 50, 50, 50]
  414. })
  415. } else {
  416. that.setData({
  417. latitude: that.data.userLatitude,
  418. longitude: that.data.userLongitude,
  419. markers: [{
  420. iconPath: '/img/index_icon_5000.png',
  421. width: '54',
  422. height: '54',
  423. latitude: that.data.latitude,
  424. longitude: that.data.longitude
  425. }],
  426. polyline: [{
  427. color: '#2D59E6',
  428. width: 2,
  429. points: [],
  430. // arrowLine:true
  431. }]
  432. })
  433. }
  434. that.data.locations = locations
  435. },
  436. getTempLine(params = {}) {
  437. const that = this;
  438. app.requestP({
  439. url: '/chain/tempLine',
  440. method: 'post',
  441. contentType: ' application/json',
  442. data: {
  443. ...params
  444. }
  445. }).then(res => {
  446. var data = res.data.data.temps;
  447. that.setData({
  448. temperature: data
  449. })
  450. if (data.length != 0) {
  451. that.setTemp(data);
  452. } else {
  453. // app.showToptip(that, 'error', '暂无温度数据');
  454. }
  455. }).catch(err => {
  456. // app.showToptip(that, 'error', '暂无温度数据');
  457. })
  458. },
  459. setTemp(data) {
  460. const that = this;
  461. that.ecWen = that.selectComponent('#ecDomWen');
  462. that.ecWen.init((canvas, width, height, dpr) => {
  463. const chart = echarts.init(canvas, null, {
  464. width: width,
  465. height: height,
  466. devicePixelRatio: dpr // new
  467. });
  468. var option = that.getOption();
  469. option.xAxis.data = data.map(v => v.createTime.replace(" ", "\n"))
  470. option.series[0].data = data.map(v => v.temp)
  471. option.dataZoom = [{
  472. type: "slider",
  473. start: 0,
  474. end: (100 / data.length) * 15, //显示五个
  475. },
  476. {
  477. type: "inside",
  478. start: 0,
  479. end: (100 / data.length) * 15, //显示五个
  480. },
  481. ]
  482. chart.setOption(option);
  483. return chart;
  484. })
  485. },
  486. getOption() {
  487. return {
  488. tooltip: {
  489. show: true,
  490. formatter: '{b}\n{c}℃',
  491. trigger: "axis",
  492. position: "top"
  493. },
  494. grid: {
  495. top: '5%',
  496. left: '0%',
  497. right: '5%',
  498. bottom: '18%',
  499. containLabel: true
  500. },
  501. xAxis: {
  502. type: 'category',
  503. nameTextStyle: {
  504. color: "#77869E",
  505. fontSize: 10
  506. },
  507. axisLabel: {
  508. color: "#cccccc",
  509. fontSize: 8,
  510. },
  511. axisLine: {
  512. onZero: false,
  513. lineStyle: {
  514. color: "#cccccc"
  515. }
  516. },
  517. axisTick: {
  518. show: false
  519. },
  520. splitLine: {
  521. show: true,
  522. },
  523. data: ['16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30']
  524. },
  525. yAxis: {
  526. type: 'value',
  527. splitNumber: 10,
  528. max: 40,
  529. axisLine: {
  530. lineStyle: {
  531. color: "#cccccc"
  532. },
  533. show: true
  534. },
  535. },
  536. series: [{
  537. type: 'line',
  538. showSymbol: false,
  539. smooth: true,
  540. lineStyle: {
  541. width: 1,
  542. color: "#328EFD", //#D4D4D4
  543. },
  544. markLine: {
  545. lineStyle: {
  546. color: "#F22424",
  547. },
  548. data: [{
  549. yAxis: 40
  550. }]
  551. },
  552. markPoint: {
  553. symbolSize: 30,
  554. //symbol:'diamond',
  555. label: {
  556. fontSize: 8,
  557. },
  558. data: [{
  559. type: 'max',
  560. name: '最大值'
  561. },
  562. {
  563. type: 'min',
  564. name: '最小值'
  565. }
  566. ]
  567. },
  568. areaStyle: {
  569. origin: "start",
  570. color: {
  571. type: 'linear',
  572. x: 0,
  573. y: 0,
  574. x2: 0,
  575. y2: 1,
  576. colorStops: [{
  577. offset: 0,
  578. color: '#FFFFFF' //
  579. }, {
  580. offset: 1,
  581. color: '#4C96FE' //#D4D4D4
  582. }],
  583. global: false
  584. }
  585. },
  586. data: [18, 36, 25, 30, -20, 40, 33]
  587. }]
  588. }
  589. },
  590. endDateChange(e) {
  591. this.setData({
  592. endDate: e.detail.value
  593. })
  594. },
  595. startDateChange(e) {
  596. this.setData({
  597. startDate: e.detail.value
  598. })
  599. },
  600. submitDate() {
  601. this.getTemp(1, this.data.options);
  602. },
  603. getTemp(type, params = {}) {
  604. var that = this;
  605. const {deviceCode,deviceType} = params;
  606. const chainId = that.data.details.chainId;
  607. var endDate = that.data.endDate;
  608. var startDate = that.data.startDate;
  609. if (type == 1) {
  610. if (endDate && startDate) {} else {
  611. app.showToptip(that, "worning", "请选择起止时间")
  612. return
  613. }
  614. }
  615. wx.showLoading({
  616. mask: true
  617. })
  618. this.getHistory({
  619. chainId,
  620. searchTag: 1,
  621. deviceCode,
  622. endTime: endDate + ' 23:59:59',
  623. startTime: startDate + ' 00:00:00'
  624. });
  625. this.getTempLine({
  626. chainId,
  627. searchTag: 1,
  628. deviceCode,
  629. deviceType,
  630. endTime: endDate + ' 23:59:59',
  631. startTime: startDate + ' 00:00:00'
  632. })
  633. },
  634. setNav(e) {
  635. var nav = e.currentTarget.dataset.val;
  636. const { deviceCode, deviceType, chainBoundId } = this.data.options;
  637. this.setData({
  638. nav,
  639. temperature: []
  640. });
  641. if (nav == 0 || nav == 2) {
  642. const chainId = this.data.details.chainId;
  643. this.getHistory({
  644. chainId,
  645. searchTag: nav,
  646. deviceCode,
  647. chainBoundId: chainBoundId || ''
  648. });
  649. this.getTempLine({
  650. chainId,
  651. searchTag: nav,
  652. deviceCode,
  653. deviceType,
  654. chainBoundId: chainBoundId || ''
  655. })
  656. }
  657. },
  658. isShow() {
  659. if (this.data.isshow) {
  660. this.setData({
  661. isShowText: '隐藏冷链',
  662. isshow: false
  663. })
  664. } else {
  665. this.setData({
  666. isShowText: '显示冷链',
  667. isshow: true
  668. })
  669. }
  670. },
  671. isAllMoer() {
  672. this.setData({
  673. allMoer: !this.data.allMoer
  674. })
  675. },
  676. cleanWarning(e) { // 解除预警
  677. const {
  678. details: {
  679. chainId
  680. },
  681. userInfo: {
  682. loginRole
  683. }
  684. } = this.data;
  685. var status = e.currentTarget.dataset.status;
  686. if (status == 10 || status == 20) {
  687. if (loginRole !== "doctor") {
  688. wx.navigateTo({
  689. url: '/pages/query/clearWarning/clearWarning?chainId=' + chainId, //details
  690. })
  691. } else {
  692. app.showToptip(this, 'error', '暂无权限');
  693. }
  694. }
  695. },
  696. goPdf(e) {
  697. var chainId = e.currentTarget.dataset.id;
  698. var transportOrderUid = e.currentTarget.dataset.orderid;
  699. wx.navigateTo({
  700. url: '/pages/workbench/scanningType/reportPdf/reportPdf?id=' + chainId+'&orderid='+transportOrderUid,
  701. })
  702. },
  703. regionChange: function (e) {
  704. this.setData({
  705. region: e.detail.value
  706. })
  707. },
  708. setModalVal(e) {
  709. this.setData({
  710. modalVal: e.detail.value
  711. })
  712. },
  713. setmodalHidden(e) {
  714. var transportStatus = e.currentTarget.dataset.transportstatus;
  715. if (transportStatus == '00' || transportStatus == '10') {
  716. this.setData({
  717. modalHidden: !this.data.modalHidden,
  718. })
  719. } else if (transportStatus == '20') {
  720. app.showToptip(this, 'error', '冷链已结束,请勿修改运输状态')
  721. }
  722. },
  723. //取消按钮点击事件
  724. modalBindcancel: function () {
  725. this.setData({
  726. modalHidden: !this.data.modalHidden,
  727. region: [],
  728. modalVal: '',
  729. iodepId: '',
  730. })
  731. },
  732. modalBindaconfirm() { //二型保存地址
  733. var that = this;
  734. var {
  735. region,
  736. modalVal,
  737. iodepId,
  738. seleteType,
  739. deptType
  740. } = that.data;
  741. var {
  742. chainId,
  743. transportStatus
  744. } = that.data.details;
  745. var addr = region.join('') + modalVal;
  746. if (region.join('') && modalVal) {
  747. app.requestP({
  748. url: '/chain/editTransport',
  749. // contentType:' application/json',
  750. method: 'post',
  751. data: {
  752. addr,
  753. chainId, // 00 已入库 //10 已出库 //20 已结束
  754. transportStatus: seleteType[deptType].transportStatus,
  755. }
  756. }).then(res => {
  757. that.setData({
  758. modalHidden: !that.data.modalHidden,
  759. region: [],
  760. modalVal: '',
  761. iodepId: '',
  762. })
  763. that.getInfo({
  764. id: chainId
  765. });
  766. app.showToptip(that, 'success', res.data.msg);
  767. }).catch(err => {
  768. app.showToptip(that, 'error', err.data.msg);
  769. })
  770. } else {
  771. app.showToptip(that, 'error', '地址和运输状态不能为空');
  772. }
  773. },
  774. goTempDetail() {
  775. var {
  776. chainId
  777. } = this.data.details;
  778. var nav = this.data.nav;
  779. wx.navigateTo({
  780. url: '/pages/query/tempDetails/tempDetails?chainId=' + chainId + '&searchTag=' + nav,
  781. })
  782. },
  783. //查一查弹框控制
  784. showChaWin() {
  785. this.setData({
  786. showChaType: true
  787. })
  788. },
  789. closeChaWin() {
  790. this.setData({
  791. showChaType: false,
  792. })
  793. },
  794. chainCode(e) {
  795. var that = this;
  796. var chainId = e.currentTarget.dataset.id;
  797. var type = e.currentTarget.dataset.type;
  798. var code = e.currentTarget.dataset.code;
  799. that.scanCode().then(result => {
  800. app.requestP({
  801. url: '/chainSource/add',
  802. method: 'post',
  803. contentType: 'application/json',
  804. data: {
  805. chainId,
  806. [type]: result.code
  807. }
  808. }).then(res => {
  809. app.showToptip(that, 'success', res.data.msg);
  810. that.getInfo({
  811. id: chainId,
  812. pid: 0
  813. });
  814. }).catch(err => {
  815. app.showToptip(that, 'error', err.data.msg);
  816. })
  817. })
  818. },
  819. scanCode() {
  820. var that = this;
  821. return new Promise((resolve, reject) => {
  822. wx.scanCode({
  823. scanType: ['barCode', 'qrCode'],
  824. success: function (res) {
  825. const {
  826. result
  827. } = res;
  828. resolve({
  829. code: result
  830. })
  831. },
  832. fail: function (err) {
  833. app.showToptip(that, 'error', '扫码失败');
  834. }
  835. })
  836. })
  837. },
  838. copyCode(e) {
  839. wx.setClipboardData({
  840. data: e.currentTarget.dataset.code
  841. })
  842. },
  843. goScanSetting() {
  844. wx.navigateTo({
  845. url: '/pages/setting/scanSetting/scanSetting',
  846. })
  847. },
  848. addChain(e) {
  849. const type = e.currentTarget.dataset.type;
  850. var details = this.data.details;
  851. var type1 = ['X201','X202','X203'];
  852. var type2 = ['X101','X102','X103','X104','X106','X107'];
  853. if(type1.indexOf(type) != -1){
  854. this.setData({
  855. showDialog:true,
  856. devicetype:type
  857. })
  858. }else{
  859. if(type == 'X105'){
  860. app.showToptip(this,'error','当前设备不支持RFID形式')
  861. }else if(type2.indexOf(type) != -1){
  862. wx.navigateTo({
  863. url: '/pages/nfc/encryptionNfc/encryptionNfc?type='+type+'&path=addLabel'+"&chainId="+details.chainId,
  864. })
  865. }
  866. }
  867. // 104 一型无源
  868. // switch (type) {
  869. // case 'lableX104':
  870. // wx.navigateTo({
  871. // url: '/pages/nfc/zhuisu2?id='+details.chainId+'&type=X104&addLabel=20',
  872. // })
  873. // break;
  874. // default:
  875. // this.setData({
  876. // showDialog: !this.data.showDialog,
  877. // devicetype:type
  878. // })
  879. // break;
  880. // }
  881. },
  882. toggleDialog() { //弹窗关闭
  883. this.setData({
  884. showDialog: !this.data.showDialog,
  885. devicetype:''
  886. });
  887. },
  888. chainBind() {
  889. var that = this;
  890. wx.scanCode({
  891. success: function (res) {
  892. const { result } = res;
  893. if (result.indexOf('imei=') != -1) {
  894. result = result.slice(result.indexOf('imei=') + 5, result.length)
  895. }
  896. that.setchainBoundBind(result);
  897. },
  898. fail: function (err) {
  899. app.showToptip(that, 'error', '二维码无效');
  900. }
  901. })
  902. },
  903. setchainBoundBind(result) {
  904. var that = this;
  905. var options = this.data.options;
  906. const {details,devicetype,latitude,longitude} = that.data;
  907. app.requestP({
  908. url: '/chainBound/checkBind',
  909. method: 'post',
  910. data: {
  911. deviceCode: result,
  912. }
  913. }).then(res => {
  914. if (res.data.data == 0) {
  915. app.requestP({
  916. url: '/chainBound/bind',
  917. method: 'post',
  918. contentType: ' application/json',
  919. data: {
  920. chainId: details.chainId,
  921. deviceCode: result,
  922. type: devicetype.substr(5),
  923. lat: latitude,
  924. lng: longitude
  925. }
  926. }).then(response => {
  927. app.showToptip(that, 'success', '绑定成功!');
  928. that.getInfo(options);
  929. that.getBoundDevice(options);
  930. }).catch(error => {
  931. app.showToptip(that, 'error', error.data.msg)
  932. })
  933. } else {
  934. app.showToptip(that, 'error', res.data.msg)
  935. }
  936. }).catch(err => {
  937. app.showToptip(that, 'error', err.data.msg)
  938. })
  939. },
  940. inputBind() {
  941. var that = this
  942. wx.showModal({
  943. title: '请输入标签编号',
  944. editable: true,
  945. success(res) {
  946. if (res.confirm) {
  947. var numreg = /^[0-9]*$/;
  948. if (res.content) {
  949. // if (!numreg.test(res.content)) {
  950. // app.showToptip(that, "error", "标签编号只能为数字!");
  951. // that.inputBind()
  952. // return;
  953. // }
  954. that.setchainBoundBind(res.content)
  955. } else {
  956. app.showToptip(that, "error", '标签编号不能为空!')
  957. that.inputBind()
  958. }
  959. } else {
  960. //pass
  961. }
  962. }
  963. })
  964. },
  965. onAll() {
  966. if (!this.data.isAll) {
  967. this.setData({
  968. allActive: '收回',
  969. isAll: true,
  970. })
  971. } else {
  972. this.setData({
  973. allActive: '展开更多',
  974. isAll: false,
  975. })
  976. }
  977. },
  978. // 运单补录
  979. showChainTime(){
  980. this.setData({
  981. showChainTimeStatus:!this.data.showChainTimeStatus
  982. })
  983. },
  984. getTime(){
  985. // 获取完整的年月日 时分秒,以及默认显示的数组
  986. var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
  987. var obj1 = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
  988. // 精确到分的处理,将数组的秒去掉
  989. //var lastArray = obj1.dateTimeArray.pop();
  990. //var lastTime = obj1.dateTime.pop();
  991. this.setData({
  992. dateTimeArray1: obj1.dateTimeArray,
  993. dateTime1: obj1.dateTime
  994. });
  995. },
  996. // 选择日期时间
  997. changeDateTime1(e) {
  998. var that = this;
  999. this.setData({
  1000. dateTime1: e.detail.value,
  1001. // estiTime:
  1002. },()=>{
  1003. var dateTimeArray1 = that.data.dateTimeArray1;
  1004. var dateTime1 = that.data.dateTime1;
  1005. var years = dateTimeArray1[0][dateTime1[0]] //年
  1006. var month = dateTimeArray1[1][dateTime1[1]] // 月
  1007. var day = dateTimeArray1[2][dateTime1[2]] // 日
  1008. var hours = dateTimeArray1[3][dateTime1[3]] // 时
  1009. var min = dateTimeArray1[4][dateTime1[4]] // 分
  1010. var seconds = dateTimeArray1[5][dateTime1[5]] // 秒
  1011. var startTime = years+'-'+month+'-'+day+' '+hours+':'+min+':'+seconds;
  1012. const {code,uid} = that.data.transportOrder;
  1013. this.updteVvmTransportOrder({code,uid,startTime})
  1014. });
  1015. },
  1016. changeDateTimeColumn1(e) {
  1017. var arr = this.data.dateTime1,
  1018. dateArr = this.data.dateTimeArray1;
  1019. arr[e.detail.column] = e.detail.value;
  1020. dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
  1021. this.setData({
  1022. dateTimeArray1: dateArr,
  1023. dateTime1: arr
  1024. });
  1025. },
  1026. updteVvmTransportOrder(form){
  1027. var that = this;
  1028. app.requestP({
  1029. url: '/transport/updteVvmTransportOrder',
  1030. method: 'post',
  1031. contentType: 'application/json',
  1032. data: form
  1033. }).then(res=>{
  1034. app.showToptip(that, 'success', res.data.msg)
  1035. }).catch(err=>{
  1036. app.showToptip(that, 'error', err.data.msg)
  1037. })
  1038. },
  1039. goEditOrder(){
  1040. const {transportName,transportType,driverName,plateNum,code,uid} = this.data.transportOrder;
  1041. wx.navigateTo({
  1042. url: '/pages/query/editOrder/editOrder?transportName='+transportName+'&transport='+transportType+'&driverName='+driverName+'&plateNum='+plateNum+'&code='+code+'&uid='+uid,
  1043. })
  1044. }
  1045. })