ปรับเมนู และเพิ่ม UI ผลงาน
This commit is contained in:
parent
b53765a469
commit
38aa872064
11 changed files with 609 additions and 74 deletions
231
src/modules/13_portfolio/views/Add.vue
Normal file
231
src/modules/13_portfolio/views/Add.vue
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import type { QForm } from "quasar";
|
||||
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const { success, messageError, showLoader, hideLoader, dialogConfirm } = mixin;
|
||||
|
||||
/**
|
||||
* ตัวแปรที่ใช้งาน
|
||||
*/
|
||||
const route = useRoute();
|
||||
const files = ref<any>();
|
||||
const name = ref("");
|
||||
const description = ref("");
|
||||
const id = ref<string>("");
|
||||
const nameFile = ref<string>("");
|
||||
const routeName = router.currentRoute.value.name;
|
||||
|
||||
/**
|
||||
* เรียกฟังก์ชันทั้งหมดตอนเรียกใช้ไฟล์นี้
|
||||
*/
|
||||
onMounted(() => {
|
||||
if (route.params.id !== undefined) {
|
||||
id.value = route.params.id.toString();
|
||||
fecthData(id.value);
|
||||
}
|
||||
});
|
||||
|
||||
const saveData = async () => {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
() => {
|
||||
createTransfer();
|
||||
},
|
||||
"ยืนยันการยื่นข้อมูลการโอน",
|
||||
"ต้องการยื่นข้อมูลการโอนนี้ใช่หรือไม่"
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* ฟังก์ชั่นสร้างขอโอน
|
||||
*/
|
||||
const createTransfer = async () => {
|
||||
showLoader();
|
||||
const formData = new FormData();
|
||||
formData.append("Organization", name.value);
|
||||
formData.append("Reason", description.value);
|
||||
formData.append("file", files.value);
|
||||
// await http
|
||||
// .post(config.API.listtransfer(), formData)
|
||||
// .then((res: any) => {
|
||||
// success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
// router.push(`/transfer`);
|
||||
// })
|
||||
// .catch((e: any) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
};
|
||||
|
||||
/**
|
||||
* ฟังก์ชั่นเรียกข้อมูลจาก Api
|
||||
* @param id ไอดีของข้อมูล
|
||||
*/
|
||||
const fecthData = async (id: string) => {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(config.API.transferByid(id))
|
||||
// .then((res: any) => {
|
||||
// let data = res.data.result;
|
||||
// name.value = data.organization;
|
||||
// description.value = data.reason;
|
||||
// files.value = data.docs;
|
||||
// })
|
||||
// .catch((e: any) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// hideLoader();
|
||||
// });
|
||||
};
|
||||
|
||||
/**
|
||||
* ฟังก์ชั่นดาว์โหลดอัปโหลดไฟล์
|
||||
*/
|
||||
const fileDocDataUpload = ref<File[]>([]);
|
||||
const filesNull = () => {
|
||||
files.value = null;
|
||||
};
|
||||
//อัปโหลดไฟล์
|
||||
const fileUploadDoc = async (file: any) => {
|
||||
fileDocDataUpload.value.push(file);
|
||||
nameFile.value = file[0].name;
|
||||
files.value = file;
|
||||
};
|
||||
|
||||
function fileOpen(url: string) {
|
||||
window.open(url, "_blank");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="col-12 row justify-center">
|
||||
<div class="col-xs-12 col-sm-12 col-md-11">
|
||||
<div class="toptitle text-white col-12 row items-center">
|
||||
<q-btn
|
||||
icon="mdi-arrow-left"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
flat
|
||||
color="primary"
|
||||
class="q-mr-sm"
|
||||
@click="router.go(-1)"
|
||||
/>
|
||||
<div v-if="routeName == 'addTransfer'">เพิ่มเอกสาร/ผลงาน</div>
|
||||
<div v-else>รายละเอียดเอกสาร/ผลงาน</div>
|
||||
</div>
|
||||
<q-form
|
||||
class="col-12"
|
||||
greedy
|
||||
@submit.prevent
|
||||
@validation-success="saveData"
|
||||
>
|
||||
<q-card bordered>
|
||||
<div class="col-12 row q-col-gutter-md q-pa-md">
|
||||
<div class="col-xs-12 col-sm-12">
|
||||
<div class="col-12 row q-pa-sm q-col-gutter-sm">
|
||||
<q-input
|
||||
:class="
|
||||
routeName != 'addPortfolio' ? 'col-12' : 'col-12 inputgreen'
|
||||
"
|
||||
dense
|
||||
outlined
|
||||
v-model="name"
|
||||
hide-bottom-space
|
||||
label="ชื่อเอกสาร/ผลงาน"
|
||||
:readonly="routeName != 'addPortfolio'"
|
||||
:rules="[(val:string) => !!val || `${'กรุณากรอกชื่อเอกสาร/ผลงาน'}`]"
|
||||
/>
|
||||
<q-input
|
||||
:class="
|
||||
routeName != 'addPortfolio' ? 'col-12' : 'col-12 inputgreen'
|
||||
"
|
||||
dense
|
||||
outlined
|
||||
v-model="description"
|
||||
label="รายละเอียดเอกสาร/ผลงาน"
|
||||
hide-bottom-space
|
||||
type="textarea"
|
||||
:readonly="routeName != 'addPortfolio'"
|
||||
:rules="[(val:string) => !!val || `${'กรุณากรอกรายละเอียดเอกสาร/ผลงาน'}`]"
|
||||
/>
|
||||
<div class="col-12 row" v-if="routeName == 'addPortfolio'">
|
||||
<q-file
|
||||
v-model="files"
|
||||
class="col-xs-12 col-sm-12 inputgreen"
|
||||
outlined
|
||||
dense
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
accept=".pdf, .docx, .doc, .xlsx, .xls"
|
||||
:rules="[
|
||||
(val:string) => !!val || 'กรุณาเลือกไฟล์เอกสาร/ผลงาน',
|
||||
]"
|
||||
label="เอกสาร/ผลงาน"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="attach_file" /> </template
|
||||
></q-file>
|
||||
</div>
|
||||
<div class="col-12 row" v-if="routeName != 'addPortfolio'">
|
||||
<q-card bordered flat class="full-width">
|
||||
<div
|
||||
class="bg-grey-1 q-pa-sm col-12 row items-center text-primary"
|
||||
>
|
||||
<div class="q-pl-sm text-weight-bold text-dark">
|
||||
เอกสาร/ผลงาน
|
||||
</div>
|
||||
</div>
|
||||
<q-separator />
|
||||
<q-list separator>
|
||||
<q-item v-for="file in files" :key="file.key">
|
||||
<q-item-section>
|
||||
{{ file.fileName }}
|
||||
</q-item-section>
|
||||
<q-item-section avatar>
|
||||
<q-btn
|
||||
color="teal-5"
|
||||
round
|
||||
flat
|
||||
icon="mdi-download"
|
||||
@click="fileOpen(file.pathName)"
|
||||
></q-btn>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<q-separator v-if="routeName == 'addPortfolio'" />
|
||||
<q-card-actions
|
||||
align="right"
|
||||
class="row col-12"
|
||||
v-if="routeName == 'addPortfolio'"
|
||||
>
|
||||
<q-space />
|
||||
<q-btn
|
||||
unelevated
|
||||
class="q-px-md items-center"
|
||||
color="primary"
|
||||
label="บันทึก"
|
||||
type="onsubmit"
|
||||
/>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue