| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import { Notification } from 'element-ui';
- export default {
- // 获取应用权限
- checkAuth (appname,auth) {
- // 获取应用数据
- let apps = JSON.parse(sessionStorage.getItem('active_modules'))
-
- let module_list = apps.apps
- // 获取当前应用数据
- let active_modules = module_list.filter(item => {
- return item.name === appname
- })
- // 获取当前应用权限
- let auth_list = active_modules[0].meta.auth
- // 判断是否拥有权限
- let _haveAuth = auth_list.some(item=>item.option === auth)
- return _haveAuth
- },
- // 获取应用表格
- tabelCol (appname) {
- // 获取应用数据
- let apps = JSON.parse(sessionStorage.getItem('active_modules'))
-
- let module_list = apps.apps
- // 获取当前应用数据
- let active_modules = module_list.filter(item => {
- return item.name === appname
- })
- // 获取当前应用表格数据
- let tablecols = active_modules[0].meta.tables
- return tablecols
- },
- // 操作响应提示
- showMessage (res) {
- if (res.code === 0) return Notification({
- title: '失败',
- message: res.data,
- type: 'error'
- });
- Notification({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- },
- // 处理省市县数据结构
- createMenu (node) {
- var that = this
- let obj = Object.keys(node).map((key,index,item)=>{
- var elNode = {
- label: key,
- value: key,
- item:node[key],
- }
- return elNode;
- })
- obj.forEach(e=>{
- if ((e.item) instanceof Array) {
- e.children = []
- e.item.forEach(c=>{
- e.children.push({
- label:c,
- value:c
- })
- })
- } else {
- if (Object.keys(e.item).length !== 0) {
- e.children = that.createMenu(e.item)
- }
- }
- })
- return obj
- },
- //正则验证手机号
- /**
- * 必须以数字组成
- * 必须以1开头
- * 必须为11位数
- */
- checkPhoneFun(text) {
- return /^1\d{10}$/.test(text)
- }
- }
|