fix: service use utils function & confirm delete
This commit is contained in:
parent
1822051a78
commit
44cd753fc3
3 changed files with 277 additions and 247 deletions
|
|
@ -1,7 +1,12 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { moveItemUp, moveItemDown, deleteItem, dialog } from 'src/stores/utils';
|
||||||
|
|
||||||
import NoData from 'src/components/NoData.vue';
|
import NoData from 'src/components/NoData.vue';
|
||||||
import WorkManagementComponent from './WorkManagementComponent.vue';
|
import WorkManagementComponent from './WorkManagementComponent.vue';
|
||||||
import { ref } from 'vue';
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
const serviceName = defineModel<string>('serviceName');
|
const serviceName = defineModel<string>('serviceName');
|
||||||
|
|
||||||
|
|
@ -14,7 +19,7 @@ const workItems = ref([
|
||||||
label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี',
|
label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี',
|
||||||
labelEn: '2 year work permit fee',
|
labelEn: '2 year work permit fee',
|
||||||
code: 'AC101',
|
code: 'AC101',
|
||||||
price: '1,200.00',
|
price: 1200,
|
||||||
time: '14',
|
time: '14',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -27,7 +32,7 @@ const workItems = ref([
|
||||||
label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี',
|
label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี',
|
||||||
labelEn: '2 year work permit fee',
|
labelEn: '2 year work permit fee',
|
||||||
code: 'AC101',
|
code: 'AC101',
|
||||||
price: '1,200.00',
|
price: 1200,
|
||||||
time: '14',
|
time: '14',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -37,7 +42,7 @@ const workItems = ref([
|
||||||
labelEn:
|
labelEn:
|
||||||
'Service and processing fees for submitting a work permit application on behalf of an MOU foreign worker',
|
'Service and processing fees for submitting a work permit application on behalf of an MOU foreign worker',
|
||||||
code: 'AC102',
|
code: 'AC102',
|
||||||
price: '1,200.00',
|
price: 1200,
|
||||||
time: '14',
|
time: '14',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -56,6 +61,28 @@ defineEmits<{
|
||||||
(e: 'deleteWork'): void;
|
(e: 'deleteWork'): void;
|
||||||
(e: 'deleteProduct'): void;
|
(e: 'deleteProduct'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
function addWork() {
|
||||||
|
console.log('hi');
|
||||||
|
workItems.value.push({
|
||||||
|
id: '',
|
||||||
|
product: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmDelete(items: unknown[], index: number) {
|
||||||
|
dialog({
|
||||||
|
color: 'negative',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: t('deleteConfirmTitle'),
|
||||||
|
actionText: t('delete'),
|
||||||
|
message: t('deleteConfirmMessage'),
|
||||||
|
action: async () => {
|
||||||
|
deleteItem(items, index);
|
||||||
|
},
|
||||||
|
cancel: () => {},
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -70,14 +97,11 @@ defineEmits<{
|
||||||
padding="0"
|
padding="0"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
|
@click="addWork"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <div class="col row rounded bordered surface-2 justify-center items-center">
|
<div v-if="workItems.length > 0" class="col q-gutter-y-md">
|
||||||
<NoData />
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
<div class="col q-gutter-y-md">
|
|
||||||
<WorkManagementComponent
|
<WorkManagementComponent
|
||||||
v-for="(work, index) in workItems"
|
v-for="(work, index) in workItems"
|
||||||
:key="work.id"
|
:key="work.id"
|
||||||
|
|
@ -85,9 +109,21 @@ defineEmits<{
|
||||||
:length="workItems.length"
|
:length="workItems.length"
|
||||||
:workIndex="index"
|
:workIndex="index"
|
||||||
v-model:product-items="work.product"
|
v-model:product-items="work.product"
|
||||||
@addProduct="$emit('addProduct')"
|
@move-work-up="moveItemUp(workItems, index)"
|
||||||
|
@move-work-down="moveItemDown(workItems, index)"
|
||||||
|
@delete-work="confirmDelete(workItems, index)"
|
||||||
|
@move-product-up="moveItemUp"
|
||||||
|
@move-product-down="moveItemDown"
|
||||||
|
@delete-product="confirmDelete"
|
||||||
></WorkManagementComponent>
|
></WorkManagementComponent>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="col row rounded bordered surface-2 justify-center items-center"
|
||||||
|
>
|
||||||
|
<NoData />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,24 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
import { Option } from 'src/stores/options/types';
|
import { Option } from 'src/stores/options/types';
|
||||||
import { ref, watch } from 'vue';
|
import { Attributes } from 'src/stores/product-service/types';
|
||||||
import { Attributes, AdditionalType } from 'src/stores/product-service/types';
|
import { moveItemUp, moveItemDown, deleteItem, dialog } from 'src/stores/utils';
|
||||||
|
|
||||||
import NoData from '../NoData.vue';
|
import NoData from '../NoData.vue';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
const propertiesOption = defineModel<Option[]>('propertiesOption');
|
const propertiesOption = defineModel<Option[]>('propertiesOption');
|
||||||
const formServiceProperties = defineModel<Attributes>('formServiceProperties');
|
const formServiceProperties = defineModel<Attributes>('formServiceProperties');
|
||||||
|
|
||||||
const telMax = ref();
|
const telMax = ref();
|
||||||
const pointNum = ref();
|
const pointNum = ref();
|
||||||
|
|
||||||
const selectAll = ref(false);
|
|
||||||
|
|
||||||
const tel = ref(false);
|
const tel = ref(false);
|
||||||
const comma = ref(false);
|
const comma = ref(false);
|
||||||
const point = ref(false);
|
const point = ref(false);
|
||||||
|
const selection = ref(false);
|
||||||
|
|
||||||
const typeOption = ref([
|
const typeOption = ref([
|
||||||
{
|
{
|
||||||
|
|
@ -36,25 +40,13 @@ const typeOption = ref([
|
||||||
icon: 'mdi-calendar-blank-outline',
|
icon: 'mdi-calendar-blank-outline',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'List',
|
label: 'Selection',
|
||||||
value: 'array',
|
value: 'array',
|
||||||
color: 'var(--indigo-7-hsl)',
|
color: 'var(--indigo-7-hsl)',
|
||||||
icon: 'mdi-code-array',
|
icon: 'mdi-code-array',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
watch(
|
|
||||||
() => selectAll.value,
|
|
||||||
() => {
|
|
||||||
if (selectAll.value) {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
defineEmits<{
|
|
||||||
(e: 'addProperties'): void;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
function manageProperties(properties?: string) {
|
function manageProperties(properties?: string) {
|
||||||
if (properties === 'all' && propertiesOption.value) {
|
if (properties === 'all' && propertiesOption.value) {
|
||||||
if (
|
if (
|
||||||
|
|
@ -94,13 +86,6 @@ function manageProperties(properties?: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteItem(index: number) {
|
|
||||||
if (!formServiceProperties.value) return;
|
|
||||||
if (index >= 0 && index < formServiceProperties.value.additional.length) {
|
|
||||||
formServiceProperties.value.additional.splice(index, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shouldShowItem(opt: Option) {
|
function shouldShowItem(opt: Option) {
|
||||||
if (formServiceProperties.value) {
|
if (formServiceProperties.value) {
|
||||||
const additionalFieldNames = new Set(
|
const additionalFieldNames = new Set(
|
||||||
|
|
@ -110,26 +95,18 @@ function shouldShowItem(opt: Option) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function swapItems(
|
function confirmDelete(items: unknown[], index: number) {
|
||||||
arr: { fieldName: string | null; type: AdditionalType | null }[],
|
dialog({
|
||||||
index1: number,
|
color: 'negative',
|
||||||
index2: number,
|
icon: 'mdi-alert',
|
||||||
) {
|
title: t('deleteConfirmTitle'),
|
||||||
[arr[index1], arr[index2]] = [arr[index2], arr[index1]];
|
actionText: t('delete'),
|
||||||
}
|
message: t('deleteConfirmMessage'),
|
||||||
|
action: async () => {
|
||||||
function moveItemUp(index: number) {
|
deleteItem(items, index);
|
||||||
if (!formServiceProperties.value || index <= 0) return;
|
},
|
||||||
swapItems(formServiceProperties.value.additional, index, index - 1);
|
cancel: () => {},
|
||||||
}
|
});
|
||||||
|
|
||||||
function moveItemDown(index: number) {
|
|
||||||
if (
|
|
||||||
!formServiceProperties.value ||
|
|
||||||
index >= formServiceProperties.value.additional.length - 1
|
|
||||||
)
|
|
||||||
return;
|
|
||||||
swapItems(formServiceProperties.value.additional, index, index + 1);
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -210,210 +187,222 @@ function moveItemDown(index: number) {
|
||||||
formServiceProperties?.additional &&
|
formServiceProperties?.additional &&
|
||||||
formServiceProperties.additional.length > 0
|
formServiceProperties.additional.length > 0
|
||||||
"
|
"
|
||||||
|
class="q-gutter-y-md"
|
||||||
>
|
>
|
||||||
<transition-group tag="div" name="list" class="q-gutter-y-md">
|
<div
|
||||||
<div
|
v-for="(p, index) in formServiceProperties.additional"
|
||||||
v-for="(p, index) in formServiceProperties.additional"
|
:key="index"
|
||||||
:key="index"
|
class="bordered surface-1 rounded q-py-sm q-px-md row items-start"
|
||||||
class="bordered surface-1 rounded q-py-sm q-px-md row items-start"
|
:class="
|
||||||
:class="
|
index === formServiceProperties.additional.length - 1 && 'q-mb-lg'
|
||||||
index === formServiceProperties.additional.length - 1 && 'q-mb-lg'
|
"
|
||||||
"
|
:ref="`item-${index}`"
|
||||||
:ref="`item-${index}`"
|
>
|
||||||
|
<q-btn
|
||||||
|
id="btn-move-up-product"
|
||||||
|
icon="mdi-arrow-up"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
:disable="index === 0"
|
||||||
|
style="color: hsl(var(--text-mute-2))"
|
||||||
|
@click="moveItemUp(formServiceProperties.additional, index)"
|
||||||
|
/>
|
||||||
|
<q-btn
|
||||||
|
id="btn-move-down-product"
|
||||||
|
icon="mdi-arrow-down"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
:disable="index === formServiceProperties.additional.length - 1"
|
||||||
|
style="color: hsl(var(--text-mute-2))"
|
||||||
|
@click="moveItemDown(formServiceProperties.additional, index)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<q-avatar
|
||||||
|
size="md"
|
||||||
|
class="q-mx-lg"
|
||||||
|
style="background-color: var(--surface-3)"
|
||||||
>
|
>
|
||||||
<q-btn
|
{{ index + 1 }}
|
||||||
id="btn-move-up-product"
|
</q-avatar>
|
||||||
icon="mdi-arrow-up"
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
:disable="index === 0"
|
|
||||||
style="color: hsl(var(--text-mute-2))"
|
|
||||||
@click="moveItemUp(index)"
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
id="btn-move-down-product"
|
|
||||||
icon="mdi-arrow-down"
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
round
|
|
||||||
:disable="index === formServiceProperties.additional.length - 1"
|
|
||||||
style="color: hsl(var(--text-mute-2))"
|
|
||||||
@click="moveItemDown(index)"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<q-avatar
|
<!-- type -->
|
||||||
size="md"
|
<q-select
|
||||||
class="q-mx-lg"
|
dense
|
||||||
style="background-color: var(--surface-3)"
|
outlined
|
||||||
>
|
emit-value
|
||||||
{{ index + 1 }}
|
map-options
|
||||||
</q-avatar>
|
hide-bottom-space
|
||||||
|
class="col q-mr-md"
|
||||||
|
label="Properties Name"
|
||||||
|
option-label="label"
|
||||||
|
option-value="value"
|
||||||
|
:options="propertiesOption"
|
||||||
|
v-model="p.fieldName"
|
||||||
|
>
|
||||||
|
<template v-slot:option="scope">
|
||||||
|
<q-item
|
||||||
|
v-if="scope.opt && shouldShowItem(scope.opt)"
|
||||||
|
v-bind="scope.itemProps"
|
||||||
|
class="row items-center col-12"
|
||||||
|
>
|
||||||
|
{{ scope.opt.label }}
|
||||||
|
</q-item>
|
||||||
|
</template>
|
||||||
|
</q-select>
|
||||||
|
|
||||||
<!-- type -->
|
<div class="col">
|
||||||
<q-select
|
<q-select
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col q-mr-md"
|
label="Type"
|
||||||
label="Properties Name"
|
|
||||||
option-label="label"
|
|
||||||
option-value="value"
|
option-value="value"
|
||||||
:options="propertiesOption"
|
:options="typeOption"
|
||||||
v-model="p.fieldName"
|
v-model="p.type"
|
||||||
>
|
>
|
||||||
<template v-slot:option="scope">
|
<template v-slot:option="scope">
|
||||||
<q-item
|
<q-item
|
||||||
v-if="scope.opt && shouldShowItem(scope.opt)"
|
v-if="scope.opt"
|
||||||
v-bind="scope.itemProps"
|
v-bind="scope.itemProps"
|
||||||
class="row items-center col-12"
|
class="row items-center col-12"
|
||||||
>
|
>
|
||||||
|
<q-avatar
|
||||||
|
size="sm"
|
||||||
|
class="q-mr-md"
|
||||||
|
:style="`background-color: hsla(${scope.opt.color}/0.2)`"
|
||||||
|
>
|
||||||
|
<q-icon
|
||||||
|
size="20px"
|
||||||
|
:name="scope.opt.icon"
|
||||||
|
:style="`color: hsl(${scope.opt.color})`"
|
||||||
|
/>
|
||||||
|
</q-avatar>
|
||||||
{{ scope.opt.label }}
|
{{ scope.opt.label }}
|
||||||
</q-item>
|
</q-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:selected-item="scope">
|
||||||
|
<div v-if="scope.opt" class="row items-center col-12">
|
||||||
|
<q-avatar
|
||||||
|
size="xs"
|
||||||
|
class="q-mr-sm"
|
||||||
|
:style="`background-color: hsla(${scope.opt.color}/0.2)`"
|
||||||
|
>
|
||||||
|
<q-icon
|
||||||
|
size="14px"
|
||||||
|
:name="scope.opt.icon"
|
||||||
|
:style="`color: hsl(${scope.opt.color})`"
|
||||||
|
/>
|
||||||
|
</q-avatar>
|
||||||
|
{{ scope.opt.label }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</q-select>
|
</q-select>
|
||||||
|
|
||||||
<div class="col">
|
<div
|
||||||
<q-select
|
v-if="p.type === 'string'"
|
||||||
dense
|
class="menu-border q-pt-md q-pb-sm"
|
||||||
outlined
|
style="margin-top: -20px"
|
||||||
emit-value
|
>
|
||||||
map-options
|
<q-item>
|
||||||
hide-bottom-space
|
<q-item-section class="column">
|
||||||
label="Type"
|
<span class="app-text-muted-2">เพิ่มเติม</span>
|
||||||
option-value="value"
|
<div class="q-gutter-y-sm">
|
||||||
:options="typeOption"
|
<div class="row items-center">
|
||||||
v-model="p.type"
|
<div class="col-7 surface-3 rounded q-mr-sm q-py-xs">
|
||||||
>
|
|
||||||
<template v-slot:option="scope">
|
|
||||||
<q-item
|
|
||||||
v-if="scope.opt"
|
|
||||||
v-bind="scope.itemProps"
|
|
||||||
class="row items-center col-12"
|
|
||||||
>
|
|
||||||
<q-avatar
|
|
||||||
size="sm"
|
|
||||||
class="q-mr-md"
|
|
||||||
:style="`background-color: hsla(${scope.opt.color}/0.2)`"
|
|
||||||
>
|
|
||||||
<q-icon
|
|
||||||
size="20px"
|
|
||||||
:name="scope.opt.icon"
|
|
||||||
:style="`color: hsl(${scope.opt.color})`"
|
|
||||||
/>
|
|
||||||
</q-avatar>
|
|
||||||
{{ scope.opt.label }}
|
|
||||||
</q-item>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:selected-item="scope">
|
|
||||||
<div v-if="scope.opt" class="row items-center col-12">
|
|
||||||
<q-avatar
|
|
||||||
size="xs"
|
|
||||||
class="q-mr-sm"
|
|
||||||
:style="`background-color: hsla(${scope.opt.color}/0.2)`"
|
|
||||||
>
|
|
||||||
<q-icon
|
|
||||||
size="14px"
|
|
||||||
:name="scope.opt.icon"
|
|
||||||
:style="`color: hsl(${scope.opt.color})`"
|
|
||||||
/>
|
|
||||||
</q-avatar>
|
|
||||||
{{ scope.opt.label }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</q-select>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="p.type === 'number'"
|
|
||||||
class="menu-border q-pt-md q-pb-sm"
|
|
||||||
style="margin-top: -20px"
|
|
||||||
>
|
|
||||||
<q-item>
|
|
||||||
<q-item-section class="column">
|
|
||||||
<span class="app-text-muted-2">เพิ่มเติม</span>
|
|
||||||
<div class="q-gutter-y-sm">
|
|
||||||
<div class="row items-center">
|
|
||||||
<div class="col-7 surface-3 rounded q-mr-sm q-py-xs">
|
|
||||||
<q-checkbox v-model="tel" size="xs" />
|
|
||||||
เบอร์โทร
|
|
||||||
</div>
|
|
||||||
<q-input
|
|
||||||
v-model="telMax"
|
|
||||||
class="col"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
label="จำนวนหลัก"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row items-center">
|
|
||||||
<div class="col surface-3 rounded q-mr-sm q-py-xs">
|
|
||||||
<q-checkbox v-model="comma" size="xs" />
|
|
||||||
ใส่ comma
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row items-center">
|
|
||||||
<div class="col-7 surface-3 rounded q-mr-sm q-py-xs">
|
|
||||||
<q-checkbox v-model="point" size="xs" />
|
|
||||||
ทศนิยม
|
|
||||||
</div>
|
|
||||||
<q-input
|
|
||||||
v-model="pointNum"
|
|
||||||
class="col"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
label="ตำแหน่ง"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="p.type === 'array'"
|
|
||||||
class="menu-border q-pt-md q-pb-sm"
|
|
||||||
style="margin-top: -20px"
|
|
||||||
>
|
|
||||||
<q-item>
|
|
||||||
<q-item-section class="column">
|
|
||||||
<span class="app-text-muted-2">เพิ่มเติม</span>
|
|
||||||
<div class="row items-center justify-between">
|
|
||||||
<div class="col surface-3 rounded q-mr-sm q-py-xs">
|
|
||||||
<q-checkbox v-model="tel" size="xs" />
|
<q-checkbox v-model="tel" size="xs" />
|
||||||
เพิ่ม list
|
เบอร์โทร
|
||||||
</div>
|
|
||||||
<div class="col-1">
|
|
||||||
<q-btn
|
|
||||||
dense
|
|
||||||
flat
|
|
||||||
icon="mdi-plus"
|
|
||||||
class="bordered"
|
|
||||||
text-color="grey"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<q-input
|
||||||
|
v-model="telMax"
|
||||||
|
class="col"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
label="จำนวนหลัก"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</q-item-section>
|
</div>
|
||||||
</q-item>
|
</q-item-section>
|
||||||
</div>
|
</q-item>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-btn
|
<div
|
||||||
id="btn-delete-work-product"
|
v-if="p.type === 'number'"
|
||||||
icon="mdi-trash-can-outline"
|
class="menu-border q-pt-md q-pb-sm"
|
||||||
dense
|
style="margin-top: -20px"
|
||||||
flat
|
>
|
||||||
round
|
<q-item>
|
||||||
color="negative"
|
<q-item-section class="column">
|
||||||
class="q-ml-sm"
|
<span class="app-text-muted-2">เพิ่มเติม</span>
|
||||||
@click="deleteItem(index)"
|
<div class="q-gutter-y-sm">
|
||||||
/>
|
<div class="row items-center">
|
||||||
|
<div class="col surface-3 rounded q-py-xs">
|
||||||
|
<q-checkbox v-model="comma" size="xs" />
|
||||||
|
ใส่ comma
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row items-center">
|
||||||
|
<div class="col-7 surface-3 rounded q-mr-sm q-py-xs">
|
||||||
|
<q-checkbox v-model="point" size="xs" />
|
||||||
|
ทศนิยม
|
||||||
|
</div>
|
||||||
|
<q-input
|
||||||
|
v-model="pointNum"
|
||||||
|
class="col"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
label="ตำแหน่ง"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="p.type === 'array'"
|
||||||
|
class="menu-border q-pt-md q-pb-sm"
|
||||||
|
style="margin-top: -20px"
|
||||||
|
>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section class="column">
|
||||||
|
<span class="app-text-muted-2">เพิ่มเติม</span>
|
||||||
|
<div class="row items-center justify-between">
|
||||||
|
<div class="col surface-3 rounded q-mr-sm q-py-xs">
|
||||||
|
<q-checkbox v-model="selection" size="xs" />
|
||||||
|
เพิ่ม Selection
|
||||||
|
</div>
|
||||||
|
<div class="col-1">
|
||||||
|
<q-btn
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="mdi-plus"
|
||||||
|
class="bordered"
|
||||||
|
text-color="grey"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition-group>
|
|
||||||
|
<q-btn
|
||||||
|
id="btn-delete-work-product"
|
||||||
|
icon="mdi-trash-can-outline"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
color="negative"
|
||||||
|
class="q-ml-sm"
|
||||||
|
@click="confirmDelete(formServiceProperties.additional, index)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -425,8 +414,4 @@ function moveItemDown(index: number) {
|
||||||
border-bottom-left-radius: var(--radius-2);
|
border-bottom-left-radius: var(--radius-2);
|
||||||
border-bottom-right-radius: var(--radius-2);
|
border-bottom-right-radius: var(--radius-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// .list-move {
|
|
||||||
// transition: all 0.2s ease;
|
|
||||||
// }
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Icon } from '@iconify/vue';
|
import { Icon } from '@iconify/vue';
|
||||||
|
import { formatNumberDecimal } from 'src/stores/utils';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
workIndex: number;
|
workIndex: number;
|
||||||
|
|
@ -14,15 +15,19 @@ const productItems = defineModel<
|
||||||
label: string;
|
label: string;
|
||||||
labelEn: string;
|
labelEn: string;
|
||||||
code: string;
|
code: string;
|
||||||
price: string;
|
price: number;
|
||||||
time: string;
|
time: string;
|
||||||
}[]
|
}[]
|
||||||
>('productItems');
|
>('productItems', { required: true });
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(e: 'addProduct'): void;
|
(e: 'moveWorkUp'): void;
|
||||||
|
(e: 'moveWorkDown'): void;
|
||||||
(e: 'deleteWork'): void;
|
(e: 'deleteWork'): void;
|
||||||
(e: 'deleteProduct'): void;
|
(e: 'addProduct'): void;
|
||||||
|
(e: 'moveProductUp', items: unknown[], index: number): void;
|
||||||
|
(e: 'moveProductDown', items: unknown[], index: number): void;
|
||||||
|
(e: 'deleteProduct', items: unknown[], index: number): void;
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -34,18 +39,19 @@ defineEmits<{
|
||||||
expand-icon="mdi-chevron-down-circle"
|
expand-icon="mdi-chevron-down-circle"
|
||||||
>
|
>
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<div class="row items-center q-py-sm full-width">
|
<div class="row items-center q-py-sm full-width" @click.stop>
|
||||||
<q-btn
|
<q-btn
|
||||||
id="btn-swap-work-product"
|
id="btn-work-up-product"
|
||||||
icon="mdi-arrow-up"
|
icon="mdi-arrow-up"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
:disable="index === 0"
|
:disable="index === 0"
|
||||||
style="color: hsl(var(--text-mute-2))"
|
style="color: hsl(var(--text-mute-2))"
|
||||||
|
@click.stop="$emit('moveWorkUp')"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
id="btn-swap-work-product"
|
id="btn-work-down-product"
|
||||||
icon="mdi-arrow-down"
|
icon="mdi-arrow-down"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
|
|
@ -53,6 +59,7 @@ defineEmits<{
|
||||||
class="q-mx-sm"
|
class="q-mx-sm"
|
||||||
:disable="index === length - 1"
|
:disable="index === length - 1"
|
||||||
style="color: hsl(var(--text-mute-2))"
|
style="color: hsl(var(--text-mute-2))"
|
||||||
|
@click.stop="$emit('moveWorkDown')"
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
for="input-work-name"
|
for="input-work-name"
|
||||||
|
|
@ -94,7 +101,7 @@ defineEmits<{
|
||||||
padding="0"
|
padding="0"
|
||||||
color="negative"
|
color="negative"
|
||||||
class="q-ml-sm"
|
class="q-ml-sm"
|
||||||
@click="$emit('deleteWork')"
|
@click.stop="$emit('deleteWork')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -112,7 +119,7 @@ defineEmits<{
|
||||||
:label="$t('serviceAddProduct')"
|
:label="$t('serviceAddProduct')"
|
||||||
padding="0"
|
padding="0"
|
||||||
style="color: hsl(var(--info-bg))"
|
style="color: hsl(var(--info-bg))"
|
||||||
@click="$emit('addProduct')"
|
@click.stop="$emit('addProduct')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -127,16 +134,17 @@ defineEmits<{
|
||||||
>
|
>
|
||||||
<div class="row items-center col-9 no-wrap" v-if="productItems">
|
<div class="row items-center col-9 no-wrap" v-if="productItems">
|
||||||
<q-btn
|
<q-btn
|
||||||
id="btn-swap-work-product"
|
id="btn-product-up"
|
||||||
icon="mdi-arrow-up"
|
icon="mdi-arrow-up"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
round
|
round
|
||||||
:disable="index === 0"
|
:disable="index === 0"
|
||||||
style="color: hsl(var(--text-mute-2))"
|
style="color: hsl(var(--text-mute-2))"
|
||||||
|
@click.stop="$emit('moveProductUp', productItems, index)"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
id="btn-swap-work-product"
|
id="btn-product-down"
|
||||||
icon="mdi-arrow-down"
|
icon="mdi-arrow-down"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
|
|
@ -144,6 +152,7 @@ defineEmits<{
|
||||||
class="q-mx-sm"
|
class="q-mx-sm"
|
||||||
:disable="index === productItems.length - 1"
|
:disable="index === productItems.length - 1"
|
||||||
style="color: hsl(var(--text-mute-2))"
|
style="color: hsl(var(--text-mute-2))"
|
||||||
|
@click.stop="$emit('moveProductDown', productItems, index)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-avatar
|
<q-avatar
|
||||||
|
|
@ -194,7 +203,7 @@ defineEmits<{
|
||||||
class="col-12 text-weight-bold text-h6"
|
class="col-12 text-weight-bold text-h6"
|
||||||
style="color: var(--teal-9)"
|
style="color: var(--teal-9)"
|
||||||
>
|
>
|
||||||
฿ {{ product.price }}
|
฿ {{ formatNumberDecimal(product.price, 2) }}
|
||||||
</span>
|
</span>
|
||||||
<span class="col-9 text-caption app-text-muted-2">
|
<span class="col-9 text-caption app-text-muted-2">
|
||||||
{{ $t('processTime') }}
|
{{ $t('processTime') }}
|
||||||
|
|
@ -213,7 +222,7 @@ defineEmits<{
|
||||||
round
|
round
|
||||||
color="negative"
|
color="negative"
|
||||||
class="q-mx-sm"
|
class="q-mx-sm"
|
||||||
@click="$emit('deleteProduct')"
|
@click.stop="$emit('deleteProduct', productItems, index)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue