comment code retirement

This commit is contained in:
AnandaTon 2023-11-17 14:21:53 +07:00
parent 45fc4848ac
commit 45ef9649e1
15 changed files with 295 additions and 64 deletions

View file

@ -1,7 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/modules/04_registry/components/DialogHeader.vue";
import type { QInput, QForm } from "quasar";
@ -9,15 +8,28 @@ import type { treeTab } from "@/modules/05_placement/interface/index/Main";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type {
requestSendNoti,
DataCopyOrder,
ResponseOrganiz,
} from "@/modules/06_retirement/interface/response/Deceased";
import { useRouter, useRoute } from "vue-router";
/** Use */
const router = useRouter();
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin(); //
const {
dialogRemove,
messageError,
showLoader,
hideLoader,
success,
dialogConfirm,
} = mixin;
/** props*/
const props = defineProps({
next: {
type: Function,
@ -31,24 +43,25 @@ const props = defineProps({
const profileId = ref<string>(route.params.id.toString());
const next = () => props.next();
const $q = useQuasar();
const mixin = useCounterMixin(); //
const { dialogRemove, messageError, showLoader, hideLoader, success,dialogConfirm } = mixin;
/**ตัวแปร */
const myForm = ref<QForm | null>(null);
const filterRef = ref<QInput>();
const filter = ref<string>("");
const modal = ref<boolean>(false);
const search = ref<string>("");
const expanded = ref<string[]>([]);
const selected = ref<string>("");
const nodesTree = ref<treeTab[]>([]);
const selectedModal = ref<ResponseOrganiz[]>([]);
const filterModal = ref<string>("");
const rows = ref<DataCopyOrder[]>([]);
const editRows = ref<DataCopyOrder[]>([]);
/** คอลัมน์Modal ที่แสดง */
const visibleColumnsModal = ref<String[]>(["no", "idCard", "name", "position"]);
/** คอลัมน์Modal */
const rowsModal = ref<ResponseOrganiz[]>([]);
const columnsModal = ref<QTableProps["columns"]>([
{
name: "no",
@ -88,13 +101,13 @@ const columnsModal = ref<QTableProps["columns"]>([
},
]);
const rowsModal = ref<ResponseOrganiz[]>([]);
/** selcet OPtion */
const optionSelect = ref<any>([
{ id: 1, name: "อีเมล" },
{ id: 2, name: "กล่องข้อความ" },
]);
/** คอลัมน์ที่แสดง */
const visibleColumns = ref<String[]>([
"no",
"idCard",
@ -103,6 +116,8 @@ const visibleColumns = ref<String[]>([
"unit",
"send",
]);
/** คอลัมน์ */
const columns = ref<QTableProps["columns"]>([
{ name: "no", align: "left", label: "ลำดับ", field: "no", sortable: true },
{
@ -152,14 +167,15 @@ const columns = ref<QTableProps["columns"]>([
},
]);
const rows = ref<DataCopyOrder[]>([]);
const editRows = ref<DataCopyOrder[]>([]);
/** Hook */
onMounted(async () => {
await getData();
});
/**
* งขอม list จาก api
* @param id id ของขอม
*/
const listModal = async (id: string) => {
showLoader();
await http
@ -189,6 +205,7 @@ const listModal = async (id: string) => {
});
};
/** เรียกข้อมูลจาก api */
const getData = async () => {
showLoader();
await http
@ -235,6 +252,9 @@ const getData = async () => {
});
};
/**
*งก Save
*/
const saveData = async () => {
showLoader();
const persons = selectedModal.value.map((item) => ({
@ -260,6 +280,10 @@ const resetFilter = () => {
filterRef.value!.focus();
};
/**
* class ดรปแบบแสดงระหวางขอมลทแกไขหรอแสดงเฉยๆ
* @param val อม input สำหรบแกไขหรอไม
*/
const getClass = (val: boolean) => {
return {
"full-width inputgreen cursor-pointer": val,
@ -267,10 +291,14 @@ const getClass = (val: boolean) => {
};
};
/** Close Modal */
const clickClose = async () => {
modal.value = false;
};
/**
* กดปมเพมดานบน table
*/
const clickAdd = async () => {
await nodeTree();
selected.value = "";
@ -282,10 +310,16 @@ const clickAdd = async () => {
}
};
/**
* ลบขอม
*/
const clickDelete = (id: string) => {
dialogRemove($q, () => deleteData(id));
};
/**
* โหลดโครงสราง tree
*/
const nodeTree = async () => {
showLoader();
await http
@ -305,10 +339,12 @@ const nodeTree = async () => {
});
};
//
const onSelected = async (id: string) => {
await listModal(id);
};
/**ลบข้อมูล */
const deleteData = async (id: string) => {
await http
.delete(config.API.detailByidDeceased(id))
@ -323,16 +359,24 @@ const deleteData = async (id: string) => {
});
};
/**
* Save อม
*/
const saveDataCopyOrder = async () => {
if (myForm.value !== null) {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
dialogConfirm($q,() => fetchSaveCopyOrder(),'ยืนยันการส่งหนังสือเวียน','ต้องการยืนยันการส่งหนังสือเวียนหรือไม่')
dialogConfirm(
$q,
() => fetchSaveCopyOrder(),
"ยืนยันการส่งหนังสือเวียน",
"ต้องการยืนยันการส่งหนังสือเวียนหรือไม่"
);
}
});
}
};
// Save
const fetchSaveCopyOrder = async () => {
let list: requestSendNoti[] = [];
rows.value.map((r: DataCopyOrder) => {
@ -343,7 +387,6 @@ const fetchSaveCopyOrder = async () => {
isSendNotification: true,
});
});
showLoader();
await http
.put(config.API.notiDeceased(profileId.value), { Persons: list })
@ -359,7 +402,6 @@ const fetchSaveCopyOrder = async () => {
getData();
});
};
const updateData = (row: DataCopyOrder) => {
editRows.value.push(row);
};