refactor: refs #8664 enhance CmrList component with query initialization and user parameters
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
76fa04f9b2
commit
393aebb06f
|
@ -1,7 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, computed, ref } from 'vue';
|
import { onBeforeMount, onMounted, computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { Notify } from 'quasar';
|
import { Notify } from 'quasar';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { toDateHourMin } from 'filters/index';
|
import { toDateHourMin } from 'filters/index';
|
||||||
import { useStateStore } from 'src/stores/useStateStore';
|
import { useStateStore } from 'src/stores/useStateStore';
|
||||||
|
@ -13,12 +14,21 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { getTokenMultimedia } = useSession();
|
const { getTokenMultimedia } = useSession();
|
||||||
const token = getTokenMultimedia();
|
const token = getTokenMultimedia();
|
||||||
const state = useStateStore();
|
const state = useStateStore();
|
||||||
const selectedRows = ref([]);
|
const selectedRows = ref([]);
|
||||||
const dataKey = 'CmrList';
|
const dataKey = 'CmrList';
|
||||||
|
const shipped = Date.vnNew();
|
||||||
|
shipped.setHours(0, 0, 0, 0);
|
||||||
|
shipped.setDate(shipped.getDate() - 1);
|
||||||
|
const userParams = {
|
||||||
|
shipped: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -75,9 +85,6 @@ const columns = computed(() => [
|
||||||
name: 'shipped',
|
name: 'shipped',
|
||||||
cardVisible: true,
|
cardVisible: true,
|
||||||
component: 'date',
|
component: 'date',
|
||||||
columnFilter: {
|
|
||||||
inWhere: true,
|
|
||||||
},
|
|
||||||
format: ({ shipped }) => toDateHourMin(shipped),
|
format: ({ shipped }) => toDateHourMin(shipped),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -90,6 +97,7 @@ const columns = computed(() => [
|
||||||
fields: ['id', 'name'],
|
fields: ['id', 'name'],
|
||||||
},
|
},
|
||||||
columnFilter: {
|
columnFilter: {
|
||||||
|
inWhere: true,
|
||||||
name: 'warehouseFk',
|
name: 'warehouseFk',
|
||||||
attrs: {
|
attrs: {
|
||||||
url: 'warehouses',
|
url: 'warehouses',
|
||||||
|
@ -112,8 +120,17 @@ const columns = computed(() => [
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
initializeFromQuery();
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => (state.rightDrawer = true));
|
onMounted(() => (state.rightDrawer = true));
|
||||||
|
|
||||||
|
const initializeFromQuery = () => {
|
||||||
|
const query = route.query.table ? JSON.parse(route.query.table) : {};
|
||||||
|
shipped.value = query.shipped || shipped.toISOString();
|
||||||
|
Object.assign(userParams, { shipped });
|
||||||
|
};
|
||||||
function getApiUrl() {
|
function getApiUrl() {
|
||||||
return new URL(window.location).origin;
|
return new URL(window.location).origin;
|
||||||
}
|
}
|
||||||
|
@ -158,6 +175,7 @@ function downloadPdfs() {
|
||||||
:data-key
|
:data-key
|
||||||
url="Cmrs/filter"
|
url="Cmrs/filter"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
|
:user-params="userParams"
|
||||||
default-mode="table"
|
default-mode="table"
|
||||||
v-model:selected="selectedRows"
|
v-model:selected="selectedRows"
|
||||||
table-height="85vh"
|
table-height="85vh"
|
||||||
|
|
Loading…
Reference in New Issue