fix: leave commander position
This commit is contained in:
parent
1542ff854e
commit
9176cf4fa7
1 changed files with 27 additions and 3 deletions
|
|
@ -18,6 +18,25 @@ const dataStore = useLeaveStore();
|
|||
const storeData = useDataStore();
|
||||
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 มาจากหน้าหลัก */
|
||||
const props = defineProps({
|
||||
model: {
|
||||
|
|
@ -56,11 +75,14 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "posExecutiveName",
|
||||
name: "posExecutiveNameOrg",
|
||||
align: "left",
|
||||
label: "ตำแหน่งทางการบริหาร",
|
||||
sortable: true,
|
||||
field: "posExecutiveName",
|
||||
field: "posExecutiveNameOrg",
|
||||
format(val) {
|
||||
return removeDuplicateWords(val || "");
|
||||
},
|
||||
headerStyle: "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}`
|
||||
: "";
|
||||
|
||||
dataStore.commanderPosition = selected.value[0].posExecutiveName;
|
||||
dataStore.commanderPosition = removeDuplicateWords(
|
||||
selected.value[0].posExecutiveNameOrg || ""
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue