Merge branch 'develop' into feat/issue

* develop:
  fix: show workflow EMP
  fix:disable radio Digital
  fix:profileId To citizenId
  fix: form upload Attachment
  fix:bug
  fix: active act org level 0 only
  add: บันทึกรักษาการในตำแหน่ง (owner only)
  fix: convertCommandCodeName columns commandCode
  test
  fix:default profileAvatar
  fix:show btn delete avatar active
  fix: approveCheck
  fix: statusCheck PENDING
  fix(leave):approveCheck logic for commander approval status
  fix: disabled organization view
  fix(indicator-plan):fix nodeDnaId
  fix: title by issue #2156 ปรับระดับชั้นงาน-ย้ายลูกจ้าง (ข้อความเมนูไม่เหมือนกัน)
  fix(timestamp):clear_rowData
  ปิดปุ่มแก้ไข และเพิ่มของประวัติตำแหน่ง เงินเดือน แก้ได้แค่ owner เท่านั้น

# Conflicts:
#	src/api/02_organizational/api.organization.ts
This commit is contained in:
Warunee Tamkoo 2026-02-04 13:43:52 +07:00
commit e3f35a189c
27 changed files with 497 additions and 204 deletions

View file

@ -196,4 +196,6 @@ export default {
orgAssistance: (id: string) => `${orgProfile}/assistance/${id}`,
orgIssues: `${organization}/issues`,
// active รักษาการในตำแหน่งตามหน่วยงาน
activeActPosition: (id: string) => `${orgPosAct}/${id}`,
};

View file

@ -177,7 +177,7 @@ function updateSelectedAgency(data: any, isUpdate: boolean = false) {
/**function ยืนยันการบันทึกข้อมูล */
function onSubmit() {
if (planData.nodeId == null || planData.strategyId == "") {
if (nodeDnaId.value == "" || planData.strategyId == "") {
dialogMessageNotify(
$q,
`กรุณาเลือกหน่วยงาน/ส่วนราชการ หรือ ยุทธศาสตร์/แผน`

View file

@ -397,13 +397,24 @@ onMounted(async () => {
@click="store.statusView = 'list'"
/>
<q-separator inset vertical />
<!-- รอแกไข API -->
<!-- <q-btn
flat
dense
icon="mdi-sitemap"
:color="store.statusView === 'tree' ? 'grey-7' : 'grey-4'"
@click="store.statusView = 'tree'"
/> -->
<q-btn
flat
dense
icon="mdi-sitemap"
:color="store.statusView === 'tree' ? 'grey-7' : 'grey-4'"
@click="store.statusView = 'tree'"
/>
disabled
>
<q-tooltip>อยระหวางปรบปร</q-tooltip>
</q-btn>
<q-separator inset vertical />
<q-btn
flat

View file

@ -40,6 +40,9 @@ const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
const citizenId = defineModel<string>("citizenId", {
required: true,
});
const baseColumns = ref<QTableColumn[]>([
{
@ -614,7 +617,7 @@ onMounted(() => {
disable
v-model="formData.status"
label="ใช้งาน"
keep-color="primary"
keep-color
/>
</div>
</div>
@ -642,6 +645,7 @@ onMounted(() => {
v-model:modal="modalCommand"
v-model:command="command"
v-model:command-id="commandId"
:citizen-id="citizenId"
/>
</template>

View file

@ -46,6 +46,9 @@ const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
const citizenId = defineModel<string>("citizenId", {
required: true,
});
const baseColumns = ref<QTableColumn[]>([
{
@ -977,6 +980,7 @@ onMounted(() => {
v-model:modal="modalCommand"
v-model:command="command"
v-model:command-id="commandId"
:citizen-id="citizenId"
/>
</template>

View file

@ -39,6 +39,9 @@ const profileId = ref<string>(
const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
const citizenId = defineModel<string>("citizenId", {
required: true,
});
const store = useGovernmentPosDataStore();
const {
@ -210,7 +213,7 @@ const baseColumns = ref<QTableColumn[]>([
sortable: true,
field: "commandCode",
format(val, row) {
return row.commandName;
return store.convertCommandCodeName(row.commandCode);
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@ -898,7 +901,11 @@ onMounted(async () => {
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-btn
v-if="!isLeave && checkPermission($route)?.attrIsUpdate"
v-if="
!isLeave &&
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrOwnership === 'OWNER'
"
flat
color="primary"
round
@ -972,7 +979,11 @@ onMounted(async () => {
</q-btn>
<q-btn
v-if="isLeave == false && checkPermission($route)?.attrIsUpdate"
v-if="
!isLeave &&
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrOwnership === 'OWNER'
"
flat
:disable="
(props.row.commandId !== null && props.row.commandId !== '') ||
@ -1613,6 +1624,7 @@ onMounted(async () => {
v-model:modal="modalCommand"
v-model:command="command"
v-model:commandId="commandId"
:citizen-id="citizenId"
/>
</template>

View file

@ -65,13 +65,22 @@ const storeRegistry = useRegistryNewDataStore();
<PerformSpecialWork :is-leave="storeRegistry.isLeave" />
</q-tab-panel>
<q-tab-panel v-if="empType != '-employee'" name="5">
<ActingPos :is-leave="storeRegistry.isLeave" />
<ActingPos
:is-leave="storeRegistry.isLeave"
:citizen-id="storeRegistry.citizenId"
/>
</q-tab-panel>
<q-tab-panel v-if="empType != '-employee'" name="6">
<HelpGovernmentDetail :is-leave="storeRegistry.isLeave" />
<HelpGovernmentDetail
:is-leave="storeRegistry.isLeave"
:citizen-id="storeRegistry.citizenId"
/>
</q-tab-panel>
<q-tab-panel name="7">
<Postion :is-leave="storeRegistry.isLeave" />
<Postion
:is-leave="storeRegistry.isLeave"
:citizen-id="storeRegistry.citizenId"
/>
</q-tab-panel>
</q-tab-panels>
</template>

View file

@ -39,6 +39,9 @@ const profileId = ref<string>(
const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
const citizenId = defineModel<string>("citizenId", {
required: true,
});
const store = useSalaryDataStore();
const {
@ -215,7 +218,7 @@ const baseColumns = ref<QTableColumn[]>([
sortable: true,
field: "commandCode",
format(val, row) {
return row.commandName;
return store.convertCommandCodeName(row.commandCode);
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
@ -860,7 +863,11 @@ onMounted(async () => {
<template>
<div class="row items-center q-gutter-x-sm q-pb-sm">
<q-btn
v-if="!isLeave && checkPermission($route)?.attrIsUpdate"
v-if="
!isLeave &&
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrOwnership === 'OWNER'
"
flat
color="primary"
round
@ -932,9 +939,12 @@ onMounted(async () => {
>
<q-tooltip>ประวแกไขตำแหน/เงนเดอน</q-tooltip>
</q-btn>
<q-btn
v-if="isLeave == false && checkPermission($route)?.attrIsUpdate"
v-if="
!isLeave &&
checkPermission($route)?.attrIsUpdate &&
checkPermission($route)?.attrOwnership === 'OWNER'
"
flat
:disable="
(props.row.commandId !== null && props.row.commandId !== '') ||
@ -1617,6 +1627,7 @@ onMounted(async () => {
v-model:modal="modalCommand"
v-model:command="command"
v-model:commandId="commandId"
:citizen-id="citizenId"
/>
</template>

View file

@ -45,7 +45,10 @@ const tab = ref<string>("1");
<q-tab-panels v-model="tab" animated>
<q-tab-panel name="1">
<PositionSalary :is-leave="storeRegistry.isLeave" />
<PositionSalary
:is-leave="storeRegistry.isLeave"
:citizen-id="storeRegistry.citizenId"
/>
</q-tab-panel>
<q-tab-panel name="2">
<NotReceiveSalary :is-leave="storeRegistry.isLeave" />

View file

@ -553,12 +553,17 @@ onMounted(async () => {
</q-form>
<div class="col-12">
{{ typeEmp }}
<!-- v-if="typeEmp != 'employee'" -->
<Workflow
v-if="typeEmp != 'employee'"
v-model:is-check-data="isCheckData"
ref="workflowRef"
:id="requestId"
sys-name="REGISTRY_PROFILE"
:sys-name="
typeEmp !== 'employee'
? 'REGISTRY_PROFILE'
: 'REGISTRY_PROFILE_EMP'
"
/>
</div>
</div>

View file

@ -695,7 +695,7 @@ function closeImage() {
* งกนยนยนการลบร
* @param id ปภาพ
*/
function deletePhoto(id: string) {
function deletePhoto(id: string, isActive: boolean) {
dialogRemove(
$q,
async () => {
@ -706,6 +706,10 @@ function deletePhoto(id: string) {
.delete(config.API.orgProfileAvatarbyType(empType.value) + `/${id}`)
.then(async () => {
await getImage();
if (isActive) {
activeImage.value = null;
await fetchDataPersonal();
}
})
.catch((e) => {
messageError($q, e);
@ -821,7 +825,6 @@ onMounted(async () => {
'SYS_PLACEMENT_OTHER',
'SYS_TRANSFER_REQ',
'SYS_RESIGN',
])) ||
leaveType === 'DISCIPLINE_TEMP_SUSPEND' ||
leaveType === 'RETIRE_RESIGN' ||
@ -873,7 +876,7 @@ onMounted(async () => {
'SYS_PROMOTION_EMP',
'SYS_PASSAWAY',
'SYS_DISMISS_EMP',
'SYS_RESIGN_EMP'
'SYS_RESIGN_EMP',
])
"
size="md"
@ -1211,18 +1214,21 @@ onMounted(async () => {
>
{{ date2Thai(n.createdAt) }}
<!-- v-if="!n.isActive" -->
<q-btn
v-if="!n.isActive"
icon="delete"
unelevated
dense
@click="deletePhoto(n.id)"
@click="deletePhoto(n.id, n.isActive)"
class="bg-white"
style="color: #ff8080"
>
<q-tooltip>ลบรปภาพ</q-tooltip>
</q-btn>
</div>
<div class="absolute-top-right" v-if="n.isActive">
<q-icon name="star" color="yellow" size="24px" />
</div>
</q-img>
</div>
</div>
@ -1230,7 +1236,12 @@ onMounted(async () => {
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn @click="selectAvatarHistory" color="public" label="เลือกรูปภาพ">
<q-btn
@click="selectAvatarHistory"
color="public"
label="เลือกรูปภาพ"
:disable="images.length == 0"
>
<q-tooltip>เลอกรปภาพ</q-tooltip>
</q-btn>
</q-card-actions>

View file

@ -745,6 +745,8 @@ onMounted(async () => {
/>
</div>
</q-card-section>
</q-card>
<!-- แสดง dialog เลอกหนวยงาน/วนราชการ -->

View file

@ -175,7 +175,7 @@ onMounted(async () => {
class="q-mr-sm"
@click="router.push(`/placement/appoint-employee`)"
/>
รายละเอยดการปรบระดบชนงานกจาง {{ fullName }}
รายละเอยดการปรบระดบชนงาน-ายกจาง {{ fullName }}
</div>
<CardProfile :data="dataProfile as DataProfile" :type="'employee'" />

View file

@ -53,6 +53,7 @@ const props = defineProps({
const modalCommand = ref<boolean>(false);
const command = ref<string>("");
const commandId = ref<string>("");
const commandCitizenId = ref<string>("");
let roleAdmin = ref<boolean>(false);
const edit = ref<boolean>(true);
@ -912,9 +913,10 @@ function onSearchAdd() {
}
function onRefCommand(data: any) {
modalCommand.value = true;
command.value = data.refCommandNo;
commandId.value = data.commandId;
commandCitizenId.value = data.citizenId;
modalCommand.value = true;
// commandId.value = 'bdf9da91-ba45-497a-a2b7-cc49e2446d97'; //
}
@ -1787,6 +1789,7 @@ onMounted(async () => {
v-model:modal="modalCommand"
v-model:command="command"
v-model:commandId="commandId"
v-model:citizen-id="commandCitizenId"
/>
</template>

View file

@ -130,7 +130,7 @@ async function fectFormfull() {
evaluate_expenct_level.value = await probationStore.assignOutput.map(
(e: any) => ({
id: e.id,
labal: e.output_desc,
label: e.output_desc,
})
);
evaluate_ouptut.value = await probationStore.assignOutput.map((e: any) => ({

View file

@ -122,7 +122,7 @@ const variablesToWatch = [
competency_level,
learn_level,
apply_level,
success_level,
// success_level,
];
const ArrayCountbotton = [orientation, self_learning, training_seminar];
@ -158,7 +158,7 @@ async function fecthFormdata(id: string) {
evaluate_expenct_level.value = res.data.result.assign_output.map(
(e: any) => ({
id: e.id,
labal: e.output_desc,
label: e.output_desc,
})
);
evaluate_ouptut.value = res.data.result.assign_output.map((e: any) => ({
@ -186,7 +186,7 @@ function savaForm() {
competency_level.value === 0 ||
learn_level.value === 0 ||
apply_level.value === 0 ||
success_level.value === 0 ||
// success_level.value === 0 ||
achievement_strength_desc.value === "" ||
lengthconduct.value !== 4 ||
lengthmoral_level.value !== 3 ||
@ -260,7 +260,7 @@ function putformData() {
competency_level: competency_level.value,
learn_level: learn_level.value,
apply_level: apply_level.value,
success_level: success_level.value,
// success_level: success_level.value,
achievement_other: achievement_other.value,
achievement_strength_desc: achievement_strength_desc.value,
achievement_improve_desc: achievement_improve_desc.value,
@ -809,7 +809,7 @@ onMounted(async () => {
</q-list>
</q-card>
<q-card class="text-top0 col-xs-12 col-sm-11 q-pa-sm q-pl-sm">
<!-- <q-card class="text-top0 col-xs-12 col-sm-11 q-pa-sm q-pl-sm">
<q-list dense>
<q-item
dense
@ -843,7 +843,7 @@ onMounted(async () => {
</q-item-section>
</q-item>
</q-list>
</q-card>
</q-card> -->
<q-card class="text-top0 col-xs-12 col-sm-11 q-pa-sm q-pl-sm">
<q-list dense>
@ -851,7 +851,7 @@ onMounted(async () => {
<q-item-section>
<q-item-label>
<q-icon name="mdi-label" color="grey-4" class="q-pr-sm" />
1.8
1.7
<q-checkbox
class="q-ml-sm"
dense

View file

@ -130,7 +130,7 @@ const variablesToWatch = [
competency_level,
learn_level,
apply_level,
success_level,
// success_level,
];
const ArrayCountbotton = [orientation, self_learning, training_seminar];
@ -157,7 +157,7 @@ function savaForm() {
competency_level.value === 0 ||
learn_level.value === 0 ||
apply_level.value === 0 ||
success_level.value === 0 ||
// success_level.value === 0 ||
achievement_strength_desc.value === "" ||
lengthconduct.value !== 4 ||
lengthmoral_level.value !== 3 ||
@ -242,7 +242,7 @@ async function fecthFormdata(id: string) {
evaluate_expenct_level.value = res.data.result.assign_output.map(
(e: any) => ({
id: e.id,
labal: e.output_desc,
label: e.output_desc,
})
);
evaluate_ouptut.value = res.data.result.assign_output.map((e: any) => ({
@ -267,7 +267,7 @@ function putformData() {
competency_level: competency_level.value,
learn_level: learn_level.value,
apply_level: apply_level.value,
success_level: success_level.value,
// success_level: success_level.value,
achievement_other: achievement_other.value,
achievement_strength_desc: achievement_strength_desc.value,
achievement_improve_desc: achievement_improve_desc.value,
@ -814,7 +814,7 @@ onMounted(async () => {
</q-list>
</q-card>
<q-card class="text-top0 col-xs-12 col-sm-11 q-pa-sm q-pl-sm">
<!-- <q-card class="text-top0 col-xs-12 col-sm-11 q-pa-sm q-pl-sm">
<q-list dense>
<q-item
dense
@ -848,7 +848,7 @@ onMounted(async () => {
</q-item-section>
</q-item>
</q-list>
</q-card>
</q-card> -->
<q-card class="text-top0 col-xs-12 col-sm-11 q-pa-sm q-pl-sm">
<q-list dense>
@ -856,7 +856,7 @@ onMounted(async () => {
<q-item-section>
<q-item-label>
<q-icon name="mdi-label" color="grey-4" class="q-pr-sm" />
1.8
1.7
<q-checkbox
class="q-ml-sm"
dense

View file

@ -170,7 +170,7 @@ async function fectFormfull() {
evaluate_expenct_level.value = await probationStore.assignOutput.map(
(e: any) => ({
id: e.id,
labal: e.output_desc,
label: e.output_desc,
})
);
evaluate_ouptut.value = await probationStore.assignOutput.map((e: any) => ({

View file

@ -372,7 +372,7 @@ onMounted(async () => {
<template>
<div class="toptitle text-dark col-12 row items-center">
รายการปรบระดบชนงานกจาง
รายการปรบระดบชนงาน-ายกจาง
</div>
<q-card flat bordered class="col-12 q-mt-sm">
<div class="row q-pa-md">

View file

@ -166,10 +166,10 @@ const commanderList = computed(() => {
//
const approveCheck = computed(() => {
const commanders = rows.value?.commanders;
return (
rows.value?.commanders?.every(
(commander) => commander.approveStatus === "APPROVE"
) ?? false
commanders?.every((commander) => commander.approveStatus === "APPROVE") ??
false
);
});
@ -1073,7 +1073,8 @@ onMounted(async () => {
rows &&
rows.approvers[0]?.profileId == keycloakId &&
rows.approvers[0]?.approveStatus == 'PENDING' &&
approveCheck
approveCheck &&
statusCheck === 'PENDING'
"
>
<q-btn

View file

@ -174,6 +174,8 @@ async function fetchData() {
checkInStatus: store.convertStatus(e.checkInStatus),
checkOutStatus: store.convertStatus(e.checkOutStatus),
}));
} else {
rows.value = [];
}
})
.catch((e) => {

View file

@ -36,6 +36,7 @@ const props = defineProps({
const avatar = ref<string>("");
const fullName = ref<string>("");
const position = ref<string>("");
const citizenId = ref<string>("");
const isLoading = ref<boolean>(true);
/** function เรียกข้อมูลส่วนตัว*/
@ -48,6 +49,7 @@ function fetchInformation() {
fullName.value = `${data.prefix}${data.firstName} ${data.lastName}`;
position.value = data.position;
citizenId.value = data.citizenId;
if (data.avatarName) {
await fetchProfile(data.id as string, data.avatarName);
@ -220,6 +222,7 @@ watch(
v-if="type === 'posSalary'"
v-model:profileId="profileId"
:employeeClass="employeeClass"
:citizenId="citizenId"
/>
<InfoDiscipline
v-if="type === 'discipline'"

View file

@ -26,6 +26,7 @@ const {
/** props*/
const profileId = defineModel<string>("profileId", { required: true });
const employeeClass = defineModel<string>("employeeClass", { required: true });
const citizenId = defineModel<string>("citizenId", { required: true });
const modalCommand = ref<boolean>(false);
const command = ref<string>("");
@ -470,6 +471,7 @@ onMounted(() => {
v-model:modal="modalCommand"
v-model:command="command"
v-model:commandId="commandId"
:citizen-id="citizenId"
/>
</template>

View file

@ -33,7 +33,9 @@ const {
showLoader,
hideLoader,
messageError,
success,
dialogRemove,
dialogConfirm,
onSearchDataTable,
} = useCounterMixin();
@ -298,6 +300,36 @@ function onSearchListPerson() {
);
}
function actActive(id: string, orgName: string) {
// confirm dialog active acting
dialogConfirm(
$q,
() => {
showLoader();
http
.post(config.API.activeActPosition(id), {
activeId: id,
})
.then(async () => {
success($q, "กำหนดรักษาการในตำแหน่งสำเร็จ");
await fetchOrganizationActive();
posmasterId.value = "";
storeActing.rootId = "";
rowPosition.value = [];
rowListPerson.value = [];
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
},
`ยืนยันการกำหนดรักษาการในตำแหน่ง`,
`คุณต้องการกำหนดรักษาการในตำแหน่งของ${orgName} ใช่หรือไม่?`
);
}
onMounted(async () => {
try {
showLoader();
@ -367,6 +399,19 @@ onMounted(async () => {
<div>
<div class="text-weight-medium">
{{ prop.node.orgTreeName }}
<q-icon
v-if="
prop.node.orgLevel === 0 &&
checkPermission($route)?.attrOwnership == 'OWNER'
"
name="mdi-content-save-edit"
color="blue"
@click.stop="
actActive(prop.node.orgTreeId, prop.node.orgTreeName)
"
size="xs"
><q-tooltip> นทกการกำหนดรกษาการ </q-tooltip></q-icon
>
</div>
<div class="text-weight-light text-grey-8">
{{ prop.node.orgCode == null ? null : prop.node.orgCode }}
@ -508,7 +553,7 @@ onMounted(async () => {
v-if="props.row.posNo && props.row.isDirector"
name="mdi-star"
color="primary"
><q-tooltip>อำนวยการ/วหน</q-tooltip>
><q-tooltip>อำนวยการ/วหน</q-tooltip>
</q-icon>
</div>
<div v-else>
@ -593,7 +638,14 @@ onMounted(async () => {
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-tr
:props="props"
:class="
props.row.statusReport === 'DONE'
? 'text-green'
: ''
"
>
<q-td
auto-width
v-if="

View file

@ -19,6 +19,7 @@ const { showLoader, hideLoader, messageError } = useCounterMixin();
const modal = defineModel<boolean>("modal", { required: true });
const command = defineModel<string>("command", { required: true });
const commandId = defineModel<string>("commandId", { required: true });
const citizenId = defineModel<string>("citizenId", { required: true });
const promises = ref<any>([]);
const tab = ref<string>("main"); //tab
@ -37,6 +38,7 @@ function closeDialog() {
modal.value = false;
command.value = "";
commandId.value = "";
citizenId.value = "";
}
/**
@ -88,13 +90,25 @@ async function downloadCover(type: string) {
*/
async function fetchDataCommand(type: string) {
let newType = type === "cover" ? "คำสั่ง" : "แนบท้าย";
const pathAPI =
type === "cover"
? config.API.fileByFile(
"ระบบออกคำสั่ง",
newType,
commandId.value,
newType
)
: config.API.subFileByFileName(
"ระบบออกคำสั่ง",
newType,
commandId.value,
citizenId.value,
newType
);
await http
.get(
config.API.fileByFile("ระบบออกคำสั่ง", newType, commandId.value, newType)
)
.get(pathAPI)
.then(async (res) => {
const data = res.data;
console.log(res);
if (type === "cover") {
dataCover.value = data;

View file

@ -43,7 +43,7 @@ async function fetchData() {
? "Live"
: data.isSignature === false
? "Digital"
: "";
: "Live";
isStatus.value = data.status;
isDraft.value = data.isDraft;
isSign.value = data.isSign;
@ -174,11 +174,12 @@ onMounted(async () => {
<q-item tag="label" v-ripple>
<q-item-section avatar>
<!-- :disable="isSignature !== null || store.readonly" -->
<q-radio
v-model="signaturetype"
val="Digital"
color="primary"
:disable="isSignature !== null || store.readonly"
disable
/>
</q-item-section>
<q-item-section>

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { onMounted, ref, computed } from "vue";
import { useQuasar } from "quasar";
import axios from "axios";
@ -42,12 +42,23 @@ const isAuthority = defineModel<boolean>("isAuthority", { required: true }); //
const isCheckAuthority = ref<boolean>(false); //
const isAttachment = defineModel<boolean>("isAttachment", { required: true }); //
const fileUploadOrder = ref<any>(null); //
const fileUploadTailer = ref<any>(null); //
// const fileUploadTailer = ref<any>(null); //
const fileOrder = ref<any>(null); //
const fileTailer = ref<any>(null); //
// const fileTailer = ref<any>(null); //
const isLoad = ref<boolean>(true); //
const modalPerView = ref<boolean>(false);
//
const attachmentList = ref<any[]>([]);
const attachmentFiles = ref<Record<number, any>>({});
const isFileTailer = computed(() => {
//
return (
attachmentList.value.length > 0 &&
attachmentList.value.every((person) => !!attachmentFiles.value[person.id])
);
});
/**
* งกนยนยนการสงใหอำนาจลงนามอน
@ -88,7 +99,9 @@ async function updateCheckboxAuthority(val: boolean) {
.put(config.API.command + `/pending-check/${commandId.value}`, {
sign: val,
})
.then(() => {})
.then(() => {
isAttachment.value && fetchLists();
})
.catch((err) => {
messageError($q, err);
})
@ -104,7 +117,7 @@ async function updateCheckboxAuthority(val: boolean) {
function onUploadFile(group: string) {
showLoader();
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
let file = group === "order" ? fileUploadOrder.value : fileUploadTailer.value;
// let file = group === "order" ? fileUploadOrder.value : fileUploadTailer.value;
const fileName = { fileName: type };
http
.post(config.API.file("ระบบออกคำสั่ง", type, commandId.value), {
@ -118,7 +131,11 @@ function onUploadFile(group: string) {
res.data[key]?.fileName !== ""
);
foundKey &&
(await uploadFileDoc(res.data[foundKey]?.uploadUrl, file, group));
(await uploadFileDoc(
res.data[foundKey]?.uploadUrl,
fileUploadOrder.value,
group
));
})
.catch((err) => {
messageError($q, err);
@ -134,7 +151,12 @@ function onUploadFile(group: string) {
* @param file ไฟลองการอปโหลด
* @param group ประเภพไฟล "คำสั่ง","แนบท้าย"
*/
async function uploadFileDoc(uploadUrl: string, file: any, group: string) {
async function uploadFileDoc(
uploadUrl: string,
file: any,
group: string,
id?: string
) {
const formData = new FormData();
formData.append("file", file);
showLoader();
@ -154,7 +176,11 @@ async function uploadFileDoc(uploadUrl: string, file: any, group: string) {
if (group === "order") {
fileUploadOrder.value = null;
} else {
fileUploadTailer.value = null;
attachmentList.value.forEach((e) => {
if (e.id === id) {
e.file = null;
}
});
}
hideLoader();
});
@ -167,15 +193,40 @@ async function uploadFileDoc(uploadUrl: string, file: any, group: string) {
async function fetchDoc(group: string) {
showLoader();
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
if (group === "order") {
await fetchDocOrder(type);
} else {
attachmentList.value.forEach(async (e) => {
await fetchDocTailer(type, e.id);
});
}
}
async function fetchDocOrder(type: string) {
await http
.get(config.API.file("ระบบออกคำสั่ง", type, commandId.value))
.then((res) => {
const data = res.data[0];
if (group === "order") {
fileOrder.value = data;
} else {
fileTailer.value = data;
}
fileOrder.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
async function fetchDocTailer(type: string, id: string) {
await http
.get(config.API.subFile("ระบบออกคำสั่ง", type, commandId.value, id))
.then((res) => {
const data = res.data[0];
attachmentList.value.forEach((e) => {
if (e.id === id) {
attachmentFiles.value[e.id] = data;
}
});
})
.catch((e) => {
messageError($q, e);
@ -190,18 +241,33 @@ const dataFile = ref<DataFileDownload>();
* ดาวนโหลดลงกไฟล
* @param fileName file name
*/
function downloadFile(file: any, group: string, isView: boolean = false) {
function downloadFile(
file: any,
group: string,
isView: boolean = false,
id: string
) {
let type = group === "order" ? "คำสั่ง" : "แนบท้าย";
const pathApi =
group === "order"
? config.API.fileByFile(
"ระบบออกคำสั่ง",
type,
commandId.value,
file.fileName
)
: config.API.subFileByFileName(
"ระบบออกคำสั่ง",
type,
commandId.value,
id,
file.fileName
);
showLoader();
http
.get(
config.API.fileByFile(
"ระบบออกคำสั่ง",
type,
commandId.value,
file.fileName
)
)
.get(pathApi)
.then((res) => {
const data = res.data;
dataFile.value = data;
@ -257,6 +323,49 @@ function onConfirmOrder() {
}
}
/** ดึงข้อมูล บุคคล */
async function fetchLists() {
await http
.get(config.API.commandAction(commandId.value, "tab2"))
.then(async (res) => {
const data = await res.data.result;
attachmentList.value = data.commandRecives.map((item: any) => ({
id: item.citizenId,
name: item.prefix + item.firstName + " " + item.lastName,
file: null,
}));
})
.catch((e) => {
messageError($q, e);
});
}
function onUploadFileTailer(id: string, file: any) {
const type = "แนบท้าย";
const fileName = { fileName: type };
http
.post(config.API.subFile("ระบบออกคำสั่ง", type, commandId.value, id), {
replace: true,
fileList: fileName,
})
.then(async (res) => {
const foundKey: string | undefined = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
foundKey &&
(await uploadFileDoc(res.data[foundKey]?.uploadUrl, file, type, id));
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
onMounted(async () => {
isCheckDraft.value = isDraft.value;
isCheckAuthority.value = isAuthority.value;
@ -264,6 +373,7 @@ onMounted(async () => {
isLoad.value = false;
let promises = [fetchDoc("order")];
if (isAttachment.value) {
await fetchLists();
promises.push(fetchDoc("tailer"));
}
await Promise.all(promises).finally(() => {
@ -318,141 +428,172 @@ onMounted(async () => {
/>
</div>
<div
class="row col-12 q-col-gutter-sm"
style="padding-left: 50px"
v-if="isAuthority"
>
<div class="row col-12" style="padding-left: 50px" v-if="isAuthority">
<div class="col-12 text-header">
ปโหลดเอกสารสแกนกลบเขาสระบบ
</div>
<div class="col-6">
<q-card
bordered
class="row col-12"
style="border: 1px solid #d6dee1"
>
<div
class="row items-center col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
<div class="col-6 q-col-gutter-sm">
<div class="col-6">
<q-card
bordered
class="row col-12"
style="border: 1px solid #d6dee1"
>
คำส
<q-space />
<q-btn
v-if="fileOrder"
rounded
flat
dense
color="primary"
icon="mdi-eye"
@click.prevent="downloadFile(fileOrder, 'order', true)"
<div
class="row items-center col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
>
<q-tooltip>ไฟลคำส</q-tooltip>
</q-btn>
<q-btn
v-if="fileOrder"
rounded
flat
dense
color="red"
icon="mdi-download"
@click.prevent="downloadFile(fileOrder, 'order')"
>
<q-tooltip>ดาวนโหลดไฟลคำส</q-tooltip>
</q-btn>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 q-pa-md" v-if="step === 2">
<q-file
outlined
dense
v-model="fileUploadOrder"
label="เลือกไฟล์คำสั่ง"
hide-bottom-space
accept=".pdf"
:readonly="store.readonly"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
คำส
<q-space />
<q-btn
v-if="fileOrder"
rounded
flat
dense
color="primary"
icon="mdi-eye"
@click.prevent="
downloadFile(fileOrder, 'order', true, '')
"
>
<q-tooltip>ไฟลคำส</q-tooltip>
</q-btn>
<q-btn
v-if="fileOrder"
rounded
flat
dense
color="red"
icon="mdi-download"
@click.prevent="
downloadFile(fileOrder, 'order', false, '')
"
>
<q-tooltip>ดาวนโหลดไฟลคำส</q-tooltip>
</q-btn>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 q-pa-md" v-if="step === 2">
<q-file
outlined
dense
v-model="fileUploadOrder"
label="เลือกไฟล์คำสั่ง"
hide-bottom-space
accept=".pdf"
:readonly="store.readonly"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
<template v-slot:after>
<q-btn
@click.prevent="onUploadFile('order')"
flat
round
icon="mdi-upload"
:color="fileUploadOrder == null ? 'grey-5' : 'blue-5'"
:disable="fileUploadOrder == null"
/>
</template>
</q-file>
</div>
</q-card>
</div>
<template v-slot:after>
<q-btn
@click.prevent="onUploadFile('order')"
flat
round
icon="mdi-upload"
:color="fileUploadOrder == null ? 'grey-5' : 'blue-5'"
:disable="fileUploadOrder == null"
/>
</template>
</q-file>
</div>
</q-card>
</div>
<div class="col-6" v-if="isAttachment">
<q-card
bordered
class="row col-12"
style="border: 1px solid #d6dee1"
>
<div
class="row items-center col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
<div class="col-6" v-if="isAttachment">
<q-card
bordered
class="row col-12"
style="border: 1px solid #d6dee1"
>
เอกสารแนบทาย
<q-space />
<q-btn
v-if="fileTailer"
rounded
flat
dense
color="primary"
icon="mdi-eye"
@click.prevent="downloadFile(fileTailer, 'tailer', true)"
<div
class="row items-center col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
>
<q-tooltip>ไฟลเอกสารแนบทาย</q-tooltip>
</q-btn>
<q-btn
v-if="fileTailer"
rounded
flat
dense
color="red"
icon="mdi-download"
@click.prevent="downloadFile(fileTailer, 'tailer')"
>
<q-tooltip>ดาวนโหลดไฟลแนบทาย</q-tooltip>
</q-btn>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 q-pa-md" v-if="step === 2">
<q-file
outlined
dense
v-model="fileUploadTailer"
label="เลือกไฟล์เอกสารแนบท้าย"
hide-bottom-space
accept=".pdf"
:readonly="store.readonly"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
<template v-slot:after>
<q-btn
@click.prevent="onUploadFile('tailer')"
flat
round
icon="mdi-upload"
:color="fileUploadTailer == null ? 'grey-5' : 'blue-5'"
:disable="fileUploadTailer == null"
/>
<q-tooltip>ปโหลดไฟลเอกสารแนบทาย</q-tooltip>
</template>
</q-file>
</div>
</q-card>
เอกสารแนบทาย
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md q-col-gutter-sm">
<div
v-for="(person, idx) in attachmentList"
:key="person.id"
class="col-12"
>
<q-card flat bordered class="q-pa-sm">
<div class="row items-center">
<div class="text-weight-medium">
{{ person.name }}
</div>
<q-space />
<q-btn
v-if="attachmentFiles[person.id]"
@click.prevent="
downloadFile(
attachmentFiles[person.id],
'tailer',
true,
person.id
)
"
flat
dense
color="primary"
icon="mdi-eye"
class="q-mr-xs"
>
<q-tooltip>ไฟลเอกสารแนบทาย</q-tooltip>
</q-btn>
<q-btn
v-if="attachmentFiles[person.id]"
@click.prevent="
downloadFile(
attachmentFiles[person.id],
'tailer',
false,
person.id
)
"
flat
dense
color="red"
icon="mdi-download"
>
<q-tooltip>ดาวนโหลดไฟลเอกสารแนบทาย</q-tooltip>
</q-btn>
</div>
<q-file
v-if="step === 2"
outlined
dense
v-model="person.file"
label="เลือกไฟล์เอกสารแนบท้าย"
hide-bottom-space
accept=".pdf"
:readonly="store.readonly"
class="full-width"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
<template v-slot:after>
<q-btn
@click.prevent="
onUploadFileTailer(person.id, person.file)
"
flat
round
icon="mdi-upload"
:color="person.file == null ? 'grey-5' : 'blue-5'"
:disable="person.file == null"
/>
<q-tooltip>ปโหลดไฟลเอกสารแนบทาย</q-tooltip>
</template>
</q-file>
</q-card>
</div>
</div>
</q-card>
</div>
</div>
</div>
@ -462,7 +603,7 @@ onMounted(async () => {
step === 2 &&
isAuthority &&
fileOrder &&
(!isAttachment || fileTailer)
(!isAttachment || isFileTailer)
"
>
<q-btn
@ -472,14 +613,14 @@ onMounted(async () => {
:color="
!isAuthority ||
fileOrder === null ||
(fileTailer === null && isAttachment)
(!isFileTailer && isAttachment)
? 'grey-5'
: 'public'
"
:disable="
!isAuthority ||
fileOrder === null ||
(fileTailer === null && isAttachment)
(!isFileTailer && isAttachment)
"
/>
</div>