UI ออกคำสั่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-10 18:03:01 +07:00
parent a750c4924c
commit 884fab1560
15 changed files with 1828 additions and 18 deletions

View file

@ -0,0 +1,105 @@
<script setup lang="ts">
import { ref } from "vue";
import { useQuasar } from "quasar";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const { dialogConfirm } = useCounterMixin();
const modal = defineModel<boolean>("modal", { required: true });
const commandNo = ref<string>("");
const commandYear = ref<string>("");
function onSubmit() {
dialogConfirm($q, () => {
console.log(commandNo.value);
console.log(commandYear.value);
onClose();
});
}
function onClose() {
modal.value = false;
commandNo.value = "";
commandYear.value = "";
}
</script>
<template>
<q-dialog v-model="modal" persistent>
<q-card style="max-width: 50%">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<DialogHeader :tittle="'ทำสำเนาคำสั่ง'" :close="onClose" />
<q-separator />
<q-card-section>
<div class="row q-col-gutter-sm">
<div class="col-6">
<q-input
class="inputgreen"
outlined
dense
v-model="commandNo"
hide-bottom-space
:label="`${'คำสั่งเลขที่'}`"
:rules="[(val) => !!val || `${'กรุณากรอกคำสั่งเลขที่'}`]"
/>
</div>
<label class="col-1 flex justify-center items-center text-bold"
>/</label
>
<div class="col-5">
<q-input
class="inputgreen"
outlined
dense
v-model="commandYear"
hide-bottom-space
:label="`${'พ.ศ.'}`"
mask="####"
:rules="[(val) => !!val || `${'กรุณากรอก พ.ศ.'}`]"
/>
<!-- <datepicker
v-model="commandYear"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="inputgreen"
:model-value="
commandYear !== null ? commandYear + 543 : null
"
:rules="[(val) => !!val || `${'กรุณาเลือก พ.ศ.'}`]"
:label="`${'พ.ศ.'}`"
dense
hide-bottom-space
outlined
>
</q-input>
</template>
</datepicker> -->
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn label="บันทึก" color="public" type="submit" />
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>
<style scoped></style>

View file

@ -0,0 +1,245 @@
<script setup lang="ts">
import { ref } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useCommandListStore } from "@/modules/18_command/store/ListStore";
import DialogCopyCommand from "@/modules/18_command/components/Main/DialogCopyCommand.vue";
import type { QTableProps } from "quasar";
const $q = useQuasar();
const router = useRouter();
const store = useCommandListStore();
const { date2Thai, dialogRemove, dialogConfirm } = useCounterMixin();
const columns = ref<QTableProps["columns"]>([
{
name: "orderNo",
align: "left",
label: "เลขที่คำสั่ง",
sortable: false,
field: "orderNo",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "orderName",
align: "center",
label: "ชื่อคำสั่ง",
sortable: true,
field: "orderName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "signatoryDate",
align: "center",
label: "วันที่ลงนาม",
sortable: false,
field: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "orderDate",
align: "center",
label: "วันที่คำสั่งมีผล",
sortable: false,
field: (v) => date2Thai(v),
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "orderBy",
align: "center",
label: "ผู้สร้าง",
sortable: false,
field: "orderBy",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "signatoryBy",
align: "center",
label: "ผู้ลงนาม",
sortable: false,
field: "signatoryBy",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const modalCopy = ref<boolean>(false);
const commandId = ref<string>("");
function onRedirectToDetail(type: string, id: string) {
router.push(`/command/${type}/${id}`);
}
function onCopy(id: string) {
commandId.value = id;
modalCopy.value = true;
}
function onCancel(id: string) {
dialogRemove(
$q,
() => {},
"ยืนยันการยกเลิกการออกคำสั่ง",
"ต้องการยืนยันการยกเลิกการออกคำสั่งนี้ใช่หรือไม่ ?"
);
}
function onReCommand(id: string) {
dialogConfirm(
$q,
() => {},
"ยืนยันการดึงไปทำคำสั่งใหม่",
"ต้องการยืนยืนยันการดึงไปทำคำสั่งใหม่ใช่หรือไม่ ?"
);
}
</script>
<template>
<d-table
ref="table"
:columns="columns"
:rows="store.rows"
row-key="id"
flat
dense
bordered
:paging="true"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<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">
<q-td auto-width>
<q-btn
flat
dense
round
color="secondary"
icon="mdi-dots-horizontal-circle-outline"
>
<q-menu>
<q-list dense style="min-width: 200px">
<!-- แกไขขอม ไมแสดง Tabs ยกเล -->
<q-item
clickable
v-close-popup
v-if="store.tabsMain !== 'list_cancel'"
@click.pervent="onRedirectToDetail('edit', props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon
color="edit"
size="xs"
name="edit
"
/>
<div class="q-pl-md">แกไขขอม</div>
</div>
</q-item-section>
</q-item>
<!-- รายละเอยด -->
<q-item
clickable
v-close-popup
@click.pervent="onRedirectToDetail('view', props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon
color="info"
size="xs"
name="mdi-eye
"
/>
<div class="q-pl-md">รายละเอยด</div>
</div>
</q-item-section>
</q-item>
<!-- ทำสำเนาคำส -->
<q-item
clickable
v-close-popup
@click.pervent="onCopy(props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon
color="blue-6"
size="xs"
name="mdi-content-copy"
/>
<div class="q-pl-md">ทำสำเนาคำส</div>
</div>
</q-item-section>
</q-item>
<!-- ยกเล ไมแสดง Tabs ยกเล -->
<q-item
clickable
v-close-popup
v-if="store.tabsMain !== 'list_cancel'"
@click.pervent="onCancel(props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon
color="red"
size="xs"
name="close
"
/>
<div class="q-pl-md">ยกเล</div>
</div>
</q-item-section>
</q-item>
<!-- งไปทำคำสงใหม แสดงแค Tabs ยกเล -->
<q-item
clickable
v-close-popup
v-if="store.tabsMain === 'list_cancel'"
@click.pervent="onReCommand(props.row.id)"
>
<q-item-section>
<div class="row items-center">
<q-icon color="amber-5" size="xs" name="mdi-replay" />
<div class="q-pl-md">งไปทำคำสงใหม</div>
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div>
{{ col.value ?? "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
<DialogCopyCommand v-model:modal="modalCopy" />
</template>
<style scoped></style>