add permission
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
<template>
|
||||
<a-form :form="form" @submit="handleSubmit">
|
||||
<vx-card title="دسترسی ها">
|
||||
<ASpin type="loading" :spinning="loading">
|
||||
<div class="grid grid-col-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-2 md:gap-2 xl:grid-cols-2 lg:gap-4 xl:gap-4">
|
||||
<a-form-item label="سطح کاربر">
|
||||
<a-select
|
||||
v-decorator="['user_type', { initialValue:null,rules: [{ required: true, message: 'لطفاسطح دسترسی را انتخاب کنید' }] }]" @change="selectChange">
|
||||
<a-select-option v-for="(item,key) in userTypes" :value="key">
|
||||
{{ item }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="نقش ها">
|
||||
<a-tree
|
||||
v-model="rid"
|
||||
checkable
|
||||
default-expand-all
|
||||
style="width: 100%"
|
||||
:tree-data="treeData"
|
||||
:replace-fields="replaceFields"
|
||||
:auto-expand-parent="autoExpandParent"
|
||||
/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
<a-button type="primary" html-type="submit">
|
||||
ثبت اطلاعات
|
||||
</a-button>
|
||||
</ASpin>
|
||||
</vx-card>
|
||||
</a-form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import axios from '@/axios'
|
||||
|
||||
export default {
|
||||
name: "Access",
|
||||
data() {
|
||||
return {
|
||||
form: this.$form.createForm(this, {name: 'coordinated'}),
|
||||
expandedKeys:[],
|
||||
value: ['0-0-0'],
|
||||
treeData:undefined,
|
||||
userTypes: undefined,
|
||||
autoExpandParent: false,
|
||||
rid: [],
|
||||
replaceFields: {
|
||||
children: 'child',
|
||||
title: 'title'
|
||||
},
|
||||
keyId: null,
|
||||
getDataUserType:null
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async getPermission() {
|
||||
try{
|
||||
const {data} = await axios.get('admin/permission/rid')
|
||||
this.treeData = Object.values(data)
|
||||
}catch (e) {
|
||||
|
||||
}finally {
|
||||
|
||||
}
|
||||
},
|
||||
handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
this.form.validateFields(async (err, values) => {
|
||||
if (!err) {
|
||||
try {
|
||||
values.rid = this.rid
|
||||
await this.$store.dispatch('access/save', values);
|
||||
this.$ntSet()
|
||||
setTimeout(()=>{
|
||||
window.location.reload()
|
||||
},500)
|
||||
} catch (e) {
|
||||
this.$ntSetError()
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
async getUserType() {
|
||||
const {data} = await axios.get('admin/user/type')
|
||||
this.userTypes = data
|
||||
console.log(this.userTypes,'user_type')
|
||||
},
|
||||
loadSyncOptionChange(){
|
||||
let storageId = localStorage.getItem("contestId");
|
||||
storageId = this.keyId;
|
||||
localStorage.setItem("contestId", storageId);
|
||||
let test = localStorage.getItem("contestId");
|
||||
test = JSON.parse(localStorage.getItem("contestId"));
|
||||
localStorage.setItem("contestId", test);
|
||||
if(test != null){
|
||||
this.$store.dispatch('access/getOneId',test).then(()=>{
|
||||
this.rid = this.data.rid
|
||||
this.form.setFieldsValue(this.data)
|
||||
})
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
},
|
||||
selectChange(id){
|
||||
this.keyId = id
|
||||
this.loadSyncOptionChange()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.access.loading;
|
||||
},
|
||||
data(){
|
||||
console.log(this.$store.state.access.access_id,'hgghgh')
|
||||
return this.$store.state.access.access_id
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getUserType()
|
||||
this.getPermission()
|
||||
this.keyId = 1
|
||||
this.loadSyncOptionChange()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
[dir=rtl] .ant-tree-checkbox-inner::after{
|
||||
right: 55%;
|
||||
top: 35%;
|
||||
border-left: 0 !important;
|
||||
-webkit-transform: rotate(-45deg) scale(0) translate(50%, -50%);
|
||||
transform: rotate(-45deg) scale(0) translate(50%, -50%);
|
||||
}
|
||||
[dir=rtl] .ant-tree-checkbox-checked .ant-tree-checkbox-inner::after{
|
||||
border-left: 0 !important;
|
||||
border-right: 2px solid #fff;
|
||||
}
|
||||
[dir=rtl] .ant-tree-checkbox-checked .ant-tree-checkbox-inner::after {
|
||||
border-left: 0 !important;
|
||||
border-right: 2px solid #fff;
|
||||
-webkit-transform: rotate(-45deg) scale(1) translate(50%, -50%);
|
||||
transform: rotate(25deg) scale(1) translate(50%, -50%);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user