[add]授权
This commit is contained in:
parent
7ae0e9c0d3
commit
08476be23c
12
src/api/flower/index.js
Normal file
12
src/api/flower/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import fetch from '../fetch.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
save(params) {
|
||||||
|
return fetch('/farmTemplate/add', params,'post','json')
|
||||||
|
},
|
||||||
|
|
||||||
|
list(params) {
|
||||||
|
return fetch('/farmTemplate/list', params,'post','json')
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
@ -11,6 +11,7 @@ import contract from '@/api/contract/index.js'
|
|||||||
import contractFile from '@/api/contract/file.js'
|
import contractFile from '@/api/contract/file.js'
|
||||||
import contractPay from '@/api/contract/pay.js'
|
import contractPay from '@/api/contract/pay.js'
|
||||||
import notice from '@/api/notice/index.js'
|
import notice from '@/api/notice/index.js'
|
||||||
|
import flower from '@/api/flower/index.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
user,
|
user,
|
||||||
@ -25,5 +26,6 @@ export default {
|
|||||||
contract,
|
contract,
|
||||||
contractFile,
|
contractFile,
|
||||||
contractPay,
|
contractPay,
|
||||||
notice
|
notice,
|
||||||
|
flower
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,7 @@ export default {
|
|||||||
menuTree(params) {
|
menuTree(params) {
|
||||||
return fetch('/menu/getAllMenuTree', params,'post','json')
|
return fetch('/menu/getAllMenuTree', params,'post','json')
|
||||||
},
|
},
|
||||||
|
|
||||||
menuRemove(params) {
|
menuRemove(params) {
|
||||||
return fetch('/menu/delete', params, 'post')
|
return fetch('/menu/delete', params, 'post')
|
||||||
},
|
},
|
||||||
@ -85,6 +86,9 @@ export default {
|
|||||||
roleUpdate(params) {
|
roleUpdate(params) {
|
||||||
return fetch('/role/update', params, 'post','json')
|
return fetch('/role/update', params, 'post','json')
|
||||||
},
|
},
|
||||||
|
roleGrant(params) {
|
||||||
|
return fetch('/role/grantMenu', params, 'post','json')
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增 或者更新
|
* 新增 或者更新
|
||||||
|
|||||||
53
src/views/flower/plan/components/edit.vue
Normal file
53
src/views/flower/plan/components/edit.vue
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<a-button type="primary" @click="show = true">{{ title }}</a-button>
|
||||||
|
<a-modal v-model:visible="show" @before-ok="submit">
|
||||||
|
<a-textarea v-model="tmp" :auto-size="{miniRows:6}"></a-textarea>
|
||||||
|
</a-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
watch: {
|
||||||
|
show:{
|
||||||
|
handler(val){
|
||||||
|
if (val){
|
||||||
|
this.tmp = JSON.stringify(this.from,null,4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
tmp:null,
|
||||||
|
show: false,
|
||||||
|
title: '新增',
|
||||||
|
from: {
|
||||||
|
circleDays: 0,
|
||||||
|
desc: '请输入描述',
|
||||||
|
isCircle: 0,
|
||||||
|
isSystem: 0,
|
||||||
|
name: '请输入名称',
|
||||||
|
remark: '请输入备注',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submit(done) {
|
||||||
|
const data = JSON.parse(this.tmp)
|
||||||
|
this.$api.flower.save(data).then(res => {
|
||||||
|
if (res.code === 200){
|
||||||
|
this.$message.success(res.msg)
|
||||||
|
done()
|
||||||
|
} else{
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
done(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
60
src/views/flower/plan/index.vue
Normal file
60
src/views/flower/plan/index.vue
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<navbar title="农事模版"/>
|
||||||
|
<a-card>
|
||||||
|
<div class="flex flex-center flex-justify-start">
|
||||||
|
<edit></edit>
|
||||||
|
</div>
|
||||||
|
<a-table class="mt-20" :columns="columns" :data="list"></a-table>
|
||||||
|
</a-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import navbar from '@/components/navbar/index.vue'
|
||||||
|
import edit from './components/edit.vue'
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
navbar,
|
||||||
|
edit
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
list: [],
|
||||||
|
page:{
|
||||||
|
current:1,
|
||||||
|
pageSize:10,
|
||||||
|
},
|
||||||
|
columns :[
|
||||||
|
{
|
||||||
|
title:'模版',
|
||||||
|
dataIndex: 'Name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title:'周期',
|
||||||
|
dataIndex: 'CircleDays',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
fetchList() {
|
||||||
|
const data ={...this.page}
|
||||||
|
this.$api.flower.list(data).then(res => {
|
||||||
|
if (res.code === 200){
|
||||||
|
this.list = res.data.list
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@ -73,7 +73,8 @@ export default {
|
|||||||
permission: '',
|
permission: '',
|
||||||
sort: 1,
|
sort: 1,
|
||||||
category: 0,
|
category: 0,
|
||||||
parentId: '0'
|
parentId: '0',
|
||||||
|
code:''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -81,6 +82,8 @@ export default {
|
|||||||
submit(done) {
|
submit(done) {
|
||||||
this.$refs.form.validate(errors => {
|
this.$refs.form.validate(errors => {
|
||||||
if (errors === undefined) {
|
if (errors === undefined) {
|
||||||
|
this.form.code = this.form.permission
|
||||||
|
this.form.title = this.form.name
|
||||||
if (this.form.id !== ""){
|
if (this.form.id !== ""){
|
||||||
this.$api.sys.menuUpdate(this.form).then(res => {
|
this.$api.sys.menuUpdate(this.form).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
|
|||||||
@ -1,8 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<a-button type="text" @click="show = true">授权</a-button>
|
<a-button type="text" @click="show = true">授权</a-button>
|
||||||
<a-modal v-model:visible="show">
|
<a-modal v-model:visible="show" @before-ok="submit">
|
||||||
{{list}}
|
<a-tree
|
||||||
|
checkable
|
||||||
|
:data="treeData"
|
||||||
|
v-model:checked-keys="selected"
|
||||||
|
:fieldNames="{
|
||||||
|
key: 'id',
|
||||||
|
title: 'name',
|
||||||
|
}"
|
||||||
|
/>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -14,10 +22,12 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
default: ''
|
default: ''
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
treeData: [],
|
||||||
|
selected: [],
|
||||||
show: false
|
show: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -25,26 +35,48 @@ export default {
|
|||||||
show: {
|
show: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.fetchPermission()
|
this.fetchMenu()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchPermission() {
|
fetchMenu() {
|
||||||
this.$api.sys.roleInfo({id: this.id}).then(res => {
|
this.$api.sys.menuTree({ category: 0, parentId: '0' }).then(res => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
this.list = res.data
|
this.treeData = res.data
|
||||||
|
console.log(this.treeData)
|
||||||
|
this.fetchPermission()
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(res.msg)
|
this.$message.error(res.msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
fetchPermission() {
|
||||||
|
this.$api.sys.roleInfo({ id: this.id }).then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.selected = res.data.Menus.map(e => e.id)
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
submit(done){
|
||||||
|
const data = {roleId: this.id,menuIds: this.selected}
|
||||||
|
this.$api.sys.roleGrant(data).then(res => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.$message.success(res.msg)
|
||||||
|
done()
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
done(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped></style>
|
||||||
|
<script setup lang="ts"></script>
|
||||||
</style>
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user