workbench.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. const app = getApp();
  2. Page({
  3. data: {
  4. isAuth: false,
  5. showAuthWin: false,
  6. showChaType: false,
  7. isPrem:false,
  8. device:false,
  9. activationLockStatu:false,// 激活锁闭按钮控制
  10. modalHidden:true,
  11. region: [],
  12. systemMenu:[],
  13. isIcon:'N',
  14. seleteType:[{transportStatus:'00',transportStatusName:'入库'},{transportStatus:'10',transportStatusName:'出库'},{transportStatus:'20',transportStatusName:'结束'}],
  15. showDialog: false,// 详情弹窗
  16. showDialogChild: false,// 选择扫描 or 输入弹窗
  17. tableCoin: [{
  18. name: 'X201',
  19. img: '../../img/work_icon11.png',
  20. status: true,
  21. type: 'lableX201'
  22. },
  23. {
  24. name: 'X202',
  25. img: '../../img/X202.png',
  26. status: true,
  27. type: 'lableX202'
  28. },
  29. {
  30. name: 'X203',
  31. img: '../../img/work_icon11.png',
  32. status: true,
  33. type: 'lableX203'
  34. },
  35. {
  36. name: 'X101',
  37. img: '../../img/x1.png',
  38. status: true,
  39. type: 'lableX101'
  40. },
  41. {
  42. name: 'X102',
  43. img: '../../img/x102.png',
  44. status: true,
  45. type: 'lableX102'
  46. },
  47. {
  48. name: 'X103',
  49. img: '../../img/x2.png',
  50. status: true,
  51. type: 'lableX103'
  52. },
  53. {
  54. name: 'X104',
  55. img: '../../img/x1.png',
  56. status: true,
  57. type: 'lableX104'
  58. },
  59. {
  60. name: 'X105',
  61. img: '../../img/rfid.png',
  62. status: true,
  63. type: 'lableX105'
  64. },
  65. {
  66. name: 'X106',
  67. img: '../../img/x1.png',
  68. status: true,
  69. type: 'lableX106'
  70. },
  71. {
  72. name: 'X107',
  73. img: '../../img/x2.png',
  74. status: true,
  75. type: 'lableX107'
  76. },
  77. ],
  78. scanType:'', //1查看当前激活状态 2激活 3锁闭 4读温度 7读取UID 8读自定义信息 9写入自定义信息 10读采温周期 X106:X106端读卡
  79. menuList:[
  80. {label: "激活查询",path:'workConsole',children:[
  81. {id:1134,label: "查一查",path: "find",icon: "http://oss.zhongyihz.cn/group156/images/67db3b48ee5d54561e687cb76cf68900.png"},
  82. {id:1137,label: "监测列表",path: "coldChain",icon: "http://oss.zhongyihz.cn/group156/images/55b55029256deb87f6769d006e090754.png"},
  83. {id:1278,label: "激活锁闭",path: "onAndOff",icon: "http://oss.zhongyihz.cn/group156/default/20220815/17/51/6/4dcc7eb59450f00227dd7e20380f9c94.png"},
  84. ]}]},
  85. onShow: function () {
  86. var that = this;
  87. //判断token,若有则假设已经登录
  88. if (wx.getStorageSync('token')) {
  89. wx.removeStorageSync('userInfo');
  90. app.requestP({
  91. url: "/user/getUserInfo",
  92. }).then(function(res){
  93. wx.setStorageSync('userInfo',res.data.data)
  94. that.setData({
  95. user : res.data.data
  96. })
  97. //获取菜单列表
  98. that.getMenu();
  99. }).catch(err=>{
  100. app.showToptip(that,'error',err.data.msg)
  101. })
  102. this.getUserDefaultMenuList();
  103. }else{
  104. //获取菜单列表
  105. that.getMenu();
  106. }
  107. //移除之前缓存的用户信息,确保拿到用户最新数据
  108. var tabarData = app.globalData.tabarData;
  109. if(Object.keys(tabarData).length !=0 ){
  110. const {loginRole, ifOverFlow, status, path} = tabarData;
  111. this.matchPage(loginRole,ifOverFlow,status,path);
  112. }
  113. var coinStatus = JSON.parse(wx.getStorageSync('labelStatus'));
  114. var tableCoin = this.data.tableCoin;
  115. var temp = '';
  116. tableCoin.map((coinType, index) => {
  117. Object.keys(coinStatus).forEach(key => {
  118. if (key == coinType.type) {
  119. temp = 'tableCoin[' + index + '].status'
  120. this.setData({
  121. [temp]: coinStatus[key]
  122. })
  123. }
  124. })
  125. })
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. app.globalData.tabarData = {};
  132. },
  133. tapMenu(e) {
  134. let type = e.currentTarget.dataset.type
  135. let path = e.currentTarget.dataset.path
  136. //判断token,若有则假设已经登录
  137. if (!wx.getStorageSync('token')) {
  138. wx.redirectTo({
  139. url: '/pages/login/login',
  140. })
  141. return;
  142. }
  143. //获取用户信息,判断userInfo是否过期
  144. let userInfo = wx.getStorageSync('userInfo');
  145. /**
  146. * status: 用户角色审核状态
  147. * 0 没有选择任何角色也没做任何认证
  148. * 10 审核中
  149. * 20 审核通过
  150. * ifOverFlow:是否通过验证
  151. * N 没有选择角色
  152. * Y 已选择角色
  153. * 非register时,如果是Y说明已经处于认证状态
  154. * admin创建企业,personnel选择了企业
  155. * loginRole:用户权限
  156. * admin 管理员
  157. * doctor 医生
  158. * register 自由注册 可申请为操作员
  159. * personnel 操作员 已选择企业未认证
  160. *
  161. */
  162. const {loginRole,ifOverFlow,status} = userInfo;
  163. this.matchPage(loginRole,ifOverFlow,status,path);
  164. },
  165. matchPage(loginRole,ifOverFlow,status,path) {
  166. if(path == 'localSetting'){ //本地设置无任何权限
  167. wx.navigateTo({
  168. url: '/pages/setting/localSetting/localSetting',
  169. })
  170. return;
  171. }else if(path == 'scanSetting'){//扫描设置无任何权限
  172. wx.navigateTo({
  173. url: '/pages/setting/scanSetting/scanSetting',
  174. })
  175. return;
  176. }
  177. //判断是否选择角色
  178. if(loginRole == 'personnel' || loginRole == 'admin'){
  179. this.setData({path,loginRole});
  180. if(ifOverFlow == 'Y' && loginRole!='register'){
  181. if(status == 20){
  182. this.isAuth(path,loginRole);
  183. }else if(status == 10){
  184. app.showToptip(this,'worning','身份审核中,审核通过可以使用该功能');
  185. }else if(status == 0){
  186. app.showToptip(this,'worning','您还没有选择身份,请选择您的身份并提交认证');
  187. wx.navigateTo({
  188. url: '/pages/userAuth/chooseRole',
  189. })
  190. }
  191. }else if(ifOverFlow == 'N' && loginRole != 'register'){
  192. // this.isAuth(path);
  193. if(loginRole == 'personnel' && path != 'workerManager'){
  194. this.showModel('/pages/userAuth/workerSelect');
  195. }else if(loginRole == 'doctor' && path == 'find' || path == 'companyInfo'){
  196. this.showModel('/pages/userAuth/doctorInfo');
  197. }else if(loginRole == 'admin'){
  198. this.showModel('/pages/userAuth/adminInfo');
  199. }else{
  200. app.showToptip(this,'worning','您当前身份暂无权限');
  201. }
  202. }
  203. }else{
  204. this.setData({path,loginRole});
  205. app.showToptip(this,'worning','您还没有选择身份,请选择您的身份');
  206. wx.navigateTo({
  207. url: '/pages/userAuth/chooseRole',
  208. })
  209. }
  210. },
  211. isAuth(path,loginRole){
  212. //判断用户点击了哪个按钮
  213. if (loginRole == 'admin' || loginRole =='personnel'){
  214. if (path == "find") {
  215. //查一查
  216. this.showChaWin();
  217. } else if(path == 'orderList'){
  218. //订单列表
  219. wx.navigateTo({
  220. url: '/pages/workbench/orderList/orderList'
  221. })
  222. }else if (path == 'warningconfig') {
  223. //预警配置
  224. wx.navigateTo({
  225. url: '/pages/workbench/warningconfig/warningconfig'
  226. })
  227. } else if (path == 'coldChain') {
  228. //冷链管理
  229. wx.navigateTo({
  230. url: '/pages/workbench/tempList/tempList',
  231. })
  232. } else if (path == 'productManager') {
  233. //产品管理
  234. wx.navigateTo({
  235. url: '/pages/workbench/product/product'
  236. })
  237. } else if (path == 'commandSend') {
  238. //指令下发
  239. this.setData({
  240. isPrem: true
  241. });
  242. } else if (path == 'factorycheck') {
  243. //出厂检测
  244. this.device();
  245. } else if (path == 'iodep') {
  246. //出库入库
  247. this.showChaWin();
  248. } else if (path == 'companyInfo') {
  249. // 企业信息
  250. wx.navigateTo({
  251. url: '/pages/companyManager/companyInfo/companyInfo',
  252. })
  253. } else if (path == 'workerManager' && loginRole == 'admin') {
  254. //员工管理
  255. wx.navigateTo({
  256. url: '/pages/companyManager/companyUser/companyUser',
  257. })
  258. }else if(path == 'zyShop'){
  259. //中义商城
  260. wx.navigateTo({
  261. url: '/pages/zyShop/zyShop',
  262. })
  263. }else if(path == 'onAndOff'){
  264. // 激活锁闭
  265. // app.showToptip(this,'worning','小程序暂不支持此功能,请移动到APP操作!');
  266. this.activationLock();
  267. }else {
  268. app.showToptip(this,'worning','您当前身份暂无权限');
  269. }
  270. }else if(loginRole == 'doctor'){
  271. if (path == "find") {
  272. //查一查
  273. this.showChaWin();
  274. }else if (path == 'companyInfo') {
  275. // 企业信息
  276. wx.navigateTo({
  277. url: '/pages/companyManager/companyInfo/companyInfo',
  278. })
  279. } else{
  280. app.showToptip(this,'worning','您当前身份暂无权限');
  281. }
  282. }
  283. },
  284. getMenu() {
  285. const that = this;
  286. //如果有token,则去拉取菜单列表,相反则只显示界面
  287. var loginRole = '';
  288. if(wx.getStorageSync('token')){
  289. var user = this.data.user;
  290. console.log(user);
  291. loginRole = user.loginRole
  292. }
  293. app.requestP({
  294. needToken: false,
  295. url: "/query/listMenu",
  296. data:{
  297. roleKey:loginRole || '',
  298. }
  299. }).then(function (res) {
  300. that.setData({
  301. // menuList: res.data.data
  302. })
  303. }).catch(err=>{
  304. app.showToptip(that,'error',err.data.msg)
  305. })
  306. },
  307. myevent(e){
  308. var that = this;
  309. var systemMenu = this.data.systemMenu;
  310. var arr = [];
  311. let userInfo = wx.getStorageSync('userInfo');
  312. systemMenu.map(item=>{
  313. arr.push(item.menuId)
  314. })
  315. this.setData({
  316. isIcon:e.detail.flag
  317. })
  318. if(e.detail.flag == 'N'){
  319. app.requestP({
  320. url:'/userDeaultMenu/add',
  321. method:'post',
  322. data:{
  323. userId:userInfo.userId,
  324. menuIds:arr
  325. }
  326. }).then(res=>{
  327. app.showToptip(that,'success',res.data.msg)
  328. }).catch(err=>{
  329. app.showToptip(that,'error',err.data.msg)
  330. })
  331. }
  332. },
  333. getUserDefaultMenuList(){
  334. var that = this;
  335. app.requestP({
  336. url:'/userDeaultMenu/list',
  337. method:'post',
  338. }).then(res=>{
  339. that.setData({
  340. systemMenu:res.data.data
  341. })
  342. }).catch(err=>{
  343. app.showToptip(that,'error',err.data.msg)
  344. })
  345. },
  346. iconJian(e){
  347. var that = this;
  348. var menuId = e.currentTarget.dataset.menuId;
  349. var index = e.currentTarget.dataset.index;
  350. var systemMenu = this.data.systemMenu;
  351. var arr = systemMenu;
  352. arr.splice(index,1);
  353. this.setData({
  354. systemMenu:arr
  355. })
  356. },
  357. iconJia(e){
  358. var that = this;
  359. var systemMenu = this.data.systemMenu;
  360. var menu = e.currentTarget.dataset.menu;
  361. if(systemMenu.length >= 4){
  362. app.showToptip(this,'error','常用功能按钮最多为4个')
  363. }else{
  364. for(var i=0;i<systemMenu.length;i++){
  365. if(systemMenu[i].menuId == menu.id){
  366. app.showToptip(that,'error','已经有该按钮,请勿重复选择')
  367. return;
  368. }
  369. }
  370. var arr = systemMenu;
  371. arr.push({...menu,menuName:menu.label,menuId:menu.id,});
  372. this.setData({
  373. systemMenu:arr
  374. })
  375. }
  376. console.log(systemMenu);
  377. },
  378. getUser() {
  379. const that = this
  380. //去拉取用户数据
  381. app.requestP({
  382. url: "/user/getUserInfo",
  383. }).then(function (res) {
  384. wx.setStorageSync('userInfo', res.data.data)
  385. that.setData({
  386. user: res.data.data
  387. })
  388. })
  389. },
  390. //权限弹窗控制
  391. showAuthWin() {
  392. this.setData({
  393. showAuthWin: true
  394. })
  395. },
  396. closeAuthWin() {
  397. this.setData({
  398. showAuthWin: false
  399. })
  400. },
  401. //查一查弹框控制
  402. showChaWin() {
  403. this.setData({
  404. showChaType: true
  405. })
  406. },
  407. closeChaWin() {
  408. this.setData({
  409. showChaType: false,
  410. device:false,
  411. activationLockStatu:false
  412. })
  413. },
  414. device(){
  415. this.setData({
  416. device: true
  417. })
  418. },
  419. // 激活锁闭按钮控制
  420. activationLock(){
  421. this.setData({
  422. activationLockStatu: true
  423. })
  424. },
  425. //开启扫码系统
  426. goScan(e) {
  427. var type = e.currentTarget.dataset.item;
  428. var that = this;
  429. var {path,devicetype} = that.data;
  430. wx.scanCode({
  431. success: function (res) {
  432. var {result} = res;
  433. if(result.indexOf('imei=') != -1){
  434. result = result.slice(result.indexOf('imei=')+5,result.length)
  435. }
  436. if(path == 'find'){
  437. if(that.data.loginRole == 'doctor'){
  438. wx.navigateTo({
  439. url: '/pages/workbench/scanningType/scanningType?inoculatorId='+result+'&path='+path,
  440. })
  441. }else{
  442. that.searchChainCheckBind(result).then(res=>{
  443. var id = res.data.msg;
  444. that.closeChaWin()
  445. that.setData({
  446. showDialog:!that.data.showDialog,
  447. detailId:id,
  448. showDialogChild:!that.data.showDialogChild,
  449. deviceCode:result //867992041247453
  450. })
  451. })
  452. }
  453. }else if(path == 'factorycheck'){
  454. wx.navigateTo({
  455. url: '/pages/device/info?imei='+result+'&devicetype='+devicetype,
  456. })
  457. }else if(path == 'iodep'){
  458. that.searchChainCheckBind(result).then(res=>{
  459. const {transportStatus,id,code} = res.data.chain;
  460. that.setData({
  461. transportStatus,
  462. iodepId:id,
  463. modalHidden:!that.data.modalHidden,
  464. showDialogChild:!that.data.showDialogChild,
  465. seleteType:that.setSeleteType(transportStatus),
  466. });
  467. })
  468. }
  469. },
  470. fail:function(err){
  471. app.showToptip(that, 'error', '二维码无效');
  472. }
  473. })
  474. },
  475. // 查询当前冷链是否绑定
  476. searchChainCheckBind(result){
  477. var that = this;
  478. return new Promise((resolve,reject)=>{
  479. app.requestP({
  480. url:'/chainBound/checkBind',
  481. method:'post',
  482. data:{
  483. deviceCode:result,
  484. }
  485. }).then(res=>{
  486. if(res.data.data != 1){
  487. app.showToptip(that,'error',res.data.msg);
  488. return;
  489. }
  490. app.requestP({
  491. url:'/chain/scan',
  492. method:'post',
  493. contentType:' application/json',
  494. data:{
  495. inoculatorId:'',
  496. payload:result,
  497. type:that.data.devicetype,
  498. }
  499. }).then(res=>{
  500. resolve(res)
  501. }).catch(err=>{
  502. reject()
  503. app.showToptip(that,'error',err.data.msg);
  504. })
  505. }).catch(err=>{
  506. reject()
  507. app.showToptip(that,'error',err.data.msg);
  508. })
  509. })
  510. },
  511. setTransportStatus(transportStatus){
  512. var seleteType = this.data.seleteType;
  513. var deptType;
  514. for(var i=0;i<seleteType.length;i++){
  515. if(seleteType[i].transportStatus == transportStatus){
  516. deptType = i;
  517. break;
  518. }
  519. }
  520. return deptType;
  521. },
  522. setSeleteType(transportStatus){
  523. var seleteType = this.data.seleteType;
  524. var type;
  525. for(var i=0;i<seleteType.length;i++){
  526. if(seleteType[i].transportStatus == transportStatus){
  527. seleteType.splice(i,1);
  528. break;
  529. }
  530. }
  531. this.setTransportStatus(transportStatus);
  532. return seleteType;
  533. },
  534. closePremWin(){
  535. this.setData({
  536. isPrem:false,
  537. iptValue:''
  538. })
  539. },
  540. setValue:function (e){
  541. const that = this;
  542. var iptValue = e.detail.value.substr(0,6)
  543. this.setData({
  544. iptValue
  545. })
  546. if(iptValue.length>=6){
  547. app.requestP({
  548. url:'/commandAuth/checkPremise',
  549. method:'post',
  550. data:{
  551. password:iptValue
  552. }
  553. }).then(res=>{
  554. this.setData({
  555. isPrem:false,
  556. iptValue:''
  557. })
  558. wx.navigateTo({
  559. url: '/pages/instruct/instruct',
  560. })
  561. }).catch(err=>{
  562. this.setData({
  563. isPrem:false,
  564. iptValue:''
  565. })
  566. app.showToptip(that, "error",err.data.msg);
  567. })
  568. }
  569. },
  570. setModalVal(e){
  571. this.setData({
  572. modalVal:e.detail.value
  573. })
  574. },
  575. modalBindaconfirm(){ //二型保存地址
  576. var that = this;
  577. var {region,modalVal,transportStatus,iodepId,seleteType,deptType} = that.data;
  578. var addr = region.join('')+modalVal;
  579. if(region.join('') && modalVal && seleteType[deptType].transportStatus){
  580. app.requestP({
  581. url:'/chain/editTransport',
  582. // contentType:' application/json',
  583. method:'post',
  584. data:{
  585. addr,
  586. chainId:iodepId,
  587. transportStatus:seleteType[deptType].transportStatus, // 00 已入库 //10 已出库 //20 已结束
  588. }
  589. }).then(res=>{
  590. that.setData({
  591. modalHidden:!that.data.modalHidden,
  592. region:[],
  593. modalVal:'',
  594. iodepId:'',
  595. deptType:'',
  596. seleteType:[{transportStatus:'00',transportStatusName:'入库'},{transportStatus:'10',transportStatusName:'出库'},{transportStatus:'20',transportStatusName:'结束'}],
  597. })
  598. app.showToptip(that,'success',res.data.msg);
  599. }).catch(err=>{
  600. app.showToptip(that,'error',err.data.msg);
  601. })
  602. }else{
  603. app.showToptip(that,'error','地址和运输状态不能为空');
  604. }
  605. },
  606. //取消按钮点击事件
  607. modalBindcancel:function(){
  608. this.setData({
  609. modalHidden:!this.data.modalHidden,
  610. region:[],
  611. modalVal:'',
  612. iodepId:'',
  613. deptType:'',
  614. seleteType:[{transportStatus:'00',transportStatusName:'入库'},{transportStatus:'10',transportStatusName:'出库'},{transportStatus:'20',transportStatusName:'结束'}],
  615. })
  616. },
  617. regionChange: function(e) {
  618. this.setData({
  619. region: e.detail.value
  620. })
  621. },
  622. showModel(url){ //提示弹框
  623. wx.showModal({
  624. title: '您还未认证,暂无权限',
  625. // content: '确定要删除该图片?',
  626. showCancel: true, //是否显示取消按钮
  627. cancelText: "取消", //默认是“取消”
  628. cancelColor: '#000', //取消文字的颜色
  629. confirmText: "去认证", //默认是“确定”
  630. confirmColor: '#2D59E6', //确定文字的颜色
  631. success: function (res) {
  632. if (res.cancel) {
  633. //点击取消,默认隐藏弹框
  634. } else {
  635. //点击去认证
  636. wx.navigateTo({
  637. url: url,
  638. })
  639. }
  640. },
  641. fail: function (res) {}, //接口调用失败的回调函数
  642. complete: function (res) {}, //接口调用结束的回调函数(调用成功、失败都会执行)
  643. })
  644. },
  645. setType(e){
  646. var value = e.detail.value;
  647. var that = this;
  648. that.setData({
  649. deptType:value
  650. })
  651. },
  652. toggleDialog() { //详情弹窗
  653. this.setData({
  654. showDialog: !this.data.showDialog,
  655. devicetype:''
  656. });
  657. },
  658. goDetail(){
  659. var detailId = this.data.detailId;
  660. var deviceCode = this.data.deviceCode;
  661. wx.navigateTo({
  662. url: '/pages/workbench/hierarchy/hierarchy?id='+detailId+'&deviceCode='+deviceCode,
  663. })
  664. this.setData({
  665. showDialog:!this.data.showDialog,
  666. devicetype:''
  667. })
  668. },
  669. clearBind(){
  670. var that = this;
  671. var detailId = that.data.detailId;
  672. var deviceCode = that.data.deviceCode;
  673. app.requestP({
  674. url:'/chainBound/unbind',
  675. method:'post',
  676. contentType:' application/json',
  677. data:{
  678. chainId:detailId,
  679. deviceCode,
  680. }
  681. }).then(res=>{
  682. that.setData({
  683. detailId:'',
  684. showDialog:!that.data.showDialog,
  685. })
  686. app.showToptip(that,'success',res.data.msg)
  687. }).catch(err=>{
  688. app.showToptip(that,'error',err.data.msg)
  689. })
  690. },
  691. isScan(){
  692. //goScan
  693. this.setData({
  694. showDialogChild:!this.data.showDialogChild
  695. })
  696. },
  697. inputBind(){
  698. var that = this;
  699. var {path,devicetype} = that.data;
  700. wx.showModal({
  701. title: '请输入标签编号',
  702. editable:true,
  703. success (res) {
  704. if (res.confirm) {
  705. var numreg = /^[0-9]*$/;
  706. if(res.content){
  707. if(!numreg.test(res.content)){
  708. app.showToptip(that, "error", "标签编号只能为数字!");
  709. that.inputBind()
  710. return;
  711. }
  712. if(path == 'factorycheck'){
  713. wx.navigateTo({
  714. url: '/pages/device/info?imei='+res.content+'&devicetype='+devicetype,
  715. })
  716. }else if(path == 'iodep'){
  717. that.searchChainCheckBind(res.content).then(result=>{
  718. const {transportStatus,id,code} = result.data.chain;
  719. that.setData({
  720. transportStatus,
  721. iodepId:id,
  722. modalHidden:!that.data.modalHidden,
  723. showDialogChild:!that.data.showDialogChild,
  724. seleteType:that.setSeleteType(transportStatus),
  725. });
  726. })
  727. }else if(path == 'find'){
  728. that.searchChainCheckBind(res.content).then(result=>{
  729. var id = result.data.msg;
  730. that.closeChaWin()
  731. that.setData({
  732. showDialog:!that.data.showDialog,
  733. detailId:id,
  734. showDialogChild:!that.data.showDialogChild,
  735. deviceCode:res.content //867992041247453
  736. })
  737. })
  738. }
  739. }else{
  740. app.showToptip(that, "error",'标签编号不能为空!')
  741. that.inputBind()
  742. }
  743. }else{
  744. //pass
  745. }
  746. }
  747. })
  748. },
  749. downDialog() { //弹窗关闭
  750. this.setData({
  751. showDialogChild: !this.data.showDialogChild,
  752. devicetype:''
  753. });
  754. },
  755. goScanSetting(e) {
  756. var type = e.currentTarget.dataset.type
  757. var uris = type?"?from="+type:""
  758. wx.navigateTo({
  759. url: '/pages/setting/scanSetting/scanSetting'+uris,
  760. })
  761. },
  762. addChain(e) {
  763. const type = e.currentTarget.dataset.type;
  764. const title = e.currentTarget.dataset.title;
  765. const path = this.data.path;
  766. var type1 = ['X201','X202','X203'];
  767. var type2 = ['X101','X102','X103','X104','X106','X107'];
  768. switch (title) {
  769. case 'showChaType':
  770. this.screenLabel(type,path,type2,type1);
  771. break;
  772. case 'device':
  773. this.screenLabel(type,path,type2,type1);
  774. break;
  775. case 'iodep':
  776. this.screenLabel(type,path,type2,type1);
  777. break;
  778. case 'activationLockStatu':
  779. wx.navigateTo({
  780. url: '/pages/workbench/activationLock/activationLock?title='+type,
  781. })
  782. break;
  783. default:
  784. break;
  785. }
  786. // const noAdd = ['lableX101', 'lableX102', 'lableX103', 'lableX105', 'lableX106', 'lableX107','NFC'];
  787. // if (noAdd.indexOf(type) != -1) {
  788. // app.showToptip(this, 'error', '该标签暂不支持在小程序操作,请移动到APP操作!')
  789. // return;
  790. // }
  791. // // 104 一型无源
  792. // switch (type) {
  793. // case 'lableX104':
  794. // wx.navigateTo({
  795. // url: '/pages/nfc/zhuisu2?path='+path+'&type=X104&loginRole='+this.data.loginRole,
  796. // })
  797. // break;
  798. // default:
  799. // this.setData({
  800. // showDialogChild:!this.data.showDialogChild,
  801. // devicetype:type.substr(5)
  802. // })
  803. // break;
  804. // }
  805. },
  806. screenLabel(type,path,type2,type1){
  807. if(type1.indexOf(type) != -1){
  808. this.setData({
  809. showDialogChild:true,
  810. devicetype:type.substr(5)
  811. })
  812. }else{
  813. if(type == 'X105'){
  814. app.showToptip(this,'error','当前设备不支持RFID形式')
  815. }else if(type2.indexOf(type) != -1){
  816. wx.navigateTo({
  817. url: '/pages/nfc/encryptionNfc/encryptionNfc?type='+type+'&path='+path,
  818. })
  819. }
  820. }
  821. },
  822. toggleDialog() { //弹窗关闭
  823. this.setData({
  824. showDialog: !this.data.showDialog,
  825. devicetype:''
  826. });
  827. },
  828. })