mirror of https://gitee.com/zorlan/skycaiji
16 lines
4.2 KiB
JavaScript
16 lines
4.2 KiB
JavaScript
|
/*
|
||
|
|--------------------------------------------------------------------------
|
||
|
| SkyCaiji (蓝天采集器)
|
||
|
|--------------------------------------------------------------------------
|
||
|
| Copyright (c) 2018 http://www.skycaiji.com All rights reserved.
|
||
|
|--------------------------------------------------------------------------
|
||
|
| 使用协议 http://www.skycaiji.com/licenses
|
||
|
|--------------------------------------------------------------------------
|
||
|
*/
|
||
|
'use strict';function DevelopClass(){}
|
||
|
DevelopClass.prototype={constructor:DevelopClass,release_cms:function(config){var $_o=this;$('#form_cms select[name="cms_name"]').bind('change',function(){if($(this).val()=='custom'){$('#cms_name_custom').show()}else{$('#cms_name_custom').hide()}});$('#add_param').bind('click',function(){windowModal('参数',ulink('Develop/cmsAddParam'))});$('#param_list').on('click','.param-key',function(){var parentObj=$(this).parents('tr[id^="param_"]').eq(0);var paramval=parentObj.find('input[name="params[]"]').val();var objid=parentObj.attr('id');windowModal('参数',ulink('Develop/cmsAddParam?objid=_objid_¶m=_param_',{'_objid_':objid,'_param_':paramval}))});$('#param_list').on('click','.delete-param',function(){$(this).parents('tr').eq(0).remove()});if(config&&!$.isEmptyObject(config)){$('#form_cms [name="name"]').val(config.name);var cmsnameOpt=$('#form_cms [name="cms_name"] option[value="'+config.cms_name+'"]');if(cmsnameOpt.length>0){$('#form_cms [name="cms_name"]').val(config.cms_name)}else{$('#form_cms [name="cms_name"]').val('custom').trigger('change');$('#form_cms [name="cms_name_custom"]').val(config.cms_name)}
|
||
|
$('#form_cms [name="identifier"]').val(config.identifier);$('#form_cms [name="copyright"]').val(config.copyright);if(config.is_edit){$('#form_cms [name="cms_name"]').attr("disabled","disabled");$('#form_cms [name="cms_name_custom"]').attr("disabled","disabled");$('#form_cms [name="identifier"]').attr("disabled","disabled");$('#form_cms [name="copyright"]').attr("disabled","disabled")}
|
||
|
if(config.params){for(var i in config.params){$_o.add_cms_param(config.params[i])}}}},init_cms_param:function(){var $_o=this;$('#win_form_param select[name="param[type]"]').bind('change',function(){$('#win_form_param .param-type-select').hide();var curType=$(this).val();if(curType=='select_val'||curType=='select_func'){$('#win_form_param .param-type-select[data-select="'+curType+'"]').show()}});$('#win_form_param').submit(function(){var checkKey=!0;var curKey=$('#win_form_param [name="param[key]"]').val();var objid=$('#win_form_param input[name="objid"]').val();if(objid){if(curKey==$('#'+objid).find('.param-key').text()){checkKey=!1}}
|
||
|
if(checkKey){var hasKey=!1;$('#param_list .param-key').each(function(){if(curKey==$(this).text()){hasKey=!0;return!1}});if(hasKey){toastr.error('变量名已存在!');return!1}}
|
||
|
$.ajax({type:'POST',dataType:'json',url:$(this).attr('action'),data:$(this).serialize(),success:function(data){if(data.code==1){$_o.add_cms_param(data.data,objid);$('#myModal').modal('hide')}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1})},load_cms_param:function(param){if(param){$('#win_form_param [name="param[key]"]').val(param.key);$('#win_form_param [name="param[require]"][value="'+param.require+'"]').prop('checked',!0);$('#win_form_param [name="param[name]"]').val(param.name);$('#win_form_param [name="param[type]"]').val(param.type).trigger('change');$('#win_form_param [name="param[select_val]"]').val(param.select_val);$('#win_form_param [name="param[select_func]"]').val(param.select_func)}},add_cms_param:function(param,objid){var paramHtml='<td><a href="javascript:;" class="param-key">_key_</a></td><td>_require_</td><td>_name_</td><td>_type_</td>'+'<td><a href="javascript:;" class="glyphicon glyphicon-remove delete-param"></a><input type="hidden" name="params[]" value="_param_"/></td>';paramHtml=paramHtml.replace('_key_',param.key).replace('_require_',(param.require>0?'是':'否')).replace('_name_',param.name).replace('_type_',param.type_name).replace('_param_',url_base64encode(JSON.stringify(param)));if(objid){$('#'+objid).html(paramHtml)}else{$('#param_list tbody').append('<tr id="param_'+generateUUID()+'">'+paramHtml+'</tr>')}}}
|
||
|
var developClass=new DevelopClass()
|