|
@@ -0,0 +1,167 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <ele-page flex-table>
|
|
|
|
|
+ <page-search @search="reload" />
|
|
|
|
|
+
|
|
|
|
|
+ <common-table
|
|
|
|
|
+ ref="pageRef"
|
|
|
|
|
+ :pageConfig="pageConfig"
|
|
|
|
|
+ :columns="columns"
|
|
|
|
|
+ :datasource="datasource"
|
|
|
|
|
+ :pagination="false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #toolbar>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ plain
|
|
|
|
|
+ :icon="PlusOutlined"
|
|
|
|
|
+ v-permission="'activation:bookActivationCodeRepository:updateRole'"
|
|
|
|
|
+ @click="handleUpdate()"
|
|
|
|
|
+ >
|
|
|
|
|
+ 新增
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
|
|
+ <template #repositories="{ row }">
|
|
|
|
|
+ <div v-if="row.repositories?.length" class="repo-tags">
|
|
|
|
|
+ <el-tag
|
|
|
|
|
+ v-for="item in row.repositories"
|
|
|
|
|
+ :key="item.id"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ class="repo-tag"
|
|
|
|
|
+ >
|
|
|
|
|
+ {{ item.repositoryName }}
|
|
|
|
|
+ </el-tag>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <span v-else>-</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
|
|
+ <template #action="{ row }">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ link
|
|
|
|
|
+ v-permission="'activation:bookActivationCodeRepository:updateRole'"
|
|
|
|
|
+ @click="handleUpdate(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 编辑
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </common-table>
|
|
|
|
|
+
|
|
|
|
|
+ <role-edit ref="editRef" @success="reload()" />
|
|
|
|
|
+ </ele-page>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script setup>
|
|
|
|
|
+ import { ref, reactive } from 'vue';
|
|
|
|
|
+ import { PlusOutlined } from '@/components/icons';
|
|
|
|
|
+ import CommonTable from '@/components/CommonPage/CommonTable.vue';
|
|
|
|
|
+ import pageSearch from './components/page-search.vue';
|
|
|
|
|
+ import roleEdit from './components/role-edit.vue';
|
|
|
|
|
+ import { listRepositoryRole } from '@/api/activation/repository';
|
|
|
|
|
+
|
|
|
|
|
+ defineOptions({ name: 'CodeRepositoryRole' });
|
|
|
|
|
+
|
|
|
|
|
+ const pageRef = ref(null);
|
|
|
|
|
+ const editRef = ref(null);
|
|
|
|
|
+ const roleList = ref([]);
|
|
|
|
|
+
|
|
|
|
|
+ const pageConfig = reactive({
|
|
|
|
|
+ fileName: '管理员仓库权限',
|
|
|
|
|
+ cacheKey: 'codeRepositoryRoleTable',
|
|
|
|
|
+ rowKey: 'userId'
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const columns = ref([
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '管理员',
|
|
|
|
|
+ prop: 'nickName',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ minWidth: 120,
|
|
|
|
|
+ formatter: (row) => row.nickName || '-'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '账号',
|
|
|
|
|
+ prop: 'userName',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ minWidth: 120,
|
|
|
|
|
+ formatter: (row) => row.userName || '-'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '仓库权限',
|
|
|
|
|
+ prop: 'repositories',
|
|
|
|
|
+ align: 'left',
|
|
|
|
|
+ minWidth: 280,
|
|
|
|
|
+ slot: 'repositories'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '操作人',
|
|
|
|
|
+ prop: 'operatorNickName',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ minWidth: 120,
|
|
|
|
|
+ formatter: (row) => row.operatorNickName || '-'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '操作时间',
|
|
|
|
|
+ prop: 'operatorTime',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ minWidth: 170,
|
|
|
|
|
+ formatter: (row) => row.operatorTime || row.updateTime || '-'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ columnKey: 'action',
|
|
|
|
|
+ label: '操作',
|
|
|
|
|
+ width: 120,
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ slot: 'action'
|
|
|
|
|
+ }
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ function matchKeyword(row, keyword) {
|
|
|
|
|
+ if (!keyword) return true;
|
|
|
|
|
+ const text = `${row.nickName || ''} ${row.userName || ''}`.toLowerCase();
|
|
|
|
|
+ return text.includes(keyword.toLowerCase());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function matchRepository(row, repositoryName) {
|
|
|
|
|
+ if (!repositoryName) return true;
|
|
|
|
|
+ return (row.repositories || []).some((item) =>
|
|
|
|
|
+ (item.repositoryName || '')
|
|
|
|
|
+ .toLowerCase()
|
|
|
|
|
+ .includes(repositoryName.toLowerCase())
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const datasource = ({ where }) => {
|
|
|
|
|
+ return listRepositoryRole().then((list) => {
|
|
|
|
|
+ roleList.value = list;
|
|
|
|
|
+ const keyword = (where?.keyword || '').trim();
|
|
|
|
|
+ const repositoryName = (where?.repositoryName || '').trim();
|
|
|
|
|
+ return list.filter(
|
|
|
|
|
+ (row) =>
|
|
|
|
|
+ matchKeyword(row, keyword) &&
|
|
|
|
|
+ matchRepository(row, repositoryName)
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ function reload(where) {
|
|
|
|
|
+ pageRef.value?.reload(where);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function handleUpdate(row) {
|
|
|
|
|
+ const assignedUserIds = roleList.value.map((item) => item.userId);
|
|
|
|
|
+ editRef.value?.handleOpen(row, assignedUserIds);
|
|
|
|
|
+ }
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+ .repo-tags {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-wrap: wrap;
|
|
|
|
|
+ gap: 6px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .repo-tag {
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+</style>
|