Merge branch 'nice_dev' into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-02-08 18:06:31 +07:00
commit bd16728a36
3 changed files with 167 additions and 136 deletions

View file

@ -37,6 +37,6 @@ export default {
/**ครองตำแหน่ง */
orgSearchProfile: `${orgProfile}/search`,
orgProfile: `${orgProfile}`,
orgDeleteProfile: (id: string) => `${orgProfile}/delete/${id}`,
orgProfile: `${orgPos}/profile`,
orgDeleteProfile: (id: string) => `${orgPos}/profile/delete/${id}`,
};

View file

@ -10,7 +10,10 @@ import { useCounterMixin } from "@/stores/mixin";
import { useOrganizational } from "@/modules/02_organizationalNew/store/organizational";
import DialogHeader from "@/components/DialogHeader.vue";
import type { Position } from "@/modules/02_organizationalNew/interface/index/organizational";
import type { DataOption } from "@/modules/02_organizationalNew/interface/index/Main";
import type {
DataOption,
NewPagination,
} from "@/modules/02_organizationalNew/interface/index/Main";
import type {
OptionType,
OptionExecutive,
@ -41,13 +44,19 @@ const levelOpsMain = ref<DataOption[]>([]);
const typeOps = ref<DataOption[]>([]);
const levelOps = ref<DataOption[]>([]);
const dataLevel = ref<any>();
const selected = ref<string[]>([]);
const selected = ref<Position[]>([]);
const isSit = ref<boolean>(false);
const executiveOps = ref<DataOption[]>([]);
const store = useOrganizational();
const $q = useQuasar();
const { dialogConfirm, showLoader, success, hideLoader, messageError } =
useCounterMixin();
const {
dialogConfirm,
showLoader,
success,
hideLoader,
messageError,
dialogMessageNotify,
} = useCounterMixin();
const modal = defineModel<boolean>("modal", { required: true });
// const modal = ref<boolean>(true);
@ -58,6 +67,10 @@ const props = defineProps({
require: true,
},
dataDetailPos: { type: Object, require: true },
fetchDataTable: {
type: Function,
required: true,
},
});
const row = ref<Position[]>([]);
const rowResult = ref<SeaechResult[]>([]);
@ -319,20 +332,13 @@ function updateSelectType(val: string) {
/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */
function validateForm() {
// const hasError = [];
// for (const key in objectRef) {
// if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
// const property = objectRef[key];
// if (property.value && typeof property.value.validate === "function") {
// const isValid = property.value.validate();
// hasError.push(isValid);
// }
// }
// }
// if (hasError.every((result) => result === true)) {
onSubmit();
// } else {
// }
if (selected.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกรายการตำแหน่ง");
} else if (selectedProfile.value.length === 0) {
dialogMessageNotify($q, "กรุณาเลือกคนครอง");
} else {
onSubmit();
}
}
/** ฟังชั่น บันทึก */
@ -340,26 +346,32 @@ function onSubmit() {
dialogConfirm(
$q,
() => {
console.log("ตำแหน่ง==>", selected.value);
console.log("ทับที่==>", isSit);
// showLoader();
// http
// .post(config.API.createOrganization, formData)
// .then((res) => {
// status.value = true;
// store.typeOrganizational = "draft";
// store.draftId = res.data.result.id;
// success($q, "");
// // props.fetchActive?.();
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(async () => {
// modal.value = await false;
// await close();
// await hideLoader();
// });
// console.log("==>", selected.value[0]?.id);
// console.log("==>", selectedProfile.value[0]?.id);
// console.log("==>", isSit.value);
// console.log(props.dataDetailPos);
const body = {
posMaster: props.dataDetailPos?.id, //*id
position: selected.value[0]?.id, //*id
profileId: selectedProfile.value[0]?.id, //*id profile
isSit: isSit.value, //*
};
showLoader();
http
.post(config.API.orgProfile, body)
.then(() => {
props.fetchDataTable?.(store.treeId, store.level, false);
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
modal.value = await false;
close();
hideLoader();
});
},
"ยืนยันการเลือกคนครอง",
"ต้องการยืนยันการเลือกคนครองตำแหน่งนี้ใช่หรือไม่?"
@ -368,7 +380,9 @@ function onSubmit() {
/** เมื่อ enter ให้ทำการ ค้นหาข้อมูล */
const page = ref<number>(1);
const pageSize = ref<number>(20);
const pageSize = ref<number>(10);
const totalPage = ref<number>(0);
const selectedProfile = ref<SeaechResult[]>([]);
async function searchData() {
showLoader();
console.log(formData);
@ -384,6 +398,7 @@ async function searchData() {
.post(config.API.orgSearchProfile, reqBody)
.then((res) => {
console.log(res);
totalPage.value = Math.ceil(res.data.result.total / pageSize.value);
const list = res.data.result.data.map((e: any) => ({
id: e.id,
citizenId: e.citizenId,
@ -402,25 +417,6 @@ async function searchData() {
hideLoader();
});
// const data = [
// {
// id: "test1",
// citizenId: "test1",
// name: "test1",
// posTypeName: "test1",
// positionName: "test1",
// posLevelName: "test1",
// },
// {
// id: "test2",
// citizenId: "test2",
// name: "test2",
// posTypeName: "test2",
// positionName: "test2",
// posLevelName: "test2",
// },
// ];
// rowResult.value = data;
// props.fetchListDisciplinary?.();
}
@ -429,6 +425,15 @@ function clearPosition() {
formData.positionType = "";
formData.positionLevel = "";
}
watch([() => page.value, () => pageSize.value], () => {
searchData();
});
function updatePagination(newPagination: NewPagination) {
pageSize.value = newPagination.rowsPerPage;
page.value = 1;
}
</script>
<template>
@ -461,70 +466,66 @@ function clearPosition() {
</div>
<div class="col-12"><q-separator /></div>
<div class="row q-col-gutter-sm q-pa-sm">
<div class="col-12">
<d-table
flat
:columns="columns"
:rows="row"
row-key="id"
dense
hide-pagination
class="custom-header-table"
selection="single"
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:header="props">
<q-tr :props="props">
<q-th class="text-center"> </q-th>
<div class="q-pa-sm col-12">
<d-table
flat
:columns="columns"
:rows="row"
row-key="id"
dense
hide-pagination
class="custom-header-table"
selection="single"
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:header="props">
<q-tr :props="props">
<q-th class="text-center"> </q-th>
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<span class="text-weight-medium">{{
col.label
}}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<td class="text-center">
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</td>
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td class="text-center">
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</q-td>
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
<div v-else>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card>
@ -653,16 +654,22 @@ function clearPosition() {
/>
<div class="col-12">
<d-table
ref="table"
flat
:columns="columnsResult"
:rows="rowResult"
row-key="id"
dense
hide-pagination
class="custom-header-table"
:paging="true"
:rows-per-page-options="[10, 25, 50, 100]"
@update:pagination="updatePagination"
selection="single"
v-model:selected="selectedProfile"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th
v-for="col in props.cols"
:key="col.name"
@ -676,6 +683,14 @@ function clearPosition() {
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td>
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</q-td>
<q-td
v-for="col in props.cols"
:key="col.name"
@ -691,6 +706,17 @@ function clearPosition() {
</q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
<q-pagination
v-model="page"
active-color="primary"
color="dark"
:max="totalPage"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
</d-table>
</div>
</div>

View file

@ -322,23 +322,27 @@ function openSelectPerson(data: DataPosition[]) {
}
/** ลบคนครอง */
function removePerson(data: DataPosition[]) {
function removePerson(id: string) {
dialogRemove(
$q,
async () => {
showLoader();
// await http
// .delete(config.API.orgPosMasterById(id))
// .then(() => {
// success($q, "");
// props.fetchDataTable?.(reqMaster.value.id, reqMaster.value.type, false);
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
hideLoader();
// });
await http
.post(config.API.orgDeleteProfile(id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
props.fetchDataTable?.(
reqMaster.value.id,
reqMaster.value.type,
false
);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการลบคนครอง",
"ต้องการยืนยันการลบคนครองนี้ใช่หรือไม่?"
@ -520,7 +524,7 @@ function removePerson(data: DataPosition[]) {
"
clickable
v-close-popup
@click="removePerson(props.row)"
@click="removePerson(props.row.id)"
>
<q-item-section>
<div class="row items-center">
@ -678,6 +682,7 @@ function removePerson(data: DataPosition[]) {
<DialogSelectPerson
v-model:modal="modalSelectPerson"
:dataDetailPos="dataDetailPos"
:fetchDataTable="props.fetchDataTable"
/>
</template>