API มอบหมายหน้าที่ความรับผิดชอบ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-10-07 18:03:50 +07:00
parent 88bf249250
commit e7568373c8
4 changed files with 135 additions and 78 deletions

View file

@ -93,6 +93,10 @@ export default {
orgProfileListKeycloak: () => `${orgProfile}/search-personal-no-keycloak`, orgProfileListKeycloak: () => `${orgProfile}/search-personal-no-keycloak`,
/** กำหนดสิทธิ์จัดการโครงสร้าง */ /** กำหนดสิทธิ์จัดการโครงสร้าง */
permissionOrg: `${organization}/permission-org`, permissionOrg: `${organization}/permission-org`,
permissionOrgProfile: `${organization}/permission-org/profile`, // คนที่มีสิทธิ์จัดการโครงสร้าง permissionOrgProfile: `${organization}/permission-org/profile`, // คนที่มีสิทธิ์จัดการโครงสร้าง
/** หมอบหมาย*/
commandSysAssign: `${organization}/commandSys/assign`,
posAssign: `${organization}/pos/assign`,
}; };

View file

@ -10,24 +10,18 @@ import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/components/DialogHeader.vue"; import DialogHeader from "@/components/DialogHeader.vue";
/** importType*/ /** importType*/
import type { QTableProps } from "quasar"; import type {
import type { FilterReqMaster } from "@/modules/02_users/interface/request/Main"; PosMaster,
import type { Roles } from "@/modules/02_users/interface/response/Main"; CommandSysAssign,
} from "@/modules/02_users/interface/response/Main";
/** use*/ /** use*/
const $q = useQuasar(); const $q = useQuasar();
const { const { showLoader, hideLoader, dialogConfirm, messageError, success } =
showLoader, useCounterMixin();
hideLoader,
dialogConfirm,
messageError,
success,
dialogMessageNotify,
} = useCounterMixin();
/** props*/ /** props*/
const modal = defineModel<boolean>("modal", { required: true }); const modal = defineModel<boolean>("modal", { required: true });
const props = defineProps({ const props = defineProps({
fetchDataTable: { fetchDataTable: {
type: Function, type: Function,
@ -37,40 +31,34 @@ const props = defineProps({
type: Object, type: Object,
required: true, required: true,
}, },
reqMaster: {
type: Object,
required: true,
},
}); });
const sysType = ref<any[]>(["SALARY_EMP"]); const posMasterId = ref<string>("");
const sysType = ref<string[]>([]);
const isChangData = ref<boolean>(false); const isChangData = ref<boolean>(false);
const sysTypeOptions = ref<any[]>([ const sysTypeOptions = ref<CommandSysAssign[]>([]);
{
code: "SALARY", async function fetchCommandSysAssign() {
name: "ระบบเงินเดือน", if (sysTypeOptions.value.length === 0) {
modules: [ showLoader();
{ await http
code: "SALARY_EMP", .get(config.API.commandSysAssign)
name: "เงินเดือนข้าราชการ", .then(async (res) => {
}, const data = await res.data.result;
{ sysTypeOptions.value = data;
code: "SALARY_TEMP", })
name: "เงินเดือนลูกจ้างประจำ", .catch((err) => {
}, messageError($q, err);
], })
}, .finally(() => {
{ hideLoader();
code: "PLACEMENT", });
name: "ระบบบรรจุ", }
modules: [ }
{
code: "PLACEMENT_NEW",
name: "เงินเดือนข้าราชการ",
},
{
code: "TRANSFER",
name: "ขอโอน",
},
],
},
]);
function closeDialog() { function closeDialog() {
modal.value = false; modal.value = false;
@ -79,14 +67,45 @@ function closeDialog() {
function onSubmit() { function onSubmit() {
if (sysType.value.length !== 0) { if (sysType.value.length !== 0) {
dialogConfirm($q, () => {}); dialogConfirm($q, async () => {
const body = {
posMasterId: posMasterId.value,
assignIds: sysType.value,
};
showLoader();
await http
.post(config.API.posAssign, body)
.then(async () => {
await props.fetchDataTable(
props.reqMaster.id,
props.reqMaster.revisionId,
props.reqMaster.type
);
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
} }
} }
watch( watch(
() => modal.value, () => modal.value,
() => { async () => {
modal.value; if (modal.value) {
await fetchCommandSysAssign();
posMasterId.value = props.dataPosMaster.id;
const assignId = props.dataPosMaster.posMasterAssigns.map(
(r: PosMaster) => r.assignId
);
sysType.value = assignId;
isChangData.value = false;
}
} }
); );
</script> </script>
@ -105,22 +124,22 @@ watch(
> >
<div class="row q-ml-md q-col-gutter-sm"> <div class="row q-ml-md q-col-gutter-sm">
<div class="text-weight-medium text-body2"> <div class="text-weight-medium text-body2">
{{ item.name }} {{ item.sysName }}
</div> </div>
<div class="col-12"> <div class="col-12">
<q-list class="q-mt-none"> <q-list class="q-mt-none">
<q-item <q-item
dense dense
v-for="(op, index) in item.modules" v-for="(op, index) in item.assgins"
:key="index" :key="index"
> >
<q-item-section avatar :top="item.caption"> <q-item-section avatar>
<q-checkbox <q-checkbox
keep-color keep-color
color="primary" color="primary"
dense dense
v-model="sysType" v-model="sysType"
:val="op.code" :val="op.id"
@update:model-value="isChangData = true" @update:model-value="isChangData = true"
/> />
</q-item-section> </q-item-section>

View file

@ -48,6 +48,7 @@ interface NodeTree {
totalRootPositionNextUse: number; totalRootPositionNextUse: number;
totalRootPositionNextVacant: number; totalRootPositionNextVacant: number;
children: NodeTree; children: NodeTree;
isOfficer: boolean;
} }
interface PosMaster { interface PosMaster {
@ -81,6 +82,7 @@ interface PosMaster {
profilePostype: null | string; profilePostype: null | string;
reason: null | string; reason: null | string;
positions: Position[]; positions: Position[];
assignId: string[];
} }
interface Position { interface Position {
@ -135,4 +137,25 @@ interface Profile {
salary: number; salary: number;
} }
export type { Users, Roles, NodeTree, PosMaster, Position, SysList, Profile }; interface CommandSysAssign {
assgins: DataAssgins[];
id: "REGISTRY";
sysName: "ทะเบียนประวัติ";
}
interface DataAssgins {
description: "เงินเดือนข้าราชการ";
id: "00942120-9787-43a1-934a-e146e0618622";
name: "เงินเดือนข้าราชการ";
}
export type {
Users,
Roles,
NodeTree,
PosMaster,
Position,
SysList,
Profile,
CommandSysAssign,
};

View file

@ -30,6 +30,7 @@ const nodes = ref<Array<NodeTree[]>>([]); // ข้อมูลโครงส
const lazy = ref(nodes); const lazy = ref(nodes);
const expanded = ref<string[]>([]); // const expanded = ref<string[]>([]); //
const nodeId = ref<string>(""); // id const nodeId = ref<string>(""); // id
const isOfficer = ref<boolean>(false);
/** Table*/ /** Table*/
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
@ -97,11 +98,11 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px", style: "font-size: 14px",
}, },
{ {
name: "responsibilities", name: "isPosMasterAssign",
align: "left", align: "center",
label: "การเจ้าหน้าที่", label: "การเจ้าหน้าที่",
sortable: false, sortable: false,
field: "responsibilities", field: "isPosMasterAssign",
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
}, },
@ -287,6 +288,7 @@ async function fetchDataTable(id: string, revisionId: string, level: number) {
*/ */
function updateSelected(data: NodeTree) { function updateSelected(data: NodeTree) {
nodeId.value = data.orgTreeId; nodeId.value = data.orgTreeId;
isOfficer.value = data.isOfficer;
fetchDataTable(data.orgTreeId, data.orgRevisionId, data.orgLevel); fetchDataTable(data.orgTreeId, data.orgRevisionId, data.orgLevel);
} }
@ -309,27 +311,24 @@ function onClickAddRole(data: PosMaster) {
* @param id ตำแหน * @param id ตำแหน
*/ */
function onDelete(id: string) { function onDelete(id: string) {
dialogRemove($q, () => { dialogRemove($q, async () => {
// showLoader(); showLoader();
// http await http
// .post(config.API.managementPermission, { .delete(config.API.posAssign + `/${id}`)
// authRoleId: "", .then(async () => {
// posMasterId: id, await fetchDataTable(
// }) reqMaster.id,
// .then(async () => { reqMaster.revisionId,
// await fetchDataTable( reqMaster.type
// reqMaster.id, );
// reqMaster.revisionId, success($q, "ลบข้อมูลสำเร็จ");
// reqMaster.type })
// ); .catch((err) => {
// success($q, ""); messageError($q, err);
// }) })
// .catch((err) => { .finally(() => {
// messageError($q, err); hideLoader();
// }) });
// .finally(() => {
// hideLoader();
// });
}); });
} }
@ -506,7 +505,15 @@ onMounted(() => {
:key="col.name" :key="col.name"
:props="props" :props="props"
> >
<span class="text-weight-medium">{{ col.label }}</span> <span class="text-weight-medium">
<template v-if="col.name === 'isPosMasterAssign'">
{{ !isOfficer ? col.label : "สกจ." }}
</template>
<template v-else>
{{ col.label }}
</template>
</span>
</q-th> </q-th>
<q-th auto-width></q-th> <q-th auto-width></q-th>
</q-tr> </q-tr>
@ -531,7 +538,10 @@ onMounted(() => {
:key="col.name" :key="col.name"
:props="props" :props="props"
> >
<div> <div v-if="col.name === 'isPosMasterAssign'">
<q-icon name="check" v-if="col.value" color="primary" />
</div>
<div v-else>
{{ col.value ? col.value : "-" }} {{ col.value ? col.value : "-" }}
</div> </div>
</q-td> </q-td>
@ -682,6 +692,7 @@ onMounted(() => {
v-model:modal="modalDialog" v-model:modal="modalDialog"
:dataPosMaster="dataPosMaster as PosMaster" :dataPosMaster="dataPosMaster as PosMaster"
:fetchDataTable="fetchDataTable" :fetchDataTable="fetchDataTable"
:reqMaster="reqMaster"
/> />
</template> </template>