pukaad-ui-lib 1.319.0 → 1.321.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/drawer/drawer-suggest-place/drawer-suggest-place.vue +7 -0
- package/dist/runtime/components/drawer/drawer-suggest-place/suggest-place-form.d.vue.ts +3 -1
- package/dist/runtime/components/drawer/drawer-suggest-place/suggest-place-form.vue +7 -15
- package/dist/runtime/components/drawer/drawer-suggest-place/suggest-place-form.vue.d.ts +3 -1
- package/dist/runtime/components/image/image-cropper.d.vue.ts +2 -2
- package/dist/runtime/components/image/image-cropper.vue.d.ts +2 -2
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
<!-- personal / business: แสดงตรงๆ ไม่มี tabs -->
|
|
103
103
|
<div v-else>
|
|
104
104
|
<SuggestPlaceForm
|
|
105
|
+
ref="formRef"
|
|
105
106
|
v-model="formData"
|
|
106
107
|
:state="props.state"
|
|
107
108
|
:fixed-province-id="provinceIdState ?? void 0"
|
|
@@ -123,6 +124,7 @@ import { computed, ref, watch } from "vue";
|
|
|
123
124
|
import { useNuxtApp, useState } from "nuxt/app";
|
|
124
125
|
import { useApi } from "#pukaad-ui/runtime/composables/useApi";
|
|
125
126
|
import { usePresignedUpload } from "#pukaad-ui/runtime/composables/usePresignedUpload";
|
|
127
|
+
import SuggestPlaceForm from "./suggest-place-form.vue";
|
|
126
128
|
const props = defineProps({
|
|
127
129
|
state: { type: String, required: false, default: "personal" },
|
|
128
130
|
editId: { type: String, required: false }
|
|
@@ -137,6 +139,7 @@ const provinceIdState = useState(
|
|
|
137
139
|
const { uploadFiles } = usePresignedUpload();
|
|
138
140
|
const isOpen = defineModel({ type: Boolean, ...{ default: false } });
|
|
139
141
|
const formData = defineModel("data", { type: Object, ...{ default: () => ({}) } });
|
|
142
|
+
const formRef = ref(null);
|
|
140
143
|
const loading = ref(false);
|
|
141
144
|
const photoColumns = ref(false);
|
|
142
145
|
const videoColumns = ref(false);
|
|
@@ -172,6 +175,10 @@ const endpointMap = {
|
|
|
172
175
|
backoffice: "/office/suggest-places"
|
|
173
176
|
};
|
|
174
177
|
const onSubmit = async () => {
|
|
178
|
+
if (props.state !== "backoffice") {
|
|
179
|
+
const isDuplicate = await formRef.value?.checkDuplicate();
|
|
180
|
+
if (isDuplicate) return;
|
|
181
|
+
}
|
|
175
182
|
loading.value = true;
|
|
176
183
|
try {
|
|
177
184
|
const d = formData.value;
|
|
@@ -41,7 +41,9 @@ type __VLS_ModelProps = {
|
|
|
41
41
|
modelValue?: SuggestPlaceData;
|
|
42
42
|
};
|
|
43
43
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
44
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
44
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
45
|
+
checkDuplicate: () => Promise<boolean>;
|
|
46
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
45
47
|
"update:modelValue": (value: SuggestPlaceData) => any;
|
|
46
48
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
47
49
|
"onUpdate:modelValue"?: ((value: SuggestPlaceData) => any) | undefined;
|
|
@@ -227,15 +227,13 @@ const fetchApprovedPlaces = async (page, pageSize, search) => {
|
|
|
227
227
|
meta: { total_pages: res.meta?.total_pages ?? 1 }
|
|
228
228
|
};
|
|
229
229
|
};
|
|
230
|
-
const lastCheckedDuplicateName = ref("");
|
|
231
|
-
let duplicateCheckTimer = null;
|
|
232
230
|
const showDuplicateAlert = async (item) => {
|
|
233
231
|
const result = await $alert.show({
|
|
234
232
|
type: "warning",
|
|
235
233
|
title: "\u0E21\u0E35\u0E2A\u0E16\u0E32\u0E19\u0E17\u0E35\u0E48\u0E19\u0E35\u0E49\u0E43\u0E19\u0E23\u0E30\u0E1A\u0E1A\u0E41\u0E25\u0E49\u0E27",
|
|
236
234
|
description: `"${item.business_name}" \u0E21\u0E35\u0E2D\u0E22\u0E39\u0E48\u0E41\u0E25\u0E49\u0E27\u0E17\u0E35\u0E48 ${item.address?.full_address ?? ""}`,
|
|
237
235
|
confirmText: "\u0E14\u0E39\u0E2A\u0E16\u0E32\u0E19\u0E17\u0E35\u0E48\u0E19\u0E35\u0E49",
|
|
238
|
-
cancelText: "\
|
|
236
|
+
cancelText: "\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
|
|
239
237
|
showCancelBtn: true
|
|
240
238
|
});
|
|
241
239
|
if (result.isConfirmed && item.id) {
|
|
@@ -247,10 +245,10 @@ const onSelectSuggestedPlace = async (item) => {
|
|
|
247
245
|
await showDuplicateAlert(item);
|
|
248
246
|
};
|
|
249
247
|
const checkDuplicate = async () => {
|
|
250
|
-
if (props.state === "backoffice") return;
|
|
251
|
-
if (!isAddressCompleted.value) return;
|
|
248
|
+
if (props.state === "backoffice") return false;
|
|
249
|
+
if (!isAddressCompleted.value) return false;
|
|
252
250
|
const name = modelValue.businessName?.trim();
|
|
253
|
-
if (!name
|
|
251
|
+
if (!name) return false;
|
|
254
252
|
try {
|
|
255
253
|
const base = listEndpointMap[props.state] ?? "/personal/suggest-places";
|
|
256
254
|
const res = await api(base, {
|
|
@@ -267,20 +265,14 @@ const checkDuplicate = async () => {
|
|
|
267
265
|
(p) => p.business_name.trim().toLowerCase() === name.toLowerCase() && p.address?.tambon_id === modelValue.address?.tambon_id
|
|
268
266
|
);
|
|
269
267
|
if (match) {
|
|
270
|
-
lastCheckedDuplicateName.value = name;
|
|
271
268
|
await showDuplicateAlert(match);
|
|
269
|
+
return true;
|
|
272
270
|
}
|
|
273
271
|
} catch {
|
|
274
272
|
}
|
|
273
|
+
return false;
|
|
275
274
|
};
|
|
276
|
-
|
|
277
|
-
() => [modelValue.businessName, modelValue.address?.tambon_id],
|
|
278
|
-
([name]) => {
|
|
279
|
-
if (!name || !isAddressCompleted.value || props.state === "backoffice") return;
|
|
280
|
-
if (duplicateCheckTimer) clearTimeout(duplicateCheckTimer);
|
|
281
|
-
duplicateCheckTimer = setTimeout(checkDuplicate, 600);
|
|
282
|
-
}
|
|
283
|
-
);
|
|
275
|
+
defineExpose({ checkDuplicate });
|
|
284
276
|
const categoryOptions = ref([]);
|
|
285
277
|
onMounted(async () => {
|
|
286
278
|
try {
|
|
@@ -41,7 +41,9 @@ type __VLS_ModelProps = {
|
|
|
41
41
|
modelValue?: SuggestPlaceData;
|
|
42
42
|
};
|
|
43
43
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
44
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
44
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
45
|
+
checkDuplicate: () => Promise<boolean>;
|
|
46
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
45
47
|
"update:modelValue": (value: SuggestPlaceData) => any;
|
|
46
48
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
47
49
|
"onUpdate:modelValue"?: ((value: SuggestPlaceData) => any) | undefined;
|
|
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
|
|
|
64
64
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
|
|
65
65
|
src: string;
|
|
66
66
|
center: boolean;
|
|
67
|
-
background: boolean;
|
|
68
|
-
modal: boolean;
|
|
69
67
|
responsive: boolean;
|
|
70
68
|
restore: boolean;
|
|
71
69
|
checkCrossOrigin: boolean;
|
|
72
70
|
checkOrientation: boolean;
|
|
73
71
|
crossorigin: "" | "anonymous" | "use-credentials";
|
|
72
|
+
modal: boolean;
|
|
74
73
|
guides: boolean;
|
|
75
74
|
highlight: boolean;
|
|
75
|
+
background: boolean;
|
|
76
76
|
autoCrop: boolean;
|
|
77
77
|
movable: boolean;
|
|
78
78
|
rotatable: boolean;
|
|
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
|
|
|
64
64
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
|
|
65
65
|
src: string;
|
|
66
66
|
center: boolean;
|
|
67
|
-
background: boolean;
|
|
68
|
-
modal: boolean;
|
|
69
67
|
responsive: boolean;
|
|
70
68
|
restore: boolean;
|
|
71
69
|
checkCrossOrigin: boolean;
|
|
72
70
|
checkOrientation: boolean;
|
|
73
71
|
crossorigin: "" | "anonymous" | "use-credentials";
|
|
72
|
+
modal: boolean;
|
|
74
73
|
guides: boolean;
|
|
75
74
|
highlight: boolean;
|
|
75
|
+
background: boolean;
|
|
76
76
|
autoCrop: boolean;
|
|
77
77
|
movable: boolean;
|
|
78
78
|
rotatable: boolean;
|