Browse Source

权限

master
zhang_li 6 months ago
parent
commit
5fa322b371
  1. 2
      .env.development
  2. 4
      .env.production
  3. 5
      src/manifest.json
  4. 2
      src/pages/inLocation/index.vue
  5. 41
      src/pages/index.vue
  6. 12
      src/pages/login.vue
  7. 2
      src/pages/outLocation/index.vue
  8. 108
      src/plugins/auth.js
  9. 6
      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://dev.ccwin-in.com:25203/api/admin-api
VITE_BASE_URL_IMAGE=http://localhost:12080/admin-api
VITE_BASE_URL_IMAGE=http://192.168.0.106:12080/admin-api

4
.env.production

@ -1,2 +1,2 @@
VITE_BASE_URL=http://10.62.139.32:82/api/admin-api
VITE_BASE_URL_IMAGE=http://10.62.139.32:82/api/admin-api
VITE_BASE_URL=http://dev.ccwin-in.com:25210/admin-api
VITE_BASE_URL_IMAGE=http://dev.ccwin-in.com:25210/admin-api

5
src/manifest.json

@ -1,6 +1,6 @@
{
"name" : "富维汽车镜",
"appid" : "__UNI__DA78BC9",
"appid" : "__UNI__0DC0349",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
@ -16,6 +16,9 @@
"autoclose" : true,
"delay" : 0
},
"compatible" : {
"ignoreVersion" : true
},
/* */
"modules" : {},
/* */

2
src/pages/inLocation/index.vue

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

41
src/pages/index.vue

@ -34,7 +34,28 @@
</view>
</view>
<view class="box">
<view class="">
<view class="" v-for="(item,index) in meaus" :key='index'>
<view class="title">{{item.name}}</view>
<u-row gutter="16" style="padding:0px 20rpx ;">
<u-col span="3" v-for="(cur,key) in item.children" :key='key'>
<view class="icon-item" @click="open(cur.path)">
<!-- 扫码图标 -->
<image src="../static/images/icon8.png" mode="" v-if="cur.componentName == 'scanCodeMeau'"></image>
<!-- 采购入库图标 -->
<image src="../static/images/icon1.png" mode="" v-else-if="cur.componentName == 'inLocation'"></image>
<!-- 备件归还图标 -->
<image src="../static/images/icon3.png" mode="" v-else-if="cur.componentName == 'sparePartsReturn'"></image>
<!-- 采购出库图标 -->
<image src="../static/images/icon2.png" mode="" v-else-if="cur.componentName == 'outLocation'"></image>
<view>{{cur.name}}</view>
</view>
</u-col>
</u-row>
</view>
<!-- <view class="">
<view class="title">扫码</view>
<u-row gutter="16" style="padding:0px 20rpx ;">
<u-col span="3">
@ -44,8 +65,8 @@
</view>
</u-col>
</u-row>
</view>
<view class="" v-if="menus1&&menus1.length>0">
</view> -->
<!-- <view class="" v-if="menus1&&menus1.length>0">
<view class="title">采购入库</view>
<u-row gutter="16" style="padding:0px 20rpx ;">
<block v-for="(item,index) in menus1" :key="index">
@ -77,7 +98,7 @@
</u-col>
</block>
</u-row>
</view>
</view> -->
</view>
<view class="btn" @click="handleLogout" v-if="getAccessToken()">退出登录</view>
</view>
@ -102,14 +123,14 @@
// store
const store = useCountStore()
const bgOpacity = ref(0)
const menus1 = ref([])
const menus2 = ref([])
const meaus = ref([])
// const menus2 = ref([])
function open(url) {
if (!getAccessToken()) {
proxy.$tab.navigateTo('/pages/login')
return
}
proxy.$tab.navigateTo(url)
proxy.$tab.navigateTo("/" + url)
}
function handleLogout() {
proxy.$modal.confirm('确定注销并退出系统吗?').then(() => {
@ -123,8 +144,10 @@
}
onLoad(async () => {
await proxy.$onLaunched;
menus1.value = store.menus1
menus2.value = store.menus2
// menus1.value = store.menus1
// menus2.value = store.menus2
meaus.value = store.meaus
console.log(meaus.value )
})
onPageScroll((e) => {
if (e.scrollTop > 0) {

12
src/pages/login.vue

@ -63,6 +63,18 @@
// store
const store = useCountStore()
if( import.meta.env.VITE_USER_NODE_ENV == 'development'){
loginForm.value = {
tenantName: "闻荫源码",
username: "admin",
password: "123456",
captchaVerification: "",
rememberMe: false,
code: '1',
uuid: "APP",
cid:uni.getStorageSync('cid')
}
}
async function handleLogin(params) {
if (loginForm.value.username === "") {
proxy.$modal.msgError("请输入您的账号")

2
src/pages/outLocation/index.vue

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

108
src/plugins/auth.js

@ -1,60 +1,64 @@
import store from '@/store'
// import store from '@/store'
import {
useCountStore
} from '@/store'
const store = useCountStore()
function authPermission(permission) {
const all_permission = "*:*:*"
const permissions = store.getters && store.getters.permissions
if (permission && permission.length > 0) {
return permissions.some(v => {
return all_permission === v || v === permission
})
} else {
return false
}
const all_permission = "*:*:*"
const permissions = store && store.permissions
if (permission && permission.length > 0) {
return permissions.some(v => {
return all_permission === v || v === permission
})
} else {
return false
}
}
function authRole(role) {
const super_admin = "admin"
const roles = store.getters && store.getters.roles
if (role && role.length > 0) {
return roles.some(v => {
return super_admin === v || v === role
})
} else {
return false
}
const super_admin = "admin"
const roles = store && store.roles
if (role && role.length > 0) {
return roles.some(v => {
return super_admin === v || v === role
})
} else {
return false
}
}
export default {
// 验证用户是否具备某权限
hasPermi(permission) {
return authPermission(permission)
},
// 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr(permissions) {
return permissions.some(item => {
return authPermission(item)
})
},
// 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd(permissions) {
return permissions.every(item => {
return authPermission(item)
})
},
// 验证用户是否具备某角色
hasRole(role) {
return authRole(role)
},
// 验证用户是否含有指定角色,只需包含其中一个
hasRoleOr(roles) {
return roles.some(item => {
return authRole(item)
})
},
// 验证用户是否含有指定角色,必须全部拥有
hasRoleAnd(roles) {
return roles.every(item => {
return authRole(item)
})
}
}
// 验证用户是否具备某权限
hasPermi(permission) {
return authPermission(permission)
},
// 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr(permissions) {
return permissions.some(item => {
return authPermission(item)
})
},
// 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd(permissions) {
return permissions.every(item => {
return authPermission(item)
})
},
// 验证用户是否具备某角色
hasRole(role) {
return authRole(role)
},
// 验证用户是否含有指定角色,只需包含其中一个
hasRoleOr(roles) {
return roles.some(item => {
return authRole(item)
})
},
// 验证用户是否含有指定角色,必须全部拥有
hasRoleAnd(roles) {
return roles.every(item => {
return authRole(item)
})
}
}

6
src/store/modules/countStore.ts

@ -20,8 +20,7 @@ const useStore = defineStore('storeId', {
role: '',
post: '',
dept: '',
menus1: [],
menus2: [],
meaus: [],
}),
getters: {
// isEven: (state) => state.count % 2 === 0
@ -63,8 +62,7 @@ const useStore = defineStore('storeId', {
menus = item.children
}
})
this.menus1 = menus.filter(item => item.path !== 'itemOut')
this.menus2 = menus.filter(item => item.path === 'itemOut')
this.meaus = menus
} else {
this.roles = []
this.role = ''

Loading…
Cancel
Save