객체접근

송용준·2025년 2월 12일

포맷 해주는 코드인데

// W/O 관리 format 변경
if (!this.gfn_IsNull(this.div_Search.form.edt_WorbNo.value)) {
    const length = this.div_Search.form.edt_WorbNo.value.length;
    const formats = {
        14: "@@@@-@-@@@@-@@-@@@",
        13: "@@@-@@@@-@@@-@@@",
        12: "@@@-@@@@-@@@-@@",
        11: "@@@@-@-@@@@-@@",
        10: "@@@-@@@@-@@@",
        9: "@@@@@@-@@@",
        1: "@",
    };

    // format이 존재하면 설정, 없으면 기본값 설정
    if (formats[length]) {
        this.div_Search.form.edt_WorbNo.set_format(formats[length]);
    } else {
        this.div_Search.form.edt_WorbNo.set_format("@@@@@@@@@@@@@@");
    }
} else {
    this.div_Search.form.edt_WorbNo.set_format("@@@@@@@@@@@@@@");
}

formats 은 객체이고 formats[length] 이런식으로 key 값에 따른 value에 접근함

profile
용용

0개의 댓글