diff --git a/package.json b/package.json
index f8454f2..04e5cdd 100644
--- a/package.json
+++ b/package.json
@@ -77,6 +77,8 @@
"node-sass": "^6.0.1",
"sass-loader": "^13.3.2",
"uview-ui": "^1.8.8",
+ "video.js": "^8.6.1",
+ "videojs-contrib-hls": "^5.15.0",
"vue": "^2.6.11",
"vuex": "^3.2.0",
"vuex-persistedstate": "^4.1.0"
diff --git a/src/App.vue b/src/App.vue
index 5868600..98876ee 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -4,12 +4,13 @@ export default {
onLaunch: function () {
console.log('App Launch')
- if (!(store.state.user_access_token && store.state.userInfo['id'])) {
+ if (!store.state.user_access_token) {
//未登录
uni.redirectTo({
url: '/pages/login/login',
})
} else {
+ this.$store.dispatch('getUserInfo')
// console.log(store.state.user_access_token)
}
},
@@ -28,7 +29,8 @@ export default {
diff --git a/src/directive/permission/index.js b/src/directive/permission/index.js
new file mode 100644
index 0000000..b745582
--- /dev/null
+++ b/src/directive/permission/index.js
@@ -0,0 +1,14 @@
+
+import permission from './permission'
+
+const install = function(Vue) {
+ Vue.directive('permission', permission)
+}
+
+if (window.Vue) {
+ window['permission'] = permission
+ Vue.use(install); // eslint-disable-line
+}
+
+permission.install = install
+export default permission
\ No newline at end of file
diff --git a/src/directive/permission/permission.js b/src/directive/permission/permission.js
new file mode 100644
index 0000000..86bb1eb
--- /dev/null
+++ b/src/directive/permission/permission.js
@@ -0,0 +1,30 @@
+import store from '@/store'
+
+function checkPermission(el, binding) {
+ const { value } = binding
+ const roles = store.getters && (store.getters.userInfo?.permissions_slug ?? [])
+ if (value && value instanceof Array) {
+ if (value.length > 0) {
+ const permissionRoles = value
+
+ const hasPermission = roles.some(role => {
+ return permissionRoles.includes(role)
+ })
+
+ if (!hasPermission) {
+ el.parentNode && el.parentNode.removeChild(el)
+ }
+ }
+ } else {
+ throw new Error(`need roles! Like v-permission="['admin','editor']"`)
+ }
+}
+
+export default {
+ inserted(el, binding) {
+ checkPermission(el, binding)
+ },
+ update(el, binding) {
+ checkPermission(el, binding)
+ }
+}
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 39e43bf..76647a0 100644
--- a/src/main.js
+++ b/src/main.js
@@ -13,6 +13,9 @@ Vue.component('ynSelectInputList', ynSelectInputList)
Vue.prototype.$http = http
Vue.prototype.$getFullUrl = getFullUrl
App.mpType = 'app'
+import permission from '@/directive/permission/index.js'
+
+Vue.directive('auth', permission)
diff --git a/src/pages/basics/basics-base.vue b/src/pages/basics/basics-base.vue
index f65d2b3..a1b4c02 100644
--- a/src/pages/basics/basics-base.vue
+++ b/src/pages/basics/basics-base.vue
@@ -2,7 +2,12 @@
- 新增
+ 新增
@@ -61,6 +66,8 @@
:data="currentData"
@onEdit="handleEdit"
@onDel="handleDel"
+ :editAuth="['endpoint.agricultural_basic.edit']"
+ :delAuth="['endpoint.agricultural_basic.destroy']"
>
@@ -80,6 +87,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue'
+import checkPermission from '@/utils/permission.js'
const baseTableColums = [
{
title: '基地名称',
@@ -164,22 +172,7 @@ export default {
},
},
dataList: [],
- options: [
- {
- text: '编辑',
- opt: 'edit',
- style: {
- backgroundColor: '#007aff',
- },
- },
- {
- text: '删除',
- opt: 'delete',
- style: {
- backgroundColor: '#dd524d',
- },
- },
- ],
+
formShow: false,
baseShow: false,
searchFormSchema: [
@@ -211,6 +204,30 @@ export default {
],
}
},
+ computed: {
+ options() {
+ return [
+ {
+ text: '编辑',
+ opt: 'edit',
+ permission: ['endpoint.agricultural_basic.edit'],
+ style: {
+ backgroundColor: '#007aff',
+ },
+ },
+ {
+ text: '删除',
+ opt: 'delete',
+ permission: ['endpoint.agricultural_basic.destroy'],
+ style: {
+ backgroundColor: '#dd524d',
+ },
+ },
+ ].filter((e) =>
+ checkPermission(e.permission)
+ )
+ },
+ },
methods: {
handleSubmit(e) {
this.filterParmas = e
diff --git a/src/pages/basics/town-base.vue b/src/pages/basics/town-base.vue
index 9b18eb1..a668612 100644
--- a/src/pages/basics/town-base.vue
+++ b/src/pages/basics/town-base.vue
@@ -3,9 +3,9 @@
全市数据统计
- 编辑
+ 编辑
-
+
- 新增
+ 新增
@@ -52,17 +52,9 @@
:data="currentData"
@onEdit="handleEdit"
@onDel="handleDel"
+ :editAuth="['endpoint.crops.edit']"
+ :delAuth="['endpoint.crops.destroy']"
>
-
@@ -83,6 +75,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue'
+import checkPermission from '@/utils/permission.js'
const baseTableColums = [
{
title: '名称',
@@ -128,22 +121,6 @@ export default {
},
},
dataList: [],
- options: [
- {
- text: '编辑',
- opt: 'edit',
- style: {
- backgroundColor: '#007aff',
- },
- },
- {
- text: '删除',
- opt: 'delete',
- style: {
- backgroundColor: '#dd524d',
- },
- },
- ],
formShow: false,
baseShow: false,
searchFormSchema: [
@@ -158,6 +135,28 @@ export default {
],
}
},
+ computed: {
+ options() {
+ return [
+ {
+ text: '编辑',
+ opt: 'edit',
+ permission: ['endpoint.crops.edit'],
+ style: {
+ backgroundColor: '#007aff',
+ },
+ },
+ {
+ text: '删除',
+ opt: 'delete',
+ permission: ['endpoint.crops.destroy'],
+ style: {
+ backgroundColor: '#dd524d',
+ },
+ },
+ ].filter((e) => checkPermission(e.permission))
+ },
+ },
methods: {
handleSubmit(e) {
this.filterParmas = e
diff --git a/src/pages/crop/town-crop.vue b/src/pages/crop/town-crop.vue
index 53891ac..1e9d949 100644
--- a/src/pages/crop/town-crop.vue
+++ b/src/pages/crop/town-crop.vue
@@ -2,7 +2,12 @@
- 新增
+ 新增
@@ -52,20 +57,15 @@
:data="currentData"
@onEdit="handleEdit"
@onDel="handleDel"
+ :editAuth="['endpoint.town_crops.edit']"
+ :delAuth="['endpoint.town_crops.destroy']"
>
-
-
+
checkPermission(e.permission))
+ },
+ },
methods: {
handleSubmit(e) {
this.filterParmas = e
diff --git a/src/pages/device/index.vue b/src/pages/device/index.vue
index d1eaab5..460da00 100644
--- a/src/pages/device/index.vue
+++ b/src/pages/device/index.vue
@@ -3,7 +3,7 @@
- 新增
+ 新增
@@ -172,8 +172,8 @@