Browse Source

fix: js改成ts 权限

master
zhang_li 7 months ago
parent
commit
0d609fac13
  1. 2
      .env.development
  2. 2
      src/App.vue
  3. 0
      src/api/inLocation.ts
  4. 0
      src/api/location.ts
  5. 0
      src/api/login.ts
  6. 0
      src/api/outLocation.ts
  7. 0
      src/api/spareParts.ts
  8. 0
      src/api/sparePartsReturn.ts
  9. 0
      src/api/upload.ts
  10. 0
      src/api/user.ts
  11. 2
      src/main.ts
  12. 6
      src/pages/inLocation/addForm.vue
  13. 5
      src/pages/inLocation/index.vue
  14. 4
      src/pages/outLocation/addForm.vue
  15. 4
      src/pages/outLocation/index.vue
  16. 2
      src/pages/scanCode/scanCode.vue
  17. 8
      src/pages/sparePartsReturn/addForm.vue
  18. 10
      src/plugins/auth.js
  19. 5
      src/store/modules/countStore.ts

2
.env.development

@ -1,4 +1,4 @@
VITE_BASE_URL=http://192.168.0.106:12080/admin-api VITE_BASE_URL=http://localhost:12080/admin-api
#VITE_BASE_URL=http://dev.ccwin-in.com:25203/api/admin-api #VITE_BASE_URL=http://dev.ccwin-in.com:25203/api/admin-api
VITE_BASE_URL_IMAGE=http://192.168.0.106:12080/admin-api VITE_BASE_URL_IMAGE=http://192.168.0.106:12080/admin-api

2
src/App.vue

@ -81,6 +81,8 @@
// }); // });
if (getAccessToken()) { if (getAccessToken()) {
await store.GetPermissionInfo().then(res => { await store.GetPermissionInfo().then(res => {
uni.setStorageSync('permissionInfo',res.permissions)
uni.setStorageSync('roles',res.roles)
}).catch(() => { }) }).catch(() => { })
await store.GetInfo().then(res => { await store.GetInfo().then(res => {
}).catch(() => { }) }).catch(() => { })

0
src/api/inLocation.js → src/api/inLocation.ts

0
src/api/location.js → src/api/location.ts

0
src/api/login.js → src/api/login.ts

0
src/api/outLocation.js → src/api/outLocation.ts

0
src/api/spareParts.js → src/api/spareParts.ts

0
src/api/sparePartsReturn.js → src/api/sparePartsReturn.ts

0
src/api/upload.js → src/api/upload.ts

0
src/api/user.js → src/api/user.ts

2
src/main.ts

@ -9,6 +9,7 @@ import App from './App.vue'
import tab from './plugins/tab' import tab from './plugins/tab'
import modal from './plugins/modal' import modal from './plugins/modal'
import time from './plugins/time' import time from './plugins/time'
import auth from './plugins/auth'
// unocss // unocss
@ -30,6 +31,7 @@ export function createApp() {
app.config.globalProperties.$modal = modal app.config.globalProperties.$modal = modal
// 时间对象 // 时间对象
app.config.globalProperties.$time = time app.config.globalProperties.$time = time
app.config.globalProperties.$auth = auth

6
src/pages/inLocation/addForm.vue

@ -133,9 +133,9 @@
ref, ref,
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as inLocationApi from "@/api/inLocation.js" import * as inLocationApi from "@/api/inLocation"
import * as sparePartsApi from "@/api/spareParts.js" import * as sparePartsApi from "@/api/spareParts"
import * as locationApi from "@/api/location.js" import * as locationApi from "@/api/location"
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const loading = ref(false) const loading = ref(false)

5
src/pages/inLocation/index.vue

@ -46,8 +46,7 @@
ref, ref,
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as inLocationApi from "@/api/inLocation.js" import * as inLocationApi from "@/api/inLocation"
import auth from '@/plugins/auth'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const params = ref({ const params = ref({
@ -57,7 +56,7 @@
const status = ref('loadmore') // const status = ref('loadmore') //
const list = ref([]) const list = ref([])
function openDetail(item){ function openDetail(item){
if(!auth.hasPermiOr(['eam:item-order-main:inOperation']))return; if(!proxy.$auth.hasPermiOr(['eam:item-order-main:inOperation']))return;
proxy.$tab.navigateTo(`/pages/inLocation/addForm?data=${encodeURIComponent(JSON.stringify(item))}`) proxy.$tab.navigateTo(`/pages/inLocation/addForm?data=${encodeURIComponent(JSON.stringify(item))}`)
} }
async function getList() { async function getList() {

4
src/pages/outLocation/addForm.vue

@ -151,8 +151,8 @@
ref, ref,
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as outLocationApi from "@/api/outLocation.js" import * as outLocationApi from "@/api/outLocation"
import * as locationApi from "@/api/location.js" import * as locationApi from "@/api/location"
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const loading = ref(false) const loading = ref(false)

4
src/pages/outLocation/index.vue

@ -63,7 +63,7 @@
ref, ref,
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as outLocationApi from "@/api/outLocation.js" import * as outLocationApi from "@/api/outLocation"
import auth from '@/plugins/auth' import auth from '@/plugins/auth'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const params = ref({ const params = ref({
@ -74,7 +74,7 @@
const list = ref([]) const list = ref([])
function openDetail(item){ function openDetail(item){
if(!auth.hasPermiOr(['eam:item-apply-record-main:outOperation']))return; if(!proxy.$auth.hasPermiOr(['eam:item-apply-record-main:outOperation']))return;
proxy.$tab.navigateTo(`/pages/outLocation/addForm?data=${encodeURIComponent(JSON.stringify(item))}`) proxy.$tab.navigateTo(`/pages/outLocation/addForm?data=${encodeURIComponent(JSON.stringify(item))}`)
} }
async function getList() { async function getList() {

2
src/pages/scanCode/scanCode.vue

@ -70,7 +70,7 @@
ref, ref,
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as locationApi from "@/api/location.js" import * as locationApi from "@/api/location"
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const number = ref('LN0000000001') const number = ref('LN0000000001')
const list = ref([]) const list = ref([])

8
src/pages/sparePartsReturn/addForm.vue

@ -100,10 +100,10 @@
ref, ref,
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as userApi from "@/api/user.js" import * as userApi from "@/api/user"
import * as sparePartsReturnApi from "@/api/sparePartsReturn.js" import * as sparePartsReturnApi from "@/api/sparePartsReturn"
import * as sparePartsApi from "@/api/spareParts.js" import * as sparePartsApi from "@/api/spareParts"
import * as locationApi from "@/api/location.js" import * as locationApi from "@/api/location"
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const loading = ref(false) const loading = ref(false)

10
src/plugins/auth.js

@ -1,12 +1,8 @@
// import store from '@/store'
import {
useCountStore
} from '@/store'
const store = useCountStore()
function authPermission(permission) { function authPermission(permission) {
const all_permission = "*:*:*" const all_permission = "*:*:*"
const permissions = store && store.permissions const permissions =uni.getStorageSync('permissionInfo')
if (permission && permission.length > 0) { if (permission && permission.length > 0) {
return permissions.some(v => { return permissions.some(v => {
return all_permission === v || v === permission return all_permission === v || v === permission
@ -18,7 +14,7 @@ function authPermission(permission) {
function authRole(role) { function authRole(role) {
const super_admin = "admin" const super_admin = "admin"
const roles = store && store.roles const roles = uni.getStorageSync('roles')
if (role && role.length > 0) { if (role && role.length > 0) {
return roles.some(v => { return roles.some(v => {
return super_admin === v || v === role return super_admin === v || v === role

5
src/store/modules/countStore.ts

@ -56,6 +56,9 @@ const useStore = defineStore('storeId', {
this.roles = res.roles this.roles = res.roles
this.role = res.roles.filter(item => item == 'all_approve' || item == 'normal_approve')[0] this.role = res.roles.filter(item => item == 'all_approve' || item == 'normal_approve')[0]
this.permissions = res.permissions this.permissions = res.permissions
uni.setStorageSync('permissionInfo',res.permissions)
uni.setStorageSync('roles',res.roles)
let menus = [] let menus = []
res.menus.forEach(item => { res.menus.forEach(item => {
if (item.path == '/pda') { if (item.path == '/pda') {
@ -107,6 +110,8 @@ const useStore = defineStore('storeId', {
this.post = '' this.post = ''
this.dept = '' this.dept = ''
removeToken() removeToken()
uni.removeStorageSync('permissionInfo')
uni.removeStorageSync('roles')
resolve(res) resolve(res)
}).catch(error => { }).catch(error => {
reject(error) reject(error)

Loading…
Cancel
Save