PermissionList.vue 5.4 KB
Newer Older
1 2 3 4 5 6 7
<template>
  <a-card :bordered="false">

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button
8
        @click="batchDel"
9 10 11
        v-if="selectedRowKeys.length > 0"
        ghost
        type="primary"
12 13
        icon="delete">批量删除
      </a-button>
14 15 16 17 18 19
    </div>

    <!-- table区域-begin -->
    <div>

      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
20 21
        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>&nbsp;&nbsp;
22 23 24 25 26 27
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        :columns="columns"
        size="middle"
28
        :pagination="false"
29
        :dataSource="dataSource"
30
        :loading="loading"
31 32 33
        :expandedRowKeys="expandedRowKeys"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @expandedRowsChange="handleExpandedRowsChange">
34 35 36 37

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

38
          <a-divider type="vertical"/>
39 40
          <a-dropdown>
            <a class="ant-dropdown-link">
41
              更多 <a-icon type="down"/>
42 43 44 45 46
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a href="javascript:;" @click="handleDetail(record)">详情</a>
              </a-menu-item>
47 48 49
              <a-menu-item>
                <a href="javascript:;" @click="handleAddSub(record)">添加子菜单</a>
              </a-menu-item>
50
              <a-menu-item>
51
                <a href="javascript:;" @click="handleDataRule(record)">数据规则</a>
52 53
              </a-menu-item>

54 55 56
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
57 58 59 60 61
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
62
        <!-- 字符串超长截取省略号显示 -->
63
        <span slot="url" slot-scope="text">
64 65 66
          <j-ellipsis :value="text" :length="25"/>
        </span>
        <!-- 字符串超长截取省略号显示-->
67
        <span slot="component" slot-scope="text">
68 69
          <j-ellipsis :value="text"/>
        </span>
70 71 72 73 74
      </a-table>

    </div>
    <!-- table区域-end -->

75 76
    <permission-modal ref="modalForm" @ok="modalFormOk"></permission-modal>
    <permission-data-rule-list ref="PermissionDataRuleList" @ok="modalFormOk"></permission-data-rule-list>
77 78 79 80 81 82

  </a-card>
</template>

<script>
  import PermissionModal from './modules/PermissionModal'
83 84 85 86
  import { getPermissionList } from '@/api/api'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import PermissionDataRuleList from './PermissionDataRuleList'
  import JEllipsis from '@/components/jeecg/JEllipsis'
87 88

  const columns = [
89
    {
90 91 92
      title: '菜单名称',
      dataIndex: 'name',
      key: 'name'
93
    }, {
94 95 96
      title: '菜单类型',
      dataIndex: 'menuType',
      key: 'menuType',
97 98 99 100 101 102
      customRender: function(text) {
        if (text == 0) {
          return '菜单'
        } else if (text == 1) {
          return '菜单'
        } else if (text == 2) {
103
          return '按钮/权限'
104 105
        } else {
          return text
106 107 108 109 110 111 112 113 114
        }
      }
    },/*{
      title: '权限编码',
      dataIndex: 'perms',
      key: 'permissionCode',
    },*/{
      title: 'icon',
      dataIndex: 'icon',
115
      key: 'icon'
116 117 118 119 120
    },
    {
      title: '组件',
      dataIndex: 'component',
      key: 'component',
121
      scopedSlots: { customRender: 'component' }
122 123 124 125 126
    },
    {
      title: '路径',
      dataIndex: 'url',
      key: 'url',
127
      scopedSlots: { customRender: 'url' }
128 129 130 131
    },
    {
      title: '排序',
      dataIndex: 'sortNo',
132
      key: 'sortNo'
133 134 135 136 137
    },
    {
      title: '操作',
      dataIndex: 'action',
      scopedSlots: { customRender: 'action' },
138 139
      align: 'center',
      width: 150
140
    }
141
  ]
142 143

  export default {
144 145
    name: 'PermissionList',
    mixins: [JeecgListMixin],
146
    components: {
147 148 149
      PermissionDataRuleList,
      PermissionModal,
      JEllipsis
150
    },
151
    data() {
152 153 154
      return {
        description: '这是菜单管理页面',
        // 表头
155 156
        columns: columns,
        loading: false,
157 158
        // 展开的行,受控属性
        expandedRowKeys: [],
159 160 161 162 163
        url: {
          list: '/sys/permission/list',
          delete: '/sys/permission/delete',
          deleteBatch: '/sys/permission/deleteBatch'
        }
164 165 166
      }
    },
    methods: {
167 168 169 170 171 172
      loadData() {
        this.dataSource = []
        getPermissionList().then((res) => {
          if (res.success) {
            console.log(res.result)
            this.dataSource = res.result
173 174 175
          }
        })
      },
176 177 178
      // 打开数据规则编辑
      handleDataRule(record) {
        this.$refs.PermissionDataRuleList.edit(record)
179 180 181 182 183 184
      },
      handleAddSub(record) {
        this.$refs.modalForm.title = "添加子菜单";
        this.$refs.modalForm.localMenuType = 1;
        this.$refs.modalForm.disableSubmit = false;
        this.$refs.modalForm.edit({status:'1',permsType:'1',route:true,'parentId':record.id});
185 186 187 188
      },
      handleExpandedRowsChange(expandedRows) {
        this.expandedRowKeys = expandedRows
      },
189 190 191
    }
  }
</script>
192
<style scoped>
193
  @import '~@assets/less/common.less';
194
</style>