<template>
|
<GlobalWindow
|
class="handle-table-dialog"
|
:title="title"
|
:visible.sync="visible"
|
:confirm-working="isWorking"
|
@confirm="confirm"
|
>
|
<p class="tip" v-if="form.parentId != null && form.id == null">为 <em>{{parentName}}</em> 新建子菜单</p>
|
<el-form :model="form" ref="form" :rules="rules">
|
<el-form-item label="上级菜单" prop="parentId">
|
<MenuSelect v-if="visible" v-model="form.parentId" placeholder="请选择上级菜单" type="2" :exclude-id="excludeMenuId" clearable :inline="false"/>
|
</el-form-item>
|
<el-form-item label="菜单名称" prop="name" required>
|
<el-input v-model="form.name" placeholder="请输入菜单名称" v-trim maxlength="50"/>
|
</el-form-item>
|
<el-form-item label="访问路径" prop="path">
|
<el-input v-model="form.path" placeholder="请输入访问路径" v-trim maxlength="200"/>
|
</el-form-item>
|
<el-form-item label="图标" prop="icon" class="form-item-icon">
|
<div style="display: flex;">
|
<UploadAvatarImage
|
:file="{ 'imgurlfull': form.fullIcon, 'imgurl': form.icon }"
|
:uploadData="uploadData"
|
customStyle="width: 80px; height: 80px;"
|
tipsLabel="上传图标"
|
@uploadSuccess="uploadReverseSuccess"
|
@uploadEnd="isUploading=false"
|
@uploadBegin="isUploading=true"
|
/>
|
<div style="display: flex; flex-direction: column-reverse;" v-if="!!form.icon">
|
<el-button style="margin-left: 5px; padding: 0 5px;" type="text" @click="form.icon=''">删除</el-button>
|
</div>
|
</div>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input type="textarea" v-model="form.remark" placeholder="请输入菜单备注" v-trim :rows="3" maxlength="500"/>
|
</el-form-item>
|
</el-form>
|
</GlobalWindow>
|
</template>
|
|
<script>
|
import BaseOpera from '@/components/base/BaseOpera'
|
import GlobalWindow from '@/components/common/GlobalWindow'
|
import MenuSelect from '@/components/common/MenuSelect'
|
import UploadAvatarImage from '@/components/common/UploadAvatarImage.vue'
|
import icons from '@/utils/icons'
|
export default {
|
name: 'OperaMenuH5Window',
|
extends: BaseOpera,
|
components: { MenuSelect, GlobalWindow, UploadAvatarImage },
|
data () {
|
return {
|
icons,
|
isUploading: false,
|
// 上级菜单名称
|
parentName: '',
|
// 需排除选择的菜单ID
|
excludeMenuId: null,
|
uploadData: {
|
floader: 'company/menu'
|
},
|
parent: {},
|
// 表单数据
|
form: {
|
id: null,
|
parentId: null,
|
name: '',
|
path: '',
|
icon: '',
|
fullIcon: '',
|
remark: '',
|
type: '2'
|
},
|
// 验证规则
|
rules: {
|
name: [
|
{ required: true, message: '请输入菜单名称' }
|
]
|
}
|
}
|
},
|
|
created () {
|
this.config({
|
api: '/system/menu'
|
})
|
},
|
methods: {
|
/**
|
* @title: 窗口标题
|
* @target: 编辑的菜单对象
|
* @parent: 新建时的上级菜单
|
* @type: 0平台 1、企业 2、h5
|
*/
|
open (title, target, parent) {
|
debugger
|
this.title = title
|
|
console.log('-----',parent);
|
this.visible = true
|
// 新建,menu为空时表示新建菜单
|
if (target == null) {
|
this.excludeMenuId = null
|
this.$nextTick(() => {
|
this.$refs.form.resetFields()
|
this.parent = parent
|
this.form.id = null
|
this.form.parentId = parent == null ? null : parent.id
|
this.parentName = parent == null ? null : parent.name
|
})
|
return
|
}
|
// 编辑
|
this.$nextTick(() => {
|
this.excludeMenuId = target.id
|
for (const key in this.form) {
|
this.form[key] = target[key]
|
}
|
this.form.fullIcon = !!target.icon ? (target.resourcePath + target.icon) : ''
|
})
|
},
|
uploadReverseSuccess(file) {
|
this.form.icon = file.imgurl;
|
this.form.fullIcon = file.imgurlfull;
|
}
|
},
|
}
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/assets/style/variables";
|
$icon-background-color: $primary-color;
|
.global-window {
|
.tip {
|
margin-bottom: 12px;
|
em {
|
font-style: normal;
|
color: $primary-color;
|
font-weight: bold;
|
}
|
}
|
// 图标
|
::v-deep .form-item-icon {
|
.el-form-item__content {
|
height: 193px;
|
overflow-y: auto;
|
}
|
.el-radio-group {
|
background: $icon-background-color;
|
padding: 4px;
|
.el-radio {
|
margin-right: 0;
|
color: #fff;
|
padding: 6px;
|
&.is-checked {
|
background: $primary-color-sel;
|
border-radius: 10px;
|
}
|
.el-radio__input.is-checked + .el-radio__label {
|
color: #fff;
|
}
|
}
|
.el-radio__input {
|
display: none;
|
}
|
.el-radio__label {
|
padding-left: 0;
|
// element-ui图标
|
i {
|
font-size: 30px;
|
}
|
// 自定义图标
|
[class^="eva-icon-"], [class*=" eva-icon-"] {
|
width: 30px;
|
height: 30px;
|
background-size: 25px;
|
vertical-align: bottom;
|
}
|
}
|
.el-radio--small {
|
height: auto;
|
padding: 8px;
|
margin-left: 0;
|
}
|
}
|
}
|
}
|
</style>
|