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
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

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

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

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

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

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

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

  </a-card>
</template>

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

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

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