api get,delete listOrder

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-08-04 14:26:13 +07:00
parent 482e44815e
commit d6c5aef69e
4 changed files with 97 additions and 208 deletions

View file

@ -55,6 +55,7 @@ export default {
// order // order
yearOptionsOrder: () => `${order}/order/fiscal-year`, yearOptionsOrder: () => `${order}/order/fiscal-year`,
listOrder: () => `${order}/order`, listOrder: () => `${order}/order`,
detailOrder:(orderId:string) => `${order}/order/${orderId}`,
typeOrder: () => `${order}/order/order-type`, typeOrder: () => `${order}/order/order-type`,
examroundOrder: () => `${order}/order/detail/exam-round`, examroundOrder: () => `${order}/order/detail/exam-round`,
}; };

View file

@ -156,7 +156,7 @@
<q-tr <q-tr
:props="props" :props="props"
class="cursor-pointer" class="cursor-pointer"
@click="redirectToPage(props.row.Order)" @click="redirectToPage(props.row.orderId)"
> >
<q-td key="Order" :props="props"> <q-td key="Order" :props="props">
{{ props.row.Order }} {{ props.row.Order }}
@ -186,7 +186,7 @@
flat flat
round round
color="red" color="red"
@click.stop="clickDelete(props.row.id)" @click.stop="clickDelete(props.row.orderId)"
icon="mdi-delete" icon="mdi-delete"
> >
<q-tooltip>ลบขอม</q-tooltip> <q-tooltip>ลบขอม</q-tooltip>
@ -217,7 +217,10 @@
import { onMounted, reactive, ref, useAttrs, computed } from "vue"; import { onMounted, reactive, ref, useAttrs, computed } from "vue";
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { FormOrderPlacementMainData } from "@/modules/05_placement/interface/request/Main"; import type { FormOrderPlacementMainData } from "@/modules/05_placement/interface/request/Main";
import type { DataOption } from "@/modules/05_placement/interface/index/Main"; import type {
DataOption,
DataOption1,
} from "@/modules/05_placement/interface/index/Main";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useOrderPlacementDataStore } from "@/modules/05_placement/store"; import { useOrderPlacementDataStore } from "@/modules/05_placement/store";
import router from "@/router"; import router from "@/router";
@ -227,11 +230,10 @@ import config from "@/app.config";
const $q = useQuasar(); // noti quasar const $q = useQuasar(); // noti quasar
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai, dateText } = mixin; const { showLoader, hideLoader, messageError, date2Thai, dateText, success } =
mixin;
const DataStore = useOrderPlacementDataStore(); const DataStore = useOrderPlacementDataStore();
const pagination = ref({ const pagination = ref({
sortBy: "desc", sortBy: "desc",
descending: false, descending: false,
@ -344,146 +346,17 @@ const columns = ref<QTableProps["columns"]>([
// () // ()
const rows = ref<FormOrderPlacementMainData[]>([ const rows = ref<FormOrderPlacementMainData[]>([
{ // {
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้", // Order: "",
OrderNum: "1/2565", // OrderNum: "1/2565",
fiscalYear: 2565, // fiscalYear: 2565,
OrderDate: "30 พ.ค. 2565", // OrderDate: "30 .. 2565",
OrderBy: "สำนักงาน กทม.", // OrderBy: " .",
Signer: "นาม สมคิด ยอดใจ ", // Signer: " ",
OrderStatus: "จัดทำร่างคำสั่ง", // OrderStatus: "",
OrderType: "คำสั่งย้าย", // OrderType: "",
}, // },
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2565",
fiscalYear: 2565,
OrderDate: "30 พ.ค. 2565",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "จัดทำร่างคำสั่ง",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "บัญชีแนบท้าย",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "บัญชีแนบท้าย",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ส่งสำเนาคำสั่ง",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ส่งสำเนาคำสั่ง",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "รอลงนาม",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2565",
fiscalYear: 2565,
OrderDate: "30 พ.ค. 2565",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งบรรจุและแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งย้าย",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2564",
fiscalYear: 2564,
OrderDate: "30 พ.ค. 2564",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
{
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
OrderNum: "1/2566",
fiscalYear: 2566,
OrderDate: "30 พ.ค. 2566",
OrderBy: "สำนักงาน กทม.",
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: "ออกคำสั่งแล้ว",
OrderType: "คำสั่งแต่งตั้ง",
},
]); ]);
// const OrderStatusOption = [
// "",
// "",
// "",
// "",
// ];
let OriginalData = ref<FormOrderPlacementMainData[]>([]); let OriginalData = ref<FormOrderPlacementMainData[]>([]);
let UpdataData = ref<FormOrderPlacementMainData[]>([]); let UpdataData = ref<FormOrderPlacementMainData[]>([]);
@ -497,13 +370,27 @@ onMounted(async () => {
}); });
const OriginalDataFetch = async () => { const OriginalDataFetch = async () => {
// API await http
// await http.get(config.API.listOrder()).then((res: any) => { .get(config.API.listOrder())
// console.log("list", res); .then((res: any) => {
// }); console.log("list", res);
// .catch((e: any) => { rows.value = res.data.result.map((e: any) => ({
// messageError($q, e); orderId: e.orderId,
// }) Order: e.orderName,
OrderNum: e.orderNo,
fiscalYear: Number(e.fiscalYear),
OrderDate: date2Thai(e.orderDate),
OrderBy: e.orderBy,
Signer: "นาม สมคิด ยอดใจ ",
OrderStatus: e.orderStatusName,
orderStatusValue: e.orderStatusValue,
OrderType: e.orderTypeName,
orderTypeValue: e.orderTypeValue,
}));
})
.catch((e: any) => {
messageError($q, e);
});
// .finally(async () => { // .finally(async () => {
// }); // });
await DataStore.DataMainOrder(rows.value); await DataStore.DataMainOrder(rows.value);
@ -513,7 +400,6 @@ const OriginalDataFetch = async () => {
// //
const redirectToPage = (id?: string) => { const redirectToPage = (id?: string) => {
console.log(id);
router.push(`/placement/order/detail/${id}`); router.push(`/placement/order/detail/${id}`);
}; };
@ -528,27 +414,27 @@ const clickDelete = (id: string) => {
persistent: true, persistent: true,
}) })
.onOk(async () => { .onOk(async () => {
// await deleteData(id); await deleteData(id);
}) })
.onCancel(() => {}) .onCancel(() => {})
.onDismiss(() => {}); .onDismiss(() => {});
}; };
// const deleteData = async (id: string) => { const deleteData = async (id: string) => {
// showLoader(); showLoader();
// await http await http
// .delete(config.API.orderReplace(id)) .delete(config.API.detailOrder(id))
// .then((res) => { .then((res) => {
// success($q, ""); success($q, "ลบข้อมูลสำเร็จ");
// }) })
// .catch((e) => { .catch((e) => {
// messageError($q, e); messageError($q, e);
// }) })
// .finally(async () => { .finally(async () => {
// hideLoader(); hideLoader();
// await fetchData(); await OriginalDataFetch();
// }); });
// }; };
const clickAdd = () => { const clickAdd = () => {
router.push({ name: "Orderplacementadd" }); router.push({ name: "Orderplacementadd" });
@ -568,14 +454,13 @@ const fiscalyearOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหม
const addedfiscalYearValues: number[] = []; const addedfiscalYearValues: number[] = [];
const fiscalYearFilter = async () => { const fiscalYearFilter = async () => {
await http.get(config.API.yearOptionsOrder()).then((res) => { await http.get(config.API.yearOptionsOrder()).then((res) => {
console.log(res); // console.log(res);
const response = res.data.result; const response = res.data.result;
fiscalyearOP.push(...response); fiscalyearOP.push(...response);
// const maxNumber = fiscalyearOP.reduce((max: any, e: any) => { // const maxNumber = fiscalyearOP.reduce((max: any, e: any) => {
// return e.id > max ? e.id : max; // return e.id > max ? e.id : max;
// }, ""); // }, "");
// fiscalyear.value = maxNumber; // fiscalyear.value = maxNumber;
// console.log(fiscalyear.value);
}); });
// API // API
// await http // await http
@ -607,13 +492,13 @@ const fiscalYearFilter = async () => {
}; };
const OrderType = ref<string>(""); const OrderType = ref<string>("");
const OrderTypeOption = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]); const OrderTypeOption = reactive<DataOption1[]>([{ id: "", name: "ทั้งหมด" }]);
const addedOrderTypeValues: string[] = []; const addedOrderTypeValues: string[] = [];
const OrderTypeFilter = async () => { const OrderTypeFilter = async () => {
await http await http
.get(config.API.typeOrder()) .get(config.API.typeOrder())
.then((res) => { .then((res) => {
console.log(res.data); // console.log(res.data);
const response = res.data.result; const response = res.data.result;
OrderTypeOption.push(...response); OrderTypeOption.push(...response);
}) })
@ -660,7 +545,9 @@ const OrderStatus = ref<string>("");
const OrderStatusText = ref<FormOrderPlacementMainData[]>( const OrderStatusText = ref<FormOrderPlacementMainData[]>(
DataStore.DataMainOrigOrder DataStore.DataMainOrigOrder
); );
const OrderStatusOption = reactive<DataOption[]>([{ id: 1, name: "ทั้งหมด" }]); const OrderStatusOption = reactive<DataOption1[]>([
{ id: "", name: "ทั้งหมด" },
]);
const addedOrderStatusValues: string[] = []; const addedOrderStatusValues: string[] = [];
const OrderStatusFilter = async () => { const OrderStatusFilter = async () => {
// API // API
@ -677,7 +564,6 @@ const OrderStatusFilter = async () => {
// }); // });
for (let data of OriginalData.value) { for (let data of OriginalData.value) {
const OrderStatusValue = data.OrderStatus; const OrderStatusValue = data.OrderStatus;
console.log(OrderStatusValue);
if ( if (
OrderStatusValue === null || OrderStatusValue === null ||
@ -687,35 +573,17 @@ const OrderStatusFilter = async () => {
} }
if (!addedOrderStatusValues.includes(OrderStatusValue)) { if (!addedOrderStatusValues.includes(OrderStatusValue)) {
// console.log(OrderStatusValue);
OrderStatusOption.push({ OrderStatusOption.push({
// id: OrderStatusValue, // id: OrderStatusValue,
id: OrderStatusOption.length, id: OrderStatusOption.length.toString(),
name: OrderStatusValue, name: OrderStatusValue,
}); });
addedOrderStatusValues.push(OrderStatusValue); addedOrderStatusValues.push(OrderStatusValue);
} }
} }
}; };
// API
const searchfiscalyear = async () => {
const yearNum = fiscalyear.value! + 543;
await DataStore.DataUpdateOrder(OrderType.value, OrderStatus.value, yearNum);
UpdataData.value = DataStore.DataMainUpdateOrder;
// API
// await http
// .get(config.API.// )
// .then((res: any) => {
// })
// .catch((e: any) => {
// messageError($q, e);
// })
// .finally(async () => {
// });
};
// //
const filterKeyword = ref<string>(""); const filterKeyword = ref<string>("");
const filterRef = ref<any>(null); const filterRef = ref<any>(null);
@ -727,22 +595,27 @@ const resetFilter = () => {
const attrs = ref<any>(useAttrs()); const attrs = ref<any>(useAttrs());
const searchFilterTable = async () => { const searchFilterTable = async () => {
if (fiscalyear.value !== null && fiscalyear.value !== 0) { if (OrderType.value == "ทั้งหมด") {
fiscalyear.value += 543; OrderType.value = "";
} }
console.log(fiscalyear.value, OrderType.value, OrderStatus.value); if (OrderStatus.value == "ทั้งหมด") {
OrderStatus.value = "";
}
console.log(
"Input value changed:",
OrderType.value,
OrderStatus.value,
fiscalyear.value
);
// console.log('Input value changed:', examTime.value, examType.value, expiredAccount.value);
await DataStore.DataUpdateOrder( await DataStore.DataUpdateOrder(
OrderType.value, OrderType.value,
OrderStatus.value, OrderStatus.value,
fiscalyear.value fiscalyear.value
); );
UpdataData.value = DataStore.DataMainUpdateOrder; UpdataData.value = DataStore.DataMainUpdateOrder;
console.log(UpdataData.value); // console.log(UpdataData.value);
}; };
// UpdataData.value = DataStore.DataMainUpdate;
// console.log("Input value changed:", OrderStatus.value, OrderType.value);
const paging = ref<boolean>(true); const paging = ref<boolean>(true);
const paginationLabel = (start: string, end: string, total: string) => { const paginationLabel = (start: string, end: string, total: string) => {

View file

@ -511,9 +511,10 @@ const clickEditRow = () => (editRow.value = true);
onMounted(async () => { onMounted(async () => {
if (orderId) { if (orderId) {
await fetchdetailOrder(); await fetchdetailOrder();
} else {
fecthTypeOption();
fecthExamRoundOption();
} }
fecthTypeOption();
fecthExamRoundOption();
// const data = localStorage.getItem("formData"); // const data = localStorage.getItem("formData");
// if (data) { // if (data) {
@ -537,6 +538,20 @@ onMounted(async () => {
const fetchdetailOrder = async () => { const fetchdetailOrder = async () => {
showLoader(); showLoader();
console.log(orderId); console.log(orderId);
let orderIdString = orderId.toString();
await http
.get(config.API.detailOrder(orderIdString))
.then((res) => {
console.log(res);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
fecthTypeOption();
fecthExamRoundOption();
});
}; };
const fecthTypeOption = async () => { const fecthTypeOption = async () => {
await http await http
@ -567,7 +582,7 @@ const submit = async () => {
orderBy: byOrder.value, orderBy: byOrder.value,
signatoryBy: nameCommand.value, signatoryBy: nameCommand.value,
signatoryPosition: positionCommand.value, signatoryPosition: positionCommand.value,
examRound: test.value, examRound: examRound.value,
registerPosition: position.value, registerPosition: position.value,
conclusionRegisterNo: register.value, conclusionRegisterNo: register.value,
conclusionRegisterDate: dateRegister.value, conclusionRegisterDate: dateRegister.value,
@ -586,9 +601,7 @@ const submit = async () => {
persistent: true, persistent: true,
}).onOk(async () => { }).onOk(async () => {
showLoader(); showLoader();
// localStorage.setItem("formData", JSON.stringify(formdata));
createListOrder(formdata); createListOrder(formdata);
// next();
}); });
} }
}); });

View file

@ -269,6 +269,8 @@ export const useOrderPlacementDataStore = defineStore("placementOrder", () => {
item.OrderStatus === filter_2 && item.OrderStatus === filter_2 &&
item.fiscalYear === filterYear item.fiscalYear === filterYear
); );
} else if (filter_1 == "ทั้งหมด" && filter_2 == "ทั้งหมด" && filterYear !== null) {
DataMainUpdateOrder.value = DataMainOrigOrder.value;
} }
}; };