fix file ทะเบียรประวัติช่วยราชการ
This commit is contained in:
parent
a9651ef0f5
commit
94f51b0eb6
3 changed files with 78 additions and 21 deletions
|
|
@ -11,7 +11,10 @@ import config from "@/app.config";
|
||||||
|
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
import type { DatAssistance } from "@/modules/04_registryPerson/interface/request/Government";
|
import type { DatAssistance } from "@/modules/04_registryPerson/interface/request/Government";
|
||||||
import type { ResAssistanceData } from "@/modules/04_registryPerson/interface/response/Government";
|
import type {
|
||||||
|
ResAssistanceData,
|
||||||
|
ResFileData,
|
||||||
|
} from "@/modules/04_registryPerson/interface/response/Government";
|
||||||
|
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernmentHistory.vue";
|
import DialogHistory from "@/modules/04_registryPerson/components/detail/GovernmentInformation/06_HelpGovernmentHistory.vue";
|
||||||
|
|
@ -104,6 +107,8 @@ const visibleColumns = ref<String[]>([
|
||||||
|
|
||||||
/** Dialog*/
|
/** Dialog*/
|
||||||
const isStatusEdit = ref<boolean>(false);
|
const isStatusEdit = ref<boolean>(false);
|
||||||
|
const isUpload = ref<boolean>(false);
|
||||||
|
|
||||||
const rowId = ref<string>("");
|
const rowId = ref<string>("");
|
||||||
const modal = ref<boolean>(false);
|
const modal = ref<boolean>(false);
|
||||||
const modalHistory = ref<boolean>(false);
|
const modalHistory = ref<boolean>(false);
|
||||||
|
|
@ -114,9 +119,10 @@ const formData = reactive<DatAssistance>({
|
||||||
dateEnd: null,
|
dateEnd: null,
|
||||||
commandNo: "",
|
commandNo: "",
|
||||||
document: "",
|
document: "",
|
||||||
isUpload: false,
|
// isUpload: false,
|
||||||
});
|
});
|
||||||
const fileUpload = ref<File>();
|
const fileUpload = ref<File>();
|
||||||
|
const fileData = ref<ResFileData>();
|
||||||
|
|
||||||
/** ฟังก์ค้นหาข้อมูลรายการ */
|
/** ฟังก์ค้นหาข้อมูลรายการ */
|
||||||
function serchDataTable() {
|
function serchDataTable() {
|
||||||
|
|
@ -149,15 +155,16 @@ function onSubmit() {
|
||||||
const body = {
|
const body = {
|
||||||
...formData,
|
...formData,
|
||||||
profileId: isStatusEdit.value ? undefined : profileId.value,
|
profileId: isStatusEdit.value ? undefined : profileId.value,
|
||||||
isUpload: isStatusEdit.value
|
isUpload: !isStatusEdit.value ? undefined : isUpload.value,
|
||||||
? formData.isUpload
|
// isUpload: isStatusEdit.value
|
||||||
? formData.isUpload
|
// ? formData.isUpload
|
||||||
: fileUpload.value
|
// ? formData.isUpload
|
||||||
? true
|
// : fileUpload.value
|
||||||
: false
|
// ? true
|
||||||
: fileUpload.value
|
// : false
|
||||||
? true
|
// : fileUpload.value
|
||||||
: false,
|
// ? true
|
||||||
|
// : false,
|
||||||
};
|
};
|
||||||
const method = isStatusEdit.value ? "patch" : "post";
|
const method = isStatusEdit.value ? "patch" : "post";
|
||||||
await http[method](
|
await http[method](
|
||||||
|
|
@ -209,7 +216,7 @@ async function uploadProfile(id: string) {
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const uploadUrl = res.data["เอกสารหลักฐาน"].uploadUrl;
|
const uploadUrl = res.data["เอกสารหลักฐาน"].uploadUrl;
|
||||||
await uploadFileURL(uploadUrl, fileUpload.value);
|
await uploadFileURL(uploadUrl, fileUpload.value, id);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -221,16 +228,27 @@ async function uploadProfile(id: string) {
|
||||||
* @param uploadUrl Path อัปโหลดไฟล์
|
* @param uploadUrl Path อัปโหลดไฟล์
|
||||||
* @param file ไฟล์เอกสาร
|
* @param file ไฟล์เอกสาร
|
||||||
*/
|
*/
|
||||||
async function uploadFileURL(uploadUrl: string, file: any) {
|
async function uploadFileURL(uploadUrl: string, file: any, id: string) {
|
||||||
await axios
|
await axios
|
||||||
.put(uploadUrl, file, {
|
.put(uploadUrl, file, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": file.type,
|
"Content-Type": file.type,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
|
await updateIsUpload(id, true);
|
||||||
fileUpload.value = undefined;
|
fileUpload.value = undefined;
|
||||||
})
|
})
|
||||||
|
.catch(async (err) => {
|
||||||
|
await updateIsUpload(id, false);
|
||||||
|
messageError($q, err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateIsUpload(id: string, val: boolean) {
|
||||||
|
await http
|
||||||
|
.patch(config.API.profileAssistance(empType.value, id), { isUpload: val })
|
||||||
|
.then(async (res) => {})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
});
|
});
|
||||||
|
|
@ -240,7 +258,7 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
* ฟังก์ชันโหลไฟลเอกสารหลักฐาน
|
* ฟังก์ชันโหลไฟลเอกสารหลักฐาน
|
||||||
* @param id รายการที่ต้องการโหลด
|
* @param id รายการที่ต้องการโหลด
|
||||||
*/
|
*/
|
||||||
async function onDownloadFile(id: string) {
|
async function onDownloadFile(id: string, isLoad: boolean = true) {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(
|
.get(
|
||||||
|
|
@ -253,8 +271,11 @@ async function onDownloadFile(id: string) {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const data = res.data.downloadUrl;
|
const data = res.data;
|
||||||
window.open(data, "_blank");
|
fileData.value = data;
|
||||||
|
if (isLoad) {
|
||||||
|
window.open(data.downloadUrl, "_blank");
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -273,7 +294,10 @@ function openEditDialog(data: ResAssistanceData) {
|
||||||
formData.dateEnd = data.dateEnd;
|
formData.dateEnd = data.dateEnd;
|
||||||
formData.commandNo = data.commandNo;
|
formData.commandNo = data.commandNo;
|
||||||
formData.document = data.document;
|
formData.document = data.document;
|
||||||
formData.isUpload = data.isUpload;
|
isUpload.value = data.isUpload;
|
||||||
|
if (isUpload.value) {
|
||||||
|
onDownloadFile(data.id, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showHistoryDialog(id: string) {
|
function showHistoryDialog(id: string) {
|
||||||
|
|
@ -290,7 +314,7 @@ function closeDialogForm() {
|
||||||
formData.dateEnd = null;
|
formData.dateEnd = null;
|
||||||
formData.commandNo = "";
|
formData.commandNo = "";
|
||||||
formData.document = "";
|
formData.document = "";
|
||||||
formData.isUpload = false;
|
isUpload.value = false;
|
||||||
fileUpload.value = undefined;
|
fileUpload.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -643,6 +667,7 @@ onMounted(() => {
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12 col-sm-12 col-md-12">
|
<div class="col-xs-12 col-sm-12 col-md-12">
|
||||||
<q-uploader
|
<q-uploader
|
||||||
|
v-if="!isUpload"
|
||||||
color="gray"
|
color="gray"
|
||||||
type="file"
|
type="file"
|
||||||
flat
|
flat
|
||||||
|
|
@ -715,6 +740,31 @@ onMounted(() => {
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</q-uploader>
|
</q-uploader>
|
||||||
|
|
||||||
|
<q-list bordered dense separator v-else>
|
||||||
|
<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(rowId)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
color="grey"
|
||||||
|
icon="close"
|
||||||
|
@click="isUpload = false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ interface DatAssistance {
|
||||||
agency: string;
|
agency: string;
|
||||||
commandNo: string;
|
commandNo: string;
|
||||||
document: string;
|
document: string;
|
||||||
isUpload: boolean;
|
// isUpload: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { DataActing, DatAssistance };
|
export type { DataActing, DatAssistance };
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,11 @@ interface ResAssistanceData {
|
||||||
profileId: string;
|
profileId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { ResActingPosData, ResAssistanceData };
|
interface ResFileData {
|
||||||
|
downloadUrl: string;
|
||||||
|
fileName: string;
|
||||||
|
path: string;
|
||||||
|
pathname: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { ResActingPosData, ResAssistanceData, ResFileData };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue