123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <div class="main-content__div">
- <!-- 列表 -->
- <div class="table-box__div" v-cloak v-loading="loadingFlag">
- <!-- 查询表单 -->
- <el-form :inline="true" class="demo-form-inline">
- <el-form-item>
- <el-button type="primary" size="small" @click="addClick">添加菜单</el-button>
- </el-form-item>
-
- </el-form>
- <el-table
- size="mini"
- :data="tableData"
- :empty-text="tableDataLoadingText"
- style="width: 100%;font-size: 15px;"
- :header-cell-style="{background:'#FAFAFA'}"
- >
- <el-table-column label="编号" width="150" prop="id"></el-table-column>
- <el-table-column label="菜单名称" prop="label" width="250"></el-table-column>
- <el-table-column label="路由地址" prop="url" width="200"></el-table-column>
- <el-table-column label="图标" prop="icon" width="200"></el-table-column>
- <el-table-column label="排序" prop="sort" width="200"></el-table-column>
- <el-table-column label="是否外链" width="200" prop="is_links">
- <template v-slot="{row}">
- <el-switch
- v-model="row.is_links"
- :active-value="1"
- :inactive-value="0"
- disabled
- ></el-switch>
- </template>
- </el-table-column>
- <el-table-column label="是否隐藏" width="200">
- <template v-slot="{row}">
-
- <el-switch
- v-model="row.hidden"
- :active-value="1"
- :inactive-value="0"
- disabled
- ></el-switch>
- </template>
- </el-table-column>
- <el-table-column prop="" label="操作" align="center" >
- <template v-slot="scope">
- <div style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
- <span class="btn " @click="nextClick(scope.row.id)">查看下级</span>
- <span class="btn" @click="updateClick(scope.row, scope.$index)">编辑</span>
- <span class="btn" @click="deleteAuthority(scope.row,scope.$index)">删除</span>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <div class="block" v-show="pagination" style="margin-top: 10px;float: right;">
- <el-pagination
- background
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-size="pageSize"
- layout="total, prev, pager, next, jumper"
- :total="parseInt(tableCount)">
- </el-pagination>
- </div>
- </div>
- </div>
- <Dialog title="温馨提示" content="您确认要删除该菜单吗?"
- @close="DialogShow = false"
- @submitSureClick="submitSureClickDel"
- @DialogFalse="DialogShow = false"
- :innerVisible="DialogShow">
- </Dialog>
- <DialogSlot
- title="添加/编辑"
- @close="menuDialogShow = false"
- @DialogClose="menuDialogShow = false"
- :innerVisible="menuDialogShow"
- @colesClick="menuDialogShow = false"
- >
- <editFrom
- @colesClick="menuDialogShow = false"
- :menuDataForm="menuDataForm"
- :isloading="isloading"
- @menuSubmitClick="menuSubmitClick"
- @closeDlg="closeDlg"
- >
- </editFrom>
- </DialogSlot>
- </template>
- <script>
- import Dialog from "../../components/dialog";
- import editFrom from "./components/edit";
- import DialogSlot from "../../components/DialogSlot";
- export default {
- components: {
- Dialog,
- editFrom,
- DialogSlot
- },
- data() {
- return {
- value:"1",
- // 菜单列表数据
- tableData: [],
- // 加载中数据提示
- tableDataLoadingText:"拼命加载中······",
- // 是否显示分页
- pagination:false,
- // 每页显示的条数
- pageSize:10,
- // 当前页
- currentPage:1,
- // 菜单列表数据总条数
- tableCount:0,
-
- loadingFlag: false,
- isShowSource: false, // 是否显示来源列
- id:0,
- DialogShow: false, //控制删除弹窗
- MenuId:'',
- MenuRowIndex:'',
- menuDataForm: {},
- menuTableData: [],
- isloading:false, //提交按钮状态
- menuDialogShow: false, // 控制保存弹窗
- }
- },
- mounted() {},
- methods: {
- // 获取菜单信息列表
- getList:function(){
- let _t = this;
- _t.loadingFlag = true;
- let parames = {
- 'page':this.currentPage,
- 'pageSize':this.pageSize,
- 'id':this.id
- }
- this.$api.authority.getMenuList(parames).then(res=>{
- _t.loadingFlag = false;
- if(res.code==200){
- if(res.data.rows.length==0){
- this.$message.error("没有下级了,休息一下吧!!!")
- return
- }
- _t.tableData = res.data.rows;
- _t.tableCount = res.data.count;
- // 总条数大于每页显示的条数时显示分页
- if( _t.tableCount > _t.pageSize ){
- _t.pagination = true;
- }
- if( _t.tableData.length==0 ){
- _t.tableDataLoadingText = "暂无数据";
- }
- }else{
- this.$message.error("查询失败")
- }
- })
- },
- // 点击翻页
- handleCurrentChange(val) {
- this.currentPage = val;
- this.getList();
- },
- // 查看下一级
- nextClick( id ){
- let _t = this;
- _t.id = id
- _t.currentPage = 1
- _t.pageSize = 10
- this.getList()
- },
- addClick(){
- this.menuDataForm = {}
- this.menuDialogShow = true
- },
- //更新菜单
- updateClick(row,index){
- console.log(row)
- this.menuDataForm = row
- this.rowIndex = index
- this.menuDialogShow = true
- },
- // menuDialogShow(){
- // this.isloading = false
- // },
- closeDlg(val){
- console.log("aaaaaa",val)
- this.menuDialogShow = false
- this.isloading = false
- },
- menuSubmitClick(data){
- let _t = this
- console.log("提交数据",data)
- let parames = data
- _t.isloading = true
- //有id更新,没有新增
- if(parames.id){
- this.$api.authority.updateMenu(parames).then(res=>{
- _t.loadingFlag = false;
- if(res.code==200){
- _t.tableData[_t.rowIndex] = parames
- console.log("修改成功")
- location.reload();
- }else{
- this.$message.error("修改失败")
- }
- this.menuDialogShow = false
- this.isloading = false
- })
- }else{
- this.$api.authority.addMenu(parames).then(res=>{
- _t.loadingFlag = false;
- if(res.code==200){
- console.log("创建成功")
- location.reload();
- }else{
- this.$message.error(res.message)
- }
- this.menuDialogShow = false
- this.isloading = false
- })
- }
-
- },
- //删除菜单
- deleteAuthority(row, index) {
- this.MenuId = row.id
- this.MenuRowIndex = index
- this.DialogShow = true
- },
- submitSureClickDel(row,index){
- let parames = {
- 'id':this.MenuId
- }
- this.$api.authority.delMenu(parames).then(res=>{
- if(res.code==200){
- this.DialogShow = false
- this.getList()
- }else{
- this.$message.error("查询失败")
- }
- })
- }
- },
- created() {
- this.getList();
- }
- }
- </script>
-
-
|