搜索结果列表页面开发
This commit is contained in:
226
src/views/Org/Repos/index copy.vue
Normal file
226
src/views/Org/Repos/index copy.vue
Normal file
@@ -0,0 +1,226 @@
|
||||
<!-- 组织列表 -->
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, watch, computed } from 'vue';
|
||||
import RepoItem from '@/components/RepoItem/index.vue';
|
||||
import { getOrgProjectList } from '@/api/org/index';
|
||||
import { reqCatch } from '@/utils/catch';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { dataHandler } from '@/components/RepoItem/datahandle';
|
||||
import * as types from '@/api/org/types';
|
||||
import { REPO_TYPES, SORT_TYPES } from '@/views/User/constant/const';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getOrgInfo } from '@/views/Org/hooks/orgInfo';
|
||||
import { orgInfoStore } from '@/stores/Org';
|
||||
import { emitEvent } from '@/utils/eventBus';
|
||||
import { starRepo, unstarRepo } from '@/api/repo';
|
||||
import { useUserInfo } from '@/views/User/hooks/useUserInfo';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { namespace, languageList, getOrglanguageList } = getOrgInfo();
|
||||
const orgSetting = reactive<Record<string, any>>({});
|
||||
const typesAry = ref(REPO_TYPES);
|
||||
const langsAry = computed(() => {
|
||||
return languageList.value.map(item => ({
|
||||
name: item.label,
|
||||
value: item.label
|
||||
}));
|
||||
});
|
||||
const sortsAry = ref(SORT_TYPES);
|
||||
|
||||
const state = reactive<{
|
||||
repoList: any,
|
||||
query: any,
|
||||
}>({
|
||||
repoList: [],
|
||||
query: {
|
||||
search: '',
|
||||
simple: false
|
||||
}
|
||||
});
|
||||
|
||||
const { isAdmin } = storeToRefs(orgInfoStore());
|
||||
|
||||
// 创建新项目跳转
|
||||
const naviTo = (name: string, params?: any) => {
|
||||
// 用于创建项目时组织的自动选择
|
||||
const { orgInfo } = orgInfoStore();
|
||||
router.push({ name, params });
|
||||
};
|
||||
|
||||
// 查询项目
|
||||
watch(() => orgSetting, () => {
|
||||
pager.pageIndex = 1;
|
||||
searchRepo();
|
||||
}, { deep: true, flush: 'post' });
|
||||
|
||||
// 获取项目
|
||||
const repoLoading = ref<boolean>(true);
|
||||
const pager = reactive({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
pageIndex: 1
|
||||
});
|
||||
const getOrgProjectListData = async() => {
|
||||
repoLoading.value = true;
|
||||
const params: types.commonGroupReqType = {
|
||||
orgId: namespace.value,
|
||||
page: pager.pageIndex,
|
||||
per_page: pager.pageSize,
|
||||
simple: false,
|
||||
include_subgroups: true,
|
||||
search: state.query.search.trim(),
|
||||
with_programming_language: orgSetting.language,
|
||||
visibility: orgSetting.type,
|
||||
order_by: orgSetting.order?.split(':')[0] || '',
|
||||
sort: orgSetting.order?.split(':')[1] || ''
|
||||
};
|
||||
const { data, error } = await reqCatch(getOrgProjectList, params);
|
||||
if (!error) {
|
||||
if (data) {
|
||||
pager.total = data.data.total;
|
||||
state.repoList = dataHandler(data?.data?.content) as any;
|
||||
state.repoList.forEach((item, index) => {
|
||||
Object.assign(item, {
|
||||
path_with_namespace: data?.data?.content[index].path_with_namespace,
|
||||
visibility: data?.data?.content[index].visibility
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
repoLoading.value = false;
|
||||
};
|
||||
// 每页条数变化
|
||||
const sizeChangeFun = (size: number) => {
|
||||
pager.pageIndex = 1;
|
||||
getOrgProjectListData();
|
||||
};
|
||||
const searchRepo = () => {
|
||||
pager.pageIndex = 1;
|
||||
getOrgProjectListData();
|
||||
};
|
||||
const inputFun = debounce(() => searchRepo(), 500);
|
||||
const pageIndexChangeFun = () => {
|
||||
getOrgProjectListData();
|
||||
};
|
||||
onMounted(async() => {
|
||||
getOrgProjectListData();
|
||||
getOrglanguageList(namespace.value);
|
||||
});
|
||||
|
||||
const { userInfo } = useUserInfo();
|
||||
const loading = ref(false);
|
||||
const toggleRepoStar = ({ id, isStar }) => {
|
||||
if (!userInfo || !userInfo.username) {
|
||||
emitEvent('login');
|
||||
return false;
|
||||
}
|
||||
if (loading.value) return false;
|
||||
loading.value = true;
|
||||
if (isStar) {
|
||||
unstarRepo({ repoId: id })
|
||||
.then(() => {
|
||||
getOrgProjectListData();
|
||||
}).finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
starRepo({ repoId: id })
|
||||
.then(() => {
|
||||
getOrgProjectListData();
|
||||
}).finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<div class="org-repos">
|
||||
<div class="org-repos-search mt-[14px]">
|
||||
<d-form layout="columns" :data="orgSetting">
|
||||
<d-form-item field="repoName" class="w-full">
|
||||
<d-input class="search-box flex-1" v-model="state.query.search" placeholder="搜索项目" @input="inputFun">
|
||||
<template #prefix>
|
||||
<Icon name="gt-search" />
|
||||
</template>
|
||||
</d-input>
|
||||
</d-form-item>
|
||||
<d-form-item field="repoDescription">
|
||||
<d-select class="sel-type horizon-sel" v-model="orgSetting.type" :options="typesAry" placeholder="选择类型" />
|
||||
</d-form-item>
|
||||
<d-form-item field="email">
|
||||
<d-select class="sel-lang horizon-sel" allow-clear v-model="orgSetting.language" :options="langsAry"
|
||||
placeholder="选择语言" />
|
||||
</d-form-item>
|
||||
<d-form-item field="location">
|
||||
<d-select class="sel-order horizon-sel" allow-clear v-model="orgSetting.order" :options="sortsAry"
|
||||
placeholder="选择排序" />
|
||||
</d-form-item>
|
||||
</d-form>
|
||||
<d-button v-if="isAdmin" icon="icon-add" variant="solid" color="primary" class="search-bar-create"
|
||||
@click="naviTo('newRepo')">新建项目</d-button>
|
||||
</div>
|
||||
<DataPanel class="org-repos-table g-content-card overflow-hidden" :loading="repoLoading && !state.repoList?.length"
|
||||
:empty="!state.repoList?.length" :card="false" skeleton>
|
||||
<div v-loading="repoLoading">
|
||||
<RepoItem v-for="(item, index) in state.repoList" :key="index" v-bind="item" @handleStar="({isStar}) => item.isStar = isStar">
|
||||
<template #right>
|
||||
<canvas height="60"></canvas>
|
||||
</template>
|
||||
</RepoItem>
|
||||
</div>
|
||||
</DataPanel>
|
||||
<d-pagination class="px-[20px] py-[20px] flex justify-center" :max-page="500" :page-size-options="[10, 20, 50]"
|
||||
auto-hide :total="pager.total" v-model:pageSize="pager.pageSize" v-model:pageIndex="pager.pageIndex"
|
||||
:can-view-total="true" :can-change-page-size="true" @page-index-change="pageIndexChangeFun"
|
||||
@page-size-change="sizeChangeFun" :max-items="5" />
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
@import 'devui-theme/styles-var/devui-var.scss';
|
||||
|
||||
.org-repos {
|
||||
|
||||
&-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
:deep(.devui-form) {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
:deep(.devui-form__label) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
// .search-box {
|
||||
// width: 100%;
|
||||
// }
|
||||
|
||||
.horizon-sel {
|
||||
width: 100px;
|
||||
margin-left: 10px;
|
||||
|
||||
:deep(.devui-select__selection) {
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.create-project {
|
||||
height: 32px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
&-table {
|
||||
margin-top: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
92
src/views/Org/Repos/index.vue
Normal file
92
src/views/Org/Repos/index.vue
Normal file
@@ -0,0 +1,92 @@
|
||||
<!-- 组织列表 -->
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import RepoList from './repoList.vue';
|
||||
import IssueList from '@/views/Org/Issue/index.vue';
|
||||
import MergeRequest from '@/views/Org/Merge/index.vue';
|
||||
const tabList:any[] = [
|
||||
{
|
||||
label: '项目',
|
||||
value: 0
|
||||
}, {
|
||||
label: 'issue',
|
||||
value: 1
|
||||
}, {
|
||||
label: 'Pull Request',
|
||||
value: 2
|
||||
}
|
||||
];
|
||||
const tabActive = ref(0);
|
||||
const handleTab = (item) => {
|
||||
tabActive.value = item.value;
|
||||
};
|
||||
const tabForm = ref(null);
|
||||
const pageDeploy = ref(null);
|
||||
</script>
|
||||
<template>
|
||||
<div class="org-repos">
|
||||
<Card style="padding:0;">
|
||||
<div>
|
||||
<div class="tabs flex items-center justify-between">
|
||||
<div class="tabs-nav flex items-center flex-shrink-0">
|
||||
<div v-for="tab in tabList" :key="tab.value" class="tabs-nav-option" :class="{active:tab.value === tabActive}" @click="handleTab(tab)"><span>{{tab.label}}</span></div>
|
||||
</div>
|
||||
<div class="right-search pr-3">
|
||||
<div ref="tabForm"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tabActive === 0"><RepoList :formElem="tabForm" :pageElem="pageDeploy"/></div>
|
||||
<div v-if="tabActive === 1"><IssueList :formElem="tabForm" :pageElem="pageDeploy"/></div>
|
||||
<div v-if="tabActive === 2"><MergeRequest :formElem="tabForm" :pageElem="pageDeploy"/></div>
|
||||
</div>
|
||||
</Card>
|
||||
<div ref="pageDeploy">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
.org-repos{
|
||||
.tabs{
|
||||
height: 60px;
|
||||
border-bottom: 1px solid var(--color-G300);
|
||||
.tabs-nav{
|
||||
.tabs-nav-option{
|
||||
line-height: 58px;
|
||||
color: var(--color-CG600);
|
||||
cursor: pointer;
|
||||
padding: 0 4px;
|
||||
margin: 0 12px;
|
||||
&::after{
|
||||
content: "";
|
||||
display: block;
|
||||
margin: auto;
|
||||
height: 2px;
|
||||
width: 0;
|
||||
background: transparent;
|
||||
// transition: width var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95)),background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95));
|
||||
}
|
||||
&.active{color:var(--color-G900);}
|
||||
&.active::after{
|
||||
content: "";
|
||||
display: block;
|
||||
margin: auto;
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
background: var(--color-G900);
|
||||
// transition: width var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95)),background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95));
|
||||
}
|
||||
&:hover::after{
|
||||
content: "";
|
||||
display: block;
|
||||
margin: auto;
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
background: var(--color-G900);
|
||||
//transition: width var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95)),background-color var(--devui-animation-duration-slow, .3s) var(--devui-animation-ease-in-out, cubic-bezier(.5, .05, .5, .95));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
248
src/views/Org/Repos/repoList.vue
Normal file
248
src/views/Org/Repos/repoList.vue
Normal file
@@ -0,0 +1,248 @@
|
||||
<!-- 组织列表 -->
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, onMounted, watch, computed } from 'vue';
|
||||
import RepoItem from '@/components/RepoItem/index.vue';
|
||||
import { getOrgProjectList } from '@/api/org/index';
|
||||
import { reqCatch } from '@/utils/catch';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { dataHandler } from '@/components/RepoItem/datahandle';
|
||||
import * as types from '@/api/org/types';
|
||||
import { REPO_TYPES, SORT_TYPES } from '@/views/User/constant/const';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getOrgInfo } from '@/views/Org/hooks/orgInfo';
|
||||
import { orgInfoStore } from '@/stores/Org';
|
||||
import { emitEvent } from '@/utils/eventBus';
|
||||
import { starRepo, unstarRepo } from '@/api/repo';
|
||||
import { useUserInfo } from '@/views/User/hooks/useUserInfo';
|
||||
import debounce from 'lodash/debounce';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { namespace, languageList, getOrglanguageList } = getOrgInfo();
|
||||
const orgSetting = reactive<Record<string, any>>({});
|
||||
const typesAry = ref(REPO_TYPES);
|
||||
const langsAry = computed(() => {
|
||||
return languageList.value.map(item => ({
|
||||
name: item.label,
|
||||
value: item.label
|
||||
}));
|
||||
});
|
||||
const sortsAry = ref(SORT_TYPES);
|
||||
|
||||
const state = reactive<{
|
||||
repoList: any,
|
||||
query: any,
|
||||
}>({
|
||||
repoList: [],
|
||||
query: {
|
||||
search: '',
|
||||
simple: false
|
||||
}
|
||||
});
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formElem: null|HTMLElement;
|
||||
pageElem: null|HTMLElement;
|
||||
}>(),
|
||||
{ formElem: null, pageElem: null }
|
||||
);
|
||||
const { isAdmin } = storeToRefs(orgInfoStore());
|
||||
|
||||
// 创建新项目跳转
|
||||
const naviTo = (name: string, params?: any) => {
|
||||
const query = {
|
||||
position: 'org_create'
|
||||
};
|
||||
// 用于创建项目时组织的自动选择
|
||||
const { orgInfo } = orgInfoStore();
|
||||
router.push({ name, params, query });
|
||||
};
|
||||
|
||||
// 查询项目
|
||||
watch(() => orgSetting, () => {
|
||||
pager.pageIndex = 1;
|
||||
searchRepo();
|
||||
}, { deep: true, flush: 'post' });
|
||||
|
||||
// 获取项目
|
||||
const repoLoading = ref<boolean>(true);
|
||||
const pager = reactive({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
pageIndex: 1
|
||||
});
|
||||
const getOrgProjectListData = async() => {
|
||||
repoLoading.value = true;
|
||||
const params: types.commonGroupReqType = {
|
||||
orgId: namespace.value,
|
||||
page: pager.pageIndex,
|
||||
per_page: pager.pageSize,
|
||||
simple: false,
|
||||
include_subgroups: true,
|
||||
search: state.query.search.trim(),
|
||||
with_programming_language: orgSetting.language,
|
||||
visibility: orgSetting.type,
|
||||
order_by: orgSetting.order?.split(':')[0] || '',
|
||||
sort: orgSetting.order?.split(':')[1] || ''
|
||||
};
|
||||
const { data, error } = await reqCatch(getOrgProjectList, params);
|
||||
repoLoading.value = false;
|
||||
if (!error) {
|
||||
if (data) {
|
||||
pager.total = data.data.total;
|
||||
state.repoList = dataHandler(data?.data?.content) as any;
|
||||
state.repoList.forEach((item, index) => {
|
||||
Object.assign(item, {
|
||||
path_with_namespace: data?.data?.content[index].path_with_namespace,
|
||||
visibility: data?.data?.content[index].visibility
|
||||
});
|
||||
if (item?.namespace?.parent_id) {
|
||||
item.title = item.namespace?.name + ' / ' + item.title;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
// 每页条数变化
|
||||
const sizeChangeFun = (size: number) => {
|
||||
pager.pageIndex = 1;
|
||||
getOrgProjectListData();
|
||||
};
|
||||
const searchRepo = () => {
|
||||
pager.pageIndex = 1;
|
||||
getOrgProjectListData();
|
||||
};
|
||||
const inputFun = debounce(() => searchRepo(), 500);
|
||||
const pageIndexChangeFun = () => {
|
||||
getOrgProjectListData();
|
||||
};
|
||||
onMounted(async() => {
|
||||
getOrgProjectListData();
|
||||
getOrglanguageList(namespace.value);
|
||||
});
|
||||
|
||||
const { userInfo } = useUserInfo();
|
||||
const loading = ref(false);
|
||||
const toggleRepoStar = ({ id, isStar }) => {
|
||||
if (!userInfo || !userInfo.username) {
|
||||
emitEvent('login', { triggerType: 'Star' });
|
||||
return false;
|
||||
}
|
||||
if (loading.value) return false;
|
||||
loading.value = true;
|
||||
if (isStar) {
|
||||
unstarRepo({ repoId: id })
|
||||
.then(() => {
|
||||
getOrgProjectListData();
|
||||
}).finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
} else {
|
||||
starRepo({ repoId: id })
|
||||
.then(() => {
|
||||
getOrgProjectListData();
|
||||
}).finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
const clearFilter = () => {
|
||||
state.query.search = '';
|
||||
searchRepo();
|
||||
};
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<div class="org-repos">
|
||||
<teleport v-if="props.formElem" :to="props.formElem">
|
||||
<div class="org-repos-search">
|
||||
<d-form layout="columns" :data="orgSetting">
|
||||
<d-form-item field="repoName">
|
||||
<d-input class="search-box" :maxlength="100" v-model="state.query.search" placeholder="搜索项目" @input="inputFun">
|
||||
<template #prefix>
|
||||
<Icon name="gt-search" />
|
||||
</template>
|
||||
<template #suffix>
|
||||
<span>{{state?.query?.search.length || 0}}/100</span>
|
||||
<Icon
|
||||
v-if="state?.query?.search.length"
|
||||
name="gt-reviewer-pass"
|
||||
@click="clearFilter"
|
||||
class="cursor-pointer"
|
||||
>
|
||||
</Icon>
|
||||
</template>
|
||||
</d-input>
|
||||
</d-form-item>
|
||||
<d-form-item field="repoDescription">
|
||||
<d-select class="sel-type horizon-sel" v-model="orgSetting.type" :options="typesAry" placeholder="选择类型" />
|
||||
</d-form-item>
|
||||
<d-form-item field="email">
|
||||
<d-select class="sel-lang horizon-sel" allow-clear v-model="orgSetting.language" :options="langsAry"
|
||||
placeholder="选择语言" />
|
||||
</d-form-item>
|
||||
<d-form-item field="location">
|
||||
<d-select class="sel-order horizon-sel" allow-clear v-model="orgSetting.order" :options="sortsAry"
|
||||
placeholder="选择排序" />
|
||||
</d-form-item>
|
||||
</d-form>
|
||||
<d-button v-if="isAdmin" icon="icon-add" variant="solid" color="primary" class="search-bar-create" @click="naviTo('newRepo')">新建项目</d-button>
|
||||
</div>
|
||||
</teleport>
|
||||
<DataPanel class="org-repos-table overflow-hidden" :loading="repoLoading && !state.repoList?.length"
|
||||
:empty="!state.repoList?.length" :card="false" skeleton>
|
||||
<div v-loading="repoLoading">
|
||||
<RepoItem v-for="(item, index) in state.repoList" :key="index" v-bind="item" @handleStar="({isStar}) => item.isStar = isStar">
|
||||
<template #right>
|
||||
<canvas height="60"></canvas>
|
||||
</template>
|
||||
</RepoItem>
|
||||
</div>
|
||||
</DataPanel>
|
||||
<teleport v-if="props.pageElem" :to="props.pageElem">
|
||||
<d-pagination class="px-[20px] py-[20px] flex justify-center" :max-page="500" :page-size-options="[10, 20, 50]"
|
||||
auto-hide :total="pager.total" v-model:pageSize="pager.pageSize" v-model:pageIndex="pager.pageIndex"
|
||||
:can-view-total="true" :can-change-page-size="true" @page-index-change="pageIndexChangeFun"
|
||||
@page-size-change="sizeChangeFun" :max-items="5" />
|
||||
</teleport>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
@import 'devui-theme/styles-var/devui-var.scss';
|
||||
|
||||
.org-repos {
|
||||
|
||||
&-search {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
:deep(.devui-form) {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
:deep(.devui-form__label) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.horizon-sel {
|
||||
width: 100px;
|
||||
margin-left: 10px;
|
||||
|
||||
:deep(.devui-select__selection) {
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.create-project {
|
||||
height: 32px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 4px;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user