start commit for admin system
This commit is contained in:
commit
badb676529
300 changed files with 58634 additions and 0 deletions
334
src/components/Dialogs/AddPersonal.vue
Normal file
334
src/components/Dialogs/AddPersonal.vue
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import type { ResponsePreson } from "@/interface/response/listPerson";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
|
||||
const mainStore = useDisciplineMainStore();
|
||||
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const { dialogMessageNotify, showLoader, hideLoader } = mixin;
|
||||
|
||||
interface typeOp {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface tableType {
|
||||
personId: string;
|
||||
idcard: string;
|
||||
prefix: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
position: string;
|
||||
positionLevel: string;
|
||||
organization: string;
|
||||
salary: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const rows = ref<tableType[]>([]);
|
||||
const type = ref<string>("idcard");
|
||||
const search = ref<string>("");
|
||||
const selected = ref<any>([]);
|
||||
|
||||
const typeOps = ref<typeOp[]>([
|
||||
{ id: "idcard", name: "เลขประจำตัวประชาชน" },
|
||||
{ id: "firstname", name: "ชื่อ" },
|
||||
{ id: "lastname", name: "นามสกุล" },
|
||||
]);
|
||||
|
||||
/** รับค่ามาจาก หน้าหลัก */
|
||||
const props = defineProps({
|
||||
modal: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true,
|
||||
},
|
||||
btnTitle: {
|
||||
type: String,
|
||||
default: "เพิ่ม",
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
desc: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
selectedData: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
close: {
|
||||
type: Function,
|
||||
default: () => console.log("not function"),
|
||||
required: true,
|
||||
},
|
||||
save: {
|
||||
type: Function,
|
||||
default: () => console.log("not function"),
|
||||
required: true,
|
||||
},
|
||||
selecetSwitch: {
|
||||
type: String,
|
||||
default: "multiple",
|
||||
},
|
||||
});
|
||||
|
||||
/**ส่งค่ากลับหน้าหลัก */
|
||||
const emit = defineEmits(["returnData"]);
|
||||
|
||||
/** ปิด dialog */
|
||||
async function close() {
|
||||
console.log("close");
|
||||
props.close();
|
||||
}
|
||||
|
||||
/** เปิด dialog ยืนยัน */
|
||||
function savePost() {
|
||||
if (selected.value.length != 0) {
|
||||
// dialogConfirm($q, () => saveData());
|
||||
saveData();
|
||||
} else {
|
||||
dialogMessageNotify($q, "กรุณาเลือกอย่างน้อย 1 รายการ");
|
||||
}
|
||||
}
|
||||
|
||||
/** save data หลังจาก ยืนยัน */
|
||||
function saveData() {
|
||||
props.save();
|
||||
emit("returnData", selected.value);
|
||||
}
|
||||
|
||||
const searchRef = ref<any>(null);
|
||||
/** input ค้นหา */
|
||||
async function searchInput() {
|
||||
searchRef.value.validate();
|
||||
if (!searchRef.value.hasError) {
|
||||
showLoader();
|
||||
const body = {
|
||||
fieldName: type.value,
|
||||
keyword: search.value,
|
||||
};
|
||||
await http
|
||||
.post(config.API.orgSearchPersonal(), body)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
const list = data.map((e: any) => ({
|
||||
personId: e.id,
|
||||
idcard: e.idcard,
|
||||
prefix: e.prefix,
|
||||
firstName: e.firstName,
|
||||
lastName: e.lastName,
|
||||
name: `${e.prefix}${e.firstName} ${e.lastName}`,
|
||||
posNo: e.posNo ?? "-",
|
||||
position: e.position ?? "-",
|
||||
positionLevel: e.positionLevelName ?? "-",
|
||||
salary: e.salary ?? "-",
|
||||
organization: e.organization ?? "-",
|
||||
phone: e.phone ?? "-",
|
||||
email: e.email ?? "-",
|
||||
root: e.root,
|
||||
rootId: e.rootId,
|
||||
rootShortName: e.rootShortName,
|
||||
child1: e.child1,
|
||||
child1Id: e.child1Id,
|
||||
child1ShortName: e.child1ShortName,
|
||||
child2: e.child2,
|
||||
child2Id: e.child2Id,
|
||||
child2ShortName: e.child2ShortName,
|
||||
child3: e.child3,
|
||||
child3Id: e.child3Id,
|
||||
child3ShortName: e.child3ShortName,
|
||||
child4: e.child4,
|
||||
child4Id: e.child4Id,
|
||||
child4ShortName: e.child4ShortName,
|
||||
posMasterNo: e.posMasterNo,
|
||||
posTypeId: e.posTypeId,
|
||||
posTypeName: e.posTypeName,
|
||||
posLevelId: e.posLevelId,
|
||||
posLevelName: e.posLevelName,
|
||||
}));
|
||||
|
||||
rows.value = list;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** update เมื่อเปลี่ยน option */
|
||||
function updateSelect() {
|
||||
search.value = "";
|
||||
}
|
||||
watch(
|
||||
() => props.selectedData,
|
||||
() => {
|
||||
if (props.selectedData) {
|
||||
selected.value = props.selectedData;
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="props.modal" persistent>
|
||||
<q-card style="min-width: 60vw">
|
||||
<q-toolbar>
|
||||
<q-toolbar-title class="text-subtitle2 text-bold">{{
|
||||
props.title
|
||||
}}</q-toolbar-title>
|
||||
<q-btn
|
||||
icon="close"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
@click="close"
|
||||
style="color: #ff8080; background-color: #ffdede"
|
||||
/>
|
||||
</q-toolbar>
|
||||
<q-separator />
|
||||
<q-card-section class="q-pa-md">
|
||||
<div class="row col-12 q-col-gutter-sm items-start">
|
||||
<div class="col-12 col-sm-5 col-md-3">
|
||||
<q-select
|
||||
label="ค้นหาจาก"
|
||||
v-model="type"
|
||||
:options="typeOps"
|
||||
emit-value
|
||||
dense
|
||||
@update:model-value="updateSelect"
|
||||
map-options
|
||||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-sm-7 col-md-9">
|
||||
<q-input
|
||||
ref="searchRef"
|
||||
v-model="search"
|
||||
outlined
|
||||
clearable
|
||||
dense
|
||||
label="คำค้น"
|
||||
:rules="[(val) => !!val || `กรุณากรอกคำค้น`]"
|
||||
>
|
||||
<template v-slot:after>
|
||||
<q-btn
|
||||
color="primary"
|
||||
icon="search"
|
||||
label="ค้นหา"
|
||||
outline
|
||||
class="full-width q-py-sm q-px-md"
|
||||
@click="searchInput()"
|
||||
>
|
||||
</q-btn>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="full-width">
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="mainStore.columnsRespondent"
|
||||
:rows="rows"
|
||||
row-key="personId"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:visible-columns="mainStore.visibleColumnsRespondent"
|
||||
:selection="props.selecetSwitch"
|
||||
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-checkbox
|
||||
keep-color
|
||||
color="primary"
|
||||
dense
|
||||
v-model="props.selected"
|
||||
/>
|
||||
</q-th>
|
||||
<q-th
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
style="color: #000000; font-weight: 500"
|
||||
>
|
||||
<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-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-if="col.name === 'fullName'">
|
||||
{{ props.prefix }}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'salary'">
|
||||
{{ props.row.salary.toLocaleString() }}
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
||||
<div class="row justify-end q-px-md q-py-sm items-center">
|
||||
<q-btn
|
||||
dense
|
||||
color="public"
|
||||
id="onSubmit"
|
||||
class="q-px-md q-py-xs"
|
||||
@click="savePost"
|
||||
>
|
||||
<!-- <q-icon left name="add" /> -->
|
||||
<div>{{ props.btnTitle }}</div>
|
||||
<!-- icon="mdi-content-save-outline" -->
|
||||
<q-tooltip>{{ props.btnTitle }}</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
901
src/components/Dialogs/DialogOrgSelect.vue
Normal file
901
src/components/Dialogs/DialogOrgSelect.vue
Normal file
|
|
@ -0,0 +1,901 @@
|
|||
<script setup lang="ts">
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { ref, watch, reactive } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import CardPosition from "@/modules/05_placement/components/PersonalList/CardPosition.vue";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type {
|
||||
OrgTree,
|
||||
DataTree,
|
||||
PositionMain,
|
||||
PositionNo,
|
||||
Positions,
|
||||
DataPositionNo,
|
||||
FormActive,
|
||||
TreeMain,
|
||||
} from "@/interface/request/orgSelect/org";
|
||||
|
||||
const props = defineProps({
|
||||
dataRows: {
|
||||
type: Object,
|
||||
require: true,
|
||||
},
|
||||
onSubmit: Function,
|
||||
});
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
messageError,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
dialogMessageNotify,
|
||||
} = mixin;
|
||||
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const title = defineModel<string>("title", { required: true });
|
||||
const type = defineModel<any>("type", { required: true });
|
||||
|
||||
const posType = defineModel<any>("posType", { required: true });
|
||||
const posLevel = defineModel<any>("posLevel", { required: true });
|
||||
const position = defineModel<any>("position", { required: true });
|
||||
|
||||
const orgRevisionId = ref<string>("");
|
||||
const filter = ref<string>("");
|
||||
const isAll = ref<boolean>(false);
|
||||
const isBlank = ref<boolean>(false);
|
||||
const posMasterMain = ref<any>([]);
|
||||
const positionNo = ref<DataPositionNo[]>();
|
||||
const itemTaps = ref<string[]>();
|
||||
const filters = ref<string>("");
|
||||
const positionId = ref<string>("");
|
||||
const selectedPos = ref<any[]>([]);
|
||||
const seletcId = ref<string>("");
|
||||
const datePos = ref<Date>(new Date());
|
||||
const rowsPosition = ref<Positions[]>([]);
|
||||
const positionData = ref<any>();
|
||||
/** active form */
|
||||
const formActive = reactive<FormActive>({
|
||||
activeId: "",
|
||||
activeName: "",
|
||||
draftId: "",
|
||||
draftName: "",
|
||||
orgPublishDate: null,
|
||||
isPublic: false,
|
||||
});
|
||||
/** node */
|
||||
const nodes = ref<Array<OrgTree>>([]);
|
||||
const lazy = ref(nodes);
|
||||
const expanded = ref<string[]>([]);
|
||||
const nodeLevel = ref<number>(0);
|
||||
const nodeId = ref<string>(""); // id ของ Tree
|
||||
|
||||
/** columns*/
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "isPosition",
|
||||
align: "left",
|
||||
label: "",
|
||||
sortable: true,
|
||||
field: "isPosition",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: true,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posMasterNo",
|
||||
align: "left",
|
||||
label: "เลขที่ตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "posMasterNo",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionName",
|
||||
align: "left",
|
||||
label: "ตำแหน่งในสายงาน",
|
||||
field: "positionName",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeName",
|
||||
align: "left",
|
||||
label: "ประเภทตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "posTypeName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posLevelName",
|
||||
align: "left",
|
||||
label: "ระดับตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "posLevelName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionIsSelected",
|
||||
align: "left",
|
||||
label: "คนครอง",
|
||||
sortable: true,
|
||||
field: "positionIsSelected",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const columnsPostition = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: false,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionName",
|
||||
align: "left",
|
||||
label: "ตำแหน่งในสายงาน",
|
||||
sortable: true,
|
||||
field: "positionName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionField",
|
||||
align: "left",
|
||||
label: "สายงาน",
|
||||
sortable: true,
|
||||
field: "positionField",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeName",
|
||||
align: "left",
|
||||
label: "ประเภทตำเเหน่ง",
|
||||
sortable: true,
|
||||
field: "posTypeName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posLevelName",
|
||||
align: "left",
|
||||
label: "ระดับตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "posLevelName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posExecutiveName",
|
||||
align: "left",
|
||||
label: "ตำแหน่งทางการบริหาร",
|
||||
sortable: true,
|
||||
field: "posExecutiveName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionExecutiveField",
|
||||
align: "left",
|
||||
label: "ด้านทางการบริหาร",
|
||||
sortable: true,
|
||||
field: "positionExecutiveField",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionArea",
|
||||
align: "left",
|
||||
label: "ด้าน/สาขา",
|
||||
sortable: true,
|
||||
field: "positionArea",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
"isPosition",
|
||||
"no",
|
||||
"posMasterNo",
|
||||
"positionName",
|
||||
"posTypeName",
|
||||
"posLevelName",
|
||||
"positionIsSelected",
|
||||
]);
|
||||
|
||||
/** ปิด dialog */
|
||||
function close() {
|
||||
modal.value = false;
|
||||
|
||||
type.value = null;
|
||||
filter.value = "";
|
||||
isAll.value = false;
|
||||
isBlank.value = false;
|
||||
|
||||
nodes.value = [];
|
||||
expanded.value = [];
|
||||
nodeLevel.value = 0;
|
||||
nodeId.value = "";
|
||||
}
|
||||
|
||||
async function getDataTable(id: string, level: number = 0) {
|
||||
showLoader();
|
||||
|
||||
const body = {
|
||||
node: level,
|
||||
nodeId: id,
|
||||
typeCommand: type.value,
|
||||
position: posType.value ? posType.value : "",
|
||||
posLevel: posLevel.value ? posLevel.value : "",
|
||||
posType: position.value ? position.value : "",
|
||||
isAll: isAll.value,
|
||||
isBlank: isBlank.value,
|
||||
};
|
||||
|
||||
await http
|
||||
.post(config.API.orgPosPlacement, body)
|
||||
.then((res) => {
|
||||
const dataMain: PositionMain[] = [];
|
||||
posMasterMain.value = res.data.result.data;
|
||||
|
||||
res.data.result.data.forEach((e: PositionNo) => {
|
||||
const p = e.positions;
|
||||
if (p.length !== 0) {
|
||||
const a = p.find((el: Positions) => el.positionIsSelected === true);
|
||||
const { id, ...rest } = a ? a : p[0];
|
||||
const data: any = { ...e, ...rest };
|
||||
dataMain.push(data);
|
||||
}
|
||||
});
|
||||
const listPosNo: DataPositionNo[] = dataMain.map((e: PositionMain) => ({
|
||||
id: e.id,
|
||||
isPosition: e.isPosition,
|
||||
posMasterNo:
|
||||
e.orgShortname +
|
||||
(e.posMasterNoPrefix != null ? e.posMasterNoPrefix : "") +
|
||||
e.posMasterNo +
|
||||
(e.posMasterNoSuffix != null ? e.posMasterNoSuffix : ""),
|
||||
positionName: e.positionName,
|
||||
posTypeName: e.posTypeName,
|
||||
posLevelName: e.posLevelName,
|
||||
positionIsSelected: e.positionIsSelected
|
||||
? e.fullNameCurrentHolder
|
||||
: "-",
|
||||
isSit: e.isSit,
|
||||
positions: e.positions,
|
||||
node: e.node,
|
||||
nodeId: e.nodeId,
|
||||
}));
|
||||
|
||||
positionNo.value = listPosNo;
|
||||
positionData.value = listPosNo;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* funtion เลือกข้อมูล Tree
|
||||
* @param data ข่อมูล Tree
|
||||
*/
|
||||
function updateSelected(data: DataTree) {
|
||||
if (props?.dataRows?.nodeId === data.orgTreeId) {
|
||||
positionId.value = props?.dataRows?.posmasterId;
|
||||
seletcId.value = props?.dataRows?.positionId;
|
||||
datePos.value = props?.dataRows?.reportingDateFullDate;
|
||||
} else {
|
||||
positionId.value = "";
|
||||
seletcId.value = "";
|
||||
selectedPos.value = [];
|
||||
datePos.value = new Date();
|
||||
}
|
||||
|
||||
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
|
||||
nodeLevel.value = data.orgLevel;
|
||||
getDataTable(data.orgTreeId, data.orgLevel);
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
|
||||
formActive.activeId = data.activeId;
|
||||
formActive.activeName = data.activeName;
|
||||
formActive.draftId = data.draftId;
|
||||
formActive.draftName = data.draftName;
|
||||
formActive.orgPublishDate = data.orgPublishDate;
|
||||
formActive.isPublic = data.isPublic;
|
||||
|
||||
getTreeData(data.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล หน่วยงาน */
|
||||
async function getTreeData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByid(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
nodes.value = data;
|
||||
filterItemsTaps(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function filterItemsTaps(data: TreeMain[]) {
|
||||
let orgTreeIds: string[] = [];
|
||||
for (const child of data) {
|
||||
orgTreeIds.push(child.orgTreeId);
|
||||
if (child.children) {
|
||||
orgTreeIds = orgTreeIds.concat(filterItemsTaps(child.children));
|
||||
}
|
||||
}
|
||||
itemTaps.value = orgTreeIds;
|
||||
return orgTreeIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* function เลือกเลขที่ตำแหน่ง
|
||||
* @param id เลชที่ตำแหน่ง
|
||||
*/
|
||||
async function onClickSelectPos(id: string) {
|
||||
positionData.value = positionNo.value;
|
||||
positionId.value = id;
|
||||
selectedPos.value = [];
|
||||
const position: DataPositionNo = positionData.value.find(
|
||||
(e: DataPositionNo) => e.id === id
|
||||
);
|
||||
|
||||
// หาตำแหน่ง
|
||||
if (position) {
|
||||
rowsPosition.value = position.positions;
|
||||
if (seletcId.value) {
|
||||
selectedPos.value = rowsPosition.value.filter(
|
||||
(e) => e.id === seletcId.value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูล expanded tree
|
||||
* @param level levelTree
|
||||
* @param id treeId
|
||||
*/
|
||||
async function fetchPosFind(level: number, id: string) {
|
||||
showLoader();
|
||||
const body = {
|
||||
node: level,
|
||||
nodeId: id,
|
||||
};
|
||||
await http
|
||||
.post(config.API.orgPosFind, body)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
expanded.value = data;
|
||||
nodeId.value = id;
|
||||
positionId.value = props?.dataRows?.posmasterId;
|
||||
seletcId.value = props?.dataRows?.positionId;
|
||||
datePos.value = props?.dataRows?.reportingDateFullDate;
|
||||
|
||||
getDataTable(nodeId.value, level);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => modal.value,
|
||||
async (n) => {
|
||||
if (n == true) {
|
||||
getActive();
|
||||
if (props?.dataRows?.node !== null && props?.dataRows?.nodeId !== null) {
|
||||
await fetchPosFind(props?.dataRows?.node, props?.dataRows?.nodeId);
|
||||
if (positionId.value) {
|
||||
setTimeout(async () => {
|
||||
await onClickSelectPos(positionId.value);
|
||||
}, 200);
|
||||
}
|
||||
} else {
|
||||
expanded.value = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isAll.value,
|
||||
(value, oldVal) => {
|
||||
if (value !== oldVal) {
|
||||
getDataTable(nodeId.value, nodeLevel.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isBlank.value,
|
||||
(value, oldVal) => {
|
||||
if (value !== oldVal) {
|
||||
getDataTable(nodeId.value, nodeLevel.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => positionId.value,
|
||||
(n) => {
|
||||
if (n) {
|
||||
onClickSelectPos(n);
|
||||
}
|
||||
}
|
||||
);
|
||||
function onSubmit() {
|
||||
const dataPosMaster = posMasterMain.value?.find(
|
||||
(e: any) => e.id === positionId.value
|
||||
);
|
||||
|
||||
console.log(dataPosMaster);
|
||||
if (selectedPos.value.length === 0) {
|
||||
dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง");
|
||||
} else {
|
||||
dialogConfirm($q, async () => {
|
||||
const body = {
|
||||
personalId: props?.dataRows?.id,
|
||||
node: dataPosMaster.node,
|
||||
nodeId: dataPosMaster.nodeId,
|
||||
orgRevisionId: formActive.activeId,
|
||||
positionId: selectedPos.value[0].id,
|
||||
posMasterNo: dataPosMaster.posMasterNo, //เลขที่ตำแหน่ง(เลขอย่่างเดียว)
|
||||
positionName: selectedPos.value[0].positionName, //ชื่อตำแหน่ง
|
||||
positionField: selectedPos.value[0].positionField, //ชื่อตำแหน่ง
|
||||
posTypeId: selectedPos.value[0].posTypeId, //ชื่อตำแหน่ง
|
||||
posTypeName: selectedPos.value[0].posTypeName, //ชื่อตำแหน่ง
|
||||
posLevelId: selectedPos.value[0].posLevelId, //ชื่อตำแหน่ง
|
||||
posLevelName: selectedPos.value[0].posLevelName, //ชื่อตำแหน่ง
|
||||
reportingDate: datePos.value,
|
||||
posmasterId: dataPosMaster.id,
|
||||
typeCommand: type.value,
|
||||
};
|
||||
props.onSubmit?.(body);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent full-width>
|
||||
<q-card class="no-scroll">
|
||||
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||
<DialogHeader :tittle="title" :close="close" />
|
||||
<q-separator />
|
||||
<q-card-section style="max-height: 80vh" class="scroll">
|
||||
<div class="row">
|
||||
<q-card
|
||||
bordered
|
||||
class="col-12 col-sm-3 scroll q-pa-sm"
|
||||
style="height: 75vh"
|
||||
>
|
||||
<q-toolbar style="padding: 0">
|
||||
<q-toolbar-title class="text-subtitle2 text-bold"
|
||||
>เลือกหน่วยงาน/ส่วนราชการ</q-toolbar-title
|
||||
>
|
||||
</q-toolbar>
|
||||
|
||||
<q-input dense outlined v-model="filter" label="ค้นหา">
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
v-if="filter !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="filter = ''"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
<q-tree
|
||||
class="q-pa-sm q-gutter-sm"
|
||||
dense
|
||||
:nodes="lazy"
|
||||
node-key="orgTreeId"
|
||||
label-key="orgTreeName"
|
||||
:filter="filter"
|
||||
no-results-label="ไม่พบข้อมูลที่ค้นหา"
|
||||
no-nodes-label="ไม่มีข้อมูล"
|
||||
v-model:expanded="expanded"
|
||||
>
|
||||
<template v-slot:default-header="prop">
|
||||
<q-item
|
||||
@click.stop="updateSelected(prop.node)"
|
||||
clickable
|
||||
:active="nodeId == prop.node.orgTreeId"
|
||||
active-class="my-list-link text-primary text-weight-medium"
|
||||
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
|
||||
>
|
||||
<div>
|
||||
<div class="text-weight-medium">
|
||||
{{ prop.node.orgTreeName }}
|
||||
</div>
|
||||
<div class="text-weight-light">
|
||||
{{
|
||||
prop.node.orgCode == null ? null : prop.node.orgCode
|
||||
}}
|
||||
{{
|
||||
prop.node.orgTreeShortName == null
|
||||
? null
|
||||
: prop.node.orgTreeShortName
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-tree>
|
||||
</q-card>
|
||||
<q-card bordered class="col-12 col-sm-9 q-pa-sm">
|
||||
<q-tab-panels
|
||||
v-model="nodeId"
|
||||
animated
|
||||
transition-prev="jump-up"
|
||||
transition-next="jump-up"
|
||||
>
|
||||
<q-tab-panel
|
||||
v-for="(item, index) in itemTaps"
|
||||
:key="index"
|
||||
:name="item"
|
||||
>
|
||||
<div class="column q-col-gutter-sm" style="height: 70vh">
|
||||
<!-- เลือกเลขที่ตำแหน่ง -->
|
||||
<div class="col-7">
|
||||
<q-card
|
||||
bordered
|
||||
style="height: 100%; border: 1px solid #d6dee1"
|
||||
>
|
||||
<div
|
||||
class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
||||
>
|
||||
เลือกเลขที่ตำแหน่ง
|
||||
</div>
|
||||
<div class="col-12"><q-separator /></div>
|
||||
<div class="col-12 q-pa-md">
|
||||
<q-toolbar style="padding: 0px">
|
||||
<div class="row q-gutter-md">
|
||||
<q-checkbox
|
||||
keep-color
|
||||
v-model="isBlank"
|
||||
label="แสดงเฉพาะตำแหน่งว่าง"
|
||||
color="primary"
|
||||
>
|
||||
<q-tooltip>แสดงเฉพาะตำแหน่งว่าง </q-tooltip>
|
||||
</q-checkbox>
|
||||
</div>
|
||||
<q-space />
|
||||
|
||||
<div class="row q-gutter-md">
|
||||
<q-checkbox
|
||||
keep-color
|
||||
v-model="isAll"
|
||||
label="แสดงตำแหน่งทั้งหมด"
|
||||
color="primary"
|
||||
>
|
||||
<q-tooltip
|
||||
>แสดงตำแหน่งทั้งหมดภายใต้หน่วยงาน/ส่วนราชการที่เลือก</q-tooltip
|
||||
>
|
||||
</q-checkbox>
|
||||
<div>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
v-model="filters"
|
||||
label="ค้นหา"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" color="grey-5" />
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<div>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
emit-value
|
||||
:display-value="$q.lang.table.columns"
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 180px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="positionData"
|
||||
:filter="filters"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
class="tableTb"
|
||||
:visible-columns="visibleColumns"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<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
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
@click="onClickSelectPos(props.row.id)"
|
||||
:class="
|
||||
props.row.id === positionId
|
||||
? 'bg-blue-2'
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'posMasterNo'">
|
||||
{{
|
||||
props.row.isSit
|
||||
? col.value + " " + "(ทับที่)"
|
||||
: col.value
|
||||
}}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'isPosition'">
|
||||
<div v-if="col.value">
|
||||
<q-icon
|
||||
name="done"
|
||||
color="primary"
|
||||
size="24px"
|
||||
>
|
||||
<q-tooltip>ตรงตามตำแหน่ง </q-tooltip>
|
||||
</q-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<!-- เลือกตำแหน่ง -->
|
||||
<div class="col-5">
|
||||
<q-card
|
||||
bordered
|
||||
style="height: 100%; border: 1px solid #d6dee1"
|
||||
>
|
||||
<div
|
||||
class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
||||
>
|
||||
เลือกตำแหน่ง
|
||||
</div>
|
||||
<div class="col-12"><q-separator /></div>
|
||||
<q-tab-panels
|
||||
v-model="positionId"
|
||||
animated
|
||||
swipeable
|
||||
vertical
|
||||
transition-prev="jump-up"
|
||||
transition-next="jump-up"
|
||||
>
|
||||
<q-tab-panel
|
||||
v-for="(item, index) in positionData"
|
||||
:key="index"
|
||||
:name="item.id"
|
||||
>
|
||||
<div class="col-12">
|
||||
<q-toolbar style="padding: 0px">
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
v-model="datePos"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
:min-date="datePos"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
ref="dateRef"
|
||||
outlined
|
||||
dense
|
||||
hide-bottom-space
|
||||
:model-value="
|
||||
datePos != null
|
||||
? date2Thai(datePos)
|
||||
: null
|
||||
"
|
||||
label="วันที่รายงานตัว"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columnsPostition"
|
||||
:rows="rowsPosition"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
class="tableTb"
|
||||
selection="single"
|
||||
v-model:selected="selectedPos"
|
||||
>
|
||||
<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 auto-width />
|
||||
<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>
|
||||
<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>
|
||||
<div
|
||||
v-else-if="col.name === 'posMasterNo'"
|
||||
>
|
||||
{{
|
||||
props.row.isSit
|
||||
? col.value + " " + "(ทับที่)"
|
||||
: col.value
|
||||
}}
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
||||
<q-card-actions align="right" class="bg-white text-teal">
|
||||
<q-btn label="บันทึก" color="secondary" type="submit"
|
||||
><q-tooltip>บันทึกข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
<style scoped>
|
||||
.my-list-link {
|
||||
color: rgb(118, 168, 222);
|
||||
border-radius: 5px;
|
||||
background: #a3d3fb48 !important;
|
||||
font-weight: 600;
|
||||
border: 1px solid rgba(175, 185, 196, 0.217);
|
||||
}
|
||||
</style>
|
||||
880
src/components/Dialogs/DialogOrgSelectEmployee.vue
Normal file
880
src/components/Dialogs/DialogOrgSelectEmployee.vue
Normal file
|
|
@ -0,0 +1,880 @@
|
|||
<script setup lang="ts">
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { ref, watch, reactive } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import CardPosition from "@/modules/05_placement/components/PersonalList/CardPosition.vue";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type {
|
||||
OrgTree,
|
||||
DataTree,
|
||||
PositionMain,
|
||||
PositionNo,
|
||||
Positions,
|
||||
DataPositionNo,
|
||||
FormActive,
|
||||
TreeMain,
|
||||
} from "@/interface/request/orgSelect/org";
|
||||
|
||||
const props = defineProps({
|
||||
dataRows: {
|
||||
type: Object,
|
||||
require: true,
|
||||
},
|
||||
onSubmit: Function,
|
||||
});
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
messageError,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
dialogMessageNotify,
|
||||
} = mixin;
|
||||
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const title = defineModel<string>("title", { required: true });
|
||||
const type = defineModel<any>("type", { required: true });
|
||||
const posType = defineModel<any>("posType", { required: true });
|
||||
const posLevel = defineModel<any>("posLevel", { required: true });
|
||||
const position = defineModel<any>("position", { required: true });
|
||||
|
||||
const orgRevisionId = ref<string>("");
|
||||
const filter = ref<string>("");
|
||||
const isAll = ref<boolean>(false);
|
||||
const isBlank = ref<boolean>(false);
|
||||
const posMasterMain = ref<any>([]);
|
||||
const positionNo = ref<DataPositionNo[]>();
|
||||
const itemTaps = ref<string[]>();
|
||||
const filters = ref<string>("");
|
||||
const positionId = ref<string>("");
|
||||
const selectedPos = ref<any[]>([]);
|
||||
const seletcId = ref<string>("");
|
||||
const datePos = ref<Date>(new Date());
|
||||
const rowsPosition = ref<Positions[]>([]);
|
||||
const positionData = ref<any>();
|
||||
/** active form */
|
||||
const formActive = reactive<FormActive>({
|
||||
activeId: "",
|
||||
activeName: "",
|
||||
draftId: "",
|
||||
draftName: "",
|
||||
orgPublishDate: null,
|
||||
isPublic: false,
|
||||
});
|
||||
/** node */
|
||||
const nodes = ref<Array<OrgTree>>([]);
|
||||
const lazy = ref(nodes);
|
||||
const expanded = ref<string[]>([]);
|
||||
const nodeLevel = ref<number>(0);
|
||||
const nodeId = ref<string>(""); // id ของ Tree
|
||||
|
||||
/** columns*/
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "isPosition",
|
||||
align: "left",
|
||||
label: "",
|
||||
sortable: true,
|
||||
field: "isPosition",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: true,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posMasterNo",
|
||||
align: "left",
|
||||
label: "เลขที่ตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "posMasterNo",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionName",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
field: "positionName",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeName",
|
||||
align: "left",
|
||||
label: "กลุ่มงาน",
|
||||
sortable: true,
|
||||
field: "posTypeName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posLevelName",
|
||||
align: "left",
|
||||
label: "ระดับชั้นงาน",
|
||||
sortable: true,
|
||||
field: "posLevelName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionIsSelected",
|
||||
align: "left",
|
||||
label: "คนครอง",
|
||||
sortable: true,
|
||||
field: "positionIsSelected",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const columnsPostition = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: false,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionName",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "positionName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionField",
|
||||
align: "left",
|
||||
label: "สายงาน",
|
||||
sortable: true,
|
||||
field: "positionField",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeName",
|
||||
align: "left",
|
||||
label: "กลุ่มงาน",
|
||||
sortable: true,
|
||||
field: "posTypeName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posLevelName",
|
||||
align: "left",
|
||||
label: "ระดับชั้นงาน",
|
||||
sortable: true,
|
||||
field: "posLevelName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "positionArea",
|
||||
align: "left",
|
||||
label: "ด้าน/สาขา",
|
||||
sortable: true,
|
||||
field: "positionArea",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
"isPosition",
|
||||
"no",
|
||||
"posMasterNo",
|
||||
"positionName",
|
||||
"posTypeName",
|
||||
"posLevelName",
|
||||
"positionIsSelected",
|
||||
]);
|
||||
|
||||
/** ปิด dialog */
|
||||
function close() {
|
||||
modal.value = false;
|
||||
filter.value = "";
|
||||
isAll.value = false;
|
||||
isBlank.value = false;
|
||||
type.value = null;
|
||||
nodes.value = [];
|
||||
expanded.value = [];
|
||||
nodeLevel.value = 0;
|
||||
nodeId.value = "";
|
||||
}
|
||||
|
||||
async function getDataTable(id: string, level: number = 0) {
|
||||
showLoader();
|
||||
|
||||
const body = {
|
||||
node: level,
|
||||
nodeId: id,
|
||||
position: position.value ? position.value : "",
|
||||
posLevel: posLevel.value ? posLevel.value : "",
|
||||
posType: posType.value ? posType.value : "",
|
||||
isAll: isAll.value,
|
||||
isBlank: isBlank.value,
|
||||
typeCommand: type.value,
|
||||
};
|
||||
|
||||
await http
|
||||
.post(config.API.orgPosPlacemenTemp, body)
|
||||
.then((res) => {
|
||||
const dataMain: PositionMain[] = [];
|
||||
posMasterMain.value = res.data.result.data;
|
||||
|
||||
res.data.result.data.forEach((e: PositionNo) => {
|
||||
const p = e.positions;
|
||||
if (p.length !== 0) {
|
||||
const a = p.find((el: Positions) => el.positionIsSelected === true);
|
||||
const { id, ...rest } = a ? a : p[0];
|
||||
const data: any = { ...e, ...rest };
|
||||
dataMain.push(data);
|
||||
}
|
||||
});
|
||||
const listPosNo: DataPositionNo[] = dataMain.map((e: PositionMain) => ({
|
||||
id: e.id,
|
||||
isPosition: e.isPosition,
|
||||
posMasterNo:
|
||||
e.orgShortname +
|
||||
(e.posMasterNoPrefix != null ? e.posMasterNoPrefix : "") +
|
||||
e.posMasterNo +
|
||||
(e.posMasterNoSuffix != null ? e.posMasterNoSuffix : ""),
|
||||
positionName: e.positionName,
|
||||
posTypeName: e.posTypeName,
|
||||
posLevelName: e.posLevelName,
|
||||
positionIsSelected: e.positionIsSelected
|
||||
? e.fullNameCurrentHolder
|
||||
: "-",
|
||||
isSit: e.isSit,
|
||||
positions: e.positions,
|
||||
node: e.node,
|
||||
nodeId: e.nodeId,
|
||||
}));
|
||||
|
||||
positionNo.value = listPosNo;
|
||||
positionData.value = listPosNo;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* funtion เลือกข้อมูล Tree
|
||||
* @param data ข่อมูล Tree
|
||||
*/
|
||||
function updateSelected(data: DataTree) {
|
||||
if (props?.dataRows?.nodeId === data.orgTreeId) {
|
||||
positionId.value = props?.dataRows?.posmasterId;
|
||||
seletcId.value = props?.dataRows?.positionId;
|
||||
datePos.value = props?.dataRows?.reportingDateFullDate;
|
||||
} else {
|
||||
positionId.value = "";
|
||||
seletcId.value = "";
|
||||
selectedPos.value = [];
|
||||
datePos.value = new Date();
|
||||
}
|
||||
|
||||
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
|
||||
nodeLevel.value = data.orgLevel;
|
||||
getDataTable(data.orgTreeId, data.orgLevel);
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
|
||||
formActive.activeId = data.activeId;
|
||||
formActive.activeName = data.activeName;
|
||||
formActive.draftId = data.draftId;
|
||||
formActive.draftName = data.draftName;
|
||||
formActive.orgPublishDate = data.orgPublishDate;
|
||||
formActive.isPublic = data.isPublic;
|
||||
|
||||
getTreeData(data.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล หน่วยงาน */
|
||||
async function getTreeData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByid(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
nodes.value = data;
|
||||
filterItemsTaps(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function filterItemsTaps(data: TreeMain[]) {
|
||||
let orgTreeIds: string[] = [];
|
||||
for (const child of data) {
|
||||
orgTreeIds.push(child.orgTreeId);
|
||||
if (child.children) {
|
||||
orgTreeIds = orgTreeIds.concat(filterItemsTaps(child.children));
|
||||
}
|
||||
}
|
||||
itemTaps.value = orgTreeIds;
|
||||
return orgTreeIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* function เลือกเลขที่ตำแหน่ง
|
||||
* @param id เลชที่ตำแหน่ง
|
||||
*/
|
||||
async function onClickSelectPos(id: string) {
|
||||
positionData.value = positionNo.value;
|
||||
positionId.value = id;
|
||||
selectedPos.value = [];
|
||||
const position: DataPositionNo = positionData.value.find(
|
||||
(e: DataPositionNo) => e.id === id
|
||||
);
|
||||
|
||||
// หาตำแหน่ง
|
||||
if (position) {
|
||||
rowsPosition.value = position.positions;
|
||||
if (seletcId.value) {
|
||||
selectedPos.value = rowsPosition.value.filter(
|
||||
(e) => e.id === seletcId.value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูล expanded tree
|
||||
* @param level levelTree
|
||||
* @param id treeId
|
||||
*/
|
||||
async function fetchPosFind(level: number, id: string) {
|
||||
showLoader();
|
||||
const body = {
|
||||
node: level,
|
||||
nodeId: id,
|
||||
};
|
||||
await http
|
||||
.post(config.API.orgPosFind, body)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
expanded.value = data;
|
||||
nodeId.value = id;
|
||||
positionId.value = props?.dataRows?.posmasterId;
|
||||
seletcId.value = props?.dataRows?.positionId;
|
||||
datePos.value = props?.dataRows?.reportingDateFullDate;
|
||||
|
||||
getDataTable(nodeId.value, level);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => modal.value,
|
||||
async (n) => {
|
||||
if (n == true) {
|
||||
getActive();
|
||||
if (props?.dataRows?.node !== null && props?.dataRows?.nodeId !== null) {
|
||||
await fetchPosFind(props?.dataRows?.node, props?.dataRows?.nodeId);
|
||||
if (positionId.value) {
|
||||
setTimeout(async () => {
|
||||
await onClickSelectPos(positionId.value);
|
||||
}, 200);
|
||||
}
|
||||
} else {
|
||||
expanded.value = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isAll.value,
|
||||
(value, oldVal) => {
|
||||
if (value !== oldVal) {
|
||||
getDataTable(nodeId.value, nodeLevel.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isBlank.value,
|
||||
(value, oldVal) => {
|
||||
if (value !== oldVal) {
|
||||
getDataTable(nodeId.value, nodeLevel.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => positionId.value,
|
||||
(n) => {
|
||||
if (n) {
|
||||
onClickSelectPos(n);
|
||||
}
|
||||
}
|
||||
);
|
||||
function onSubmit() {
|
||||
const dataPosMaster = posMasterMain.value?.find(
|
||||
(e: any) => e.id === positionId.value
|
||||
);
|
||||
|
||||
console.log(dataPosMaster);
|
||||
if (selectedPos.value.length === 0) {
|
||||
dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง");
|
||||
} else {
|
||||
dialogConfirm($q, async () => {
|
||||
const body = {
|
||||
personalId: props?.dataRows?.id,
|
||||
node: dataPosMaster.node,
|
||||
nodeId: dataPosMaster.nodeId,
|
||||
orgRevisionId: formActive.activeId,
|
||||
positionId: selectedPos.value[0].id,
|
||||
posMasterNo: dataPosMaster.posMasterNo, //เลขที่ตำแหน่ง(เลขอย่่างเดียว)
|
||||
positionName: selectedPos.value[0].positionName, //ชื่อตำแหน่ง
|
||||
positionField: selectedPos.value[0].positionField, //ชื่อตำแหน่ง
|
||||
posTypeId: selectedPos.value[0].posTypeId, //ชื่อตำแหน่ง
|
||||
posTypeName: selectedPos.value[0].posTypeName, //ชื่อตำแหน่ง
|
||||
posLevelId: selectedPos.value[0].posLevelId, //ชื่อตำแหน่ง
|
||||
posLevelName: selectedPos.value[0].posLevelName, //ชื่อตำแหน่ง
|
||||
reportingDate: datePos.value,
|
||||
posmasterId: dataPosMaster.id,
|
||||
typeCommand: type.value,
|
||||
};
|
||||
props.onSubmit?.(body);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent full-width>
|
||||
<q-card class="no-scroll">
|
||||
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||
<DialogHeader :tittle="title" :close="close" />
|
||||
<q-separator />
|
||||
<q-card-section style="max-height: 80vh" class="scroll">
|
||||
<div class="row">
|
||||
<q-card
|
||||
bordered
|
||||
class="col-12 col-sm-3 scroll q-pa-sm"
|
||||
style="height: 75vh"
|
||||
>
|
||||
<q-toolbar style="padding: 0">
|
||||
<q-toolbar-title class="text-subtitle2 text-bold"
|
||||
>เลือกหน่วยงาน/ส่วนราชการ</q-toolbar-title
|
||||
>
|
||||
</q-toolbar>
|
||||
|
||||
<q-input dense outlined v-model="filter" label="ค้นหา">
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
v-if="filter !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="filter = ''"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
<q-tree
|
||||
class="q-pa-sm q-gutter-sm"
|
||||
dense
|
||||
:nodes="lazy"
|
||||
node-key="orgTreeId"
|
||||
label-key="orgTreeName"
|
||||
:filter="filter"
|
||||
no-results-label="ไม่พบข้อมูลที่ค้นหา"
|
||||
no-nodes-label="ไม่มีข้อมูล"
|
||||
v-model:expanded="expanded"
|
||||
>
|
||||
<template v-slot:default-header="prop">
|
||||
<q-item
|
||||
@click.stop="updateSelected(prop.node)"
|
||||
clickable
|
||||
:active="nodeId == prop.node.orgTreeId"
|
||||
active-class="my-list-link text-primary text-weight-medium"
|
||||
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
|
||||
>
|
||||
<div>
|
||||
<div class="text-weight-medium">
|
||||
{{ prop.node.orgTreeName }}
|
||||
</div>
|
||||
<div class="text-weight-light">
|
||||
{{
|
||||
prop.node.orgCode == null ? null : prop.node.orgCode
|
||||
}}
|
||||
{{
|
||||
prop.node.orgTreeShortName == null
|
||||
? null
|
||||
: prop.node.orgTreeShortName
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-tree>
|
||||
</q-card>
|
||||
<q-card bordered class="col-12 col-sm-9 q-pa-sm">
|
||||
<q-tab-panels
|
||||
v-model="nodeId"
|
||||
animated
|
||||
transition-prev="jump-up"
|
||||
transition-next="jump-up"
|
||||
>
|
||||
<q-tab-panel
|
||||
v-for="(item, index) in itemTaps"
|
||||
:key="index"
|
||||
:name="item"
|
||||
>
|
||||
<div class="column q-col-gutter-sm" style="height: 70vh">
|
||||
<!-- เลือกเลขที่ตำแหน่ง -->
|
||||
<div class="col-7">
|
||||
<q-card
|
||||
bordered
|
||||
style="height: 100%; border: 1px solid #d6dee1"
|
||||
>
|
||||
<div
|
||||
class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
||||
>
|
||||
เลือกเลขที่ตำแหน่ง
|
||||
</div>
|
||||
<div class="col-12"><q-separator /></div>
|
||||
<div class="col-12 q-pa-md">
|
||||
<q-toolbar style="padding: 0px">
|
||||
<div class="row q-gutter-md">
|
||||
<q-checkbox
|
||||
keep-color
|
||||
v-model="isBlank"
|
||||
label="แสดงเฉพาะตำแหน่งว่าง"
|
||||
color="primary"
|
||||
>
|
||||
<q-tooltip>แสดงเฉพาะตำแหน่งว่าง </q-tooltip>
|
||||
</q-checkbox>
|
||||
</div>
|
||||
<q-space />
|
||||
|
||||
<div class="row q-gutter-md">
|
||||
<q-checkbox
|
||||
keep-color
|
||||
v-model="isAll"
|
||||
label="แสดงตำแหน่งทั้งหมด"
|
||||
color="primary"
|
||||
>
|
||||
<q-tooltip
|
||||
>แสดงตำแหน่งทั้งหมดภายใต้หน่วยงาน/ส่วนราชการที่เลือก</q-tooltip
|
||||
>
|
||||
</q-checkbox>
|
||||
<div>
|
||||
<q-input
|
||||
outlined
|
||||
dense
|
||||
v-model="filters"
|
||||
label="ค้นหา"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" color="grey-5" />
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<div>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
emit-value
|
||||
:display-value="$q.lang.table.columns"
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 180px"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="positionData"
|
||||
:filter="filters"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
class="tableTb"
|
||||
:visible-columns="visibleColumns"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<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
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
@click="onClickSelectPos(props.row.id)"
|
||||
:class="
|
||||
props.row.id === positionId
|
||||
? 'bg-blue-2'
|
||||
: ''
|
||||
"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'posMasterNo'">
|
||||
{{
|
||||
props.row.isSit
|
||||
? col.value + " " + "(ทับที่)"
|
||||
: col.value
|
||||
}}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'isPosition'">
|
||||
<div v-if="col.value">
|
||||
<q-icon
|
||||
name="done"
|
||||
color="primary"
|
||||
size="24px"
|
||||
>
|
||||
<q-tooltip>ตรงตามตำแหน่ง </q-tooltip>
|
||||
</q-icon>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<!-- เลือกตำแหน่ง -->
|
||||
<div class="col-5">
|
||||
<q-card
|
||||
bordered
|
||||
style="height: 100%; border: 1px solid #d6dee1"
|
||||
>
|
||||
<div
|
||||
class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
||||
>
|
||||
เลือกตำแหน่ง
|
||||
</div>
|
||||
<div class="col-12"><q-separator /></div>
|
||||
<q-tab-panels
|
||||
v-model="positionId"
|
||||
animated
|
||||
swipeable
|
||||
vertical
|
||||
transition-prev="jump-up"
|
||||
transition-next="jump-up"
|
||||
>
|
||||
<q-tab-panel
|
||||
v-for="(item, index) in positionData"
|
||||
:key="index"
|
||||
:name="item.id"
|
||||
>
|
||||
<div class="col-12">
|
||||
<q-toolbar style="padding: 0px">
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
v-model="datePos"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
borderless
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
:min-date="datePos"
|
||||
>
|
||||
<template #year="{ year }">
|
||||
{{ year + 543 }}
|
||||
</template>
|
||||
<template #year-overlay-value="{ value }">
|
||||
{{ parseInt(value + 543) }}
|
||||
</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
ref="dateRef"
|
||||
outlined
|
||||
dense
|
||||
hide-bottom-space
|
||||
:model-value="
|
||||
datePos != null
|
||||
? date2Thai(datePos)
|
||||
: null
|
||||
"
|
||||
label="วันที่รายงานตัว"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
</q-toolbar>
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columnsPostition"
|
||||
:rows="rowsPosition"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
class="tableTb"
|
||||
selection="single"
|
||||
v-model:selected="selectedPos"
|
||||
>
|
||||
<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 auto-width />
|
||||
<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>
|
||||
<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>
|
||||
<div
|
||||
v-else-if="col.name === 'posMasterNo'"
|
||||
>
|
||||
{{
|
||||
props.row.isSit
|
||||
? col.value + " " + "(ทับที่)"
|
||||
: col.value
|
||||
}}
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
||||
<q-card-actions align="right" class="bg-white text-teal">
|
||||
<q-btn label="บันทึก" color="secondary" type="submit"
|
||||
><q-tooltip>บันทึกข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
<style scoped>
|
||||
.my-list-link {
|
||||
color: rgb(118, 168, 222);
|
||||
border-radius: 5px;
|
||||
background: #a3d3fb48 !important;
|
||||
font-weight: 600;
|
||||
border: 1px solid rgba(175, 185, 196, 0.217);
|
||||
}
|
||||
</style>
|
||||
577
src/components/Dialogs/DialogOrgSelectOneStep.vue
Normal file
577
src/components/Dialogs/DialogOrgSelectOneStep.vue
Normal file
|
|
@ -0,0 +1,577 @@
|
|||
<script setup lang="ts">
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { ref, watch, reactive } from "vue";
|
||||
import type { QInput, QTableProps } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type {
|
||||
OrgTree,
|
||||
DataTree,
|
||||
Positions,
|
||||
DataPositionNo,
|
||||
FormActive,
|
||||
TreeMain,
|
||||
} from "@/interface/request/orgSelect/org";
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const filterRef = ref<QInput>();
|
||||
const filterModal = ref<string>("");
|
||||
const props = defineProps({
|
||||
dataRows: {
|
||||
type: Object,
|
||||
require: true,
|
||||
},
|
||||
onSubmit: Function,
|
||||
saveData: Function,
|
||||
});
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
messageError,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
dialogMessageNotify,
|
||||
} = mixin;
|
||||
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const title = defineModel<string>("title", { required: true });
|
||||
const selectedModal = defineModel<any[]>("selectedModal");
|
||||
|
||||
const filter = ref<string>("");
|
||||
const isAll = ref<boolean>(false);
|
||||
const isBlank = ref<boolean>(false);
|
||||
const positionNo = ref<DataPositionNo[]>();
|
||||
const itemTaps = ref<string[]>();
|
||||
const positionId = ref<string>("");
|
||||
const selectedPos = ref<any[]>([]);
|
||||
const seletcId = ref<string>("");
|
||||
const datePos = ref<Date>(new Date());
|
||||
const rowsPosition = ref<Positions[]>([]);
|
||||
const positionData = ref<any>();
|
||||
/** active form */
|
||||
const formActive = reactive<FormActive>({
|
||||
activeId: "",
|
||||
activeName: "",
|
||||
draftId: "",
|
||||
draftName: "",
|
||||
orgPublishDate: null,
|
||||
isPublic: false,
|
||||
});
|
||||
/** node */
|
||||
const nodes = ref<Array<OrgTree>>([]);
|
||||
const lazy = ref(nodes);
|
||||
const expanded = ref<string[]>([]);
|
||||
const nodeLevel = ref<number>(0);
|
||||
const nodeId = ref<string>(""); // id ของ Tree
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
field: "no",
|
||||
sortable: true,
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "citizenId",
|
||||
align: "left",
|
||||
label: "เลขประจำตัวประชาชน",
|
||||
field: "citizenId",
|
||||
sortable: true,
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
align: "left",
|
||||
label: "ชื่อ-นามสกุล",
|
||||
field: "name",
|
||||
sortable: true,
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "position",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
field: "position",
|
||||
sortable: true,
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
]);
|
||||
|
||||
const visibleColumns = ref<String[]>(["no", "citizenId", "name", "position"]);
|
||||
|
||||
/** ปิด dialog */
|
||||
function close() {
|
||||
modal.value = false;
|
||||
filter.value = "";
|
||||
isAll.value = false;
|
||||
isBlank.value = false;
|
||||
|
||||
nodes.value = [];
|
||||
expanded.value = [];
|
||||
nodeLevel.value = 0;
|
||||
nodeId.value = "";
|
||||
|
||||
rows.value = [];
|
||||
selectedModal.value = [];
|
||||
}
|
||||
|
||||
async function getDataTable(id: string, level: number = 0) {
|
||||
//new
|
||||
showLoader();
|
||||
http
|
||||
.post(config.API.orgDeceasedProfile, {
|
||||
nodeId: id,
|
||||
node: level,
|
||||
isAll: isAll.value,
|
||||
})
|
||||
.then((res) => {
|
||||
const data = res.data.result.data;
|
||||
|
||||
rows.value = data;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
//old
|
||||
// showLoader();
|
||||
|
||||
// const body = {
|
||||
// node: level,
|
||||
// nodeId: id,
|
||||
// typeCommand: type.value,
|
||||
// position: posType.value ? posType.value : "",
|
||||
// posLevel: posLevel.value ? posLevel.value : "",
|
||||
// posType: position.value ? position.value : "",
|
||||
// isAll: isAll.value,
|
||||
// isBlank: isBlank.value,
|
||||
// };
|
||||
|
||||
// await http
|
||||
// .post(config.API.orgPosPlacement, body)
|
||||
// .then((res) => {
|
||||
// const dataMain: PositionMain[] = [];
|
||||
// posMasterMain.value = res.data.result.data;
|
||||
|
||||
// res.data.result.data.forEach((e: PositionNo) => {
|
||||
// const p = e.positions;
|
||||
// if (p.length !== 0) {
|
||||
// const a = p.find((el: Positions) => el.positionIsSelected === true);
|
||||
// const { id, ...rest } = a ? a : p[0];
|
||||
// const data: any = { ...e, ...rest };
|
||||
// dataMain.push(data);
|
||||
// }
|
||||
// });
|
||||
// const listPosNo: DataPositionNo[] = dataMain.map((e: PositionMain) => ({
|
||||
// id: e.id,
|
||||
// isPosition: e.isPosition,
|
||||
// posMasterNo:
|
||||
// e.orgShortname +
|
||||
// (e.posMasterNoPrefix != null ? e.posMasterNoPrefix : "") +
|
||||
// e.posMasterNo +
|
||||
// (e.posMasterNoSuffix != null ? e.posMasterNoSuffix : ""),
|
||||
// positionName: e.positionName,
|
||||
// posTypeName: e.posTypeName,
|
||||
// posLevelName: e.posLevelName,
|
||||
// positionIsSelected: e.positionIsSelected
|
||||
// ? e.fullNameCurrentHolder
|
||||
// : "-",
|
||||
// isSit: e.isSit,
|
||||
// positions: e.positions,
|
||||
// node: e.node,
|
||||
// nodeId: e.nodeId,
|
||||
// }));
|
||||
|
||||
// positionNo.value = listPosNo;
|
||||
// positionData.value = listPosNo;
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// messageError($q, err);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// setTimeout(() => {
|
||||
// hideLoader();
|
||||
// }, 1000);
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* funtion เลือกข้อมูล Tree
|
||||
* @param data ข่อมูล Tree
|
||||
*/
|
||||
function updateSelected(data: DataTree) {
|
||||
positionId.value = "";
|
||||
seletcId.value = "";
|
||||
selectedPos.value = [];
|
||||
datePos.value = new Date();
|
||||
|
||||
nodeId.value = data.orgTreeId ? data.orgTreeId : "";
|
||||
nodeLevel.value = data.orgLevel;
|
||||
getDataTable(data.orgTreeId, data.orgLevel);
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล active */
|
||||
async function getActive() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.activeOrganization)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
|
||||
formActive.activeId = data.activeId;
|
||||
formActive.activeName = data.activeName;
|
||||
formActive.draftId = data.draftId;
|
||||
formActive.draftName = data.draftName;
|
||||
formActive.orgPublishDate = data.orgPublishDate;
|
||||
formActive.isPublic = data.isPublic;
|
||||
|
||||
getTreeData(data.activeId);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล หน่วยงาน */
|
||||
async function getTreeData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgByid(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
nodes.value = data;
|
||||
filterItemsTaps(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function filterItemsTaps(data: TreeMain[]) {
|
||||
let orgTreeIds: string[] = [];
|
||||
for (const child of data) {
|
||||
orgTreeIds.push(child.orgTreeId);
|
||||
if (child.children) {
|
||||
orgTreeIds = orgTreeIds.concat(filterItemsTaps(child.children));
|
||||
}
|
||||
}
|
||||
itemTaps.value = orgTreeIds;
|
||||
return orgTreeIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* function เลือกเลขที่ตำแหน่ง
|
||||
* @param id เลชที่ตำแหน่ง
|
||||
*/
|
||||
async function onClickSelectPos(id: string) {
|
||||
positionData.value = positionNo.value;
|
||||
positionId.value = id;
|
||||
selectedPos.value = [];
|
||||
const position: DataPositionNo = positionData.value.find(
|
||||
(e: DataPositionNo) => e.id === id
|
||||
);
|
||||
|
||||
// หาตำแหน่ง
|
||||
if (position) {
|
||||
rowsPosition.value = position.positions;
|
||||
if (seletcId.value) {
|
||||
selectedPos.value = rowsPosition.value.filter(
|
||||
(e) => e.id === seletcId.value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function fetch ข้อมูล expanded tree
|
||||
* @param level levelTree
|
||||
* @param id treeId
|
||||
*/
|
||||
async function fetchPosFind(level: number, id: string) {
|
||||
showLoader();
|
||||
const body = {
|
||||
node: level,
|
||||
nodeId: id,
|
||||
};
|
||||
await http
|
||||
.post(config.API.orgPosFind, body)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
expanded.value = data;
|
||||
nodeId.value = id;
|
||||
positionId.value = props?.dataRows?.posmasterId;
|
||||
seletcId.value = props?.dataRows?.positionId;
|
||||
datePos.value = props?.dataRows?.reportingDateFullDate;
|
||||
|
||||
getDataTable(nodeId.value, level);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => modal.value,
|
||||
async (n) => {
|
||||
if (n == true) {
|
||||
getActive();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isAll.value,
|
||||
(value, oldVal) => {
|
||||
if (value !== oldVal) {
|
||||
getDataTable(nodeId.value, nodeLevel.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => isBlank.value,
|
||||
(value, oldVal) => {
|
||||
if (value !== oldVal) {
|
||||
getDataTable(nodeId.value, nodeLevel.value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => positionId.value,
|
||||
(n) => {
|
||||
if (n) {
|
||||
onClickSelectPos(n);
|
||||
}
|
||||
}
|
||||
);
|
||||
function onSubmit() {
|
||||
if (nodeId.value == "") {
|
||||
dialogMessageNotify($q, "กรุณาเลือกตำแหน่ง");
|
||||
} else {
|
||||
dialogConfirm($q, async () => {
|
||||
props.saveData?.();
|
||||
close();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function resetFilter() {
|
||||
filter.value = "";
|
||||
filterRef.value!.focus();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent full-width>
|
||||
<q-card class="no-scroll">
|
||||
<q-form greedy @submit.prevent @validation-success="onSubmit">
|
||||
<DialogHeader :tittle="title" :close="close" />
|
||||
<q-separator />
|
||||
<q-card-section style="max-height: 80vh" class="scroll">
|
||||
<div class="row">
|
||||
<q-card
|
||||
bordered
|
||||
class="col-12 col-sm-3 scroll q-pa-sm"
|
||||
style="height: 75vh"
|
||||
>
|
||||
<q-input dense outlined v-model="filter" label="ค้นหา">
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
v-if="filter !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="filter = ''"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
<q-tree
|
||||
class="q-pa-sm q-gutter-sm"
|
||||
dense
|
||||
:nodes="lazy"
|
||||
node-key="orgTreeId"
|
||||
label-key="orgTreeName"
|
||||
:filter="filter"
|
||||
no-results-label="ไม่พบข้อมูลที่ค้นหา"
|
||||
no-nodes-label="ไม่มีข้อมูล"
|
||||
v-model:expanded="expanded"
|
||||
>
|
||||
<template v-slot:default-header="prop">
|
||||
<q-item
|
||||
@click.stop="updateSelected(prop.node)"
|
||||
clickable
|
||||
:active="nodeId == prop.node.orgTreeId"
|
||||
active-class="my-list-link text-primary text-weight-medium"
|
||||
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
|
||||
>
|
||||
<div>
|
||||
<div class="text-weight-medium">
|
||||
{{ prop.node.orgTreeName }}
|
||||
</div>
|
||||
<div class="text-weight-light">
|
||||
{{
|
||||
prop.node.orgCode == null ? null : prop.node.orgCode
|
||||
}}
|
||||
{{
|
||||
prop.node.orgTreeShortName == null
|
||||
? null
|
||||
: prop.node.orgTreeShortName
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</q-item>
|
||||
</template>
|
||||
</q-tree>
|
||||
</q-card>
|
||||
<q-card bordered class="col-12 col-sm-9 q-pa-sm">
|
||||
<div class="col-12 row q-py-sm items-center q-col-gutter-sm">
|
||||
<q-space />
|
||||
<div class="items-center" style="display: flex">
|
||||
<q-checkbox
|
||||
keep-color
|
||||
v-model="isAll"
|
||||
label="แสดงทั้งหมด"
|
||||
color="primary"
|
||||
>
|
||||
<q-tooltip>แสดงทั้งหมด</q-tooltip>
|
||||
</q-checkbox>
|
||||
<q-input
|
||||
standout
|
||||
dense
|
||||
v-model="filterModal"
|
||||
ref="filterRef"
|
||||
outlined
|
||||
debounce="300"
|
||||
placeholder="ค้นหา"
|
||||
style="max-width: 200px"
|
||||
class="q-ml-sm"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterModal == ''" name="search" />
|
||||
<q-icon
|
||||
v-if="filterModal !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="resetFilter"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
:display-value="$q.lang.table.columns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
:options="columns"
|
||||
options-dense
|
||||
option-value="name"
|
||||
map-options
|
||||
emit-value
|
||||
style="min-width: 150px"
|
||||
class="gt-xs q-ml-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<d-table
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:visible-columns="visibleColumns"
|
||||
:filter="filterModal"
|
||||
row-key="id"
|
||||
selection="multiple"
|
||||
v-model:selected="selectedModal"
|
||||
:rows-per-page-options="[10, 25, 50, 100]"
|
||||
>
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th auto-width>
|
||||
<q-checkbox
|
||||
keep-color
|
||||
color="primary"
|
||||
dense
|
||||
v-model="props.selected"
|
||||
/>
|
||||
</q-th>
|
||||
<q-th
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
style="color: #000000; font-weight: 500"
|
||||
>
|
||||
<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 auto-width>
|
||||
<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>
|
||||
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
|
||||
<q-card-actions align="right" class="bg-white text-teal">
|
||||
<q-btn label="บันทึก" color="secondary" type="submit"
|
||||
><q-tooltip>บันทึกข้อมูล</q-tooltip></q-btn
|
||||
>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
<style scoped>
|
||||
.my-list-link {
|
||||
color: rgb(118, 168, 222);
|
||||
border-radius: 5px;
|
||||
background: #a3d3fb48 !important;
|
||||
font-weight: 600;
|
||||
border: 1px solid rgba(175, 185, 196, 0.217);
|
||||
}
|
||||
</style>
|
||||
39
src/components/Dialogs/Information.vue
Normal file
39
src/components/Dialogs/Information.vue
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<script setup lang="ts">
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
const props = defineProps({
|
||||
modal: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
desc: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
clickClose: {
|
||||
type: Function
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="props.modal" persistent>
|
||||
<q-card style="width: 35vw; max-width: 35vw">
|
||||
<q-form ref="myForm">
|
||||
<DialogHeader :tittle="props.title" :close="clickClose" />
|
||||
<q-separator />
|
||||
<q-card-section class="q-pa-md bg-grey-1">
|
||||
<div class="row col-12">
|
||||
|
||||
{{ props.desc }}
|
||||
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
406
src/components/Dialogs/PopupPersonal.vue
Normal file
406
src/components/Dialogs/PopupPersonal.vue
Normal file
|
|
@ -0,0 +1,406 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** importType*/
|
||||
import type { PersonalImformation } from "@/components/information/interface/response/Information";
|
||||
import type { Goverment } from "@/components/information/interface/response/Government";
|
||||
import type { Avatar } from "@/components/information/interface/response/avatar";
|
||||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/** use*/
|
||||
const mixin = useCounterMixin();
|
||||
const $q = useQuasar();
|
||||
|
||||
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
|
||||
|
||||
/** props*/
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
requier: true,
|
||||
},
|
||||
modal: {
|
||||
type: Boolean,
|
||||
requier: true,
|
||||
},
|
||||
});
|
||||
|
||||
/** emit*/
|
||||
const emit = defineEmits(["update:modal"]);
|
||||
|
||||
/** interface*/
|
||||
interface StatusLoad {
|
||||
val: boolean;
|
||||
val2: boolean;
|
||||
val3: boolean;
|
||||
}
|
||||
|
||||
/** ตัวแปร*/
|
||||
const modal = ref<boolean>(false);
|
||||
const statusLoad = ref<StatusLoad>({ val: false, val2: false, val3: false }); // เช็คสถานะการโหลด
|
||||
const avatar = reactive<Avatar>({
|
||||
avatar: "",
|
||||
fullname: "",
|
||||
position: "",
|
||||
});
|
||||
const imformation = reactive<PersonalImformation>({
|
||||
prefix: "",
|
||||
citizenId: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
birthDate: "",
|
||||
age: "",
|
||||
gender: "",
|
||||
});
|
||||
const goverment = reactive<Goverment>({
|
||||
oc: "",
|
||||
posNo: "",
|
||||
position: "",
|
||||
positionPathSide: "",
|
||||
positionLine: "",
|
||||
positionType: "",
|
||||
positionLevel: "",
|
||||
positionExecutive: "",
|
||||
positionExecutiveSide: "",
|
||||
});
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลรูปภาพ
|
||||
* @param id profileID
|
||||
*/
|
||||
async function fetchAvatar(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileAvatarId(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
avatar.avatar = data.avatar;
|
||||
avatar.fullname = data.fullname;
|
||||
avatar.position = data.position ?? "-";
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
statusLoad.value.val = true;
|
||||
loaderFunction();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลส่วนตัว
|
||||
* @param id profileID
|
||||
*/
|
||||
async function fetchInformation(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileInforId(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
imformation.prefix = data.prefix;
|
||||
imformation.citizenId = data.citizenId;
|
||||
imformation.firstName = data.firstName;
|
||||
imformation.lastName = data.lastName;
|
||||
imformation.birthDate = data.birthDate ? date2Thai(data.birthDate) : "";
|
||||
imformation.age = data.age;
|
||||
imformation.gender = data.gender;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
statusLoad.value.val2 = true;
|
||||
loaderFunction();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลข้อมูลราชการ
|
||||
* @param id profileID
|
||||
*/
|
||||
async function fetchProfileGov(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileGovId(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
goverment.oc = data.oc ?? "-";
|
||||
goverment.posNo = data.posNo ?? "-";
|
||||
goverment.position = data.position ?? "-";
|
||||
goverment.positionPathSide = data.positionPathSide ?? "-";
|
||||
goverment.positionLine = data.positionLine ?? "-";
|
||||
goverment.positionType = data.positionType ?? "-";
|
||||
goverment.positionLevel = data.positionLevel ?? "-";
|
||||
goverment.positionExecutive = data.positionExecutive ?? "-";
|
||||
goverment.positionExecutiveSide = data.positionExecutiveSide ?? "-";
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
statusLoad.value.val3 = true;
|
||||
loaderFunction();
|
||||
});
|
||||
}
|
||||
|
||||
/** functoion เช็คการโหลดของข้อมูล*/
|
||||
function loaderFunction() {
|
||||
const allTrue = Object.values(statusLoad.value).every((val) => val);
|
||||
allTrue && hideLoader();
|
||||
}
|
||||
|
||||
function redirecToRegistry() {
|
||||
window.open(`/registry/${props.id}`, "_blank");
|
||||
modal.value = false;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modal,
|
||||
async () => {
|
||||
modal.value = props.modal ? props.modal : false;
|
||||
modal.value &&
|
||||
props.id &&
|
||||
(await fetchAvatar(props.id),
|
||||
await fetchInformation(props.id),
|
||||
await fetchProfileGov(props.id));
|
||||
}
|
||||
);
|
||||
|
||||
watch(modal, (newValue) => {
|
||||
if (!newValue) {
|
||||
emit("update:modal", false);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="modal" position="right" :maximized="true">
|
||||
<q-card style="width: 420px; overflow: visible">
|
||||
<q-toolbar>
|
||||
<q-toolbar-title class="text-subtitle1 text-bold"
|
||||
>ทะเบียนประวัติ</q-toolbar-title
|
||||
>
|
||||
<q-btn
|
||||
icon="close"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
@click="emit('update:modal', false)"
|
||||
style="color: red; background-color: #ffdede"
|
||||
/>
|
||||
</q-toolbar>
|
||||
<!-- <q-card-section>
|
||||
<div class="text-bold text-h6 text-center">ข้อมูลทะเบียนประวัติ</div>
|
||||
<q-space />
|
||||
|
||||
</q-card-section> -->
|
||||
|
||||
<q-card-section class="col q-pt-none bg-grey-12">
|
||||
<div class="q-gutter-md">
|
||||
<q-card bordered class="text-center bg-grey-12">
|
||||
<div>
|
||||
<q-avatar size="120px" color="grey-4">
|
||||
<img
|
||||
v-if="avatar.avatar"
|
||||
:src="avatar.avatar"
|
||||
class="bg-grey-3"
|
||||
style="object-fit: cover"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
src="@/assets/avatar_user.jpg"
|
||||
class="bg-grey-3"
|
||||
style="object-fit: cover"
|
||||
/>
|
||||
</q-avatar>
|
||||
</div>
|
||||
<div
|
||||
class="q-mt-md text-subtitle2 text-bold"
|
||||
style="font-size: 18px"
|
||||
>
|
||||
{{ avatar.fullname }}
|
||||
</div>
|
||||
<div
|
||||
v-if="avatar.position != '-'"
|
||||
class="q-mb-xs text-center text-grey"
|
||||
>
|
||||
{{ avatar.position }}
|
||||
</div>
|
||||
<div class="q-mt-md">
|
||||
<q-btn
|
||||
class="bg-white"
|
||||
outline
|
||||
rounded
|
||||
label="ดูรายละเอียดเพิ่มเติมทั้งหมด"
|
||||
color="secondary"
|
||||
@click.prevent="redirecToRegistry"
|
||||
/>
|
||||
</div>
|
||||
</q-card>
|
||||
|
||||
<q-scroll-area style="height: 65vh; max-width: 100%">
|
||||
<div class="q-gutter-md q-pa-sm">
|
||||
<q-card bordered style="border: 1px solid #d6dee1">
|
||||
<div class="q-pa-md">
|
||||
<div class="text-weight-bold row items-center">
|
||||
<q-icon name="mdi-account" color="grey-7" />
|
||||
<span class="q-ml-md">ข้อมูลส่วนตัว </span>
|
||||
</div>
|
||||
<div class="row q-pa-sm">
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.citizenId"
|
||||
label="เลขประจำตัวประชาชน"
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.prefix"
|
||||
label="คำนำหน้าชื่อ"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.firstName"
|
||||
label="ชื่่อ"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.lastName"
|
||||
label="นามสกุล"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.birthDate"
|
||||
label="วัน/เดือน/ปีเกิด"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.gender"
|
||||
label="เพศ"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.age"
|
||||
label="อายุ"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
|
||||
<q-card bordered style="border: 1px solid #d6dee1">
|
||||
<div class="q-pa-md">
|
||||
<div class="text-weight-bold row items-center">
|
||||
<q-icon name="mdi-account-tie" color="grey-7" />
|
||||
<span class="q-ml-md">ข้อมูลราชการ </span>
|
||||
</div>
|
||||
<div class="row q-pa-sm">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.oc === '' ? '-' : goverment.oc"
|
||||
label="สังกัด"
|
||||
autogrow
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.posNo"
|
||||
label="ตำแหน่งเลขที่"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.position"
|
||||
label="ตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionPathSide"
|
||||
label="ด้าน/สาขา"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionLine"
|
||||
label="สายงาน"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionType"
|
||||
label="ประเภทตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionLevel"
|
||||
label="ระดับตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionExecutive"
|
||||
label="ตำแหน่งทางการบริหาร"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionExecutiveSide"
|
||||
label="ด้านตำแหน่งทางการบริหาร"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-scroll-area>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
420
src/components/Dialogs/PopupPersonalNew.vue
Normal file
420
src/components/Dialogs/PopupPersonalNew.vue
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, watch, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
/** importType*/
|
||||
import type { PersonalImformation } from "@/components/information/interface/response/Information";
|
||||
import type { Goverment } from "@/components/information/interface/response/Government";
|
||||
import type { Avatar } from "@/components/information/interface/response/avatar";
|
||||
|
||||
/** importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/** use*/
|
||||
const route = useRoute();
|
||||
const mixin = useCounterMixin();
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const retireDate = ref<Date>();
|
||||
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
|
||||
const empType = ref<string>(
|
||||
route.name !== "appoint-employee-detail" ? "" : "-employee"
|
||||
);
|
||||
/** props*/
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: String,
|
||||
requier: true,
|
||||
},
|
||||
modal: {
|
||||
type: Boolean,
|
||||
requier: true,
|
||||
},
|
||||
type: { type: String, default: "" },
|
||||
});
|
||||
|
||||
/** emit*/
|
||||
const emit = defineEmits(["update:modal"]);
|
||||
|
||||
/** ตัวแปร*/
|
||||
const modal = ref<boolean>(false);
|
||||
const avatar = reactive<Avatar>({
|
||||
avatar: "",
|
||||
fullname: "",
|
||||
position: "",
|
||||
});
|
||||
const imformation = reactive<PersonalImformation>({
|
||||
prefix: "",
|
||||
citizenId: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
birthDate: "",
|
||||
age: "",
|
||||
gender: "",
|
||||
});
|
||||
const goverment = reactive<Goverment>({
|
||||
oc: "",
|
||||
posNo: "",
|
||||
position: "",
|
||||
positionPathSide: "",
|
||||
positionLine: "",
|
||||
positionType: "",
|
||||
positionLevel: "",
|
||||
positionExecutive: "",
|
||||
positionExecutiveSide: "",
|
||||
});
|
||||
|
||||
function calculateAge(birthDate: Date | null) {
|
||||
if (!birthDate) return null;
|
||||
const birthDateTimeStamp = new Date(birthDate).getTime();
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - birthDateTimeStamp;
|
||||
|
||||
const ageDate = new Date(diff);
|
||||
const years = ageDate.getUTCFullYear() - 1970;
|
||||
const months = ageDate.getUTCMonth();
|
||||
const days = ageDate.getUTCDate() - 1;
|
||||
const retire = new Date(birthDate);
|
||||
retire.setFullYear(retire.getFullYear() + 60);
|
||||
retireDate.value = retire;
|
||||
|
||||
if (years > 60) {
|
||||
return "อายุเกิน 60 ปี";
|
||||
}
|
||||
|
||||
return `${years} ปี ${months} เดือน ${days} วัน`;
|
||||
}
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลส่วนตัว
|
||||
* @param id profileID
|
||||
*/
|
||||
async function fetchInformation(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgProfileById(id, empType.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
imformation.prefix = data.prefix ? data.prefix : "-";
|
||||
imformation.citizenId = data.citizenId ? data.citizenId : "-";
|
||||
imformation.firstName = data.firstName ? data.firstName : "-";
|
||||
imformation.lastName = data.lastName ? data.lastName : "-";
|
||||
imformation.birthDate = data.birthDate ? date2Thai(data.birthDate) : "-";
|
||||
imformation.age = data.birthDate ? calculateAge(data.birthDate) : "-";
|
||||
imformation.gender = data.gender ?? "-";
|
||||
|
||||
avatar.fullname = `${data.prefix}${data.firstName} ${data.lastName}`;
|
||||
|
||||
avatar.position = data.position ? data.position : "-";
|
||||
if (data.avatarName) {
|
||||
fetchProfile(data.id as string, data.avatarName);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลข้อมูลราชการ
|
||||
* @param id profileID
|
||||
*/
|
||||
async function fetchProfileGov(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileNewGovernmentById(id, empType.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
goverment.oc = data.org !== "" ? data.org : "-";
|
||||
goverment.posNo = data.posMasterNo !== "" ? data.posMasterNo : "-";
|
||||
goverment.position = data.position !== "" ? data.position : "-";
|
||||
goverment.positionPathSide =
|
||||
data.positionArea !== "" ? data.positionArea : "-";
|
||||
goverment.positionLine =
|
||||
data.positionField !== "" ? data.positionField : "-";
|
||||
goverment.positionType = data.posType !== "" ? data.posType : "-";
|
||||
goverment.positionLevel = data.posLevel !== "" ? data.posLevel : "-";
|
||||
goverment.positionExecutive =
|
||||
data.posExecutive !== null ? data.posExecutive : "-";
|
||||
goverment.positionExecutiveSide =
|
||||
data.positionExecutiveField !== "" ? data.positionExecutiveField : "-";
|
||||
})
|
||||
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
function redirecToRegistry() {
|
||||
router.push(`/registry-new${empType.value}/${props.id}`);
|
||||
modal.value = false;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modal,
|
||||
async () => {
|
||||
modal.value = props.modal ? props.modal : false;
|
||||
if (modal.value) {
|
||||
if (props.id) {
|
||||
fetchInformation(props.id);
|
||||
fetchProfileGov(props.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(modal, (newValue) => {
|
||||
if (!newValue) {
|
||||
emit("update:modal", false);
|
||||
}
|
||||
});
|
||||
|
||||
async function fetchProfile(id: string, avatarName: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName))
|
||||
.then(async (res) => {
|
||||
avatar.avatar = res.data.downloadUrl;
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="modal" position="right" :maximized="true">
|
||||
<q-card style="width: 420px; overflow: visible">
|
||||
<q-toolbar>
|
||||
<q-toolbar-title class="text-subtitle1 text-bold"
|
||||
>ทะเบียนประวัติ</q-toolbar-title
|
||||
>
|
||||
<q-btn
|
||||
icon="close"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
@click="emit('update:modal', false)"
|
||||
style="color: red; background-color: #ffdede"
|
||||
/>
|
||||
</q-toolbar>
|
||||
|
||||
<q-card-section class="col q-pt-none bg-grey-12">
|
||||
<div class="q-gutter-md">
|
||||
<q-card bordered class="text-center bg-grey-12">
|
||||
<div>
|
||||
<q-avatar size="120px" color="grey-4">
|
||||
<img
|
||||
v-if="avatar.avatar"
|
||||
:src="avatar.avatar"
|
||||
class="bg-grey-3"
|
||||
style="object-fit: cover"
|
||||
/>
|
||||
<img
|
||||
v-else
|
||||
src="@/assets/avatar_user.jpg"
|
||||
class="bg-grey-3"
|
||||
style="object-fit: cover"
|
||||
/>
|
||||
</q-avatar>
|
||||
</div>
|
||||
<div
|
||||
class="q-mt-md text-subtitle2 text-bold"
|
||||
style="font-size: 18px"
|
||||
>
|
||||
{{ avatar.fullname }}
|
||||
</div>
|
||||
<div
|
||||
v-if="avatar.position != '-'"
|
||||
class="q-mb-xs text-center text-grey"
|
||||
>
|
||||
{{ avatar.position }}
|
||||
</div>
|
||||
<div class="q-mt-md">
|
||||
<q-btn
|
||||
class="bg-white"
|
||||
outline
|
||||
rounded
|
||||
label="ดูรายละเอียดเพิ่มเติมทั้งหมด"
|
||||
color="secondary"
|
||||
@click.prevent="redirecToRegistry"
|
||||
/>
|
||||
</div>
|
||||
</q-card>
|
||||
|
||||
<q-scroll-area style="height: 65vh; max-width: 100%">
|
||||
<div class="q-gutter-md q-pa-sm">
|
||||
<q-card bordered style="border: 1px solid #d6dee1">
|
||||
<div class="q-pa-md">
|
||||
<div class="text-weight-bold row items-center">
|
||||
<q-icon name="mdi-account" color="grey-7" />
|
||||
<span class="q-ml-md">ข้อมูลส่วนตัว </span>
|
||||
</div>
|
||||
<div class="row q-pa-sm">
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.citizenId"
|
||||
label="เลขประจำตัวประชาชน"
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.prefix"
|
||||
label="คำนำหน้าชื่อ"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.firstName"
|
||||
label="ชื่่อ"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.lastName"
|
||||
label="นามสกุล"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.birthDate"
|
||||
label="วัน/เดือน/ปีเกิด"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.gender"
|
||||
label="เพศ"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="imformation.age"
|
||||
label="อายุ"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
|
||||
<q-card bordered style="border: 1px solid #d6dee1">
|
||||
<div class="q-pa-md">
|
||||
<div class="text-weight-bold row items-center">
|
||||
<q-icon name="mdi-account-tie" color="grey-7" />
|
||||
<span class="q-ml-md">ข้อมูลราชการ </span>
|
||||
</div>
|
||||
<div class="row q-pa-sm">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.oc === '' ? '-' : goverment.oc"
|
||||
label="สังกัด"
|
||||
autogrow
|
||||
></q-input>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.posNo"
|
||||
label="ตำแหน่งเลขที่"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.position"
|
||||
label="ตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionPathSide"
|
||||
label="ด้าน/สาขา"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionLine"
|
||||
label="สายงาน"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionType"
|
||||
label="ประเภทตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-6 col-md-6">
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionLevel"
|
||||
label="ระดับตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="col-xs-6 col-md-6"
|
||||
v-if="props.type !== 'employee'"
|
||||
>
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionExecutive"
|
||||
label="ตำแหน่งทางการบริหาร"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="col-xs-6 col-md-6"
|
||||
v-if="props.type !== 'employee'"
|
||||
>
|
||||
<q-input
|
||||
borderless
|
||||
readonly
|
||||
:model-value="goverment.positionExecutiveSide"
|
||||
label="ด้านตำแหน่งทางการบริหาร"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card>
|
||||
</div>
|
||||
</q-scroll-area>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
96
src/components/Dialogs/PopupReason.vue
Normal file
96
src/components/Dialogs/PopupReason.vue
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
const reason = ref<string | undefined>("");
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const props = defineProps({
|
||||
// modal: {
|
||||
// type: Boolean,
|
||||
// default: false,
|
||||
// },
|
||||
title: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
// clickClose: {
|
||||
// type: Function,
|
||||
// default: () => {},
|
||||
// },
|
||||
savaForm: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
textReport: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
watch(props, () => {
|
||||
if (modal.value === true && props.textReport == "") {
|
||||
reason.value = "";
|
||||
} else {
|
||||
reason.value = props.textReport;
|
||||
}
|
||||
});
|
||||
|
||||
const myForm = ref<any>();
|
||||
const submit = () => {
|
||||
myForm.value.validate().then((result: boolean) => {
|
||||
if (result) {
|
||||
props.savaForm(reason.value);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function closeModal() {
|
||||
modal.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card style="width: 40vw; max-width: 40vw">
|
||||
<q-form ref="myForm">
|
||||
<DialogHeader :tittle="props.title" :close="closeModal" />
|
||||
<q-separator />
|
||||
<q-card-section class="q-pa-sm bg-grey-1">
|
||||
<div class="row col-12 q-col-gutter-sm">
|
||||
<div class="col-xs-12">
|
||||
<div class="col-12 row q-py-sm items-center q-col-gutter-sm">
|
||||
<q-input
|
||||
type="textarea"
|
||||
class="full-width inputgreen cursor-pointer"
|
||||
hide-bottom-space
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
:rules="[(val) => !!val || `กรุณากรอก${label}`]"
|
||||
v-model="reason"
|
||||
:label="`${label}`"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
dense
|
||||
unelevated
|
||||
label="บันทึก"
|
||||
color="public"
|
||||
@click="submit"
|
||||
class="q-px-md"
|
||||
>
|
||||
<!-- icon="mdi-content-save-outline" -->
|
||||
<q-tooltip>บันทึก</q-tooltip>
|
||||
</q-btn>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
111
src/components/Dialogs/PopupReplyInbox.vue
Normal file
111
src/components/Dialogs/PopupReplyInbox.vue
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import { useQuasar } from "quasar";
|
||||
const mixin = useCounterMixin(); //เรียกฟังก์ชันกลาง
|
||||
const $q = useQuasar();
|
||||
|
||||
const { showLoader, hideLoader, success, messageError } = mixin;
|
||||
|
||||
const myForm = ref<any>();
|
||||
const props = defineProps({
|
||||
modal: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
idInbox: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
clickClose: {
|
||||
type: Function,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const subject = ref<string>("");
|
||||
const body = ref<string>("");
|
||||
async function submit() {
|
||||
myForm.value.validate().then(async (result: boolean) => {
|
||||
if (result) {
|
||||
// props.savaForm(reason.value);
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.replyMessage(props.idInbox), {
|
||||
subject: subject.value,
|
||||
body: body.value,
|
||||
})
|
||||
.then((res) => {
|
||||
props.clickClose()
|
||||
success($q, "ส่งข้อความสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-dialog v-model="props.modal" persistent>
|
||||
<q-card style="width: 40vw; max-width: 40vw">
|
||||
<q-form ref="myForm">
|
||||
<DialogHeader tittle="ส่งข้อความ" :close="clickClose" />
|
||||
<q-separator />
|
||||
<q-card-section class="q-pa-sm bg-grey-1">
|
||||
<div class="row col-12 q-col-gutter-sm">
|
||||
<div class="col-xs-12">
|
||||
<div class="col-12 row q-py-sm items-center q-col-gutter-sm">
|
||||
<q-input
|
||||
class="full-width inputgreen cursor-pointer"
|
||||
hide-bottom-space
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
:rules="[(val) => !!val || 'กรุณากรอกหัวข้อ']"
|
||||
v-model="subject"
|
||||
label="หัวข้อ"
|
||||
/>
|
||||
|
||||
<q-input
|
||||
type="textarea"
|
||||
class="full-width inputgreen cursor-pointer"
|
||||
hide-bottom-space
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
:rules="[(val) => !!val || 'กรุณากรอกข้อความ']"
|
||||
v-model="body"
|
||||
label="ข้อความ"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
dense
|
||||
unelevated
|
||||
label="ส่งข้อความ"
|
||||
color="public"
|
||||
@click="submit"
|
||||
class="q-px-md"
|
||||
>
|
||||
<!-- icon="mdi-content-save-outline" -->
|
||||
<q-tooltip>บันทึก</q-tooltip>
|
||||
</q-btn>
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue