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. 106
      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://192.168.0.106: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://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=http://dev.ccwin-in.com:25210/admin-api
VITE_BASE_URL_IMAGE=http://10.62.139.32:82/api/admin-api VITE_BASE_URL_IMAGE=http://dev.ccwin-in.com:25210/admin-api

5
src/manifest.json

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

2
src/pages/inLocation/index.vue

@ -47,6 +47,7 @@
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as inLocationApi from "@/api/inLocation.js" import * as inLocationApi from "@/api/inLocation.js"
import auth from '@/plugins/auth'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const params = ref({ const params = ref({
@ -56,6 +57,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;
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() {

41
src/pages/index.vue

@ -34,7 +34,28 @@
</view> </view>
</view> </view>
<view class="box"> <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> <view class="title">扫码</view>
<u-row gutter="16" style="padding:0px 20rpx ;"> <u-row gutter="16" style="padding:0px 20rpx ;">
<u-col span="3"> <u-col span="3">
@ -44,8 +65,8 @@
</view> </view>
</u-col> </u-col>
</u-row> </u-row>
</view> </view> -->
<view class="" v-if="menus1&&menus1.length>0"> <!-- <view class="" v-if="menus1&&menus1.length>0">
<view class="title">采购入库</view> <view class="title">采购入库</view>
<u-row gutter="16" style="padding:0px 20rpx ;"> <u-row gutter="16" style="padding:0px 20rpx ;">
<block v-for="(item,index) in menus1" :key="index"> <block v-for="(item,index) in menus1" :key="index">
@ -77,7 +98,7 @@
</u-col> </u-col>
</block> </block>
</u-row> </u-row>
</view> </view> -->
</view> </view>
<view class="btn" @click="handleLogout" v-if="getAccessToken()">退出登录</view> <view class="btn" @click="handleLogout" v-if="getAccessToken()">退出登录</view>
</view> </view>
@ -102,14 +123,14 @@
// store // store
const store = useCountStore() const store = useCountStore()
const bgOpacity = ref(0) const bgOpacity = ref(0)
const menus1 = ref([]) const meaus = ref([])
const menus2 = ref([]) // const menus2 = ref([])
function open(url) { function open(url) {
if (!getAccessToken()) { if (!getAccessToken()) {
proxy.$tab.navigateTo('/pages/login') proxy.$tab.navigateTo('/pages/login')
return return
} }
proxy.$tab.navigateTo(url) proxy.$tab.navigateTo("/" + url)
} }
function handleLogout() { function handleLogout() {
proxy.$modal.confirm('确定注销并退出系统吗?').then(() => { proxy.$modal.confirm('确定注销并退出系统吗?').then(() => {
@ -123,8 +144,10 @@
} }
onLoad(async () => { onLoad(async () => {
await proxy.$onLaunched; await proxy.$onLaunched;
menus1.value = store.menus1 // menus1.value = store.menus1
menus2.value = store.menus2 // menus2.value = store.menus2
meaus.value = store.meaus
console.log(meaus.value )
}) })
onPageScroll((e) => { onPageScroll((e) => {
if (e.scrollTop > 0) { if (e.scrollTop > 0) {

12
src/pages/login.vue

@ -63,6 +63,18 @@
// store // store
const store = useCountStore() 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) { async function handleLogin(params) {
if (loginForm.value.username === "") { if (loginForm.value.username === "") {
proxy.$modal.msgError("请输入您的账号") proxy.$modal.msgError("请输入您的账号")

2
src/pages/outLocation/index.vue

@ -64,6 +64,7 @@
getCurrentInstance getCurrentInstance
} from 'vue' } from 'vue'
import * as outLocationApi from "@/api/outLocation.js" import * as outLocationApi from "@/api/outLocation.js"
import auth from '@/plugins/auth'
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
const params = ref({ const params = ref({
pageNo: 1, pageNo: 1,
@ -73,6 +74,7 @@
const list = ref([]) const list = ref([])
function openDetail(item){ function openDetail(item){
if(!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() {

106
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) { function authPermission(permission) {
const all_permission = "*:*:*" const all_permission = "*:*:*"
const permissions = store.getters && store.getters.permissions const permissions = store && store.permissions
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
}) })
} else { } else {
return false return false
} }
} }
function authRole(role) { function authRole(role) {
const super_admin = "admin" const super_admin = "admin"
const roles = store.getters && store.getters.roles const roles = store && store.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
}) })
} else { } else {
return false return false
} }
} }
export default { export default {
// 验证用户是否具备某权限 // 验证用户是否具备某权限
hasPermi(permission) { hasPermi(permission) {
return authPermission(permission) return authPermission(permission)
}, },
// 验证用户是否含有指定权限,只需包含其中一个 // 验证用户是否含有指定权限,只需包含其中一个
hasPermiOr(permissions) { hasPermiOr(permissions) {
return permissions.some(item => { return permissions.some(item => {
return authPermission(item) return authPermission(item)
}) })
}, },
// 验证用户是否含有指定权限,必须全部拥有 // 验证用户是否含有指定权限,必须全部拥有
hasPermiAnd(permissions) { hasPermiAnd(permissions) {
return permissions.every(item => { return permissions.every(item => {
return authPermission(item) return authPermission(item)
}) })
}, },
// 验证用户是否具备某角色 // 验证用户是否具备某角色
hasRole(role) { hasRole(role) {
return authRole(role) return authRole(role)
}, },
// 验证用户是否含有指定角色,只需包含其中一个 // 验证用户是否含有指定角色,只需包含其中一个
hasRoleOr(roles) { hasRoleOr(roles) {
return roles.some(item => { return roles.some(item => {
return authRole(item) return authRole(item)
}) })
}, },
// 验证用户是否含有指定角色,必须全部拥有 // 验证用户是否含有指定角色,必须全部拥有
hasRoleAnd(roles) { hasRoleAnd(roles) {
return roles.every(item => { return roles.every(item => {
return authRole(item) return authRole(item)
}) })
} }
} }

6
src/store/modules/countStore.ts

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

Loading…
Cancel
Save