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