clone code

This commit is contained in:
Kittapath 2023-06-01 12:54:58 +07:00
parent c9597d1e38
commit d57bcd1719
362 changed files with 104804 additions and 0 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,90 @@
<template>
<q-card-actions class="text-primary">
<q-space />
<q-btn
v-if="!editvisible"
flat
round
:disabled="editvisible"
:color="editvisible ? 'grey-7' : 'primary'"
@click="edit"
icon="mdi-pencil-outline"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<div v-else>
<!-- <q-btn
flat
round
:disabled="!editvisible"
:outline="!editvisible"
:color="!editvisible ? 'grey-7' : 'red'"
@click="cancel()"
icon="mdi-undo"
v-if="modalEdit == true"
>
<q-tooltip>ยกเล</q-tooltip>
</q-btn> -->
<q-btn
flat
round
:disabled="!editvisible"
:color="!editvisible ? 'grey-7' : 'public'"
@click="checkSave"
icon="mdi-content-save-outline"
>
<q-tooltip>นท</q-tooltip>
</q-btn>
</div>
</q-card-actions>
</template>
<script setup lang="ts">
import { ref, useAttrs } from "vue";
const props = defineProps({
editvisible: Boolean,
modalEdit: Boolean,
cancel: {
type: Function,
default: () => console.log("not function"),
},
edit: {
type: Function,
default: () => console.log("not function"),
},
save: {
type: Function,
default: () => console.log("not function"),
},
validate: {
type: Function,
default: () => console.log("not function"),
},
});
const emit = defineEmits([
"update:editvisible",
"update:next",
"update:previous",
]);
const updateEdit = (value: Boolean) => {
emit("update:editvisible", value);
};
const cancel = async () => {
props.cancel();
};
const edit = async () => {
updateEdit(!props.editvisible);
props.edit();
};
const checkSave = () => {
props.validate();
props.save();
// if (myForm.value !== null) {
// myForm.value.validate().then((success) => {
// if (success) {
// }
// });
// }
};
</script>

View file

@ -0,0 +1,27 @@
<template>
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold">{{ tittle }}</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="close"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
</template>
<script setup lang="ts">
import { ref, useAttrs } from "vue";
const props = defineProps({
tittle: String,
close: {
type: Function,
default: () => console.log("not function"),
},
});
const close = async () => {
props.close();
};
</script>

View file

@ -0,0 +1,221 @@
<template>
<div class="q-pb-sm row">
<div class="flex items-center">
<q-btn
size="12px"
v-if="!editvisible"
flat
round
:disabled="editvisible"
:color="editvisible ? 'grey-7' : 'primary'"
@click="clickEdit"
icon="mdi-pencil-outline"
>
<q-tooltip>แกไขขอม</q-tooltip>
</q-btn>
<q-btn
size="12px"
flat
round
v-if="editvisible"
:disabled="!editvisible"
:color="!editvisible ? 'grey-7' : 'add'"
@click="checkAdd"
icon="mdi-plus"
>
<q-tooltip>เพมขอม</q-tooltip>
</q-btn>
<q-btn
size="12px"
flat
round
v-if="editvisible"
:disabled="!editvisible"
:color="!editvisible ? 'grey-7' : 'red'"
@click="clickCancel"
icon="mdi-undo"
>
<q-tooltip>ยกเล</q-tooltip>
</q-btn>
<q-space />
</div>
<q-space />
<div class="items-center" style="display: flex">
<!-- นหาขอความใน table -->
<q-input
standout
dense
:model-value="inputfilter"
ref="filterRef"
@update:model-value="updateInput"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
class="q-ml-sm"
>
<template v-slot:append>
<q-icon v-if="inputfilter == ''" name="search" />
<q-icon
v-if="inputfilter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<!-- แสดงคอลมนใน table -->
<q-select
:model-value="inputvisible"
@update:model-value="updateVisible"
:display-value="$q.lang.table.columns"
multiple
outlined
dense
:options="attrs.columns"
options-dense
option-value="name"
map-options
emit-value
style="min-width: 150px"
class="gt-xs q-ml-sm"
/>
</div>
</div>
<q-table
ref="table"
flat
bordered
class="custom-header-table"
v-bind="attrs"
virtual-scroll
:virtual-scroll-sticky-size-start="48"
dense
:pagination-label="paginationLabel"
:pagination="initialPagination"
:rows-per-page-options="[0]"
>
<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-th auto-width v-if="history == true" />
</q-tr>
</template>
<template #body="props">
<slot v-bind="props" name="columns"></slot>
</template>
</q-table>
</template>
<script setup lang="ts">
import { ref, useAttrs } from "vue";
import type { Pagination } from "@/modules/04_registry/interface/index/Main";
const attrs = ref<any>(useAttrs());
const table = ref<any>(null);
const filterRef = ref<any>(null);
const editvisible = ref<boolean>(false);
const initialPagination = ref<Pagination>({
// descending: false,
rowsPerPage: 0,
});
const props = defineProps({
inputfilter: String,
inputvisible: Array,
editvisible: Boolean,
history: Boolean,
edit: {
type: Function,
default: () => console.log("not function"),
},
add: {
type: Function,
default: () => console.log("not function"),
},
cancel: {
type: Function,
default: () => console.log("not function"),
},
});
const emit = defineEmits([
"update:inputfilter",
"update:inputvisible",
"update:editvisible",
]);
const updateEdit = (value: Boolean) => {
emit("update:editvisible", value);
};
const updateInput = (value: string | number | null) => {
emit("update:inputfilter", value);
};
const updateVisible = (value: []) => {
emit("update:inputvisible", value);
};
const paginationLabel = (start: string, end: string, total: string) => {
return start + "-" + end + " ใน " + total;
};
const checkAdd = () => {
props.add();
};
const clickEdit = () => {
updateEdit(!props.editvisible);
editvisible.value = !editvisible.value;
props.edit();
};
const clickCancel = () => {
updateEdit(!props.editvisible);
editvisible.value = !editvisible.value;
props.cancel();
};
const resetFilter = () => {
// reset X
emit("update:inputfilter", "");
filterRef.value.focus();
};
</script>
<style lang="scss">
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 64vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -0,0 +1,215 @@
<template>
<div class="q-px-md q-pb-md">
<div class="col-12 row q-pb-sm items-center q-col-gutter-sm">
<q-btn
size="14px"
color="grey-7"
dense
flat
round
@click="onTab"
class="shadow-1"
icon="chevron_right"
v-if="!isTab"
>
<q-tooltip>เป</q-tooltip>
</q-btn>
<q-btn
size="14px"
dense
flat
round
color="primary"
@click="onConfirm"
icon="assignment_turned_in"
>
<q-tooltip>นยนเพอเอาไปออกคำส</q-tooltip>
</q-btn>
<q-btn
size="14px"
dense
flat
round
color="info"
icon="mdi-history"
@click="onHistory"
>
<q-tooltip>ประว</q-tooltip>
</q-btn>
<q-space />
<!-- นหาขอความใน table -->
<q-input
standout
dense
:model-value="inputfilter"
ref="filterRef"
@update:model-value="updateInput"
outlined
debounce="300"
placeholder="ค้นหา"
style="max-width: 200px"
>
<template v-slot:append>
<q-icon v-if="inputfilter == ''" name="search" />
<q-icon
v-if="inputfilter !== ''"
name="clear"
class="cursor-pointer"
@click="resetFilter"
/>
</template>
</q-input>
<!-- แสดงคอลมนใน table -->
<q-select
:model-value="inputvisible"
@update:model-value="updateVisible"
:display-value="$q.lang.table.columns"
multiple
outlined
dense
:options="attrs.columns"
options-dense
option-value="name"
map-options
emit-value
style="min-width: 150px"
class="gt-xs"
/>
</div>
<q-table
ref="table"
flat
bordered
class="custom-header-table"
v-bind="attrs"
virtual-scroll
:virtual-scroll-sticky-size-start="48"
dense
:pagination-label="paginationLabel"
:pagination="initialPagination"
:rows-per-page-options="paging == true ? [25, 50, 100, 500] : []"
>
<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-th auto-width v-if="delect == true" />
</q-tr>
</template>
<template #body="props">
<slot v-bind="props" name="columns"></slot>
</template>
</q-table>
</div>
</template>
<script setup lang="ts">
import { ref, useAttrs } from "vue";
const attrs = ref<any>(useAttrs());
const table = ref<any>(null);
const filterRef = ref<any>(null);
const props = defineProps({
inputfilter: String,
inputvisible: Array,
addvisible: Boolean,
delect: {
type: Boolean,
defualt: false,
},
paging: {
type: Boolean,
defualt: false,
},
isTab: {
type: Boolean,
default: true,
},
onTab: {
type: Function,
default: () => console.log("not function"),
},
onConfirm: {
type: Function,
default: () => console.log("not function"),
},
onHistory: {
type: Function,
default: () => console.log("not function"),
},
add: {
type: Function,
default: () => console.log("not function"),
},
});
const emit = defineEmits(["update:inputfilter", "update:inputvisible"]);
const updateVisible = (value: any) => {
emit("update:inputvisible", value);
};
const updateInput = (value: any) => {
emit("update:inputfilter", value);
};
const onConfirm = () => {
props.onConfirm();
};
const onHistory = () => {
props.onHistory();
};
const onTab = () => {
props.onTab();
};
const checkAdd = () => {
props.add();
};
const initialPagination = ref<any>({
// descending: false,
rowsPerPage: props.paging == true ? 25 : 0,
});
const paginationLabel = (start: string, end: string, total: string) => {
if (props.paging == true)
return " " + start + " ใน " + end + " จากจำนวน " + total + " รายการ";
else return start + "-" + end + " ใน " + total;
};
const resetFilter = () => {
emit("update:inputfilter", "");
filterRef.value.focus();
};
</script>
<style lang="scss">
.icon-color {
color: #4154b3;
}
.custom-header-table {
max-height: 80vh;
.q-table tr:nth-child(odd) td {
background: white;
}
.q-table tr:nth-child(even) td {
background: #f8f8f8;
}
.q-table thead tr {
background: #ecebeb;
}
.q-table thead tr th {
position: sticky;
z-index: 1;
}
/* this will be the loading indicator */
.q-table thead tr:last-child th {
/* height of all previous header rows */
top: 48px;
}
.q-table thead tr:first-child th {
top: 0;
}
}
</style>

View file

@ -0,0 +1,444 @@
<!-- =============================== -->
<!-- component เพ/แกไข ตำแหน ของ โครงสรางอตรากำล -->
<!-- เปนช q-select(dropdown) ใชในการ mapping ตำแหนงกบโครงสราง -->
<!-- เพอสราง โครงสรางตำแหน ใหมใน DB -->
<!-- Call API to fill all dropdown list -->
<!-- แกไขไมองมจำนวน จะแก 1:1 check เรองการสงคาด -->
<!-- =============================== -->
<template>
<div v-if="isAddNew" class="row col-12 items-center q-pt-md">
<div class="bg-white q-px-sm topCard">
<span class="text-weight-medium">เพมตำแหน</span>
<q-btn
flat
color="primary"
size="12px"
icon="mdi-plus"
dense
class="q-mx-sm"
@click="addPositionItem()"
>
<q-tooltip>เพมตำแหน</q-tooltip>
</q-btn>
</div>
</div>
<!-- การดเพมตำแหน-->
<q-form ref="myForm">
<div v-if="!isAddNew">
<div v-for="(item, index) in positions" :key="index">
<q-select
dense
outlined
v-model="item.positionMasterId"
:options="position"
label="ตำแหน่ง"
class="col-xs-9 col-sm-6 col-md-8"
use-input
input-debounce="0"
@filter="filterFn"
hide-bottom-space
option-label="positionPath"
option-value="id"
map-options
emit-value
clearable
:rules="[(val:any) => !!val || `${'กรุณาเลือกตำแหน่ง'}`]"
>
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<q-item-section>
<q-item-label>{{ scope.opt.positionPath }}</q-item-label>
<q-item-label caption>
<q-icon
class="q-mr-sm"
size="15px"
color="primary"
name="mdi-bookmark"
v-if="scope.opt.isDirector"
></q-icon>
{{ scope.opt.positionExecutive }}
{{ scope.opt.positionExecutiveSide }}
{{ scope.opt.positionLevel }}
{{ scope.opt.positionLine }}
{{ scope.opt.positionPathSide }}
{{ scope.opt.positionType }}
</q-item-label>
</q-item-section>
</q-item>
</template>
<template v-slot:selected-item="scope">
<q-chip dense square class="q-my-none q-ml-xs q-mr-none">
{{ scope.opt.positionPath }}
</q-chip>
<q-item-label caption>
<q-icon
class="q-mr-sm"
size="15px"
color="primary"
name="mdi-bookmark"
v-if="scope.opt.isDirector"
></q-icon>
{{ scope.opt.positionExecutive }}
{{ scope.opt.positionExecutiveSide }}
{{ scope.opt.positionLevel }}
{{ scope.opt.positionLine }}
{{ scope.opt.positionPathSide }}
{{ scope.opt.positionType }}
</q-item-label>
</template>
<template v-slot:no-option>
<ddNoResultMsg />
</template>
</q-select>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-input
:class="getClass(true)"
hide-bottom-space
:outlined="true"
dense
lazy-rules
:readonly="false"
:borderless="false"
v-model="item.positionUserNote"
:label="`${'หมายเหตุ'}`"
type="textarea"
/>
<!-- :rules="[(val) => !!val || `${'กรุณากรอกเงื่อนไขตำแหน่ง'}`]" -->
</div>
</div>
</div>
<q-card v-else bordered flat class="q-py-sm">
<q-card
flat
class="bg-grey-2 q-pa-sm q-ma-sm row col-12"
v-for="(item, index) in positions"
:key="index"
>
<div class="col-12 row items-center q-col-gutter-xs">
<div>
<q-avatar
class="q-mr-sm"
size="25px"
color="grey-3"
text-color="grey-9"
>{{ index + 1 }}</q-avatar
>
</div>
<q-btn
flat
round
color="red"
size="10px"
class="q-mr-sm"
icon="mdi-trash-can-outline"
dense
@click="deletePositionItem(item)"
/>
<!-- label="ตำแหน่ง" -->
<q-select
dense
outlined
v-model="item.positionMasterId"
:options="position"
label="ตำแหน่ง"
class="col-xs-9 col-sm-6 col-md-8"
use-input
input-debounce="0"
@filter="filterFn"
hide-bottom-space
option-label="positionPath"
option-value="id"
map-options
emit-value
clearable
:rules="[(val:any) => !!val || `${'กรุณาเลือกตำแหน่ง'}`]"
>
<template v-slot:option="scope">
<q-item v-bind="scope.itemProps">
<q-item-section>
<q-item-label>{{ scope.opt.positionPath }}</q-item-label>
<q-item-label caption>
<q-icon
class="q-mr-sm"
size="15px"
color="primary"
name="mdi-bookmark"
v-if="scope.opt.isDirector"
></q-icon>
{{ scope.opt.positionExecutive }}
{{ scope.opt.positionExecutiveSide }}
{{ scope.opt.positionLevel }}
{{ scope.opt.positionLine }}
{{ scope.opt.positionPathSide }}
{{ scope.opt.positionType }}
</q-item-label>
</q-item-section>
</q-item>
</template>
<template v-slot:selected-item="scope">
<q-chip dense square class="q-my-none q-ml-xs q-mr-none">
{{ scope.opt.positionPath }}
</q-chip>
<q-item-label caption>
<q-icon
class="q-mr-sm"
size="15px"
color="primary"
name="mdi-bookmark"
v-if="scope.opt.isDirector"
></q-icon>
{{ scope.opt.positionPathSide }}
{{ scope.opt.positionExecutive }}
{{ scope.opt.positionLevel }}
{{ scope.opt.positionLine }}
<!-- {{ scope.opt.positionType }}
{{ scope.opt.positionExecutiveSide }} -->
</q-item-label>
</template>
<template v-slot:no-option>
<ddNoResultMsg />
</template>
</q-select>
<q-input
dense
outlined
v-model.number="item.count"
class="col-xs-3 col-sm-2 col-md-2"
type="number"
hide-bottom-space
label="จำนวน"
:rules="[(val:any) => val > 0 || `${'ต้องมากกว่า 0'}`]"
/>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-input
:class="getClass(true)"
hide-bottom-space
:outlined="true"
dense
lazy-rules
:readonly="false"
:borderless="false"
v-model="item.positionUserNote"
:label="`${'หมายเหตุ'}`"
type="textarea"
/>
<!-- :rules="[(val) => !!val || `${'กรุณากรอกเงื่อนไขตำแหน่ง'}`]" -->
</div>
</div>
</q-card>
</q-card>
</q-form>
</template>
<script setup lang="ts">
import { ref, defineAsyncComponent, watch, onMounted } from "vue";
import { useQuasar, QForm } from "quasar";
import type { PropType } from "vue";
import { useDataStore } from "@/stores/data";
import http from "@/plugins/http";
import config from "@/app.config";
import type { DataOption } from "../../interface/index/Main";
const ddNoResultMsg = defineAsyncComponent(
() => import("@/components/DropDownNoResultMsg.vue")
); // Dropdown Filter
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const $q = useQuasar(); // show dialog
const emit = defineEmits(["update:positions", "update:formprops"]);
const props = defineProps({
positions: Array,
formprops: QForm as PropType<QForm | null>,
isAddNew: {
type: Boolean,
required: true,
// default: true,
},
editObj: Object, //FE rowClickTree
});
const myForm = ref<QForm | null>(null);
watch(myForm, (form: QForm | null, prevForm: QForm | null) => {
if (!props.isAddNew) {
positions.value.push(JSON.parse(JSON.stringify(positionSet.value)));
if (!props.editObj != null && !props.editObj != undefined) {
// console.log("position.value", position.value);
// console.log("props.editObj", props.editObj);
positions.value[0].positionMasterId = props.editObj?.positionMasterId;
positions.value[0].positionUserNote = props.editObj?.positionUserNote;
}
}
emit("update:formprops", form);
});
const positions = ref<Array<any>>([]); //Array positionSet Array<object> html
const positionSet = ref<object>({
count: 1, //
positionMasterId: "", // Table PositionMaster ,
positionUserNote: "",
}); // Drop Down key API
emit("update:positions", positions.value);
const positionFilter = ref<Array<any>>([]); //for DropDown
const position = ref<Array<any>>([]); //for DropDown
onMounted(async () => {
loaderPage(false);
await fetchPositionMaster();
});
const fetchPositionMaster = async () => {
loaderPage(true);
await http
// .get(config.API.getPostionMasterDraft(false))
.get(config.API.getPostionMaster(false))
.then((res) => {
// console.log("psMaster:", res.data.result);
res.data.result.map((e: any) => {
positionFilter.value.push({
id: e.id,
isActive: e.isActive,
positionType: e.positionType,
positionLine: e.positionLine,
positionPath: e.positionPath,
positionPathSide: e.positionPathSide,
positionExecutive: e.positionExecutive,
positionExecutiveSide: e.positionExecutiveSide,
positionLevel: e.positionLevel.toString(),
positionStatus: e.positionStatus,
positionTypeId: e.positionTypeId,
positionMasterId: e.positionMasterId,
positionLineId: e.positionLineId,
positionPathId: e.positionPathId,
positionPathSideId: e.positionPathSideId,
positionExecutiveId: e.positionExecutiveId,
positionExecutiveSideId: e.positionExecutiveSideId,
positionLevelId: e.positionLevelId,
positionStatusId: e.positionStatusId,
positionCondition: e.positionCondition,
positionMasterUserNote: e.positionMasterUserNote,
isDirector: e.isDirector,
});
position.value = positionFilter.value;
});
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**Fuction Filter DropDown
* q-select งคามาใหเองจาก @filter="filterFn"
* @param val าตวพมพนหา
* @param update กครงทมพ
*/
const filterFn = (val: string, update: any) => {
if (val === "") {
update(() => {
position.value = positionFilter.value;
//
// here you have access to "ref" which
// is the Vue reference of the QSelect
});
return;
}
update(() => {
position.value = positionFilter.value.filter(
(v: any) => v.positionPath != null && v.positionPath.indexOf(val) > -1
);
});
// console.log(positions.value);
};
/**Add new positionSet item into positions
*กรอกขอมลสำคญครบถงเพ ตำแหน ใหมได
*อมลไมครบแสดง Alert เตอนใหเฉยๆ แลวไมใหเพ
*/
const addPositionItem = () => {
// console.log(positions.value);
myForm.value!.validate().then((result) => {
if (result) {
positions.value.push(JSON.parse(JSON.stringify(positionSet.value)));
// positions.value.push(ref<any>(positionSet.value));
emit("update:positions", positions.value);
} else {
// pop-up user
console.log("validation fail");
}
});
};
/**Delete positionSet item from positions
* ลบตำแหนงตวทกดลบ
* @param val data ใน item จะลบ
*/
const deletePositionItem = (val: object) => {
//Check if val is completed before delete
// filter array [val]
if (!isEmptyPosition([val])) {
$q.dialog({
title: "ยืนยันการลบข้อมูล",
message: "มีข้อมูลอยู่ หากต้องการลบกด ตกลง",
cancel: true,
persistent: true,
})
.onOk(() => {
// console.log(">>>> OK");
positions.value = positions.value.filter((x: object) => x !== val); //
// console.log(positions.value);
})
.onCancel(() => {
// console.log(">>>> Cancel");
})
.onDismiss(() => {
// console.log("I am triggered on both OK and Cancel");
});
} else {
positions.value = positions.value.filter((x: object) => x !== val);
}
emit("update:positions", positions.value);
};
/** Check if position is Empty
* -- return true/false
* @param items Array of position
*/
const isEmptyPosition = (items: any[]) => {
console.log("items", items);
const isEmpty = items.map((f: any) => !f.positionMasterId);
// true
// data false
console.log("isEmpty", isEmpty[0]);
return isEmpty[0];
};
/**class
* copy from AddMappingPositions
* @param val อม input สำหรบแกไขหรอไม
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script>
<style>
.text1 {
color: gray;
font-weight: 400;
padding-right: 2px;
font-size: 13px;
}
.text2 {
font-weight: 400;
padding-right: 10px;
}
</style>

View file

@ -0,0 +1,999 @@
<template>
<div>
<div class="row col-12 items-center q-pt-md">
<div class="bg-white q-px-sm topCard">
<span class="text-weight-medium">เพมหนวยงาน</span>
<q-btn
flat
color="primary"
size="12px"
icon="mdi-plus"
dense
class="q-mx-sm"
@click="addOrganizationItem()"
>
<q-tooltip>เพมหนวยงาน</q-tooltip>
</q-btn>
</div>
</div>
<!-- การดเพมหนวยงาน-->
<q-form ref="myForm">
<q-card bordered flat>
<div class="overScroll q-py-sm">
<q-card
flat
class="bg-grey-2 q-pa-sm q-ma-sm row col-12 items-start"
v-for="(item, index) in organizations"
:key="index"
>
<div>
<q-avatar
class="q-mr-sm"
size="25px"
color="grey-3"
text-color="grey-9"
>{{ index + 1 }}</q-avatar
>
</div>
<q-btn
flat
round
color="red"
size="10px"
class="q-mr-sm"
icon="mdi-trash-can-outline"
dense
@click="deleteOrgItem(item)"
/>
<!-- @update:model-value="updateGoverment" -->
<div class="col-11 row q-col-gutter-xs">
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationOrganizationId"
:options="organizationOri"
label="หน่วยงาน"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '1')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
:rules="[(val:any) => !!val || `${'กรุณาเลือกหน่วยงาน'}`]"
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationAgencyCode"
:options="organizationAgencyCode"
label="รหัสหน่วยงาน"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterCodeSelector(inputValue, doneFn, '2',item)
"
@update:model-value="(value:any) => updateGovernmentCode(value, item)"
option-label="agencyCode"
option-value="agencyCode"
map-options
emit-value
clearable
:rules="[(val:any) => !!val || `${'กรุณาเลือกรหัสหน่วยงาน'}`]"
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationGovernmentCode"
:options="item.organizationGovernmentCodeOption"
label="รหัสส่วนราชการ"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterCodeSelector(inputValue, doneFn, '3',item)
"
@update:model-value="(value:any) => updateAgencyCode(value, item)"
option-label="governmentCode"
option-value="governmentCode"
map-options
emit-value
clearable
:rules="[(val:any) => !!val || `${'กรุณาเลือกรหัสส่วนราชการ'}`]"
/>
<q-input
hide-bottom-space
dense
readonly
outlined
:modelValue="item.organizationShortName.toString() ?? ''"
label="ชื่อย่อหน่วยงาน"
class="col-xs-12 col-sm-4 col-md-3"
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationAgencyId"
:options="organizationAgency"
label="หน่วยงานต้นสังกัด"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '1')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationGovernmentAgencyId"
:options="organizationGovernmentAgency"
label="ส่วนราชการต้นสังกัด"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '1')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationTypeId"
:options="organizationType"
label="ประเภทหน่วยงาน"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '6')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
/><!-- :rules="[(val:any) => !!val || `${''}`]" -->
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationLevelId"
:options="organizationLevel"
label="ระดับหน่วยงาน"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '7')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
:rules="[(val:any) => !!val || `${'กรุณาเลือกระดับหน่วยงาน'}`]"
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationExternalPhoneId"
:options="organizationTelExternal"
label="หมายเลขโทรศัพท์ติดต่อจากภายนอก"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '8')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationInternalPhoneId"
:options="organizationTelInternal"
label="หมายเลขโทรศัพท์ติดต่อจากภายใน"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '9')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
/>
<selector
hide-bottom-space
dense
outlined
v-model="item.organizationFaxId"
:options="organizationFax"
label="หมายเลขโทรสาร"
class="col-xs-12 col-sm-4 col-md-3"
use-input
input-debounce="0"
@filter="
(inputValue:any, doneFn:Function) =>
filterSelector(inputValue, doneFn, '10')
"
option-label="name"
option-value="id"
map-options
emit-value
clearable
/>
<q-input
dense
outlined
v-model="item.agency"
class="col-xs-12 col-sm-4 col-md-3"
label="หน่วยงาน"
/>
<q-input
dense
outlined
v-model="item.government"
class="col-xs-12 col-sm-4 col-md-3"
label="ส่วนราชการ"
/>
<q-input
dense
outlined
v-model="item.department"
class="col-xs-12 col-sm-4 col-md-3"
label="ฝ่าย/ส่วน"
/>
<q-input
dense
outlined
v-model="item.pile"
class="col-xs-12 col-sm-4 col-md-3"
label="กอง"
/>
<q-input
dense
outlined
:modelValue="Number(item.organizationOrder) ?? 0"
class="col-xs-12 col-sm-4 col-md-3"
type="number"
label="ลำดับผังโครงสร้าง"
/>
<div class="col-xs-12 col-sm-12 col-md-12">
<q-input
:class="getClass(true)"
hide-bottom-space
:outlined="true"
dense
lazy-rules
:readonly="false"
:borderless="false"
v-model="item.organizationUserNote"
:label="`${'หน้าที่รับผิดชอบ'}`"
type="textarea"
/>
<!-- :rules="[(val) => !!val || `${'กรุณากรอกเงื่อนไขตำแหน่ง'}`]" -->
</div>
</div>
</q-card>
</div>
</q-card>
</q-form>
</div>
</template>
<script setup lang="ts">
import { ref, defineAsyncComponent, watch, onMounted } from "vue";
import type { PropType } from "vue";
import { useQuasar, QForm } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type {
DataOption,
OrganizaOption,
GovermentOption,
} from "../../interface/index/Main";
import { log } from "console";
import { useDataStore } from "@/stores/data";
// import { organizationSet } from "../interface/index/Main";
const props = defineProps({
organizprops: Array as PropType<OrganizaOption[]>,
formprops: QForm as PropType<QForm | null>,
});
const emit = defineEmits(["update:organizprops", "update:formprops"]);
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const $q = useQuasar(); // show dialog
const myForm = ref<QForm | null>(null);
// const organizations = ref<OrganizaOption[]>([]);
const organizations = ref<OrganizaOption[]>([]);
emit("update:organizprops", organizations.value);
// emit("update:formprops", myForm.value);
watch(myForm, (form: QForm | null, prevForm: QForm | null) => {
emit("update:formprops", form);
});
const organizationFax = ref<DataOption[]>([]);
const organizationTelInternal = ref<DataOption[]>([]);
const organizationTelExternal = ref<DataOption[]>([]);
const organizationFaxFilter = ref<DataOption[]>([]);
const organizationTelInternalFilter = ref<DataOption[]>([]);
const organizationTelExternalFilter = ref<DataOption[]>([]);
const organizationGovernmentAgency = ref<DataOption[]>([]);
const organizationGovernmentAgencyFilter = ref<DataOption[]>([]);
const organizationAgency = ref<DataOption[]>([]);
const organizationAgencyFilter = ref<DataOption[]>([]);
const organizationType = ref<DataOption[]>([]);
const organizationTypeFilter = ref<DataOption[]>([]);
const organizationLevel = ref<DataOption[]>([]);
const organizationLevelFilter = ref<DataOption[]>([]);
const organizationOri = ref<DataOption[]>([]);
const organizationOriFilter = ref<DataOption[]>([]);
const organizationGovernmentCode = ref<GovermentOption[]>([]);
const organizationGovernmentCodeFilter = ref<GovermentOption[]>([]);
const organizationAgencyCode = ref<GovermentOption[]>([]);
const organizationAgencyCodeFilter = ref<GovermentOption[]>([]);
onMounted(async () => {
loaderPage(false);
await fetchOrganizationOri();
await fetchOrganizationAgencyCode();
await fetchOrganizationGovernmentCode();
await fetchOrganizationAgency();
await fetchOrganizationGovernmentAgency();
await fetchOrganizationType();
await fetchOrganizationLevel();
await fetchOrganizationFax();
await fetchOrganizationTelExternal();
await fetchOrganizationTelInternal();
});
/**
* หนวยงาน
*/
const fetchOrganizationOri = async () => {
loaderPage(true);
await http
.get(config.API.organization)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
organizationOri.value = option;
organizationOriFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* รหสหนวยงาน
*/
const fetchOrganizationAgencyCode = async () => {
loaderPage(true);
await http
.get(config.API.organizationCode)
.then((res) => {
const data = res.data.result;
// console.log(data);
let option: GovermentOption[] = [];
data.map((r: any) => {
option.push({
id: r.id.toString(),
governmentCode: r.governmentCode.toString(),
agencyCode: r.agencyCode.toString(),
shortName: r.name.toString(),
});
});
organizationAgencyCode.value = option;
organizationAgencyCodeFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* รหสสวนราชการ
*/
const fetchOrganizationGovernmentCode = async () => {
loaderPage(true);
await http
.get(config.API.organizationShortName)
.then((res) => {
const data = res.data.result;
// console.log(data);
let option: GovermentOption[] = [];
data.map((r: any) => {
option.push({
id: r.id.toString(),
governmentCode: r.governmentCode.toString(),
agencyCode: r.agencyCode.toString(),
shortName: r.name.toString(),
});
});
organizationGovernmentCode.value = option;
organizationGovernmentCodeFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
// /**
// *
// */
// const fetchOrganizationShortName = async () => {
// loaderPage(true);
// await http
// .get(config.API.organizationShortName)
// .then((res) => {
// const data = res.data.result;
// // console.log(data);
// let option: GovermentOption[] = [];
// data.map((r: any) => {
// option.push({
// id: r.id.toString(),
// name: r.governmentCode.toString(),
// agencyCode: r.agencyCode.toString(),
// shortName: r.name.toString(),
// });
// });
// organizationShortName.value = option;
// organizationShortNameFilter.value = option;
// })
// .catch((e) => {
// console.log(e);
// })
// .finally(() => {
// loaderPage(false);
// });
// };
/**
* หนวยงานตนสงก
*/
const fetchOrganizationAgency = async () => {
loaderPage(true);
await http
.get(config.API.listOrganizationAgency("หน่วยงาน"))
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({
id: r.organizationId.toString(),
name: r.organizationName.toString(),
});
});
organizationAgency.value = option;
organizationAgencyFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* วนราชการตนสงก
*/
const fetchOrganizationGovernmentAgency = async () => {
loaderPage(true);
await http
.get(config.API.listOrganizationAgency("ส่วนราชการ"))
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({
id: r.organizationId.toString(),
name: r.organizationName.toString(),
});
});
organizationGovernmentAgency.value = option;
organizationGovernmentAgencyFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* ประเภทหนวยงาน
*/
const fetchOrganizationType = async () => {
loaderPage(true);
await http
.get(config.API.organizationType)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
organizationType.value = option;
organizationTypeFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* ระดบหนวยงาน
*/
const fetchOrganizationLevel = async () => {
loaderPage(true);
await http
.get(config.API.organizationLevel)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
organizationLevel.value = option;
organizationLevelFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* เบอรดตอภายใน
*/
const fetchOrganizationTelInternal = async () => {
loaderPage(true);
await http
.get(config.API.organizationTelInternal)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
organizationTelInternal.value = option;
organizationTelInternalFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* เบอรดตอภายนอก
*/
const fetchOrganizationTelExternal = async () => {
loaderPage(true);
await http
.get(config.API.organizationTelExternal)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
organizationTelExternal.value = option;
organizationTelExternalFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**
* เบอรโทรสาร
*/
const fetchOrganizationFax = async () => {
loaderPage(true);
await http
.get(config.API.organizationFax)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
organizationFax.value = option;
organizationFaxFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
};
/**Delete positionSet item from positions
* ลบตำแหนงตวทกดลบ
* @param val data ใน item จะลบ
*/
const deleteOrgItem = (val: OrganizaOption) => {
//Check if val is completed before delete
// filter array [val]
if (!isEmptyOrganization([val])) {
$q.dialog({
title: "ยืนยันการลบข้อมูล",
message: "มีข้อมูลอยู่ หากต้องการลบกด ตกลง",
cancel: true,
persistent: true,
})
.onOk(() => {
// console.log(">>>> OK");
organizations.value = organizations.value.filter(
(x: object) => x !== val
); //
// console.log(positions.value);
})
.onCancel(() => {
// console.log(">>>> Cancel");
})
.onDismiss(() => {
// console.log("I am triggered on both OK and Cancel");
});
} else {
organizations.value = organizations.value.filter((x: object) => x !== val);
}
emit("update:organizprops", organizations.value);
};
/** Check if organization is Empty
* -- return true/false
* @param items Array of OrganizaOption
*/
const isEmptyOrganization = (items: OrganizaOption[]) => {
const isEmpty = items.map(
(f: OrganizaOption) =>
!f.organizationOrganizationId &&
!f.organizationShortNameId &&
!f.organizationAgencyId &&
!f.organizationGovernmentAgencyId &&
!f.organizationTypeId &&
!f.organizationLevelId &&
!f.organizationExternalPhoneId &&
!f.organizationInternalPhoneId &&
!f.organizationFaxId
);
// true
// data false
return isEmpty[0];
};
/**Add new positionSet item into positions
*กรอกขอมลสำคญครบถงเพ ตำแหน ใหมได
*อมลไมครบแสดง Alert เตอนใหเฉยๆ แลวไมใหเพ
*/
const addOrganizationItem = async () => {
await myForm.value!.validate().then(async (result: boolean) => {
// console.log(result);
if (result) {
// organizations.value.push(JSON.parse(JSON.stringify(organizationSet)));
organizations.value.push({
organizationOrganizationId: "", //
organizationShortNameId: "", // Id
organizationShortName: "", //
organizationAgencyCode: "", //
organizationGovernmentCode: "", //
organizationAgencyId: "", //
organizationGovernmentAgencyId: "", //
organizationTypeId: "", //
organizationLevelId: "", //
organizationInternalPhoneId: "", //
organizationExternalPhoneId: "", //
organizationFaxId: "", //
organizationOrder: 0, //
organizationUserNote: "", // User Note
organizationStatusId: "",
agency: "", //
government: "", //
department: "", // /
pile: "", //
organizationGovernmentCodeOption: organizationGovernmentCode.value,
organizationGovernmentCodeOptionFilter:
organizationGovernmentCodeFilter.value,
});
emit("update:organizprops", organizations.value);
// console.log(organizations);
}
});
};
const fetchAgencyCode = async (val: string, item: OrganizaOption) => {
let option: GovermentOption[] = [];
loaderPage(true);
await http
.get(config.API.organizationGovernmentCode(val))
.then((res) => {
const data = res.data.result;
data.map((r: any) => {
option.push({
id: r.id.toString(),
governmentCode: r.governmentCode.toString(),
agencyCode: r.agencyCode.toString(),
shortName: r.name.toString(),
});
});
// organizationAgencyCode.value = option;
// organizationAgencyCodeFilter.value = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
return option;
};
const fetchGovernmentCode = async (val: string, item: OrganizaOption) => {
let option: GovermentOption[] = [];
loaderPage(true);
await http
.get(config.API.organizationAgencyCode(val))
.then((res) => {
const data = res.data.result;
data.map((r: any) => {
option.push({
id: r.id.toString(),
governmentCode: r.governmentCode.toString(),
agencyCode: r.agencyCode.toString(),
shortName: r.name.toString(),
});
});
item.organizationGovernmentCodeOption = option;
item.organizationGovernmentCodeOptionFilter = option;
})
.catch((e) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
});
return option;
};
/**
* q-select งคามาใหเองจาก @update:model-value="updateShortName"
* @param val าตวทเลอก
*/
const updateAgencyCode = async (val: string, item: OrganizaOption) => {
let option = await fetchAgencyCode(val, item);
// organizationAgencyCode.value = option;
// organizationAgencyCodeFilter.value = option;
// const find = option.filter((r) => r.governmentCode === val);
// if (find.length == 1) {
item.organizationShortName = option[0].shortName.toString();
item.organizationAgencyCode = option[0].agencyCode.toString();
item.organizationGovernmentCode = option[0].governmentCode.toString();
item.organizationShortNameId = option[0].id;
// } else {
// item.organizationShortName = "";
// item.organizationAgencyCode = "";
// // item.organizationGovernmentCode = "";
// }
await fetchGovernmentCode(item.organizationAgencyCode, item);
};
/**
* q-select งคามาใหเองจาก @update:model-value="updateShortName"
* @param val าตวทเลอก
*/
const updateGovernmentCode = async (val: string, item: OrganizaOption) => {
let option = await fetchGovernmentCode(val, item);
const find = option.filter((r) => r.agencyCode === val);
if (find.length == 1) {
item.organizationShortName = find[0].shortName.toString();
item.organizationAgencyCode = find[0].agencyCode.toString();
item.organizationGovernmentCode = find[0].governmentCode.toString();
item.organizationShortNameId = find[0].id.toString();
} else {
item.organizationShortName = "";
// item.organizationAgencyCode = "";
item.organizationGovernmentCode = "";
}
};
const updateNumber = (item: OrganizaOption, newValue: any) => {
item.organizationOrder = newValue;
};
/**Fuction Filter DropDown
* q-select งคามาใหเองจาก @filter="filterSelector"
* @param val าตวพมพนหา
* @param update กครงทมพ
*/
const filterSelector = (val: any, update: Function, filtername: string) => {
switch (filtername) {
case "1":
update(() => {
organizationOri.value = organizationOriFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
// case "2":
// update(() => {
// organizationAgencyCode.value =
// organizationAgencyCodeFilter.value.filter(
// (v: GovermentOption) => v.agencyCode.indexOf(val) > -1
// );
// });
// break;
// case "3":
// update(() => {
// organizationGovernmentCode.value =
// organizationGovernmentCodeFilter.value.filter(
// (v: GovermentOption) => v.governmentCode.indexOf(val) > -1
// );
// });
// break;
case "4":
update(() => {
organizationAgency.value = organizationAgencyFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "5":
update(() => {
organizationGovernmentAgency.value =
organizationGovernmentAgencyFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "6":
update(() => {
organizationType.value = organizationTypeFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "7":
update(() => {
organizationLevel.value = organizationLevelFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "8":
update(() => {
organizationTelExternal.value =
organizationTelExternalFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "9":
update(() => {
organizationTelInternal.value =
organizationTelInternalFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
case "10":
update(() => {
organizationFax.value = organizationFaxFilter.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
break;
default:
break;
}
};
const filterCodeSelector = (
val: any,
update: Function,
filtername: string,
item: OrganizaOption
) => {
switch (filtername) {
case "2":
update(() => {
organizationAgencyCode.value =
organizationAgencyCodeFilter.value.filter(
(v: GovermentOption) => v.agencyCode.indexOf(val) > -1
);
});
break;
case "3":
update(() => {
item.organizationGovernmentCodeOption =
item.organizationGovernmentCodeOptionFilter.filter(
(v: GovermentOption) => v.governmentCode.indexOf(val) > -1
);
});
break;
}
};
/**class
* copy from AddMappingPositions
* @param val อม input สำหรบแกไขหรอไม
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
};
</script>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,232 @@
<!-- =============================== -->
<!-- Component มกด หน TreeList -->
<!-- v-model:editvisible="True/False" -->
<!-- :refreshData="clearLocalStorage Function"
:deleteDraft="clickDeleteDraft Function"
:publishDraft="clickPublish Function"
:publicData="version === 'published'" (True = Disable Buttons) -->
<!-- =============================== -->
<template>
<div>
<q-btn
v-if="!editvisible"
flat
round
:disabled="editvisible"
:color="editvisible ? 'grey-7' : 'primary'"
@click="clickEdit()"
icon="mdi-pencil-outline"
class="q-mr-sm"
>
<q-tooltip>แกไขโครงสราง</q-tooltip>
</q-btn>
<q-btn
flat
round
v-if="editvisible"
:disabled="!editvisible"
:color="!editvisible ? 'grey-7' : 'red'"
@click="clickCancel()"
icon="mdi-undo"
class="q-mr-sm"
>
<q-tooltip>ยกเล</q-tooltip>
</q-btn>
<!-- ลบบนทกราง แสดงเม นทกรางแล -->
<q-btn
flat
round
:disabled="publicData == true || editvisible == false"
:color="
publicData == true || editvisible == false ? 'grey-7' : 'deep-orange'
"
@click="showDeleteModal()"
icon="mdi-file-remove-outline"
class="q-mr-sm"
>
<q-tooltip>ลบบนทกราง</q-tooltip>
</q-btn>
<!-- เผยแพร -->
<q-btn
flat
round
:disabled="
!(publicData == false || updateData == true) || editvisible == false
"
:color="
!(publicData == false || updateData == true) || editvisible == false
? 'grey-7'
: 'public'
"
icon="mdi-cloud-upload-outline"
@click="showPublishModal()"
class="q-mr-sm"
>
<q-tooltip>เผยแพร</q-tooltip>
</q-btn>
<!-- refresh data -->
<q-btn
flat
round
icon="mdi-refresh"
@click="refreshData()"
color="public"
class="q-mr-sm"
>
<q-tooltip>เฟรชขอม</q-tooltip>
</q-btn>
<q-space />
</div>
<!-- อมลการเผยแพรอม -->
<!-- <q-dialog v-model="modalPublish" persistent>
<q-card class="q-pa-sm">
<q-card-section class="row">
<div class="q-pr-md">
<q-avatar
icon="public"
size="lg"
font-size="25px"
color="blue-1"
text-color="public"
/>
</div>
<div class="col text-dark">
<span class="text-bold">องการเผยแพรอมลนหรอไม?</span>
<br />
<span>อมลทกำลงถกเผยแพรจะมผลใชงานทนท</span>
</div>
</q-card-section>
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="ยกเลิก" flat color="grey-8" v-close-popup />
<q-btn
label="เผยแพร่"
color="public"
@click="publishDraft()"
v-close-popup
/>
</q-card-actions>
</q-card>
</q-dialog> -->
<!-- <notifyPublishDraft v-model:showModal="modalPublish" :ok="publishDraft" /> -->
<!-- อมลการลบเผยแพรอม -->
<!-- <q-dialog v-model="modalDelete" persistent>
<q-card class="q-pa-sm">
<q-card-section class="row">
<div class="q-pr-md">
<q-avatar
icon="mdi-file-remove-outline"
size="lg"
font-size="25px"
color="red-1"
text-color="deep-orange"
/>
</div>
<div class="col text-dark">
<span class="text-bold">องการลบขอมลบนทกรางนหรอไม?</span>
<br />
<span>อมลบนทกรางทกำลงถกลบนจะมผลใชงานทนท</span>
</div>
</q-card-section>
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="ยกเลิก" flat color="grey-8" v-close-popup />
<q-btn
label="ลบบันทึก"
color="red"
@click="deleteDraft()"
v-close-popup
/>
</q-card-actions>
</q-card>
</q-dialog> -->
<!-- <notifyDeleteDraft v-model:showModal="modalDelete" :ok="deleteDraft" /> -->
</template>
<script setup lang="ts">
// import NotifyDeleteDraft from "@/components/NotifyDeleteDraft.vue";
import { ref } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
const $q = useQuasar();
const mixin = useCounterMixin(); //
const { dialogMessage } = mixin;
const modalPublish = ref<boolean>(false);
const modalDelete = ref<boolean>(false);
const emit = defineEmits(["update:editvisible"]);
const props = defineProps({
editvisible: {
type: Boolean,
defualt: false,
},
publicData: {
type: Boolean,
defualt: true,
required: false,
},
updateData: {
type: Boolean,
defualt: true,
required: false,
},
refreshData: {
type: Function,
default: () => console.log("call Parent refreshData"),
},
publishDraft: {
type: Function,
default: () => console.log("call parent publishDraft"),
},
deleteDraft: {
type: Function,
default: () => console.log("call parent deleteDraft"),
},
});
const clickRefresh = () => {
props.refreshData();
};
const clickEdit = () => {
emit("update:editvisible", !props.editvisible);
};
const clickCancel = () => {
emit("update:editvisible", !props.editvisible);
};
const showPublishModal = () => {
// modalPublish.value = true;
dialogMessage(
$q,
"ต้องการเผยแพร่ข้อมูลนี้หรือไม่?",
"ข้อมูลที่กำลังถูกเผยแพร่นี้จะมีผลใช้งานทันที",
"public",
"เผยแพร่",
"public",
props.publishDraft,
undefined
);
};
const showDeleteModal = () => {
// modalDelete.value = true;
dialogMessage(
$q,
"ต้องการลบข้อมูลบันทึกร่างนี้หรือไม่?",
"ข้อมูลบันทึกร่างที่กำลังถูกลบนี้จะมีผลใช้งานทันที",
"mdi-file-remove-outline",
"ลบบันทึก",
"red",
props.deleteDraft,
undefined
);
};
const hideDeleteModal = () => {
props.deleteDraft(); //Call Function DeleteDraft in Parent page
};
const hidePublishModal = () => {
props.publishDraft(); //Call Function DeleteDraft in Parent page
};
</script>
<style lang="scss">
.icon-color {
color: #4154b3;
}
</style>