diff --git a/src/components/CardProfile.vue b/src/components/CardProfile.vue index e73dbbab3..eabeeb3a0 100644 --- a/src/components/CardProfile.vue +++ b/src/components/CardProfile.vue @@ -33,12 +33,22 @@ const profile = reactive({ }); const modalPersonal = ref(false); +const profileId = ref(""); + function fetchDataProfile(data: DataProfile) { fetchProfile(data.profileId); + profile.id = data.profileId; profile.fullName = `${data.prefix}${data.firstName} ${data.lastName}`; - profile.position = data.position !== "" ? data.position : "-"; - profile.positionLevel = `${data.posTypeName} (${data.posLevelName})`; + profile.position = + data.position == "" || data.position === null ? "-" : data.position; + if (data.posTypeName && data.posLevelName) { + profile.positionLevel = `${data.posTypeName} (${data.posLevelName})`; + } else if (data.posTypeName) { + profile.positionLevel = `${data.posTypeName}`; + } else if (data.posLevelName) { + profile.positionLevel = `(${data.posLevelName})`; + } else profile.positionLevel = "-"; profile.organization = findOrgName(data); } @@ -73,6 +83,7 @@ watch( () => props.data, () => { const dataMain = props.data as DataProfile; + profileId.value = dataMain.profileId; fetchDataProfile(dataMain); } ); @@ -86,6 +97,7 @@ watch( ([]); const mixin = useCounterMixin(); -const { showLoader, success, messageError, dialogConfirm, hideLoader } = mixin; +const { + showLoader, + success, + messageError, + dialogConfirm, + hideLoader, + findOrgName, +} = mixin; /** คอลัมน์ */ const columns2 = ref([ @@ -33,6 +42,9 @@ const columns2 = ref([ field: "fullname", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.prefix}${row.firstName} ${row.lastName}`; + }, }, { name: "position", @@ -46,29 +58,44 @@ const columns2 = ref([ { name: "positionLevel", align: "left", - label: "ระดับ", + label: "ประเภทตำแหน่ง", sortable: true, field: "positionLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + let name = ""; + if (row.posTypeName && row.posLevelName) { + name = `${row.posTypeName} (${row.posLevelName})`; + } else if (row.posTypeName) { + name = `${row.posTypeName}`; + } else if (row.posLevelName) { + name = `(${row.posLevelName})`; + } else name = "-"; + return name; + }, }, { - name: "organizationPositionOld", + name: "org", align: "left", label: "สังกัด", sortable: true, - field: "organizationPositionOld", + field: "org", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return findOrgName(row); + }, }, { - name: "statustext", + name: "status", align: "left", label: "สถานะ", sortable: true, - field: "statustext", + field: "status", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (val) => statusText(val), }, ]); @@ -78,16 +105,15 @@ const visibleColumns2 = ref([ "fullname", "position", "positionLevel", - "positionNumberOld", - "organizationPositionOld", - "statustext", + "org", + "status", ]); /** props*/ const props = defineProps({ modal: Boolean, closeModal: Function, - getData: Function, + fecthlistRecevice: Function, rows2: Array, filterKeyword2: String, }); @@ -128,7 +154,7 @@ const Ordersave = async () => { messageError($q, e); }) .finally(async () => { - props.getData?.(); + props.fecthlistRecevice?.(); hideLoader(); }); }; @@ -224,31 +250,15 @@ watchEffect(() => { v-model="props.selected" /> - - {{ props.rowIndex + 1 }} - - - {{ props.row.fullname }} - - - {{ props.row.position }} - - - {{ props.row.positionLevel }} - - -
- {{ props.row.organizationPositionOld }} + +
+ {{ props.rowIndex + 1 }}
-
- -
- {{ props.row.organization }} + +
+ {{ col.value ? col.value : "-" }}
- - {{ props.row.statustext }} - diff --git a/src/modules/06_retirement/components/DismissOrder/DismissOrder.vue b/src/modules/06_retirement/components/DismissOrder/DismissOrder.vue index c855856ea..49e0e64a6 100644 --- a/src/modules/06_retirement/components/DismissOrder/DismissOrder.vue +++ b/src/modules/06_retirement/components/DismissOrder/DismissOrder.vue @@ -22,6 +22,7 @@ const { hideLoader, success, dialogMessage, + findOrgName, } = mixin; const { statusText } = transferStore; const modal = ref(false); @@ -32,9 +33,9 @@ const visibleColumns = ref([ "fullname", "position", "positionLevel", - "organizationPositionOld", + "org", "createdAt", - "statustext", + "status", ]); //ค้นหา คอลัมน์ คอลัมน์ที่แสดง @@ -64,6 +65,9 @@ const columns = ref([ field: "fullname", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.prefix}${row.firstName} ${row.lastName}`; + }, }, { name: "position", @@ -77,20 +81,34 @@ const columns = ref([ { name: "positionLevel", align: "left", - label: "ระดับ", + label: "ประเภทตำแหน่ง", sortable: true, field: "positionLevel", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + let name = ""; + if (row.posTypeName && row.posLevelName) { + name = `${row.posTypeName} (${row.posLevelName})`; + } else if (row.posTypeName) { + name = `${row.posTypeName}`; + } else if (row.posLevelName) { + name = `(${row.posLevelName})`; + } else name = "-"; + return name; + }, }, { - name: "organizationPositionOld", + name: "org", align: "left", label: "สังกัด", sortable: true, - field: "organizationPositionOld", + field: "org", headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return findOrgName(row); + }, }, { name: "createdAt", @@ -100,15 +118,17 @@ const columns = ref([ field: "createdAt", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (val) => date2Thai(val), }, { - name: "statustext", + name: "status", align: "left", label: "สถานะ", sortable: true, - field: "statustext", + field: "status", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (val) => statusText(val), }, ]); onMounted(async () => { @@ -140,33 +160,8 @@ const getData = async () => { .get(config.API.retirementOut) .then((res: any) => { const data = res.data.result; - let list: ResponseData[] = []; - data.map((r: ResponseData) => { - list.push({ - createdAt: date2Thai(r.createdAt), - date: r.date, - firstName: r.firstName ?? "", - id: r.id ?? "", - isActive: r.isActive ? r.isActive : false, - lastName: r.lastName ?? "", - organization: r.organization ?? "", - organizationPositionOld: r.organizationPositionOld ?? "", - posNo: r.posNo ?? "", - position: r.position ?? "", - positionLevel: r.positionLevel ?? "", - positionLevelOld: r.positionLevelOld ?? "", - positionNumberOld: r.positionNumberOld ?? "", - positionTypeOld: r.positionTypeOld ?? "", - prefix: r.prefix ?? "", - reason: r.reason ?? "", - salary: r.salary ? r.salary : 0, - status: r.status ?? "", - statustext: statusText(r.status ?? ""), - fullname: `${r.prefix ?? ""}${r.firstName ?? ""} ${r.lastName ?? ""}`, - }); - }); - rows.value = list; - filters.value = list; + rows.value = data; + filters.value = data; }) .catch((e) => { messageError($q, e); @@ -192,7 +187,7 @@ const clickDelete = async (id: string) => { const deleteData = async (id: string) => { await http .delete(config.API.outByid(id)) - .then((res) => { + .then(() => { success($q, "ลบข้อมูลสำเร็จ"); }) .catch((e) => { @@ -295,70 +290,38 @@ const pagination = ref({