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";
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 */
import profile from "./api/registry/api.profile";
import registry from "./api/registry/api.registry";
/** API Report2 List */
import report2 from "./api/recruiting/api.report2";
@ -98,6 +99,7 @@ const API = {
//profile
...profile,
...registry,
//report2
...report2,

View file

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

View file

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