ต่อ API รอปรับ UI
This commit is contained in:
parent
8662e7eabb
commit
21687e3714
4 changed files with 232 additions and 149 deletions
|
|
@ -18,9 +18,11 @@ const mixin = useCounterMixin();
|
|||
const store = useIndividualDevelopmentPlan();
|
||||
const { showLoader, hideLoader, messageError, success, dialogRemove } = mixin;
|
||||
|
||||
const idRow = ref<string>("");
|
||||
const isEdit = ref<boolean>(false);
|
||||
const modalAdd = ref<boolean>(false); //ตัวแปร dialog #Add
|
||||
const filterKeyword = ref<string>("");
|
||||
const status = ref<string>(""); // สถานะคำร้อง
|
||||
const status = ref<string>("ALL"); // สถานะคำร้อง
|
||||
const statusOptions = ref<DataOption[]>(store.optionStatus);
|
||||
|
||||
/** pagination */
|
||||
|
|
@ -38,9 +40,9 @@ const visibleColumns = ref<string[]>([
|
|||
"no",
|
||||
"name",
|
||||
"developmentProjects",
|
||||
"target",
|
||||
"developmentTarget",
|
||||
"developmentResults",
|
||||
"point",
|
||||
"developmentReport",
|
||||
"topic",
|
||||
"detail",
|
||||
"document",
|
||||
|
|
@ -80,11 +82,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "target",
|
||||
name: "developmentTarget",
|
||||
align: "left",
|
||||
label: "เป้าหมายการพัฒนา",
|
||||
sortable: true,
|
||||
field: "target",
|
||||
field: "developmentTarget",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
|
|
@ -102,11 +104,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "point",
|
||||
name: "developmentReport",
|
||||
align: "left",
|
||||
label: "รายงานผลการพัฒนา",
|
||||
sortable: true,
|
||||
field: "point",
|
||||
field: "developmentReport",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
|
|
@ -161,7 +163,7 @@ function filterOption(val: string, update: Function) {
|
|||
* function เคลียร์ข้อมูลสถานะคำร้อง
|
||||
*/
|
||||
function clearStatus() {
|
||||
status.value = "";
|
||||
status.value = "ALL";
|
||||
statusOptions.value = store.optionStatus;
|
||||
}
|
||||
|
||||
|
|
@ -172,100 +174,39 @@ function openAdd() {
|
|||
|
||||
function onDelete(id: string) {
|
||||
dialogRemove($q, async () => {
|
||||
// await http
|
||||
// .delete(config.API.path(id))
|
||||
// .then(async (res) => {
|
||||
// success($q, "ลบข้อมูลสำเร็จ");
|
||||
// await getListData();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(() => {});
|
||||
await http
|
||||
.delete(config.API.developmentRequest + `/${id}`)
|
||||
.then(async (res) => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
await getListData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {});
|
||||
});
|
||||
}
|
||||
/** list รายการ */
|
||||
async function getListData() {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .get(
|
||||
// config.API.path +
|
||||
// `?page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}&searchKeyword=${filterKeyword.value}
|
||||
// `
|
||||
// )
|
||||
// .then(async (res) => {
|
||||
// const data = await res.data.result.data;
|
||||
// const dataTotal = await res.data.result.total;
|
||||
// totalList.value = Math.ceil(dataTotal / pagination.value.rowsPerPage);
|
||||
// total.value = dataTotal;
|
||||
// rows.value = data;
|
||||
|
||||
/** จำลอง */
|
||||
rows.value = [
|
||||
{
|
||||
id: "01c73dc6-f716-4518-883b-289587cf91d7",
|
||||
createdAt: "2024-08-27T01:20:44.960Z",
|
||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
lastUpdatedAt: "2024-08-27T03:41:09.440Z",
|
||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
createdFullName: "นันทนา ศรีพัฒน์",
|
||||
lastUpdateFullName: "นันทนา ศรีพัฒน์",
|
||||
profileId: "08dc4c98-8739-401f-8180-65a982ee4237",
|
||||
profileEmployeeId: null,
|
||||
name: "พัฒนาด้านการสื่อสาร",
|
||||
target: "สื่อสารได้ดีมากขึ้น",
|
||||
summary: 10,
|
||||
point: 10,
|
||||
achievement10: "มีผลการพัฒนาและมีการดำเนินการตามเป้าหมายการนำไปพัฒนางาน",
|
||||
achievement5:
|
||||
"มีผลการพัฒนาแต่ยังไม่ได้ดำเนินการตามเป้าหมายการนำไปพัฒนางาน",
|
||||
achievement0: "ไม่ได้ดำเนินการพัฒนา",
|
||||
isDevelopment70: true,
|
||||
isDevelopment20: true,
|
||||
isDevelopment10: true,
|
||||
reasonDevelopment70: "",
|
||||
reasonDevelopment20: "",
|
||||
reasonDevelopment10: "",
|
||||
kpiDevelopmentId: "1cddfbd8-9264-4720-a985-0a6500b8e8aa",
|
||||
status: "PENDING",
|
||||
remark: "เปลี่ยนรูปภาพแล้ว",
|
||||
},
|
||||
{
|
||||
id: "f0ad722f-5915-4292-b4f4-9d9c9c891cb5",
|
||||
createdAt: "2024-08-27T01:20:45.958Z",
|
||||
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
lastUpdatedAt: "2024-08-27T03:41:09.398Z",
|
||||
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
|
||||
createdFullName: "นันทนา ศรีพัฒน์",
|
||||
lastUpdateFullName: "นันทนา ศรีพัฒน์",
|
||||
profileId: "08dc4c98-8739-401f-8180-65a982ee4237",
|
||||
profileEmployeeId: null,
|
||||
name: "พัฒนาด้านการทำงานเป็นทีม",
|
||||
target: "ทำงานเป็นทีมได้ดีขึ้น",
|
||||
summary: 10,
|
||||
point: 10,
|
||||
achievement10: "มีผลการพัฒนาและมีการดำเนินการตามเป้าหมายการนำไปพัฒนางาน",
|
||||
achievement5:
|
||||
"มีผลการพัฒนาแต่ยังไม่ได้ดำเนินการตามเป้าหมายการนำไปพัฒนางาน",
|
||||
achievement0: "ไม่ได้ดำเนินการพัฒนา",
|
||||
isDevelopment70: true,
|
||||
isDevelopment20: true,
|
||||
isDevelopment10: true,
|
||||
reasonDevelopment70: "บรรยาย",
|
||||
reasonDevelopment20: "",
|
||||
reasonDevelopment10: "",
|
||||
kpiDevelopmentId: "86ea3b48-96c4-494c-a180-5c315b4c4f85",
|
||||
status: "COMPLETE",
|
||||
remark: "เปลี่ยนรูปภาพแล้ว",
|
||||
},
|
||||
];
|
||||
|
||||
// hideLoader();
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// hideLoader();
|
||||
// })
|
||||
// .finally(() => {});
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.developmentRequest +
|
||||
`/user?status=${status.value}&keyword=${filterKeyword.value}&page=${pagination.value.page}&pageSize=${pagination.value.rowsPerPage}
|
||||
`
|
||||
)
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result.data;
|
||||
const dataTotal = await res.data.result.total;
|
||||
totalList.value = Math.ceil(dataTotal / pagination.value.rowsPerPage);
|
||||
total.value = dataTotal;
|
||||
rows.value = data;
|
||||
hideLoader();
|
||||
})
|
||||
.catch((e) => {
|
||||
hideLoader();
|
||||
})
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,19 +216,10 @@ async function getListData() {
|
|||
function onDownloadFile(id: string) {
|
||||
showLoader();
|
||||
http
|
||||
.get(
|
||||
config.API.file(
|
||||
"ระบบทะเบียนประวัติ",
|
||||
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
|
||||
"eecb1cd9-4c55-4e73-ba52-36fce07ef18d"
|
||||
)
|
||||
)
|
||||
.get(config.API.file("IDP", "ยื่นคำร้องขอแก้ไขข้อมูล", id))
|
||||
.then((res) => {
|
||||
if (res.data.length !== 0) {
|
||||
downloadUrl(
|
||||
"eecb1cd9-4c55-4e73-ba52-36fce07ef18d",
|
||||
res.data[0].fileName
|
||||
);
|
||||
downloadUrl(id, res.data[0].fileName);
|
||||
} else {
|
||||
hideLoader();
|
||||
}
|
||||
|
|
@ -307,8 +239,8 @@ function downloadUrl(id: string, fileName: string) {
|
|||
http
|
||||
.get(
|
||||
config.API.fileByFile(
|
||||
"ระบบทะเบียนประวัติ",
|
||||
"เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล",
|
||||
"IDP",
|
||||
"ยื่นคำร้องขอแก้ไขข้อมูล",
|
||||
id,
|
||||
fileName
|
||||
)
|
||||
|
|
@ -330,6 +262,16 @@ function updatePagination(newPagination: any) {
|
|||
pagination.value.rowsPerPage = newPagination.rowsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังชั่น เปิดรายละเอียด
|
||||
* @param id id row
|
||||
*/
|
||||
function onDetail(id: string) {
|
||||
modalAdd.value = true;
|
||||
isEdit.value = true;
|
||||
idRow.value = id;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => pagination.value.rowsPerPage,
|
||||
async () => {
|
||||
|
|
@ -374,8 +316,6 @@ onMounted(async () => {
|
|||
:options="statusOptions"
|
||||
style="width: 250px"
|
||||
@update:model-value="getListData()"
|
||||
:clearable="status !== ''"
|
||||
@clear="clearStatus"
|
||||
@filter="(inputValue:string,
|
||||
doneFn:Function) => filterOption(inputValue, doneFn
|
||||
) "
|
||||
|
|
@ -386,8 +326,15 @@ onMounted(async () => {
|
|||
ไม่มีข้อมูล
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template></q-select
|
||||
>
|
||||
</template>
|
||||
<template v-if="status !== 'ALL'" v-slot:append>
|
||||
<q-icon
|
||||
name="cancel"
|
||||
@click.stop.prevent="(status = 'ALL'), getListData()"
|
||||
class="cursor-pointer"
|
||||
/>
|
||||
</template>
|
||||
</q-select>
|
||||
<q-btn dense round flat icon="add" color="primary" @click="openAdd">
|
||||
<q-tooltip>เพิ่มข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
|
|
@ -396,12 +343,20 @@ onMounted(async () => {
|
|||
<q-input
|
||||
v-model="filterKeyword"
|
||||
outlined
|
||||
clearable
|
||||
dense
|
||||
label="ค้นหา"
|
||||
@keydown.enter="getListData()"
|
||||
style="width: 200px"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
<q-icon
|
||||
v-if="filterKeyword !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="(filterKeyword = ''), getListData()"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
<q-select
|
||||
v-model="visibleColumns"
|
||||
|
|
@ -447,7 +402,10 @@ onMounted(async () => {
|
|||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
class="vertical-top"
|
||||
class="vertical-top cursor-pointer"
|
||||
@click="
|
||||
col.name === 'document' ? '' : onDetail(props.row.id)
|
||||
"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
{{
|
||||
|
|
@ -470,7 +428,7 @@ onMounted(async () => {
|
|||
</q-btn>
|
||||
</div>
|
||||
<div v-else-if="col.name == 'developmentProjects'">
|
||||
<div class="column">
|
||||
<div class="column no-pointer-events">
|
||||
<q-checkbox
|
||||
size="xs"
|
||||
:model-value="props.row.isDevelopment70"
|
||||
|
|
@ -488,31 +446,6 @@ onMounted(async () => {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="col.name == 'developmentResults'">
|
||||
<div class="column">
|
||||
<span>
|
||||
{{
|
||||
props.row.achievement10
|
||||
? `- ${props.row.achievement10} (10)`
|
||||
: ""
|
||||
}}
|
||||
</span>
|
||||
<span>
|
||||
{{
|
||||
props.row.achievement5
|
||||
? `- ${props.row.achievement5} (5)`
|
||||
: ""
|
||||
}}
|
||||
</span>
|
||||
<span>
|
||||
{{
|
||||
props.row.achievement0
|
||||
? `- ${props.row.achievement10} (0)`
|
||||
: ""
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="table_ellipsis">
|
||||
{{ col.value ? col.value : "-" }}
|
||||
</div>
|
||||
|
|
@ -556,6 +489,11 @@ onMounted(async () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<DialogDevelop v-model:modal="modalAdd" />
|
||||
<DialogDevelop
|
||||
v-model:modal="modalAdd"
|
||||
:get-data="getListData"
|
||||
v-model:is-edit="isEdit"
|
||||
v-model:id-row="idRow"
|
||||
/>
|
||||
</template>
|
||||
<style scoped lang="scss"></style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue