diff --git a/env.d.ts b/env.d.ts index 11f02fe2a..33cd2182c 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1 +1,2 @@ /// +declare module 'quasar-ui-q-draggable-table'; \ No newline at end of file diff --git a/package.json b/package.json index 403f6f025..cc3443f41 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "node-sass": "^9.0.0", "npm-run-all": "^4.1.5", "prettier": "^2.7.1", + "quasar-ui-q-draggable-table": "^1.0.1", "sass": "^1.69.4", "start-server-and-test": "^1.15.2", "typescript": "~4.7.4", diff --git a/src/main.ts b/src/main.ts index 2926f9112..79578a04c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,10 @@ import { createApp, defineAsyncComponent } from "vue"; import App from "./App.vue"; import router from "./router"; import { Dialog, Notify, Quasar, Loading } from "quasar"; -import quasarUserOptions from "./quasar-user-options"; +import "./quasar-user-options"; + +import qDraggableTable from 'quasar-ui-q-draggable-table'; +import 'quasar-ui-q-draggable-table/dist/index.css'; import "quasar/src/css/index.sass"; import th from "quasar/lang/th"; @@ -29,6 +32,7 @@ app.config.globalProperties.$filters = filters; app.use(router); app.use(pinia); +app.use(qDraggableTable); app.use( Quasar, diff --git a/src/modules/01_metadataNew/components/insignia/InsigniaDetail.vue b/src/modules/01_metadataNew/components/insignia/InsigniaDetail.vue index db71f6c5e..e9d957565 100644 --- a/src/modules/01_metadataNew/components/insignia/InsigniaDetail.vue +++ b/src/modules/01_metadataNew/components/insignia/InsigniaDetail.vue @@ -17,7 +17,6 @@ const router = useRouter(); const route = useRoute(); const $q = useQuasar(); const store = useInsigniaDataStore(); -const row = ref(); const mixin = useCounterMixin(); const { date2Thai, messageError, hideLoader, showLoader } = mixin; const id = ref(route.params.id.toString()); @@ -40,9 +39,10 @@ async function fetchData(id: string) { } onMounted(async () => { - fetchData(id.value); + await fetchData(id.value); }); + diff --git a/src/modules/01_metadataNew/components/insignia/InsigniaList.vue b/src/modules/01_metadataNew/components/insignia/InsigniaList.vue index 227ac7657..cf7090275 100644 --- a/src/modules/01_metadataNew/components/insignia/InsigniaList.vue +++ b/src/modules/01_metadataNew/components/insignia/InsigniaList.vue @@ -5,12 +5,20 @@ import { useCounterMixin } from "@/stores/mixin"; import { useRouter, useRoute } from "vue-router"; import { useInsigniaDataStore } from "@/modules/01_metadataNew/stores/InsigniaStore"; import dialogHeader from "@/components/DialogHeader.vue"; +import TableDraggable from "@/modules/01_metadataNew/components/insignia/TableDraggable.vue"; import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; const store = useInsigniaDataStore(); const router = useRouter(); const mixin = useCounterMixin(); + +const props = defineProps({ + fetchData: { + type: Function, + default: ()=>"", + } +}) const { date2Thai, dialogRemove, @@ -22,17 +30,14 @@ const { const $q = useQuasar(); const columns = ref([ { - name: "level", + name: "no", align: "left", label: "ลำดับ", - sortable: true, - field: "level", + sortable: false, + field: "no", headerStyle: "font-size: 14px; width:0px", style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, - { name: "name", align: "left", @@ -143,7 +148,7 @@ const shortNameRef = ref(null); const dialogStatus = ref(""); const editId = ref(""); const visibleColumns = ref([ - "level", + "no", "name", "shortName", "insigniaType", @@ -164,24 +169,24 @@ function validateForm() { onSubmit(); } -async function fetchData(id: string) { - showLoader(); - await http - .get(config.API.insigniaTypeNewId(id)) - .then(async (res) => { - insigniaTypeId.value = res.data.result.name; - store.fetchData(res.data.result.insignias, res.data.result.name); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} -onMounted(async () => { - fetchData(id.value); -}); +// async function fetchData(id: string) { +// showLoader(); +// await http +// .get(config.API.insigniaTypeNewId(id)) +// .then(async (res) => { +// insigniaTypeId.value = res.data.result.name; +// store.fetchData(res.data.result.insignias, res.data.result.name); +// }) +// .catch((err) => { +// messageError($q, err); +// }) +// .finally(() => { +// hideLoader(); +// }); +// } +// onMounted(async () => { +// fetchData(id.value); +// }); async function onSubmit() { if (name.value.length > 0 && shortName.value.length > 0) { @@ -209,7 +214,7 @@ async function addData() { note: note.value == "" ? "-" : note.value, insigniaTypeId: id.value, }); - fetchData(id.value); + props.fetchData(id.value); } async function editData(idData: string) { @@ -220,17 +225,18 @@ async function editData(idData: string) { note: note.value == "" ? "-" : note.value, insigniaTypeId: id.value, }); - fetchData(id.value); + props.fetchData(id.value); } async function deleteData(idData: string) { await http.delete(config.API.insigniaNewId(idData)); - fetchData(id.value); + props.fetchData(id.value); } import { defineEmits } from "vue"; const emit = defineEmits(["nameType"]); +const dialogOrder = ref(false);