pukaad-ui-lib 1.286.0 → 1.288.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 +3 -2
- package/dist/runtime/components/drawer/drawer-suggest-place/suggest-place-form.d.vue.ts +1 -0
- package/dist/runtime/components/drawer/drawer-suggest-place/suggest-place-form.vue +3 -2
- package/dist/runtime/components/drawer/drawer-suggest-place/suggest-place-form.vue.d.ts +1 -0
- package/dist/runtime/components/input/input-address.d.vue.ts +1 -0
- package/dist/runtime/components/input/input-address.vue +33 -4
- package/dist/runtime/components/input/input-address.vue.d.ts +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
|
|
93
93
|
<!-- personal / business: แสดงตรงๆ ไม่มี tabs -->
|
|
94
94
|
<div v-else>
|
|
95
|
-
<SuggestPlaceForm v-model="formData" :state="props.state" />
|
|
95
|
+
<SuggestPlaceForm v-model="formData" :state="props.state" :fixed-province-id="provinceIdState ?? void 0" />
|
|
96
96
|
</div>
|
|
97
97
|
<template #footer>
|
|
98
98
|
<div class="flex gap-[8px] justify-end">
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
|
|
108
108
|
<script setup>
|
|
109
109
|
import { computed, ref, watch } from "vue";
|
|
110
|
-
import { useNuxtApp } from "nuxt/app";
|
|
110
|
+
import { useNuxtApp, useState } from "nuxt/app";
|
|
111
111
|
import { useApi } from "#pukaad-ui/runtime/composables/useApi";
|
|
112
112
|
import { usePresignedUpload } from "#pukaad-ui/runtime/composables/usePresignedUpload";
|
|
113
113
|
const props = defineProps({
|
|
@@ -116,6 +116,7 @@ const props = defineProps({
|
|
|
116
116
|
const emit = defineEmits(["submit"]);
|
|
117
117
|
const { $toast } = useNuxtApp();
|
|
118
118
|
const api = useApi();
|
|
119
|
+
const provinceIdState = useState("pukaad:province-id", () => null);
|
|
119
120
|
const { uploadFiles } = usePresignedUpload();
|
|
120
121
|
const isOpen = defineModel({ type: Boolean, ...{ default: false } });
|
|
121
122
|
const formData = defineModel("data", { type: Object, ...{ default: () => ({}) } });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="flex gap-[16px] w-full">
|
|
3
3
|
<!-- กรอกข้อมูล -->
|
|
4
4
|
<div class="flex flex-col gap-[16px] w-[490px]">
|
|
5
|
-
<InputAddress name="address" v-model="modelValue.address" />
|
|
5
|
+
<InputAddress name="address" v-model="modelValue.address" :fixed-province-id="props.fixedProvinceId" />
|
|
6
6
|
<template v-if="isAddressCompleted">
|
|
7
7
|
<div class="font-body-large-prominent">รายละเอียด</div>
|
|
8
8
|
<div class="flex flex-col gap-[4px]">
|
|
@@ -78,7 +78,8 @@ import { ref, computed, onMounted, watch, reactive } from "vue";
|
|
|
78
78
|
import { useApi } from "#pukaad-ui/runtime/composables/useApi";
|
|
79
79
|
import SuggestPlaceMap from "./suggest-place-map.vue";
|
|
80
80
|
const props = defineProps({
|
|
81
|
-
state: { type: String, required: false, default: "personal" }
|
|
81
|
+
state: { type: String, required: false, default: "personal" },
|
|
82
|
+
fixedProvinceId: { type: Number, required: false }
|
|
82
83
|
});
|
|
83
84
|
const api = useApi();
|
|
84
85
|
const _model = defineModel({ type: Object, ...{ default: () => ({}) } });
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<ShadCommand class="p-2">
|
|
16
16
|
<ShadTabs v-model="currentTab" class="w-full">
|
|
17
17
|
<ShadTabsList class="w-full grid grid-cols-4">
|
|
18
|
-
<ShadTabsTrigger value="province"> จังหวัด </ShadTabsTrigger>
|
|
18
|
+
<ShadTabsTrigger value="province" :disabled="!!props.fixedProvinceId"> จังหวัด </ShadTabsTrigger>
|
|
19
19
|
<ShadTabsTrigger value="district" :disabled="!selectedProvince">
|
|
20
20
|
อำเภอ/เขต
|
|
21
21
|
</ShadTabsTrigger>
|
|
@@ -171,7 +171,8 @@ const props = defineProps({
|
|
|
171
171
|
required: { type: Boolean, required: false, default: false },
|
|
172
172
|
requiredDetail: { type: Boolean, required: false, default: false },
|
|
173
173
|
rules: { type: [Object, String, Function], required: false },
|
|
174
|
-
gap: { type: String, required: false, default: "gap-4" }
|
|
174
|
+
gap: { type: String, required: false, default: "gap-4" },
|
|
175
|
+
fixedProvinceId: { type: Number, required: false }
|
|
175
176
|
});
|
|
176
177
|
const emits = defineEmits(["selectProvince", "selectDistrict", "selectSubDistrict", "selectZipCode", "change"]);
|
|
177
178
|
const modelValue = defineModel({ type: Object, ...{
|
|
@@ -372,8 +373,36 @@ const initializeFromModelValue = async () => {
|
|
|
372
373
|
addressDetailValue.value = val.detail_address;
|
|
373
374
|
}
|
|
374
375
|
};
|
|
375
|
-
onMounted(() => {
|
|
376
|
-
initializeFromModelValue();
|
|
376
|
+
onMounted(async () => {
|
|
377
|
+
await initializeFromModelValue();
|
|
378
|
+
if (props.fixedProvinceId) {
|
|
379
|
+
if (!selectedProvince.value) {
|
|
380
|
+
const province = await loadProvinceById(props.fixedProvinceId);
|
|
381
|
+
if (province) {
|
|
382
|
+
selectedProvince.value = province;
|
|
383
|
+
await loadAmphursForProvince(province.id);
|
|
384
|
+
updateModelValue();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
currentTab.value = "district";
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
watch(() => props.fixedProvinceId, async (newId, oldId) => {
|
|
391
|
+
if (!newId || newId === oldId) return;
|
|
392
|
+
selectedProvince.value = null;
|
|
393
|
+
selectedDistrict.value = null;
|
|
394
|
+
selectedSubDistrict.value = null;
|
|
395
|
+
selectedZipcode.value = null;
|
|
396
|
+
allAmphurs.value = [];
|
|
397
|
+
allTambons.value = [];
|
|
398
|
+
zipcodes.value = [];
|
|
399
|
+
const province = await loadProvinceById(newId);
|
|
400
|
+
if (province) {
|
|
401
|
+
selectedProvince.value = province;
|
|
402
|
+
await loadAmphursForProvince(province.id);
|
|
403
|
+
currentTab.value = "district";
|
|
404
|
+
updateModelValue();
|
|
405
|
+
}
|
|
377
406
|
});
|
|
378
407
|
const defaultRules = (v) => {
|
|
379
408
|
if (!v && props.required) {
|