fix: leave commander position

This commit is contained in:
Warunee Tamkoo 2025-12-08 17:43:59 +07:00
parent 1542ff854e
commit 9176cf4fa7

View file

@ -18,6 +18,25 @@ const dataStore = useLeaveStore();
const storeData = useDataStore(); const storeData = useDataStore();
const { date2Thai, messageError } = useCounterMixin(); const { date2Thai, messageError } = useCounterMixin();
/** ฟังก์ชันสำหรับลบคำที่ซ้ำติดกัน */
function removeDuplicateWords(text: string): string {
if (!text) return text;
//
const words = text.split(/(?=[ก-๙])/);
const result: string[] = [];
for (let i = 0; i < words.length; i++) {
const word = words[i];
if (i === 0 || word !== words[i - 1]) {
result.push(word);
}
}
// : regex
return text.replace(/([ก-๙]+)\1+/g, "$1");
}
/** รับ props มาจากหน้าหลัก */ /** รับ props มาจากหน้าหลัก */
const props = defineProps({ const props = defineProps({
model: { model: {
@ -56,11 +75,14 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px", style: "font-size: 14px",
}, },
{ {
name: "posExecutiveName", name: "posExecutiveNameOrg",
align: "left", align: "left",
label: "ตำแหน่งทางการบริหาร", label: "ตำแหน่งทางการบริหาร",
sortable: true, sortable: true,
field: "posExecutiveName", field: "posExecutiveNameOrg",
format(val) {
return removeDuplicateWords(val || "");
},
headerStyle: "font-size: 14px", headerStyle: "font-size: 14px",
style: "font-size: 14px", style: "font-size: 14px",
}, },
@ -136,7 +158,9 @@ function onSubmit() {
? `${selected.value[0].prefix}${selected.value[0].firstName} ${selected.value[0].lastName}` ? `${selected.value[0].prefix}${selected.value[0].firstName} ${selected.value[0].lastName}`
: ""; : "";
dataStore.commanderPosition = selected.value[0].posExecutiveName; dataStore.commanderPosition = removeDuplicateWords(
selected.value[0].posExecutiveNameOrg || ""
);
} }
/** /**