//데이터, 테이블, 상단 버튼
let _listTable            = null;
let searchBtn             = null;
let fltrCheck2            = null;
let fltrCheck1            = null;
let fltrLwstSped          = null;
let fltrHghsSped          = null;
let trafMinNum            = null;
let trafMaxNum            = null;
let fifoCheck             = null;
let fifoTable             = null;
let weightCheck           = null;
let weightTable           = null;
let adjsNoCheck           = null;
let adjsCheck             = null;
let adjsPttr              = null;
let adjsWghtAvrgPre3Cycl  = null;
let adjsWghtAvrgPre2Cycl  = null;
let adjsWghtAvrgPre1Cycl  = null;
let fftnPttrCheck         = null;
let loopNum               = null;
let smthNoCheck           = null;
let smthLimitCheck        = null;
let minSpedNum            = null;
let maxSpedNum            = null;
let smthFiftAvgCheck      = null;
let smthWghtAvrgPre2Cycl  = null;
let smthWghtAvrgPre1Cycl  = null;
let smthWghtAvrgPrst      = null;
let allActiveBtn          = null;
let selectActiveBtn       = null;
let fifoData              = [];
let fltrChecker           = [];
let fusnChecker           = [];
let adjsChecker           = [];
let smthChecker           = [];
let fusnData              = [];
let _selectedLink         = null;
let fusnListData          = [];
let _paramId              = null;
let fusnMaxCheck          = null;
const _apiUri             = '/api/database/link-para-stup';
const fusnUri             = '/api/database/clct-syst-stup';
const clctSystStupLinkUri = '/api/database/link';

$(()=>{
    //상단 조회 버튼
    searchBtn = $(".search-button").dxButton({
        stylingMode:'outlined',
        text:'조회',
        icon:'refresh',
        height:'30px',
        width: '80px',
        onClick(){
            _listTable.clearSelection();
            _listTable.option('focusedRowIndex', -1);
            fetchBaseData();
        }
    }).dxButton("instance")
    _paramId = new dxSelect($('.param-select'), 'outlined', '80%', '30px', 'para_nm', 'para_id', false);
    _paramId.onItemClick((e)=>{settingData(e.itemData.para_id)});
    const popupBtn    = new dxBtn($('.popup-btn'), '가공 파라미터 설정', '', 'outlined');
    popupBtn.onClick(openEditPopup);
    //상단 닫기 버튼
    $(".cancle-button").dxButton({
        text:'닫기',
        icon:'close',
        height:'30px',
        width: '80px',
        stylingMode:'outlined',
        onClick(){
            window.close();
        }
    }).dxButton("instance")
    
    //전체 선택 버튼
    $(".all-sel-btn").dxButton({
        text:'전체선택',
        height:'30px',
        width: '100px',
        stylingMode:'outlined',
        onClick(){
            _listTable.selectAll();
        }
    }).dxButton("instance")

    //전체 해제 버튼
    $(".all-desel-btn").dxButton({
        text:'전체해제',
        height:'30px',
        width: '100px',
        stylingMode:'outlined',
        onClick(){
            _listTable.deselectAll();
        }
    }).dxButton("instance")

    //필터링 파라미터
    //사용안함 체크
    fltrCheck1 = $('.fltr-check1').dxCheckBox({
        value: false,
        text: '사용안함',
        onValueChanged(data) {
            fltrCheck2.option("value",!data.value);
        },
    }).dxCheckBox("instance");
    
    //범위값 체크
    fltrCheck2 = $('.fltr-check2').dxCheckBox({
        value: true,
        text: '범위값 사용',
        onValueChanged(data) {
            fltrCheck1.option("value",!data.value);
            trafMaxNum.option("disabled",!data.value);
            trafMinNum.option("disabled",!data.value);
            fltrHghsSped.option("disabled",!data.value);
            fltrLwstSped.option("disabled",!data.value);
            $(".fltr-box").toggleClass("dx-nav-item");
            $(".fltr-box").toggleClass("dx-theme-border-color-as-background-color");
        },
    }).dxCheckBox("instance");
    
    //교통량 최저 넘버
    trafMinNum = $(".traf-min").dxNumberBox({
        width           : '100px',
        height          : '25px',
        value           : 1,
        showSpinButtons : true,
        min             : 0,
        max             : 999999,
        stylingMode     : "outlined",
    }).dxNumberBox("instance");

    //교통량 최대 넘버
    trafMaxNum = $(".traf-max").dxNumberBox({
        width           : '100px',
        height          : '25px',
        value           : 200,
        min             : 0,
        max             : 999999,
        showSpinButtons : true,
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    
    //속도 최저 넘버
    fltrLwstSped = $(".sped-min").dxNumberBox({
        width           : '100px',
        height          : '25px',
        value           : 1,
        min             : 0,
        max             : 999,
        showSpinButtons : true,
        stylingMode:"outlined",
    }).dxNumberBox("instance");
    
    //속도 최대 넘버    
    fltrHghsSped = $(".sped-max").dxNumberBox({
        width           : '100px',
        height          : '25px',
        value           : 200,
        min             : 0,
        max             : 999,
        showSpinButtons : true,
        stylingMode     : "outlined",
    }).dxNumberBox("instance");

  
    //우선순위 테이블
    fifoTable = $(".fifo-table").width('100%').height("100%").dxDataGrid({
        dataSource              : [],
        allowColumnReordering   : true,
        showColumnLines         : true,
        allowColumnResizing     : true,
        showBorders             : true,
        rowAlternationEnabled   : true,
        columnAutoWidth         : true,
        noDataText              : '표출할 정보가 없습니다.',
        keyExpr                 : 'clct_syst_cd',
        selection: {
            mode : 'single',
        },
        headerFilter: {
            visible : false,
        },
        editing:{
            mode: 'cell',
            allowUpdating: true,
        },
        scrolling: {
            mode : 'virtual',
        },
        columns:[
            {   
                dataField    : "clct_syst_desc",
                caption      : "수집원",
                alignment    : "center",
                allowEditing : false,
                // sortIndex    : 0,
                // sortOrder    : "asc",
                cssClass     : "noPadding",
                validationRules: [{ type: 'required' }],
                cellTemplate(c,e){
                    let result = nullChecker(e.displayValue);
                    return  $('<div style="text-align: left;">'+result+'</div>')
                }
            },
            {
                dataField :"fusn_prrt",
                caption   :"우선순위",
                alignment :"center",
                cssClass  : "noPadding",
                lookup    :{
                    dataSource:fifoData,
                    displayExpr:'fusn_prrt',
                    valueExpr:'fusn_prrt',
                },
                cellTemplate(c,e){
                    if (nullChecker(e.data.fusn_prrt) === "" ){
                        return c.text("사용안함")
                    }
                    return c.text(e.data.fusn_prrt);
                }
            },]
    }).dxDataGrid("instance");

      //퓨전 파라미터
    //우선순위 체크
    fifoCheck = $('.fifo-check').dxCheckBox({
        value: true,
        text: '우선순위',
        onValueChanged(data) {
            if (data.value) {
                weightCheck.option("value", false);
                fifoTable.option("disabled", false);
                fusnMaxCheck.option("value", false);
                weightTable.option("disabled",data.value);
                $(".fifo-box").removeClass("dx-nav-item");
                $(".fifo-box").addClass("dx-theme-border-color-as-background-color");
             }
            
        },
    }).dxCheckBox("instance");
    
    //가중치 체크
    weightCheck = $('.weight-check').dxCheckBox({
        value: false,
        text: '가중치',
        onValueChanged(data) {
            if (data.value) {
                fifoCheck.option("value",!data.value);
                fifoTable.option("disabled",data.value);
                fusnMaxCheck.option("value", false);
                weightTable.option("disabled",!data.value);
                $(".weight-box").removeClass("dx-nav-item");
                $(".weight-box").addClass("dx-theme-border-color-as-background-color");
           }
        },
    }).dxCheckBox("instance");
    
    //최대값 체크
    fusnMaxCheck = $('.fusn-max-check').dxCheckBox({
        value: false,
        text: '최대값',
        onValueChanged(data) {
            if (data.value) {
                fifoCheck.option("value", false);
                weightCheck.option("value", false);
                fifoTable.option("disabled", true);
                weightTable.option("disabled", true);
                $(".fifo-box").addClass("dx-nav-item");
                $(".fifo-box").removeClass("dx-theme-border-color-as-background-color");
                $(".weight-box").addClass("dx-nav-item");
                $(".weight-box").removeClass("dx-theme-border-color-as-background-color");
            }
        },
    }).dxCheckBox("instance");

    //가중치 테이블
    weightTable = $(".weight-table").width('100%').height("100%").dxDataGrid({
        dataSource              : [],
        allowColumnReordering   : true,
        showColumnLines         : true,
        allowColumnResizing     : true,
        showBorders             : true,
        rowAlternationEnabled   : true,
        columnAutoWidth         : true,
        disabled                : true,
        noDataText              : '표출할 정보가 없습니다.',
        keyExpr                 : 'clct_syst_cd',
        headerFilter: {
            visible : false,
        },
        editing:{
            mode: 'cell',
            allowUpdating: true,
        },
        selection: {
            mode : 'single',
        },
        scrolling: {
            mode : 'virtual',
        },
        disabled : true,
        columns:[
            {   
                dataField    : "clct_syst_desc",
                caption      : "수집원",
                alignment    : "center",
                allowEditing : false,
                // sortIndex    : 0,
                // sortOrder    : "asc",
                cssClass     : "noPadding",
                cellTemplate(c,e){
                    alignTemplate(c, e,'left');
                }
            },
            {
                dataField    : "fusn_wght",
                caption      : "가중치",
                alignment    : "center",
                cssClass     : "noPadding",
                editorOptions:{
                    dataType        : "number",
                    showSpinButtons : true,
                    format          : '##0',
                    min             : 0,
                    max             : 100,
                },
                cellTemplate(c,e){
                    if(nullChecker(e.data.fusn_wght) === ""){
                        return c.text(10);
                    }
                    return c.text(e.data.fusn_wght);
                }
                
            },]
    }).dxDataGrid("instance");

    //3주기전 평균 넘버
    adjsWghtAvrgPre3Cycl = $(".thr-week-num").dxNumberBox({
        width           : '70px',
        height          : '25px',
        value           : 20,
        min             : 0,
        max             : 100,
        showSpinButtons : true,
        format          : '##0',
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    
    //2주기전 평균 넘버
    adjsWghtAvrgPre2Cycl = $(".two-week-num").dxNumberBox({
        width           : '70px',
        height          : '25px',
        value           : 30,
        min             : 0,
        max             : 100,
        showSpinButtons : true,
        format          : '##0',
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    
    //1주기전 평균 넘버
    adjsWghtAvrgPre1Cycl = $(".one-week-num").dxNumberBox({
        width           : '70px',
        height          : '25px',
        value           : 50,
        min             : 0,
        max             : 100,
        showSpinButtons : true,
        format          : '##0',
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    //단기 결측 판단 주기 넘버
    loopNum = $(".loop-num").dxNumberBox({
        width           : '70px',
        height          : '25px',
        value           : 3,
        min             : 0,
        max             : 99,
        showSpinButtons : true,
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    
    //사용안함 체크
    adjsNoCheck = $(".adjs-no-check").dxCheckBox({
        value: false,
        text: '사용안함',
        onValueChanged(data) {
            if(data.value){
                adjsCheck.option("value",false)
                adjsPttr.option("value",false)
            }
        },
    }).dxCheckBox("instance");
    
    //단기(15분이동평균)/장기(패턴) 체크
    adjsCheck = $(".adjs-check").dxCheckBox({
        value: true,
        text: '단기(15분이동평균)/장기(패턴)',
        onValueChanged(data) {
            if(data.value){
                adjsNoCheck.option("value",false);
                adjsPttr   .option("value",false);
            }
            $(".adjs-box").toggleClass("dx-theme-border-color-as-background-color");
            $(".adjs-box").toggleClass("dx-nav-item");
            adjsWghtAvrgPre3Cycl    .option("disabled",!data.value);
            adjsWghtAvrgPre2Cycl    .option("disabled",!data.value);
            adjsWghtAvrgPre1Cycl    .option("disabled",!data.value);
            fftnPttrCheck .option("disabled",!data.value);
            loopNum       .option("disabled",!data.value);
        },
    }).dxCheckBox("instance");
    
    //패턴 적용 체크
    adjsPttr = $(".adjs-pttr").dxCheckBox({
        value: false,
        text: '패턴적용',
        onValueChanged(data) {
            if(data.value){
                adjsCheck.option("value",false)
                adjsNoCheck.option("value",false)
            }
        },
    }).dxCheckBox("instance");
    
    //15분 패턴 추가 적용 체크
    fftnPttrCheck = $(".fftn-pttr-check").dxCheckBox({
        value: false,
        text: '15분 패턴 추가적용(장기 결측시)',
        onValueChanged(data) {
        },
    }).dxCheckBox("instance");

    //사용안함 체크
    smthNoCheck = $(".smth-no-check").dxCheckBox({
        stylingMode:'outlined',
        text:'사용안함',
        value: false,
        onValueChanged(data) {
            if(data.value){
                smthFiftAvgCheck.option("value",false);
                smthLimitCheck.option("value",false);
            }
        },
    }).dxCheckBox("instance");

    //편차제한 체크
    smthLimitCheck = $(".smth-limit-check").dxCheckBox({
        stylingMode:'outlined',
        text:'편차제한(최저-최대)',
        value: true,
        onValueChanged(data) {
            if(data.value){
                smthFiftAvgCheck.option("value",false);
                smthNoCheck.option("value",false);
            }
            $(".smth-sped-box").toggleClass("dx-nav-item");
            $(".smth-sped-box").toggleClass("dx-theme-border-color-as-background-color");
            minSpedNum.option("disabled",!data.value)
            maxSpedNum.option("disabled",!data.value)
            
        },
    }).dxCheckBox("instance");

    //15분 이동 평균 체크
    smthFiftAvgCheck = $(".smth-fift-avg-check").dxCheckBox({
        stylingMode:'outlined',
        text:'15분 이동평균(전체합=100)',
        value: false,
        onValueChanged(data) {
            if(data.value){
                smthLimitCheck.option("value",false);
                smthNoCheck.option("value",false);
            }
            $(".smth-avg-box").toggleClass("dx-nav-item");
            $(".smth-avg-box").toggleClass("dx-theme-border-color-as-background-color");
            smthWghtAvrgPre2Cycl.option("disabled",!data.value);
            smthWghtAvrgPre1Cycl.option("disabled",!data.value);
            smthWghtAvrgPrst.option("disabled",!data.value);
        },
    }).dxCheckBox("instance");

    //최저 속도 넘버
    minSpedNum = $(".min-sped-num").dxNumberBox({
        width           : '75px',
        height          : '25px',
        value           : 0.20,
        format          : '#0.##00',
        min             : 0.00,
        max             : 9.99,
        showSpinButtons : true,
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    //최대 속도 넘버
    maxSpedNum = $(".max-sped-num").dxNumberBox({
        width           : '75px',
        height          : '25px',
        value           : 2.00,
        format          : '#0.##00',
        min             : 0.00,
        max             : 9.99,
        showSpinButtons : true,
        stylingMode     : "outlined",
    }).dxNumberBox("instance");
    
    //2주기 가중치 넘버
    smthWghtAvrgPre2Cycl = $(".two-week-weight-num").dxNumberBox({
        stylingMode     :'outlined',
        width           : '70px',
        height          : '25px',
        min             : 0,
        max             : 100,
        format          : '##0',
        showSpinButtons : true,
        disabled:true,
    }).dxNumberBox("instance");

    //1주기 가중치 넘버
    smthWghtAvrgPre1Cycl = $(".one-week-weight-num").dxNumberBox({
        stylingMode     :'outlined',
        width           : '70px',
        height          : '25px',
        min             : 0,
        max             : 100,
        format          : '##0',
        showSpinButtons : true,
        disabled:true,
    }).dxNumberBox("instance");

    //현재 가중치 넘버
    smthWghtAvrgPrst = $(".crnt-weight-num").dxNumberBox({
        stylingMode     :'outlined',
        width           : '70px',
        height          : '25px',
        min             : 0,
        max             : 100,
        format          : '##0',
        showSpinButtons : true,
        disabled:true,
    }).dxNumberBox("instance");

    allActiveBtn = $(".all-active-btn").dxButton({
        stylingMode :'outlined',
        icon        : 'check',
        text        :'전체구간 적용',
        onClick(){
            const paramIdVal = _paramId.getValue()
            if (paramIdVal) {
                confirmMessage("전체 구간에 대하여 파라미터 정보를 설정합니다.<br>전체 구간에 대하여 파라미터 정보를 적용하시겠습니까?").done((yes) => {
                    if (yes === true) {
                        let result = postInsertUpdate(_apiUri + '/apply/all/' + paramIdVal);
                        if (result > 0) {
                            fetchListData();
                            return alertConfirm("파라미터 정보를 설정하였습니다.");
                        }
                    }
                });
            }
               
        }
    }).dxButton("instance");

    selectActiveBtn = $(".select-active-btn").dxButton({
        stylingMode:'outlined',
        icon : 'check',
        text:'선택구간 적용',
        disabled    : true,
        onClick(){
            const paramIdVal = _paramId.getValue();
            if (paramIdVal) {

                if(_listTable.getSelectedRowsData().length <= 0){
                    alertWarning("선택된 데이터가 없습니다. 파리미터 정보를 설정할 데이터를 선택해주세요");
                    return false;
                }
                
                confirmMessage("선택된 구간에 대하여 파라미터 정보를 설정합니다.<br>선택한 구간에 대하여 파라미터 정보를 적용하시겠습니까?").done((yes) => {
                    if (yes === true) {
                        let result = 0;
                        let updateId = [];
                        for(let ii = 0; ii < _listTable.getSelectedRowsData().length; ii ++){
                            updateId.push(_listTable.getSelectedRowsData()[ii].link_id)
                        }

                        result = postInsertUpdate( _apiUri + "/apply/select/" + paramIdVal + "/" + updateId);
                        if (result > 0) {
                            fetchListData();
                            alertConfirm("파라미터 정보를 설정하였습니다.");
                        }
                    }
                });

            }
        }
    }).dxButton("instance");
    
    fltrChecker   = [
        {
            check:fltrCheck1,
            data:"FMT0"
        },
        {
            check:fltrCheck2,
            data:"FMT1"
        }
    ]
    
    fusnChecker   = [
        {
            check:fifoCheck,
            data : "FST1",
        },
        {
            check:weightCheck,
            data : "FST2",
        },
        {
            check:fusnMaxCheck,
            data : "FST3",
        }
    ]
    
    adjsChecker   = [
        {
            check:adjsNoCheck,
            data:"MCA0",
        },
        {
            check:adjsCheck,
            data:"MCA1",
        },
        {
            check:adjsPttr,
            data:"MCA2",
        },
    ]
    
    smthChecker   = [
        {
            check:smthNoCheck,
            data:"SMT0",
        },
        {
            check:smthLimitCheck,
            data:"SMT1",
        },
        {
            check:smthFiftAvgCheck,
            data:"SMT2",
        },
    ]
    
    //링크 관리 테이블
    _listTable = $(".clct-syst-stup-table").width('100%').height("100%").dxDataGrid({
        dataSource              : null,
        allowColumnReordering   : true,
        showColumnLines         : true,
        allowColumnResizing     : true,
        showBorders             : true,
        rowAlternationEnabled   : true,
        columnAutoWidth         : true,
        focusedRowEnabled       : true,
        noDataText              : '표출할 정보가 없습니다.',
        keyExpr                 : 'link_id',
        filterRow: {
            visible: true,
            applyFilter: "auto",
            showOperationChooser:false,
        },
        scrolling               : {
            mode : 'standard',
        },
        paging: {
            enabled: true,
            pageSize: 1000,
        },
        selection: {
            mode        : 'single',
        },
        headerFilter: {
            visible : true,
        },
        grouping: {
            autoExpandAll : true,
        },
        scrolling: {
            mode : 'virtual',
        },
        groupPanel:{
            visible         : true,
            emptyPanelText  : "그룹 지을 항목을 여기에 끌어다 놓으세요"
        },
        
        columns:[
            {   
                dataField    : "link_id",
                caption      : "링크 ID",
                alignment    : "center",
                dataType     : 'string',
                allowEditing : false,
                sortIndex    : 0, 
                sortOrder    : "asc",
                validationRules: [{ type: 'required' }],
            },
            {
                dataField:"from_node",
                caption:"시작노드",
                alignment:"center",
                cellTemplate(c,e){
                    let result = nullChecker(e.displayValue);
                    return  $('<div style="text-align: left;">'+result+'</div>')
                }
            },
            {
                dataField:"to_node",
                caption:"종료노드",
                alignment:"center",
                cellTemplate(c,e){
                    let result = nullChecker(e.displayValue);
                    return  $('<div style="text-align: left;">'+result+'</div>')
                }
            },
            {
                dataField:"link_leng",
                caption:"길이(m)",
                alignment:"center",
            },
            {
                dataField:"road_name",
                caption:"도로명",
                alignment:"center",
                cellTemplate(c,e){
                    let result = nullChecker(e.displayValue);
                    return  $('<div style="text-align: left;">'+result+'</div>')
                }
            },
            {
                dataField:"road_no",
                caption:"도로번호",
                alignment:"center",
            },
            {
                dataField:"road_type_desc",
                caption:"도로유형",
                alignment:"center",
                cellTemplate(c, e) {
                    c.css('text-align', 'left');
                    c.text(e.displayValue);
                    return c;
                }
            },
            {
                dataField:"lanes",
                caption:"차로수",
                alignment:"center",
            },
        ],
        onRowClick(e) {
            if ( _selectedLink !== e.data.link_id ) {
                _selectedLink = e.data.link_id;
                dsblOnBtn(selectActiveBtn);
            }
        },
        onRowDblClick(e){
            if(nullChecker(e.data.para_id) !== ""){
                settingData(e.data.para_id);
                dsblOffBtn(selectActiveBtn);
            }
        }

    }).dxDataGrid("instance");
    
    fetchBaseData();
});
function openEditPopup() {
    window.open('./clct-syst-stup-edit-popup.html', '가공 파라미터 설정','width = 1700, height = 950, top = 40, left = 100, resizable=yes, scrollbars=no');
    $('.popup-screen').css('display', 'flex');
}
function fetchListData(method){
    getDataAsync(clctSystStupLinkUri, (jsonData)=>{ 
        _listTable.option('dataSource', jsonData);
        if(method) {
            method();
        }
    });
}
function fetchBaseData(){
    fetchListData();
    getDataAsync(fusnUri, (fusnData)=>{
        if (fusnData.length > 0) {
            for ( let ii = 1; ii <= fusnData.length; ii++){
                fusnListData.push({...fusnData[ii-1]});
                fusnListData[ii-1].fusn_prrt = ii;
                fusnListData[ii-1].fusn_wght = 10;
                fusnListData[ii-1].clct_syst_desc = fusnData[ii-1].clct_syst_nm;
                if(fusnData.length === ii){
                    fifoData.push({fusn_prrt:ii});
                    fifoData.push({fusn_prrt:'사용안함'});
                    break;
                } 
                
                fifoData.push({
                    fusn_prrt:ii,
                })
            }
        }
        fifoTable.option('dataSource', fusnListData);
        fifoTable.option('columns[1].lookup.dataSource', fifoData);
        weightTable.option('dataSource', fusnListData);
    });
    getDataAsync(_apiUri, (jsonData)=>{
        console.log(jsonData);
        _paramId.setDataSource(jsonData);
        _paramId.setValue(jsonData[0].para_id);
        settingData(jsonData[0].para_id);
    });
}
function settingData(id){
    _paramId.setValue(id);
    let paramData = [];
        let data      = null;
        let detl      = [];
        let wfData    = [];
        fifoData      = [];
        
        getData(_apiUri + '/' + id, paramData);
        
        if (paramData[0]) {
            data   = paramData[0];
            detl   = data.detl;
            wfData = data.clcts;
            wfData.map((item)=>{
                item.fusn_wght = item.fusn_wght * 100;
            });
            findCheckValue(fltrChecker, data.fltr_mthd_cd);
            findCheckValue(fusnChecker, data.fusn_mthd_cd);
            findCheckValue(smthChecker, data.smth_mthd_cd);
            findCheckValue(adjsChecker, data.adjs_mthd_cd);
            weightTable.option('dataSource',wfData);
            fifoTable.option('dataSource', wfData);
            
            if (detl) {
                setValue( adjsWghtAvrgPre3Cycl, detl.adjs_wght_avrg_pre_3cycl * 100 );
                setValue( adjsWghtAvrgPre2Cycl, detl.adjs_wght_avrg_pre_2cycl * 100 );
                setValue( adjsWghtAvrgPre1Cycl, detl.adjs_wght_avrg_pre_1cycl * 100 );
                setValue( minSpedNum, detl.smth_lwst_sped_fctr );
                setValue( maxSpedNum, detl.smth_hghs_sped_fctr );
                setValue( smthWghtAvrgPre2Cycl, detl.smth_wght_avrg_pre_2cycl * 100 );
                setValue( smthWghtAvrgPre1Cycl, detl.smth_wght_avrg_pre_1cycl * 100 );
                setValue( smthWghtAvrgPrst, detl.smth_wght_avrg_prst * 100 );
                setValue( fltrLwstSped, detl.fltr_lwst_sped );
                setValue( fltrHghsSped, detl.fltr_hghs_sped );
                setValue( trafMinNum, detl.fltr_min_tfvl );
                setValue( trafMaxNum, detl.fltr_max_tfvl );
                setValue( loopNum, detl.adjs_shtr_miss_decs_cycl );
                let result = detl.adjs_15m_ptrn_aply_yn === 'Y';
                setValue( fftnPttrCheck, result );
            }
        }
}

function findCheckValue(array, code){
    for (let idx in array) {
        if (array[idx].data === code) {
            return setValue(array[idx].check, true);
        } 
    }
}