modules_dormitory_dorm-cmb.js

import { HCmb } from "../academic/h-cmb";
import { getMenuId } from "../../adapters/ezworks/com-api/get-menu-id";
import { YySmr } from "../academic/yy-smr-wrapper";

export class DormCmb extends HCmb {
    /**
     * 데이터를 검색합니다.
     *
     * @returns {Promise}
     * @access private
     */
    searchData() {
        var sParam = " MENU_ID='" + getMenuId(this.fm) + "'";
        sParam += " TASK_DTL_CD='" + this.taskDtlCd + "'";

        this._ds_yy = new Dataset("_ds_yy");
        this._ds_smr = new Dataset("_ds_smr");
        this._ds_org = new Dataset("_ds_org");
        this.fm.addChild(this.unique("_ds_yy"), this._ds_yy);
        this.fm.addChild(this.unique("_ds_smr"), this._ds_smr);
        this.fm.addChild(this.unique("_ds_org"), this._ds_org);

        const dataList = [
            {
                sqlId: "$hcmb.dormSchdl",
                outDs: this.unique("_ds_yy"),
            },
            {
                sqlId: "$hcmb.dormSmr",
                outDs: this.unique("_ds_smr"),
            },
            {
                sqlId: "$hcmb.dormOrg", //생활관조직
                outDs: this.unique("_ds_org"),
            },
        ];

        return this.fm.tx.search({
            action: "basic",
            svcId: this.unique("getDormCmb"),
            //sqlId: dataList.map((v) => v.sqlId).join(" "),
            //outDs: dataList.map((v) => v.outDs).join(" "),
            sqlId: "$hcmb.dormOrg",
            outDs: this.unique("_ds_org"),
            param: sParam,
        });
    }

    /**
     * 연도, 학기 초기화
     *
     * @access private
     */
    initYySmrValue() {
        this.yy = this._ds_yy.getColumn(0, "YY");
        this.smr = this._ds_yy.getColumn(0, "SMR");
    }
}

/**
 * 생활관 전용 콤보입니다. 학사콤보를 상속합니다.
 *
 * @function getDormCmb
 * @param {nexacro.Form} form  현재 폼 (this)
 * @returns {DormCmb}
 * @memberof $f
 * @example
 * // 기본 사용법
 * $f.getDormCmb(this).init({
 *     div: [this.div_search],
 *     grid: [this.grd_main],
 * });
 *
 * // 특정 조직 필터링
 * $f.getDormCmb(this).init({
 *     div: this.div_search,
 *     orgFilter: (ctx) => ctx.rowData["UNIV_CD"] === "03130000",
 * });
 *
 * // 콤보 모드 설정
 * $f.getDormCmb(this).init({
 *     div: this.div_search,
 *     orgMode: {
 *         // 조직 콤보 모드
 *         fclt: "a", // 대학/대학원: '전체' 표시
 *         univ: "s", // 대학: '선택' 표시
 *         dpmj: "n", // 학과: 빈값 없음
 *         majr: "n", // 전공: 빈값 없음
 *         detMajr: "n", // 세부전공: 빈값 없음
 *     },
 *     smrMode: "a", // 학기 콤보: '전체' 표시
 * });
 *
 * // 문자열로 모든 모드 일괄 설정
 * $f.getDormCmb(this).init({
 *     div: this.div_search,
 *     orgMode: "a", // 모든 조직 콤보에 '전체' 표시
 *     smrMode: "a", // 학기 콤보: '전체' 표시
 * });
 *
 * // 그리드 콤보 모드 설정
 * $f.getDormCmb(this).init({
 *     grid: this.grd_main,
 *     orgGridMode: {
 *         // 그리드 조직 콤보 모드
 *         fclt: "s", // 대학/대학원: '선택' 표시
 *         univ: "s", // 대학: '선택' 표시
 *         dpmj: "n", // 학과: 빈값 없음
 *     },
 *     smrGridMode: "s", // 그리드 학기 콤보: '선택' 표시
 * });
 *
 * // 바인딩 컴포넌트 대상 변경
 * $f.getDormCmb(this).init({
 *     div: this.div_search,
 *     targtCompNm: {
 *         // 컴포넌트 명 재정의
 *         yyCompNm: /^spn_aplyYy$/,
 *         smrCompNm: /^cmb_aplySmr$/,
 *         fcltCompNm: /^cmb_fcltDvcd$/,
 *         univCompNm: /^cmb_testUnivCd$/,
 *         dpmjCompNm: /^cmb_hakgwaCd$/,
 *         majrCompNm: /^cmb_majrCd$/,
 *         detMajrCompNm: /^cmb_detMajrCd$/,
 *
 *         // 그리드 컬럼 명 재정의
 *         smrColNm: ["SMR", "GRDU_SMR"],
 *         fcltGridColNm: "FCLT_DVCD",
 *         univColNm: "CUSTOM_1",
 *         dpmjColNm: "CUSTOM_2",
 *         majrColNm: "CUSTOM_3",
 *         detMajrColNm: "detMajrColNm",
 *     },
 * });
 *
 */
export function getDormCmb(form) {
    if (!(form instanceof nexacro.Form)) {
        return null;
    }

    return new DormCmb(form);
}