Commit 040bb8aa authored by 周远喜's avatar 周远喜

产品发布成功。

parent d9d6b1f3
<template>
<Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :show-message="false" :label-width="90">
<Row>
<FormItem label="类型" prop="typeid">
<Select v-model="formValidate.typeid" placeholder="请选择" style="width:240px;">
<Option v-for="(item,index) in alltype " :key="item.index" :value="item.value">{{item.label}}</Option>
</Select>
</FormItem>
</Row>
<Row>
<FormItem label="名称" prop="name">
<Input v-model="formValidate.name" style="width:240px;"></Input>
</FormItem>
</Row>
<Row>
<FormItem label="描述" prop="description">
<Input v-model="formValidate.description" style="width:240px;"></Input>
</FormItem>
</Row>
<!-- <FormItem label="编号" prop="number">
<Input v-model="formValidate.number" number></Input>
</FormItem> -->
</Form>
</template>
<script>
export default {
name:'addDictionary',
props:['alltype'],
data(){
return {
formValidate:{typeid:'',name:'',description:''},
ruleValidate:{
name:[{required: true}],
// number:[{required: true,type:'number'}],
typeid:[{required: true}]
}
}
}
}
</script>
<style scoped>
.ivu-form-item {width:48%;display:inline-block;}
.ivu-form-item:nth-child(odd) {
margin-left: 10px
}
</style>
\ No newline at end of file
<template>
<div>
<div class="contentRight">
<label>类型:</label>
<Select v-model="model1" @on-change="change" placeholder="请选择" style="width: 200px">
<Option v-for="(item,index) in selectdata" :key="item.index" :value="item.value">{{item.label}}</Option>
</Select>
<div style="float:right" class="paddingbtn">
<Button type="primary" @click="add('formValidate')">新增</Button>
<!-- <Button type="primary" @click="edit">编辑</Button>
<Button type="primary" @click="del">删除</Button> -->
</div>
<tb :tbPro="tbPro" ref="table" v-on:rowclick="rowclick" class="margin-top-10"></tb>
</div>
<Modal v-model="modal1" title="新增字典数据" :width="440" :mask-closable="false"
:loading="myloading"
ok-text="保存" cancel-text="取消" @on-ok="ok('formValidate')" @on-cancel='cancel'
>
<add-dictionary ref="datadictionary" :alltype="selectdata"></add-dictionary>
<!-- <div slot="footer" style="text-align:center">
<Button type="primary" @click="ok('formValidate')">保存</Button>
<Button
type="primary"
style="border-color: rgb(204, 204, 204);background-color:white;color:black"
@click="cancel"
>取消</Button>
</div> -->
</Modal>
<myconfirm ref="mysel" v-on:confirmok="okmysel" v-on:confirmcancel="cancelmysel"></myconfirm>
</div>
</template>
<script>
import tb from '../roleManagent/components/tb'
import addDictionary from './components/add'
import myconfirm from '../../processDesign/productTree/components/myconfirm'
import service from '@/plugins/request'
export default {
components:{tb,addDictionary,myconfirm},
data(){
return {
myloading:true,
model1:'',
modal1:false,
isEdit:false,
formValidate1:{},
keyid:0,
clickdata:{},
//xia la
selectdata:[
{
value:'产品类型',
label:'产品类型'
},
{
value:'产品分类',
label:'产品分类'
},
{
value:'工艺类型',
label:'工艺类型'
},
{
value:'工艺阶段',
label:'工艺阶段'
},
{
value:'产品型号',
label:'产品型号'
},
],
//表格数据和属性
tbPro:{
height:"",
isBorder: true,
stripe: true,//斑马纹
highlight:true,//高亮显示
columns: [
{
type: 'index',
width: 60,
align: 'center'
},
{
title: '名称',
key: 'name'
},
{
title: '描述',
key: 'description'
},
{
title: '编码',
key: 'code'
},
{
title: '操作',
key: 'action',
align: 'center',
width:400,
render: (h, params) => {
return h('div', [
h(
'span',
{
props: {
type: 'text',
ghost:true
},
style: {
color: '#249E91',
marginRight:"5px",
cursor:"pointer"
},
on: {
click: () => {
this.edit(params)
}
}
},
'编辑'
),
h(
'span',
{
props: {
type: 'text',
ghost:true
},
style: {
color: '#F56C6C',
marginRight:"5px",
cursor:"pointer"
},
on: {
click: () => {
this.del(params)
}
}
},
'删除'
)
])
}
}
],
data: [
]
}
}
},
created(){
var url=`${systemUrl}/DictionaryType/GetPaged`
service.get(`${url}`).then(response=>{
//console.log(response.result.items)
this.selectdata=response.result.items
this.model1=this.selectdata[0].value
this.loaddata(this.model1)
});
this.tbPro.height = window.innerHeight - 180;
},
mounted(){
window.onresize = () => {
return (() => {
this.tbPro.height = window.innerHeight - 180;
})()
}
},
computed:{
alldata:function(){
return this.tbPro.data
}
},
methods:{
loaddata(id){
var url=`${systemUrl}/Dictionary/GetPaged`
service.get(`${url}`,{params:{TypeId:id}}).then(response=>{
this.tbPro.data=response.result.items
})
},
change(data){
// console.log(data);
this.loaddata(data)
},
add:function(name){
this.isEdit=false;
var a = this.$refs.datadictionary;
a.$refs[name].resetFields();
this.modal1=true;
this.$refs.datadictionary.formValidate={typeid:'',description:'',name:''}
},
edit(params){
var a = this.$refs.datadictionary;
a.$refs['formValidate'].resetFields();
this.modal1=true;
this.isEdit=true;
let {typeId,name,description,id,code}=params.row;
// console.log(typeId)
// console.log(number);
this.$refs.datadictionary.formValidate={typeid:typeId,name:name,description:description,id:id,code:code}
},
del(params){
console.log(params)
this.keyid=params.row.id
console.log(this.keyid)
this.$refs.mysel.confirmmodal=true;
},
okmysel(bl){
var url=`${systemUrl}/Dictionary/Delete?id=${this.keyid}`
service.delete(`${url}`).then(response=>{
if(response.success)
{
this.$Message.success('删除成功')
this.loaddata(this.model1)
}
}).catch(error=>{
this.$Message.error('删除失败')
})
this.$refs.mysel.confirmmodal=bl
},
cancelmysel(bl){
this.$refs.mysel.confirmmodal=bl
},
//保存增加修改
ok(name){
var a = this.$refs.datadictionary;
var url=`${systemUrl}/Dictionary/CreateOrUpdate`
var ar=this.alldata.find((val)=>{
return (val.name==this.$refs.datadictionary.formValidate.name)
})
if(ar){
this.$Message.error('已存在字典项的名字');
setTimeout(() => {
this.myloading = false
this.$nextTick(() => {
this.myloading = true
})
}, 500)
return;
}
a.$refs[name].validate((valid) => {
if (valid) {
this.formValidate1 = this.$refs.datadictionary.formValidate
if (this.isedit)
{
//this.formValidate1.id=
}
service.post(`${url}`,JSON.stringify({Dictionary:this.formValidate1})).then(response=>{
if(response.success){
this.$Message.success('保存成功')
this.loaddata(this.model1)
this.modal1 = false
}
}).catch(error=>{
//console.log(123)
// console.log(error)
this.$Message.error('保存失败')
})
} else {
setTimeout(() => {
this.myloading = false
this.$nextTick(() => {
this.myloading = true
})
}, 500)
this.$Message.error('请输入必填项')
}
})
},
cancel(){
this.modal1=false;
},
rowclick(data,index){
console.log(typeof(data));
this.clickdata=data;
// console.log(this.clickdata);
}
}
}
</script>
<style scoped>
</style>
import api from '@/plugins/request'
const u=(path)=>`${systemUrl}/Dictionary/${path}`
export default {
getChildren(id) {
return api.get(u("GetChildren"), { id })
},
getTree(){
return api.get(u('GetTree'))
},
setColor(paras) {
return api.post(u("SetColor"), {Dictionary:paras})
},
setSort(paras) {
return api.post(u("SetSort"), paras)
},
save(paras) {
return api.post(u("CreateOrUpdate"), {Dictionary:paras})
},
}
\ No newline at end of file
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="100">
<Row class="rowTitle100">
<FormItem label="类别" prop="typeId">
<RadioGroup v-model="entity.typeId">
<Radio :label="0" disabled>系统</Radio>
<Radio :label="1" disabled>分类</Radio>
<Radio :label="2" disabled>字典</Radio>
<Radio :label="3" disabled>字典项</Radio>
</RadioGroup>
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="名称" prop="name">
<Input v-model="entity.name">
<ColorPicker v-model="entity.color" slot="prepend" transfer size="small" transfer recommend />
</Input>
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="编码" prop="code">
<Input v-model="entity.code" />
</FormItem>
</Row>
<Row class="rowTitle100">
<FormItem label="图标" prop="icon">
<InputIcon v-model="entity.icon"></InputIcon>
</FormItem>
</Row>
<FormItem label="状态" prop="number">
<RadioGroup v-model="entity.status">
<Radio :label="0">启用</Radio>
<Radio :label="1">禁用(名称和值可以启用或禁用,但不能删除)</Radio>
</RadioGroup>
</FormItem>
<FormItem label="锁定" prop="number">
<RadioGroup v-model="entity.isStatic">
<Radio :label="0">不锁定</Radio>
<Radio :label="1">锁定(锁定后不可改变名称和值,不能删除)</Radio>
</RadioGroup>
</FormItem>
<Row class="rowTitle100">
<FormItem label="描述" prop="description">
<Input v-model="entity.description" type="textarea" :rows="3"></Input>
</FormItem>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</template>
<script>
export default {
name: 'Edit',
data() {
return {
entity: this.v,
rules: {
name: [{ required: true, message: '必填', trigger: 'blur' }],
code: [{ required: true, message: '必填', trigger: 'blur' }]
}
}
},
props: {
v: Object
},
methods: {
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
var url2 = `${systemUrl}/Dictionary/createorupdate`
this.$api.post(url2, { Dictionary: this.entity }).then((r) => {
if (r.success) {
this.$Message.success('保存成功')
this.$emit('on-ok')
}
})
}
})
},
handleClose() {
this.$emit('on-close')
}
},
watch: {
v(v) {
this.entity = this.v
console.info(this.entity)
}
}
}
</script>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<template>
<div class="jurisdiction">
<div class="jurisdiction-form">
<!-- <Form :model="formItem" :label-width="70" inline>
<FormItem label="菜单名称">
<Input v-model="formItem.name" placeholder="请输入菜单名"></Input>
</FormItem>
<FormItem label="菜单状态">
<Select v-model="formItem.status" placeholder="请选择菜单状态">
<Option value="1">显示</Option>
<Option value="2">隐藏</Option>
</Select>
</FormItem>
<FormItem :label-width="0">
<Button type="primary" @click="listTree">查询</Button>
</FormItem>
</Form> -->
<div class="right-btn">
<Button type="primary" @click="add">新建系统</Button>
</div>
</div>
<div>
<div class="margin-top-10">
<tree-grid
:items="data"
ref="table"
:columns="columns"
@on-row-click="rowClick"
@on-selection-change="selectionClick"
@on-sort-change="sortClick"
></tree-grid>
</div>
</div>
<!-- 新增系统弹框 -->
<Modal
v-model="addShow"
:title=" titleAdd"
:width="440"
:mask-closable="false"
ok-text="保存"
cancel-text="取消"
@on-ok="saveOk"
@on-cancel="saveCancel"
>
<div style="height:250px;padding:20px 0">
<Form :model="addModel" :label-width="120" inline>
<FormItem label="系统名称">
<Input
style="width:240px;"
size="large"
v-model.trim="addModel.name"
placeholder="请输入系统名称"
/>
</FormItem>
<FormItem label="请求地址">
<Input
style="width:240px;"
size="large"
v-model.trim="addModel.url"
placeholder="请输入请求地址"
/>
</FormItem>
<FormItem label="备注">
<Input
:rows="4"
maxlength="50"
show-word-limit
type="textarea"
placeholder="请输入备注信息"
style="width: 240px"
size="large"
v-model.trim="addModel.remark"
/>
</FormItem>
</Form>
</div>
</Modal>
<!-- 新建菜单/目录弹框 -->
<add-Memu ref="showAdd" :dataChild="dataChild" @listTree="listTree"></add-Memu>
</div>
</template>
<script>
import addMemu from './componets/addMemu'
export default {
name: '',
components: {
addMemu
},
data() {
return {
dataChild: {},
addShow: false,
showMenu: false,
titleAdd: '',
formItem: {
status: '',
name: ''
},
addModel: {
name: '',
url: '',
remark: '',
type: '0'
},
data: [],
columns: [
{
title: '菜单名称',
key: 'name',
width: '150',
sortable: true
},
{
title: '排序',
key: 'priority'
},
{
title: '请求地址',
key: 'url',
width: '200',
align: 'left'
},
{
title: '类型',
key: 'type',
align: 'center',
// render: (h, params) => {
// return h('state', {
// props: {
// code: 'system.menu.target',
// type: 'text',
// value: params.row.type + ''
// }
// })
// },
type: 'menuRender'
},
{
title: '状态',
key: 'status',
align: 'center',
type: 'menuIsshow'
},
{
title: 'icon图标',
key: 'icon',
align: 'center',
width: '100',
type: 'icons'
},
{
title: '打开方式',
key: 'target',
width: '150',
align: 'center',
type: 'menuTarget'
},
{
title: '备注',
key: 'remark',
width: '150'
},
{
title: '操作',
type: 'action',
actions: [
{
type: 'primary',
text: '新增'
},
{
type: 'primary',
text: '编辑'
},
{
type: 'error',
text: '删除'
}
],
width: '150'
}
]
}
},
created() {
this.formItem = {}
this.listTree()
},
async fetch({ store, params }) {
await store.dispatch('loadDictionary') // 加载数据字典
},
methods: {
//查询
listTree() {
// name:this.formItem.name,status:this.formItem.status
this.$http.jurisdiction.getListTree(this.formItem).then((res) => {
// debugger
this.data = res.result
})
},
//新建
add() {
this.titleAdd = '新增系统'
this.addModel = {}
this.addShow = true
},
selectionClick(arr) {
//console.log('选中数据id数组:' + arr)
// this.checkids = arr
},
sortClick(key, type) {
//console.log('排序字段:' + key)
//console.log('排序规则:' + type)
},
rowClick(data, event, index, txt) {
this.dataChild = data
console.log(data)
if (txt == '新增') {
this.$refs.showAdd.showMenu = true
this.$refs.showAdd.addModel.type = '1'
this.$refs.showAdd.addModel.status = '1'
this.$refs.showAdd.addModel.up_id = data.id
this.$refs.showAdd.addModel.upName = data.name
this.$refs.showAdd.width = 500
this.$refs.showAdd.isActive = false
this.$refs.showAdd.hasError = true
this.$refs.showAdd.title = '新建目录'
this.$refs.showAdd.addModel.name = ''
this.$refs.showAdd.addModel.priority = ''
this.$refs.showAdd.addModel.remark = ''
}
if (txt == '编辑') {
if (data.type == '0') {
this.titleAdd = '编辑系统'
this.addShow = true
} else if (data.type == '3') {
//按钮
this.$refs.showAdd.customTitle = '编辑按钮'
this.$refs.showAdd.customShow = true
this.$refs.showAdd.customModel.status = data.status.toString()
this.$refs.showAdd.customModel.type = data.type.toString()
} else {
this.titleEit = '编辑目录/菜单'
this.$refs.showAdd.showCatalog = true
this.$refs.showAdd.catalogModel.status = data.status.toString()
this.$refs.showAdd.catalogModel.type = data.type.toString()
}
}
if (txt == '删除') {
this.$Modal.confirm({
title: '删除',
content: '<p>是否删除此条菜单,删除请选择确认,否则请取消</p>',
okText: '确认',
cancelText: '取消',
onOk: () => {
this.$http.jurisdiction.deleteRow(data.id).then((res) => {
this.$Message.success('删除成功')
this.listTree()
})
}
})
}
//console.log('当前行数据:' + data)
// console.log('点击行号:' + index)
// console.log('点击事件:' + event)
},
saveOk() {
if (this.titleAdd == '新增系统') {
this.addModel.type = '0'
} else if (this.titleAdd == '编辑系统') {
this.addModel.id = this.childId
}
this.$http.jurisdiction.add({ privilege: this.addModel }).then((res) => {
this.listTree()
})
},
saveCancel() {}
}
}
</script>
<style lang="less" scoped>
.jurisdiction-form {
margin-top: 10px;
// position: relative;
.right-btn {
text-align: right;
margin-bottom: 10px;
// position: absolute;
// top: 0px;
// right: 10px;
}
}
</style>
\ No newline at end of file
<template id="addPRi">
<Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :show-message="false" :label-width="80" >
<FormItem label="父权限" prop="up_id">
<Select v-model="formValidate.up_id" style="width:240px;">
<Option v-for="(item,index) in list " :key="index" :value="item.value" style="display:none">{{item.label}} </Option>
<Tree v-show="isShow" :data="seldata" @on-select-change="handleSelect"></Tree>
</Select>
</FormItem>
<FormItem label="权限名称" prop="name">
<Input v-model="formValidate.name" style="width:240px;"></Input>
</FormItem>
<FormItem label="系统" prop="from_system">
<Select v-model="formValidate.from_system" @on-change="selectSys" style="width:240px;">
<Option v-for="(item,index) in allsystem " :key="index+1" :value="item.value">{{item.label}}</Option>
</Select>
</FormItem>
<FormItem label="操作类型" prop="type">
<Select v-model="formValidate.type" placeholder="请选择" style="width:240px;">
<Option value=1>菜单</Option>
<Option value=2>系统</Option>
<Option value=3>页面</Option>
</Select>
</FormItem>
<FormItem label="地址" prop="url">
<Input v-model="formValidate.url" style="width:240px;"></Input>
<!-- <Select v-model="formValidate.url" placeholder="请选择">
<Option v-for="(item,index) in allpages " :key="item.value" :value="item.value">{{item.label}}</Option>
</Select> -->
</FormItem>
<!-- <FormItem label="密级" prop="secret_class">
<Select v-model="formValidate.secret_class" placeholder="请选择" style="width:240px;">
<Option v-for="(item,index) in mijis " :key="item.value" :value="item.value">{{item.label}}</Option>
</Select>
</FormItem> -->
<FormItem label="状态" prop="status">
<Select v-model="formValidate.status" placeholder="请选择" style="width:240px;">
<Option value=0>启用</Option>
<Option value=1>禁用</Option>
</Select>
</FormItem>
<!-- <FormItem label="打开方式" prop="target">
<Select v-model="formValidate.target" placeholder="请选择" style="width:240px;">
<Option value="系统内">系统内</Option>
<Option value="新页面">新页面</Option>
</Select>
</FormItem> -->
<FormItem label="排序" prop="priority">
<Input v-model="formValidate.priority" style="width:240px;"></Input>
</FormItem>
</Form>
</template>
<script>
import service from '@/plugins/request'
export default {
name:'addPrivilege',
tit:'',
props:[
'seldata'
],
data(){
return {
formValidate:{name:'',up_id:-1,from_system:'',type:'',url:'',status:'',target:'',priority:'',secret_class:''},
ruleValidate: {
up_id:[{required: true}],
name:[{required: true}],
from_system:[{required: true}],
type:[{required: true}],
url:[{required: true}]
// priority:[ { required: true, message: '排序不能为空' },
// { type: 'number', message: '请输入排序,只能填写数字' }]
},
list:[],
isShow:true,
allsystem:[
{
value:'0',
label:'三车间MES'
},
{
value:'1',
label:'机加MES'
}
],
allpages:[
{
value:'/a/index.html',
label:'/a/index.html'
},
{
value:'/a/port.html',
label:'/a/port.html'
},
{
value:'/a/default.html',
label:'/a/default.html'
}
],
mijis:[
{
value:'机密',
label:'机密'
},
{
value:'一般',
label:'一般'
},
{
value:'内部',
label:'内部'
}
]
}
},
created(){
this.formValidate.from_system=this.allsystem[0].value
//this.gettree(this.formValidate.from_system);
},
computed:{
},
methods:{
selectSys(){
this.$emit('selectSys',this.formValidate.from_system)
},
handleSelect(data){
this.list=[];
this.list.push({label:data[0].title,value:data[0].value});
console.log(this.list);
this.formValidate.up_id=data[0].value;
},
getdata(){
return this.formValidate
}
}
}
</script>
<style scoped>
.ivu-form-item {width:48%;display:inline-block;}
.ivu-form-item:nth-child(odd) {
margin-left: 10px
}
</style>
\ No newline at end of file
This diff is collapsed.
<template>
<Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :show-message="false" :label-width="90" >
<Row >
<FormItem label="角色名称" prop="name">
<Input v-model="formValidate.name" style="width:240px;"></Input>
</FormItem>
</Row>
<Row >
<FormItem label="状态" prop="status">
<Select v-model="formValidate.status" placeholder="请选择" style="width:240px;">
<Option value="0">启用</Option>
<Option value="1">禁用</Option>
</Select>
</FormItem>
</Row>
<Row >
<FormItem label="角色描述" prop="description">
<Input v-model="formValidate.description" style="width:240px;"></Input>
</FormItem>
</Row>
<!-- <FormItem label="角色类型" prop="type">
<Select v-model="formValidate.type" placeholder="请选择">
<Option value="生产处调度员">生产处调度员</Option>
<Option value="库管">库管</Option>
<Option value="班组长">班组长</Option>
<Option value="操作工">操作工</Option>
</Select>
</FormItem> -->
</Form>
</template>
<script>
export default {
name:'addRole',
tit:'',
props:[
''
],
data(){
return {
formValidate:{name:'',status:'',description:''},
ruleValidate: {
name:[{required: true}],
status:[{required: true}]
},
isShow:true,
allsystem:[
{
value:'全部',
label:'全部'
},
{
value:'三车间MES',
label:'三车间MES'
},
{
value:'机加MES',
label:'机加MES'
}
],
}
},
created(){
},
methods:{
}
}
</script>
<style scoped>
.ivu-form-item {width:46%;display:inline-block;}
.ivu-form-item:nth-child(odd) {
margin-left: 10px
}
.ivu-form-item:nth-child(even) {
margin-left: 14px
}
</style>
\ No newline at end of file
<template>
<div>
<Input v-model="value1" placeholder="请输入角色名称" clearable style="width: 200px" />
<Select v-model="model1" style="width:200px" clearable placeholder="请选择">
<Option v-for="item in roleStatus" :value="item.value" :key="item.value">{{item.label }}</Option>
</Select>
<Button type="primary" @click="search">查询</Button>
<slot></slot>
</div>
</template>
<script>
export default {
name:'rolemain',
data(){
return {
value1:'',
model1: '',
roleStatus: [
{
value: '启用',
label: '启用'
},
{
value: '禁用',
label: '禁用'
}
]
}
},
methods:{
search:function(){
this.$emit('search',this.value1,this.model1)
}
}
}
</script>
<style scoped>
</style>
\ No newline at end of file
<template>
<Select v-model="model1" style="width:200px">
<Option v-for="item in roleStatus" :value="item.value" :key="item.value">{{item.label}}</Option>
</Select>
</template>
<script>
export default {
name:'sel',
props:[
'model1','roleStatus'
]
}
</script>
\ No newline at end of file
<template>
<Table :border="tbPro.isBorder" stripe :columns="tbPro.columns" :stripe="tbPro.stripe"
:data="tbPro.data" :highlight-row="tbPro.highlight" :loading="tbPro.loading" :height="tbPro.height" :content="tbPro.cur" @on-row-click="rowclick" class="tableCommon"></Table>
</template>
<script>
export default {
name:'tb',
props:[
//'columns1','data1','isBorder'
'tbPro'
],
methods:{
rowclick(rowdata,index){
this.$emit('rowclick',rowdata,index)
}
}
}
</script>
\ No newline at end of file
This diff is collapsed.
<template>
<div>
<div class="roleMenu">
<Tree v-if="show" :data="list" ref="mytree" show-checkbox check-directly ></Tree>
</div>
<div>
<Button type="primary" @click="commit">保存</Button>
<Button class="ml20" @click="$emit('menu-close')">取消</Button>
</div>
</div>
</template>
<script>
export default {
name: 'addRole',
tit: '',
props: {
role: Object
},
data() {
return {
show:false,
data: [],
list:[]
}
},
created() {
this.loadTree();
},
methods: {
loadTree() {
var url = `${systemUrl}/menu/list`
this.$api.post(`${url}`, { pageSize: 2000 ,conditions:[{"fieldName":"Type","fieldValue":3,"conditionalType":"LessThan"}]}).then((r) => {
r.result.sort(function(a,b){
return a.priority-b.priority;
})
this.data = r.result;
})
},
loadRole() {
var url = `${systemUrl}/roleMenu/GetRoleMenu`
//权限树
this.show=false
this.list=[]
this.$api.get(`${url}`, { id: this.role.id }).then((response) => {
let ids= response.result
var items=this.$u.clone(this.data);
console.info(ids,items);
this.list=this.$u.toTree(items,0,u=>{
u.title=u.name;
u.expand=true;
if(ids.indexOf(u.id)>-1){
u.checked=true;
}else{
delete u.checked
}
},"upId")
this.show=true
})
},
commit(){
var list=[];
this.$refs.mytree.getCheckedAndIndeterminateNodes().map(u=>{
list.push({id:u.id,methodId:u.methodId|0,status:u.checked?1:0})
});
var url = `${systemUrl}/RoleMenu/AddRoleMenu`
//权限树
this.$api.post(`${url}`, { id: this.role.id ,list:list}).then((r) => {
if(r.success){
this.$Message.success("权限设置成功!")
}
})
}
}
,
watch:{
"role.id"(v){
this.loadRole();
}
}
}
</script>
<style scoped>
.roleMenu{
height: 400px;
overflow: auto;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment