require(['config'], function() {
    require([
        'jquery.bootstrap.fileUpload', //파일 업로드가 있는 페이지에서 로딩
        'kakao.map.util'
    ], function($) {
        pageObj.init();
    });
});


// 화면변수
const VENDINFO01010_DETAIL_GRID_ID = '#ITP_VENDINFO01010_DETAIL_jqGrid';
const VENDINFO01010_DETAIL_GRID_LIST = '#ITP_VENDINFO01010_DETAIL_jqGrid_list';
const VENDINFO01010_DETAIL_GRID_PAGER = '#ITP_VENDINFO01010_DETAIL_jqGridPager';
const VENDINFO01010_DETAIL_GRID_EMPTY = 'ITP_VENDINFO01010_DETAIL_jqGridEmpty';

let ITP_FORM_VENDINFO01010_DETAIL_IS_DUPLICATE = false;
let ITP_FORM_VENDINFO01010_DETAIL_IS_WRITING = false;

let ITP_COMMON_ASSGN_TASK = fn_make_common_cd_list(CODE_LIST, 'ASSGN_TASK', true, '담당업무');

let VENDINFO01010_GRID_LAST_ROW_ID;


//API URL
let API_SPPLY_DETAIL_GRID_LIST = '/api/spply/detail-grid-list';
let API_SPPLY_INFO_SPPLY = '/api/spply/info-spply';
let API_SPPLY_SAVE_SPPLY = '/api/spply/save-spply';


//화면 Grid Object
const gridColModel = {
    list: [],
    view: [],
    detail: [
    	{
			index: 'VIEW_CD', name: 'viewCd',
			label: ITP_MSG_LOCALE.label.viewCd,
			width: '10', fixed: false, align: 'center',
			sortable: false, hidden: true
		},
		{
			index: 'SPPLY_ID', name: 'spplyId',
			label: ITP_MSG_LOCALE.label.spplyId,
			width: '10', fixed: false, align: 'center',
			sortable: false, hidden: true
		},
		{
			index: 'SPPLY_MGR_ID', name: 'spplyMgrId',
			label: ITP_MSG_LOCALE.label.spplyMgrId,
			width: '10', fixed: false, align: 'center',
			sortable: false, hidden: true
		},
		{
			index: 'ASSGN_TASK_NM', name: 'spplyMgrNm',
			label: ITP_MSG_LOCALE.label.spplyMgrNm, 	//담당자명
			width: '10', fixed: false, align: 'left',
			sortable: false, editable: true, edittype: 'text',
			classes: 'input_color',
			editrules: {required: true},
			editoptions: {maxlength: 20}
		},
        {
            index: 'POSITION', name: 'position',
            label: ITP_MSG_LOCALE.label.position,		// 직위
            width: '10', fixed: false, align: 'left',
            classes: 'input_color',
            sortable: false, hidden: false, editable: true, edittype: 'text',
            editoptions: {maxlength: 20}
        },
        {
            index: 'RPRST_EMAL', name: 'rprstEmal',
            label: ITP_MSG_LOCALE.label.rprstEmal,		// 이메일
            width: '10', fixed: false, align: 'left',
            classes: 'input_color',
            sortable: false, hidden: false, editable: true, edittype: 'text',
            editoptions: {maxlength: 50}
        },
        {
            index: 'RPRST_TEL_NO', name: 'rprstTelNo',
            label: ITP_MSG_LOCALE.label.rprstTelNo,		// 전화번호
            width: '10', fixed: false, align: 'center',
            classes: 'input_color',
            sortable: false, hidden: false, editable: true, edittype: 'text',
            editoptions: {'data-key-up': 'tel', maxlength: 13}
        },
        {
            index: 'ASSGN_TASK', name: 'assgnTask',
            label: ITP_MSG_LOCALE.label.assgnTaskNm,	// 담당업무
            width: '10', fixed: false, align: 'left',
            classes: 'input_color',
            sortable: false, editable: true, formatter: 'select', edittype: 'select',
			editoptions: {value: ITP_COMMON_ASSGN_TASK},
			editrules: {required: false}
        }
    ]
};


// 화면공통 오브젝트
let pageObj = {
	init: function () {
        this.ui.init();
		this.event.init();
    },
    ui: {
        init: function () {
            this.view();
            this.grid();
            this.form();
            this.ready();
        },
        view: function() {
            // 버튼 권한설정
            fn_proc_btn_auth('VENDINFO01010');

            // 공통코드 표시
            $('select').each(function() {
                if($(this).data('select-code')) {
                    fn_make_select(CODE_LIST, $(this).data('select-code'), $(this).attr('id'));
                }
            });
        },
        form: function() {
			itp_fn_form_event.onKeyup('#ITP_FORM_VENDINFO01010_DETAIL');
		},
        grid: function() {
            itp_fn_jqgrid_resize(VENDINFO01010_DETAIL_GRID_ID, VENDINFO01010_DETAIL_GRID_LIST, 'lg');
            modifyObj.empty.init();
            itp_fn_fire_window_resize();
        },
        ready: function() {
            modifyObj.init();
        }
    },
    event: {
        init: function () {
            this.button();
        },
        button: function () {
            // 버튼 클릭 이벤트
            $('button').each(function() {
                var id = $(this).attr('id');
                $(this).on('click', function() {
                    switch (id) {
                        case 'ITP_BTN_VENDINFO01010_SRH'				: modifyObj.button.search();	break;	// 조회 버튼 클릭
                        case 'ITP_BTN_VENDINFO01010_NEWREG'				: modifyObj.button.create(); 	break;	// 신규등록 버튼
                        case 'ITP_BTN_VENDINFO01010_MODIFY'				: modifyObj.button.modify();	break;	// 수정 버튼
                        case 'ITP_BTN_VENDINFO01010_CANCELLIST'			: modifyObj.button.cancel(); 	break;	// 취소/목록 버튼
                        case 'ITP_BTN_VENDINFO01010_DELETE'				: 								break;	// 삭제 버튼
                        case 'ITP_BTN_VENDINFO01010_SAVE'				: modifyObj.button.save(); 		break;	// 저장 버튼
                        case 'ITP_FORM_VENDINFO01010_DETAIL_DUP'		: modifyObj.button.duplicate();	break;	// 중복체크
                        case 'ITP_BTN_VENDINFO01010_RESET_PW'			: modifyObj.button.resetPass();	break;	// 상세:비밀번호 초기화
                        case 'ITP_BTN_VENDINFO01010_DETAIL_ADRES_SCH'	: modifyObj.button.address();	break;	// 신규등록 주소 찾기
                        case 'ITP_BTN_VENDINFO01010_ADDROW'				: modifyObj.button.addRow();	break;	// 상세:추가버튼
                        case 'ITP_BTN_VENDINFO01010_DELROW'				: modifyObj.button.delRow();	break;	// 상세:삭제버튼
                    }
                });
            });
            
            $('body').on('click', function(e) {
				var gridId = VENDINFO01010_DETAIL_GRID_ID.replace('#', '');
				itp_fn_grid_reset_selection(e, VENDINFO01010_GRID_LAST_ROW_ID, gridId, 'VENDINFO01010');
			});
        }
    },
    fileUpload: function() {
        //파일업로드(수정화면)
        var id = 'VENDINFO01010';
        var acctScrId = 'VENDINFO01010_ACCT';
        $('#ITP_' + id + '_DETAIL_ACCT_FILE_UPLOAD').empty();
        $('#ITP_' + id + '_DETAIL_ACCT_FILE_LOGO_FILE').empty();
        var removeFn = (param) => {
			$('#ITP_' + id + '_DETAIL_ACCT_FILE_LOGO_FILE').empty();
		};
        const acctFileArgs = {
            'fileNo': $('#ITP_FORM_' + id + '_DETAIL_ACCT_FILE_NO').val(),
            'viewCd': $('#ITP_FORM_' + id + '_DETAIL_VIEW_CD').val(),
            'showYn': $('#ITP_' + id + '_DETAIL_ACCT_FILE_UPLOAD').attr('data-show-yn'),
            'fileId': '#ITP_FORM_' + id + '_DETAIL_ACCT_FILE_NO' //파일번호를 서버에서 받아서 넣을 파일번호 인풋박스 아이디
        };
        itp_fn_set_file_upload('ITP_' + id + '_DETAIL_ACCT_FILE_UPLOAD', 'spply1', true, false, acctScrId, acctFileArgs);
        
        /********************************************************************************/
        
		var corpScrId = 'VENDINFO01010_CORP';
		$('#ITP_' + id + '_DETAIL_CORP_FILE_UPLOAD').empty();
		$('#ITP_' + id + '_DETAIL_CORP_FILE_LOGO_FILE').empty();
		var removeFn2 = (param) => {
			$('#ITP_' + id + '_DETAIL_CORP_FILE_LOGO_FILE').empty();
		};
		const corpFileArgs = {
			'fileNo': $('#ITP_FORM_' + id + '_DETAIL_CORP_FILE_NO').val(),
			'viewCd': $('#ITP_FORM_' + id + '_DETAIL_VIEW_CD').val(),
			'showYn': $('#ITP_' + id + '_DETAIL_CORP_FILE_UPLOAD').attr('data-show-yn'),
			'fileId': '#ITP_FORM_' + id + '_DETAIL_CORP_FILE_NO' //파일번호를 서버에서 받아서 넣을 파일번호 인풋박스 아이디
		};
		itp_fn_set_file_upload('ITP_' + id + '_DETAIL_CORP_FILE_UPLOAD', 'spply2', true, false, corpScrId, corpFileArgs);
    },
    switchScreen: function(mode) {
		$('.itp_det_head').find('button[id^="ITP_BTN_VENDINFO01010_"]').each(function(i) {
			$(this).hide();
		});
		$('#ITP_TAB_VENDINFO01010').find('div[id$="_CONTAINER"]').each(function(i) {
			$(this).hide();
		});
		if(mode === 'LIST') { // 목록
			$('#ITP_AJAX_VENDINFO01010_LIST_CONTAINER').show();
			fn_show_btn_auth_array(['#ITP_BTN_VENDINFO01010_SRH', '#ITP_BTN_VENDINFO01010_NEWREG']);
		} else if(mode == 'ADD') { // 등록
			$('#ITP_AJAX_VENDINFO01010_DETAIL_CONTAINER').show();
			fn_show_btn_auth_array(['#ITP_BTN_VENDINFO01010_CANCELLIST', '#ITP_BTN_VENDINFO01010_SAVE']);

			$('#ITP_FORM_VENDINFO01010_DETAIL').find('input, textarea, select, checkbox').each(function(i, elem) {
				$(this).attr('id') === 'ITP_FORM_VENDINFO01010_DETAIL_VIEW_CD' ? $(this).val('C') : $(this).val('');
				if(elem.type === 'select') {
					$(this).val('').prop('selected', true);
				}
			});

			$('#ITP_FORM_VENDINFO01010_DETAIL_USER_ID').removeAttr('readonly');
			$('#ITP_FORM_VENDINFO01010_DETAIL_DUP').removeAttr('disabled');
			$('#ITP_FORM_VENDINFO01010_DETAIL_SEARCH_BRAND_ID option').remove();
			$('#ITP_FORM_VENDINFO01010_DETAIL_SEARCH_AFFL_SHOP').show();
			$('#ITP_FORM_VENDINFO01010_DETAIL_DELETE_AFFL_SHOP').show();
		} else if(mode === 'MODIFY') { // 수정
			$('#ITP_AJAX_VENDINFO01010_DETAIL_CONTAINER').show();
			fn_show_btn_auth_array(['#ITP_BTN_VENDINFO01010_CANCELLIST', '#ITP_BTN_VENDINFO01010_SAVE', '#ITP_BTN_VENDINFO01010_RESET_PW']);

			$('#ITP_FORM_VENDINFO01010_DETAIL_USER_ID').attr('readonly', true);
			$('#ITP_FORM_VENDINFO01010_DETAIL_DUP').attr('disabled', true);
			$('#ITP_FORM_VENDINFO01010_DETAIL_SEARCH_AFFL_SHOP_NM').attr('readonly', true);
			$('#ITP_FORM_VENDINFO01010_DETAIL_USER_NM').attr('readonly', true);
			$('#ITP_FORM_VENDINFO01010_DETAIL_SEARCH_AFFL_SHOP').hide();
			$('#ITP_FORM_VENDINFO01010_DETAIL_DELETE_AFFL_SHOP').hide();
			$('#ITP_BTN_VENDINFO01010_DETAIL_ADRES_SCH').show();
			$('#ITP_VENDINFO01010_DETAIL_ACCT_FILE_UPLOAD').show();
			$('#ITP_VENDINFO01010_DETAIL_ACCT_FILE_UPLOAD').show();
		} /*else if(mode === 'VIEW') { // 보기
			$('#ITP_AJAX_VENDINFO01010_VIEW_CONTAINER').show();
			fn_show_btn_auth_array(['#ITP_BTN_VENDINFO01010_MODIFY', '#ITP_BTN_VENDINFO01010_CANCELLIST']);
		}*/
	},
	grid: {
		init: function(mode, gridData) {
			this.mode = mode;
			this.gridId = (mode === 'VIEW') ? VENDINFO01010_VIEW_GRID_ID : VENDINFO01010_DETAIL_GRID_ID;
			this.gridList = (mode === 'VIEW') ? VENDINFO01010_VIEW_GRID_LIST : VENDINFO01010_DETAIL_GRID_LIST;
			this.gridEmpty = (mode === 'VIEW') ? VENDINFO01010_VIEW_GRID_EMPTY : VENDINFO01010_DETAIL_GRID_EMPTY;
			this.unload();
			this.load(mode, gridData);
		},
		mode: 'DETAIL',
		gridId: '',
		gridList: '',
		gridEmpty: '',
		load: function(mode, gridData) {
			//let string = 'brandId=' + LOGIN_USER_INFO.brandId + "&spplyId=" + LOGIN_USER_INFO.spplyId;
			var _this = this;
			var option = {
				gridId: _this.gridId,
				colModel: gridColModel.detail,
				data: gridData,
				multiselect: (this.mode !== 'VIEW'),
				loadComplete: function(data) {
					itp_fn_grid_load_complete(data, VENDINFO01010_DETAIL_GRID_ID, true, 'number', 'VENDINFO01010', modifyObj.itp_VENDINFO01010_search, modifyObj.empty, true, data.gridRecords, true);
					let gridList = VENDINFO01010_DETAIL_GRID_LIST;
					$(gridList).find('.ui-jqgrid .ui-jqgrid-bdiv').css('overflow-x', 'hidden');
					(Array.isArray(data.rows) && data.rows.length === 0) ? $(_this.gridEmpty).show() : $(_this.gridEmpty).hide();
					var ids = $(VENDINFO01010_DETAIL_GRID_ID).getDataIDs();
					$.each(ids, function(idx, rowId) {
						$(VENDINFO01010_DETAIL_GRID_ID).jqGrid('setCell', rowId, 'contSttDt', '', ITP_GRID_COL_STYLE.link);
					});
					modifyObj.rows = data.gridRows;
				},
				onCellSelect: function(rowId, cellIdx, cellValue) {
					VENDINFO01010_GRID_LAST_ROW_ID = itp_fn_set_data_editable(rowId, cellIdx, VENDINFO01010_GRID_LAST_ROW_ID, VENDINFO01010_DETAIL_GRID_ID, ['actionId']);
					itp_fn_form_event.onKeyup(VENDINFO01010_DETAIL_GRID_ID);
				},
			};
			itp_fn_grid_make_local(option);
		},
		unload : function() {
			$.jgrid.gridUnload(this.gridId);
		}
	}
}

/*수정화면 Object*/
let modifyObj = {
	init: function () {
		let param = 'brandId=' + LOGIN_USER_INFO.brandId + "&spplyId=" + LOGIN_USER_INFO.spplyId;
		this.load(param);
	},
	itp_VENDINFO01010_search: false,
	button: {
		address: function() {
			kakaoMap.simpleAddress('ITP_FORM_VENDINFO01010_DETAIL');
		},
		addRow: function() {
			itp_fn_grid_add_row(VENDINFO01010_DETAIL_GRID_ID, undefined, ['spplyId'], 'VENDINFO01010_DETAIL');
			itp_fn_form_event.onKeyup(VENDINFO01010_DETAIL_GRID_ID);
		},
		delRow: function() {
			itp_fn_grid_del_row(VENDINFO01010_DETAIL_GRID_ID);
		},
		save: function() {
			const formId = '#ITP_FORM_VENDINFO01010_DETAIL';
			itp_fn_form_clear_validate(null, formId);	
			
			if(modifyObj.isValid(formId)){
				var modalFn = {
					callBack: (args) => {
						itp_fn_grid_save_rows(VENDINFO01010_DETAIL_GRID_ID);		// rowData 보조
						let gridInsertData = [];
						let gridUpdateData = [];
						let gridDeleteData = [];
						for(var i=0; i<$(VENDINFO01010_DETAIL_GRID_ID).getGridParam('reccount'); i++) {
							$(VENDINFO01010_DETAIL_GRID_ID).jqGrid('saveCell', i+1, 2)
						}
						const rowData = $(VENDINFO01010_DETAIL_GRID_ID).getRowData();
						const keyValue = $(formId + '_BRAND_ID').val();
						$.each(rowData, function(key, value) {
							if (value.viewCd != 'R') {
									value.userId = keyValue;
								if (value.viewCd == 'C') {
									gridInsertData.push(value);
								} else if (value.viewCd == 'U') {
									gridUpdateData.push(value);
								} else if (value.viewCd == 'D') {
									gridDeleteData.push(value);
								}
							}
						});
						let param = $(formId).serializeObject();
						
						param.gridInsertData = gridInsertData;
						param.gridUpdateData = gridUpdateData;
						param.gridDeleteData = gridDeleteData;
						param.brandId = LOGIN_USER_INFO.brandId;
						var searhFn = function() {
							ITP_FORM_VENDINFO01010_DETAIL_IS_WRITING = false;
							modifyObj.init();
						};
						fn_ajax_call(API_SPPLY_SAVE_SPPLY, JSON.stringify(param), searhFn, 'POST');
					}	
				};
				itp_fn_modal_confirm('저장 하시겠습니까?', modalFn);
			}
		}
	},
	empty: {
		init: function() {
			var _this = this;
			this.push();
			$(VENDINFO01010_DETAIL_GRID_EMPTY).on('click', function() {
				_this.back();
				_this.itp_VENDINFO01010_param.gridSize = $.jgrid.defaults.rowNum;
				$(VENDINFO01010_DETAIL_GRID_ID).setGridParam({'postData': JSON.stringify(_this.itp_VENDINFO01010_param)}).trigger('reloadGrid');
			});
		},
		itp_VENDINFO01010_param: {},
		push: function() {
			let param = $('#ITP_FORM_VENDINFO01010_DETAIL').serializeObject();
			modifyObj.itp_VENDINFO01010_param = param;
		}/*,
		back: function() {
			$('#ITP_FORM_VENDINFO01010_DEVI_TP_CD').val(this.itp_VENDINFO01010_param.deviTpCd);
			$('#ITP_FORM_VENDINFO01010_ORDER_YN').val(this.itp_VENDINFO01010_param.orderYn);
			$('#ITP_FORM_VENDINFO01010_ADT_AUTH_CD').val(this.itp_VENDINFO01010_param.adtAuthCd);
			$('#ITP_FORM_VENDINFO01010_EMAIL_RCV_YN').val(this.itp_VENDINFO01010_param.emailRcvYn);
			$('#ITP_FORM_VENDINFO01010_MEMB_EXIT_DT').val(this.itp_VENDINFO01010_param.membExitDt);
			$('#ITP_FORM_VENDINFO01010_FROM_DT').val(this.itp_VENDINFO01010_param.fromDt);
			$('#ITP_FORM_VENDINFO01010_TO_DT').val(this.itp_VENDINFO01010_param.toDt);
			$('#ITP_FORM_VENDINFO01010_KEYWORD').val(this.itp_VENDINFO01010_param.keyword);
		}*/
	},
	load: function(param) {
		fn_ajax_call(API_SPPLY_INFO_SPPLY, param, this.callback, 'GET');
	},
	callback: function (result) {
		pageObj.switchScreen('MODIFY');
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_VIEW_CD').val('U');
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_POP_NO').val(result.popNo);
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_MENU_NO').val(result.menuNo);
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_FILE_NO').val(result.popFileNo);
		/*var brandId = result.brandId;
		var brandNm = result.brandNm;
		if(brandId !== '' && brandNm !== '') {
			var brandList = [{'brandId':brandId, 'brandNm':brandNm}];
			fn_make_select_brand(brandList, 'ITP_FORM_VENDINFO01010_DETAIL_SEARCH_BRAND_ID');
		}*/
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_CORP_TYPE').val(result.corpType);		// 기업형태
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_SPPLY_NM').val(result.spplyNm);		// 공급업체명
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_BSNS_CNDT').val(result.bsnsCndt);		// 업태
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_CTGR_BSNS').val(result.ctgrBsns);		// 업종
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_TEL_NO').val(result.mgrTelNo);			// 전화번호
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_OWNER_NM').val(result.ownerNm);		// 대표자명
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_FAX_NO').val(result.faxNo);			// FAX
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_EMAL_ADDR').val(result.mgrEmal);		// 이메일
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_MBL_NO').val(result.mgrMblNo);			// 핸드폰
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_AREA_CD').val(result.areaCd);			// 지역
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_BNK_CD').val(result.bnkCd);			// 은행
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_ACCT_NO').val(result.acctNo);			// 계좌번호
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_OWAC_NM').val(result.owacNm);			// 예금주
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_ZIPNO').val(result.zipNo);				// 우편번호
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_ADRES').val(result.addr1);				// 기본주소
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_ADRES_DTL').val(result.addr2);			// 상세주소
		
		$('#ITP_FORM_VENDINFO01010_DETAIL .fnBrandNm').text(result.brandNm);									// 브랜드
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_ST_CD').val(result.stCd);				// 상태
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_SPPLY_ID').val(result.spplyId);		// 공급업체번호
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_BSNS_REG_NO').val(result.bsnsRegNo);	// 사업자번호
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_CORP_REG_NO').val(result.corpRegNo);	// 법인번호
		$('#ITP_FORM_VENDINFO01010_DETAIL .fnRegId').text(result.sysRegId);										// 등록자
		$('#ITP_FORM_VENDINFO01010_DETAIL .fnRegDt').text(result.sysRegDttm);									// 등록일
		$('#ITP_FORM_VENDINFO01010_DETAIL .fnChgId').text(result.sysChgId);										// 수정자
		$('#ITP_FORM_VENDINFO01010_DETAIL .fnChgDt').text(result.sysChgDttm);									// 수정일

		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_ACCT_FILE_NO').val(result.bbookCopyFileNo);	// 통장사본
		$('#ITP_FORM_VENDINFO01010_DETAIL #ITP_FORM_VENDINFO01010_DETAIL_CORP_FILE_NO').val(result.bsnsRegFileNo);		// 사업자등록파일

		pageObj.fileUpload();

		
		// 권한정보 리스트 조회
		pageObj.grid.init('DETAIL', result.spplyMgrList);
	},
	isValid: function(formId) {
		var isValid = false;
		$(formId).find('input, select, checkbox, textarea').each(function(k) {
			if($(this).data('check-required')) {
				var arry = $(this).data('check-required').split(',');
				isValid = itp_fn_form_validate(formId, '#' + $(this).attr('id'), arry, undefined);
				if(!isValid) return false;
			}
		});
		return isValid;
	},
	rows: [],
	changeRows: function(gridRows) {
		var modifyRows = [];
		var chkColumns = ['spplyMgrNm', 'position', 'rprstEmal', 'rprstTelNo', 'assgnTask'];
		$.each(this.rows, function(index, item) {
			var row = gridRows[index];
			if(row.viewCd === 'C') {
				modifyRows.push(item);
			} else {
				if(row.itemId === item.itemId) {
					$.each(chkColumns, function(index, column) {
						if(row[column].toString() !== item[column].toString()) {
							row.viewCd = 'U';
							modifyRows.push(row);
							return false;
						}
					});
				}
			}
		});
		return modifyRows;
	}
};
