start commit for admin system
This commit is contained in:
commit
badb676529
300 changed files with 58634 additions and 0 deletions
|
|
@ -0,0 +1,482 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
ObjectPosRef,
|
||||
FormQuery,
|
||||
} from "@/modules/01_metadata/interface/index/positionEmployee";
|
||||
import type {
|
||||
DataOption,
|
||||
RowDetailPositions,
|
||||
} from "@/modules/01_metadata/interface/request/position/index";
|
||||
import type {
|
||||
ResGroup,
|
||||
ResLevel,
|
||||
ResPossition,
|
||||
} from "@/modules/01_metadata/interface/response/positionEmployee/Main";
|
||||
|
||||
/**importComponets*/
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/**importStore*/
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/**use*/
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
messageError,
|
||||
success,
|
||||
dialogRemove,
|
||||
} = mixin;
|
||||
|
||||
const rows = ref<ResPossition[]>([]);
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: false,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posDictName",
|
||||
align: "left",
|
||||
label: "ชื่อตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "posDictName",
|
||||
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",
|
||||
},
|
||||
]);
|
||||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"posDictName",
|
||||
"posTypeName",
|
||||
"posLevelName",
|
||||
]);
|
||||
|
||||
const formQuery = reactive<FormQuery>({
|
||||
type: "positionName",
|
||||
keyword: "",
|
||||
});
|
||||
|
||||
const optionFilter = ref<DataOption[]>([
|
||||
{ id: "positionName", name: "ชื่อตำแหน่ง" },
|
||||
{ id: "positionType", name: "กลุ่มงาน" },
|
||||
{ id: "positionLevel", name: "ระดับชั้นงาน" },
|
||||
]);
|
||||
|
||||
const modalDialog = ref<boolean>(false);
|
||||
const isStatusEdit = ref<boolean>(false);
|
||||
const posId = ref<string>("");
|
||||
const formDataPos = reactive({
|
||||
posName: "",
|
||||
posTypeName: "",
|
||||
posLevelName: "",
|
||||
});
|
||||
const posNameRef = ref<object | null>(null);
|
||||
const posTypeNameRef = ref<object | null>(null);
|
||||
const posLevelNameRef = ref<object | null>(null);
|
||||
const objectRef: ObjectPosRef = {
|
||||
posName: posNameRef,
|
||||
posTypeName: posTypeNameRef,
|
||||
posLevelName: posLevelNameRef,
|
||||
};
|
||||
|
||||
const posTypeMain = ref<ResGroup[]>([]);
|
||||
const posTypeOp = ref<DataOption[]>([]);
|
||||
const posLevelOp = ref<DataOption[]>([]);
|
||||
|
||||
function deletePos(id: string) {
|
||||
dialogRemove($q, () => {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.orgEmployeePosById(id))
|
||||
.then(() => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
fetchData();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function onClickOpenDialog(typeEdit: boolean = false, data: any = []) {
|
||||
modalDialog.value = true;
|
||||
isStatusEdit.value = typeEdit;
|
||||
await fetchType();
|
||||
updatePosTypeName(data.posTypeId);
|
||||
if (data) {
|
||||
posId.value = data.id;
|
||||
setTimeout(() => {
|
||||
formDataPos.posName = data.posDictName;
|
||||
formDataPos.posTypeName = data.posTypeId;
|
||||
formDataPos.posLevelName = data.posLevelId;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchData(statusFetch: boolean = false) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.orgEmployeePos +
|
||||
`?keyword=${formQuery.keyword}&type=${
|
||||
statusFetch ? "" : formQuery.type
|
||||
}`
|
||||
)
|
||||
.then((res) => {
|
||||
rows.value = res.data.result;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchType() {
|
||||
if (posTypeMain.value.length === 0) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgEmployeeType)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
posTypeMain.value = data;
|
||||
posTypeOp.value = data.map((e: ResGroup) => ({
|
||||
id: e.id,
|
||||
name: e.posTypeName,
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function onClickSubmit() {
|
||||
const hasError = [];
|
||||
for (const key in objectRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(objectRef, key)) {
|
||||
const property = objectRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
dialogConfirm($q, () => {
|
||||
submit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const body = {
|
||||
posDictName: formDataPos.posName,
|
||||
posTypeId: formDataPos.posTypeName,
|
||||
posLevelId: formDataPos.posLevelName,
|
||||
};
|
||||
showLoader();
|
||||
try {
|
||||
const url = !isStatusEdit.value
|
||||
? config.API.orgEmployeePos
|
||||
: config.API.orgEmployeePosById(posId.value);
|
||||
await http[!isStatusEdit.value ? "post" : "put"](url, body);
|
||||
success($q, "บันทีกข้อมูลสำเร็จ");
|
||||
fetchData();
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
hideLoader();
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
function updatePosTypeName(id: string) {
|
||||
const posLevel = posTypeMain.value.find((e: ResGroup) => e.id === id);
|
||||
posLevelOp.value =
|
||||
posLevel?.posLevels.map((e: ResLevel) => ({
|
||||
id: e.id,
|
||||
name: e.posLevelName.toString(),
|
||||
})) ?? [];
|
||||
formDataPos.posLevelName = "";
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
modalDialog.value = false;
|
||||
formDataPos.posName = "";
|
||||
formDataPos.posTypeName = "";
|
||||
formDataPos.posLevelName = "";
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData(true);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="row col-12 q-mb-sm">
|
||||
<div class="col-md-2">
|
||||
<q-btn
|
||||
id="addComplaints"
|
||||
for="addComplaints"
|
||||
size="12px"
|
||||
flat
|
||||
round
|
||||
color="primary"
|
||||
icon="mdi-plus"
|
||||
@click="onClickOpenDialog()"
|
||||
><q-tooltip>เพิ่มตำเเหน่ง </q-tooltip></q-btn
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="row col-md-10 q-col-gutter-sm">
|
||||
<div class="col-md-4">
|
||||
<q-select
|
||||
label="ค้นหาจาก"
|
||||
v-model="formQuery.type"
|
||||
:options="optionFilter"
|
||||
emit-value
|
||||
dense
|
||||
map-options
|
||||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<q-input
|
||||
ref="searchRef"
|
||||
v-model="formQuery.keyword"
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
label="คำค้น"
|
||||
hide-bottom-space
|
||||
@keydown.enter="fetchData()"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon
|
||||
v-if="formQuery.keyword"
|
||||
name="cancel"
|
||||
@click="(formQuery.keyword = ''), fetchData()"
|
||||
class="cursor-pointer"
|
||||
></q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
|
||||
<div class="row col-md-2">
|
||||
<q-btn
|
||||
color="primary"
|
||||
icon="search"
|
||||
label="ค้นหา"
|
||||
class="full-width"
|
||||
@click="fetchData()"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="full-width q-mt-sm">
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
row-key="id"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
: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"
|
||||
style="color: #000000; font-weight: 500"
|
||||
>
|
||||
<span class="text-weight-medium">{{ col.label }}</span>
|
||||
</q-th>
|
||||
<q-th auto-width></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">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
color="blue-6"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
class="q-mr-xs"
|
||||
size="12px"
|
||||
icon="mdi-content-copy"
|
||||
clickable
|
||||
@click.stop="
|
||||
() => {
|
||||
onClickOpenDialog(false, props.row);
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip>คัดลอกข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
color="edit"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
size="12px"
|
||||
icon="mdi-pencil"
|
||||
clickable
|
||||
@click.stop="onClickOpenDialog(true, props.row)"
|
||||
v-close-popup
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
color="red"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
size="12px"
|
||||
icon="mdi-delete"
|
||||
clickable
|
||||
@click.stop="deletePos(props.row.id)"
|
||||
v-close-popup
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
|
||||
<q-dialog v-model="modalDialog" class="dialog" persistent>
|
||||
<q-card style="width: 350px">
|
||||
<form @submit.prevent="onClickSubmit">
|
||||
<DialogHeader
|
||||
:tittle="`${
|
||||
isStatusEdit
|
||||
? 'แก้ไขข้อมูลตำแหน่งลูกจ้างประจำ'
|
||||
: 'เพิ่มข้อมูลตำแหน่งลูกจ้างประจำ'
|
||||
}`"
|
||||
:close="closeDialog"
|
||||
/>
|
||||
<q-separator />
|
||||
|
||||
<q-card-section>
|
||||
<div class="row q-col-gutter-sm col-12">
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
ref="posNameRef"
|
||||
v-model="formDataPos.posName"
|
||||
dense
|
||||
outlined
|
||||
for="#positionName"
|
||||
label="ชื่อตำแหน่ง"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกชื่อตำแหน่ง'}`]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<q-select
|
||||
ref="posTypeNameRef"
|
||||
label="กลุ่มงาน"
|
||||
v-model="formDataPos.posTypeName"
|
||||
:options="posTypeOp"
|
||||
emit-value
|
||||
dense
|
||||
map-options
|
||||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกกลุ่มงาน'}`]"
|
||||
@update:model-value="updatePosTypeName"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<q-select
|
||||
ref="posLevelNameRef"
|
||||
label="ระดับชั้นงาน"
|
||||
v-model="formDataPos.posLevelName"
|
||||
:disable="formDataPos.posTypeName === ''"
|
||||
:options="posLevelOp"
|
||||
emit-value
|
||||
dense
|
||||
map-options
|
||||
outlined
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกระดับชั้นงาน'}`]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<q-card-actions align="right">
|
||||
<q-btn type="submit" :label="`บันทึก`" color="public" />
|
||||
</q-card-actions>
|
||||
</form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,373 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useQuasar } from "quasar";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { ObjectGroupRef } from "@/modules/01_metadata/interface/index/positionEmployee";
|
||||
import type { ResGroup } from "@/modules/01_metadata/interface/response/positionEmployee/Main";
|
||||
import type { FrmDataGroup } from "@/modules/01_metadata/interface/request/positionEmployee";
|
||||
|
||||
/** importComponents*/
|
||||
import dialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/** importStore*/
|
||||
import { usePositionEmployeeDataStore } from "@/modules/01_metadata/stores/positionEmployeeStore";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/** use*/
|
||||
const $q = useQuasar();
|
||||
const store = usePositionEmployeeDataStore();
|
||||
const router = useRouter();
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogRemove,
|
||||
dialogConfirm,
|
||||
success,
|
||||
messageError,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
} = mixin;
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "posTypeName",
|
||||
align: "left",
|
||||
label: "กลุ่มงาน",
|
||||
sortable: true,
|
||||
field: "posTypeName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeShortName",
|
||||
align: "left",
|
||||
label: "อักษรย่อกลุ่มงาน",
|
||||
sortable: true,
|
||||
field: "posTypeShortName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posTypeRank",
|
||||
align: "left",
|
||||
label: "ระดับกลุ่มงาน",
|
||||
sortable: true,
|
||||
field: "posTypeRank",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const visibleColumns = ref<string[]>([
|
||||
"posTypeName",
|
||||
"posTypeShortName",
|
||||
"posTypeRank",
|
||||
]);
|
||||
|
||||
/** from เพิ่มข้อมูลกลุ่มงาน */
|
||||
const formDataGroup = reactive<FrmDataGroup>({
|
||||
posTypeName: "",
|
||||
posTypeShortName: "",
|
||||
posTypeRank: null,
|
||||
});
|
||||
|
||||
/** formRef*/
|
||||
const posTypeNameRef = ref<Object | null>(null);
|
||||
const posTypeShortNameRef = ref<Object | null>(null);
|
||||
const posTypeRankRef = ref<Object | null>(null);
|
||||
const objectGroupRef: ObjectGroupRef = {
|
||||
posTypeName: posTypeNameRef,
|
||||
posTypeShortName: posTypeShortNameRef,
|
||||
posTypeRank: posTypeRankRef,
|
||||
};
|
||||
|
||||
const editId = ref<string>("");
|
||||
const filterKeyword = ref<string>("");
|
||||
const dialog = ref<boolean>(false);
|
||||
const dialogStatus = ref<string>("");
|
||||
const rows = ref<ResGroup[]>([]);
|
||||
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.orgEmployeeType)
|
||||
.then(async (res) => {
|
||||
rows.value = res.data.result;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function onClickSubmit() {
|
||||
const hasError = [];
|
||||
for (const key in objectGroupRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(objectGroupRef, key)) {
|
||||
const property = objectGroupRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
dialogConfirm($q, () => {
|
||||
submit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const body: FrmDataGroup = {
|
||||
posTypeName: formDataGroup.posTypeName,
|
||||
posTypeShortName: formDataGroup.posTypeShortName,
|
||||
posTypeRank: Number(formDataGroup.posTypeRank),
|
||||
};
|
||||
showLoader();
|
||||
try {
|
||||
const url =
|
||||
dialogStatus.value === "create"
|
||||
? config.API.orgEmployeeType
|
||||
: config.API.orgEmployeeTypeById(editId.value);
|
||||
await http[dialogStatus.value === "create" ? "post" : "put"](url, body);
|
||||
success($q, "บันทีกข้อมูลสำเร็จ");
|
||||
fetchData();
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
hideLoader();
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
function onClickDelete(id: string) {
|
||||
dialogRemove($q, () => {
|
||||
showLoader();
|
||||
http
|
||||
.delete(config.API.orgEmployeeTypeById(id))
|
||||
.then(() => {
|
||||
fetchData();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onClickOpenDialogEdit(data: ResGroup) {
|
||||
dialogStatus.value = "edit";
|
||||
dialog.value = true;
|
||||
editId.value = data.id;
|
||||
formDataGroup.posTypeName = data.posTypeName;
|
||||
formDataGroup.posTypeShortName = data.posTypeShortName;
|
||||
formDataGroup.posTypeRank = data.posTypeRank;
|
||||
}
|
||||
|
||||
function onClickDetail(id: string) {
|
||||
router.push(`/master-data/position-employee/level/${id}`);
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
dialog.value = false;
|
||||
clearFormData();
|
||||
}
|
||||
|
||||
function clearFormData() {
|
||||
formDataGroup.posTypeName = "";
|
||||
formDataGroup.posTypeShortName = "";
|
||||
formDataGroup.posTypeRank = null;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-toolbar style="padding: 0">
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
color="primary"
|
||||
icon="add"
|
||||
@click.stop="
|
||||
() => {
|
||||
dialogStatus = 'create';
|
||||
dialog = true;
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip> เพิ่มข้อมูล </q-tooltip>
|
||||
</q-btn>
|
||||
<q-space />
|
||||
<div class="row q-gutter-sm">
|
||||
<q-input outlined dense v-model="filterKeyword" label="ค้นหา"></q-input>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
/>
|
||||
</div>
|
||||
</q-toolbar>
|
||||
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
:filter="filterKeyword"
|
||||
row-key="name"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
: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-th auto-width />
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr
|
||||
:props="props"
|
||||
class="cursor-pointer"
|
||||
@click.stop="onClickDetail(props.row.id)"
|
||||
>
|
||||
<q-td v-for="col in props.cols" :key="col.id">
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
color="edit"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
class="q-mr-xs"
|
||||
size="12px"
|
||||
icon="edit"
|
||||
@click.stop="onClickOpenDialogEdit(props.row)"
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
color="red"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
size="12px"
|
||||
icon="mdi-delete"
|
||||
clickable
|
||||
@click.stop="onClickDelete(props.row.id)"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
|
||||
<q-dialog v-model="dialog" class="dialog" persistent>
|
||||
<q-card style="width: 350px">
|
||||
<form @submit.prevent="onClickSubmit">
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<dialog-header
|
||||
:tittle="
|
||||
dialogStatus === 'edit'
|
||||
? 'แก้ไขข้อมูลกลุ่มงาน'
|
||||
: 'เพิ่มข้อมูลกลุ่มงาน'
|
||||
"
|
||||
:close="closeDialog"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
<q-separator color="grey-4" />
|
||||
<q-card-section class="row q-gutter-y-md">
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
ref="posTypeNameRef"
|
||||
outlined
|
||||
v-model="formDataGroup.posTypeName"
|
||||
label="ชื่อกลุ่มงาน"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
bg-color="white"
|
||||
:rules="[(val) => val.length > 0 || 'กรุณากรอกชื่อกลุ่มงาน']"
|
||||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
ref="posTypeShortNameRef"
|
||||
v-model="formDataGroup.posTypeShortName"
|
||||
dense
|
||||
outlined
|
||||
for="#positionShortName"
|
||||
label="อักษรย่อกลุ่มงาน"
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกอักษรย่อกลุ่มงาน'}`]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
ref="posTypeRankRef"
|
||||
outlined
|
||||
v-model="formDataGroup.posTypeRank"
|
||||
label="ระดับกลุ่มงาน"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
min="1"
|
||||
bg-color="white"
|
||||
:rules="[(val) => val != undefined || 'กรุณากรอกระดับกลุ่มงาน']"
|
||||
hide-bottom-space
|
||||
mask="############"
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-separator />
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
id="onSubmit"
|
||||
type="submit"
|
||||
dense
|
||||
unelevated
|
||||
label="บันทึก"
|
||||
color="public"
|
||||
class="q-px-md"
|
||||
>
|
||||
<q-tooltip>บันทึกข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-card-actions>
|
||||
</form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
|
|
@ -0,0 +1,408 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
/** importType*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
ResGroup,
|
||||
ResLevel,
|
||||
} from "@/modules/01_metadata/interface/response/positionEmployee/Main";
|
||||
import type { ObjectLevelRef } from "@/modules/01_metadata/interface/index/positionEmployee";
|
||||
import type { FormDataLevel } from "@/modules/01_metadata/interface/request/positionEmployee";
|
||||
|
||||
/** importComponts*/
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
/** importStore*/
|
||||
import { useMainOptionDataStore } from "@/modules/01_metadata/stores/main";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
/**use*/
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const posName = ref<string>("");
|
||||
const posTypeId = ref<string>(route.params.id.toString());
|
||||
|
||||
const {
|
||||
dialogRemove,
|
||||
dialogConfirm,
|
||||
showLoader,
|
||||
hideLoader,
|
||||
messageError,
|
||||
success,
|
||||
} = useCounterMixin();
|
||||
const storeOption = useMainOptionDataStore();
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: false,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px; width:0px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posLevelName",
|
||||
align: "left",
|
||||
label: "ระดับชั้นงาน",
|
||||
sortable: true,
|
||||
field: "posLevelName",
|
||||
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: "posLevelAuthority",
|
||||
align: "left",
|
||||
label: "ผู้มีอำนาจสั่งบรรจุ",
|
||||
sortable: true,
|
||||
field: "posLevelAuthority",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
const rows = ref<any>([]);
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
"no",
|
||||
"posLevelName",
|
||||
"posTypeName",
|
||||
"posLevelAuthority",
|
||||
]);
|
||||
const filter = ref<string>("");
|
||||
|
||||
const levelId = ref<string>("");
|
||||
const titleName = ref<string | null>("");
|
||||
const formDataLevel = reactive<FormDataLevel>({
|
||||
posLevelName: null,
|
||||
posTypeName: "",
|
||||
posLevelAuthority: "",
|
||||
});
|
||||
|
||||
/** formRef*/
|
||||
const posLevelNameRef = ref<Object | null>(null);
|
||||
const commanderRef = ref<Object | null>(null);
|
||||
const objectLevelRef: ObjectLevelRef = {
|
||||
posLevelName: posLevelNameRef,
|
||||
posLevelAuthority: commanderRef,
|
||||
};
|
||||
|
||||
const id = ref<string>(route.params.id.toString());
|
||||
|
||||
function fetchData() {
|
||||
showLoader();
|
||||
http
|
||||
.get(config.API.orgEmployeeTypeById(id.value))
|
||||
.then((res) => {
|
||||
titleName.value = res.data.result.posTypeName ?? null;
|
||||
formDataLevel.posTypeName = res.data.result.posTypeName;
|
||||
rows.value = res.data.result.posLevels.map((x: any) => ({
|
||||
...x,
|
||||
posTypeName: res.data.result.posTypeName,
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
const isStatusEdit = ref<boolean>(false);
|
||||
const modalDialog = ref<boolean>(false);
|
||||
function onClickOpenDialog(statusEdit: boolean = false, data: any = []) {
|
||||
isStatusEdit.value = statusEdit;
|
||||
modalDialog.value = true;
|
||||
|
||||
if (statusEdit) {
|
||||
levelId.value = data.id;
|
||||
formDataLevel.posLevelName = data.posLevelName;
|
||||
formDataLevel.posTypeName = titleName.value;
|
||||
formDataLevel.posLevelAuthority = data.posLevelAuthority;
|
||||
} else {
|
||||
formDataLevel.posTypeName = titleName.value ? titleName.value : "";
|
||||
}
|
||||
}
|
||||
|
||||
function onClickCloseDialog() {
|
||||
modalDialog.value = false;
|
||||
formDataLevel.posLevelName = null;
|
||||
formDataLevel.posTypeName = "";
|
||||
formDataLevel.posLevelAuthority = "";
|
||||
}
|
||||
|
||||
function onClickSubmit() {
|
||||
const hasError = [];
|
||||
for (const key in objectLevelRef) {
|
||||
if (Object.prototype.hasOwnProperty.call(objectLevelRef, key)) {
|
||||
const property = objectLevelRef[key];
|
||||
if (property.value && typeof property.value.validate === "function") {
|
||||
const isValid = property.value.validate();
|
||||
hasError.push(isValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
dialogConfirm($q, () => {
|
||||
submit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const body = {
|
||||
posLevelName: Number(formDataLevel.posLevelName),
|
||||
posTypeId: posTypeId.value,
|
||||
posLevelRank: Number(formDataLevel.posLevelName),
|
||||
posLevelAuthority: formDataLevel.posLevelAuthority,
|
||||
};
|
||||
showLoader();
|
||||
try {
|
||||
const url = !isStatusEdit.value
|
||||
? config.API.orgEmployeelevel
|
||||
: config.API.orgEmployeelevelById(levelId.value);
|
||||
await http[!isStatusEdit.value ? "post" : "put"](url, body);
|
||||
success($q, "บันทีกข้อมูลสำเร็จ");
|
||||
fetchData();
|
||||
onClickCloseDialog();
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
|
||||
function onClickDelete(id: string) {
|
||||
dialogRemove($q, () => {
|
||||
http
|
||||
.delete(config.API.orgEmployeelevelById(id))
|
||||
.then(() => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
fetchData();
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function convertPosLevelAuthority(val: string) {
|
||||
const result = storeOption.posLevelAuthorityOption.find((e) => e.id === val);
|
||||
return result?.label;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
posTypeId.value && fetchData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
<q-btn
|
||||
icon="mdi-arrow-left"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
flat
|
||||
color="primary"
|
||||
class="q-mr-sm"
|
||||
@click="router.go(-1)"
|
||||
/>
|
||||
รายการระดับชั้นงาน{{ titleName }}
|
||||
</div>
|
||||
|
||||
<q-card flat bordered>
|
||||
<div class="q-pa-md">
|
||||
<q-toolbar style="padding: 0">
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
color="primary"
|
||||
icon="add"
|
||||
@click.stop.pervent="onClickOpenDialog()"
|
||||
>
|
||||
<q-tooltip> เพิ่มข้อมูล </q-tooltip>
|
||||
</q-btn>
|
||||
<q-space />
|
||||
<div class="row q-gutter-sm">
|
||||
<q-input outlined dense v-model="filter" label="ค้นหา"></q-input>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
/>
|
||||
</div>
|
||||
</q-toolbar>
|
||||
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
:filter="filter"
|
||||
row-key="name"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
: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-bold">{{ col.label }}</span>
|
||||
</q-th>
|
||||
<q-th auto-width />
|
||||
</q-tr>
|
||||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td v-for="(col, index) in props.cols" :key="col.id">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-else-if="col.name === 'posLevelAuthority'">
|
||||
{{ col.value ? convertPosLevelAuthority(col.value) : "-" }}
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn
|
||||
color="edit"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
class="q-mr-xs"
|
||||
size="12px"
|
||||
icon="edit"
|
||||
@click.stop.pervent="onClickOpenDialog(true, props.row)"
|
||||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
color="red"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
size="12px"
|
||||
icon="mdi-delete"
|
||||
@click="onClickDelete(props.row.id)"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-card>
|
||||
|
||||
<q-dialog v-model="modalDialog" class="dialog" persistent>
|
||||
<q-card style="width: 350px">
|
||||
<form @submit.prevent="onClickSubmit">
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<DialogHeader
|
||||
:tittle="isStatusEdit ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
|
||||
:close="onClickCloseDialog"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
<q-separator color="grey-4" />
|
||||
<q-card-section class="row q-gutter-y-md">
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
outlined
|
||||
ref="posLevelNameRef"
|
||||
v-model="formDataLevel.posLevelName"
|
||||
label="ระดับชั้นงาน"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
bg-color="white"
|
||||
hide-bottom-space
|
||||
mask="#######################################"
|
||||
:rules="[(val) => !!val || 'กรุณากรอกระดับชั้นงาน']"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<q-select
|
||||
ref="commanderRef"
|
||||
outlined
|
||||
v-model="formDataLevel.posLevelAuthority"
|
||||
emit-value
|
||||
map-options
|
||||
:options="storeOption.posLevelAuthorityOption"
|
||||
option-value="id"
|
||||
label="ผู้มีอำนาจสั่งบรรจุ"
|
||||
dense
|
||||
lazy-rules
|
||||
borderless
|
||||
bg-color="white"
|
||||
hide-bottom-space
|
||||
:rules="[(val) => !!val || 'กรุณาเลือกผู้มีอำนาจสั่งบรรจุ']"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<q-select
|
||||
ref="posTypeIdRef"
|
||||
v-model="formDataLevel.posTypeName"
|
||||
label="กลุ่มงาน"
|
||||
outlined
|
||||
dense
|
||||
bg-color="white"
|
||||
options-cover
|
||||
hide-bottom-space
|
||||
readonly
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
id="onSubmit"
|
||||
type="submit"
|
||||
dense
|
||||
unelevated
|
||||
label="บันทึก"
|
||||
color="public"
|
||||
class="q-px-md"
|
||||
>
|
||||
<q-tooltip>บันทึกข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-card-actions>
|
||||
</form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue