123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="Cache" content="no-cache">
- <meta http-equiv="cache-control" content="no-cache, must-revalidate">
- <meta http-equiv="expires" content="0">
- <meta name="viewport"
- content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
-
- <title>部门管理</title>
- <link rel="stylesheet" href="../css/index.css">
- <link rel="stylesheet" href="../css/style.css">
- <link rel="stylesheet" href="../css/element.css">
- <script src="../js/vue.min.js"></script>
- <script src="../js/jquery.min.js"></script>
- <script src="../js/index.js"></script>
- <script src="../js/yz/init.js"></script>
- <script>
- checkLogin();
- </script>
- <style type="text/css">
- *{
- padding: 0;
- margin: 0;
- box-sizing: border-box;
- }
- body{
- padding: 10px;
- background-color: #040d32;
- }
- .search_ input {
- position: relative;
- width: 100%;
- height: 32px;
- line-height: 32px;
- border-radius: 4px;
- font-size: 14px;
- padding: 0 5px 0 25px;
- color: #dcdcdc;
- background-color: rgba(255, 255, 255, 0.2);
- border: 1px solid rgba(232, 232, 232, 0.3);
- }
- .search_ input::-webkit-input-placeholder {
- color: #dcdcdc;
- }
- .search_ .el-icon-search {
- position: absolute;
- left: 12px;
- top: 16px;
- color: #dcdcdc;
- }
- .elTable{
- width: 100%;
- border: 1px solid rgba(255, 255, 255, 0.2);
- }
- .el-table::before{
- height: 0;
- }
- .el-table::after{
- width: 0;
- }
- .el-table,.el-table__expanded-cell {
- color: #ddd;
- background-color: transparent !important;
- }
- .el-table tr,
- .el-table td {
- font-size: 14px;
- background-color: transparent !important;
- }
- .el-table td.el-table__cell,.el-table th.el-table__cell.is-leaf{
- border-bottom: 1px solid rgba(255, 255, 255, 0.2);
- }
- .el-table--border .el-table__cell{
- border-right: 1px solid rgba(255, 255, 255, 0.2);
- }
- .el-dialog__header{
- padding: 10px;
- }
- .el-dialog__title{
- font-size: 15px;
- }
- .el-dialog__headerbtn{
- top: 14px;
- }
- .el-dialog__body{
- padding: 10px;
- color: #fff;
- background-color: #082041;
- }
- .br{
- border: 1px solid rgba(255, 255, 255, 0.2);
- }
- .el-input__inner{
- height: 34px;
- line-height: 34px;
- }
- ._Form>div{
- border-bottom: 1px solid rgba(255, 255, 255, 0.2);
- }
- ._Form .formTxt{
- width: 100px;
- height: 60px;
- line-height: 60px;
- border-right: 1px solid rgba(255, 255, 255, 0.2);
- border-left: 1px solid rgba(255, 255, 255, 0.2);
- }
- ._Form .formInp{
- width: calc(100% - 100px);
- padding: 0 10px;
- }
- .el-input__inner{
- color: #ececec;
- border-color: transparent;
- background-color: rgba(255, 255, 255, 0.2);
- }
- .el-input__inner::-webkit-input-placeholder {
- color: #a1a1a1;
- }
- .el-select .el-input__inner::-webkit-input-placeholder {
- color: #ececec;
- }
- ._Form .el-radio{
- color: #fff;
- }
- .el-radio__input.is-checked .el-radio__inner,
- .el-checkbox__input.is-checked .el-checkbox__inner,
- .el-checkbox__input.is-indeterminate .el-checkbox__inner,
- .el-button--success{
- border-color: #39b54a;
- background: #39b54a;
- }
- .el-radio__input.is-checked+.el-radio__label{
- color: #39b54a;
- }
- .el-icon-arrow-right{
- color: #fff;
- }
- .el-select-dropdown__item{
- height: auto;
- }
- .el-tree{
- color: #fff;
- background-color: transparent;
- }
- .el-select-dropdown__item.hover, .el-select-dropdown__item:hover,
- .el-tree-node__content:hover,.el-tree-node:focus>.el-tree-node__content{
- background-color: transparent;
- }
- .el-popper[x-placement^=bottom] .popper__arrow::after{
- border-bottom-color: #707070;
- }
- .el-select-dropdown{
- background-color: #707070;
- }
- </style>
- </head>
- <body>
- <div id="app">
- <div>
- <div class="flex align-center margin-bottom-sm">
- <div>
- <el-input placeholder="请输入关键词" v-model="inpKey" @input="_Search">
- <i slot="prefix" class="el-input__icon el-icon-search"></i>
- </el-input>
- </div>
- <div class="tableTool">
- <el-button type="primary" size="small" class="margin-left-sm">查询</el-button>
- <el-button type="success" size="small" @click="newAdd">新增</el-button>
- </div>
- </div>
- <el-table
- :data="tableData"
- :header-cell-style="{background:'#082041',color:'#fff'}"
- class="elTable"
- row-key="menuId"
- border
- lazy
- load="load"
- :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
- <el-table-column align="center" prop="menuName" label="菜单名称"> </el-table-column>
- <el-table-column align="center" prop="icon" label="图标">
- <template slot-scope="scope">
- <i :class="'iconfont '+scope.row.icon"></i>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="perms" label="权限标识"> </el-table-column>
- <el-table-column align="center" prop="orderNum" label="排序"> </el-table-column>
- <el-table-column align="center" prop="path" label="页面路径"> </el-table-column>
- <el-table-column align="center" prop="status" label="状态">
- <template slot-scope="scope">
- <el-switch
- :value="scope.row.status == 0"
- disabled
- active-color="#13ce66"
- inactive-color="#ff4949">
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="createTime" label="创建时间"> </el-table-column>
- <el-table-column
- align="center"
- width="200"
- label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="newAdd(scope.row)" class="text-sray">
- <i class="el-icon-plus"></i>新增
- </el-button>
- <el-button type="text" size="small" @click="Edit(scope.row)" class="text-green">
- <i class="el-icon-edit"></i>编辑
- </el-button>
- <el-button type="text" size="small" @click="Delete(scope.row)" class="text-red">
- <i class="el-icon-delete"></i>删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-dialog title="部门信息" :visible.sync="dialogVisible" width="60%">
- <div class="br" style="text-align: center;">
- <div class="_Form">
- <div class="flex align-center">
- <div class="formTxt" style="border-left: none;">上级菜单</div>
- <div class="formInp">
- <el-select :placeholder="parentName.menuName" ref="conSelect" style="width: 100%;">
- <el-option>
- <el-tree
- ref="tree"
- node-key="id"
- :data="TreeData"
- :props="defaultProps"
- @node-click="nodeClick"
- />
- </el-option>
- </el-select>
- </div>
- </div>
- <div class="flex align-center">
- <div class="formTxt" style="border-left: none;">菜单类型</div>
- <div class="formInp text-left">
- <el-radio v-model="nowForm.menuType" label="M">目录</el-radio>
- <el-radio v-model="nowForm.menuType" label="C">菜单</el-radio>
- </div>
- </div>
- <div class="flex align-center">
- <div class="formTxt" style="border-left: none;">菜单图标</div>
- <div class="formInp"><el-input v-model="nowForm.icon" placeholder="菜单图标"></el-input></div>
- </div>
- <div class="flex align-center">
- <div class="flex-sub flex align-center">
- <div class="formTxt" style="border-left: none;"><span class="text-red">*</span>菜单名称</div>
- <div class="formInp"><el-input v-model="nowForm.menuName" placeholder="菜单名称"></el-input></div>
- </div>
- <div class="flex-sub flex align-center">
- <div class="formTxt">权限标识</div>
- <div class="formInp"><el-input v-model="nowForm.perms" placeholder="权限标识"></el-input></div>
- </div>
- </div>
- <div class="flex align-center">
- <div class="flex-sub flex align-center">
- <div class="formTxt" style="border-left: none;"><span class="text-red">*</span>页面路径</div>
- <div class="formInp"><el-input v-model="nowForm.path" placeholder="页面路径"></el-input></div>
- </div>
- <div class="flex-sub flex align-center">
- <div class="formTxt"><span class="text-red">*</span>显示顺序</div>
- <div class="formInp"><el-input type="number" min="0" v-model="nowForm.orderNum" placeholder="角色顺序"></el-input></div>
- </div>
- </div>
- <div class="flex align-center" style="border: none;">
- <div class="flex-sub flex align-center">
- <div class="formTxt" style="border-left: none;">显示状态</div>
- <div class="text-left formInp">
- <el-radio v-model="nowForm.visible" label="0">显示</el-radio>
- <el-radio v-model="nowForm.visible" label="1">隐藏</el-radio>
- </div>
- </div>
- <div class="flex-sub flex align-center">
- <div class="formTxt">状态</div>
- <div class="text-left formInp">
- <el-radio v-model="nowForm.status" label="0">正常</el-radio>
- <el-radio v-model="nowForm.status" label="1">停用</el-radio>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="padding-sm text-center">
- <el-button size="small" @click="dialogVisible = false;">取消</el-button>
- <el-button size="small" type="success" @click="conFirm">提交</el-button>
- </div>
- </el-dialog>
- </div>
- <script>
- var _this, dataObj=[];
- new Vue({
- el: '#app',
- data: function() {
- return {
- tableData: [],
- TreeData:[],
- nowForm:{
- icon: "",
- isCache: "0",
- isFrame: "1",
- menuName: "",
- menuType: "M",
- orderNum: "0",
- parentId: 0,
- path: "",
- status: "0",
- visible: "0",
- perms:""
- },
- dialogVisible:false,
- inpKey:"",
- defaultProps: {
- children: 'children',
- label: 'label'
- },
- parentName: {
- menuName: "请选择",
- menuId: ""
- }
- }
- },
- created() {
- _this = this;
- _this.getList();
- },
- methods: {
- getList() {
- let data1 = {
- pageNum:1,
- pageSize:100
- };
- let _opts = {
- url: "/system/menu/list",
- type:"GET"
- };
- tokenAjax(_opts, data1)
- .then(function(res) {
- if (res.code == 200) {
- _this.tableData = _this.getTrees(res.data, 0)
- _this.TreeData = [{
- id: 0,
- label: "主类目",
- menuName:"主类目",
- menuId:0,
- children:(res.data.length? _this.getTrees(res.data, 0):[])
- }];
- dataObj = res.data;
- }else{
- _this.$message.error(res.msg);
- }
- })
- },
- getTrees(data, parentId) {
- var tree = [];
- var temp;
- for (var i = 0; i < data.length; i++) {
- data[i].label = data[i].menuName;
- data[i].id = data[i].menuId;
- if (data[i].parentId == parentId) {
- var obj = data[i];
- temp = _this.getTrees(data, data[i].menuId);
- if (temp.length > 0) {
- obj.children = [...temp];
- }
- tree.push(obj);
- }
- }
- return tree;
- },
- _Search(_key){
- let newArr = [],_ovj = dataObj;
- if(_key == ""){
- newArr = dataObj;
- }else{
- for(var i=0;i<_ovj.length;i++){
- if( JSON.stringify(_ovj[i]).indexOf(_key) != -1){
- newArr.push(_ovj[i])
- }
- }
- }
- _this.tableData = _this.getTrees(newArr, 0);
- },
- newAdd(_row){
- if(_row.menuId != undefined){
- _this.parentName = {
- menuName: _row.menuName,
- menuId: _row.menuId
- };
- }else{
- _this.parentName = {
- menuName: _this.TreeData[0].menuName,
- menuId: _this.TreeData[0].menuId
- };
- }
- _this.nowForm = {
- icon:_row.menuId != undefined? "#":"",
- isCache: "0",
- isFrame: "1",
- menuName: "",
- menuType:_row.menuId != undefined?"C" :"M",
- orderNum: "0",
- parentId:_row.menuId != undefined? _row.menuId:0,
- path: "",
- status: "0",
- visible: "0",
- perms:""
- };
- _this.dialogVisible = true;
- },
- Edit(_row){
- let data1 = {};
- let _opts = {
- url: "/system/menu/" + _row.menuId,
- type:"GET"
- };
- tokenAjax(_opts, data1)
- .then(function(res) {
- if (res.code == 200) {
- if(_row.parentId == 0){
- _this.parentName = {
- menuName:"主类目",
- menuId:0,
- };
- }else{
- dataObj.forEach((it,ind)=>{
- if(it.menuId == _row.parentId){
- _this.parentName = {
- menuName: it.menuName,
- menuId: it.menuId
- };
- }
- })
- }
- _this.nowForm = res.data;
- _this.dialogVisible = true;
- }
- })
- },
- Delete(_row){
- _this.$confirm('是否确认删除编号为"'+_row.menuId+'"的数据项?', '温馨提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- let data1 = {};
- let _opts = {
- url: "/system/menu/"+_row.menuId,
- type:"DELETE"
- };
- tokenAjax(_opts, data1)
- .then(function(res) {
- if(res.code == 200){
- _this.$message({
- type: 'success',
- message: '删除成功!'
- });
- _this.getList();
- }else{
- _this.$message.error(res.msg);
- }
- })
- }).catch(() => {
-
- });
- },
- conFirm(){
- _this.nowForm.parentId = _this.parentName.menuId;
- if(_this.nowForm.menuName == ""){
- _this.$message({
- type: 'warning',
- message: "请输入菜单名称"
- });
- return;
- }
- if(_this.nowForm.path == ""&&_this.nowForm.menuType == "C"){
- _this.$message({
- type: 'warning',
- message: '请输入页面路径',
- })
- return;
- }
- let data1 = _this.nowForm;
- let _opts = {
- url:"/system/menu",
- type: _this.nowForm.menuId == undefined?"POST":"PUT"
- };
- tokenPostAjax(_opts,data1)
- .then(function(res){
- if(res.code == 200){
- _this.$message({
- type: 'success',
- message: '操作成功!'
- });
- _this.getList();
- _this.dialogVisible = false;
- }else{
- _this.$message.error(res.msg);
- }
- })
- },
- nodeClick(_e){
- _this.parentName = {
- menuName: _e.menuName,
- menuId: _e.menuId
- };
- this.$refs.conSelect.blur();
- }
- }
- })
- </script>
- </body>
-
- </html>
|