This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-16 10:26:09 +07:00
parent 51707646e7
commit df481043b1
9 changed files with 138 additions and 91 deletions

View file

@ -149,13 +149,14 @@ function onSubmit() {
formData.responsibility != null ? formData.responsibility : "",
};
//
if (actionType.value === "ADD") {
await http
.post(config.API.createOrgLevel(type.toLocaleLowerCase()), body)
.then(() => {
props.fetchDataTree(store.draftId);
success($q, "บันทึกข้อมูลสำเร็จ");
closeClear();
.then(async () => {
await props.fetchDataTree(store.draftId);
await success($q, "บันทึกข้อมูลสำเร็จ");
await closeClear();
})
.catch((err) => {
messageError($q, err);
@ -164,6 +165,7 @@ function onSubmit() {
hideLoader();
});
} else {
//
props.dataNode &&
(await http
.put(
@ -173,32 +175,35 @@ function onSubmit() {
),
body
)
.then(() => {
props.fetchDataTree(store.draftId);
props.edit?.(
.then(async () => {
await props.fetchDataTree(store.draftId);
await props.edit?.(
props.dataNode?.orgTreeId,
type,
body,
props.dataNode?.orgRootCode
);
closeClear();
props.fetchDataTable(
await props.fetchDataTable(
props?.dataNode?.orgTreeId,
props?.dataNode?.orgLevel,
false
);
success($q, "บันทึกข้อมูลสำเร็จ");
await success($q, "บันทึกข้อมูลสำเร็จ");
await closeClear();
})
.catch((err) => {
messageError($q, err);
})
.finally(async () => {
.finally(() => {
hideLoader();
}));
}
});
}
/**
* function เช formdata กลบไปคาวาง และป popup
*/
function closeClear() {
formData.orgName = "";
formData.orgShortName = "";
@ -211,14 +216,14 @@ function closeClear() {
props.close?.();
}
/**
* callback function ทำงานเมอมการเป popup
*/
watch(
() => props.modal,
() => {
if (props.modal === true) {
if (actionType.value === "ADD") {
// console.log(props.dataNode);
// console.log(level.value);
if (props.dataNode) {
formData.orgCode =
props?.dataNode?.orgLevel !== 0
@ -261,6 +266,9 @@ watch(
}
);
/**
* title ของ popup
*/
const tittleName = computed(() => {
let name = "";
if (actionType.value === "ADD") {
@ -272,6 +280,11 @@ const tittleName = computed(() => {
return name;
});
/**
* function เลอกระดบของสวนราชการ
* @param val
* @param status
*/
function selectOrgLevele(val: string, status: boolean = true) {
formData.orgLevelSub = status ? "" : formData.orgLevelSub;
switch (val) {