jws-frontend/src/components/05_quotation/QuotationCard.vue

253 lines
6.2 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { Icon } from '@iconify/vue/dist/iconify.js';
import { formatNumberDecimal } from 'src/stores/utils';
2024-10-28 10:17:12 +07:00
import BadgeComponent from 'components/BadgeComponent.vue';
import KebabAction from '../shared/KebabAction.vue';
2024-10-18 11:52:04 +07:00
import MainButton from '../button/MainButton.vue';
defineProps<{
title?: string;
code?: string;
amount?: number;
2024-10-25 18:10:36 +07:00
status?: string;
workerCount?: number;
workerMax?: number;
createdAt?: string;
validUntil?: string;
customerName?: string;
reporter?: string;
totalPrice?: number;
2024-10-11 12:07:15 +07:00
urgent?: boolean;
feat: menu request list (#75) * feat: i18n * feat: request list * refactor: hide stat transition on app.scss * feat: request list i18n * feat: request list => constants and main page * feat: add store * feat: add fetch data * feat: add utilities fn * feat: add store function / types * refactor: request list type * refactor: request list constants * refactor: quotation card => add customData and badge color props * feat: avatar group components * feat: request list group * refactor: request list => remove tab, add table data * feat: send search query * feat: add parameter * refactor: remove unused function * fix: rename component lits to list * feat: show stats from api * chore: cleanup * refactor: make it type safe * refactor: accept rotate flow id as parameter * feat: use page size component * feat: add component, data display & expansion product * feat: i18n * refactor: constants and request list table * refactor: type code, createdAt, updatedAt * refactor: utils function changThemeMode * feat: request list => view page * refactor: use type instead of infer from value * fix: function getEmployeeName att type * refactor: fetch work list * refactor: loop work list * feat: add i18n duty * feat: add form issue component * feat: add form issue section * fix: store error * refactor: edit by value * refactor: accept basic info from outside instead * feat: add status filter support on fetch * refactor: remove delete button * refactor: wording * feat/fix: request list i18n & constant * feat: document type * feat/refactor: request list => document expansion * refactor: doc expansion use FormGroupHead * refactor: fetch data based on id from route param * refactor: text area disable * feat: properties expansion display (mocking) * refactor: add document at product relation * refactor: edit get value product * feat: get workflow step to show on top * refactor: add type * refactor: add get attachment * refactor: add view attachment * refactor: edit file name * refactor: define props get hide icon * refactor: edit align row * refactor: by value table document * refactor: by value row table * feat: add independent ocr dialog * chore: clean up * refactor: accept more props and small adjustment * fix: error withDefault call * feat: accept default metadata when open * fix: typo * feat: add override hook when finish ocr * feat: reset state on open * feat: detect reader result is actually string * fix: variable name conflict * feat: properties to input component * feat: properties input in properties expansion * feat: properties expansion data (temporary) * refactor: add i18n status work * refactor: edit type work status and add step status * refactor: add edit status work * refactor: edit step work * refactor: properties data type * refactor: filter selected product & specific properties * feat: add emit event * refactor: change variable name for better understanding * refactor: hide step that no properties * refactor: work status type to validate * feat: work status color * refactor: key for filename * refactor: close expansion when change step * refactor: responsive meta data * refactor: product expansion responsive * fix: dark mode step text color * fix: document expansion table no data label * refactor: main page body bordered and overflow hidden * refactor: use utils function instead * refactor: add process * refactor: by value name * refactor: add upload file * refactor: upload file * refactor: by value * fix: option worker type * refactor: fetchRequestAttachment after edit * fix: metadata display * refactor: add class full-height * refactor: edit type * refactor: fetch file * refactor: by value visa * refactor: request list attributes type * fix: properties to input props (placeholder, readonly, disable) * feat: request list properties function * fix: error when no workflow * docs: update comment to fix indent * refactor: step type (attributes) * refactor: add attributes payload on editStatusRequestWork function * feat/refactor: functional form expansion/filter worklist * refactor: set attributes properties after submit * refactor: add request work ready status * feat: request list => form employee component * feat/refactor: form expansion select user/layout * fix: properties readonly --------- Co-authored-by: puriphatt <puriphat@frappet.com> Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
2024-11-22 18:02:03 +07:00
hidePreview?: boolean;
badgeColor?: string;
customData?: {
label: string;
value: string | number | unknown;
slotName?: string;
}[];
}>();
defineEmits<{
(e: 'view'): void;
(e: 'edit'): void;
(e: 'link'): void;
(e: 'upload'): void;
(e: 'delete'): void;
(e: 'example'): void;
(e: 'preview'): void;
}>();
2024-11-07 16:50:41 +07:00
const rand = Math.random();
</script>
<template>
2024-11-07 10:55:55 +07:00
<div
2024-11-07 11:45:24 +07:00
class="surface-1 rounded q-pa-sm quo-card bordered"
2024-11-07 10:55:55 +07:00
:class="{ 'urgent-card': urgent }"
:style="{ '--animation-delay': rand + 's' }"
2024-11-07 10:55:55 +07:00
>
<!-- SEC: header -->
<header class="row items-center no-wrap">
2024-11-07 11:45:24 +07:00
<div v-if="urgent" class="q-mr-sm" style="font-size: 90%">
<BadgeComponent
icon="mdi-fire"
:title="$t('general.urgent2')"
hsla-color="--gray-1-hsl"
hsla-background="--red-8-hsl"
solid
/>
</div>
2024-11-07 11:45:24 +07:00
<div class="q-mr-sm" style="font-size: 90%">
<BadgeComponent
:title="status"
feat: menu request list (#75) * feat: i18n * feat: request list * refactor: hide stat transition on app.scss * feat: request list i18n * feat: request list => constants and main page * feat: add store * feat: add fetch data * feat: add utilities fn * feat: add store function / types * refactor: request list type * refactor: request list constants * refactor: quotation card => add customData and badge color props * feat: avatar group components * feat: request list group * refactor: request list => remove tab, add table data * feat: send search query * feat: add parameter * refactor: remove unused function * fix: rename component lits to list * feat: show stats from api * chore: cleanup * refactor: make it type safe * refactor: accept rotate flow id as parameter * feat: use page size component * feat: add component, data display & expansion product * feat: i18n * refactor: constants and request list table * refactor: type code, createdAt, updatedAt * refactor: utils function changThemeMode * feat: request list => view page * refactor: use type instead of infer from value * fix: function getEmployeeName att type * refactor: fetch work list * refactor: loop work list * feat: add i18n duty * feat: add form issue component * feat: add form issue section * fix: store error * refactor: edit by value * refactor: accept basic info from outside instead * feat: add status filter support on fetch * refactor: remove delete button * refactor: wording * feat/fix: request list i18n & constant * feat: document type * feat/refactor: request list => document expansion * refactor: doc expansion use FormGroupHead * refactor: fetch data based on id from route param * refactor: text area disable * feat: properties expansion display (mocking) * refactor: add document at product relation * refactor: edit get value product * feat: get workflow step to show on top * refactor: add type * refactor: add get attachment * refactor: add view attachment * refactor: edit file name * refactor: define props get hide icon * refactor: edit align row * refactor: by value table document * refactor: by value row table * feat: add independent ocr dialog * chore: clean up * refactor: accept more props and small adjustment * fix: error withDefault call * feat: accept default metadata when open * fix: typo * feat: add override hook when finish ocr * feat: reset state on open * feat: detect reader result is actually string * fix: variable name conflict * feat: properties to input component * feat: properties input in properties expansion * feat: properties expansion data (temporary) * refactor: add i18n status work * refactor: edit type work status and add step status * refactor: add edit status work * refactor: edit step work * refactor: properties data type * refactor: filter selected product & specific properties * feat: add emit event * refactor: change variable name for better understanding * refactor: hide step that no properties * refactor: work status type to validate * feat: work status color * refactor: key for filename * refactor: close expansion when change step * refactor: responsive meta data * refactor: product expansion responsive * fix: dark mode step text color * fix: document expansion table no data label * refactor: main page body bordered and overflow hidden * refactor: use utils function instead * refactor: add process * refactor: by value name * refactor: add upload file * refactor: upload file * refactor: by value * fix: option worker type * refactor: fetchRequestAttachment after edit * fix: metadata display * refactor: add class full-height * refactor: edit type * refactor: fetch file * refactor: by value visa * refactor: request list attributes type * fix: properties to input props (placeholder, readonly, disable) * feat: request list properties function * fix: error when no workflow * docs: update comment to fix indent * refactor: step type (attributes) * refactor: add attributes payload on editStatusRequestWork function * feat/refactor: functional form expansion/filter worklist * refactor: set attributes properties after submit * refactor: add request work ready status * feat: request list => form employee component * feat/refactor: form expansion select user/layout * fix: properties readonly --------- Co-authored-by: puriphatt <puriphat@frappet.com> Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
2024-11-22 18:02:03 +07:00
:hsla-color="badgeColor || '--blue-6-hsl'"
2024-11-07 11:45:24 +07:00
:border="urgent"
/>
2024-11-07 10:55:55 +07:00
</div>
<nav class="col text-right">
2024-10-25 18:10:36 +07:00
<q-btn
feat: menu request list (#75) * feat: i18n * feat: request list * refactor: hide stat transition on app.scss * feat: request list i18n * feat: request list => constants and main page * feat: add store * feat: add fetch data * feat: add utilities fn * feat: add store function / types * refactor: request list type * refactor: request list constants * refactor: quotation card => add customData and badge color props * feat: avatar group components * feat: request list group * refactor: request list => remove tab, add table data * feat: send search query * feat: add parameter * refactor: remove unused function * fix: rename component lits to list * feat: show stats from api * chore: cleanup * refactor: make it type safe * refactor: accept rotate flow id as parameter * feat: use page size component * feat: add component, data display & expansion product * feat: i18n * refactor: constants and request list table * refactor: type code, createdAt, updatedAt * refactor: utils function changThemeMode * feat: request list => view page * refactor: use type instead of infer from value * fix: function getEmployeeName att type * refactor: fetch work list * refactor: loop work list * feat: add i18n duty * feat: add form issue component * feat: add form issue section * fix: store error * refactor: edit by value * refactor: accept basic info from outside instead * feat: add status filter support on fetch * refactor: remove delete button * refactor: wording * feat/fix: request list i18n & constant * feat: document type * feat/refactor: request list => document expansion * refactor: doc expansion use FormGroupHead * refactor: fetch data based on id from route param * refactor: text area disable * feat: properties expansion display (mocking) * refactor: add document at product relation * refactor: edit get value product * feat: get workflow step to show on top * refactor: add type * refactor: add get attachment * refactor: add view attachment * refactor: edit file name * refactor: define props get hide icon * refactor: edit align row * refactor: by value table document * refactor: by value row table * feat: add independent ocr dialog * chore: clean up * refactor: accept more props and small adjustment * fix: error withDefault call * feat: accept default metadata when open * fix: typo * feat: add override hook when finish ocr * feat: reset state on open * feat: detect reader result is actually string * fix: variable name conflict * feat: properties to input component * feat: properties input in properties expansion * feat: properties expansion data (temporary) * refactor: add i18n status work * refactor: edit type work status and add step status * refactor: add edit status work * refactor: edit step work * refactor: properties data type * refactor: filter selected product & specific properties * feat: add emit event * refactor: change variable name for better understanding * refactor: hide step that no properties * refactor: work status type to validate * feat: work status color * refactor: key for filename * refactor: close expansion when change step * refactor: responsive meta data * refactor: product expansion responsive * fix: dark mode step text color * fix: document expansion table no data label * refactor: main page body bordered and overflow hidden * refactor: use utils function instead * refactor: add process * refactor: by value name * refactor: add upload file * refactor: upload file * refactor: by value * fix: option worker type * refactor: fetchRequestAttachment after edit * fix: metadata display * refactor: add class full-height * refactor: edit type * refactor: fetch file * refactor: by value visa * refactor: request list attributes type * fix: properties to input props (placeholder, readonly, disable) * feat: request list properties function * fix: error when no workflow * docs: update comment to fix indent * refactor: step type (attributes) * refactor: add attributes payload on editStatusRequestWork function * feat/refactor: functional form expansion/filter worklist * refactor: set attributes properties after submit * refactor: add request work ready status * feat: request list => form employee component * feat/refactor: form expansion select user/layout * fix: properties readonly --------- Co-authored-by: puriphatt <puriphat@frappet.com> Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
2024-11-22 18:02:03 +07:00
v-if="!hidePreview"
2024-10-25 18:10:36 +07:00
flat
dense
rounded
icon="mdi-play-box-outline"
size="12px"
:title="$t('preview.doc')"
2024-10-25 18:10:36 +07:00
@click.stop="$emit('preview')"
/>
<q-btn
flat
dense
rounded
icon="mdi-eye-outline"
size="12px"
:title="$t('general.viewDetail')"
@click.stop="$emit('view')"
/>
<KebabAction
:idName="code"
status="ACTIVE"
2024-10-18 14:00:14 +07:00
hide-toggle
@view="$emit('view')"
@edit="$emit('edit')"
@link="$emit('link')"
@upload="$emit('upload')"
@delete="$emit('delete')"
/>
</nav>
</header>
2024-11-07 11:45:24 +07:00
<div class="ellipsis q-px-xs">
<b>{{ title || '-' }}</b>
<q-tooltip anchor="bottom start" self="top left">
{{ title || '-' }}
</q-tooltip>
</div>
2024-11-22 16:33:46 +07:00
<div class="ellipsis q-px-xs q-mb-sm app-text-muted" style="font-size: 80%">
2024-11-07 11:45:24 +07:00
{{ code || '-' }}
<q-tooltip anchor="bottom start" self="top left">
{{ title || '-' }}
</q-tooltip>
</div>
<!-- SEC: body -->
2024-11-07 11:45:24 +07:00
<section
class="rounded q-px-sm"
:class="{
'surface-1': urgent,
'surface-2': !urgent,
}"
>
feat: menu request list (#75) * feat: i18n * feat: request list * refactor: hide stat transition on app.scss * feat: request list i18n * feat: request list => constants and main page * feat: add store * feat: add fetch data * feat: add utilities fn * feat: add store function / types * refactor: request list type * refactor: request list constants * refactor: quotation card => add customData and badge color props * feat: avatar group components * feat: request list group * refactor: request list => remove tab, add table data * feat: send search query * feat: add parameter * refactor: remove unused function * fix: rename component lits to list * feat: show stats from api * chore: cleanup * refactor: make it type safe * refactor: accept rotate flow id as parameter * feat: use page size component * feat: add component, data display & expansion product * feat: i18n * refactor: constants and request list table * refactor: type code, createdAt, updatedAt * refactor: utils function changThemeMode * feat: request list => view page * refactor: use type instead of infer from value * fix: function getEmployeeName att type * refactor: fetch work list * refactor: loop work list * feat: add i18n duty * feat: add form issue component * feat: add form issue section * fix: store error * refactor: edit by value * refactor: accept basic info from outside instead * feat: add status filter support on fetch * refactor: remove delete button * refactor: wording * feat/fix: request list i18n & constant * feat: document type * feat/refactor: request list => document expansion * refactor: doc expansion use FormGroupHead * refactor: fetch data based on id from route param * refactor: text area disable * feat: properties expansion display (mocking) * refactor: add document at product relation * refactor: edit get value product * feat: get workflow step to show on top * refactor: add type * refactor: add get attachment * refactor: add view attachment * refactor: edit file name * refactor: define props get hide icon * refactor: edit align row * refactor: by value table document * refactor: by value row table * feat: add independent ocr dialog * chore: clean up * refactor: accept more props and small adjustment * fix: error withDefault call * feat: accept default metadata when open * fix: typo * feat: add override hook when finish ocr * feat: reset state on open * feat: detect reader result is actually string * fix: variable name conflict * feat: properties to input component * feat: properties input in properties expansion * feat: properties expansion data (temporary) * refactor: add i18n status work * refactor: edit type work status and add step status * refactor: add edit status work * refactor: edit step work * refactor: properties data type * refactor: filter selected product & specific properties * feat: add emit event * refactor: change variable name for better understanding * refactor: hide step that no properties * refactor: work status type to validate * feat: work status color * refactor: key for filename * refactor: close expansion when change step * refactor: responsive meta data * refactor: product expansion responsive * fix: dark mode step text color * fix: document expansion table no data label * refactor: main page body bordered and overflow hidden * refactor: use utils function instead * refactor: add process * refactor: by value name * refactor: add upload file * refactor: upload file * refactor: by value * fix: option worker type * refactor: fetchRequestAttachment after edit * fix: metadata display * refactor: add class full-height * refactor: edit type * refactor: fetch file * refactor: by value visa * refactor: request list attributes type * fix: properties to input props (placeholder, readonly, disable) * feat: request list properties function * fix: error when no workflow * docs: update comment to fix indent * refactor: step type (attributes) * refactor: add attributes payload on editStatusRequestWork function * feat/refactor: functional form expansion/filter worklist * refactor: set attributes properties after submit * refactor: add request work ready status * feat: request list => form employee component * feat/refactor: form expansion select user/layout * fix: properties readonly --------- Co-authored-by: puriphatt <puriphat@frappet.com> Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
2024-11-22 18:02:03 +07:00
<article
class="q-py-sm"
:class="{
row: $q.screen.gt.sm,
column: $q.screen.lt.sm,
}"
v-if="customData && customData?.length > 0"
>
<template v-for="cData in customData" :key="cData.label">
<template v-if="cData.slotName">
<slot :name="cData.slotName" :props="cData" />
</template>
<template v-else>
<div class="col-4 app-text-muted q-pr-sm">
{{ cData.label || '-' }}
</div>
<div class="col-8">{{ cData.value || '-' }}</div>
</template>
</template>
</article>
<article v-else class="row q-py-sm">
2024-11-07 10:55:55 +07:00
<div class="col-4 app-text-muted q-pr-sm">
{{ $t('quotation.customerName') }}
</div>
<div class="col-8">{{ customerName || '-' }}</div>
<div class="col-4 app-text-muted q-pr-sm">
{{ $t('quotation.actor') }}
</div>
<div class="col-8">{{ reporter || '-' }}</div>
<div class="col-4 app-text-muted q-pr-sm">
{{ $t('quotation.employee') }}
</div>
<div class="col-8">
<BadgeComponent
feat: menu request list (#75) * feat: i18n * feat: request list * refactor: hide stat transition on app.scss * feat: request list i18n * feat: request list => constants and main page * feat: add store * feat: add fetch data * feat: add utilities fn * feat: add store function / types * refactor: request list type * refactor: request list constants * refactor: quotation card => add customData and badge color props * feat: avatar group components * feat: request list group * refactor: request list => remove tab, add table data * feat: send search query * feat: add parameter * refactor: remove unused function * fix: rename component lits to list * feat: show stats from api * chore: cleanup * refactor: make it type safe * refactor: accept rotate flow id as parameter * feat: use page size component * feat: add component, data display & expansion product * feat: i18n * refactor: constants and request list table * refactor: type code, createdAt, updatedAt * refactor: utils function changThemeMode * feat: request list => view page * refactor: use type instead of infer from value * fix: function getEmployeeName att type * refactor: fetch work list * refactor: loop work list * feat: add i18n duty * feat: add form issue component * feat: add form issue section * fix: store error * refactor: edit by value * refactor: accept basic info from outside instead * feat: add status filter support on fetch * refactor: remove delete button * refactor: wording * feat/fix: request list i18n & constant * feat: document type * feat/refactor: request list => document expansion * refactor: doc expansion use FormGroupHead * refactor: fetch data based on id from route param * refactor: text area disable * feat: properties expansion display (mocking) * refactor: add document at product relation * refactor: edit get value product * feat: get workflow step to show on top * refactor: add type * refactor: add get attachment * refactor: add view attachment * refactor: edit file name * refactor: define props get hide icon * refactor: edit align row * refactor: by value table document * refactor: by value row table * feat: add independent ocr dialog * chore: clean up * refactor: accept more props and small adjustment * fix: error withDefault call * feat: accept default metadata when open * fix: typo * feat: add override hook when finish ocr * feat: reset state on open * feat: detect reader result is actually string * fix: variable name conflict * feat: properties to input component * feat: properties input in properties expansion * feat: properties expansion data (temporary) * refactor: add i18n status work * refactor: edit type work status and add step status * refactor: add edit status work * refactor: edit step work * refactor: properties data type * refactor: filter selected product & specific properties * feat: add emit event * refactor: change variable name for better understanding * refactor: hide step that no properties * refactor: work status type to validate * feat: work status color * refactor: key for filename * refactor: close expansion when change step * refactor: responsive meta data * refactor: product expansion responsive * fix: dark mode step text color * fix: document expansion table no data label * refactor: main page body bordered and overflow hidden * refactor: use utils function instead * refactor: add process * refactor: by value name * refactor: add upload file * refactor: upload file * refactor: by value * fix: option worker type * refactor: fetchRequestAttachment after edit * fix: metadata display * refactor: add class full-height * refactor: edit type * refactor: fetch file * refactor: by value visa * refactor: request list attributes type * fix: properties to input props (placeholder, readonly, disable) * feat: request list properties function * fix: error when no workflow * docs: update comment to fix indent * refactor: step type (attributes) * refactor: add attributes payload on editStatusRequestWork function * feat/refactor: functional form expansion/filter worklist * refactor: set attributes properties after submit * refactor: add request work ready status * feat: request list => form employee component * feat/refactor: form expansion select user/layout * fix: properties readonly --------- Co-authored-by: puriphatt <puriphat@frappet.com> Co-authored-by: Thanaphon Frappet <thanaphon@frappet.com>
2024-11-22 18:02:03 +07:00
:hsla-color="badgeColor"
2024-11-07 10:55:55 +07:00
icon="mdi-account-multiple-outline"
:title="[workerCount, workerMax].join(' / ')"
/>
</div>
<div class="col-4 app-text-muted q-pr-sm">
{{ $t('general.createdAt') }}
</div>
<div class="col-8">
{{ createdAt }}
</div>
<div class="col-4 app-text-muted q-pr-sm">
{{ $t('general.validUntil') }}
</div>
<div class="col-8">
{{ validUntil }}
</div>
<div class="col-4 app-text-muted q-pr-sm">
{{ $t('quotation.totalPrice') }}
</div>
<div class="col-8">
{{ formatNumberDecimal(totalPrice || 0, 2) }}
</div>
</article>
2024-10-25 18:10:36 +07:00
</section>
</div>
</template>
<style scoped>
.badge-card {
font-size: 12px;
color: hsla(var(--gray-0-hsl) / 1);
background: hsla(var(--_color) / 1);
}
.badge-card__fullAmountCash {
--_color: var(--red-6-hsl);
}
.badge-card__installmentsCash {
--_color: var(--blue-6-hsl);
}
.badge-card__fullAmountBill {
--_color: var(--jungle-8-hsl);
}
.badge-card__installmentsBill {
--_color: var(--purple-7-hsl);
}
.dark .badge-card__installmentsCash {
--_color: var(--blue-10-hsl);
}
span {
display: inline-block;
/*new:*/
line-height: 12px;
height: 12px;
}
2024-10-11 12:07:15 +07:00
2024-11-07 10:55:55 +07:00
.urgent-card {
--_color: var(--red-7-hsl);
2024-11-07 11:45:24 +07:00
background-color: hsla(var(--red-7-hsl) / 0.07) !important;
border: 0.5px solid var(--red-6) !important;
animation: status 1s infinite;
animation-delay: var(--animation-delay);
2024-11-07 10:55:55 +07:00
.code {
color: var(--red-6);
}
.tag {
font-size: 12px;
border-radius: var(--radius-2);
background: hsl(var(--red-7-hsl));
color: white;
-webkit-box-shadow: 0px 0px 6px 0px rgba(240, 62, 62, 1);
-moz-box-shadow: 0px 0px 6px 0px rgba(240, 62, 62, 1);
box-shadow: 0px 0px 6px 0px rgba(240, 62, 62, 1);
}
2024-10-11 12:07:15 +07:00
}
@keyframes status {
0% {
box-shadow: 0x 0px 0px hsla(var(--_color) / 1);
}
50% {
box-shadow: 0px 0px 1px 4px hsla(var(--_color) / 0.3);
}
100% {
box-shadow: 0px 0px 4px 12px hsla(var(--_color) / 0);
}
}
</style>