Merge branch 'develop' of github.com:Frappet/bma-ehr-frontend into develop

* 'develop' of github.com:Frappet/bma-ehr-frontend:
  ทะเบียนประวัติ: api registry
  ข้อมูลเครื่องราช: clear code
  ข้อมูลเครื่องราช: ปรับสไตล์/validate/ใส่catch
This commit is contained in:
Warunee Tamkoo 2024-03-15 12:08:02 +07:00
commit b8d58df613
4 changed files with 166 additions and 103 deletions

View file

@ -1,5 +1,14 @@
import env from "../index"; import env from "../index";
export default { const registryNew = `${env.API_URI}/org/profile/`;
} export default {
registryNew,
profileNewInsign: `${registryNew}insignia`,
profileNewInsignByProfileId: (profileId: string) =>
`${registryNew}insignia/${profileId}`,
profileNewInsignByInsignId: (insignId: string) =>
`${registryNew}insignia/${insignId}`,
profileNewInsignHisByInsignId: (insignId: string) =>
`${registryNew}insignia/history/${insignId}`,
};

View file

@ -23,6 +23,7 @@ import recruit from "./api/recruiting/api.recruit";
/** API Profile List */ /** API Profile List */
import profile from "./api/registry/api.profile"; import profile from "./api/registry/api.profile";
import registry from "./api/registry/api.registry";
/** API Report2 List */ /** API Report2 List */
import report2 from "./api/recruiting/api.report2"; import report2 from "./api/recruiting/api.report2";
@ -98,6 +99,7 @@ const API = {
//profile //profile
...profile, ...profile,
...registry,
//report2 //report2
...report2, ...report2,

View file

@ -2,7 +2,7 @@
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 { useRoute } 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 TableDraggable from "@/modules/01_metadataNew/components/insignia/TableDraggable.vue"; import TableDraggable from "@/modules/01_metadataNew/components/insignia/TableDraggable.vue";
@ -10,21 +10,20 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
const store = useInsigniaDataStore(); const store = useInsigniaDataStore();
const router = useRouter();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
// const props = defineProps({
// fetchData: {
// type: Function,
// default: () => "",
// },
// });
const insigniaTypeName = defineModel<string>("insigniaTypeName", { const insigniaTypeName = defineModel<string>("insigniaTypeName", {
required: true, required: true,
}); });
const { dialogRemove, dialogConfirm, showLoader, hideLoader, messageError } = const {
mixin; dialogRemove,
dialogConfirm,
showLoader,
hideLoader,
messageError,
success,
} = mixin;
const $q = useQuasar(); const $q = useQuasar();
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -216,26 +215,49 @@ async function addData() {
}) })
.then(() => { .then(() => {
fetchData(id.value); fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ");
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
})
.finally(() => {
hideLoader();
}); });
} }
async function editData(idData: string) { async function editData(idData: string) {
await http.put(config.API.insigniaNewIdOrg(idData), { await http
name: name.value, .put(config.API.insigniaNewIdOrg(idData), {
isActive: isActive.value, name: name.value,
shortName: shortName.value, isActive: isActive.value,
note: note.value == "" ? "-" : note.value, shortName: shortName.value,
insigniaTypeId: id.value, note: note.value == "" ? "-" : note.value,
}); insigniaTypeId: id.value,
fetchData(id.value); })
.then(() => {
fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
} }
async function deleteData(idData: string) { async function deleteData(idData: string) {
await http.delete(config.API.insigniaNewIdOrg(idData)); await http
fetchData(id.value); .delete(config.API.insigniaNewIdOrg(idData))
.then(() => {
fetchData(id.value);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
} }
import { defineEmits } from "vue"; import { defineEmits } from "vue";
@ -382,7 +404,7 @@ const dialogOrder = ref<boolean>(false);
</d-table> </d-table>
<q-dialog v-model="dialog" class="dialog" persistent> <q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="min-width: 350px" class="bg-grey-11"> <q-card style="min-width: 350px">
<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
@ -393,55 +415,59 @@ const dialogOrder = ref<boolean>(false);
<q-separator color="grey-4" /> <q-separator color="grey-4" />
<q-card-section class="q-pa-none"> <q-card-section class="q-pa-none">
<q-input <div class="col-12 q-ma-md">
outlined <q-input
:model-value="insigniaTypeId" outlined
label="ลำดับชั้นเครื่องราชฯ" :model-value="insigniaTypeId"
dense label="ลำดับชั้นเครื่องราชฯ"
lazy-rules dense
borderless lazy-rules
class="col-12 bg-white q-ma-md" borderless
hide-bottom-space hide-bottom-space
readonly readonly
/> />
<q-input </div>
ref="nameRef" <div class="col-12 q-ma-md">
outlined <q-input
v-model="name" ref="nameRef"
label="ชื่อเครื่องราชฯ" outlined
dense v-model="name"
lazy-rules label="ชื่อเครื่องราชฯ"
borderless dense
class="col-12 bg-white q-ma-md" lazy-rules
:rules="[ borderless
(val) => val.length > 0 || 'กรุณากรอกลำดับชั้นเครื่องราชฯ', :rules="[
]" (val) => val.length > 0 || 'กรุณากรอกลำดับชั้นเครื่องราชฯ',
hide-bottom-space ]"
/> hide-bottom-space
<q-input />
ref="shortNameRef" </div>
outlined <div class="col-12 q-ma-md">
v-model="shortName" <q-input
label="ชื่อย่อ" ref="shortNameRef"
dense outlined
lazy-rules v-model="shortName"
borderless label="ชื่อย่อ"
class="col-12 bg-white q-ma-md" dense
:rules="[ lazy-rules
(val) => val.length > 0 || 'กรุณากรอกลำดับชั้นเครื่องราชฯ', borderless
]" :rules="[
hide-bottom-space (val) => val.length > 0 || 'กรุณากรอกลำดับชั้นเครื่องราชฯ',
/> ]"
<q-input hide-bottom-space
outlined />
v-model="note" </div>
label="หมายเหตุ" <div class="col-12 q-ma-md">
dense <q-input
type="textarea" outlined
borderless v-model="note"
class="col-12 bg-white q-ma-md" label="หมายเหตุ"
hide-bottom-space dense
/> type="textarea"
borderless
hide-bottom-space
/>
</div>
<div <div
class="col q-ma-md q-pa-sm bg-white border_custom text-weight-medium" class="col q-ma-md q-pa-sm bg-white border_custom text-weight-medium"
> >
@ -463,7 +489,6 @@ const dialogOrder = ref<boolean>(false);
unelevated unelevated
label="บันทึก" label="บันทึก"
color="public" color="public"
class="q-px-md"
> >
<q-tooltip>นทกขอม</q-tooltip> <q-tooltip>นทกขอม</q-tooltip>
</q-btn> </q-btn>

View file

@ -95,8 +95,6 @@ const visibleColumns = ref<string[]>([
"isActive", "isActive",
]); ]);
// const row = ref([]);
async function fetchData() { async function fetchData() {
showLoader(); showLoader();
await http await http
@ -125,24 +123,53 @@ function onclickDetail(id: string) {
} }
async function addData() { async function addData() {
await http.post(config.API.insigniaTypeOrg, { await http
name: name.value, .post(config.API.insigniaTypeOrg, {
isActive: isActive.value, name: name.value,
}); isActive: isActive.value,
fetchData(); })
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
} }
async function editData(id: string) { async function editData(id: string) {
await http.put(config.API.insigniaTypeNewIdOrg(id), { await http
name: name.value, .put(config.API.insigniaTypeNewIdOrg(id), {
isActive: isActive.value, name: name.value,
}); isActive: isActive.value,
fetchData(); })
.then(() => {
fetchData();
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
} }
async function deleteData(id: string) { async function deleteData(id: string) {
await http.delete(config.API.insigniaTypeNewIdOrg(id)); await http
fetchData(); .delete(config.API.insigniaTypeNewIdOrg(id))
.then(() => {
fetchData();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
} }
function validateForm() { function validateForm() {
@ -287,7 +314,7 @@ async function onSubmit() {
</d-table> </d-table>
<q-dialog v-model="dialog" class="dialog" persistent> <q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="min-width: 350px" class="bg-grey-11"> <q-card style="min-width: 350px">
<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
@ -298,20 +325,21 @@ async function onSubmit() {
<q-separator color="grey-4" /> <q-separator color="grey-4" />
<q-card-section class="q-pa-none"> <q-card-section class="q-pa-none">
<q-input <div class="col-12 q-ma-md">
ref="nameRef" <q-input
outlined ref="nameRef"
v-model="name" outlined
label="ลำดับชั้นเครื่องราชฯ" v-model="name"
dense label="ลำดับชั้นเครื่องราชฯ"
lazy-rules dense
borderless lazy-rules
class="col-12 bg-white q-ma-md" borderless
:rules="[ :rules="[
(val) => val.length > 0 || 'กรุณากรอกลำดับชั้นเครื่องราชฯ', (val) => val.length > 0 || 'กรุณากรอกลำดับชั้นเครื่องราชฯ',
]" ]"
hide-bottom-space hide-bottom-space
/> />
</div>
<div <div
class="col q-ma-md q-pa-sm bg-white border_custom text-weight-medium" class="col q-ma-md q-pa-sm bg-white border_custom text-weight-medium"
> >
@ -333,7 +361,6 @@ async function onSubmit() {
unelevated unelevated
label="บันทึก" label="บันทึก"
color="public" color="public"
class="q-px-md"
> >
<q-tooltip>นทกขอม</q-tooltip> <q-tooltip>นทกขอม</q-tooltip>
</q-btn> </q-btn>