From 7da3f132eafaa906890202d668c1c94e95fc0a81 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 24 Sep 2024 13:54:58 +0200 Subject: [PATCH] feat: refs #6321 update --- quasar.config.js | 12 +- src/boot/global-components.js | 13 + src/components/ui/VnStockValueDisplay.vue | 11 +- src/pages/Item/components/ItemProposal.vue | 97 +++--- .../Item/components/ItemProposalProxy.vue | 15 +- src/pages/Item/locale/en.yml | 1 + src/pages/Route/RouteList.vue | 313 ++---------------- .../Ticket/Negative/TicketLackDetail.vue | 9 +- src/pages/Ticket/Negative/TicketLackList.vue | 4 - src/pages/Ticket/Negative/TicketLackTable.vue | 11 +- 10 files changed, 119 insertions(+), 367 deletions(-) create mode 100644 src/boot/global-components.js diff --git a/quasar.config.js b/quasar.config.js index b59c62eeb..56b07bb0c 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -29,8 +29,16 @@ module.exports = configure(function (/* ctx */) { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli/boot-files - boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar', 'quasar.defaults'], - + boot: [ + 'i18n', + 'axios', + 'vnDate', + 'validations', + 'quasar', + 'quasar.defaults', + 'global-components', + ], + importStrategy: 'auto', // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css css: ['app.scss'], diff --git a/src/boot/global-components.js b/src/boot/global-components.js new file mode 100644 index 000000000..17e7a6c30 --- /dev/null +++ b/src/boot/global-components.js @@ -0,0 +1,13 @@ +// src/boot/global-components.js +import { defineAsyncComponent } from 'vue'; + +const components = import.meta.glob('src/components/**/*.vue'); +export default ({ app }) => { + for (const path in components) { + const componentName = path + .split('/') + .pop() + .replace(/\.\w+$/, ''); + app.component(componentName, defineAsyncComponent(components[path])); + } +}; diff --git a/src/components/ui/VnStockValueDisplay.vue b/src/components/ui/VnStockValueDisplay.vue index ac64d4c39..a0decfac0 100644 --- a/src/components/ui/VnStockValueDisplay.vue +++ b/src/components/ui/VnStockValueDisplay.vue @@ -17,8 +17,12 @@ const props = defineProps({ }, }); -const valueClass = computed(() => (props.value > 0 ? 'positive' : 'negative')); -const iconName = computed(() => (props.value > 0 ? 'arrow_upward' : 'arrow_downward')); +const valueClass = computed(() => + props.value === 0 ? 'neutral' : props.value > 0 ? 'positive' : 'negative' +); +const iconName = computed(() => + props.value === 0 ? 'equal' : props.value > 0 ? 'arrow_upward' : 'arrow_downward' +); const formattedValue = computed(() => props.value); @@ -29,6 +33,9 @@ const formattedValue = computed(() => props.value); .negative { color: red; } +.neutral { + color: orange; +} .value-icon { margin-right: 4px; } diff --git a/src/pages/Item/components/ItemProposal.vue b/src/pages/Item/components/ItemProposal.vue index a8b6c814c..1a818d47d 100644 --- a/src/pages/Item/components/ItemProposal.vue +++ b/src/pages/Item/components/ItemProposal.vue @@ -23,11 +23,6 @@ const gradientStyle = (value) => )}, ${colorSpacer} 10%)`; const $props = defineProps({ - item: { - type: Object, - required: true, - default: () => {}, - }, itemLack: { type: Object, required: true, @@ -38,7 +33,7 @@ const $props = defineProps({ required: false, default: false, }, - tickets: { + sales: { type: Array, required: false, default: () => [], @@ -47,15 +42,19 @@ const $props = defineProps({ const proposalSelected = ref([]); const quantity = ref(-1); const defaultColumnAttrs = { - align: 'left', + align: 'center', sortable: true, }; -const ticket = computed(() => $props.tickets[0]); +const ticket = computed(() => $props.sales[0]); const saleFk = computed(() => ticket.value.saleFk); const statusConditionalValue = (row) => { const total = MATCH_VALUES.reduce((acc, i) => acc + row[`match${i}`], 0); return total; }; +const popupProxyRef = ref(null); +const proposalTableRef = ref(null); +const emit = defineEmits(['onDialogClosed', 'itemReplaced']); + const conditionalValuePrice = (price) => (price > 1.3 ? 'match' : 'not-match'); const columns = computed(() => [ { @@ -63,18 +62,13 @@ const columns = computed(() => [ label: t('proposal.available'), name: 'available', field: 'available', - component: 'input', type: 'number', - class: 'shrink', }, { ...defaultColumnAttrs, label: t('proposal.difference'), name: 'difference', - component: 'input', - type: 'number', - class: 'shrink', - style: 'background-color:red;max-width: 75px', + style: 'max-width: 75px', }, { ...defaultColumnAttrs, @@ -88,9 +82,6 @@ const columns = computed(() => [ label: t('proposal.counter'), name: 'counter', field: 'counter', - component: 'input', - type: 'number', - class: 'shrink', }, { @@ -107,9 +98,6 @@ const columns = computed(() => [ ...defaultColumnAttrs, label: t('proposal.price2'), name: 'price2', - field: 'price2', - component: 'input', - type: 'number', class: 'shrink', }, { @@ -131,12 +119,18 @@ const columns = computed(() => [ async function confirm() { try { - const params = { - saleFk: saleFk.value, - newItemFK: proposalSelected.value[0].id, - quantity: quantity.value, - }; + // const params = { + // saleFk: saleFk.value, + // substitutionFk: proposalSelected.value[0].id, + // quantity: quantity.value, + // }; // const { data } = await axios.post('Sales/replaceItem', params); + const params = [saleFk.value, proposalSelected.value[0].id, quantity.value]; + const { data } = await axios.post('Applications/sale_replaceItem/execute-proc', { + schema: 'vn', + params, + }); + proposalTableRef.value.reload(); emit('itemReplaced', { type: 'refresh', itemProposal: proposalSelected.value[0], @@ -149,8 +143,6 @@ async function confirm() { } } // const { dialogRef, onDialogOK, onDialogCancel } = useDialogPluginComponent(); -const popupProxyRef = ref(null); -const emit = defineEmits(['onDialogClosed', 'itemReplaced']); // function onDialogClose() { // console.log('Dialog has been closed'); @@ -161,16 +153,20 @@ onUnmounted(() => {}); function handleSelection(value, _) { quantity.value = value.available; } -const isSelectionAvailable = (data) => { - if (!data?.row) return false; - const { row } = data; - return $props.replaceAction && row.available >= $props.itemLack.lack * -1; -}; +// const isSelectionAvailable = (data) => { +// if (!data?.row) return false; +// const { row } = data; +// return $props.replaceAction && row.available >= Math.abs($props.itemLack.lack); +// }; // watch(proposalSelected, ({ available }) => (quantity.value = available)); diff --git a/src/pages/Item/components/ItemProposalProxy.vue b/src/pages/Item/components/ItemProposalProxy.vue index 077e97208..48ce1e4d4 100644 --- a/src/pages/Item/components/ItemProposalProxy.vue +++ b/src/pages/Item/components/ItemProposalProxy.vue @@ -6,11 +6,6 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; const emit = defineEmits(['onDialogClosed', 'itemReplaced']); const $props = defineProps({ - item: { - type: Object, - required: true, - default: () => {}, - }, itemLack: { type: Object, required: true, @@ -21,7 +16,7 @@ const $props = defineProps({ required: false, default: false, }, - tickets: { + sales: { type: Array, required: false, default: () => [], @@ -37,12 +32,12 @@ const $props = defineProps({ - + - {{ item.longName }} - + {{ itemLack.longName }} + - + diff --git a/src/pages/Item/locale/en.yml b/src/pages/Item/locale/en.yml index 4ca1556af..fa18b499c 100644 --- a/src/pages/Item/locale/en.yml +++ b/src/pages/Item/locale/en.yml @@ -89,6 +89,7 @@ itemType: category: Category temperature: Temperature proposal: + difference: Difference title: Items proposal itemFk: Item longName: Name diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index 661525a51..b6c23f8ed 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -1,41 +1,20 @@ -