pukaad-ui-lib 1.286.0 → 1.287.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/suggest-place-form.vue +2 -1
- 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
|
@@ -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="provinceIdState ?? void 0" />
|
|
6
6
|
<template v-if="isAddressCompleted">
|
|
7
7
|
<div class="font-body-large-prominent">รายละเอียด</div>
|
|
8
8
|
<div class="flex flex-col gap-[4px]">
|
|
@@ -81,6 +81,7 @@ const props = defineProps({
|
|
|
81
81
|
state: { type: String, required: false, default: "personal" }
|
|
82
82
|
});
|
|
83
83
|
const api = useApi();
|
|
84
|
+
const provinceIdState = useState("pukaad:province-id", () => null);
|
|
84
85
|
const _model = defineModel({ type: Object, ...{ default: () => ({}) } });
|
|
85
86
|
const modelValue = reactive({
|
|
86
87
|
address: {},
|
|
@@ -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) {
|