refactor: sort product is add
This commit is contained in:
parent
0d72c5eee6
commit
e7eb53dd57
3 changed files with 29 additions and 2 deletions
|
|
@ -6,6 +6,8 @@ import { Product } from 'stores/product-service/types';
|
||||||
|
|
||||||
import KebabAction from 'src/components/shared/KebabAction.vue';
|
import KebabAction from 'src/components/shared/KebabAction.vue';
|
||||||
|
|
||||||
|
import { MainButton } from 'components/button';
|
||||||
|
|
||||||
import useOptionStore from 'stores/options';
|
import useOptionStore from 'stores/options';
|
||||||
import { formatNumberDecimal } from 'stores/utils';
|
import { formatNumberDecimal } from 'stores/utils';
|
||||||
import { dateFormat } from 'src/utils/datetime';
|
import { dateFormat } from 'src/utils/datetime';
|
||||||
|
|
@ -14,6 +16,7 @@ const optionStore = useOptionStore();
|
||||||
const baseUrl = ref<string>(import.meta.env.VITE_API_BASE_URL);
|
const baseUrl = ref<string>(import.meta.env.VITE_API_BASE_URL);
|
||||||
|
|
||||||
const selectedItem = defineModel<Product[]>('selectedItem');
|
const selectedItem = defineModel<Product[]>('selectedItem');
|
||||||
|
const isSort = ref<boolean>(false);
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
|
@ -24,6 +27,7 @@ const props = withDefaults(
|
||||||
currentPage?: number;
|
currentPage?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
useKebabAction?: boolean;
|
useKebabAction?: boolean;
|
||||||
|
useSortAction?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
row: () => [],
|
row: () => [],
|
||||||
|
|
@ -42,6 +46,7 @@ defineEmits<{
|
||||||
(e: 'delete'): void;
|
(e: 'delete'): void;
|
||||||
(e: 'changeStatus'): void;
|
(e: 'changeStatus'): void;
|
||||||
(e: 'select', data: any): void;
|
(e: 'select', data: any): void;
|
||||||
|
(e: 'sort', isSort: boolean): void;
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -64,7 +69,17 @@ defineEmits<{
|
||||||
style="background-color: hsla(var(--info-bg) / 0.07)"
|
style="background-color: hsla(var(--info-bg) / 0.07)"
|
||||||
:props="props"
|
:props="props"
|
||||||
>
|
>
|
||||||
<q-th auto-width></q-th>
|
<q-th auto-width>
|
||||||
|
<!-- <MainButton
|
||||||
|
icon="mdi-sort"
|
||||||
|
color="0 0% 0%"
|
||||||
|
@click="
|
||||||
|
() => {
|
||||||
|
$emit('sort', (isSort = !isSort));
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/> -->
|
||||||
|
</q-th>
|
||||||
<template v-for="col in props.cols" :key="col.name" :props="props">
|
<template v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
<q-th>
|
<q-th>
|
||||||
{{ $t(col.label) }}
|
{{ $t(col.label) }}
|
||||||
|
|
|
||||||
|
|
@ -581,7 +581,10 @@ async function fetchListGroups() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListOfProductIsAdd(productGroupId: string) {
|
async function fetchListOfProductIsAdd(
|
||||||
|
productGroupId: string,
|
||||||
|
isSort?: boolean,
|
||||||
|
) {
|
||||||
const res = await fetchListProduct({
|
const res = await fetchListProduct({
|
||||||
status:
|
status:
|
||||||
currentStatus.value === 'INACTIVE'
|
currentStatus.value === 'INACTIVE'
|
||||||
|
|
@ -592,6 +595,8 @@ async function fetchListOfProductIsAdd(productGroupId: string) {
|
||||||
productGroupId,
|
productGroupId,
|
||||||
shared: true,
|
shared: true,
|
||||||
pageSize: 150,
|
pageSize: 150,
|
||||||
|
orderField: 'name',
|
||||||
|
orderBy: true ? 'asc' : 'desc',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
@ -3496,6 +3501,11 @@ watch(
|
||||||
:fieldSelected="tbControl.product.fieldSelected"
|
:fieldSelected="tbControl.product.fieldSelected"
|
||||||
:grid="modeViewIsAdd"
|
:grid="modeViewIsAdd"
|
||||||
v-model:selectedItem="selectProduct"
|
v-model:selectedItem="selectProduct"
|
||||||
|
@sort="
|
||||||
|
(isSort) => {
|
||||||
|
fetchListOfProductIsAdd(currentIdGroup, isSort);
|
||||||
|
}
|
||||||
|
"
|
||||||
@select="
|
@select="
|
||||||
(data) => {
|
(data) => {
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,8 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
productGroupId?: string;
|
productGroupId?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
shared?: boolean;
|
shared?: boolean;
|
||||||
|
orderField?: string;
|
||||||
|
orderBy?: 'asc' | 'desc';
|
||||||
}) {
|
}) {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue