UI รอบการปฏิบัติงาน
This commit is contained in:
parent
aa4fa5b989
commit
ad1545ac2e
6 changed files with 274 additions and 455 deletions
|
|
@ -1,216 +1,214 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { ref, useAttrs, onMounted } from "vue";
|
||||
|
||||
import router from "@/router";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoundDataStore } from '@/modules/09_leave/stores/RoundStores.ts'
|
||||
import DialogHeader from "@/components/information/DialogHeader.vue";
|
||||
|
||||
const $q = useQuasar();
|
||||
const dataStore = useRoundDataStore()
|
||||
const mixin = useCounterMixin();
|
||||
const {
|
||||
dialogRemove,
|
||||
} = mixin;
|
||||
|
||||
onMounted(() => {
|
||||
// get ข้อมูลแล้วโยนใส่ store
|
||||
dataStore.fetchData([
|
||||
{
|
||||
round: "07:30 - 15:30",
|
||||
am: "07:30",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "15:30",
|
||||
note: "-",
|
||||
status: true,
|
||||
},
|
||||
{
|
||||
round: "08:30 - 16:30",
|
||||
am: "08:30",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "16:30",
|
||||
note: "-",
|
||||
status: false,
|
||||
},
|
||||
{
|
||||
round: "09:00 - 17:00",
|
||||
am: "09:00",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "17:00",
|
||||
note: "-",
|
||||
status: false,
|
||||
},
|
||||
])
|
||||
});
|
||||
import DialogForm from '@/modules/09_leave/components/3_WorkTime/DialogForm.vue'
|
||||
import { useRoundDataStore } from '@/modules/09_leave/stores/RoundStores'
|
||||
const dataStore = useRoundDataStore();
|
||||
const { fetchData } = dataStore;
|
||||
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const modal = ref<boolean>(false)
|
||||
const detailData = ref<any>()
|
||||
const editCheck = ref<string>('')
|
||||
// ค้นหาในตาราง
|
||||
const filterKeyword = ref<string>("");
|
||||
const filterRef = ref<HTMLInputElement | null>(null);
|
||||
function resetFilter() {
|
||||
const resetFilter = () => {
|
||||
filterKeyword.value = "";
|
||||
if (filterRef.value) {
|
||||
filterRef.value.focus();
|
||||
}
|
||||
};
|
||||
|
||||
// กำหนด pagination
|
||||
const attrs = ref<any>(useAttrs());
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
// sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 25,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
const mode = ref("add");
|
||||
const modal = ref(false);
|
||||
const roundTime = ref<string>("");
|
||||
const am = ref("");
|
||||
const amOut = ref("");
|
||||
const pm = ref("");
|
||||
const pmOut = ref("");
|
||||
const note = ref("");
|
||||
const status = ref(false);
|
||||
|
||||
function clickAdd() {
|
||||
mode.value = "add";
|
||||
modal.value = true;
|
||||
const paginationLabel = (start: string, end: string, total: string) => {
|
||||
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
||||
else return start + "-" + end + " ใน " + total;
|
||||
};
|
||||
|
||||
const clickEdit = async (val: string) => {
|
||||
mode.value = "edit";
|
||||
modal.value = true;
|
||||
roundTime.value = val;
|
||||
function openModal(data:any,check:string){
|
||||
console.log(check)
|
||||
modal.value = true
|
||||
editCheck.value = check
|
||||
if(check === 'edit'){
|
||||
detailData.value = data
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* กดปิด dialog
|
||||
*/
|
||||
const clickClose = async () => {
|
||||
function closeDialog(){
|
||||
modal.value = false
|
||||
};
|
||||
editCheck.value = 'add'
|
||||
}
|
||||
onMounted(() => {
|
||||
dataStore.fetchData([
|
||||
{
|
||||
am: "07:30",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "15:30",
|
||||
note: "",
|
||||
status: true,
|
||||
},
|
||||
{
|
||||
am: "08:30",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "15:30",
|
||||
note: "",
|
||||
status: false,
|
||||
},
|
||||
{
|
||||
am: "09:30",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "15:30",
|
||||
note: "",
|
||||
status: true,
|
||||
},
|
||||
{
|
||||
am: "10:30",
|
||||
amOut: "12:00",
|
||||
pm: "13:00",
|
||||
pmOut: "15:30",
|
||||
note: "",
|
||||
status: true,
|
||||
},
|
||||
]);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
รายการรอบการปฏิบัติงาน
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
|
||||
<div class="row col-12 q-col-gutter-sm q-mb-sm">
|
||||
<div>
|
||||
<q-btn @click="clickAdd" size="12px" flat round color="add" icon="mdi-plus">
|
||||
<q-tooltip>เพิ่มรอบการปฏิบัติงาน</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
<q-space />
|
||||
|
||||
<q-input class="col-xs-12 col-sm-3 col-md-2" standout dense v-model="filterKeyword" ref="filterRef" outlined
|
||||
debounce="300" placeholder="ค้นหา">
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
<q-icon v-if="filterKeyword !== ''" name="clear" class="cursor-pointer" @click="resetFilter" />
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-select v-model="dataStore.visibleColumns" multiple outlined dense options-dense
|
||||
:display-value="$q.lang.table.columns" emit-value map-options :options="dataStore.columns" option-value="name"
|
||||
options-cover style="min-width: 150px" class="col-xs-12 col-sm-3 col-md-2" />
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<d-table
|
||||
:columns="dataStore.columns"
|
||||
:rows="dataStore.rows"
|
||||
:filter="filterKeyword"
|
||||
row-key="tb-list"
|
||||
<div class="row col-12 q-col-gutter-sm q-mb-sm">
|
||||
<div>
|
||||
<q-btn
|
||||
for="#addInvestigatefacts"
|
||||
@click="openModal(null,'add')"
|
||||
size="12px"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
v-model:pagination="pagination"
|
||||
:visible-columns="dataStore.visibleColumns">
|
||||
<template v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<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="clickEdit(props.row.round)">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-if="col.name == 'status'" class="">
|
||||
<q-icon
|
||||
v-if="col.value == false"
|
||||
name="mdi-close"
|
||||
color="grey-6"
|
||||
class="text-h5"
|
||||
/>
|
||||
<q-icon
|
||||
v-else
|
||||
name="mdi-check"
|
||||
color="positive"
|
||||
class="text-h5"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
round
|
||||
color="add"
|
||||
icon="mdi-plus"
|
||||
>
|
||||
<q-tooltip>เพิ่มรอบการปฏิบัติงาน</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
<q-space />
|
||||
|
||||
<q-input
|
||||
for="#search"
|
||||
class="col-xs-12 col-sm-3 col-md-2"
|
||||
standout
|
||||
dense
|
||||
v-model="filterKeyword"
|
||||
ref="filterRef"
|
||||
outlined
|
||||
debounce="300"
|
||||
placeholder="ค้นหา"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<q-icon v-if="filterKeyword == ''" name="search" />
|
||||
<q-icon
|
||||
v-if="filterKeyword !== ''"
|
||||
name="clear"
|
||||
class="cursor-pointer"
|
||||
@click="resetFilter"
|
||||
/>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-select
|
||||
for="#select"
|
||||
v-model="dataStore.visibleColumns"
|
||||
multiple
|
||||
outlined
|
||||
dense
|
||||
options-dense
|
||||
:display-value="$q.lang.table.columns"
|
||||
emit-value
|
||||
map-options
|
||||
:options="dataStore.columns"
|
||||
option-value="name"
|
||||
options-cover
|
||||
style="min-width: 150px"
|
||||
class="col-xs-12 col-sm-3 col-md-2"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<d-table
|
||||
ref="table"
|
||||
:columns="dataStore.columns"
|
||||
:rows="dataStore.rows"
|
||||
:filter="filterKeyword"
|
||||
row-key="interrogated"
|
||||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
dense
|
||||
class="custom-header-table"
|
||||
v-bind="attrs"
|
||||
:visible-columns="dataStore.visibleColumns"
|
||||
:pagination-label="paginationLabel"
|
||||
v-model:pagination="pagination"
|
||||
>
|
||||
<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.prevent="openModal(props.row,'edit')">
|
||||
<div v-if="col.name === 'status'" class="text-center">
|
||||
<q-icon
|
||||
v-if="props.row.status === true"
|
||||
name="mdi-check"
|
||||
size="sm"
|
||||
color="positive"
|
||||
/>
|
||||
<q-icon
|
||||
v-if="props.row.status === false"
|
||||
name="mdi-close"
|
||||
size="sm"
|
||||
color="grey"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</d-table>
|
||||
</div>
|
||||
</q-card>
|
||||
<!-- popup Edit window-->
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card style="width: 30%">
|
||||
<q-form ref="myForm">
|
||||
<DialogHeader
|
||||
:tittle="
|
||||
mode == 'add'
|
||||
? 'เพิ่มรอบการปฏิบัติงาน'
|
||||
: 'แก้ไขรอบการ '+ `${roundTime}`
|
||||
"
|
||||
:close="clickClose" />
|
||||
<q-separator />
|
||||
<div class="q-pa-sm row">
|
||||
<q-card bordered class="row col-12 q-pa-sm q-mb-sm">
|
||||
<div class="col-12 text-primary text-weight-medium q-pb-sm">ครึ่งเช้า</div>
|
||||
<div class="col-12 row q-col-gutter-sm">
|
||||
<q-input dense outlined :readonly="mode != 'add'" class="col-xs-12 col-sm-6" v-model="am" type="time" label="เวลาเข้างาน" />
|
||||
<q-input dense outlined :readonly="mode != 'add'" class="col-xs-12 col-sm-6" v-model="amOut" type="time" label="เวลาออกงาน" />
|
||||
</div>
|
||||
</q-card>
|
||||
<q-card bordered class="row col-12 q-pa-sm q-mb-sm">
|
||||
<div class="col-12 text-primary text-weight-medium q-pb-sm">ครึ่งบ่าย</div>
|
||||
<div class="col-12 row q-col-gutter-sm">
|
||||
<q-input dense outlined :readonly="mode != 'add'" class="col-xs-12 col-sm-6" v-model="pm" type="time" label="เวลาเข้างาน" />
|
||||
<q-input dense outlined :readonly="mode != 'add'" class="col-xs-12 col-sm-6" v-model="pmOut" type="time" label="เวลาออกงาน" />
|
||||
</div>
|
||||
</q-card>
|
||||
<div class="col-12 q-mb-sm">
|
||||
<q-input class="bg-white" dense outlined v-model="note" type="textarea" label="คำอธิบาย" />
|
||||
</div>
|
||||
<q-card bordered class="row col-12 q-pa-sm items-center">
|
||||
<div class="text-weight-medium text-dark text-subtitle2 text-primary">สถานะการใช้งาน</div>
|
||||
<q-space/>
|
||||
<q-toggle
|
||||
v-model="status"
|
||||
color="primary"
|
||||
left-label
|
||||
/>
|
||||
</q-card>
|
||||
</div>
|
||||
<q-separator />
|
||||
<div class="q-pa-sm row col-12">
|
||||
<q-space/>
|
||||
<q-btn dense class="q-px-md" unelevated color="public" label="บันทึก" />
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
<DialogForm
|
||||
:modal="modal"
|
||||
:closeDialog="closeDialog"
|
||||
:editCheck="editCheck"
|
||||
:detailData="detailData"
|
||||
/>
|
||||
</template>
|
||||
<style scoped lang="scss">
|
||||
.q-table tbody td:before.no-background {
|
||||
background: none;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue