[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 contractPay from '@/api/contract/pay.js'
|
||||
import notice from '@/api/notice/index.js'
|
||||
import flower from '@/api/flower/index.js'
|
||||
|
||||
export default {
|
||||
user,
|
||||
@ -25,5 +26,6 @@ export default {
|
||||
contract,
|
||||
contractFile,
|
||||
contractPay,
|
||||
notice
|
||||
notice,
|
||||
flower
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ export default {
|
||||
menuTree(params) {
|
||||
return fetch('/menu/getAllMenuTree', params,'post','json')
|
||||
},
|
||||
|
||||
menuRemove(params) {
|
||||
return fetch('/menu/delete', params, 'post')
|
||||
},
|
||||
@ -85,6 +86,9 @@ export default {
|
||||
roleUpdate(params) {
|
||||
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: '',
|
||||
sort: 1,
|
||||
category: 0,
|
||||
parentId: '0'
|
||||
parentId: '0',
|
||||
code:''
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -81,6 +82,8 @@ export default {
|
||||
submit(done) {
|
||||
this.$refs.form.validate(errors => {
|
||||
if (errors === undefined) {
|
||||
this.form.code = this.form.permission
|
||||
this.form.title = this.form.name
|
||||
if (this.form.id !== ""){
|
||||
this.$api.sys.menuUpdate(this.form).then(res => {
|
||||
if (res.code === 200) {
|
||||
|
||||
@ -1,50 +1,82 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-button type="text" @click="show = true">授权</a-button>
|
||||
<a-modal v-model:visible="show">
|
||||
{{list}}
|
||||
</a-modal>
|
||||
</div>
|
||||
<div>
|
||||
<a-button type="text" @click="show = true">授权</a-button>
|
||||
<a-modal v-model:visible="show" @before-ok="submit">
|
||||
<a-tree
|
||||
checkable
|
||||
:data="treeData"
|
||||
v-model:checked-keys="selected"
|
||||
:fieldNames="{
|
||||
key: 'id',
|
||||
title: 'name',
|
||||
}"
|
||||
/>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
required:true,
|
||||
default: ''
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
show:{
|
||||
handler(val){
|
||||
if(val){
|
||||
this.fetchPermission()
|
||||
data() {
|
||||
return {
|
||||
treeData: [],
|
||||
selected: [],
|
||||
show: false
|
||||
}
|
||||
},
|
||||
immediate:true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchPermission() {
|
||||
this.$api.sys.roleInfo({id: this.id}).then(res => {
|
||||
if (res.code === 200){
|
||||
this.list = res.data
|
||||
} else {
|
||||
this.$message.error(res.msg)
|
||||
},
|
||||
watch: {
|
||||
show: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.fetchMenu()
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
fetchMenu() {
|
||||
this.$api.sys.menuTree({ category: 0, parentId: '0' }).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.treeData = res.data
|
||||
console.log(this.treeData)
|
||||
this.fetchPermission()
|
||||
} else {
|
||||
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>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
<script setup lang="ts"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user