no message
This commit is contained in:
parent
1484c9288d
commit
626e6023c3
4 changed files with 143 additions and 40 deletions
|
|
@ -4,24 +4,31 @@ import http from "@/plugins/http";
|
|||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
const $q = useQuasar(); //ใช้ noti quasar
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, success } = mixin;
|
||||
const { messageError, success, showLoader, hideLoader } = mixin;
|
||||
const route = useRoute();
|
||||
|
||||
const type_params = route.params.type;
|
||||
const props = defineProps({
|
||||
retireld: String,
|
||||
listId: String,
|
||||
UpdateListId: Function,
|
||||
});
|
||||
|
||||
const modal = ref<boolean>(false);
|
||||
const retireld = ref<any>();
|
||||
const type = ref<any>();
|
||||
const listId = ref(props.listId);
|
||||
|
||||
const columns = ref<any["columns"]>([
|
||||
{
|
||||
name: "order",
|
||||
name: "index",
|
||||
required: true,
|
||||
label: "ลำดับ",
|
||||
field: "order",
|
||||
field: "index",
|
||||
align: "left",
|
||||
},
|
||||
{
|
||||
|
|
@ -108,27 +115,73 @@ const filter = ref<string>("");
|
|||
watch(modal, () => {
|
||||
if (modal.value === true) {
|
||||
retireld.value = props.retireld;
|
||||
fecthlistRetire(retireld.value);
|
||||
if (type_params === "officer") {
|
||||
type.value = type_params;
|
||||
} else type.value = "all";
|
||||
|
||||
fecthlistRetire();
|
||||
}
|
||||
});
|
||||
const fecthlistRetire = async (retireld: any) => {
|
||||
// await http
|
||||
// .get(config.API.listRetire(retireld))
|
||||
// .then((res) => {
|
||||
// console.log(res);
|
||||
// rows.value = res.data.result.map((e: any) => ({
|
||||
// order: e.order,
|
||||
// fullname: e.fullName,
|
||||
// position: e.position,
|
||||
// level: e.positionEmployeeLevel,
|
||||
// organizationOrganization: e.organizationOrganization,
|
||||
// }));
|
||||
// })
|
||||
// .catch((e) => {
|
||||
// messageError($q, e);
|
||||
// });
|
||||
const updateListId = (val: any) => {
|
||||
listId.value = val;
|
||||
if (props.UpdateListId) {
|
||||
props.UpdateListId(listId.value);
|
||||
}
|
||||
};
|
||||
const clickAdd = () => {
|
||||
const fecthlistRetire = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.profileOrganizRoot)
|
||||
.then((res) => {
|
||||
const id = res.data.result[0].id;
|
||||
console.log(id);
|
||||
if (id !== "") {
|
||||
findlist(id);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
});
|
||||
};
|
||||
|
||||
const findlist = async (id: string) => {
|
||||
let data = [{}];
|
||||
if (type.value === "officer") {
|
||||
data = [{ criteriaType: "is_retire", criteriaValue: "false" }];
|
||||
} else if (type.value === "all") {
|
||||
console.log("all");
|
||||
data = [
|
||||
{ criteriaType: "is_retire", criteriaValue: "false" },
|
||||
{ criteriaType: "employee_class", criteriaValue: "perm" },
|
||||
];
|
||||
}
|
||||
console.log(data);
|
||||
|
||||
await http
|
||||
.post(config.API.profileSearchNewOcIdType(id, type.value), {
|
||||
criterias: data,
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data.result);
|
||||
rows.value = res.data.result.map((e: any) => ({
|
||||
id: e.id,
|
||||
fullname: e.fullname,
|
||||
position: e.position,
|
||||
level: e.positionEmployeeLevel,
|
||||
organizationOrganization: e.oc,
|
||||
}));
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
const clickAdd = (props: any) => {
|
||||
console.log(props.row.id);
|
||||
let data: any = props.row.id;
|
||||
|
||||
$q.dialog({
|
||||
title: "ยืนยันการเพิ่มข้อมูล",
|
||||
message: "ต้องการเพิ่มข้อมูลนี้ใช่หรือไม่?",
|
||||
|
|
@ -141,15 +194,17 @@ const clickAdd = () => {
|
|||
.onOk(async () => {
|
||||
console.log("เพิ่มข้อมูล");
|
||||
await http
|
||||
.put(config.API.profileRetire("123"))
|
||||
.then(() => {
|
||||
.put(config.API.profileRetire(data), { profileId: data })
|
||||
.then((res) => {
|
||||
success($q, "เพิ่มข้อมูลสำเร็จ");
|
||||
updateListId(data);
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
fecthlistRetire();
|
||||
modal.value = false;
|
||||
});
|
||||
})
|
||||
.onCancel(() => {})
|
||||
|
|
@ -236,10 +291,10 @@ const paginationLabel = (start: number, end: number, total: number) => {
|
|||
</template>
|
||||
<template v-slot:body="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<!-- <q-td>{{ props.rowIndex + 1 }}</q-td> -->
|
||||
<q-td key="order" :props="props">
|
||||
<q-td>{{ props.rowIndex + 1 }}</q-td>
|
||||
<!-- <q-td key="order" :props="props">
|
||||
{{ props.row.order }}
|
||||
</q-td>
|
||||
</q-td> -->
|
||||
<q-td key="fullname" :props="props">
|
||||
{{ props.row.fullname }}
|
||||
</q-td>
|
||||
|
|
@ -254,9 +309,10 @@ const paginationLabel = (start: number, end: number, total: number) => {
|
|||
<q-td>
|
||||
<q-btn
|
||||
outline
|
||||
:props="props"
|
||||
label="เพิ่ม"
|
||||
class="text-teal-5"
|
||||
@click="clickAdd"
|
||||
@click="clickAdd(props)"
|
||||
/>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue