Refactoring code module 01_masterdata

This commit is contained in:
STW_TTTY\stwtt 2024-09-12 15:42:47 +07:00
parent 82f5380f3e
commit 71be6d095f
22 changed files with 272 additions and 209 deletions

View file

@ -5,26 +5,31 @@ import { useRouter, useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import type {
DataOption,
IndicatorType,
OrgTreeNode,
DataHistory,
} from "@/modules/01_masterdata/interface/index/Main";
import type { DataOption } from "@/modules/01_masterdata/interface/index/Main";
import DialogHistory from "@/modules/01_masterdata/components/Indicators/DialogHistory.vue";
import Summary from "@/modules/01_masterdata/components/Indicators/Summary.vue";
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
/** use*/
const dataHistory = ref<any[]>([]);
const modalHistory = ref<boolean>(false);
const isAll = ref<boolean>(false);
const $q = useQuasar();
const router = useRouter();
const route = useRoute();
const { showLoader, hideLoader, dialogRemove, success, messageError } =
useCounterMixin();
const dataHistory = ref<DataHistory[]>([]);
const modalHistory = ref<boolean>(false);
const isAll = ref<boolean>(false);
/** หัวตาราง */
const rows = ref<any[]>([]);
const rows = ref<IndicatorType[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "including",
@ -45,7 +50,7 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const node = ref<any>([]);
const node = ref<OrgTreeNode[]>([]);
const expanded = ref<any>([]);
const filterMain = ref<string>("");
const visibleColumns = ref<string[]>(["including", "includingName"]);
@ -68,6 +73,7 @@ const nodeData = reactive<any>({
keyword: "",
});
/** ดึงข้อมูล */
function fetchList() {
if (nodeData.nodeId) {
showLoader();
@ -96,6 +102,11 @@ function fetchList() {
}
}
/**
* งช add/edit
* @param status true = edit / false = add
* @param id id edit
*/
function onClickAddOrView(status: boolean = false, id: string = "") {
status
? router.push(`/masterdata/indicator-plan/${id}`)
@ -120,6 +131,7 @@ function fetchActive() {
});
}
/** ดึงข้อมูลโครงสรร้าง */
async function fetchTree(id: string) {
showLoader();
http
@ -136,6 +148,7 @@ async function fetchTree(id: string) {
});
}
/** เรียกข้อมูลตาม row โครงสร้าง*/
function updateSelectedTreeMain(data: any) {
if (nodeData.node === data.orgLevel && nodeData.nodeId === data.orgTreeId) {
nodeData.node = null;
@ -147,11 +160,13 @@ function updateSelectedTreeMain(data: any) {
fetchListProjectNew();
}
/** ดึงรายละเอียดโครงสร้าง */
function fetchListProjectNew() {
nodeData.page = 1;
fetchList();
}
/** delete */
async function deleteData(idData: string) {
dialogRemove($q, () =>
http
@ -169,6 +184,7 @@ async function deleteData(idData: string) {
);
}
/** clear input filter */
function clearFilter() {
nodeData.keyword = "";
fetchActive();