Files
laws_weilai/jero-web/src/views/system/PermissionList.vue
T

229 lines
7.0 KiB
Java

<template>
<a-card :bordered="false">
<!-- 操作按钮区域 -->
<div class="table-operator">
<div @click="handleAdd" class="operator-text">
<a-icon type="plus"/>
{{$t('add')}}
</div>
<!-- <a-button @click="handleAdd" type="primary" icon="plus">{{$t('add')}}</a-button>-->
<!-- <a-button-->
<!-- @click="batchDel"-->
<!-- v-if="selectedRowKeys.length > 0"-->
<!-- ghost-->
<!-- type="primary"-->
<!-- icon="delete">{{$t('BatchDelete')}}-->
<!-- </a-button>-->
</div>
<!-- table区域-begin -->
<div>
<!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
<!-- <i class="anticon anticon-info-circle ant-alert-icon"></i>{{$t('selected')}}&nbsp;<a style="font-weight: 600">{{-->
<!-- selectedRowKeys.length }}</a>{{$t('term')}}-->
<!-- <a style="margin-left: 24px" @click="onClearSelected">{{$t('empty')}}</a>-->
<!-- </div>-->
<a-table
:columns="columns"
:scroll="{x: '100%'}"
size="middle"
:components="drag(columns,'columns')"
:pagination="false"
:dataSource="dataSource"
:loading="loading"
:expandedRowKeys="expandedRowKeys"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@expandedRowsChange="handleExpandedRowsChange">
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">{{$t('edit')}}</a>
<a-divider type="vertical"/>
<a-dropdown>
<a class="ant-dropdown-link">
{{$t('more')}} <a-icon type="down"/>
</a>
<a-menu slot="overlay">
<a-menu-item>
<a href="javascript:;" @click="handleDetail(record)">{{$t('details')}}</a>
</a-menu-item>
<a-menu-item>
<a href="javascript:;" @click="handleAddSub(record)">{{$t('AddSubordinate')}}</a>
</a-menu-item>
<a-menu-item>
<a href="javascript:;" @click="handleDataRule(record)">{{$t('DataRules')}}</a>
</a-menu-item>
<a-menu-item v-if="isTrue(record)">
<a-popconfirm :title="$t('areYouSure')" @confirm="() => handleDelete(record.id)">
<a>{{$t('delete')}}</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
<!-- 字符串超长截取省略号显示 -->
<span slot="url" slot-scope="text">
<j-ellipsis :value="text" :length="25"/>
</span>
<!-- 字符串超长截取省略号显示-->
<span slot="component" slot-scope="text">
<j-ellipsis :value="text"/>
</span>
</a-table>
</div>
<!-- table区域-end -->
<permission-modal ref="modalForm" @ok="modalFormOk"></permission-modal>
<permission-data-rule-list ref="PermissionDataRuleList" @ok="modalFormOk"></permission-data-rule-list>
</a-card>
</template>
<script>
import PermissionModal from './modules/PermissionModal'
import { getPermissionList } from '@/api/api'
import { JeroListMixin } from '@/mixins/JeroListMixin'
import PermissionDataRuleList from './PermissionDataRuleList'
import JEllipsis from '@/components/jero/JEllipsis'
import { ResizeHeader, ResizeColumnProvide } from '@/mixins/header'
export default {
name: 'PermissionList',
mixins: [JeroListMixin, ResizeHeader, ResizeColumnProvide],
components: {
PermissionDataRuleList,
PermissionModal,
JEllipsis
},
data() {
return {
description: this.$t('menuMnagementPage'),
// 表头
columns: [
{
title: this.$t('MenuName'),
dataIndex: 'name',
align: 'left',
key: 'name',
ellipsis: true,
width: 180
},
{
title: this.$t('MenuEnName'),
dataIndex: 'menuEn',
align: 'left',
key: 'menuEn',
ellipsis: true,
width: 180
},
{
title: 'icon',
dataIndex: 'icon',
align: 'left',
key: 'icon',
ellipsis: true,
width: 180
},
{
title: this.$t('assembly'),
dataIndex: 'component',
align: 'left',
key: 'component',
width: 240,
ellipsis: true,
scopedSlots: { customRender: 'component' }
},
{
title: this.$t('route'),
dataIndex: 'url',
align: 'left',
key: 'url',
width: 240,
ellipsis: true,
scopedSlots: { customRender: 'url' }
},
{
title: this.$t('sort'),
dataIndex: 'sortNo',
align: 'left',
width: 80,
ellipsis: true,
key: 'sortNo'
},
{
title: this.$t('operation'),
dataIndex: 'action',
fixed: 'right',
scopedSlots: { customRender: 'action' },
align: 'left',
width: 150
}
],
loading: false,
// 展开的行,受控属性
expandedRowKeys: [],
url: {
list: '/sys/permission/page',
delete: '/sys/permission/delete',
deleteBatch: '/sys/permission/deleteBatch'
}
}
},
computed: {
text: function() {
if (text == 0) {
return this.$t('menu')
} else if (text == 1) {
return this.$t('menu')
} else if (text == 2) {
return this.$t('ButtonsPermissions')
} else {
return text
}
}
},
methods: {
isTrue(record) {
if (record.id == '1580735287309119489' ||
record.id == '1580735611793059842' ||
record.id == '1580735965892980738' ||
record.id == '1580734309507805185' ||
record.id == '1580762600394469378') {
return false
}
return true
},
loadData() {
this.dataSource = []
getPermissionList().then((res) => {
if (res.success) {
console.log(res.result)
this.dataSource = res.result
}
})
},
// 打开数据规则编辑
handleDataRule(record) {
this.$refs.PermissionDataRuleList.edit(record)
},
handleAddSub(record) {
this.$refs.modalForm.title = this.$t('AddSubmenu')
this.$refs.modalForm.localMenuType = 1
this.$refs.modalForm.disableSubmit = false
this.$refs.modalForm.edit({ status: '1', permsType: '1', route: true, 'parentId': record.id })
},
handleExpandedRowsChange(expandedRows) {
this.expandedRowKeys = expandedRows
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>