API จัดลำดับการแสดงผล
This commit is contained in:
parent
33e521facc
commit
460f133b3e
2 changed files with 55 additions and 25 deletions
|
|
@ -76,6 +76,9 @@ export default {
|
||||||
|
|
||||||
// ประวัติการศึกษา
|
// ประวัติการศึกษา
|
||||||
profileNewEducation: (type: string) => `${registryNew}${type}/educations`,
|
profileNewEducation: (type: string) => `${registryNew}${type}/educations`,
|
||||||
|
profileNewEducationSort: (type: string) =>
|
||||||
|
`${registryNew}${type}/educations/sort`,
|
||||||
|
|
||||||
profileNewEducationByProfileId: (profileId: string, type: string) =>
|
profileNewEducationByProfileId: (profileId: string, type: string) =>
|
||||||
`${registryNew}${type}/educations/${profileId}`,
|
`${registryNew}${type}/educations/${profileId}`,
|
||||||
profileNewEducationByEducationId: (educationId: string, type: string) =>
|
profileNewEducationByEducationId: (educationId: string, type: string) =>
|
||||||
|
|
@ -202,5 +205,6 @@ export default {
|
||||||
|
|
||||||
developMentPlan: `${registryNew}/development`,
|
developMentPlan: `${registryNew}/development`,
|
||||||
|
|
||||||
requestInformationbyType:(type:string,id:string)=>`${registryNew}/request-edit/${type}/${id}`
|
requestInformationbyType: (type: string, id: string) =>
|
||||||
|
`${registryNew}/request-edit/${type}/${id}`,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useOrganizational } from "@/modules/02_organization/store/organizational";
|
import { useOrganizational } from "@/modules/02_organization/store/organizational";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
|
||||||
/** importType*/
|
/** importType*/
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
|
|
@ -18,6 +19,7 @@ import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
|
||||||
/** use*/
|
/** use*/
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
|
const route = useRoute();
|
||||||
const store = useOrganizational();
|
const store = useOrganizational();
|
||||||
const {
|
const {
|
||||||
dialogConfirm,
|
dialogConfirm,
|
||||||
|
|
@ -34,21 +36,12 @@ const modal = defineModel<boolean>("modal", { required: true });
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataSort: Array as PropType<ResponseObject[]>,
|
dataSort: Array as PropType<ResponseObject[]>,
|
||||||
});
|
});
|
||||||
|
const profileId = ref<string>(route.params.id.toString()); //id profile
|
||||||
|
|
||||||
/** ข้อมูล Table*/
|
/** ข้อมูล Table*/
|
||||||
const rows = ref<ResponseObject[]>([]);
|
const rows = ref<ResponseObject[]>([]);
|
||||||
|
const selected = ref<any[]>([]);
|
||||||
const columns = ref<QTableProps["columns"]>([
|
const columns = ref<QTableProps["columns"]>([
|
||||||
{
|
|
||||||
name: "no",
|
|
||||||
align: "left",
|
|
||||||
label: "ลำดับ",
|
|
||||||
sortable: true,
|
|
||||||
field: "no",
|
|
||||||
headerStyle: "font-size: 14px",
|
|
||||||
style: "font-size: 14px",
|
|
||||||
sort: (a: string, b: string) =>
|
|
||||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "educationLevel",
|
name: "educationLevel",
|
||||||
align: "left",
|
align: "left",
|
||||||
|
|
@ -234,16 +227,42 @@ const columns = ref<QTableProps["columns"]>([
|
||||||
*/
|
*/
|
||||||
function onDrop(from: number, to: number) {
|
function onDrop(from: number, to: number) {
|
||||||
rows.value.splice(to, 0, rows.value.splice(from, 1)[0]);
|
rows.value.splice(to, 0, rows.value.splice(from, 1)[0]);
|
||||||
|
selected.value.push(rows.value[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** function บันทึกการจัดลำดับ*/
|
/** function บันทึกการจัดลำดับ*/
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
dialogConfirm($q, () => {});
|
dialogConfirm($q, async () => {
|
||||||
|
showLoader();
|
||||||
|
const body = rows.value.map((e: any) => ({
|
||||||
|
id: e.id,
|
||||||
|
isUse: selected.value.some((i: any) => i.id === e.id),
|
||||||
|
}));
|
||||||
|
|
||||||
|
await http
|
||||||
|
.put(config.API.profileNewEducationSort("") + `/${profileId.value}`, {
|
||||||
|
data: body,
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
await success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
modal.value = false;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(modal, async () => {
|
watch(modal, async () => {
|
||||||
if (modal.value && props.dataSort) {
|
if (modal.value && props.dataSort) {
|
||||||
rows.value = props.dataSort;
|
rows.value = props.dataSort;
|
||||||
|
selected.value.push(rows.value[0]);
|
||||||
|
} else {
|
||||||
|
selected.value = [];
|
||||||
|
rows.value = [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -277,26 +296,33 @@ watch(modal, async () => {
|
||||||
hide-bottom
|
hide-bottom
|
||||||
hide-pagination
|
hide-pagination
|
||||||
hide-header
|
hide-header
|
||||||
|
selection="multiple"
|
||||||
|
v-model:selected="selected"
|
||||||
>
|
>
|
||||||
|
<template v-slot:header-selection="scope">
|
||||||
|
<q-checkbox
|
||||||
|
keep-color
|
||||||
|
color="primary"
|
||||||
|
dense
|
||||||
|
v-model="scope.checkBox"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
<template v-slot:body="props">
|
<template v-slot:body="props">
|
||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
|
<q-td>
|
||||||
|
<q-checkbox
|
||||||
|
keep-color
|
||||||
|
color="primary"
|
||||||
|
dense
|
||||||
|
v-model="props.selected"
|
||||||
|
/>
|
||||||
|
</q-td>
|
||||||
<q-td
|
<q-td
|
||||||
v-for="col in props.cols"
|
v-for="col in props.cols"
|
||||||
:key="col.id"
|
:key="col.id"
|
||||||
:class="props.rowIndex === 0 ? 'text-primary' : ''"
|
:class="props.rowIndex === 0 ? 'text-primary' : ''"
|
||||||
>
|
>
|
||||||
<div v-if="col.name === 'no'">
|
<div>
|
||||||
{{
|
|
||||||
props.rowIndex === 0
|
|
||||||
? "วุฒิในตำแหน่ง"
|
|
||||||
: props.rowIndex === 1
|
|
||||||
? "ลำดับที่ 2"
|
|
||||||
: props.rowIndex === 2
|
|
||||||
? "ลำดับที่ 3"
|
|
||||||
: ""
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
{{
|
{{
|
||||||
col.value === "" || col.value === null ? "-" : col.value
|
col.value === "" || col.value === null ? "-" : col.value
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue