api get,delete listOrder
This commit is contained in:
parent
482e44815e
commit
d6c5aef69e
4 changed files with 97 additions and 208 deletions
|
|
@ -55,6 +55,7 @@ export default {
|
|||
// order
|
||||
yearOptionsOrder: () => `${order}/order/fiscal-year`,
|
||||
listOrder: () => `${order}/order`,
|
||||
detailOrder:(orderId:string) => `${order}/order/${orderId}`,
|
||||
typeOrder: () => `${order}/order/order-type`,
|
||||
examroundOrder: () => `${order}/order/detail/exam-round`,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@
|
|||
<q-tr
|
||||
:props="props"
|
||||
class="cursor-pointer"
|
||||
@click="redirectToPage(props.row.Order)"
|
||||
@click="redirectToPage(props.row.orderId)"
|
||||
>
|
||||
<q-td key="Order" :props="props">
|
||||
{{ props.row.Order }}
|
||||
|
|
@ -186,7 +186,7 @@
|
|||
flat
|
||||
round
|
||||
color="red"
|
||||
@click.stop="clickDelete(props.row.id)"
|
||||
@click.stop="clickDelete(props.row.orderId)"
|
||||
icon="mdi-delete"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
|
|
@ -217,7 +217,10 @@
|
|||
import { onMounted, reactive, ref, useAttrs, computed } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
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 { useOrderPlacementDataStore } from "@/modules/05_placement/store";
|
||||
import router from "@/router";
|
||||
|
|
@ -227,11 +230,10 @@ import config from "@/app.config";
|
|||
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const mixin = useCounterMixin();
|
||||
const { showLoader, hideLoader, messageError, date2Thai, dateText } = mixin;
|
||||
const { showLoader, hideLoader, messageError, date2Thai, dateText, success } =
|
||||
mixin;
|
||||
const DataStore = useOrderPlacementDataStore();
|
||||
|
||||
|
||||
|
||||
const pagination = ref({
|
||||
sortBy: "desc",
|
||||
descending: false,
|
||||
|
|
@ -344,146 +346,17 @@ const columns = ref<QTableProps["columns"]>([
|
|||
|
||||
// ข้อมูลตาราง (จำลอง)
|
||||
const rows = ref<FormOrderPlacementMainData[]>([
|
||||
{
|
||||
Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
|
||||
OrderNum: "1/2565",
|
||||
fiscalYear: 2565,
|
||||
OrderDate: "30 พ.ค. 2565",
|
||||
OrderBy: "สำนักงาน กทม.",
|
||||
Signer: "นาม สมคิด ยอดใจ ",
|
||||
OrderStatus: "จัดทำร่างคำสั่ง",
|
||||
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: "คำสั่งแต่งตั้ง",
|
||||
},
|
||||
// {
|
||||
// Order: "คำสั่งแต่งตั้งผู้สอบแข่งขันได้",
|
||||
// OrderNum: "1/2565",
|
||||
// fiscalYear: 2565,
|
||||
// OrderDate: "30 พ.ค. 2565",
|
||||
// OrderBy: "สำนักงาน กทม.",
|
||||
// Signer: "นาม สมคิด ยอดใจ ",
|
||||
// OrderStatus: "จัดทำร่างคำสั่ง",
|
||||
// OrderType: "คำสั่งย้าย",
|
||||
// },
|
||||
]);
|
||||
// const OrderStatusOption = [
|
||||
// "ทั้งหมด",
|
||||
// "ยังไม่ได้บรรจุ",
|
||||
// "บรรจุแล้ว",
|
||||
// "ยังไม่ได้ออกคำสั่ง",
|
||||
// ];
|
||||
|
||||
let OriginalData = ref<FormOrderPlacementMainData[]>([]);
|
||||
let UpdataData = ref<FormOrderPlacementMainData[]>([]);
|
||||
|
|
@ -497,13 +370,27 @@ onMounted(async () => {
|
|||
});
|
||||
|
||||
const OriginalDataFetch = async () => {
|
||||
// API
|
||||
// await http.get(config.API.listOrder()).then((res: any) => {
|
||||
// console.log("list", res);
|
||||
// });
|
||||
// .catch((e: any) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
await http
|
||||
.get(config.API.listOrder())
|
||||
.then((res: any) => {
|
||||
console.log("list", res);
|
||||
rows.value = res.data.result.map((e: any) => ({
|
||||
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 () => {
|
||||
// });
|
||||
await DataStore.DataMainOrder(rows.value);
|
||||
|
|
@ -513,7 +400,6 @@ const OriginalDataFetch = async () => {
|
|||
|
||||
// ดูรายการหน้าต่อไป
|
||||
const redirectToPage = (id?: string) => {
|
||||
console.log(id);
|
||||
router.push(`/placement/order/detail/${id}`);
|
||||
};
|
||||
|
||||
|
|
@ -528,27 +414,27 @@ const clickDelete = (id: string) => {
|
|||
persistent: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
// await deleteData(id);
|
||||
await deleteData(id);
|
||||
})
|
||||
.onCancel(() => {})
|
||||
.onDismiss(() => {});
|
||||
};
|
||||
|
||||
// const deleteData = async (id: string) => {
|
||||
// showLoader();
|
||||
// await http
|
||||
// .delete(config.API.orderReplace(id))
|
||||
// .then((res) => {
|
||||
// success($q, "ลบข้อมูลสำเร็จ");
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(async () => {
|
||||
// hideLoader();
|
||||
// await fetchData();
|
||||
// });
|
||||
// };
|
||||
const deleteData = async (id: string) => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.detailOrder(id))
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
await OriginalDataFetch();
|
||||
});
|
||||
};
|
||||
|
||||
const clickAdd = () => {
|
||||
router.push({ name: "Orderplacementadd" });
|
||||
|
|
@ -568,14 +454,13 @@ const fiscalyearOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหม
|
|||
const addedfiscalYearValues: number[] = [];
|
||||
const fiscalYearFilter = async () => {
|
||||
await http.get(config.API.yearOptionsOrder()).then((res) => {
|
||||
console.log(res);
|
||||
// console.log(res);
|
||||
const response = res.data.result;
|
||||
fiscalyearOP.push(...response);
|
||||
// const maxNumber = fiscalyearOP.reduce((max: any, e: any) => {
|
||||
// return e.id > max ? e.id : max;
|
||||
// }, "");
|
||||
// fiscalyear.value = maxNumber;
|
||||
// console.log(fiscalyear.value);
|
||||
});
|
||||
// API
|
||||
// await http
|
||||
|
|
@ -607,13 +492,13 @@ const fiscalYearFilter = async () => {
|
|||
};
|
||||
|
||||
const OrderType = ref<string>("");
|
||||
const OrderTypeOption = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]);
|
||||
const OrderTypeOption = reactive<DataOption1[]>([{ id: "", name: "ทั้งหมด" }]);
|
||||
const addedOrderTypeValues: string[] = [];
|
||||
const OrderTypeFilter = async () => {
|
||||
await http
|
||||
.get(config.API.typeOrder())
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
// console.log(res.data);
|
||||
const response = res.data.result;
|
||||
OrderTypeOption.push(...response);
|
||||
})
|
||||
|
|
@ -660,7 +545,9 @@ const OrderStatus = ref<string>("");
|
|||
const OrderStatusText = ref<FormOrderPlacementMainData[]>(
|
||||
DataStore.DataMainOrigOrder
|
||||
);
|
||||
const OrderStatusOption = reactive<DataOption[]>([{ id: 1, name: "ทั้งหมด" }]);
|
||||
const OrderStatusOption = reactive<DataOption1[]>([
|
||||
{ id: "", name: "ทั้งหมด" },
|
||||
]);
|
||||
const addedOrderStatusValues: string[] = [];
|
||||
const OrderStatusFilter = async () => {
|
||||
// API
|
||||
|
|
@ -677,7 +564,6 @@ const OrderStatusFilter = async () => {
|
|||
// });
|
||||
for (let data of OriginalData.value) {
|
||||
const OrderStatusValue = data.OrderStatus;
|
||||
console.log(OrderStatusValue);
|
||||
|
||||
if (
|
||||
OrderStatusValue === null ||
|
||||
|
|
@ -687,35 +573,17 @@ const OrderStatusFilter = async () => {
|
|||
}
|
||||
|
||||
if (!addedOrderStatusValues.includes(OrderStatusValue)) {
|
||||
// console.log(OrderStatusValue);
|
||||
|
||||
OrderStatusOption.push({
|
||||
// id: OrderStatusValue,
|
||||
id: OrderStatusOption.length,
|
||||
id: OrderStatusOption.length.toString(),
|
||||
name: 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 filterRef = ref<any>(null);
|
||||
|
|
@ -727,22 +595,27 @@ const resetFilter = () => {
|
|||
const attrs = ref<any>(useAttrs());
|
||||
|
||||
const searchFilterTable = async () => {
|
||||
if (fiscalyear.value !== null && fiscalyear.value !== 0) {
|
||||
fiscalyear.value += 543;
|
||||
if (OrderType.value == "ทั้งหมด") {
|
||||
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(
|
||||
OrderType.value,
|
||||
OrderStatus.value,
|
||||
fiscalyear.value
|
||||
);
|
||||
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 paginationLabel = (start: string, end: string, total: string) => {
|
||||
|
|
|
|||
|
|
@ -511,9 +511,10 @@ const clickEditRow = () => (editRow.value = true);
|
|||
onMounted(async () => {
|
||||
if (orderId) {
|
||||
await fetchdetailOrder();
|
||||
} else {
|
||||
fecthTypeOption();
|
||||
fecthExamRoundOption();
|
||||
}
|
||||
fecthTypeOption();
|
||||
fecthExamRoundOption();
|
||||
|
||||
// const data = localStorage.getItem("formData");
|
||||
// if (data) {
|
||||
|
|
@ -537,6 +538,20 @@ onMounted(async () => {
|
|||
const fetchdetailOrder = async () => {
|
||||
showLoader();
|
||||
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 () => {
|
||||
await http
|
||||
|
|
@ -567,7 +582,7 @@ const submit = async () => {
|
|||
orderBy: byOrder.value,
|
||||
signatoryBy: nameCommand.value,
|
||||
signatoryPosition: positionCommand.value,
|
||||
examRound: test.value,
|
||||
examRound: examRound.value,
|
||||
registerPosition: position.value,
|
||||
conclusionRegisterNo: register.value,
|
||||
conclusionRegisterDate: dateRegister.value,
|
||||
|
|
@ -586,9 +601,7 @@ const submit = async () => {
|
|||
persistent: true,
|
||||
}).onOk(async () => {
|
||||
showLoader();
|
||||
// localStorage.setItem("formData", JSON.stringify(formdata));
|
||||
createListOrder(formdata);
|
||||
// next();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -269,6 +269,8 @@ export const useOrderPlacementDataStore = defineStore("placementOrder", () => {
|
|||
item.OrderStatus === filter_2 &&
|
||||
item.fiscalYear === filterYear
|
||||
);
|
||||
} else if (filter_1 == "ทั้งหมด" && filter_2 == "ทั้งหมด" && filterYear !== null) {
|
||||
DataMainUpdateOrder.value = DataMainOrigOrder.value;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue