UI => ส่งคนไประบบออกคำสั่ง

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-27 15:59:13 +07:00
parent 3ca0390b87
commit fc75e315f5
19 changed files with 816 additions and 842 deletions

View file

@ -226,7 +226,7 @@ onMounted(() => {
:readonly="!edit"
:borderless="!edit"
v-model="educationOld"
:rules="[(val) => !!val || `${'กรุณากรอกวุฒิการศึกษา'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกวุฒิการศึกษา'}`]"
hide-bottom-space
:label="`${'วุฒิการศึกษา'}`"
type="text"
@ -249,7 +249,7 @@ onMounted(() => {
:readonly="!edit"
:borderless="!edit"
v-model="organizationPositionOld"
:rules="[(val) => !!val || `${'กรุณากรอกตำแหน่ง/สังกัด'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกตำแหน่ง/สังกัด'}`]"
hide-bottom-space
:label="`${'ตำแหน่ง/สังกัด'}`"
type="textarea"
@ -267,7 +267,7 @@ onMounted(() => {
:readonly="!edit"
:borderless="!edit"
v-model="positionTypeOld"
:rules="[(val) => !!val || `${'กรุณากรอกตำแหน่งประเภท'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกตำแหน่งประเภท'}`]"
hide-bottom-space
:label="`${'ตำแหน่งประเภท'}`"
/>
@ -283,7 +283,7 @@ onMounted(() => {
:readonly="!edit"
:borderless="!edit"
v-model="positionLevelOld"
:rules="[(val) => !!val || `${'กรุณากรอกระดับตำแหน่ง'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกระดับตำแหน่ง'}`]"
hide-bottom-space
:label="`${'ระดับตำแหน่ง'}`"
/>
@ -299,7 +299,7 @@ onMounted(() => {
:readonly="!edit"
:borderless="!edit"
v-model="posNo"
:rules="[(val) => !!val || `${'กรุณากรอกเลขที่'}`]"
:rules="[(val:string) => !!val || `${'กรุณากรอกเลขที่'}`]"
hide-bottom-space
:label="`${'เลขที่'}`"
/>
@ -347,7 +347,7 @@ onMounted(() => {
:borderless="!edit"
:readonly="!edit"
:model-value="date !== null ? date2Thai(date) : null"
:rules="[(val) => !!val || `${'กรุณาเลือกตั้งแต่วัน'}`]"
:rules="[(val:string) => !!val || `${'กรุณาเลือกตั้งแต่วัน'}`]"
hide-bottom-space
:label="`${'ดำรงตำแหน่งในระดับปัจจุบันเมื่อ'}`"
>

View file

@ -1,31 +1,27 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { ref, watch, type PropType } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useTransferDataStore } from "@/modules/05_placement/store";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCommandMainStore } from "@/modules/18_command/store/Main";
/**
* importType
*/
/** importType*/
import type { QTableProps } from "quasar";
import type { UserDataNew } from "@/modules/05_placement/interface/response/AppointMent";
import type { PersonData } from "@/modules/05_placement/interface/index/Main";
import type { ListCommand } from "@/modules/18_command/interface/index/Main";
/**
* importcomponents
*/
/** importcomponents*/
import DialogHeader from "@/components/DialogHeader.vue";
import DialogCreateCommand from "@/modules/18_command/components/DialogCreateCommand.vue";
const $q = useQuasar();
const storeFn = useTransferDataStore();
const storeCommand = useCommandMainStore();
const { statusText } = storeFn;
const {
showLoader,
success,
messageError,
dialogConfirm,
hideLoader,
date2Thai,
} = useCounterMixin();
@ -38,7 +34,7 @@ const props = defineProps({
fetchData: Function,
nextPage: Function,
optionsType: Array,
rows2: Array,
rows2: Array as PropType<PersonData[]>,
filterKeyword2: String,
type: String,
});
@ -51,6 +47,8 @@ const emit = defineEmits([
/**
* table
*/
const rows = ref<PersonData[]>([]); //
const selected = ref<PersonData[]>([]); //
const visibleColumns2 = ref<string[]>([
"no",
"citizenId",
@ -126,227 +124,286 @@ const columns2 = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const selected = ref<[]>([]);
const commandType = ref<string>(""); //
const commandMainOp = ref<ListCommand[]>([]); //
const commandOp = ref<ListCommand[]>([]); //
const modalCommand = ref<boolean>(false);
/**
* ไปหนารายละเอยดทเลอก
* @param item
* @param id รายการทองการดรายละเอยด
*/
function pageNext(item: any) {
props.nextPage?.(item?.id);
function pageNext(id: string) {
props.nextPage?.(id);
}
/**
* ปเดท filter
*/
function updateInput(value: any) {
/** อัปเดท filter*/
function updateInput(value: string) {
emit("update:filterKeyword2", value);
}
/**
* เซตคาในชองคนหา
*/
/** รีเซ็ตค่าในช่องค้นหา*/
function Reset() {
emit("update:filterKeyword2", "");
}
/**
* นยนสงไปออกคำส
*/
/** ยืนยันส่งไปออกคำสั่ง*/
function sendToCommand() {
dialogConfirm($q, async () => {
let pId: string[] = [];
let Type = props.type as string;
selected.value.forEach((e: UserDataNew) => {
pId.push(e.id);
});
let data = {
id: pId,
};
showLoader();
await http
.put(config.API.apppointmentReport(Type), data)
.then(async () => {
await props.fetchData?.();
await props.clickClose?.();
await success($q, "บันทึกสำเร็จ");
selected.value = [];
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
modalCommand.value = true;
await props.clickClose?.();
});
}
/** ฟังก์ชันเลือกประเภทคำสั่ง */
function filterSelectOrder() {
const data = props.rows2 ? props.rows2 : [];
selected.value = [];
rows.value = data.filter((v: PersonData) => {
switch (commandType.value) {
case "C-PM-05":
return v.typeCommand === "APPOINT";
case "C-PM-39":
return v.typeCommand === "SLIP";
case "C-PM-07":
return v.typeCommand === "MOVE";
default:
return [];
}
});
}
/**
* ลเตอร คำส
* @param val าจาก Input
* @param update Funtion quasar
*/
function filterSelector(val: string, update: Function) {
update(() => {
commandType.value = val ? "" : commandType.value;
commandOp.value = commandMainOp.value.filter(
(v: ListCommand) => v.name.indexOf(val) > -1
);
});
}
/**
* เม props.modal เป true
*
* กำหนดให selected เปนคาวาง
*/
watch(
() => props.Modal,
() => {
async () => {
if (props.Modal === true) {
rows.value = props.rows2 ? props.rows2 : [];
selected.value = [];
commandType.value = "";
const data = await storeCommand.getCommandTypes();
commandMainOp.value = data.filter(
(e: ListCommand) =>
e.code === "C-PM-05" || e.code === "C-PM-39" || e.code === "C-PM-07"
);
}
}
);
</script>
<template>
<q-dialog v-model="props.Modal">
<q-card style="width: 1200px; max-width: 80vw">
<DialogHeader :tittle="'ส่งไปออกคำสั่ง'" :close="clickClose" />
<q-separator />
<q-card-section>
<div class="row justify-between">
<div class="col-5"></div>
<div class="col-5">
<q-toolbar style="padding: 0">
<q-input
borderless
outlined
dense
debounce="300"
:model-value="filterKeyword2"
@update:model-value="updateInput"
placeholder="ค้นหา"
style="width: 850px; max-width: auto"
>
<template v-slot:append>
<q-icon v-if="filterKeyword2 == ''" name="search" />
<q-icon
v-if="filterKeyword2 !== ''"
name="clear"
class="cursor-pointer"
@click="Reset"
/>
</template>
</q-input>
<q-form greedy @submit.prevent @validation-success="sendToCommand">
<DialogHeader :tittle="'ส่งไปออกคำสั่ง'" :close="clickClose" />
<q-separator />
<q-card-section>
<div class="row q-col-gutter-sm">
<div class="row col-12">
<q-select
v-model="visibleColumns2"
multiple
outlined
v-model="commandType"
dense
options-dense
:display-value="$q.lang.table.columns"
outlined
label="ประเภทคำสั่ง"
:options="commandOp"
option-label="name"
option-value="code"
emit-value
map-options
:options="columns2"
option-value="name"
options-cover
style="min-width: 150px"
class="gt-xs q-ml-sm"
/>
</q-toolbar>
</div>
</div>
<d-table
:columns="columns2"
:rows="rows2"
:filter="filterKeyword2"
row-key="profileId"
flat
:visible-columns="visibleColumns2"
selection="multiple"
v-model:selected="selected"
>
<template v-slot:header-selection="scope">
<q-checkbox
keep-color
color="primary"
dense
v-model="scope.selected"
/>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td auto-width>
<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"
@click="pageNext(props.row)"
use-input
style="width: 350px; max-width: auto"
@update:model-value="filterSelectOrder"
@filter="(inputValue:string,
doneFn:Function) => filterSelector(inputValue, doneFn
) "
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'fullname'">
{{
props.row.firstName
? `${props.row.prefix ?? ""}${
props.row.firstName ?? ""
} ${props.row.lastName ?? ""}`
: "-"
}}
</div>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
<q-space />
<div class="row q-col-gutter-sm">
<q-input
borderless
outlined
dense
debounce="300"
:model-value="filterKeyword2"
@update:model-value="updateInput"
placeholder="ค้นหา"
>
<template v-slot:append>
<q-icon v-if="filterKeyword2 == ''" name="search" />
<q-icon
v-if="filterKeyword2 !== ''"
name="clear"
class="cursor-pointer"
@click="Reset"
/>
</template>
</q-input>
<q-select
v-model="visibleColumns2"
multiple
outlined
dense
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns2"
option-value="name"
options-cover
style="min-width: 150px"
/>
</div>
</div>
<div v-else-if="col.name == 'status'">
{{ props.row.status ? statusText(props.row.status) : "-" }}
</div>
<div v-else-if="col.name == 'dateOfBirth'">
{{
props.row.dateOfBirth
? date2Thai(props.row.dateOfBirth)
: "-"
}}
</div>
<div v-else-if="col.name == 'organizationName'">
<div class="col-4">
<div class="text-weight-medium">
{{ props.row.root !== null ? props.row.root : "-" }}
{{
props.row.rootShortName !== null
? `(${props.row.rootShortName})`
: ""
}}
</div>
<div class="text-weight-light">
{{
props.row.nodeName !== null ? props.row.nodeName : ""
}}
{{
props.row.nodeShortName !== null
? `(${props.row.nodeShortName}${props.row.posMasterNo})`
: ""
}}
</div>
</div>
</div>
<div v-else-if="col.name == 'createdAt'">
{{
props.row.createdAt ? date2Thai(props.row.createdAt) : "-"
}}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
label="ส่งไปออกคำสั่ง"
@click="sendToCommand"
color="public"
:disable="selected.length === 0"
>
<q-tooltip>งไปออกคำส</q-tooltip>
</q-btn>
</q-card-actions>
<div class="col-12">
<d-table
:columns="columns2"
:rows="rows"
:filter="filterKeyword2"
row-key="profileId"
flat
:visible-columns="visibleColumns2"
selection="multiple"
v-model:selected="selected"
>
<template v-slot:header-selection="scope">
<q-checkbox
keep-color
color="primary"
dense
v-model="scope.selected"
/>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td auto-width>
<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"
@click="pageNext(props.row.id)"
>
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'fullname'">
{{
props.row.firstName
? `${props.row.prefix ?? ""}${
props.row.firstName ?? ""
} ${props.row.lastName ?? ""}`
: "-"
}}
</div>
<div v-else-if="col.name == 'status'">
{{
props.row.status ? statusText(props.row.status) : "-"
}}
</div>
<div v-else-if="col.name == 'dateOfBirth'">
{{
props.row.dateOfBirth
? date2Thai(props.row.dateOfBirth)
: "-"
}}
</div>
<div v-else-if="col.name == 'organizationName'">
<div class="col-4">
<div class="text-weight-medium">
{{ props.row.root !== null ? props.row.root : "-" }}
{{
props.row.rootShortName !== null
? `(${props.row.rootShortName})`
: ""
}}
</div>
<div class="text-weight-light">
{{
props.row.nodeName !== null
? props.row.nodeName
: ""
}}
{{
props.row.nodeShortName !== null
? `(${props.row.nodeShortName}${props.row.posMasterNo})`
: ""
}}
</div>
</div>
</div>
<div v-else-if="col.name == 'createdAt'">
{{
props.row.createdAt
? date2Thai(props.row.createdAt)
: "-"
}}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
label="ส่งไปออกคำสั่ง"
type="submit"
color="public"
:disable="selected.length === 0 || commandType === ''"
>
<q-tooltip>งไปออกคำส</q-tooltip>
</q-btn>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
<!-- dialog สรางคำส -->
<DialogCreateCommand
v-model:modal="modalCommand"
:command-type-code="commandType"
:persons-id="selected.map((r) => r.id)"
/>
</template>