แก้อัพไฟล์

This commit is contained in:
setthawutttty 2025-01-29 09:56:04 +07:00
parent 15c1c2038f
commit e92997302b
13 changed files with 448 additions and 108 deletions

View file

@ -15,6 +15,9 @@ import type {
DataOption,
DataOptionInsignia,
InsigniaOps,
InsigniasType,
InsigniasTypeSub,
ResFileData,
} from "@/modules/04_registryPerson/interface/index/Main";
import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/request/Insignia";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/Insignia";
@ -37,7 +40,9 @@ const {
onSearchDataTable,
} = mixin;
const fileUpload = ref<File>();
const isUpload = ref<boolean>(false);
const fileUpload = ref<File | null>(null);
const fileData = ref<ResFileData | null>(null);
const uploadUrl = ref<string>("");
/** props*/
const isLeave = defineModel<boolean>("isLeave", {
@ -76,8 +81,10 @@ const OpsFilter = ref<InsigniaOps>({
insigniaOptions: [],
});
const insigniaOptions = ref<any[]>([]);
const insigniaOptionsMain = ref<any[]>([]);
const insigniaOptions = ref<InsigniasType[]>([]);
const insigniaOptionsMain = ref<InsigniasType[]>([]);
const insigniaOptionsName = ref<InsigniasTypeSub[]>([]);
const insigniaOptionsNameMain = ref<InsigniasTypeSub[]>([]);
//
const Ops = ref<InsigniaOps>({
insigniaOptions: [],
@ -118,7 +125,7 @@ const columns = ref<QTableProps["columns"]>([
field: "insigniaId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => Ops.value.insigniaOptions.find((r) => r.id === v)?.name,
format: (v) => store.allNameInsignia.find((r) => r.id === v)?.name,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -305,7 +312,7 @@ const columnsHistory = ref<QTableProps["columns"]>([
field: "insigniaId",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
format: (v) => Ops.value.insigniaOptions.find((r) => r.id === v)?.name,
format: (v) => store.allNameInsignia.find((r) => r.id === v)?.name,
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
@ -487,18 +494,21 @@ async function fetchData() {
}
}
/** fetch ข้อมูลเครื่องราชอิสริยาภรณ์*/
async function fetchInsignia() {
/** ดึง */
async function getInsigniaActive() {
showLoader();
try {
const res = await http.get(config.API.insigniaOrg);
const data = res.data.result;
mapInsigniaOption(data);
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
http
.get(config.API.orgInsigniaActive())
.then((res) => {
const data = res.data.result;
mapInsigniaOption(data);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
@ -514,15 +524,18 @@ async function addEditData(editStatus: boolean = false) {
const method = editStatus ? "patch" : "post";
const reqBody: RequestItemsObject = {
...insigniaForm,
isUpload: !isEdit.value ? undefined : isUpload.value,
profileEmployeeId:
!editStatus && empType.value !== "" ? profileId.value : undefined,
profileId:
!editStatus && empType.value === "" ? profileId.value : undefined,
};
try {
await http[method](url, reqBody).then(async (res) => {
if (fileUpload.value && res.data.result) {
await uploadProfile(res.data.result);
if ((fileUpload.value && id.value) || res.data.result) {
await uploadProfile(id.value);
}
});
@ -574,19 +587,37 @@ async function uploadFileURL(uploadUrl: string, file: any) {
"Content-Type": file.type,
},
})
.then(() => {
fileUpload.value = undefined;
.then(async (res) => {
if (res.status == 200) {
await isUploadFn();
}
fileUpload.value = null;
})
.catch((err) => {
messageError($q, err);
});
}
async function isUploadFn() {
await http
.patch(config.API.profileNewInsignById(id.value, empType.value), {
isUpload: fileUpload.value ? true : false,
})
.then(async (res) => {})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* งกนโหลไฟลเอกสารหลกฐาน
* @param id รายการทองการโหลด
*/
async function onDownloadFile(id: string) {
async function onDownloadFile(id: string, isLoad: boolean = true) {
showLoader();
await http
.get(
@ -599,8 +630,11 @@ async function uploadFileURL(uploadUrl: string, file: any) {
)
)
.then(async (res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
const data = res.data;
fileData.value = data;
if (isLoad) {
window.open(data.downloadUrl, "_blank");
}
})
.catch((err) => {
messageError($q, err);
@ -631,13 +665,28 @@ function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) {
insigniaForm.refCommandDate = row.refCommandDate;
insigniaForm.refCommandNo = row.refCommandNo;
insigniaForm.note = row.note;
isUpload.value = row.isUpload;
const insigniaTypeFilter = insigniaOptionsMain.value.filter(
(r: any) => r.typeId === insigniaType.value
if (isUpload.value) {
onDownloadFile(row.id, false);
}
const list = store.insigniaTypeOpMain;
const insigniaTypeFilter = list.filter(
(r: InsigniasType) => r.id === insigniaType.value
);
if (insigniaTypeFilter.length > 0) {
OpsFilter.value.insigniaOptions = insigniaTypeFilter;
insigniaOptions.value = OpsFilter.value.insigniaOptions;
const type = insigniaTypeFilter;
const name = insigniaTypeFilter[0].insignias.map(
(item: InsigniasTypeSub) => ({
...item,
name: `${item.name} (${item.shortName})`,
})
);
insigniaOptions.value = type;
insigniaOptionsMain.value = type;
insigniaOptionsName.value = name;
insigniaOptionsNameMain.value = name;
}
} else {
clearData();
@ -687,29 +736,46 @@ function onSubmit() {
* @param refData type กำหนด ของ input นๆ
*/
function filterSelector(val: string, update: Function, refData: string) {
switch (refData) {
case "insigniaOptions":
update(() => {
insigniaOptions.value = OpsFilter.value.insigniaOptions.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
if (refData == "type") {
update(() => {
insigniaOptions.value = store.insigniaTypeOpMain.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
} else if (refData == "insigniaOptions") {
update(() => {
insigniaOptionsName.value = insigniaOptionsNameMain.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
}
}
/** ค้นหาลำดับชั้น*/
function insigniaTypeSelection(check: boolean) {
function insigniaTypeSelection(check: boolean, id: string) {
if (check) {
insigniaForm.insigniaId = "";
}
const insigniaTypeFilter = insigniaOptionsMain.value.filter(
(r: any) => r.typeId === insigniaType.value
);
if (insigniaTypeFilter.length > 0) {
OpsFilter.value.insigniaOptions = insigniaTypeFilter;
const data = store.insigniaTypeOpMain.find(
(item: InsigniasType) => item.id == id
);
if (data) {
const listData = data.insignias.map((item: InsigniasTypeSub) => ({
id: item.id,
createdAt: item.createdAt,
createdUserId: item.createdUserId,
lastUpdatedAt: item.lastUpdatedAt,
lastUpdateUserId: item.lastUpdateUserId,
createdFullName: item.createdFullName,
lastUpdateFullName: item.lastUpdateFullName,
name: `${item.name} (${item.shortName})`,
shortName: item.shortName,
level: item.level,
isActive: item.isActive,
note: item.note,
insigniaTypeId: item.insigniaTypeId,
}));
insigniaOptionsNameMain.value = listData;
}
}
}
@ -729,7 +795,9 @@ function clearData() {
insigniaForm.refCommandNo = "";
insigniaForm.refCommandDate = null;
insigniaForm.note = "";
fileUpload.value = undefined;
fileUpload.value = null;
isUpload.value = false;
fileData.value = null;
}
function serchDataTable() {
@ -751,10 +819,9 @@ function serchDataTableHistory() {
/** ทำงานเมื่อ Components ถูกเรียกใช้งาน*/
onMounted(async () => {
await fetchData();
store.insigniaOption.length === 0 ? await fetchInsignia() : "";
Ops.value.insigniaOptions = store.insigniaOption;
store.insigniaTypeOpMain.length === 0 ? await getInsigniaActive() : "";
insigniaOptionsMain.value = store.insigniaOption;
insigniaOptionsMain.value = store.insigniaTypeOpMain;
insigniaOptions.value = store.insigniaOption;
});
</script>
@ -1064,12 +1131,12 @@ onMounted(async () => {
v-model="insigniaType"
class="inputgreen"
:label="`${'ลำดับชั้น'}`"
:options="store.insigniaTypeOp"
:options="insigniaOptions"
:rules="[(val:string) => !!val || `${'กรุณาเลือกลำดับชั้น'}`]"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'insigniaOptions'
doneFn:Function) => filterSelector(inputValue, doneFn,'type'
) "
@update:modelValue="insigniaTypeSelection(true)"
@update:modelValue="(val:any)=>insigniaTypeSelection(true,val)"
>
<template v-slot:no-option>
<q-item>
@ -1098,7 +1165,7 @@ onMounted(async () => {
v-model="insigniaForm.insigniaId"
class="inputgreen"
:label="`${'ชื่อเครื่องราชฯ'}`"
:options="insigniaOptions"
:options="insigniaOptionsName"
:rules="[(val:string) => !!val || `${'กรุณาเลือกชื่อเครื่องราชฯ'}`]"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn,'insigniaOptions'
@ -1288,6 +1355,7 @@ onMounted(async () => {
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="row">
<q-uploader
v-if="!isUpload"
color="gray"
type="file"
flat
@ -1360,6 +1428,31 @@ onMounted(async () => {
</div>
</template>
</q-uploader>
<q-list bordered dense separator v-else class="full-width">
<q-item>
<q-item-section> {{ fileData?.fileName }}</q-item-section>
<q-item-section avatar>
<div class="row">
<q-btn
flat
round
color="primary"
icon="mdi-download"
@click="onDownloadFile(id)"
/>
<q-btn
flat
round
color="grey"
icon="close"
@click="isUpload = false"
/>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>

View file

@ -11,7 +11,10 @@ import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/request/DeclarationHonor";
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
import type {
DataOption,
ResFileData,
} from "@/modules/04_registryPerson/interface/index/Main";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/DeclarationHonor";
import DialogHeader from "@/components/DialogHeader.vue";
@ -34,13 +37,14 @@ const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const isUpload = ref<boolean>(false);
const fileUpload = ref<File | null>(null);
const fileData = ref<ResFileData | null>(null);
/** props*/
const isLeave = defineModel<boolean>("isLeave", {
required: true,
});
const fileUpload = ref<File>();
const uploadUrl = ref<string>("");
const typeOp = ref<DataOption[]>([
@ -282,6 +286,7 @@ async function addEditData(editStatus: boolean = false) {
const method = editStatus ? "patch" : "post";
const reqBody: RequestItemsObject = {
...declHonorForm,
isUpload: !isEdit.value ? undefined : isUpload.value,
profileEmployeeId:
!editStatus && empType.value !== "" ? profileId.value : undefined,
profileId:
@ -295,8 +300,8 @@ async function addEditData(editStatus: boolean = false) {
try {
await http[method](url, reqBody).then(async (res) => {
if (fileUpload.value && res.data.result) {
await uploadProfile(res.data.result);
if ((fileUpload.value && id.value) || res.data.result) {
await uploadProfile(id.value);
}
});
await fetchData();
@ -352,19 +357,38 @@ async function uploadFileURL(uploadUrl: string, file: any) {
"Content-Type": file.type,
},
})
.then(() => {
fileUpload.value = undefined;
.then(async (res) => {
if (res.status == 200) {
await isUploadFn();
}
fileUpload.value = null;
})
.catch((err) => {
messageError($q, err);
});
}
async function isUploadFn() {
await http
.patch(config.API.profileNewHonorById(id.value, empType.value), {
isUpload: fileUpload.value ? true : false,
isDate: declHonorForm.isDate === "true" ? true : false,
})
.then(async (res) => {})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* งกนโหลไฟลเอกสารหลกฐาน
* @param id รายการทองการโหลด
*/
async function onDownloadFile(id: string) {
async function onDownloadFile(id: string, isLoad: boolean = true) {
showLoader();
await http
.get(
@ -377,8 +401,11 @@ async function onDownloadFile(id: string) {
)
)
.then(async (res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
const data = res.data;
fileData.value = data;
if (isLoad) {
window.open(data.downloadUrl, "_blank");
}
})
.catch((err) => {
messageError($q, err);
@ -404,6 +431,12 @@ function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) {
declHonorForm.refCommandDate = row.refCommandDate;
declHonorForm.type = row.type;
declHonorForm.isDate = row.isDate ? "true" : "false";
isUpload.value = row.isUpload;
if (isUpload.value) {
onDownloadFile(row.id, false);
}
} else {
clearData();
}
@ -456,6 +489,10 @@ function clearData() {
declHonorForm.type = "";
declHonorForm.refCommandDate = null;
declHonorForm.isDate = "false";
fileUpload.value = null;
isUpload.value = false;
fileData.value = null;
}
function serchDataTable() {
@ -890,6 +927,7 @@ onMounted(() => {
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="row">
<q-uploader
v-if="!isUpload"
color="gray"
type="file"
flat
@ -962,6 +1000,31 @@ onMounted(() => {
</div>
</template>
</q-uploader>
<q-list bordered dense separator v-else class="full-width">
<q-item>
<q-item-section> {{ fileData?.fileName }}</q-item-section>
<q-item-section avatar>
<div class="row">
<q-btn
flat
round
color="primary"
icon="mdi-download"
@click="onDownloadFile(id)"
/>
<q-btn
flat
round
color="grey"
icon="close"
@click="isUpload = false"
/>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>

View file

@ -10,6 +10,7 @@ import http from "@/plugins/http";
import config from "@/app.config";
import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/index/performSpecialWork";
import type { ResFileData } from "@/modules/04_registryPerson/interface/index/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/04_PerformSpecialWorkHistory.vue";
@ -33,8 +34,13 @@ const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const fileUpload = ref<File>();
const uploadUrl = ref<string>("");
const isUpload = ref<boolean>(false);
const fileUpload = ref<File | null>(null);
const fileData = ref<ResFileData | null>(null);
/** props*/
const isLeave = defineModel<boolean>("isLeave", {
required: true,
@ -51,7 +57,8 @@ const dutyData = reactive<RequestItemsObject>({
detail: "", //
reference: "", //
refCommandNo: "", //
refCommandDate: null, //' ()'
refCommandDate: null, //' ()',
isUpload: false,
});
const mode = ref<string>("table"); // Table card
@ -158,6 +165,12 @@ function openDialogEdit(props: RequestItemsObject) {
dutyData.reference = props.reference;
dutyData.refCommandNo = props.refCommandNo;
dutyData.refCommandDate = props.refCommandDate;
isUpload.value = props.isUpload;
if (isUpload.value && props.id) {
onDownloadFile(props.id, false);
}
}
/**
@ -179,7 +192,11 @@ function closeDialog() {
dutyData.reference = "";
dutyData.refCommandNo = "";
dutyData.refCommandDate = null;
fileUpload.value = undefined;
fileUpload.value = null;
fileUpload.value = null;
isUpload.value = false;
fileData.value = null;
}
/** fetch ข้อมูลรายการพิเศษ*/
@ -211,6 +228,7 @@ function addData() {
reference: dutyData.reference,
refCommandNo: dutyData.refCommandNo,
refCommandDate: dutyData.refCommandDate,
isUpload: !edit.value ? undefined : isUpload.value,
};
http
.post(config.API.profileNewDuty(empType.value), body)
@ -239,8 +257,8 @@ function editData(idData: string) {
profileId: undefined,
})
.then(async (res) => {
if (fileUpload.value && res.data.result) {
await uploadProfile(res.data.result);
if (fileUpload.value && id.value) {
await uploadProfile(id.value);
}
await fetchData(profileId.value);
await success($q, "บันทึกข้อมูลสำเร็จ");
@ -297,19 +315,37 @@ async function uploadFileURL(uploadUrl: string, file: any) {
"Content-Type": file.type,
},
})
.then(() => {
fileUpload.value = undefined;
.then(async (res) => {
if (res.status == 200) {
await isUploadFn();
}
fileUpload.value = null;
})
.catch((err) => {
messageError($q, err);
});
}
async function isUploadFn() {
await http
.patch(config.API.profileNewDutyByDutyId(id.value, empType.value), {
isUpload: fileUpload.value ? true : false,
})
.then(async (res) => {})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* งกนโหลไฟลเอกสารหลกฐาน
* @param id รายการทองการโหลด
*/
async function onDownloadFile(id: string) {
async function onDownloadFile(id: string, isLoad: boolean = true) {
showLoader();
await http
.get(
@ -322,8 +358,11 @@ async function onDownloadFile(id: string) {
)
)
.then(async (res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
const data = res.data;
fileData.value = data;
if (isLoad) {
window.open(data.downloadUrl, "_blank");
}
})
.catch((err) => {
messageError($q, err);
@ -756,6 +795,7 @@ onMounted(() => {
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="row">
<q-uploader
v-if="!isUpload"
color="gray"
type="file"
flat
@ -828,6 +868,31 @@ onMounted(() => {
</div>
</template>
</q-uploader>
<q-list bordered dense separator v-else class="full-width">
<q-item>
<q-item-section> {{ fileData?.fileName }}</q-item-section>
<q-item-section avatar>
<div class="row">
<q-btn
flat
round
color="primary"
icon="mdi-download"
@click="onDownloadFile(id)"
/>
<q-btn
flat
round
color="grey"
icon="close"
@click="isUpload = false"
/>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>

View file

@ -43,10 +43,10 @@ async function getData() {
showLoader();
await http
.get(
config.API.file("ระบบทะเบียนประวัติ", "เอกสาร ก.พ.7", profileId.value)
config.API.file("ระบบทะเบียนประวัติ", "เอกสารหลักฐานเพิ่มเติม", profileId.value)
)
.then((res) => {
console.log("ระบบทะเบียนประวัติ", "เอกสาร ก.พ.7", profileId.value)
console.log("ระบบทะเบียนประวัติ", "เอกสารหลักฐานเพิ่มเติม", profileId.value)
fileList.value = res.data;
})
.catch((e) => {
@ -73,7 +73,7 @@ function clickUpload(file: any) {
.post(
config.API.file(
"ระบบทะเบียนประวัติ",
"เอกสาร ก.พ.7",
"เอกสารหลักฐานเพิ่มเติม",
profileId.value
),
{
@ -135,7 +135,7 @@ function downloadFile(fileName: string) {
.get(
config.API.fileByFile(
"ระบบทะเบียนประวัติ",
"เอกสาร ก.พ.7",
"เอกสารหลักฐานเพิ่มเติม",
profileId.value,
fileName
)
@ -163,7 +163,7 @@ function deleteFile(fileName: string) {
.delete(
config.API.fileByFile(
"ระบบทะเบียนประวัติ",
"เอกสาร ก.พ.7",
"เอกสารหลักฐานเพิ่มเติม",
profileId.value,
fileName
)

View file

@ -13,6 +13,7 @@ import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar";
import type { RequestItemsObject } from "@/modules/04_registryPerson/interface/request/SpecialSkill";
import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/SpecialSkill";
import type { ResFileData } from "@/modules/04_registryPerson/interface/index/Main";
import dialogHeader from "@/components/DialogHeader.vue";
@ -35,9 +36,12 @@ const profileId = ref<string>(
route.params.id ? route.params.id.toString() : ""
);
const empType = ref<string>(pathRegistryEmp(route.name?.toString() ?? ""));
const fileUpload = ref<File>();
const uploadUrl = ref<string>("");
const uploadUrl = ref<string>("");
const isUpload = ref<boolean>(false);
const fileUpload = ref<File | null>(null);
const fileData = ref<ResFileData | null>(null);
const isEdit = ref<boolean>(false);
const mode = ref<string>("table"); // Table card
/**
* props
@ -227,7 +231,11 @@ function clearForm() {
specialSkill.field = "";
specialSkill.reference = "";
specialSkill.remark = "";
fileUpload.value = undefined;
isEdit.value = false;
fileUpload.value = null;
isUpload.value = false;
fileData.value = null;
}
/**
@ -242,6 +250,12 @@ function editForm(row: any) {
specialSkill.reference = row.reference;
specialSkill.remark = row.remark;
dialog.value = true;
isEdit.value = true;
isUpload.value = row.isUpload;
if (isUpload.value) {
onDownloadFile(row.id, false);
}
}
/** function fetch ข้อมูลความสามรรถพิเศษ*/
@ -291,6 +305,7 @@ async function addData() {
dateEnd: null,
profileId: empType.value === "" ? id.value : undefined,
profileEmployeeId: empType.value !== "" ? id.value : undefined,
isUpload: !isEdit.value ? undefined : isUpload.value,
})
.then(async (res) => {
if (fileUpload.value && res.data.result) {
@ -322,8 +337,8 @@ async function editData(idData: string) {
profileId: undefined,
})
.then(async (res) => {
if (fileUpload.value && res.data.result) {
await uploadProfile(res.data.result);
if (fileUpload.value && id.value) {
await uploadProfile(id.value);
}
await fetchData(id.value);
await success($q, "บันทึกข้อมูลสำเร็จ");
@ -380,19 +395,37 @@ async function uploadFileURL(uploadUrl: string, file: any) {
"Content-Type": file.type,
},
})
.then(() => {
fileUpload.value = undefined;
.then(async (res) => {
if (res.status == 200) {
await isUploadFn();
}
fileUpload.value = null;
})
.catch((err) => {
messageError($q, err);
});
}
async function isUploadFn() {
await http
.patch(config.API.profileNewAbilityByAbilityId(editId.value, empType.value), {
isUpload: fileUpload.value ? true : false,
})
.then(async (res) => {})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
/**
* งกนโหลไฟลเอกสารหลกฐาน
* @param id รายการทองการโหลด
*/
async function onDownloadFile(id: string) {
async function onDownloadFile(id: string, isLoad: boolean = true) {
showLoader();
await http
.get(
@ -405,8 +438,11 @@ async function onDownloadFile(id: string) {
)
)
.then(async (res) => {
const data = res.data.downloadUrl;
window.open(data, "_blank");
const data = res.data;
fileData.value = data;
if (isLoad) {
window.open(data.downloadUrl, "_blank");
}
})
.catch((err) => {
messageError($q, err);
@ -419,6 +455,7 @@ async function onDownloadFile(id: string) {
/** function ปิด popup ข้อมูลความสามารถพิเศษ*/
function closeDialog() {
dialog.value = false;
clearForm();
}
/** function ปิด popup รายการประวัติ*/
@ -590,7 +627,7 @@ onMounted(() => {
dense
round
icon="mdi-file-document-outline"
@click="onDownloadFile(props.row.id)"
@click="onDownloadFile(props.row.profileId)"
>
<q-tooltip>ดาวนโหลด</q-tooltip>
</q-btn>
@ -713,6 +750,7 @@ onMounted(() => {
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="row">
<q-uploader
v-if="!isUpload"
color="gray"
type="file"
flat
@ -785,6 +823,31 @@ onMounted(() => {
</div>
</template>
</q-uploader>
<q-list bordered dense separator v-else class="full-width">
<q-item>
<q-item-section> {{ fileData?.fileName }}</q-item-section>
<q-item-section avatar>
<div class="row">
<q-btn
flat
round
color="primary"
icon="mdi-download"
@click="onDownloadFile(id)"
/>
<q-btn
flat
round
color="grey"
icon="close"
@click="isUpload = false"
/>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>

View file

@ -83,6 +83,41 @@ interface Request {
topic: string;
}
interface InsigniasType {
id: string;
createdAt: Date;
createdUserId: string;
lastUpdatedAt: Date;
lastUpdateUserId: string;
createdFullName: string;
lastUpdateFullName: string;
name: string;
isActive: boolean;
insignias: InsigniasTypeSub[];
}
interface InsigniasTypeSub {
id:string;
createdAt:Date;
createdUserId:string;
lastUpdatedAt:Date;
lastUpdateUserId:string;
createdFullName:string;
lastUpdateFullName:string;
name:string;
shortName:string;
level:string;
isActive:string;
note:string;
insigniaTypeId:string;
}
interface ResFileData {
downloadUrl: string;
fileName: string;
path: string;
pathname: string;
}
export type {
Pagination,
DataOption,
@ -97,4 +132,8 @@ export type {
DataOptionEducation,
DataOptionEducationLevel,
Request,
InsigniasType,
InsigniasTypeSub,
ResFileData
};

View file

@ -21,6 +21,7 @@ interface RequestItemsObject {
reference: string;
refCommandNo: string;
refCommandDate: Date | null;
isUpload: boolean;
}
interface MyObjectRef {

View file

@ -8,6 +8,7 @@ interface RequestItemsObject {
refCommandNo: string;
type: string;
isDate: boolean | string;
isUpload?: boolean|undefined;
}
export type { RequestItemsObject };

View file

@ -14,6 +14,7 @@ interface RequestItemsObject {
refCommandNo: string;
note: string;
profileEmployeeId?: string | null;
isUpload?: boolean | undefined;
}
export type { RequestItemsObject };

View file

@ -14,6 +14,7 @@ interface ResponseObject {
profileId: string;
type: string;
refCommandDate: Date;
isUpload: boolean;
refCommandNo: string;
}

View file

@ -20,6 +20,7 @@ interface ResponseObject {
volumeNo: string;
refCommandDate: Date | null;
refCommandNo: string;
isUpload: boolean;
note: string;
}

View file

@ -1,30 +1,37 @@
import { ref, computed } from "vue";
import { defineStore } from "pinia";
import type { DataOptionInsignia,DataOption } from "@/modules/04_registryPerson/interface/index/Main";
import type {
DataOptionInsignia,
DataOption,
InsigniasType,
InsigniasTypeSub,
} from "@/modules/04_registryPerson/interface/index/Main";
import type { ResponseObject as Insignia } from "@/modules/07_insignia/interface/response/Main";
export const useInsigniaDataStore = defineStore("insigniaDataStore", () => {
const insigniaOption = ref<DataOptionInsignia[]>([]);
const insigniaTypeOp = ref<DataOption[]>([]);
const insigniaTypeOpMain = ref<DataOption[]>([]);
const insigniaOption = ref<InsigniasType[]>([]);
function mapInsigniaOption(resData: any) {
insigniaTypeOp.value = Array.from(
new Map(
resData.map((item:any) => [item.insigniaTypeName, { id: item.insigniaTypeId, name: item.insigniaTypeName }])
).values()
) as DataOption[];
const insigniaTypeOp = ref<InsigniasType[]>([]);
const insigniaTypeOpMain = ref<InsigniasType[]>([]);
const allNameInsignia = ref<InsigniasTypeSub[]>([]);
insigniaOption.value = [];
resData.map((r: Insignia) => {
insigniaOption.value.push({
id: r.id.toString(),
name: r.name.toString() + ` (${r.shortName})`,
typeId: r.insigniaTypeId.toString(),
typeName: r.insigniaTypeName.toString(),
});
});
function mapInsigniaOption(resData: InsigniasType[]) {
insigniaTypeOpMain.value = resData;
insigniaTypeOp.value = resData;
allNameInsignia.value = resData
.flatMap((item: InsigniasType) => item.insignias)
.map((i: InsigniasTypeSub) => ({
...i,
name: `${i.name} (${i.shortName})`,
}));
}
return { insigniaOption, mapInsigniaOption,insigniaTypeOp };
return {
insigniaOption,
mapInsigniaOption,
insigniaTypeOp,
insigniaTypeOpMain,
allNameInsignia,
};
});