MainLayout.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. <template>
  2. <q-layout view="hHh LpR fFf" :style="{ height: $q.screen.height, width: $q.screen.width }">
  3. <q-header reveal elevated class="bg-primary text-white">
  4. <q-toolbar class="main-headers text-white shadow-18 rounded-borders">
  5. <transition appear enter-active-class="animated zoomIn">
  6. <q-btn flat @click="drawerleft = !drawerleft" round dense icon="menu">
  7. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[15, 15]"
  8. content-style="font-size: 12px">{{ drawerleft ? $t("index.hide_menu") : $t("index.open_menu")
  9. }}</q-tooltip>
  10. </q-btn>
  11. </transition>
  12. <transition appear enter-active-class="animated zoomIn">
  13. <q-toolbar-title shrink class="text-weight-bold" @click="$router.push({ name: 'web_index' }); linkChange('')">
  14. {{ $t("index.title") }}</q-toolbar-title>
  15. </transition>
  16. <q-space />
  17. <transition appear enter-active-class="animated zoomIn">
  18. <q-btn square dense flat color="white" :label="warehouse_name" icon="maps_home_work"
  19. style="margin: 0 10px 0 10px">
  20. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[15, 15]" content-style="font-size: 12px">
  21. {{ $t("index.warehouse_switch") }}
  22. </q-tooltip>
  23. <q-menu>
  24. <q-list style="min-width: 100px">
  25. <q-item clickable v-close-popup v-for="(warehouse, index) in warehouseOptions" :key="index"
  26. @click="warehouseChange(index)">
  27. <q-item-section>{{ warehouse.warehouse_name }}</q-item-section>
  28. </q-item>
  29. </q-list>
  30. </q-menu>
  31. </q-btn>
  32. </transition>
  33. <q-separator vertical />
  34. <template v-if="authin === '1'">
  35. <transition appear enter-active-class="animated zoomIn">
  36. <q-btn-dropdown stretch flat color="white-8" icon="account_circle">
  37. <div class="q-pa-md">
  38. <div class="column items-center">
  39. <q-avatar size="72px"><q-img src="statics/staff/stafftype.png"></q-img></q-avatar>
  40. <div class="text-subtitle1 q-mt-md q-mb-xs">
  41. {{ login_name }}
  42. </div>
  43. <q-btn color="primary" :label="$t('index.change_user')" push size="sm" v-close-popup icon="face"
  44. @click="login = true">
  45. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[10, 10]"
  46. content-style="font-size: 12px">{{ $t("index.change_user") }}</q-tooltip>
  47. </q-btn>
  48. <q-separator />
  49. <q-btn color="primary" :label="$t('index.logout')" push size="sm" v-close-popup
  50. icon="img:statics/icons/logout.png" @click="Logout()">
  51. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[10, 10]"
  52. content-style="font-size: 12px">{{ $t("index.logout") }}</q-tooltip>
  53. </q-btn>
  54. </div>
  55. </div>
  56. </q-btn-dropdown>
  57. </transition>
  58. </template>
  59. <template v-if="authin === '0'">
  60. <transition appear enter-active-class="animated zoomIn">
  61. <q-btn :label="$t('index.login')" color="primary" @click="login = true" style="margin-left: 10px">
  62. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[15, 15]"
  63. content-style="font-size: 12px">{{ $t("index.login_tip") }}</q-tooltip>
  64. </q-btn>
  65. </transition>
  66. <transition appear enter-active-class="animated zoomIn">
  67. <q-btn :label="$t('index.register')" color="primary" @click="register = true" style="margin-left: 10px">
  68. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[15, 15]"
  69. content-style="font-size: 12px">{{ $t("index.register_tip") }}</q-tooltip>
  70. </q-btn>
  71. </transition>
  72. </template>
  73. </q-toolbar>
  74. </q-header>
  75. <q-drawer v-model="drawerleft" show-if-above :width="200" :breakpoint="500" bordered
  76. content-class="bg-grey-3 shadow-24">
  77. <q-scroll-area class="fit" style="overflow-y: auto">
  78. <q-list>
  79. <q-item clickable :to="{ name: 'management' }" @click="linkChange('stock')" v-ripple exact
  80. :active="link === 'stock' && link !== ''" :class="{ 'my-menu-link': link === 'stock' && link !== '' }">
  81. <q-item-section avatar><q-icon name="multiline_chart" /></q-item-section>
  82. <q-item-section>{{ $t("menuItem.stock") }}</q-item-section>
  83. </q-item>
  84. <q-separator />
  85. <q-item clickable :to="{ name: 'erpasn' }" @click="linkChange('erp')" v-ripple exact
  86. :active="link === 'erp' && link !== ''" :class="{
  87. 'my-menu-link': link === 'erp' && link !== '',
  88. }">
  89. <q-item-section avatar><q-icon name="img:statics/outbound/outbound.png" /></q-item-section>
  90. <q-item-section>{{ "ERP任务" }}</q-item-section>
  91. <q-badge
  92. v-if="ERPTasks > 0"
  93. color="red-5"
  94. class="task-badge"
  95. :class="{ 'high-priority': ERPTasks > 20 }"
  96. >
  97. {{ ERPTasks > 99 ? '99+' : ERPTasks }}
  98. </q-badge>
  99. </q-item>
  100. <q-item clickable :to="{ name: 'inboundAndOutbound' }" @click="linkChange('outbounddashboard')" v-ripple exact
  101. :active="link === 'outbounddashboard' && link !== ''" :class="{
  102. 'my-menu-link': link === 'outbounddashboard' && link !== '',
  103. }">
  104. <q-item-section avatar><q-icon name="auto_graph" /></q-item-section>
  105. <q-item-section>{{ $t("menuItem.dashboard") }}</q-item-section>
  106. </q-item>
  107. <q-separator />
  108. <q-item clickable :to="{ name: 'asn' }" @click="linkChange('inbound')" v-ripple exact
  109. :active="link === 'inbound' && link !== ''" :class="{ 'my-menu-link': link === 'inbound' && link !== '' }">
  110. <q-item-section avatar><q-icon name="speaker_notes" /></q-item-section>
  111. <q-item-section>{{ $t("menuItem.inbound") }}</q-item-section>
  112. </q-item>
  113. <q-item clickable :to="{ name: 'containerlist' }" @click="linkChange('container')" v-ripple exact
  114. :active="link === 'container' && link !== ''" :class="{
  115. 'my-menu-link': link === 'container' && link !== '',
  116. }">
  117. <q-item-section avatar><q-icon name="stay_current_landscape" /></q-item-section>
  118. <q-item-section>托盘管理</q-item-section>
  119. </q-item>
  120. <q-item clickable :to="{ name: 'dn' }" @click="linkChange('outbound')" v-ripple exact
  121. :active="link === 'outbound' && link !== ''"
  122. :class="{ 'my-menu-link': link === 'outbound' && link !== '' }">
  123. <q-item-section avatar>
  124. <q-icon name="rv_hookup">
  125. </q-icon>
  126. </q-item-section>
  127. <q-item-section>{{ $t("menuItem.outbound") }}</q-item-section>
  128. <q-badge
  129. v-if="pendingTasks > 0"
  130. color="red-5"
  131. class="task-badge"
  132. :class="{ 'high-priority': pendingTasks > 20 }"
  133. >
  134. {{ pendingTasks > 99 ? '99+' : pendingTasks }}
  135. </q-badge>
  136. </q-item>
  137. <q-separator />
  138. <q-item clickable :to="{ name: 'task' }" @click="linkChange('taskpage')" v-ripple exact
  139. :active="link === 'taskpage' && link !== ''" :class="{
  140. 'my-menu-link': link === 'taskpage' && link !== '',
  141. }">
  142. <q-item-section avatar><q-icon name="img:statics/outbound/picked.png" /></q-item-section>
  143. <q-item-section>任务管理</q-item-section>
  144. </q-item>
  145. <q-item clickable :to="{ name: 'warehouseset' }" @click="linkChange('warehouse')" v-ripple exact
  146. :active="link === 'warehouse' && link !== ''"
  147. :class="{ 'my-menu-link': link === 'warehouse' && link !== '' }">
  148. <q-item-section avatar><q-icon name="settings" /></q-item-section>
  149. <q-item-section>{{ $t("menuItem.warehouse") }}</q-item-section>
  150. </q-item>
  151. <q-item clickable :to="{ name: 'stafflist' }" @click="linkChange('staff')" v-ripple exact
  152. :active="link === 'staff' && link !== ''" :class="{ 'my-menu-link': link === 'staff' && link !== '' }">
  153. <q-item-section avatar><q-icon name="assignment_ind" /></q-item-section>
  154. <q-item-section>{{ $t("menuItem.staff") }}</q-item-section>
  155. </q-item>
  156. <q-separator />
  157. <q-item clickable :to="{ name: 'initializeupload' }" @click="linkChange('uploadcenter')" v-ripple exact
  158. :active="link === 'uploadcenter' && link !== ''"
  159. :class="{ 'my-menu-link': link === 'uploadcenter' && link !== '' }">
  160. <q-item-section avatar><q-icon name="file_upload" /></q-item-section>
  161. <q-item-section>{{ $t("menuItem.uploadcenter") }}</q-item-section>
  162. </q-item>
  163. <q-item clickable :to="{ name: 'downloadinbound' }" @click="linkChange('downloadcenter')" v-ripple exact
  164. :active="link === 'downloadcenter' && link !== ''" :class="{
  165. 'my-menu-link': link === 'downloadcenter' && link !== '',
  166. }">
  167. <q-item-section avatar><q-icon name="file_download" /></q-item-section>
  168. <q-item-section>{{ $t("menuItem.downloadcenter") }}</q-item-section>
  169. </q-item>
  170. <q-separator />
  171. </q-list>
  172. </q-scroll-area>
  173. </q-drawer>
  174. <q-page-container class="main-page" :style="{
  175. height: container_height,
  176. width: $q.screen.width,
  177. }">
  178. <router-view />
  179. </q-page-container>
  180. <q-dialog v-model="authid" transition-show="jump-down" transition-hide="jump-up">
  181. <q-card style="min-width: 350px">
  182. <q-bar class="bg-light-blue-10 text-white rounded-borders" style="height: 50px">
  183. <div>{{ $t("index.your_openid") }}</div>
  184. <q-space></q-space>
  185. <q-btn dense flat icon="close" v-close-popup>
  186. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[20, 20]"
  187. content-style="font-size: 12px">{{
  188. $t("index.close") }}</q-tooltip>
  189. </q-btn>
  190. </q-bar>
  191. <q-card-section class="q-pt-md"><q-input dense outlined square label="Openid" v-model="openid" readonly
  192. disable /></q-card-section>
  193. </q-card>
  194. </q-dialog>
  195. <q-dialog v-model="login" transition-show="" transition-hide="" persistent full-width full-height>
  196. <div class="flex flex-center"
  197. style="height: 100%; background-color: #f5f5f5; position: absolute; top: 0; left: 0; right: 0; bottom: 0;">
  198. <div style="font-size: 55px;letter-spacing: 10px;width: 100%; text-align: center; margin-top: 10px">
  199. {{ $t("index.developer") }}
  200. </div>
  201. <q-card style="min-width: 350px">
  202. <q-bar class="bg-light-blue-10 text-white rounded-borders" style="height: 50px">
  203. <q-tabs v-model="activeTab" class="tabs">
  204. <q-tab name="admin" @click="admin = true">
  205. {{ $t("index.user_login") }}
  206. <q-tooltip content-class="bg-amber text-black shadow-4" :offset="[5, 5]"
  207. content-style="font-size: 12px">{{
  208. $t("index.user_login") }}</q-tooltip>
  209. </q-tab>
  210. </q-tabs>
  211. <q-space />
  212. </q-bar>
  213. <q-card-section class="q-pt-md">
  214. <template v-if="admin">
  215. <q-input dense outlined square :label="$t('index.staff_name')" v-model="adminlogin.name" autofocus
  216. @keyup.enter="adminLogin()" />
  217. <q-input dense outlined square :label="$t('index.password')" :type="isPwd ? 'password' : 'text'"
  218. v-model="adminlogin.password" @keyup.enter="adminLogin()" style="margin-top: 5px">
  219. <template v-slot:append>
  220. <q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
  221. @click="isPwd = !isPwd" />
  222. </template>
  223. </q-input>
  224. </template>
  225. </q-card-section>
  226. <q-card-actions align="left" class="text-primary">
  227. <q-space />
  228. <template>
  229. <q-btn color="primary" :label="$t('index.login')" style="font-size: 16px; margin: 0 8px; width: 100%"
  230. @click="adminLogin()" />
  231. </template>
  232. <div class="q-mx-auto">
  233. <q-btn flat class="text-teal-4 q-mt-sm" @click="
  234. login = false;
  235. register = true;
  236. ">
  237. {{ $t("index.register_tip") }}
  238. </q-btn>
  239. </div>
  240. </q-card-actions>
  241. </q-card>
  242. <lottie-web-cimo ref="lottie_web" animationName="welcome"
  243. style="width: 85%; max-width: 95%;height: 12%; margin :auto;" />
  244. </div>
  245. </q-dialog>
  246. <q-dialog v-model="register" transition-show="" transition-hide="" persistent full-width full-height>
  247. <div class="flex flex-center"
  248. style="height: 100%; background-color: #f5f5f5; position: absolute; top: 0; left: 0; right: 0; bottom: 0;">
  249. <div style="font-size: 55px;letter-spacing: 10px;width: 100%; text-align: center; margin-top: 10px">
  250. {{ $t("index.developer") }}
  251. </div>
  252. <q-card style="min-width: 350px">
  253. <q-bar class="bg-light-blue-10 text-white rounded-borders" style="height: 50px">
  254. <div>{{ $t("index.register_tip") }}</div>
  255. </q-bar>
  256. <q-card-section class="q-pt-md">
  257. <q-input dense outlined square :label="$t('index.staff_name')" v-model="registerform.name"
  258. @keyup.enter="Register()" />
  259. <q-input dense outlined square :label="$t('index.password')" v-model="registerform.password1"
  260. :type="isPwd ? 'password' : 'text'" @keyup.enter="Register()" style="margin-top: 5px">
  261. <template v-slot:append>
  262. <q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
  263. @click="isPwd = !isPwd" />
  264. </template>
  265. </q-input>
  266. <q-input dense outlined square :label="$t('index.confirm_password')" v-model="registerform.password2"
  267. :type="isPwd2 ? 'password' : 'text'" @keyup.enter="Register()" style="margin-top: 5px">
  268. <template v-slot:append>
  269. <q-icon :name="isPwd2 ? 'visibility_off' : 'visibility'" class="cursor-pointer"
  270. @click="isPwd2 = !isPwd2" />
  271. </template>
  272. </q-input>
  273. </q-card-section>
  274. <q-card-actions align="right" class="text-primary q-mx-sm"><q-btn class="full-width" color="primary"
  275. :label="$t('index.register')" @click="Register()" /></q-card-actions>
  276. <q-card-actions align="center" style="margin-top: -8px">
  277. <q-btn class="text-teal-4" flat :label="$t('index.return_to_login')" @click="
  278. login = true;
  279. register = false;
  280. "></q-btn>
  281. </q-card-actions>
  282. </q-card>
  283. <lottie-web-cimo ref="lottie_web" animationName="welcome"
  284. style="width: 85%; max-width: 95%;height: 12%; margin :auto;" />
  285. </div>
  286. </q-dialog>
  287. <q-dialog v-model="switch_warehouse">
  288. <q-card class="shadow-24">
  289. <q-bar class="bg-light-blue-10 text-white rounded-borders" style="height: 50px">
  290. <div>{{ $t("index.warehouse_switch") }}</div>
  291. <q-space />
  292. </q-bar>
  293. <q-card-section style="max-height: 325px; width: 400px" class="scroll">
  294. {{ switch_state ? $t("index.switch_state_on") : $t("index.switch_state_off") }}
  295. </q-card-section>
  296. </q-card>
  297. </q-dialog>
  298. </q-layout>
  299. </template>
  300. <script>
  301. import { get, getauth, post, baseurl } from 'boot/axios_request'
  302. import { LocalStorage, SessionStorage, openURL } from 'quasar'
  303. import Bus from 'boot/bus.js'
  304. import LottieWebCimo from 'components/lottie-web-cimo'
  305. export default {
  306. components: { LottieWebCimo },
  307. data() {
  308. return {
  309. device: LocalStorage.getItem('device'),
  310. device_name: LocalStorage.getItem('device_name'),
  311. lang: 'zh-hans',
  312. container_height: this.$q.screen.height + '' + 'px',
  313. warehouse_name: '',
  314. warehouseOptions: [],
  315. warehouseOptions_openid: [],
  316. langOptions: [
  317. // { value: 'en-US', label: 'English' },
  318. { value: 'zh-hans', label: '中文简体' },
  319. // { value: 'zh-hant', label: '中文繁體' }
  320. // { value: 'fr', label: 'Français' },
  321. // { value: 'pt', label: 'Português' },
  322. // { value: 'sp', label: 'Español' },
  323. // { value: 'de', label: 'Deutsch' },
  324. // { value: 'ru', label: 'русский язык' },
  325. // { value: 'ar', label: 'Arabic' },
  326. // { value: 'it', label: 'Italiano' },
  327. // { value: 'ja', label: '日本語' }
  328. ],
  329. title: this.$t('index.webtitle'),
  330. admin: true,
  331. adminlogin: {
  332. name: '',
  333. password: ''
  334. },
  335. openid: '',
  336. appid: '',
  337. switch_state: false,
  338. switch_warehouse: false,
  339. isPwd: true,
  340. isPwd2: true,
  341. authin: '0',
  342. authid: false,
  343. left: false,
  344. drawerleft: false,
  345. tab: '',
  346. login: false,
  347. link: '',
  348. login_name: '',
  349. login_id: 0,
  350. check_code: '',
  351. register: false,
  352. registerform: {
  353. name: '',
  354. password1: '',
  355. password2: ''
  356. },
  357. needLogin: '',
  358. activeTab: '',
  359. ERPTasks:0,
  360. pendingTasks: 0,
  361. pollInterval: null,
  362. timer : null,
  363. }
  364. },
  365. methods: {
  366. linkChange(e) {
  367. var _this = this
  368. localStorage.removeItem('menulink')
  369. localStorage.setItem('menulink', e)
  370. _this.link = e
  371. console.log(_this.link)
  372. },
  373. drawerClick(e) {
  374. var _this = this
  375. if (_this.miniState) {
  376. _this.miniState = false
  377. e.stopPropagation()
  378. }
  379. },
  380. brownlink(e) {
  381. openURL(e)
  382. },
  383. apiLink() {
  384. openURL(baseurl + '/api/docs/')
  385. },
  386. adminLogin() {
  387. var _this = this
  388. if (!_this.adminlogin.name) {
  389. _this.$q.notify({
  390. message: '请输入用户名',
  391. color: 'negative',
  392. icon: 'close'
  393. })
  394. } else {
  395. if (!_this.adminlogin.password) {
  396. _this.$q.notify({
  397. message: '请输入密码',
  398. icon: 'close',
  399. color: 'negative'
  400. })
  401. } else {
  402. SessionStorage.set('axios_check', 'false')
  403. post('login/', _this.adminlogin)
  404. .then((res) => {
  405. if (res.code === '200') {
  406. _this.authin = '1'
  407. _this.login = false
  408. _this.admin = false
  409. _this.openid = res.data.openid
  410. _this.appid = res.data.appid
  411. _this.login_name = res.data.name
  412. _this.login_id = res.data.user_id
  413. LocalStorage.set('auth', '1')
  414. LocalStorage.set('openid', res.data.openid)
  415. LocalStorage.set('appid', res.data.appid)
  416. LocalStorage.set('login_name', _this.login_name)
  417. LocalStorage.set('login_id', _this.login_id)
  418. LocalStorage.set('login_mode', res.data.staff_type)
  419. _this.$q.notify({
  420. message: 'Success Login',
  421. icon: 'check',
  422. color: 'green'
  423. })
  424. localStorage.removeItem('menulink')
  425. _this.link = ''
  426. _this.$router.push({ name: 'web_index' })
  427. window.setTimeout(() => {
  428. location.reload()
  429. }, 1)
  430. } else {
  431. _this.$q.notify({
  432. message: res.msg,
  433. icon: 'close',
  434. color: 'negative'
  435. })
  436. }
  437. })
  438. .catch((err) => {
  439. _this.$q.notify({
  440. message: err.detail,
  441. icon: 'close',
  442. color: 'negative'
  443. })
  444. })
  445. }
  446. }
  447. },
  448. Logout() {
  449. var _this = this
  450. _this.authin = '0'
  451. _this.login_name = ''
  452. LocalStorage.remove('auth')
  453. SessionStorage.remove('axios_check')
  454. LocalStorage.set('login_name', '')
  455. LocalStorage.set('login_id', '')
  456. LocalStorage.set('appid', '')
  457. _this.$q.notify({
  458. message: 'Success Logout',
  459. icon: 'check',
  460. color: 'negative'
  461. })
  462. // _this.staffType();
  463. localStorage.removeItem('menulink')
  464. _this.link = ''
  465. _this.$router.push({ name: 'web_index' })
  466. window.setTimeout(() => {
  467. location.reload()
  468. }, 1)
  469. },
  470. Register() {
  471. var _this = this
  472. SessionStorage.set('axios_check', 'false')
  473. post('register/', _this.registerform)
  474. .then((res) => {
  475. if (res.code === '200') {
  476. _this.register = false
  477. _this.openid = res.data.openid
  478. _this.login_name = _this.registerform.name
  479. _this.login_id = res.data.user_id
  480. _this.authin = '1'
  481. LocalStorage.set('auth', '1')
  482. LocalStorage.set('appid', res.data.appid)
  483. LocalStorage.set('login_name', res.data.name)
  484. LocalStorage.set('login_id', res.data.user_id)
  485. LocalStorage.set('openid', res.data.openid)
  486. LocalStorage.set('login_mode', 'Admin')
  487. _this.registerform = {
  488. name: '',
  489. password1: '',
  490. password2: ''
  491. }
  492. _this.$q.notify({
  493. message: res.msg,
  494. icon: 'check',
  495. color: 'green'
  496. })
  497. _this.staffType()
  498. localStorage.removeItem('menulink')
  499. _this.link = ''
  500. _this.$router.push({ name: 'web_index' })
  501. window.setTimeout(() => {
  502. location.reload()
  503. }, 1)
  504. } else {
  505. _this.$q.notify({
  506. message: res.msg,
  507. icon: 'close',
  508. color: 'negative'
  509. })
  510. }
  511. })
  512. .catch((err) => {
  513. _this.$q.notify({
  514. message: err.detail,
  515. icon: 'close',
  516. color: 'negative'
  517. })
  518. })
  519. },
  520. staffType() {
  521. var _this = this
  522. getauth('staff/?staff_name=' + _this.login_name).then((res) => {
  523. LocalStorage.set('staff_type', res.results[0].staff_type)
  524. })
  525. },
  526. warehouseOptionsGet() {
  527. var _this = this
  528. get('warehouse/multiple/?max_page=30')
  529. .then((res) => {
  530. // if (res.count === 1) {
  531. // _this.openid = res.results[0].openid
  532. // _this.warehouse_name = res.results[0].warehouse_name
  533. // LocalStorage.set('openid', _this.openid)
  534. // } else {
  535. _this.warehouseOptions = res.results
  536. if (LocalStorage.has('openid')) {
  537. _this.warehouseOptions.forEach((item, index) => {
  538. if (item.openid === LocalStorage.getItem('openid')) {
  539. _this.warehouseOptions_openid.push(item)
  540. }
  541. })
  542. }
  543. _this.warehouse_name = res.results[0].warehouse_name
  544. localStorage.setItem('warehouse_name', res.results[0].warehouse_name)
  545. localStorage.setItem('warehouse_code', res.results[0].warehouse_code)
  546. // }
  547. })
  548. .catch((err) => {
  549. console.log(err)
  550. _this.$q.notify({
  551. message: err.detail,
  552. icon: 'close',
  553. color: 'negative'
  554. })
  555. })
  556. },
  557. warehouseChange(e) {
  558. var _this = this
  559. _this.openid = _this.warehouseOptions[e].openid
  560. if (_this.openid === LocalStorage.getItem('openid')) {
  561. _this.warehouse_name = _this.warehouseOptions[e].warehouse_name
  562. localStorage.setItem('warehouse_name', _this.warehouseOptions[e].warehouse_name)
  563. localStorage.setItem('warehouse_code', _this.warehouseOptions[e].warehouse_code)
  564. _this.switch_state = true
  565. }
  566. else {
  567. _this.switch_state = false
  568. }
  569. _this.switch_warehouse = true
  570. // LocalStorage.set('openid', _this.openid)
  571. // LocalStorage.set('staff_type', 'Admin')
  572. // _this.login_name = ''
  573. // LocalStorage.set('login_name', '')
  574. // _this.authin = '0'
  575. // _this.isLoggedIn()
  576. // LocalStorage.remove('auth')
  577. // SessionStorage.remove('axios_check')
  578. },
  579. // langChange(e) {
  580. // var _this = this
  581. // _this.lang = e
  582. // window.setTimeout(() => {
  583. // location.reload()
  584. // }, 1)
  585. // },
  586. isLoggedIn() {
  587. if (this.$q.localStorage.getItem('openid')) {
  588. this.login = true
  589. } else {
  590. this.register = true
  591. }
  592. },
  593. handleTimer() {
  594. getauth('/wms/inboundBills/?bound_status=0').then((res) => {
  595. this.ERPTasks = res.count
  596. this.pendingTasks = res.pending_count
  597. })}
  598. },
  599. created() {
  600. var _this = this
  601. _this.$i18n.locale = 'zh-hans'
  602. if (LocalStorage.has('openid')) {
  603. _this.openid = LocalStorage.getItem('openid')
  604. _this.activeTab = 'admin'
  605. } else {
  606. _this.openid = ''
  607. LocalStorage.set('openid', '')
  608. }
  609. if (LocalStorage.has('login_name')) {
  610. _this.login_name = LocalStorage.getItem('login_name')
  611. } else {
  612. _this.login_name = ''
  613. LocalStorage.set('login_name', '')
  614. }
  615. if (LocalStorage.has('auth')) {
  616. _this.authin = '1'
  617. _this.staffType()
  618. } else {
  619. LocalStorage.set('staff_type', 'Admin')
  620. _this.authin = '0'
  621. _this.isLoggedIn()
  622. }
  623. },
  624. mounted() {
  625. var _this = this
  626. _this.warehouseOptionsGet()
  627. _this.handleTimer()
  628. _this.link = localStorage.getItem('menulink')
  629. Bus.$on('needLogin', (val) => {
  630. _this.isLoggedIn()
  631. })
  632. _this.timer = setInterval(() => {
  633. _this.handleTimer()
  634. }, 10000)
  635. },
  636. updated() {
  637. },
  638. beforeDestroy() {
  639. Bus.$off('needLogin')
  640. },
  641. destroyed() {
  642. },
  643. watch: {
  644. login(val) {
  645. if (val) {
  646. if (this.activeTab === 'admin') {
  647. this.admin = true
  648. } else {
  649. this.admin = false
  650. }
  651. }
  652. }
  653. }
  654. }
  655. </script>
  656. <style>
  657. .tabs .q-tab__indicator {
  658. width: 25%;
  659. height: 1.5px;
  660. margin: auto;
  661. color: #d6d7d7;
  662. }
  663. .tabs .absolute-bottom {
  664. bottom: 8px;
  665. }
  666. /* 基础定位 */
  667. .menu-item-with-badge {
  668. position: relative;
  669. }
  670. .task-badge {
  671. /* 定位 */
  672. position: absolute;
  673. top: 12px;
  674. right: 12px;
  675. transform: translate(50%, -50%);
  676. /* 样式 */
  677. min-width: 20px;
  678. height: 20px;
  679. font-size: 0.75rem;
  680. font-weight: 700;
  681. border-radius: 2px;
  682. padding: 2px 6px;
  683. box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  684. /* 动画 */
  685. transition: all 0.3s ease;
  686. animation: pulse 2s infinite;
  687. }
  688. /* 高优先级样式 */
  689. .task-badge.high-priority {
  690. color: white !important;
  691. background: linear-gradient(145deg, #ff5252, #ff1744);
  692. }
  693. </style>