reportForm.js 5.61 KB
Newer Older
1 2 3 4
/**
 * ReportForm function js
 * @since cms:1.4.3.2&1.4.3.3 web:1.0
 */
5 6 7

var RF = {};

8 9
RF.addReportFlg;

10 11 12
/**
 * init
 */
Takumi Imai committed
13
RF.init = function () {
14 15 16 17 18 19 20 21 22 23 24
    let count = 0;
    if (new COMMON.sysSetting() != null) {
        clearInterval(set_interval_id);
    } else {
        count++;
        if (count >= 5) {
            clearInterval(set_interval_id);
            COMMON.goUrlWithCurrentParams(CONSTANT.PAGE_NAME.LOGIN);
        }
        return;
    }
25
    COMMON.showLoading();
26
    //Check if user is logged in
27
    COMMON.checkAuth(false);
28
    COMMON.checkQuickReport(function (result) {
29
        if (result) {
Kang Donghun committed
30
            RF.addReportFlg = result.addReportFlg;
31
        }
32
    });
33 34 35
    RF.loadCommon();
};

36
RF.interval = setInterval(RF.init(), 1000);
37

Takumi Imai committed
38 39 40
/**
 * load common
 */
41
RF.loadCommon = function () {
Kang Donghun committed
42 43
    TEMPLATE.loadHeader('#includedHeader');
    TEMPLATE.loadConfirmModal('#includedConfirmModal');
44
    RF.initBreadcrumb();
45 46
};

47 48 49
/**
 * create breadcrumb menu on ReportForm
 */
50
RF.initBreadcrumb = function () {
51 52 53 54 55 56 57
    let navs = [];
    const reportFormBread = { titleLang: CONSTANT.PAGE_NAME.REPORT_FORM };
    const reportListBread = {
        titleLang: CONSTANT.PAGE_NAME.REPORT_LIST,
        href: CONSTANT.URL_TREE_NAME.REPORT_LIST,
    };

58
    if (sessionStorage.activeHomePage == CONSTANT.PAGE_TAB.DASHBOARD) {
59 60 61 62 63 64
        const dashBordBread = {
            titleLang: CONSTANT.PAGE_NAME.DASHBOARD,
            href: CONSTANT.URL_TREE_NAME.DASHBOARD,
        };
        let pickupBread = { titleLang: CONSTANT.PAGE_NAME.PICKUP };

65
        if (sessionStorage.getItem('pickUpType') == CONSTANT.PICK_UP_TYPE.CONTINOUS_WORK) {
66 67
            pickupBread.href = CONSTANT.URL_TREE_NAME.PICKUP_CONTINUOS;
            navs = [dashBordBread, pickupBread, reportFormBread];
68
        } else if (sessionStorage.getItem('pickUpType') == CONSTANT.PICK_UP_TYPE.WARNING_REPORT) {
69 70
            pickupBread.href = CONSTANT.URL_TREE_NAME.PICKUP_WARNING;
            navs = [dashBordBread, pickupBread, reportFormBread];
71
        } else {
72 73
            pickupBread.href = CONSTANT.URL_TREE_NAME.PICKUP_NEW;
            navs = [dashBordBread, pickupBread, reportListBread, reportFormBread];
74 75
        }
    } else {
76
        if (sessionStorage.getItem('pickUpType')) sessionStorage.removeItem('pickUpType');
77 78 79 80
        const operationListBread = {
            titleLang: CONSTANT.PAGE_NAME.OPERATION_LIST,
            href: CONSTANT.URL_TREE_NAME.OPERATION_LIST,
        };
Kang Donghun committed
81

82 83 84
        const reportType = sessionStorage.getItem('reportType');
        if ((RF.addReportFlg && RF.addReportFlg == 1) || reportType == CONSTANT.REPORT_TYPE_INT.ROUTINE) {
            navs = [operationListBread, reportListBread, reportFormBread];
85
        } else {
86
            navs = [operationListBread, reportFormBread];
87 88
        }
    }
89
    TEMPLATE.loadMainNavsTitle('#includedMainTitle', CONSTANT.PAGE_NAME.REPORT_FORM, navs, RF.loadMainTitleCallback);
90
};
91

92 93 94
/**
 * load main title callcack
 */
95
RF.loadMainTitleCallback = function () {
96
    const elmInspect = $(
Takumi Imai committed
97
        '<div id ="inspectLabelWeb" style="display: none; margin:0 auto">' +
98 99 100
            '<div><span class=" lang" style="font-size:18px;" lang="periodicInspectionPeriod"></span></div>' +
            '<div><span id="inspectDate"></span></div></div>',
    );
101 102
    let elmA = $('<div class="quickReportBtn" id="quickReportBtn" onclick="submitForm();">');
    const elmImg = $('<img src="../common/img/icon_pdf.svg" alt="pdf出力" class="p-1 w-40px" data-toggle="tooltip" data-placement="bottom" title="pdfPrint">');
103 104
    elmA.append(elmImg);
    $('#mainTitleHeader').after(elmA);
105
    $('#mainTitleHeader').after(elmInspect);
106 107 108

    // load form html
    RF.initFormView();
109
};
110

Takumi Imai committed
111 112 113
/**
 * iinit form view
 */
114 115 116
RF.initFormView = function () {
    const urlParameterList = COMMON.getUrlParameter();
    const operationId = urlParameterList['operationId'];
Takumi Imai committed
117
    sessionStorage.setItem(['operationId'], operationId);
118 119
    if (operationId) {
        let params = {};
Takumi Imai committed
120 121 122 123
        const taskKey = urlParameterList['taskKey'];
        const replyNo = urlParameterList['replyNo'];
        const processKey = urlParameterList['processKey'];
        const phaseNo = urlParameterList['phaseNo'];
Takumi Imai committed
124
        const reportStartDate = urlParameterList['reportStartDate'];
Takumi Imai committed
125

126 127
        params.sid = COMMON.getSid();
        params.operationId = operationId;
128
        params.lang = I18N.getCurrentLanguage;
Takumi Imai committed
129 130 131 132
        if (taskKey) params.taskKey = taskKey;
        if (replyNo) params.replyNo = replyNo;
        if (processKey) params.processKey = processKey;
        if (phaseNo) params.phaseNo = phaseNo;
Takumi Imai committed
133
        if (reportStartDate) params.reportStartDate = reportStartDate;
Takumi Imai committed
134

135
        const url = COMMON.format(ClientData.conf_checkApiUrl(), ClientData.userInfo_accountPath()) + CONSTANT.URL.CMS.HTML.BASE + CONSTANT.URL.CMS.HTML.LIST_REPORT_FORM;
136 137
        $('#report-form').load(url, params, function () {
            initPageLoad();
138
            COMMON.closeLoading();
139
        });
140
    } else {
Takumi Imai committed
141
        COMMON.avwScreenMove('index.html');
142 143
    }
};
144 145 146 147 148

/**
 * back page url
 */
RF.backPage = function () {
149 150 151 152 153
    // need to save Data
    setTimeout(function () {
        RF.initFormView();
    }, 750);

154
    if (sessionStorage.activeHomePage == CONSTANT.PAGE_TAB.DASHBOARD) {
Takumi Imai committed
155
        if (sessionStorage.getItem('pickUpType') == CONSTANT.PICK_UP_TYPE.NEW_REPORT) {
156 157 158 159 160
            COMMON.avwScreenMove('reportList.html');
        } else {
            COMMON.avwScreenMove('pickup.html');
        }
    } else {
Takumi Imai committed
161
        const reportType = sessionStorage.getItem('reportType');
162
        if (addReportFlg == 1 || reportType == CONSTANT.REPORT_TYPE_INT.ROUTINE) {
163 164 165 166 167 168
            COMMON.avwScreenMove('reportList.html');
        } else {
            COMMON.avwScreenMove('index.html');
        }
    }
};