PermissionList.vue 5.1 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 31
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
32 33 34 35

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

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

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

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

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

  </a-card>
</template>

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

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

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