API เครื่องราช
This commit is contained in:
parent
0dd2915db7
commit
8cd40e69aa
5 changed files with 183 additions and 156 deletions
|
|
@ -32,4 +32,7 @@ export default {
|
||||||
// listInsigniaHistoryId: (id: string) => `${insignia}history/${id}`,
|
// listInsigniaHistoryId: (id: string) => `${insignia}history/${id}`,
|
||||||
// listInsigniaPublished: `${insignia}history/published`,
|
// listInsigniaPublished: `${insignia}history/published`,
|
||||||
// listInsigniaPublishedHistory: `${insignia}history/published-history`,
|
// listInsigniaPublishedHistory: `${insignia}history/published-history`,
|
||||||
|
insigniaTypeNew: `${insigniaType}draft`,
|
||||||
|
insigniaTypeNewId: (id: string) => `${insigniaType}${id}`,
|
||||||
|
insigniaNewId: (id: string) => `${insignia}${id}`,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,118 +2,45 @@
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
import { useRouter, useRoute } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
import InsigniaList from "@/modules/01_metadataNew/components/insignia/InsigniaList.vue";
|
import InsigniaList from "@/modules/01_metadataNew/components/insignia/InsigniaList.vue";
|
||||||
const router = useRouter();
|
|
||||||
const route = useRoute();
|
|
||||||
const nameType = ref<string>("");
|
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
import { useInsigniaDataStore } from "@/modules/01_metadataNew/stores/InsigniaStore";
|
||||||
import type {
|
import type {
|
||||||
DetailResponse,
|
DetailResponse,
|
||||||
DetailRow,
|
DetailRow,
|
||||||
} from "@/modules/01_metadataNew/interface/response/insignia/Insignia";
|
} from "@/modules/01_metadataNew/interface/response/insignia/Insignia";
|
||||||
|
|
||||||
|
const nameType = ref<string>("");
|
||||||
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
const $q = useQuasar();
|
||||||
|
const store = useInsigniaDataStore();
|
||||||
const row = ref<DetailRow[]>();
|
const row = ref<DetailRow[]>();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai } = mixin;
|
const { date2Thai, messageError, hideLoader, showLoader } = mixin;
|
||||||
const id = ref<string>(route.params.id.toString());
|
const id = ref<string>(route.params.id.toString());
|
||||||
function fetchName(name: string) {
|
const insigniaTypeId = ref<string>("");
|
||||||
nameType.value = name;
|
|
||||||
|
async function fetchData(id: string) {
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.get(config.API.insigniaTypeNewId(id))
|
||||||
|
.then(async (res) => {
|
||||||
|
insigniaTypeId.value = res.data.result.name;
|
||||||
|
store.fetchData(res.data.result.insignias, res.data.result.name);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = ref<DetailResponse[]>([
|
onMounted(async () => {
|
||||||
{
|
fetchData(id.value);
|
||||||
id: "1",
|
|
||||||
level: 1,
|
|
||||||
shortName: "จ.ม.",
|
|
||||||
insigniaType: "ชั้นต่ำกว่าสายสะพาย",
|
|
||||||
insigniaTypeId: "1",
|
|
||||||
note: "-",
|
|
||||||
name: "จัตุรถาภรณ์มงกุฎไทย",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "System Administrator",
|
|
||||||
isActive: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2",
|
|
||||||
level: 1,
|
|
||||||
shortName: "จ.ช.",
|
|
||||||
insigniaType: "ชั้นต่ำกว่าสายสะพาย",
|
|
||||||
insigniaTypeId: "1",
|
|
||||||
note: "-",
|
|
||||||
name: "จัตุรถาภรณ์ช้างเผือก",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "คณะกรรมการ ตรวจรับ",
|
|
||||||
isActive: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
level: 1,
|
|
||||||
shortName: "บ.ม.",
|
|
||||||
insigniaType: "ชั้นสายสะพาย",
|
|
||||||
insigniaTypeId: "2",
|
|
||||||
note: "-",
|
|
||||||
name: "เบญจมาภรณ์มงกุฎไทย",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "คณะกรรมการ ตรวจรับ",
|
|
||||||
isActive: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2",
|
|
||||||
level: 1,
|
|
||||||
shortName: "ท.ม.",
|
|
||||||
insigniaType: "ชั้นสายสะพาย",
|
|
||||||
insigniaTypeId: "2",
|
|
||||||
note: "-",
|
|
||||||
name: "ทวีติยาภรณ์มงกุฎไทย",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "คณะกรรมการ ตรวจรับ",
|
|
||||||
isActive: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
level: 1,
|
|
||||||
shortName: "บ.ช.",
|
|
||||||
insigniaType: "เหรียญบำเหน็จในราชการ",
|
|
||||||
insigniaTypeId: "3",
|
|
||||||
note: "-",
|
|
||||||
name: "เบญจมาภรณ์ช้างเผือก",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
|
||||||
isActive: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "2",
|
|
||||||
level: 1,
|
|
||||||
shortName: "ท.ม.",
|
|
||||||
insigniaType: "เหรียญบำเหน็จในราชการ",
|
|
||||||
insigniaTypeId: "3",
|
|
||||||
note: "-",
|
|
||||||
name: "ทวีติยาภรณ์มงกุฎไทย",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "System Administrator",
|
|
||||||
isActive: true,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
function fetchData() {
|
|
||||||
const datafilter = data.value.find((e) => e.insigniaTypeId === id.value);
|
|
||||||
console.log(datafilter);
|
|
||||||
datafilter && fetchName(datafilter.insigniaType);
|
|
||||||
const list = data.value.map((e) => ({
|
|
||||||
...e,
|
|
||||||
createdAt: e.createdAt ? date2Thai(e.createdAt) : "",
|
|
||||||
lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "",
|
|
||||||
}));
|
|
||||||
row.value = list.filter((e) => e.insigniaTypeId === id.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
fetchData();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -128,15 +55,11 @@ onMounted(() => {
|
||||||
class="q-mr-sm"
|
class="q-mr-sm"
|
||||||
@click="router.go(-1)"
|
@click="router.go(-1)"
|
||||||
/>
|
/>
|
||||||
รายละเอียดข้อมูลเครื่องราชอิสริยาภรณ์ {{ nameType }}
|
รายการข้อมูลเครื่องราชอิสริยาภรณ์ {{ insigniaTypeId }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-card flat bordered>
|
<q-card flat bordered>
|
||||||
<InsigniaList
|
<InsigniaList :data="row" />
|
||||||
:data="row"
|
|
||||||
@update:fetchName="fetchName"
|
|
||||||
:nameType="nameType"
|
|
||||||
/>
|
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,23 @@
|
||||||
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 } from "vue-router";
|
import { useRouter, useRoute } from "vue-router";
|
||||||
|
import { useInsigniaDataStore } from "@/modules/01_metadataNew/stores/InsigniaStore";
|
||||||
import dialogHeader from "@/components/DialogHeader.vue";
|
import dialogHeader from "@/components/DialogHeader.vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
const store = useInsigniaDataStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai, dialogRemove, dialogConfirm } = mixin;
|
const {
|
||||||
|
date2Thai,
|
||||||
|
dialogRemove,
|
||||||
|
dialogConfirm,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
messageError,
|
||||||
|
} = mixin;
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const columns = ref<QTableProps["columns"]>([
|
const columns = ref<QTableProps["columns"]>([
|
||||||
{
|
{
|
||||||
|
|
@ -119,7 +129,8 @@ const columns = ref<QTableProps["columns"]>([
|
||||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
const route = useRoute();
|
||||||
|
const id = ref<string>(route.params.id.toString());
|
||||||
const filterKeyword = ref<string>("");
|
const filterKeyword = ref<string>("");
|
||||||
const dialog = ref<boolean>(false);
|
const dialog = ref<boolean>(false);
|
||||||
const isActive = ref<boolean>(false);
|
const isActive = ref<boolean>(false);
|
||||||
|
|
@ -130,6 +141,7 @@ const insigniaTypeId = ref<string>("");
|
||||||
const nameRef = ref<any>(null);
|
const nameRef = ref<any>(null);
|
||||||
const shortNameRef = ref<any>(null);
|
const shortNameRef = ref<any>(null);
|
||||||
const dialogStatus = ref<string>("");
|
const dialogStatus = ref<string>("");
|
||||||
|
const editId = ref<string>("");
|
||||||
const visibleColumns = ref<string[]>([
|
const visibleColumns = ref<string[]>([
|
||||||
"level",
|
"level",
|
||||||
"name",
|
"name",
|
||||||
|
|
@ -142,11 +154,6 @@ const visibleColumns = ref<string[]>([
|
||||||
"note",
|
"note",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
data: { type: Object },
|
|
||||||
nameType: { type: String },
|
|
||||||
});
|
|
||||||
|
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
dialog.value = false;
|
dialog.value = false;
|
||||||
}
|
}
|
||||||
|
|
@ -157,21 +164,78 @@ function validateForm() {
|
||||||
onSubmit();
|
onSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchData(id: string) {
|
||||||
|
showLoader();
|
||||||
|
await http
|
||||||
|
.get(config.API.insigniaTypeNewId(id))
|
||||||
|
.then(async (res) => {
|
||||||
|
insigniaTypeId.value = res.data.result.name;
|
||||||
|
store.fetchData(res.data.result.insignias, res.data.result.name);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
onMounted(async () => {
|
||||||
|
fetchData(id.value);
|
||||||
|
console.log(id.value);
|
||||||
|
});
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
if (name.value.length > 0 && shortName.value.length > 0) {
|
if (name.value.length > 0 && shortName.value.length > 0) {
|
||||||
dialogConfirm(
|
dialogConfirm(
|
||||||
$q,
|
$q,
|
||||||
async () => {
|
async () => {
|
||||||
console.log("สำเร็จ");
|
dialogStatus.value === "create" ? addData() : editData(editId.value);
|
||||||
closeDialog();
|
closeDialog();
|
||||||
name.value = "";
|
name.value = "";
|
||||||
shortName.value = "";
|
shortName.value = "";
|
||||||
|
isActive.value = false;
|
||||||
|
note.value = "";
|
||||||
},
|
},
|
||||||
"ยืนยันการบันทึกข้อมูล",
|
"ยืนยันการบันทึกข้อมูล",
|
||||||
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addData() {
|
||||||
|
await http.post(config.API.insignia, {
|
||||||
|
name: name.value,
|
||||||
|
isActive: isActive.value,
|
||||||
|
shortName: shortName.value,
|
||||||
|
note: note.value == "" ? "-" : "",
|
||||||
|
insigniaTypeId: id.value,
|
||||||
|
});
|
||||||
|
fetchData(id.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function editData(idData: string) {
|
||||||
|
await http.put(config.API.insigniaNewId(idData), {
|
||||||
|
name: name.value,
|
||||||
|
isActive: isActive.value,
|
||||||
|
shortName: shortName.value,
|
||||||
|
note: note.value == "" ? "-" : "",
|
||||||
|
insigniaTypeId: id.value,
|
||||||
|
});
|
||||||
|
fetchData(id.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteData(idData: string) {
|
||||||
|
await http.delete(config.API.insigniaNewId(idData));
|
||||||
|
fetchData(id.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
import { defineEmits } from "vue";
|
||||||
|
|
||||||
|
const emit = defineEmits(["nameType"]);
|
||||||
|
|
||||||
|
const nameType = () => {
|
||||||
|
emit("nameType", insigniaTypeId.value);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -214,7 +278,7 @@ async function onSubmit() {
|
||||||
<d-table
|
<d-table
|
||||||
ref="table"
|
ref="table"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:rows="props.data"
|
:rows="store.row"
|
||||||
:filter="filterKeyword"
|
:filter="filterKeyword"
|
||||||
row-key="name"
|
row-key="name"
|
||||||
flat
|
flat
|
||||||
|
|
@ -272,6 +336,11 @@ async function onSubmit() {
|
||||||
() => {
|
() => {
|
||||||
dialogStatus = 'edit';
|
dialogStatus = 'edit';
|
||||||
dialog = true;
|
dialog = true;
|
||||||
|
editId = props.row.id;
|
||||||
|
name = props.row.name;
|
||||||
|
shortName = props.row.shortName;
|
||||||
|
note = props.row.note;
|
||||||
|
isActive = props.row.isActive;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
@ -284,7 +353,12 @@ async function onSubmit() {
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section
|
<q-item-section
|
||||||
@click="dialogRemove($q, async () => {})"
|
@click="
|
||||||
|
dialogRemove(
|
||||||
|
$q,
|
||||||
|
async () => await deleteData(props.row.id)
|
||||||
|
)
|
||||||
|
"
|
||||||
v-close-popup
|
v-close-popup
|
||||||
>
|
>
|
||||||
<div class="row items-center white">
|
<div class="row items-center white">
|
||||||
|
|
@ -315,7 +389,7 @@ async function onSubmit() {
|
||||||
<q-card-section class="q-pa-none">
|
<q-card-section class="q-pa-none">
|
||||||
<q-input
|
<q-input
|
||||||
outlined
|
outlined
|
||||||
:model-value="nameType"
|
:model-value="insigniaTypeId"
|
||||||
label="ลำดับชั้นเครื่องราชฯ"
|
label="ลำดับชั้นเครื่องราชฯ"
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
|
|
@ -328,7 +402,7 @@ async function onSubmit() {
|
||||||
ref="nameRef"
|
ref="nameRef"
|
||||||
outlined
|
outlined
|
||||||
v-model="name"
|
v-model="name"
|
||||||
label="ชื่อเครื่องราช"
|
label="ชื่อเครื่องราชฯ"
|
||||||
dense
|
dense
|
||||||
lazy-rules
|
lazy-rules
|
||||||
borderless
|
borderless
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,20 @@ import { useRouter } from "vue-router";
|
||||||
import { useInsigniaDataStore } from "@/modules/01_metadataNew/stores/InsigniaStore";
|
import { useInsigniaDataStore } from "@/modules/01_metadataNew/stores/InsigniaStore";
|
||||||
import dialogHeader from "@/components/DialogHeader.vue";
|
import dialogHeader from "@/components/DialogHeader.vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
const store = useInsigniaDataStore();
|
const store = useInsigniaDataStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { dialogRemove, dialogConfirm } = mixin;
|
const {
|
||||||
|
dialogRemove,
|
||||||
|
dialogConfirm,
|
||||||
|
success,
|
||||||
|
messageError,
|
||||||
|
showLoader,
|
||||||
|
hideLoader,
|
||||||
|
} = mixin;
|
||||||
const columns = ref<QTableProps["columns"]>([
|
const columns = ref<QTableProps["columns"]>([
|
||||||
{
|
{
|
||||||
name: "name",
|
name: "name",
|
||||||
|
|
@ -71,6 +80,7 @@ const columns = ref<QTableProps["columns"]>([
|
||||||
|
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
|
||||||
|
const editId = ref<string>("");
|
||||||
const filterKeyword = ref<string>("");
|
const filterKeyword = ref<string>("");
|
||||||
const dialog = ref<boolean>(false);
|
const dialog = ref<boolean>(false);
|
||||||
const isActive = ref<boolean>(false);
|
const isActive = ref<boolean>(false);
|
||||||
|
|
@ -87,34 +97,20 @@ const visibleColumns = ref<string[]>([
|
||||||
|
|
||||||
// const row = ref([]);
|
// const row = ref([]);
|
||||||
|
|
||||||
function fetchData() {
|
async function fetchData() {
|
||||||
const data = [
|
showLoader();
|
||||||
{
|
await http
|
||||||
id: "1",
|
.get(config.API.insigniaTypeNew)
|
||||||
name: "ชั้นต่ำกว่าสายสะพาย",
|
.then(async (res) => {
|
||||||
createdAt: new Date(),
|
console.log(res.data.result);
|
||||||
lastUpdatedAt: new Date(),
|
store.fetchData(res.data.result);
|
||||||
lastUpdateFullName: "สาวิตรี ศรีสมัย",
|
})
|
||||||
isActive: true,
|
.catch((err) => {
|
||||||
},
|
messageError($q, err);
|
||||||
{
|
})
|
||||||
id: "2",
|
.finally(() => {
|
||||||
name: "ชั้นสายสะพาย",
|
hideLoader();
|
||||||
createdAt: new Date(),
|
});
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "System Administrator",
|
|
||||||
isActive: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3",
|
|
||||||
name: "เหรียญบำเหน็จในราชการ",
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
lastUpdateFullName: "คณะกรรมการ ตรวจรับ",
|
|
||||||
isActive: false,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
store.fetchData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
@ -129,6 +125,27 @@ function onclickDetail(id: string) {
|
||||||
router.push(`/master-data/insignia/detail/${id}`);
|
router.push(`/master-data/insignia/detail/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addData() {
|
||||||
|
await http.post(config.API.insigniaType, {
|
||||||
|
name: name.value,
|
||||||
|
isActive: isActive.value,
|
||||||
|
});
|
||||||
|
fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function editData(id: string) {
|
||||||
|
await http.put(config.API.insigniaTypeNewId(id), {
|
||||||
|
name: name.value,
|
||||||
|
isActive: isActive.value,
|
||||||
|
});
|
||||||
|
fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteData(id: string) {
|
||||||
|
await http.delete(config.API.insigniaTypeNewId(id));
|
||||||
|
fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
function validateForm() {
|
function validateForm() {
|
||||||
nameRef.value.validate();
|
nameRef.value.validate();
|
||||||
onSubmit();
|
onSubmit();
|
||||||
|
|
@ -139,9 +156,10 @@ async function onSubmit() {
|
||||||
dialogConfirm(
|
dialogConfirm(
|
||||||
$q,
|
$q,
|
||||||
async () => {
|
async () => {
|
||||||
console.log("สำเร็จ");
|
dialogStatus.value === "create" ? addData() : editData(editId.value);
|
||||||
closeDialog();
|
closeDialog();
|
||||||
name.value = "";
|
name.value = "";
|
||||||
|
isActive.value = false;
|
||||||
},
|
},
|
||||||
"ยืนยันการบันทึกข้อมูล",
|
"ยืนยันการบันทึกข้อมูล",
|
||||||
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
||||||
|
|
@ -246,6 +264,9 @@ async function onSubmit() {
|
||||||
() => {
|
() => {
|
||||||
dialogStatus = 'edit';
|
dialogStatus = 'edit';
|
||||||
dialog = true;
|
dialog = true;
|
||||||
|
editId = props.row.id;
|
||||||
|
name = props.row.name;
|
||||||
|
isActive = props.row.isActive;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
@ -258,7 +279,12 @@ async function onSubmit() {
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable>
|
<q-item clickable>
|
||||||
<q-item-section
|
<q-item-section
|
||||||
@click="dialogRemove($q, async () => {})"
|
@click="
|
||||||
|
dialogRemove(
|
||||||
|
$q,
|
||||||
|
async () => await deleteData(props.row.id)
|
||||||
|
)
|
||||||
|
"
|
||||||
v-close-popup
|
v-close-popup
|
||||||
>
|
>
|
||||||
<div class="row items-center white">
|
<div class="row items-center white">
|
||||||
|
|
@ -280,7 +306,7 @@ async function onSubmit() {
|
||||||
<form @submit.prevent="validateForm">
|
<form @submit.prevent="validateForm">
|
||||||
<q-card-section class="flex justify-between" style="padding: 0">
|
<q-card-section class="flex justify-between" style="padding: 0">
|
||||||
<dialog-header
|
<dialog-header
|
||||||
:tittle="dialogStatus == 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
|
:tittle="dialogStatus === 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
|
||||||
:close="closeDialog"
|
:close="closeDialog"
|
||||||
/>
|
/>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,15 @@ const { date2Thai } = useCounterMixin();
|
||||||
|
|
||||||
export const useInsigniaDataStore = defineStore("insigniaData", () => {
|
export const useInsigniaDataStore = defineStore("insigniaData", () => {
|
||||||
const row = ref<DataRow[]>();
|
const row = ref<DataRow[]>();
|
||||||
function fetchData(data: DataResponse[]) {
|
const name1 = ref<string>("");
|
||||||
console.log(data);
|
function fetchData(data: DataResponse[], insigniaType?: string) {
|
||||||
const list = data.map((e) => ({
|
const list = data.map((e) => ({
|
||||||
...e,
|
...e,
|
||||||
|
insigniaType: insigniaType,
|
||||||
createdAt: e.createdAt ? date2Thai(e.createdAt) : "",
|
createdAt: e.createdAt ? date2Thai(e.createdAt) : "",
|
||||||
lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "",
|
lastUpdatedAt: e.lastUpdatedAt ? date2Thai(e.lastUpdatedAt) : "",
|
||||||
}));
|
}));
|
||||||
console.log(list);
|
console.log("test");
|
||||||
row.value = list;
|
row.value = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue