hrms-mgt/src/modules/11_discipline/components/1_Complaint/Popup.vue

301 lines
8 KiB
Vue

<script setup lang="ts">
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import DialogHeader from "@/components/DialogHeader.vue";
import type { QTableProps } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useComplainstDataStore } from "@/modules/11_discipline/store/ComplaintsStore";
const complainstStore = useComplainstDataStore();
const mixin = useCounterMixin();
const $q = useQuasar();
const { dialogConfirm, dialogMessageNotify, success } = mixin;
const props = defineProps({
title: {
type: String,
default: "ส่งไปสืบสวน",
},
modal: {
type: Boolean,
require: true,
},
close: {
type: Function,
require: true,
},
sentApprove: {
type: Function,
default: () => "",
},
});
const emit = defineEmits([
"returnPerson"
])
/** หัวตาราง */
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: false,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "idcard",
align: "left",
label: "เลขบัตรประชาชน",
sortable: true,
field: "idcard",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "name",
align: "left",
label: "ชื่อ - นามสกุล",
sortable: true,
field: "name",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionNo",
align: "left",
label: "ตำแหน่งเลขที่",
sortable: true,
field: "positionNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "position",
align: "left",
label: "ตำแหน่ง",
sortable: true,
field: "position",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionLevel",
align: "left",
label: "ระดับ",
sortable: true,
field: "positionLevel",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "salary",
align: "left",
label: "เงินเดือน",
sortable: true,
field: "salary",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "organization",
align: "left",
label: "หน่วยงาน",
sortable: true,
field: "organization",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
/** หัวข้อที่เเสดงในตาราง */
const visibleColumns = ref<string[]>([
"no",
"idcard",
"name",
"positionNo",
"position",
"positionLevel",
"salary",
"organization",
]);
const selected = ref<any>([]);
const inspectionResults = ref<string>("");
const filter = ref<string>("");
// const inputRef = ref<any>(null);
const initialPagination = ref<any>({
descending: false,
rowsPerPage: 25,
});
function onclickSend() {
// inputRef.value.validate();
// dialogConfirm($q, () => props.sentApprove());
if (selected.value.length > 0) {
dialogConfirm(
$q,
async () => {
success($q, `ส่งข้อมูล${props.title}สำเร็จ`);
console.log(selected.value);
emit('returnPerson',selected.value)
props.close?.();
},
`ยืนยันการส่ง${props.title}`,
`ต้องการยืนยันการส่ง${props.title}หรือไม่`
);
} else {
dialogMessageNotify($q, "กรุณาเลือกรายชื่อ");
}
}
function onClickClose() {
props.close?.();
}
watch([() => props.modal], () => {
inspectionResults.value = props.modal ? "" : "";
selected.value = props.modal ? [] : [];
if(props.modal === true){
selected.value = complainstStore.rowsAdd;
}
});
</script>
<template>
<q-dialog v-model="props.modal">
<q-card style="width: 820px; max-width: 80vw">
<DialogHeader :tittle="props.title" :close="onClickClose" />
<q-separator />
<q-card-section class="q-pt-none q-mt-md">
<div class="col-12 row q-pb-sm items-center">
<q-space />
<div class="items-center" style="display: flex">
<!-- ค้นหาข้อความใน table -->
<q-input
for="inputfilterRef"
standout
dense
v-model="filter"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
class="q-ml-sm"
>
<template v-slot:append>
<q-icon v-if="filter == ''" name="search" />
<q-icon
v-if="filter !== ''"
name="clear"
class="cursor-pointer"
/>
</template>
</q-input>
<!-- แสดงคอลัมน์ใน table -->
<q-select
for="selectVisibleColumns"
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 q-ml-sm"
/>
</div>
</div>
<d-table
ref="table"
:columns="columns"
:rows="complainstStore.rowsAdd"
:filter="filter"
row-key="personId"
flat
bordered
:paging="false"
dense
class="custom-header-table"
:visible-columns="visibleColumns"
selection="multiple"
v-model:selected="selected"
:pagination="initialPagination"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width>
<!-- <q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/> -->
</q-th>
<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>
<q-checkbox
keep-color
color="primary"
dense
v-model="props.selected"
/>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div>
{{ col.value }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
<!-- <div class="col-xs-12 col-sm-12 q-mt-sm">
<q-input
for="inputInspectionResults"
ref="inputRef"
dense
outlined
hide-bottom-space
v-model="inspectionResults"
:rules="[(val) => !!val || 'กรุณากรอกผลการตรวจสอบเรื่องร้องเรียน']"
lazy-rules
label="ผลการตรวจสอบเรื่องร้องเรียน"
type="textarea"
rows="5"
/>
</div> -->
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn :label="props.title" color="public" @click="onclickSend" />
</q-card-actions>
</q-card>
</q-dialog>
</template>
<style scoped></style>