อัตรากำลังลูกจ้างประจำ ฯ => refactor code

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-25 15:00:26 +07:00
parent 7e2350eef8
commit 81e0a82b0e
18 changed files with 377 additions and 188 deletions

View file

@ -3,20 +3,42 @@ import { ref, watch, defineProps } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
/**
* importType
*/
import type { QTableProps } from "quasar";
import type { DataSortPos } from "@/modules/02_organizationalNew/interface/index/organizational";
/**
* importComponents
*/
import DialogHeader from "@/components/DialogHeader.vue";
/**
* importStore
*/
import { useCounterMixin } from "@/stores/mixin";
import { usePositionEmp } from "@/modules/16_positionEmployee/store/organizational";
/**
* use
*/
const $q = useQuasar();
const store = usePositionEmp();
const { dialogConfirm, showLoader, success, hideLoader, messageError } =
useCounterMixin();
/**
* props
*/
const modal = defineModel<boolean>("sortPosition", { required: true });
const rows = ref<any[]>([]);
const props = defineProps({
fetchDataTable: Function,
});
/** ข้อมูล Table*/
const rows = ref<DataSortPos[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "name",
@ -28,22 +50,22 @@ const columns = ref<QTableProps["columns"]>([
},
]);
const props = defineProps({
fetchDataTable: Function,
});
function onDrop(from: any, to: any) {
onDropRow(from, to);
}
function onDropRow(from: any, to: any) {
/**
* fiunction ดลำด
* @param from ตำแหนงป
* @param to ตำแหนงทจะยายไป
*/
function onDrop(from: number, to: number) {
rows.value.splice(to, 0, rows.value.splice(from, 1)[0]);
}
/**
* function นทกการจดลำด
*/
function save() {
dialogConfirm($q, () => {
const data = rows.value;
const dataId = data.map((item: any) => item.id);
const dataId = data.map((item: DataSortPos) => item.id);
showLoader();
http
.post(config.API.orgPosSortEmp, {
@ -51,10 +73,10 @@ function save() {
type: store.level,
sortId: dataId,
})
.then((res) => {
.then(async () => {
await props.fetchDataTable?.(store.treeId, store.level, false);
await success($q, "บันทึกข้อมูลสำเร็จ");
modal.value = false;
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchDataTable?.(store.treeId, store.level, false);
})
.catch((e) => {
messageError($q, e);
@ -65,6 +87,9 @@ function save() {
});
}
/**
* function เรยกรายการขอมลตำแหน
*/
function getData() {
showLoader();
http
@ -79,6 +104,7 @@ function getData() {
})
.then((res) => {
const dataList = res.data.result.data;
const dataMap = dataList.map((item: any) => ({
id: item.id,
name: `${item.orgShortname}${
@ -100,6 +126,9 @@ function getData() {
});
}
/**
* callback function ทำงานเม modal = true ทำการเรยกขอมลตำแหน
*/
watch(
() => modal.value,
() => {