From 4225b6bd06403d39c6abc7631706427b63df199c Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 13 Jul 2023 17:30:16 +0700 Subject: [PATCH] check disable --- src/api/05_placement/api.placement.ts | 2 + .../components/PersonalList/OrgTree.vue | 1022 ++++++++++------- 2 files changed, 609 insertions(+), 415 deletions(-) diff --git a/src/api/05_placement/api.placement.ts b/src/api/05_placement/api.placement.ts index 00a562918..5c51c3b35 100644 --- a/src/api/05_placement/api.placement.ts +++ b/src/api/05_placement/api.placement.ts @@ -44,4 +44,6 @@ export default { //education placementEducationId: (id: string) => `${placement}/education/${id}`, + // position + placementPosition: () => `${placement}/position/use`, }; diff --git a/src/modules/05_placement/components/PersonalList/OrgTree.vue b/src/modules/05_placement/components/PersonalList/OrgTree.vue index 8014155d9..994f207f7 100644 --- a/src/modules/05_placement/components/PersonalList/OrgTree.vue +++ b/src/modules/05_placement/components/PersonalList/OrgTree.vue @@ -16,488 +16,680 @@ const noData = ref("ไม่พบข้อมูลผังโคร const checkValidate = ref(false); const myFormPosition = ref(); -const selected = ref("") +const selected = ref(""); // Set form field let dataForm = reactive({ - personalId: "", - containDate: new Date(), - posNoId: "", - positionId: "", - positionLevelId: "", - positionLineId: "", - positionPathSideId: "", - positionTypeId: "", - salaryAmount: null, - mouthSalaryAmount: null, - positionSalaryAmount: null, + personalId: "", + containDate: new Date(), + posNoId: "", + positionId: "", + positionLevelId: "", + positionLineId: "", + positionPathSideId: "", + positionTypeId: "", + salaryAmount: null, + mouthSalaryAmount: null, + positionSalaryAmount: null, }); onMounted(() => { - loadTreeData(); -}) + loadTreeData(); + fetchplacementPosition(); +}); // โหลดข้อมูลโครงสร้างจาก json const treeData = ref>([]); const loadTreeData = async () => { - await http - .get(config.API.orgTree) - .then((res: any) => { - treeData.value = res.data; - }) - .catch((e: any) => { - messageError($q, e); - }) - .finally(() => { - hideLoader(); - }); + await http + .get(config.API.orgTree) + .then((res: any) => { + treeData.value = res.data; + }) + .catch((e: any) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +}; +// โหลด position +const placementPosition = ref([]); +const fetchplacementPosition = async () => { + await http + .get(config.API.placementPosition()) + .then((res: any) => { + placementPosition.value = res.data.result; + }) + .catch((e: any) => { + messageError($q, e); + }); }; const search = ref(""); //reset Tree Filter -const filterRef = ref(null) +const filterRef = ref(null); const resetFilter = () => { - search.value = ""; - filterRef.value.focus(); + search.value = ""; + filterRef.value.focus(); }; const props = defineProps({ - personalId: String, - modal: Boolean, - close: { - type: Function, - default: () => console.log('close modal'), - }, + personalId: String, + modal: Boolean, + close: { + type: Function, + default: () => console.log("close modal"), + }, }); const myFilterMethod = (node: any, filter: string) => { - const filt = filter; + const filt = filter; - return ((node.name && node.name == null) || !node.name) && ((node.organizationName && node.organizationName.indexOf(filt) > -1) || - (node.positionNum && node.positionNum.indexOf(filt) > -1) || - (node.positionName && node.positionName.indexOf(filt) > -1) || - (node.governmentCode && - node.governmentCode.toString().indexOf(filt) > -1) || - (node.agency && node.agency.indexOf(filt) > -1) || - (node.government && node.government.indexOf(filt) > -1) || - (node.department && node.department.indexOf(filt) > -1) || - (node.pile && node.pile.indexOf(filt) > -1) || - (node.organizationShortName && - node.organizationShortName.indexOf(filt) > -1) || - (node.positionSideName && node.positionSideName.indexOf(filt) > -1) || - (node.executivePosition && node.executivePosition.indexOf(filt) > -1) || - (node.executivePositionSide && - node.executivePositionSide.indexOf(filt) > -1) || - (node.positionLevel && node.positionLevel.indexOf(filt) > -1)) -} + return ( + ((node.name && node.name == null) || !node.name) && + ((node.organizationName && node.organizationName.indexOf(filt) > -1) || + (node.positionNum && node.positionNum.indexOf(filt) > -1) || + (node.positionName && node.positionName.indexOf(filt) > -1) || + (node.governmentCode && + node.governmentCode.toString().indexOf(filt) > -1) || + (node.agency && node.agency.indexOf(filt) > -1) || + (node.government && node.government.indexOf(filt) > -1) || + (node.department && node.department.indexOf(filt) > -1) || + (node.pile && node.pile.indexOf(filt) > -1) || + (node.organizationShortName && + node.organizationShortName.indexOf(filt) > -1) || + (node.positionSideName && node.positionSideName.indexOf(filt) > -1) || + (node.executivePosition && node.executivePosition.indexOf(filt) > -1) || + (node.executivePositionSide && + node.executivePositionSide.indexOf(filt) > -1) || + (node.positionLevel && node.positionLevel.indexOf(filt) > -1)) + ); +}; const validateData = async () => { - checkValidate.value = true; - await myFormPosition.value.validate().then((result: boolean) => { - if (result == false) { - checkValidate.value = false; - } - }); + checkValidate.value = true; + await myFormPosition.value.validate().then((result: boolean) => { + if (result == false) { + checkValidate.value = false; + } + }); }; const saveAppoint = async () => { - myFormPosition.value.validate().then(async (result: boolean) => { - if (result) { - const dataAppoint = await { - personalId: props.personalId, - containDate: dataForm.containDate, - posNoId: dataForm.posNoId, - positionId: dataForm.positionId, - positionLevelId: dataForm.positionLevelId, - positionLineId: dataForm.positionLineId, - positionPathSideId: dataForm.positionPathSideId, - positionTypeId: dataForm.positionTypeId, - salaryAmount: dataForm.salaryAmount, - mouthSalaryAmount: dataForm.mouthSalaryAmount, - positionSalaryAmount: dataForm.positionSalaryAmount, - }; - // console.log("save appoint===>", dataAppoint); + myFormPosition.value.validate().then(async (result: boolean) => { + if (result) { + const dataAppoint = await { + personalId: props.personalId, + containDate: dataForm.containDate, + posNoId: dataForm.posNoId, + positionId: dataForm.positionId, + positionLevelId: dataForm.positionLevelId, + positionLineId: dataForm.positionLineId, + positionPathSideId: dataForm.positionPathSideId, + positionTypeId: dataForm.positionTypeId, + salaryAmount: dataForm.salaryAmount, + mouthSalaryAmount: dataForm.mouthSalaryAmount, + positionSalaryAmount: dataForm.positionSalaryAmount, + }; + // console.log("save appoint===>", dataAppoint); - showLoader(); - await http - .post(config.API.placementPass(), dataAppoint) - .then((res) => { - console.log("respone=>", res) - success($q, "บันทึกสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(async () => { - await closeAndClear() - await resetFilter() - hideLoader() - }); - } - }); + showLoader(); + await http + .post(config.API.placementPass(), dataAppoint) + .then((res) => { + console.log("respone=>", res); + success($q, "บันทึกสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(async () => { + await closeAndClear(); + await resetFilter(); + hideLoader(); + }); + } + }); }; const editDataStatus = ref(false); const clickEditRow = () => { - editDataStatus.value = true; + editDataStatus.value = true; }; const closeModal = () => { - if (editDataStatus.value == true) { - $q.dialog({ - title: `ข้อมูลมีการแก้ไข`, - message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`, - cancel: "ยกเลิก", - ok: "ยืนยัน", - persistent: true, - }).onOk(() => { - editDataStatus.value = false; - closeAndClear() - }); - } else { - closeAndClear() - } -} + if (editDataStatus.value == true) { + $q.dialog({ + title: `ข้อมูลมีการแก้ไข`, + message: `ยืนยันที่จะปิดโดยไม่บันทึกใช่หรือไม่?`, + cancel: "ยกเลิก", + ok: "ยืนยัน", + persistent: true, + }).onOk(() => { + editDataStatus.value = false; + closeAndClear(); + }); + } else { + closeAndClear(); + } +}; const closeAndClear = async () => { - await props.close(); - editDataStatus.value = false; - selected.value = "" - dataForm.personalId = ''; - dataForm.containDate = new Date() - dataForm.posNoId = "" - dataForm.positionId = "" - dataForm.positionLevelId = "" - dataForm.positionLineId = "" - dataForm.positionPathSideId = "" - dataForm.positionTypeId = "" - dataForm.salaryAmount = null - dataForm.mouthSalaryAmount = null; - dataForm.positionSalaryAmount = null -} + await props.close(); + editDataStatus.value = false; + selected.value = ""; + dataForm.personalId = ""; + dataForm.containDate = new Date(); + dataForm.posNoId = ""; + dataForm.positionId = ""; + dataForm.positionLevelId = ""; + dataForm.positionLineId = ""; + dataForm.positionPathSideId = ""; + dataForm.positionTypeId = ""; + dataForm.salaryAmount = null; + dataForm.mouthSalaryAmount = null; + dataForm.positionSalaryAmount = null; +}; // ตำแหน่งเลขที่ -const posNoOptions = ref([{ - label: '', - value: '' -}]); +const posNoOptions = ref([ + { + label: "", + value: "", + }, +]); // ตำแหน่ง -const positionOptions = ref([{ - label: '', - value: '' -}]); +const positionOptions = ref([ + { + label: "", + value: "", + }, +]); // ด้าน/สาขา -const positionPathSideOptions = ref([{ - label: '', - value: '' -}]); +const positionPathSideOptions = ref([ + { + label: "", + value: "", + }, +]); // ตำแหน่งประเภท -const positionTypeOptions = ref([{ - label: '', - value: '' -}]); +const positionTypeOptions = ref([ + { + label: "", + value: "", + }, +]); // สายงาน -const positionLineOptions = ref([{ - label: '', - value: '' -}]); +const positionLineOptions = ref([ + { + label: "", + value: "", + }, +]); // ระดับ -const positionLevelOptions = ref([{ - label: '', - value: '' -}]); +const positionLevelOptions = ref([ + { + label: "", + value: "", + }, +]); const selectedPosition = async (data: any) => { + if (data.name == null && selected.value != data.keyId) { + console.log("selecteds", data); - if (data.name == null && selected.value != data.keyId) { - console.log("selecteds", data) + editDataStatus.value = true; + selected.value = data.keyId; - editDataStatus.value = true; - selected.value = data.keyId + // posNo Options + posNoOptions.value = [ + { + label: data.positionNum, + value: data.positionNumId, + }, + ]; + dataForm.posNoId = data.positionNumId; - // posNo Options - posNoOptions.value = [{ - label: data.positionNum, - value: data.positionNumId, - }] - dataForm.posNoId = data.positionNumId; + // position Options + positionOptions.value = [ + { + label: data.positionName, + value: data.positionNameId, + }, + ]; + dataForm.positionId = data.positionNameId; - // position Options - positionOptions.value = [{ - label: data.positionName, - value: data.positionNameId, - }] - dataForm.positionId = data.positionNameId; - - // positionPathSide Options - let positionPathSideArr: any = []; - if (data.positionSideNameObj != null) { - data.positionSideNameObj.map((x: any) => { - positionLevelsArr.push({ - label: x.Name, - value: x.Id, - }) - }) - positionPathSideOptions.value = positionPathSideArr; - dataForm.positionPathSideId = positionPathSideArr.length > 1 || positionPathSideArr.length == 0 ? '' : positionPathSideArr[0].value; - } - - // positionType Options - positionTypeOptions.value = [{ - label: data.positionType, - value: data.positionTypeId, - }] - dataForm.positionTypeId = data.positionTypeId; - - // positionLine Options - positionLineOptions.value = [{ - label: data.positionLine, - value: data.positionLineId, - }] - dataForm.positionLineId = data.positionLineId; - - - // positionLevel Options - let positionLevelsArr: any = []; - if (data.positionLevelObj != null) { - data.positionLevelObj.map((x: any) => { - positionLevelsArr.push({ - label: x.Name, - value: x.Id, - }) - }) - positionLevelOptions.value = positionLevelsArr; - dataForm.positionLevelId = positionLevelsArr.length > 1 || positionLevelsArr.length == 0 ? '' : positionLevelsArr[0].value; - } - - } else if (selected.value == data.keyId) { - selected.value = ''; - dataForm.posNoId = ""; - dataForm.positionId = ""; - dataForm.positionLevelId = ""; - dataForm.positionLineId = ""; - dataForm.positionPathSideId = ""; - dataForm.positionTypeId = ""; + // positionPathSide Options + let positionPathSideArr: any = []; + if (data.positionSideNameObj != null) { + data.positionSideNameObj.map((x: any) => { + positionLevelsArr.push({ + label: x.Name, + value: x.Id, + }); + }); + positionPathSideOptions.value = positionPathSideArr; + dataForm.positionPathSideId = + positionPathSideArr.length > 1 || positionPathSideArr.length == 0 + ? "" + : positionPathSideArr[0].value; } -} + + // positionType Options + positionTypeOptions.value = [ + { + label: data.positionType, + value: data.positionTypeId, + }, + ]; + dataForm.positionTypeId = data.positionTypeId; + + // positionLine Options + positionLineOptions.value = [ + { + label: data.positionLine, + value: data.positionLineId, + }, + ]; + dataForm.positionLineId = data.positionLineId; + + // positionLevel Options + let positionLevelsArr: any = []; + if (data.positionLevelObj != null) { + data.positionLevelObj.map((x: any) => { + positionLevelsArr.push({ + label: x.Name, + value: x.Id, + }); + }); + positionLevelOptions.value = positionLevelsArr; + dataForm.positionLevelId = + positionLevelsArr.length > 1 || positionLevelsArr.length == 0 + ? "" + : positionLevelsArr[0].value; + } + } else if (selected.value == data.keyId) { + selected.value = ""; + dataForm.posNoId = ""; + dataForm.positionId = ""; + dataForm.positionLevelId = ""; + dataForm.positionLineId = ""; + dataForm.positionPathSideId = ""; + dataForm.positionTypeId = ""; + } +}; +const checkPosition = (val: string) => { + const num = placementPosition.value.findIndex((e: string) => e === val); + return num; +}; \ No newline at end of file +