ออกคำสั่ง ==> รายละเอียด API Tab 3

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-13 11:49:49 +07:00
parent 4ef591fd72
commit 8336ba3051
9 changed files with 388 additions and 208 deletions

View file

@ -4,27 +4,29 @@ import { onMounted, ref, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useCommandDetail } from "@/modules/18_command/store/DetailStore";
import type { ItemTabs } from "@/modules/18_command/interface/index/Main";
import Detail from "@/modules/18_command/components/Step/1_Detail.vue"; //
import ListPersons from "@/modules/18_command/components/Step/2_ListPersons.vue"; //
import ReceivedCopy from "@/modules/18_command/components/Step/3_ReceivedCopy.vue"; //
import ReceivedCopy from "@/modules/18_command/components/Step/3_ReceivedCopy.vue"; //
import Attached from "@/modules/18_command/components/Step/4_Attached.vue"; //
const router = useRouter();
const route = useRoute();
const store = useCommandDetail();
const childDetailRef = ref<InstanceType<typeof Detail> | null>(null);
const childListPersonsRef = ref<InstanceType<typeof ListPersons> | null>(null);
const childDetailRef = ref<InstanceType<typeof Detail> | null>(null); //ref components
const childListPersonsRef = ref<InstanceType<typeof ListPersons> | null>(null); //ref components
const childReceivedCopyRef = ref<InstanceType<typeof ReceivedCopy> | null>(
null
);
const childAttachedRef = ref<InstanceType<typeof Attached> | null>(null);
); //ref components
const childAttachedRef = ref<InstanceType<typeof Attached> | null>(null); //ref components
const readonly = ref<boolean>(route.name === "commandViewDetailPage");
const isChangeData = ref<boolean>(false);
const tabs = ref<string>("Detail");
const tabsManu = ref([
const tabs = ref<string>("Detail"); //Tab
const readonly = ref<boolean>(route.name === "commandViewDetailPage"); //
const isChangeData = ref<boolean>(false); //
// Tab
const tabsManu = ref<ItemTabs[]>([
{ label: "รายละเอียดคำสั่ง", name: "Detail" },
{
label: "รายชื่อผู้ออกคำสั่ง",
@ -38,25 +40,40 @@ const tabsManu = ref([
]);
/**
* function เชคการแกไขอม
* งกนเชคการเปลนรแปลงของขอม
*
* ามการเปลนยแปลง กำหนด 'isChangeData' เป true
*/
function onCheckChangeData() {
isChangeData.value = true;
}
onMounted(() => {
store.readonly = readonly.value;
/**
* การเปลยนแปลงของ tabs เมอมการเปลยนแปลง
*
* เชคการเปลยนแปลงของขอม าการเปลยนแปลงของขอมลจะบนทกขอม
*/
watch(tabs, (newValue, oldValue) => {
//
if (isChangeData.value) {
const refMap: { [key: string]: any } = {
Detail: childDetailRef,
ListPersons: childListPersonsRef,
ReceivedCopy: childReceivedCopyRef,
Attached: childAttachedRef,
};
refMap[oldValue]?.value?.onSubmit();
}
});
watch(tabs, (newValue, oldValue) => {
console.log(`Count changed from ${oldValue} to ${newValue}`);
if (isChangeData.value) {
// component
if (oldValue === "Detail") {
console.log(childDetailRef.value);
childDetailRef.value?.onSubmit();
}
}
/**
* ทำงานเม Components กเรยกใชงาน
*
* กำหนดค `store.readonly` เม route.name เป "commandViewDetailPage" จะอานขอมลไดอยางเดยว
*/
onMounted(() => {
store.readonly = route.name === "commandViewDetailPage";
});
</script>

View file

@ -18,8 +18,7 @@ const $q = useQuasar();
const store = useCommandListStore();
const { showLoader, hideLoader, messageError } = useCounterMixin();
const modalAdd = ref<boolean>(false);
// Tab
const tabsManu = ref<ItemTabs[]>([
{ label: "แบบร่าง", name: "DRAFT" },
{ label: "รอผู้มีอำนาจ", name: "PENDING" },
@ -27,14 +26,18 @@ const tabsManu = ref<ItemTabs[]>([
{ label: "ออกคำสั่งเสร็จสิ้น", name: "REPORTED" },
{ label: "ยกเลิก", name: "CANCEL" },
]);
//
const queryParams = reactive<FormQuery>({
page: 1,
pageSize: 10,
year: new Date().getFullYear(),
keyword: "",
page: 1, //
pageSize: 10, //
year: new Date().getFullYear(), //
keyword: "", //
});
const modalAdd = ref<boolean>(false); //
/**
* งกนดงขอมลรายการคำส
*/
async function fetchListCommand() {
showLoader();
await http