แก้จังหวัด
This commit is contained in:
parent
4f7d0cee99
commit
1441896dbb
2 changed files with 29 additions and 23 deletions
|
|
@ -105,6 +105,7 @@ async function addData() {
|
||||||
await http
|
await http
|
||||||
.post(config.API.orgDistrict, {
|
.post(config.API.orgDistrict, {
|
||||||
name: district.value,
|
name: district.value,
|
||||||
|
provinceId:id.value
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchData();
|
fetchData();
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,29 @@
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useRouter,useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import { usePersonalDataStore } from "@/modules/01_metadataNew/stores/personalStore";
|
import { usePersonalDataStore } from "@/modules/01_metadataNew/stores/personalStore";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
import DialogForm from "@/modules/01_metadataNew/components/personal/DialogForm.vue";
|
import DialogForm from "@/modules/01_metadataNew/components/personal/DialogForm.vue";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import type{ FormSubDistrict } from '@/modules/01_metadataNew/interface/response/personal/personal'
|
import type { FormSubDistrict } from "@/modules/01_metadataNew/interface/response/personal/personal";
|
||||||
|
|
||||||
const rows = ref<FormSubDistrict[]>([])
|
const rows = ref<FormSubDistrict[]>([]);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const id = ref<string>(route.params.id as string)
|
const id = ref<string>(route.params.id as string);
|
||||||
const idProvince = ref<string>(route.params.provinceId as string)
|
const idProvince = ref<string>(route.params.provinceId as string);
|
||||||
const store = usePersonalDataStore();
|
const store = usePersonalDataStore();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { dialogRemove, messageError, showLoader, hideLoader, success,date2Thai } = mixin;
|
const {
|
||||||
|
dialogRemove,
|
||||||
|
messageError,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
success,
|
||||||
|
date2Thai,
|
||||||
|
} = mixin;
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
|
|
@ -84,15 +91,15 @@ const visibleColumns = ref<string[]>([
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.orgDistrict+`/${id.value}`)
|
.get(config.API.orgDistrict + `/${id.value}`)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.result.subDistricts
|
const data = res.data.result.subDistricts;
|
||||||
const list = data.map((e:any) => ({
|
const list = data.map((e: any) => ({
|
||||||
...e,
|
...e,
|
||||||
createdAt: e.createdAt ? date2Thai(e.createdAt) : "",
|
createdAt: e.createdAt ? date2Thai(e.createdAt) : "",
|
||||||
lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "",
|
lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "",
|
||||||
}));
|
}));
|
||||||
rows.value = list
|
rows.value = list;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -106,6 +113,8 @@ async function addData() {
|
||||||
await http
|
await http
|
||||||
.post(config.API.orgSubDistrict, {
|
.post(config.API.orgSubDistrict, {
|
||||||
name: subDistrict.value,
|
name: subDistrict.value,
|
||||||
|
districtId: id.value,
|
||||||
|
zipCode: zipCode.value,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchData();
|
fetchData();
|
||||||
|
|
@ -119,10 +128,11 @@ async function addData() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function editData(id: string) {
|
async function editData(idRow: string) {
|
||||||
await http
|
await http
|
||||||
.put(config.API.orgSubDistrict + `/${id}`, {
|
.put(config.API.orgSubDistrict + `/${idRow}`, {
|
||||||
name: subDistrict.value,
|
name: subDistrict.value,
|
||||||
|
districtId: id.value,
|
||||||
zipCode: zipCode.value,
|
zipCode: zipCode.value,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
@ -152,7 +162,6 @@ async function deleteData(id: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
fetchData();
|
fetchData();
|
||||||
});
|
});
|
||||||
|
|
@ -173,7 +182,6 @@ onMounted(async () => {
|
||||||
แขวง/ตำบล
|
แขวง/ตำบล
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<q-card flat bordered>
|
<q-card flat bordered>
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<q-toolbar class="q-pa-none">
|
<q-toolbar class="q-pa-none">
|
||||||
|
|
@ -187,7 +195,7 @@ onMounted(async () => {
|
||||||
dialogStatus = 'create';
|
dialogStatus = 'create';
|
||||||
dialog = true;
|
dialog = true;
|
||||||
subDistrict = '';
|
subDistrict = '';
|
||||||
zipCode = ''
|
zipCode = '';
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
@ -241,10 +249,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
<q-tr :props="props" class="cursor-pointer">
|
<q-tr :props="props" class="cursor-pointer">
|
||||||
<q-td
|
<q-td v-for="col in props.cols" :key="col.id">
|
||||||
v-for="col in props.cols"
|
|
||||||
:key="col.id"
|
|
||||||
>
|
|
||||||
<div>
|
<div>
|
||||||
{{ col.value }}
|
{{ col.value }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue