增加更多筛选项

This commit is contained in:
joylink_zhaoerwei 2024-09-24 16:42:11 +08:00
parent 5888422322
commit 4adcfacc12
4 changed files with 105 additions and 34 deletions

View File

@ -21,6 +21,14 @@ export const iscsStyleOption = [
}, },
]; ];
export const searchTscsStyleOption = [
{
label: '全部',
value: IscsStyle.UNKNOWN,
},
...iscsStyleOption,
];
export interface DraftItem { export interface DraftItem {
id: number; id: number;
name: string; name: string;
@ -34,7 +42,9 @@ export interface DraftItem {
updatedAt: string; updatedAt: string;
defaultReleaseDataName: string; defaultReleaseDataName: string;
} }
export interface IscsDataOptions {
style: IscsStyle;
}
export interface PagingQueryParams { export interface PagingQueryParams {
paging: { paging: {
page: number; page: number;
@ -42,9 +52,10 @@ export interface PagingQueryParams {
}; };
query: { query: {
dataType: DraftDataType; dataType: DraftDataType;
userId?: number; options?: IscsDataOptions;
name?: string; name?: string;
isShared?: boolean; isShared?: boolean;
userId?: number;
}; };
} }
export interface DraftIscsDataDto { export interface DraftIscsDataDto {
@ -52,9 +63,6 @@ export interface DraftIscsDataDto {
options: IscsDataOptions; options: IscsDataOptions;
} }
export interface IscsDataOptions {
style: IscsStyle;
}
export async function draftPageQuery( export async function draftPageQuery(
params: PagingQueryParams params: PagingQueryParams
): Promise<PageDto<DraftIscsDataDto>> { ): Promise<PageDto<DraftIscsDataDto>> {
@ -208,10 +216,7 @@ export function saveDraft(variables: { id: number; data: string }) {
* @param variables * @param variables
* @returns * @returns
*/ */
export async function saveAsDraft(variables: { export async function saveAsDraft(variables: { id: number; name: string }) {
id: number;
name: string;
}) {
const mutation = ` const mutation = `
mutation saveAsNewDraftData($id: Int,$name: String) { mutation saveAsNewDraftData($id: Int,$name: String) {
saveAsNewDraftData(id: $id,name: $name){ saveAsNewDraftData(id: $id,name: $name){

View File

@ -26,6 +26,7 @@ interface PagingQueryParams {
userId?: number; userId?: number;
name?: string; name?: string;
isPublished?: boolean; isPublished?: boolean;
options?: IscsDataOptions;
}; };
} }
export interface PublishIscsDataDto { export interface PublishIscsDataDto {

View File

@ -15,19 +15,35 @@
@request="onRequest" @request="onRequest"
> >
<template v-slot:top-right> <template v-slot:top-right>
<q-input <div class="q-gutter-md q-mt-none row justify-center items-start">
dense <q-input dense debounce="1000" v-model="filter.name" label="名称" />
debounce="1000" <q-select
v-model="filter.name" dense
label="名称" v-model="filter.iscsStyle"
></q-input> :options="searchTscsStyleOption"
<q-btn flat round color="primary" icon="search" /> emit-value
<q-btn map-options
color="primary" options-dense
v-if="route.name == 'iscsDraft'" class="ellipsis"
label="新建" label="ISCS风格"
@click="createFormShow = true" style="width: 130px"
/> />
<q-select
v-if="route.name == 'iscsDraft'"
dense
v-model="filter.isShared"
:options="isSharedOption"
class="ellipsis"
label="共享相关"
style="width: 130px"
/>
<q-btn
color="primary"
v-if="route.name == 'iscsDraft'"
label="新建"
@click="createFormShow = true"
/>
</div>
</template> </template>
<template v-slot:header-cell-name="props"> <template v-slot:header-cell-name="props">
<q-th :props="props"> <q-th :props="props">
@ -249,6 +265,7 @@ import {
sharedDraftPageQuery, sharedDraftPageQuery,
PagingQueryParams, PagingQueryParams,
iscsStyleOption, iscsStyleOption,
searchTscsStyleOption,
} from '../api/DraftApi'; } from '../api/DraftApi';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
@ -339,6 +356,8 @@ const tableRef = ref();
const rows = reactive([]); const rows = reactive([]);
const filter = reactive({ const filter = reactive({
name: '', name: '',
iscsStyle: IscsStyle.UNKNOWN,
isShared: '全部',
}); });
const loading = ref(false); const loading = ref(false);
const pagination = ref({ const pagination = ref({
@ -353,8 +372,6 @@ const pagination = ref({
let allRequestData: DraftIscsDataDto[] = []; let allRequestData: DraftIscsDataDto[] = [];
async function onRequest(props: any) { async function onRequest(props: any) {
const { page, rowsPerPage } = props.pagination; const { page, rowsPerPage } = props.pagination;
const filter = props.filter;
loading.value = true; loading.value = true;
const variables: PagingQueryParams = { const variables: PagingQueryParams = {
paging: { paging: {
@ -363,9 +380,19 @@ async function onRequest(props: any) {
}, },
query: { query: {
dataType: DraftDataType.ISCS, dataType: DraftDataType.ISCS,
name: filter.name,
}, },
}; };
if (filter.name) {
Object.assign(variables.query, { name: filter.name });
}
if (filter.iscsStyle) {
Object.assign(variables.query, { options: { style: filter.iscsStyle } });
}
if (filter.isShared !== '全部') {
Object.assign(variables.query, {
isShared: filter.isShared == '共享' ? true : false,
});
}
try { try {
let response: PageDto<DraftIscsDataDto>; let response: PageDto<DraftIscsDataDto>;
if (route.name == 'iscsDraft') { if (route.name == 'iscsDraft') {
@ -402,6 +429,9 @@ function getTypeName(row: DraftItem) {
return iscsStyleName || ''; return iscsStyleName || '';
} }
//
const isSharedOption = ['全部', '共享', '不共享'];
// //
const createFormShow = ref(false); const createFormShow = ref(false);
const createForm = reactive({ const createForm = reactive({

View File

@ -18,13 +18,28 @@
@request="onRequest" @request="onRequest"
> >
<template v-slot:top-right> <template v-slot:top-right>
<q-input <div class="q-gutter-md q-mt-none row justify-center items-start">
dense <q-input dense debounce="1000" v-model="filter.name" label="名称" />
debounce="1000" <q-select
v-model="filter.name" dense
label="名称" v-model="filter.iscsStyle"
></q-input> :options="searchTscsStyleOption"
<q-btn flat round color="primary" icon="search" /> emit-value
map-options
options-dense
class="ellipsis"
label="ISCS风格"
style="width: 130px"
/>
<q-select
dense
v-model="filter.isPublished"
:options="isPublishedOption"
class="ellipsis"
label="上下架"
style="width: 130px"
/>
</div>
</template> </template>
<template v-slot:header-cell-name="props"> <template v-slot:header-cell-name="props">
@ -141,7 +156,12 @@ import {
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { nextTick } from 'process'; import { nextTick } from 'process';
import { DraftDataType, iscsStyleOption } from 'src/api/DraftApi'; import {
DraftDataType,
IscsStyle,
iscsStyleOption,
searchTscsStyleOption,
} from 'src/api/DraftApi';
const route = useRoute(); const route = useRoute();
const $q = useQuasar(); const $q = useQuasar();
@ -210,6 +230,8 @@ const tableRef = ref();
const rows = reactive([]); const rows = reactive([]);
const filter = reactive({ const filter = reactive({
name: '', name: '',
iscsStyle: IscsStyle.UNKNOWN,
isPublished: '全部',
}); });
const loading = ref(false); const loading = ref(false);
const pagination = ref({ const pagination = ref({
@ -234,9 +256,19 @@ async function onRequest(props: any) {
}, },
query: { query: {
dataType: DraftDataType.ISCS, dataType: DraftDataType.ISCS,
name: filter.name,
}, },
}; };
if (filter.name) {
Object.assign(variables.query, { name: filter.name });
}
if (filter.iscsStyle) {
Object.assign(variables.query, { options: { style: filter.iscsStyle } });
}
if (filter.isPublished !== '全部') {
Object.assign(variables.query, {
isPublished: filter.isPublished == '上架' ? true : false,
});
}
try { try {
const response = await publishPageQuery(variables); const response = await publishPageQuery(variables);
pagination.value.rowsNumber = response.total; pagination.value.rowsNumber = response.total;
@ -268,6 +300,9 @@ function getTypeName(row: PublishItem) {
return iscsStyleName || ''; return iscsStyleName || '';
} }
//
const isPublishedOption = ['全部', '上架', '下架'];
// //
function dataReleaseFn(row: PublishItem) { function dataReleaseFn(row: PublishItem) {
if (row.isPublished) { if (row.isPublished) {