From be3ccc205922d50e6a97b575b1b33ffbadfd8300 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Tue, 30 Jan 2024 13:26:41 +0700 Subject: [PATCH] pop up --- .../components/DialogFormPosition.vue | 774 ++++++++++++++---- .../components/StructureDetail.vue | 4 +- .../interface/index/Main.ts | 25 +- 3 files changed, 647 insertions(+), 156 deletions(-) diff --git a/src/modules/02_organizationalNew/components/DialogFormPosition.vue b/src/modules/02_organizationalNew/components/DialogFormPosition.vue index 78381a629..dafa9c308 100644 --- a/src/modules/02_organizationalNew/components/DialogFormPosition.vue +++ b/src/modules/02_organizationalNew/components/DialogFormPosition.vue @@ -8,6 +8,9 @@ import type { FormDataPosition, FormPositionRef, DataOption, + FormPositionSelect, + RowDetailPositions, + ListMenu, } from "@/modules/02_organizationalNew/interface/index/Main"; const props = defineProps({ @@ -15,23 +18,56 @@ const props = defineProps({ close: Function, }); +const isReadonly = ref(false); // อ่านได้อย่างเดียว const $q = useQuasar(); const mixin = useCounterMixin(); const { dialogConfirm } = mixin; +const selected = ref([]); +const search = ref(""); +const type = ref("positionName"); +const typeOps = ref([ + { id: "positionName", name: "ตำแหน่งในสายงาน" }, + { id: "positionField", name: "สายงาน" }, + { id: "positionType", name: "ประเภทตำแหน่ง" }, + { id: "positionLevel", name: "ระดับตำแหน่ง" }, + { id: "positionExecutive", name: "ตำแหน่งทางการบริหาร" }, + { id: "positionExecutiveField", name: "ด้านทางการบริหาร" }, + { id: "positionArea", name: "ด้าน/สาขา" }, +]); -const rows = ref([]); +const listMenu = ref([ + { + label: "คัดลอก", + icon: "mdi-content-copy", + type: "copy", + color: "orange", + }, +]); + +const rows = ref([]); +const rowsPositionSelect = ref([]); const ocLevelOp = ref([]); const prefixNoRef = ref(null); const positionNoRef = ref(null); const formData = reactive({ + shortName: "สกจ.", prefixNo: "", positionNo: "", suffixNo: "", confirm: false, }); +const formPositionSelect = reactive({ + positionName: "", + positionField: "", + positionType: "", + positionLevel: "", + positionExecutive: "", + positionExecutiveField: "", + positionArea: "", +}); /** maping ref เข้าตัวแปรเพื่อเตรียมตรวจสอบ */ const objectPositionRef: FormPositionRef = { prefixNo: prefixNoRef, @@ -39,60 +75,89 @@ const objectPositionRef: FormPositionRef = { }; const columns = ref([ - { - name: "no", - align: "left", - label: "ลำดับ", - sortable: false, - field: "no", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "positionType", - align: "left", - label: "ประเภทตำเเหน่ง", - sortable: true, - field: "positionType", - 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: "positionAdmin", - align: "left", - label: "ตำแหน่งทางการบริหาร", - sortable: true, - field: "positionAdmin", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "other", - align: "left", - label: "ฯลฯ", - sortable: true, - field: "other", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - - ]); - const visibleColumns = ref([ - "no", - "positionType", - "positionLevel", - "positionAdmin", - "other", - ]); + { + name: "no", + align: "left", + label: "ลำดับ", + sortable: false, + field: "no", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionName", + align: "left", + label: "ตำแหน่งในสายงาน", + sortable: true, + field: "positionName", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionField", + align: "left", + label: "สายงาน", + sortable: true, + field: "positionField", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionType", + align: "left", + label: "ประเภทตำเเหน่ง", + sortable: true, + field: "positionType", + 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: "positionExecutive", + align: "left", + label: "ตำแหน่งทางการบริหาร", + sortable: true, + field: "positionExecutive", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionExecutiveField", + align: "left", + label: "ด้านทางการบริหาร", + sortable: true, + field: "positionExecutiveField", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "positionArea", + align: "left", + label: "ด้าน/สาขา", + sortable: true, + field: "positionArea", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, +]); +const visibleColumns = ref([ + "no", + "positionName", + "positionField", + "positionType", + "positionLevel", + "positionExecutive", + "positionExecutiveField", + "positionArea", +]); /** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */ function validateForm() { @@ -112,27 +177,120 @@ function validateForm() { } } +/** ฟังก์ชั่นตรวจสอบความถูกต้องของข้อมูลในฟอร์ม */ +function validateFormPositionEdit() { + // const hasError = []; + // for (const key in objectPositionRef) { + // if (Object.prototype.hasOwnProperty.call(objectPositionRef, key)) { + // const property = objectPositionRef[key]; + // if (property.value && typeof property.value.validate === "function") { + // const isValid = property.value.validate(); + // hasError.push(isValid); + // } + // } + // } + // if (hasError.every((result) => result === true)) { + onSubmitSelectEdit(); + // } else { + // } +} + /** ฟังชั่น บันทึก */ function onSubmit() { dialogConfirm($q, () => { console.log(formData); }); } +/** ฟังชั่น บันทึก */ +function onSubmitSelectEdit() { + dialogConfirm($q, () => { + console.log(formPositionSelect); + }); +} + +/** update เมื่อเปลี่ยน option */ +function updateSelect() { + search.value = ""; +} + +/** input ค้นหา */ +const searchRef = ref(null); +async function searchInput() { + searchRef.value.validate(); + if (!searchRef.value.hasError) { + // จำลอง + const dataList = [ + { + positionName: "test1", + positionField: "test1", + positionType: "test1", + positionLevel: "test1", + positionExecutive: "test1", + positionExecutiveField: "test1", + positionArea: "test1", + }, + { + positionName: "test2", + positionField: "test2", + positionType: "test2", + positionLevel: "test2", + positionExecutive: "test2", + positionExecutiveField: "test2", + positionArea: "test2", + }, + { + positionName: "test3", + positionField: "test3", + positionType: "test3", + positionLevel: "test3", + positionExecutive: "test3", + positionExecutiveField: "test3", + positionArea: "test3", + }, + ]; + rowsPositionSelect.value = dataList; + } +} + +/** + * คัดลอกข้อมูล + * @param data ข้อมูลตำแหน่ง + */ +function copyDetiail(data: RowDetailPositions) { + formPositionSelect.positionName = data.positionName; + formPositionSelect.positionField = data.positionField; + formPositionSelect.positionType = data.positionType; + formPositionSelect.positionLevel = data.positionLevel; + formPositionSelect.positionExecutive = data.positionExecutive; + formPositionSelect.positionExecutiveField = data.positionExecutiveField; + formPositionSelect.positionArea = data.positionArea; +} + +/** + * ส่งค่า css ออกไปตามเงื่อนไข + * @param val true/false + */ +function inputEdit(val: boolean) { + return { + "full-width cursor-pointer inputgreen ": val, + "full-width cursor-pointer inputgreen": !val, + }; +} watch( () => props.modal, () => { if (props.modal === true) { - ocLevelOp.value = [ - { - id: "id1", - name: "id1", - }, - { - id: "id2", - name: "id2", - }, - ]; + } + } +); +watch( + () => selected.value, + () => { + if (selected.value.length > 0) { + rows.value = selected.value; + } else { + rows.value = []; } } ); @@ -140,101 +298,411 @@ watch(