ทะเบียนประวัติ ==> uploadFile
This commit is contained in:
parent
a8f0a486e3
commit
70373acacd
11 changed files with 656 additions and 42 deletions
|
|
@ -1,5 +1,11 @@
|
|||
import { defineStore } from "pinia";
|
||||
import { ref, reactive, computed } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import axios from "axios";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
|
||||
|
|
@ -9,6 +15,9 @@ import type {
|
|||
} from "@/modules/04_registryPerson/interface/response/Main";
|
||||
import type { FormFilter } from "@/modules/04_registryPerson/interface/request/Main";
|
||||
|
||||
const $q = useQuasar();
|
||||
const { messageError } = useCounterMixin();
|
||||
|
||||
export const useRegistryNewDataStore = defineStore("registryNew", () => {
|
||||
const route = useRoute();
|
||||
const routerName = ref<any>();
|
||||
|
|
@ -151,6 +160,82 @@ export const useRegistryNewDataStore = defineStore("registryNew", () => {
|
|||
{ id: "ASC", name: "เรียงตามวันที่บรรจุแต่งตั้ง (เก่า-ล่าสุด)" },
|
||||
]);
|
||||
|
||||
/**
|
||||
* ฟังก์ชันสร้าง Path อัพโหลดไฟล์
|
||||
* @param group กลุ่มไฟล์
|
||||
* @param profileId id
|
||||
* @param id subId
|
||||
* @returns Path อัพโหลดไฟล์
|
||||
*/
|
||||
async function createPathUploadFlie(
|
||||
group: string,
|
||||
profileId: string,
|
||||
id: string
|
||||
) {
|
||||
try {
|
||||
const res = await http.post(
|
||||
config.API.subFile("ทะเบียนประวัติ", group, profileId, id),
|
||||
{
|
||||
replace: true,
|
||||
fileList: [
|
||||
{
|
||||
fileName: "เอกสารหลักฐาน",
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
return res.data["เอกสารหลักฐาน"].uploadUrl;
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันเรียก Path อัพโหลดไฟล์
|
||||
* @param group กลุ่มไฟล์
|
||||
* @param profileId id
|
||||
* @param id subId
|
||||
* @returns ข้อมูลไฟล์
|
||||
*/
|
||||
async function getPathUploadFlie(
|
||||
group: string,
|
||||
profileId: string,
|
||||
id: string
|
||||
) {
|
||||
try {
|
||||
const res = await http.get(
|
||||
config.API.subFileByFileName(
|
||||
"ทะเบียนประวัติ",
|
||||
group,
|
||||
profileId,
|
||||
id,
|
||||
"เอกสารหลักฐาน"
|
||||
)
|
||||
);
|
||||
return res.data;
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันอัพโหลดไฟล์
|
||||
* @param uploadUrl Path อัพโหลดไฟล์
|
||||
* @param file ไฟล์
|
||||
*/
|
||||
async function uploadFile(uploadUrl: string, file: any) {
|
||||
try {
|
||||
await axios.put(uploadUrl, file, {
|
||||
headers: {
|
||||
"Content-Type": file.type,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
messageError($q, err);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
fetchType,
|
||||
fetchLevel,
|
||||
|
|
@ -172,5 +257,8 @@ export const useRegistryNewDataStore = defineStore("registryNew", () => {
|
|||
citizenId,
|
||||
displayOrderOps,
|
||||
routerName,
|
||||
createPathUploadFlie,
|
||||
getPathUploadFlie,
|
||||
uploadFile,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue