123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- /**
- * admin/pushForm
- */
- var mcare_admin_pushForm = function(){
- //상속
- mcare_admin.call(this);
-
- var self = this;
- //변수
- var $grid = $("#grid"),
- $crudServiceBaseUrl = contextPath + "/admin/pushform";
- /**
- * 초기화
- */
- this.init = function(){
- initGrid();
- addEvent();
- };
- /**
- * 이벤트 등록
- */
- var addEvent = function(){
-
- };
- // 데이터소스
- var dataSource = new kendo.data.DataSource({
- transport: {
- read: {
- url: $crudServiceBaseUrl + "/getList.json",
- method: "post",
- dataType: "json",
- contentType: "application/json",
- complete: gridReadComplete
- },
- create: {
- url: $crudServiceBaseUrl + "/save.json",
- method: "post",
- dataType: "json",
- contentType: "application/json",
- complete: gridActionComplete
- },
- update: {
- url: $crudServiceBaseUrl + "/update.json",
- method: "post",
- dataType: "json",
- contentType: "application/json",
- complete: gridActionComplete
- },
- parameterMap: function( options, operation ) {
- if( operation !== "read" && options.models ) {
- options.models[0].formType = $("select[data-id=formTypeEditor]").val();
-
- if( options.models[0].formType === "PAGE" ){
- options.models[0].menuId = $("select[data-id=menuIdEditor]").val();
- options.models[0].menuName = $("select[data-id=menuIdEditor] option:selected").text();
- } else {
- options.models[0].menuId = "";
- options.models[0].menuName = "";
- }
- var id = options.models[0].formId,
- rex1 = /[~!@\#$%<>^&*\()\-=+\’]/gi,
- rex2 = /\s/gi;
- if( rex1.test(id) ){
- alert("특수문자는 사용할 수 없습니다.");
- return false;
- } else if( rex2.test(id) ){
- alert("공백은 포함할 수 없습니다." );
- return false;
- }
-
- return self.util.stringifyJson( options.models[0] );
- } else if( operation === "read" ){
- return self.util.stringifyJson( options );
- }
- }
- },
- batch: true,
- pageSize: 13,
- serverPaging: true,
- serverSorting: true,
- schema: {
- data: "data",
- total: "totalCount",
- model: {
- id: "formId",
- fields: {
- formId: {type:"string"},
- formType: { type: "string"},
- useYn : {type:"string",defaultValue:"N"},
- menuId: { type: "string"},
- menuName: { type: "string"},
- includeNameYn: { type: "string", defaultValue:"N"},
- formDesc : { type:"string" }
- }
- }
- }
- });
- /**
- * 그리드 이벤트 동작 complate
- * @private
- */
- function gridActionComplete( e ){
- if( e.responseText !== "" ){
- var result = self.util.parseJson( e.responseText );
- if( result.msg !== undefined && result.msg !== "" ){
- alert( result.msg );
- }
- }
- $grid.data("kendoGrid").dataSource.read();
- };
- /**
- * 그리드 이벤트 동작 complate
- * @private
- */
- function gridReadComplete( e ){
- var result = self.util.parseJson( e.responseText );
- if( result.msg ){
- alert( result.msg );
- if( result.type == "AuthException" ){
- window.location.href = contextPath + "/admin/logout.page";
- return;
- }
- }
- };
- /**
- * 그리드 초기화
- */
- var initGrid = function(){
- // 그리드 옵션
- var option = {
- dataSource: dataSource,
- pageable: true,
- sortable: true,
- resizable: true,
- height: 580,
- toolbar: [{ name : "create", text: "추가", complete: function(e) {
- $grid.data("kendoGrid").dataSource.read();
- } }],
- columns: [
- { field: "formId", title: "이름",filterable:false, width: 120, attributes: {style: "text-align: center;"}}
- ,{ field: "formType", title: "타입",filterable:false, width: 50,editor:formTypeEditor, attributes: {style: "text-align: center;"}}
- ,{ field: "useYn", title: "사용여부",filterable:false, width: 50,editor:useYnEditor, attributes: {style: "text-align: center;"}}
- ,{ field: "menuId", title: "메뉴명",filterable:false,hidden:true,editor:menuIdEditor, width: 80, attributes: {style: "text-align: center;"}}
- ,{ field: "menuName", title: "메뉴명", width: 80, attributes: {style: "text-align: center;"}}
- ,{ field: "includeNameYn", title: "이름포함여부",filterable:false, width:50, editor:includeNameYnEditor,attributes: {style: "text-align: center;"}}
- ,{ field: "formDesc", title: "설명", width: 120,filterable:false, attributes: {style: "text-align: center;"}}
- ,{ command: [{name:"edit",text:"수정"}], title: " ", width: 80, attributes: {style: "text-align: center;"}}
- ],
- editable: "popup",
- edit: function(e) {
- $("label[for=menuName]").parent().hide();
- $("div[data-container-for=menuName]").hide();
- if (!e.model.isNew()) {
- $("input[name=formId]").prop("readonly",true);
- $("label[for=formType]").parent().hide();
- $("div[data-container-for=formType]").hide();
- $("label[for=menuId]").parent().hide();
- $("div[data-container-for=menuId]").hide();
- }
- },
- filterable: {
- extra : false,
- operators : {
- string : {
- contains : " 포함 "
- }
- }
- },
- dataBound: function () {
- var rowCount = $grid.find( ".k-grid-content tbody tr" ).length;
- if( rowCount < dataSource._take ) {
- var addRows = dataSource._take - rowCount;
- for( var i = 0; i < addRows; i++ ) {
- $grid.find( ".k-grid-content tbody" )
- .append( "<tr class='kendo-data-row'><td> </td></tr>" );
- }
- }
- }
- };
- function formTypeEditor(container,options){
- var select = $("<select></select>").attr({"data-id":"formTypeEditor","data-bind":"value:"+options.field});
- select.html("<option value='PAGE'>PAGE</option>");
- select.append("<option value='MAP'>MAP</option>");
- select.append("<option value='GUIDE'>GUIDE</option>");
- select.val(options.model.formType).appendTo(container).kendoDropDownList({autoBind: true,
- change : function(e){
- if( this.value() !== "PAGE" ){
- $("label[for=menuId]").parent().hide();
- $("div[data-container-for=menuId]").hide();
- } else {
- $("label[for=menuId]").parent().show();
- $("div[data-container-for=menuId]").show();
- }
- }});
- }
- function useYnEditor(container,options){
- var select = $("<select></select>").attr({"data-id":"useYnEditor","data-bind":"value:"+options.field});
- select.html("<option value='Y'>Y</option>");
- select.append("<option value='N'>N</option>");
- select.val(options.model.useYn).appendTo(container).kendoDropDownList({autoBind: true});
- }
- function menuIdEditor(container,options){
- // $.ajax({
- // url: contextPath + "/admin/menu/getList.json",
- // method : "POST",
- // dataType : "json",
- // success: function(data){
- // var select = $("<select></select>").attr({"data-id":"menuIdEditor","data-bind":"value:"+options.field});
- // for( var i = 0; i < data.length; i++ ){
- // var item = data[i];
- //
- // if( (item.accessUriAddr).indexOf(".page") > 0 ){
- //
- // select.append("<option value='"+ item.menuId+"'>"+item.menuName+"</option>");
- // }
- // }
- // select.val(options.model.menuId).appendTo(container).kendoDropDownList({autoBind: true});
- // },
- // error: function(xhr){
- //
- // },
- // complete: function(){
- //
- // }
- // });
- var opt = {
- url: contextPath + "/admin/menu/getList.json",
- method : "POST",
- dataType : "json",
- complete : function(){
-
- }
- };
- var success = function(data){
- var select = $("<select></select>").attr({"data-id":"menuIdEditor","data-bind":"value:"+options.field});
- for( var i = 0; i < data.length; i++ ){
- var item = data[i];
-
- if( (item.accessUriAddr).indexOf(".page") > 0 ){
-
- select.append("<option value='"+ item.menuId+"'>"+item.menuName+"</option>");
- }
- }
- select.val(options.model.menuId).appendTo(container).kendoDropDownList({autoBind: true});
- };
- var error = function(xhr,d,t){
-
- };
- self.ajaxAdmin( opt, success, error );
- }
- function includeNameYnEditor(container,options){
- var select = $("<select></select>").attr({"data-id":"includeNameYnEditor","data-bind":"value:"+options.field});
- select.html("<option value='Y'>Y</option>");
- select.append("<option value='N'>N</option>");
- select.val(options.model.includeNameYn).appendTo(container).kendoDropDownList({autoBind: true});
- }
- //그리드 초기화
- self.grid( $grid, option );
- };
- };
|