ปรับเมนู และเพิ่ม UI ผลงาน

This commit is contained in:
Warunee Tamkoo 2024-06-27 14:59:54 +07:00
parent b53765a469
commit 38aa872064
11 changed files with 609 additions and 74 deletions

View file

@ -0,0 +1,33 @@
/**
* Router
*/
const MainPage = () => import("@/modules/13_portfolio/views/Main.vue");
const FormData = () => import("@/modules/13_portfolio/views/Add.vue");
export default [
{
path: "/portfolio",
name: "portfolio",
component: MainPage,
meta: {
Auth: true,
},
},
{
path: "/portfolio/add",
name: "addPortfolio",
component: FormData,
meta: {
Auth: true,
},
},
{
path: "/portfolio/:id",
name: "portfolioDetail",
component: FormData,
meta: {
Auth: true,
},
},
];

View 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>

View file

@ -0,0 +1,260 @@
<script setup lang="ts">
import type { QTableProps } from "quasar";
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
const currentPage = ref<number>(1);
const router = useRouter();
const $q = useQuasar();
const mixin = useCounterMixin();
const { date2Thai, messageError, showLoader, hideLoader } = mixin;
const pagination = ref({
sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
});
/**
* เพมหวขอตาราง
*/
const filter = ref<string>("");
const rows = ref<any>([]);
const visibleColumns = ref<String[]>(["no", "name", "description"]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:5px;",
},
{
name: "name",
align: "left",
label: "ชื่อเอกสาร/ผลงาน",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:5px;",
},
{
name: "description",
align: "left",
label: "รายละเอียดเอกสาร/ผลงาน",
sortable: true,
field: "description",
headerStyle: "font-size: 14px",
style: "font-size: 14px; width:5px;",
},
]);
/**
* เรยกฟงกนทงหมดตอนเรยกใชไฟล
*/
onMounted(async () => {
await fecthList();
});
//
const fecthList = async () => {
// showLoader();
// await http
// .get(config.API.listUserTransfer())
// .then((res: any) => {
// })
// .catch((e: any) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
};
/**
* งกนกดเพมไปหนาเพมขอโอน
*/
const clickAdd = async () => {
router.push(`/portfolio/add`);
};
/**
* งกนกดยอนกล
*/
const clickBack = () => {
router.push(`/`);
};
</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="clickBack"
/>
รายการเอกสาร/ผลงาน
</div>
<div class="col-12">
<q-card bordered class="q-pa-md">
<div class="q-pb-sm row">
<div>
<q-btn
size="14px"
flat
dense
color="blue"
@click="clickAdd"
icon="mdi-plus"
>
<q-tooltip>เพมขอม</q-tooltip>
</q-btn>
</div>
<q-space />
<div class="items-center q-gutter-sm" style="display: flex">
<!-- นหาขอความใน table -->
<q-input
standout
dense
v-model="filter"
ref="filterRef"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
>
<template v-slot:append>
<q-icon v-if="filter == ''" name="search" />
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
@click="filter = ''"
/>
</template>
</q-input>
<!-- แสดงคอลมนใน table -->
<q-select
v-model="visibleColumns"
:display-value="$q.lang.table.columns"
multiple
outlined
dense
:options="columns"
options-dense
option-value="name"
map-options
emit-value
style="min-width: 150px"
class="gt-xs"
>
<template> </template>
</q-select>
</div>
</div>
<div>
<d-table
flat
bordered
dense
:paging="true"
row-key="id"
class="custom-table2"
style="max-height: 80vh"
:rows="rows"
:columns="columns"
:visible-columns="visibleColumns"
:rows-per-page-options="[10, 25, 50, 100]"
v-model:pagination="pagination"
>
<template v-slot:pagination="scope">
งหมด {{ rows.length }} รายการ
<q-pagination
v-model="pagination.page"
active-color="primary"
color="dark"
:max="scope.pagesNumber"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template>
<template v-slot:header="props">
<q-tr :props="props">
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
style="color: #000000; font-weight: 500"
>
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td
v-for="col in props.cols"
:key="col.name"
:props="props"
@click="router.push(`/transfer/` + props.row.id)"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
<template #item="props">
<div class="q-pa-xs col-xs-12 col-sm-6 col-md-4 col-lg-3">
<q-card
bordered
flat
@click="router.push(`/transfer/` + props.row.id)"
>
<q-list>
<q-item
v-for="col in props.cols.filter((col:any) => col.name !== 'desc')"
:key="col.name"
>
<q-item-section>
<q-item-label caption>{{ col.label }}</q-item-label>
<q-item-label v-if="col.name === 'no'">
{{ props.rowIndex + 1 }}
</q-item-label>
<q-item-label v-else>{{
col.value ?? "-"
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-card>
</div>
</template>
</d-table>
</div>
</q-card>
</div>
</div>
</div>
</template>
<style scoped lang="scss"></style>