feat: refs #6123 refactor ZoneControl component by removing unused imports and optimizing column definitions
This commit is contained in:
parent
ff29f8b934
commit
01d380c57c
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useQuasar, date } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
|
|
||||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
@ -9,9 +9,6 @@ import FormModelPopup from 'components/FormModelPopup.vue';
|
||||||
import VnInputNumber from 'src/components/common/VnInput.vue';
|
import VnInputNumber from 'src/components/common/VnInput.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
|
||||||
import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue';
|
|
||||||
import TravelDescriptorProxy from '../Travel/Card/TravelDescriptorProxy.vue';
|
|
||||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
|
@ -24,88 +21,49 @@ const footer = ref({ bought: 0, reserve: 0 });
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
label: 'Id',
|
name: 'zoneFk',
|
||||||
name: 'id',
|
label: t('zone'),
|
||||||
isId: true,
|
isId: true,
|
||||||
columnFilter: false,
|
format: ({ name }, dashIfEmpty) => dashIfEmpty(name),
|
||||||
visible: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'left',
|
name: 'etd',
|
||||||
name: 'workerFk',
|
label: t('etd'),
|
||||||
label: t('entryStockBought.buyer'),
|
|
||||||
isTitle: true,
|
|
||||||
component: 'select',
|
|
||||||
isEditable: false,
|
|
||||||
cardVisible: true,
|
|
||||||
create: true,
|
|
||||||
attrs: {
|
|
||||||
url: 'TicketRequests/getItemTypeWorker',
|
|
||||||
fields: ['id', 'nickname'],
|
|
||||||
optionLabel: 'nickname',
|
|
||||||
sortBy: 'nickname ASC',
|
|
||||||
optionValue: 'id',
|
|
||||||
},
|
|
||||||
columnFilter: false,
|
|
||||||
width: '60%',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
align: 'center',
|
|
||||||
label: t('entryStockBought.reserve'),
|
|
||||||
name: 'reserve',
|
|
||||||
columnFilter: false,
|
|
||||||
create: true,
|
|
||||||
component: 'number',
|
|
||||||
summation: true,
|
|
||||||
format: ({ reserve }, dashIfEmpty) => dashIfEmpty(round(reserve)),
|
|
||||||
width: '20%',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
align: 'right',
|
|
||||||
label: t('entryStockBought.bought'),
|
|
||||||
name: 'bought',
|
|
||||||
summation: true,
|
|
||||||
cardVisible: true,
|
|
||||||
style: ({ reserve, bought }) => boughtStyle(bought, reserve),
|
|
||||||
columnFilter: false,
|
|
||||||
width: '20%',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('entryStockBought.date'),
|
|
||||||
name: 'dated',
|
|
||||||
component: 'date',
|
component: 'date',
|
||||||
visible: false,
|
|
||||||
create: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
align: 'center',
|
name: 'isLate',
|
||||||
name: 'tableActions',
|
label: t('isLate'),
|
||||||
actions: [
|
component: 'checkbox',
|
||||||
{
|
},
|
||||||
title: t('entryStockBought.viewMoreDetails'),
|
{
|
||||||
name: 'searchBtn',
|
name: 'isFull',
|
||||||
icon: 'search',
|
label: t('isFull'),
|
||||||
isPrimary: true,
|
component: 'checkbox',
|
||||||
action: (row) => {
|
},
|
||||||
quasar.dialog({
|
{
|
||||||
component: EntryStockBoughtDetail,
|
name: 'm3',
|
||||||
componentProps: {
|
label: t('m3'),
|
||||||
workerFk: row.workerFk,
|
component: 'number',
|
||||||
dated: filterDate.value.dated,
|
},
|
||||||
},
|
{
|
||||||
});
|
name: 'm3enc',
|
||||||
},
|
label: t('m3enc'),
|
||||||
},
|
component: 'number',
|
||||||
],
|
},
|
||||||
|
{
|
||||||
|
name: 'm3porEnc',
|
||||||
|
label: t('m3porEnc'),
|
||||||
|
component: 'number',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const fetchDataRef = ref();
|
const fetchDataRef = ref();
|
||||||
const travelDialogRef = ref(false);
|
const productionConfigDialogRef = ref(false);
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const productionConfig = ref();
|
const productionConfig = ref();
|
||||||
|
|
||||||
function openDialog() {
|
function openDialog() {
|
||||||
travelDialogRef.value = true;
|
productionConfigDialogRef.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFooter(data) {
|
function setFooter(data) {
|
||||||
|
@ -115,39 +73,6 @@ function setFooter(data) {
|
||||||
footer.value.reserve += row?.reserve;
|
footer.value.reserve += row?.reserve;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function round(value) {
|
|
||||||
return Math.round(value * 100) / 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
function boughtStyle(bought, reserve) {
|
|
||||||
return reserve < bought ? { color: 'var(--q-negative)' } : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
async function beforeSave(data, getChanges) {
|
|
||||||
const changes = data.creates;
|
|
||||||
if (!changes) return data;
|
|
||||||
const patchPromises = [];
|
|
||||||
|
|
||||||
for (const change of changes) {
|
|
||||||
if (change?.isReal === false && change?.reserve > 0) {
|
|
||||||
const postData = {
|
|
||||||
workerFk: change.workerFk,
|
|
||||||
reserve: change.reserve,
|
|
||||||
dated: filterDate.value.dated,
|
|
||||||
};
|
|
||||||
const promise = axios.post('StockBoughts', postData).catch((error) => {
|
|
||||||
console.error('Error processing change: ', change, error);
|
|
||||||
});
|
|
||||||
|
|
||||||
patchPromises.push(promise);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(patchPromises);
|
|
||||||
data.creates = [];
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnSubToolbar>
|
<VnSubToolbar>
|
||||||
|
@ -185,22 +110,24 @@ async function beforeSave(data, getChanges) {
|
||||||
</VnRow>
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
<QDialog v-model="travelDialogRef" :class="['vn-row', 'wrap']">
|
<QDialog v-model="productionConfigDialogRef" :class="['vn-row', 'wrap']">
|
||||||
<FormModelPopup
|
<FormModelPopup
|
||||||
model="ProductionConfigs"
|
url-update="ProductionConfigs/1"
|
||||||
:title="t('Production Config')"
|
:title="t('popUpTitle')"
|
||||||
:form-initial-data="productionConfig"
|
:form-initial-data="productionConfig"
|
||||||
@on-data-saved="fetchDataRef.fetch()"
|
@on-data-saved="fetchDataRef.fetch()"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data }">
|
<template #form-inputs="{ data }">
|
||||||
<VnInputNumber
|
<VnRow>
|
||||||
v-model="data.minTicketsToCloseZone"
|
<VnInputNumber
|
||||||
:label="t('minTicketsToCloseZone')"
|
v-model="data.minTicketsToCloseZone"
|
||||||
/>
|
:label="t('minTicketsToCloseZone')"
|
||||||
<VnCheckbox
|
/>
|
||||||
v-model="data.isZoneClosedByExpeditionActivated"
|
<VnCheckbox
|
||||||
:label="t('isZoneClosedByExpeditionActivated')"
|
v-model="data.isZoneClosedByExpeditionActivated"
|
||||||
/>
|
:label="t('isZoneClosedByExpeditionActivated')"
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</FormModelPopup>
|
</FormModelPopup>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
|
@ -208,11 +135,9 @@ async function beforeSave(data, getChanges) {
|
||||||
<div class="column items-center">
|
<div class="column items-center">
|
||||||
<VnTable
|
<VnTable
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
data-key="StockBoughts"
|
data-key="ZoneControl"
|
||||||
url="StockBoughts/getStockBought"
|
url="Zones/controlFilter"
|
||||||
:beforeSaveFn="beforeSave"
|
search-url="Zones/controlFilter"
|
||||||
save-url="StockBoughts/crud"
|
|
||||||
search-url="StockBoughts"
|
|
||||||
order="bought DESC"
|
order="bought DESC"
|
||||||
:is-editable="true"
|
:is-editable="true"
|
||||||
@on-fetch="
|
@on-fetch="
|
||||||
|
@ -229,25 +154,6 @@ async function beforeSave(data, getChanges) {
|
||||||
:user-params="{ dated: Date.vnNew() }"
|
:user-params="{ dated: Date.vnNew() }"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
<template #column-workerFk="{ row }">
|
|
||||||
<span class="link" @click.stop>
|
|
||||||
{{ row?.worker?.user?.nickname }}
|
|
||||||
<WorkerDescriptorProxy :id="row?.workerFk" />
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template #column-footer-reserve>
|
|
||||||
<span class="q-pr-xs">
|
|
||||||
{{ round(footer.reserve) }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template #column-footer-bought>
|
|
||||||
<span
|
|
||||||
:style="boughtStyle(footer?.bought, footer?.reserve)"
|
|
||||||
class="q-pr-xs"
|
|
||||||
>
|
|
||||||
{{ round(footer.bought) }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</VnTable>
|
</VnTable>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -256,9 +162,11 @@ async function beforeSave(data, getChanges) {
|
||||||
en:
|
en:
|
||||||
minTicketsToCloseZone: Min tickets to close
|
minTicketsToCloseZone: Min tickets to close
|
||||||
isZoneClosedByExpeditionActivated: Closed by expedition
|
isZoneClosedByExpeditionActivated: Closed by expedition
|
||||||
|
popUpTitle: Edit config
|
||||||
es:
|
es:
|
||||||
minTicketsToCloseZone: Tickets minimos para cerrar zona
|
minTicketsToCloseZone: Tickets minimos para cerrar zona
|
||||||
isZoneClosedByExpeditionActivated: Zona cerrada por expedición activada
|
isZoneClosedByExpeditionActivated: Zona cerrada por expedición activada
|
||||||
|
popUpTitle: Editar configuración
|
||||||
</i18n>
|
</i18n>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.table-container {
|
.table-container {
|
||||||
|
|
Loading…
Reference in New Issue