API แก้ไขอัตรากำลัง
This commit is contained in:
parent
98bef466d6
commit
e69db49a3f
5 changed files with 118 additions and 36 deletions
|
|
@ -19,6 +19,7 @@ import type {
|
|||
OptionExecutive,
|
||||
DataPosition,
|
||||
} from "@/modules/02_organizationalNew/interface/response/organizational";
|
||||
import type { FilterMaster } from "@/modules/02_organizationalNew/interface/request/organizational";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
|
|
@ -28,8 +29,11 @@ const props = defineProps({
|
|||
orgLevel: Number,
|
||||
treeId: String,
|
||||
actionType: String,
|
||||
rowId: String,
|
||||
fetchDataTable: Function,
|
||||
});
|
||||
|
||||
const reqMaster = defineModel<FilterMaster>("reqMaster", { required: true });
|
||||
const isReadonly = ref<boolean>(false); // อ่านได้อย่างเดียว
|
||||
const isDisValidate = ref<boolean>(false);
|
||||
|
||||
|
|
@ -216,7 +220,11 @@ async function fetchPosition(id: string) {
|
|||
await http
|
||||
.get(config.API.orgPosPositionById(id))
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
const data = res.data.result;
|
||||
formData.prefixNo = data.posMasterNoPrefix;
|
||||
formData.positionNo = data.posMasterNo;
|
||||
formData.suffixNo = data.posMasterNoSuffix;
|
||||
rows.value = data.positions;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -346,18 +354,42 @@ function onSubmit() {
|
|||
positions: positionsData,
|
||||
};
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.orgPosMaster, body)
|
||||
.then((res) => {
|
||||
success($q, "เพิ่มข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
props.close?.();
|
||||
hideLoader();
|
||||
});
|
||||
props.actionType === "ADD"
|
||||
? await http
|
||||
.post(config.API.orgPosMaster, body)
|
||||
.then(() => {
|
||||
success($q, "เพิ่มข้อมูลสำเร็จ");
|
||||
props.fetchDataTable?.(
|
||||
reqMaster.value.id,
|
||||
reqMaster.value.type,
|
||||
false
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
props.close?.();
|
||||
hideLoader();
|
||||
})
|
||||
: props.rowId &&
|
||||
(await http
|
||||
.put(config.API.orgPosMasterById(props.rowId), body)
|
||||
.then(() => {
|
||||
success($q, "แก้ไขข้อมูลสำเร็จ");
|
||||
props.fetchDataTable?.(
|
||||
reqMaster.value.id,
|
||||
reqMaster.value.type,
|
||||
false
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
props.close?.();
|
||||
hideLoader();
|
||||
}));
|
||||
});
|
||||
}
|
||||
/** ฟังชั่น บันทึก */
|
||||
|
|
@ -411,7 +443,6 @@ async function searchInput() {
|
|||
`?keyword=${search.value}&type=${type.value}`
|
||||
)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
rowsPositionSelect.value = res.data.result;
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -462,7 +493,7 @@ watch(
|
|||
rows.value = [];
|
||||
clearFormPositionSelect();
|
||||
} else {
|
||||
// props.treeId && fetchPosition(props.treeId);
|
||||
props.rowId && fetchPosition(props.rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -487,7 +518,7 @@ function deletePos(id: string) {
|
|||
showLoader();
|
||||
http
|
||||
.delete(config.API.orgPosPositionById(id))
|
||||
.then((res) => {
|
||||
.then(() => {
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue