MainLayout.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  1. <template>
  2. <q-layout
  3. view="hHh LpR fFf"
  4. :style="{ height: $q.screen.height, width: $q.screen.width }"
  5. >
  6. <q-header reveal elevated class="bg-primary text-white">
  7. <q-toolbar class="main-headers text-white shadow-18 rounded-borders">
  8. <transition appear enter-active-class="animated zoomIn">
  9. <q-btn flat @click="drawerleft = !drawerleft" round dense icon="menu">
  10. <q-tooltip
  11. content-class="bg-amber text-black shadow-4"
  12. :offset="[15, 15]"
  13. content-style="font-size: 12px"
  14. >{{
  15. drawerleft ? $t("index.hide_menu") : $t("index.open_menu")
  16. }}</q-tooltip
  17. >
  18. </q-btn>
  19. </transition>
  20. <transition appear enter-active-class="animated zoomIn">
  21. <q-toolbar-title
  22. shrink
  23. class="text-weight-bold"
  24. @click="
  25. $router.push({ name: 'web_index' });
  26. linkChange('');
  27. "
  28. >
  29. {{ $t("index.title") }}</q-toolbar-title
  30. >
  31. </transition>
  32. <q-space />
  33. <screenfull id="screenfull" class="right-menu-item hover-effect" />
  34. <transition appear enter-active-class="animated zoomIn">
  35. <q-btn
  36. square
  37. dense
  38. flat
  39. color="white"
  40. :label="warehouse_name"
  41. icon="maps_home_work"
  42. style="margin: 0 10px 0 10px"
  43. >
  44. <q-tooltip
  45. content-class="bg-amber text-black shadow-4"
  46. :offset="[15, 15]"
  47. content-style="font-size: 12px"
  48. >
  49. {{ $t("index.warehouse_switch") }}
  50. </q-tooltip>
  51. <q-menu>
  52. <q-list style="min-width: 100px">
  53. <q-item
  54. clickable
  55. v-close-popup
  56. v-for="(warehouse, index) in warehouseOptions"
  57. :key="index"
  58. @click="warehouseChange(index)"
  59. >
  60. <q-item-section>{{
  61. warehouse.warehouse_name
  62. }}</q-item-section>
  63. </q-item>
  64. </q-list>
  65. </q-menu>
  66. </q-btn>
  67. </transition>
  68. <q-separator vertical />
  69. <template v-if="authin === '1'">
  70. <transition appear enter-active-class="animated zoomIn">
  71. <q-btn-dropdown stretch flat color="white-8" icon="account_circle">
  72. <div class="q-pa-md">
  73. <div class="column items-center">
  74. <q-avatar size="72px"
  75. ><q-img src="statics/staff/stafftype.png"></q-img
  76. ></q-avatar>
  77. <div class="text-subtitle1 q-mt-md q-mb-xs">
  78. {{ login_name }}
  79. </div>
  80. <q-btn
  81. color="primary"
  82. :label="$t('index.change_user')"
  83. push
  84. size="sm"
  85. v-close-popup
  86. icon="face"
  87. @click="login = true"
  88. >
  89. <q-tooltip
  90. content-class="bg-amber text-black shadow-4"
  91. :offset="[10, 10]"
  92. content-style="font-size: 12px"
  93. >{{ $t("index.change_user") }}</q-tooltip
  94. >
  95. </q-btn>
  96. <q-separator />
  97. <q-btn
  98. color="primary"
  99. :label="$t('index.logout')"
  100. push
  101. size="sm"
  102. v-close-popup
  103. icon="img:statics/icons/logout.png"
  104. @click="Logout()"
  105. >
  106. <q-tooltip
  107. content-class="bg-amber text-black shadow-4"
  108. :offset="[10, 10]"
  109. content-style="font-size: 12px"
  110. >{{ $t("index.logout") }}</q-tooltip
  111. >
  112. </q-btn>
  113. </div>
  114. </div>
  115. </q-btn-dropdown>
  116. </transition>
  117. </template>
  118. <template v-if="authin === '0'">
  119. <transition appear enter-active-class="animated zoomIn">
  120. <q-btn
  121. :label="$t('index.login')"
  122. color="primary"
  123. @click="login = true"
  124. style="margin-left: 10px"
  125. >
  126. <q-tooltip
  127. content-class="bg-amber text-black shadow-4"
  128. :offset="[15, 15]"
  129. content-style="font-size: 12px"
  130. >{{ $t("index.login_tip") }}</q-tooltip
  131. >
  132. </q-btn>
  133. </transition>
  134. <transition appear enter-active-class="animated zoomIn">
  135. <q-btn
  136. :label="$t('index.register')"
  137. color="primary"
  138. @click="register = true"
  139. style="margin-left: 10px"
  140. >
  141. <q-tooltip
  142. content-class="bg-amber text-black shadow-4"
  143. :offset="[15, 15]"
  144. content-style="font-size: 12px"
  145. >{{ $t("index.register_tip") }}</q-tooltip
  146. >
  147. </q-btn>
  148. </transition>
  149. </template>
  150. </q-toolbar>
  151. </q-header>
  152. <q-drawer
  153. v-model="drawerleft"
  154. show-if-above
  155. :width="200"
  156. :breakpoint="500"
  157. bordered
  158. content-class="bg-grey-3 shadow-24"
  159. >
  160. <q-scroll-area class="fit" style="overflow-y: auto">
  161. <q-list>
  162. <q-item
  163. clickable
  164. :to="{ name: 'management' }"
  165. @click="linkChange('stock')"
  166. v-ripple
  167. exact
  168. :active="link === 'stock' && link !== ''"
  169. :class="{ 'my-menu-link': link === 'stock' && link !== '' }"
  170. >
  171. <q-item-section avatar
  172. ><q-icon name="multiline_chart"
  173. /></q-item-section>
  174. <q-item-section>{{ $t("menuItem.stock") }}</q-item-section>
  175. </q-item>
  176. <q-separator />
  177. <q-item
  178. clickable
  179. :to="{ name: 'erpasn' }"
  180. @click="linkChange('erp')"
  181. v-ripple
  182. exact
  183. :active="link === 'erp' && link !== ''"
  184. :class="{
  185. 'my-menu-link': link === 'erp' && link !== '',
  186. }"
  187. >
  188. <q-item-section avatar
  189. ><q-icon name="img:statics/outbound/outbound.png"
  190. /></q-item-section>
  191. <q-item-section>{{ "ERP任务" }}</q-item-section>
  192. <q-badge
  193. v-if="ERPTasks > 0"
  194. color="red-5"
  195. class="task-badge"
  196. :class="{ 'high-priority': ERPTasks > 20 }"
  197. >
  198. {{ ERPTasks > 99 ? "99+" : ERPTasks }}
  199. </q-badge>
  200. <q-badge
  201. v-if="ERPOutTasks > 0"
  202. color="blue-5"
  203. class="outtask-badge"
  204. >
  205. {{ ERPOutTasks > 99 ? "99+" : ERPOutTasks }}
  206. </q-badge>
  207. </q-item>
  208. <q-separator />
  209. <q-item
  210. clickable
  211. :to="{ name: 'asn' }"
  212. @click="linkChange('inbound')"
  213. v-ripple
  214. exact
  215. :active="link === 'inbound' && link !== ''"
  216. :class="{ 'my-menu-link': link === 'inbound' && link !== '' }"
  217. >
  218. <q-item-section avatar
  219. ><q-icon name="speaker_notes"
  220. /></q-item-section>
  221. <q-item-section>{{ $t("menuItem.inbound") }}</q-item-section>
  222. </q-item>
  223. <q-item
  224. clickable
  225. :to="{ name: 'containerlist' }"
  226. @click="linkChange('container')"
  227. v-ripple
  228. exact
  229. :active="link === 'container' && link !== ''"
  230. :class="{
  231. 'my-menu-link': link === 'container' && link !== '',
  232. }"
  233. >
  234. <q-item-section avatar
  235. ><q-icon name="stay_current_landscape"
  236. /></q-item-section>
  237. <q-item-section>托盘管理</q-item-section>
  238. </q-item>
  239. <q-item
  240. clickable
  241. :to="{ name: 'dn' }"
  242. @click="linkChange('outbound')"
  243. v-ripple
  244. exact
  245. :active="link === 'outbound' && link !== ''"
  246. :class="{ 'my-menu-link': link === 'outbound' && link !== '' }"
  247. >
  248. <q-item-section avatar>
  249. <q-icon name="rv_hookup"> </q-icon>
  250. </q-item-section>
  251. <q-item-section>{{ $t("menuItem.outbound") }}</q-item-section>
  252. <q-badge
  253. v-if="pendingTasks > 0"
  254. color="red-5"
  255. class="task-badge"
  256. :class="{ 'high-priority': pendingTasks > 20 }"
  257. >
  258. {{ pendingTasks > 99 ? "99+" : pendingTasks }}
  259. </q-badge>
  260. </q-item>
  261. <q-separator />
  262. <q-item
  263. clickable
  264. :to="{ name: 'task' }"
  265. @click="linkChange('taskpage')"
  266. v-ripple
  267. exact
  268. :active="link === 'taskpage' && link !== ''"
  269. :class="{
  270. 'my-menu-link': link === 'taskpage' && link !== '',
  271. }"
  272. >
  273. <q-item-section avatar
  274. ><q-icon name="img:statics/outbound/picked.png"
  275. /></q-item-section>
  276. <q-item-section>任务管理</q-item-section>
  277. </q-item>
  278. <q-separator />
  279. <q-item
  280. clickable
  281. :to="{ name: 'inboundAndOutbound' }"
  282. @click="linkChange('outbounddashboard')"
  283. v-ripple
  284. exact
  285. :active="link === 'outbounddashboard' && link !== ''"
  286. :class="{
  287. 'my-menu-link': link === 'outbounddashboard' && link !== '',
  288. }"
  289. >
  290. <q-item-section avatar><q-icon name="auto_graph" /></q-item-section>
  291. <q-item-section>{{ $t("menuItem.dashboard") }}</q-item-section>
  292. </q-item>
  293. <q-item
  294. clickable
  295. :to="{ name: 'warehouseset' }"
  296. @click="linkChange('warehouse')"
  297. v-ripple
  298. exact
  299. :active="link === 'warehouse' && link !== ''"
  300. :class="{ 'my-menu-link': link === 'warehouse' && link !== '' }"
  301. >
  302. <q-item-section avatar><q-icon name="settings" /></q-item-section>
  303. <q-item-section>{{ $t("menuItem.warehouse") }}</q-item-section>
  304. </q-item>
  305. <q-item
  306. clickable
  307. :to="{ name: 'stafflist' }"
  308. @click="linkChange('staff')"
  309. v-ripple
  310. exact
  311. :active="link === 'staff' && link !== ''"
  312. :class="{ 'my-menu-link': link === 'staff' && link !== '' }"
  313. >
  314. <q-item-section avatar
  315. ><q-icon name="assignment_ind"
  316. /></q-item-section>
  317. <q-item-section>{{ $t("menuItem.staff") }}</q-item-section>
  318. </q-item>
  319. <q-separator />
  320. <q-item
  321. clickable
  322. :to="{ name: 'initializeupload' }"
  323. @click="linkChange('uploadcenter')"
  324. v-ripple
  325. exact
  326. :active="link === 'uploadcenter' && link !== ''"
  327. :class="{ 'my-menu-link': link === 'uploadcenter' && link !== '' }"
  328. >
  329. <q-item-section avatar
  330. ><q-icon name="file_upload"
  331. /></q-item-section>
  332. <q-item-section>{{ $t("menuItem.uploadcenter") }}</q-item-section>
  333. </q-item>
  334. <q-item
  335. clickable
  336. :to="{ name: 'downloadinbound' }"
  337. @click="linkChange('downloadcenter')"
  338. v-ripple
  339. exact
  340. :active="link === 'downloadcenter' && link !== ''"
  341. :class="{
  342. 'my-menu-link': link === 'downloadcenter' && link !== '',
  343. }"
  344. >
  345. <q-item-section avatar
  346. ><q-icon name="file_download"
  347. /></q-item-section>
  348. <q-item-section>{{ $t("menuItem.downloadcenter") }}</q-item-section>
  349. </q-item>
  350. <q-separator />
  351. </q-list>
  352. </q-scroll-area>
  353. </q-drawer>
  354. <q-page-container
  355. class="main-page"
  356. :style="{
  357. height: container_height,
  358. width: $q.screen.width,
  359. }"
  360. >
  361. <router-view />
  362. </q-page-container>
  363. <q-dialog
  364. v-model="authid"
  365. transition-show="jump-down"
  366. transition-hide="jump-up"
  367. >
  368. <q-card style="min-width: 350px">
  369. <q-bar
  370. class="bg-light-blue-10 text-white rounded-borders"
  371. style="height: 50px"
  372. >
  373. <div>{{ $t("index.your_openid") }}</div>
  374. <q-space></q-space>
  375. <q-btn dense flat icon="close" v-close-popup>
  376. <q-tooltip
  377. content-class="bg-amber text-black shadow-4"
  378. :offset="[20, 20]"
  379. content-style="font-size: 12px"
  380. >{{ $t("index.close") }}</q-tooltip
  381. >
  382. </q-btn>
  383. </q-bar>
  384. <q-card-section class="q-pt-md"
  385. ><q-input
  386. dense
  387. outlined
  388. square
  389. label="Openid"
  390. v-model="openid"
  391. readonly
  392. disable
  393. /></q-card-section>
  394. </q-card>
  395. </q-dialog>
  396. <q-dialog
  397. v-model="login"
  398. transition-show=""
  399. transition-hide=""
  400. persistent
  401. full-width
  402. full-height
  403. >
  404. <div
  405. class="flex flex-center"
  406. style="
  407. height: 100%;
  408. background-color: #f5f5f5;
  409. position: absolute;
  410. top: 0;
  411. left: 0;
  412. right: 0;
  413. bottom: 0;
  414. "
  415. >
  416. <div
  417. style="
  418. font-size: 55px;
  419. letter-spacing: 10px;
  420. width: 100%;
  421. text-align: center;
  422. margin-top: 10px;
  423. "
  424. >
  425. {{ $t("index.developer") }}
  426. </div>
  427. <q-card style="min-width: 350px">
  428. <q-bar
  429. class="bg-light-blue-10 text-white rounded-borders"
  430. style="height: 50px"
  431. >
  432. <q-tabs v-model="activeTab" class="tabs">
  433. <q-tab name="admin" @click="admin = true">
  434. {{ $t("index.user_login") }}
  435. <q-tooltip
  436. content-class="bg-amber text-black shadow-4"
  437. :offset="[5, 5]"
  438. content-style="font-size: 12px"
  439. >{{ $t("index.user_login") }}</q-tooltip
  440. >
  441. </q-tab>
  442. </q-tabs>
  443. <q-space />
  444. </q-bar>
  445. <q-card-section class="q-pt-md">
  446. <template v-if="admin">
  447. <q-input
  448. dense
  449. outlined
  450. square
  451. :label="$t('index.staff_name')"
  452. v-model="adminlogin.name"
  453. autofocus
  454. @keyup.enter="adminLogin()"
  455. />
  456. <q-input
  457. dense
  458. outlined
  459. square
  460. :label="$t('index.password')"
  461. :type="isPwd ? 'password' : 'text'"
  462. v-model="adminlogin.password"
  463. @keyup.enter="adminLogin()"
  464. style="margin-top: 5px"
  465. >
  466. <template v-slot:append>
  467. <q-icon
  468. :name="isPwd ? 'visibility_off' : 'visibility'"
  469. class="cursor-pointer"
  470. @click="isPwd = !isPwd"
  471. />
  472. </template>
  473. </q-input>
  474. </template>
  475. </q-card-section>
  476. <q-card-actions align="left" class="text-primary">
  477. <q-space />
  478. <template>
  479. <q-btn
  480. color="primary"
  481. :label="$t('index.login')"
  482. style="font-size: 16px; margin: 0 8px; width: 100%"
  483. @click="adminLogin()"
  484. />
  485. </template>
  486. <div class="q-mx-auto">
  487. <q-btn
  488. flat
  489. class="text-teal-4 q-mt-sm"
  490. @click="
  491. login = false;
  492. register = true;
  493. "
  494. >
  495. {{ $t("index.register_tip") }}
  496. </q-btn>
  497. </div>
  498. </q-card-actions>
  499. </q-card>
  500. <lottie-web-cimo
  501. ref="lottie_web"
  502. animationName="welcome"
  503. style="width: 85%; max-width: 95%; height: 12%; margin: auto"
  504. />
  505. </div>
  506. </q-dialog>
  507. <q-dialog
  508. v-model="register"
  509. transition-show=""
  510. transition-hide=""
  511. persistent
  512. full-width
  513. full-height
  514. >
  515. <div
  516. class="flex flex-center"
  517. style="
  518. height: 100%;
  519. background-color: #f5f5f5;
  520. position: absolute;
  521. top: 0;
  522. left: 0;
  523. right: 0;
  524. bottom: 0;
  525. "
  526. >
  527. <div
  528. style="
  529. font-size: 55px;
  530. letter-spacing: 10px;
  531. width: 100%;
  532. text-align: center;
  533. margin-top: 10px;
  534. "
  535. >
  536. {{ $t("index.developer") }}
  537. </div>
  538. <q-card style="min-width: 350px">
  539. <q-bar
  540. class="bg-light-blue-10 text-white rounded-borders"
  541. style="height: 50px"
  542. >
  543. <div>{{ $t("index.register_tip") }}</div>
  544. </q-bar>
  545. <q-card-section class="q-pt-md">
  546. <q-input
  547. dense
  548. outlined
  549. square
  550. :label="$t('index.staff_name')"
  551. v-model="registerform.name"
  552. @keyup.enter="Register()"
  553. />
  554. <q-input
  555. dense
  556. outlined
  557. square
  558. :label="$t('index.password')"
  559. v-model="registerform.password1"
  560. :type="isPwd ? 'password' : 'text'"
  561. @keyup.enter="Register()"
  562. style="margin-top: 5px"
  563. >
  564. <template v-slot:append>
  565. <q-icon
  566. :name="isPwd ? 'visibility_off' : 'visibility'"
  567. class="cursor-pointer"
  568. @click="isPwd = !isPwd"
  569. />
  570. </template>
  571. </q-input>
  572. <q-input
  573. dense
  574. outlined
  575. square
  576. :label="$t('index.confirm_password')"
  577. v-model="registerform.password2"
  578. :type="isPwd2 ? 'password' : 'text'"
  579. @keyup.enter="Register()"
  580. style="margin-top: 5px"
  581. >
  582. <template v-slot:append>
  583. <q-icon
  584. :name="isPwd2 ? 'visibility_off' : 'visibility'"
  585. class="cursor-pointer"
  586. @click="isPwd2 = !isPwd2"
  587. />
  588. </template>
  589. </q-input>
  590. </q-card-section>
  591. <q-card-actions align="right" class="text-primary q-mx-sm"
  592. ><q-btn
  593. class="full-width"
  594. color="primary"
  595. :label="$t('index.register')"
  596. @click="Register()"
  597. /></q-card-actions>
  598. <q-card-actions align="center" style="margin-top: -8px">
  599. <q-btn
  600. class="text-teal-4"
  601. flat
  602. :label="$t('index.return_to_login')"
  603. @click="
  604. login = true;
  605. register = false;
  606. "
  607. ></q-btn>
  608. </q-card-actions>
  609. </q-card>
  610. <lottie-web-cimo
  611. ref="lottie_web"
  612. animationName="welcome"
  613. style="width: 85%; max-width: 95%; height: 12%; margin: auto"
  614. />
  615. </div>
  616. </q-dialog>
  617. <q-dialog v-model="switch_warehouse">
  618. <q-card class="shadow-24">
  619. <q-bar
  620. class="bg-light-blue-10 text-white rounded-borders"
  621. style="height: 50px"
  622. >
  623. <div>{{ $t("index.warehouse_switch") }}</div>
  624. <q-space />
  625. </q-bar>
  626. <q-card-section style="max-height: 325px; width: 400px" class="scroll">
  627. {{
  628. switch_state
  629. ? $t("index.switch_state_on")
  630. : $t("index.switch_state_off")
  631. }}
  632. </q-card-section>
  633. </q-card>
  634. </q-dialog>
  635. </q-layout>
  636. </template>
  637. <script>
  638. import { get, getauth, post, baseurl } from 'boot/axios_request'
  639. import { LocalStorage, SessionStorage, openURL } from 'quasar'
  640. import Bus from 'boot/bus.js'
  641. import LottieWebCimo from 'components/lottie-web-cimo'
  642. import Screenfull from 'components/Screenfull'
  643. export default {
  644. components: {
  645. LottieWebCimo,
  646. Screenfull
  647. },
  648. data () {
  649. return {
  650. device: LocalStorage.getItem('device'),
  651. device_name: LocalStorage.getItem('device_name'),
  652. lang: 'zh-hans',
  653. container_height: this.$q.screen.height + '' + 'px',
  654. warehouse_name: '',
  655. warehouseOptions: [],
  656. warehouseOptions_openid: [],
  657. langOptions: [{ value: 'zh-hans', label: '中文简体' }],
  658. title: this.$t('index.webtitle'),
  659. admin: true,
  660. adminlogin: {
  661. name: '',
  662. password: ''
  663. },
  664. openid: '',
  665. appid: '',
  666. switch_state: false,
  667. switch_warehouse: false,
  668. isPwd: true,
  669. isPwd2: true,
  670. authin: '0',
  671. authid: false,
  672. left: false,
  673. drawerleft: false,
  674. tab: '',
  675. login: false,
  676. link: '',
  677. login_name: '',
  678. login_id: 0,
  679. check_code: '',
  680. register: false,
  681. registerform: {
  682. name: '',
  683. password1: '',
  684. password2: ''
  685. },
  686. needLogin: '',
  687. activeTab: '',
  688. ERPTasks: 0,
  689. ERPOutTasks: 0,
  690. pendingTasks: 0,
  691. pollInterval: null,
  692. timer: null
  693. }
  694. },
  695. methods: {
  696. linkChange (e) {
  697. var _this = this
  698. localStorage.removeItem('menulink')
  699. localStorage.setItem('menulink', e)
  700. _this.link = e
  701. console.log(_this.link)
  702. },
  703. drawerClick (e) {
  704. var _this = this
  705. if (_this.miniState) {
  706. _this.miniState = false
  707. e.stopPropagation()
  708. }
  709. },
  710. brownlink (e) {
  711. openURL(e)
  712. },
  713. apiLink () {
  714. openURL(baseurl + '/api/docs/')
  715. },
  716. adminLogin () {
  717. var _this = this
  718. if (!_this.adminlogin.name) {
  719. _this.$q.notify({
  720. message: '请输入用户名',
  721. color: 'negative',
  722. icon: 'close'
  723. })
  724. } else {
  725. if (!_this.adminlogin.password) {
  726. _this.$q.notify({
  727. message: '请输入密码',
  728. icon: 'close',
  729. color: 'negative'
  730. })
  731. } else {
  732. SessionStorage.set('axios_check', 'false')
  733. post('login/', _this.adminlogin)
  734. .then((res) => {
  735. if (res.code === '200') {
  736. _this.authin = '1'
  737. _this.login = false
  738. _this.admin = false
  739. _this.openid = res.data.openid
  740. _this.appid = res.data.appid
  741. _this.login_name = res.data.name
  742. _this.login_id = res.data.user_id
  743. LocalStorage.set('auth', '1')
  744. LocalStorage.set('openid', res.data.openid)
  745. LocalStorage.set('appid', res.data.appid)
  746. LocalStorage.set('login_name', _this.login_name)
  747. LocalStorage.set('login_id', _this.login_id)
  748. LocalStorage.set('login_mode', res.data.staff_type)
  749. _this.$q.notify({
  750. message: 'Success Login',
  751. icon: 'check',
  752. color: 'green'
  753. })
  754. localStorage.removeItem('menulink')
  755. _this.link = ''
  756. _this.$router.push({ name: 'web_index' })
  757. window.setTimeout(() => {
  758. location.reload()
  759. }, 1)
  760. } else {
  761. _this.$q.notify({
  762. message: res.msg,
  763. icon: 'close',
  764. color: 'negative'
  765. })
  766. }
  767. })
  768. .catch((err) => {
  769. _this.$q.notify({
  770. message: err.detail,
  771. icon: 'close',
  772. color: 'negative'
  773. })
  774. })
  775. }
  776. }
  777. },
  778. Logout () {
  779. var _this = this
  780. _this.authin = '0'
  781. _this.login_name = ''
  782. LocalStorage.remove('auth')
  783. SessionStorage.remove('axios_check')
  784. LocalStorage.set('login_name', '')
  785. LocalStorage.set('login_id', '')
  786. LocalStorage.set('appid', '')
  787. _this.$q.notify({
  788. message: 'Success Logout',
  789. icon: 'check',
  790. color: 'negative'
  791. })
  792. // _this.staffType();
  793. localStorage.removeItem('menulink')
  794. _this.link = ''
  795. _this.$router.push({ name: 'web_index' })
  796. window.setTimeout(() => {
  797. location.reload()
  798. }, 1)
  799. },
  800. Register () {
  801. var _this = this
  802. SessionStorage.set('axios_check', 'false')
  803. post('register/', _this.registerform)
  804. .then((res) => {
  805. if (res.code === '200') {
  806. _this.register = false
  807. _this.openid = res.data.openid
  808. _this.login_name = _this.registerform.name
  809. _this.login_id = res.data.user_id
  810. _this.authin = '1'
  811. LocalStorage.set('auth', '1')
  812. LocalStorage.set('appid', res.data.appid)
  813. LocalStorage.set('login_name', res.data.name)
  814. LocalStorage.set('login_id', res.data.user_id)
  815. LocalStorage.set('openid', res.data.openid)
  816. LocalStorage.set('login_mode', 'Admin')
  817. _this.registerform = {
  818. name: '',
  819. password1: '',
  820. password2: ''
  821. }
  822. _this.$q.notify({
  823. message: res.msg,
  824. icon: 'check',
  825. color: 'green'
  826. })
  827. _this.staffType()
  828. localStorage.removeItem('menulink')
  829. _this.link = ''
  830. _this.$router.push({ name: 'web_index' })
  831. window.setTimeout(() => {
  832. location.reload()
  833. }, 1)
  834. } else {
  835. _this.$q.notify({
  836. message: res.msg,
  837. icon: 'close',
  838. color: 'negative'
  839. })
  840. }
  841. })
  842. .catch((err) => {
  843. _this.$q.notify({
  844. message: err.detail,
  845. icon: 'close',
  846. color: 'negative'
  847. })
  848. })
  849. },
  850. staffType () {
  851. var _this = this
  852. getauth('staff/?staff_name=' + _this.login_name).then((res) => {
  853. LocalStorage.set('staff_type', res.results[0].staff_type)
  854. })
  855. },
  856. warehouseOptionsGet () {
  857. var _this = this
  858. get('warehouse/multiple/?max_page=30')
  859. .then((res) => {
  860. // if (res.count === 1) {
  861. // _this.openid = res.results[0].openid
  862. // _this.warehouse_name = res.results[0].warehouse_name
  863. // LocalStorage.set('openid', _this.openid)
  864. // } else {
  865. _this.warehouseOptions = res.results
  866. if (LocalStorage.has('openid')) {
  867. _this.warehouseOptions.forEach((item, index) => {
  868. if (item.openid === LocalStorage.getItem('openid')) {
  869. _this.warehouseOptions_openid.push(item)
  870. }
  871. })
  872. }
  873. _this.warehouse_name = res.results[0].warehouse_name
  874. localStorage.setItem('warehouse_name', res.results[0].warehouse_name)
  875. localStorage.setItem('warehouse_code', res.results[0].warehouse_code)
  876. // }
  877. })
  878. .catch((err) => {
  879. console.log(err)
  880. _this.$q.notify({
  881. message: err.detail,
  882. icon: 'close',
  883. color: 'negative'
  884. })
  885. })
  886. },
  887. warehouseChange (e) {
  888. var _this = this
  889. _this.openid = _this.warehouseOptions[e].openid
  890. if (_this.openid === LocalStorage.getItem('openid')) {
  891. _this.warehouse_name = _this.warehouseOptions[e].warehouse_name
  892. localStorage.setItem(
  893. 'warehouse_name',
  894. _this.warehouseOptions[e].warehouse_name
  895. )
  896. localStorage.setItem(
  897. 'warehouse_code',
  898. _this.warehouseOptions[e].warehouse_code
  899. )
  900. _this.switch_state = true
  901. } else {
  902. _this.switch_state = false
  903. }
  904. _this.switch_warehouse = true
  905. // LocalStorage.set('openid', _this.openid)
  906. // LocalStorage.set('staff_type', 'Admin')
  907. // _this.login_name = ''
  908. // LocalStorage.set('login_name', '')
  909. // _this.authin = '0'
  910. // _this.isLoggedIn()
  911. // LocalStorage.remove('auth')
  912. // SessionStorage.remove('axios_check')
  913. },
  914. // langChange(e) {
  915. // var _this = this
  916. // _this.lang = e
  917. // window.setTimeout(() => {
  918. // location.reload()
  919. // }, 1)
  920. // },
  921. isLoggedIn () {
  922. if (this.$q.localStorage.getItem('openid')) {
  923. this.login = true
  924. } else {
  925. this.register = true
  926. }
  927. },
  928. handleTimer () {
  929. getauth('/wms/inboundBills/?bound_status=0').then((res) => {
  930. this.ERPTasks = res.count
  931. })
  932. getauth('/wms/outboundBills/?bound_status=0').then((res) => {
  933. this.ERPOutTasks = res.count
  934. })
  935. }
  936. },
  937. created () {
  938. var _this = this
  939. _this.$i18n.locale = 'zh-hans'
  940. if (LocalStorage.has('openid')) {
  941. _this.openid = LocalStorage.getItem('openid')
  942. _this.activeTab = 'admin'
  943. } else {
  944. _this.openid = ''
  945. LocalStorage.set('openid', '')
  946. }
  947. if (LocalStorage.has('login_name')) {
  948. _this.login_name = LocalStorage.getItem('login_name')
  949. } else {
  950. _this.login_name = ''
  951. LocalStorage.set('login_name', '')
  952. }
  953. if (LocalStorage.has('auth')) {
  954. _this.authin = '1'
  955. _this.staffType()
  956. } else {
  957. LocalStorage.set('staff_type', 'Admin')
  958. _this.authin = '0'
  959. _this.isLoggedIn()
  960. }
  961. },
  962. mounted () {
  963. var _this = this
  964. _this.warehouseOptionsGet()
  965. _this.handleTimer()
  966. _this.link = localStorage.getItem('menulink')
  967. Bus.$on('needLogin', (val) => {
  968. _this.isLoggedIn()
  969. })
  970. _this.timer = setInterval(() => {
  971. _this.handleTimer();
  972. }, 100000);
  973. },
  974. // 修改时间 :10000
  975. updated () {},
  976. beforeDestroy () {
  977. Bus.$off('needLogin')
  978. },
  979. destroyed () {},
  980. watch: {
  981. login (val) {
  982. if (val) {
  983. if (this.activeTab === 'admin') {
  984. this.admin = true
  985. } else {
  986. this.admin = false
  987. }
  988. }
  989. }
  990. }
  991. }
  992. </script>
  993. <style>
  994. .tabs .q-tab__indicator {
  995. width: 25%;
  996. height: 1.5px;
  997. margin: auto;
  998. color: #d6d7d7;
  999. }
  1000. .tabs .absolute-bottom {
  1001. bottom: 8px;
  1002. }
  1003. /* 基础定位 */
  1004. .menu-item-with-badge {
  1005. position: relative;
  1006. }
  1007. .task-badge {
  1008. /* 定位 */
  1009. position: absolute;
  1010. top: 12px;
  1011. right: 12px;
  1012. transform: translate(50%, -50%);
  1013. /* 样式 */
  1014. min-width: 20px;
  1015. height: 20px;
  1016. font-size: 0.75rem;
  1017. font-weight: 700;
  1018. border-radius: 2px;
  1019. padding: 2px 6px;
  1020. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  1021. /* 动画 */
  1022. transition: all 0.3s ease;
  1023. animation: pulse 2s infinite;
  1024. }
  1025. /* 高优先级样式 */
  1026. .task-badge.high-priority {
  1027. color: white !important;
  1028. background: linear-gradient(145deg, #ff5252, #ff1744);
  1029. }
  1030. .outtask-badge {
  1031. /* 定位 */
  1032. position: absolute;
  1033. bottom: -9px;
  1034. right: 12px;
  1035. transform: translate(50%, -50%);
  1036. /* 样式 */
  1037. min-width: 20px;
  1038. height: 20px;
  1039. font-size: 0.75rem;
  1040. font-weight: 700;
  1041. border-radius: 2px;
  1042. padding: 2px 6px;
  1043. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  1044. /* 动画 */
  1045. transition: all 0.3s ease;
  1046. animation: pulse 2s infinite;
  1047. }
  1048. /* 高优先级样式 */
  1049. .outtask-badge.high-priority {
  1050. color: white !important;
  1051. background: linear-gradient(145deg, #982323, #ff1744);
  1052. }
  1053. </style>