123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- function businessGenPage() {
- var page = '<div id="business_page" style="display: block;">\
- <div class="maintitle">\
- <div>业务中台切换</div>\
- <div class="page_description_text">用于开发测试环境<strong>灵活</strong>切换业务中台链接。将替代集中配置中的业务链接,设置永久有效<br/>\
- 信息有变更时需重启Chromium实体或者重启应用方能生效。\
- </div>\
- </div>\
- <div id="businessContent">\
- <div class="clearboth" id="apn_list" style="padding-top:70px;">\
- <div class="table_top">\
- <div class="table_list_title">自定义业务链接\
- </div>\
- <div class="pull-right">\
- <div id="web_new" class="btn_new pull-left" >\
- \
- </div>\
- </div>\
- </div>\
- <div class="border_left border_right color_Darkgray" style="width:678px;padding-top:-1px;">\
- <div id="web_lists" class="clearboth" style="width:100%;overflow:hidden;">\
- </div>\
- </div>\
- <div class="table_bottom">\
- </div>\
- </div>\
- <div id="add_web_item_win" class="out_win_content submit_background hide">\
- <div class="table_top">\
- <div style="border-bottom: #E9E9E9 solid 1px;font-size: 16px;text-align:center;line-height: 65px;">\
- 业务链接设置</div>\
- </div>\
- <div class="border_left border_right margin_bottom_box2 color_background_white"\
- style="padding-top: 40px;">\
- <div id="add_web_item_win_scroll" style="max-height:300px;">\
- <div id="web_env_type_div" class="clearboth">\
- <div class="control-label-win"><span>环境</span></div>\
- <div class="controls-win">\
- <div id="web_env" class="select_on_normal"\
- onclick="SelectItem(this)"></div>\
- <div id="web_env_list" class="select_list hide"\
- style="display: none;">\
- <div id="web_env_list_item_dev" option="1"\
- class="select_medium"">DEV</div>\
- <div id="web_env_list_item_st" option="2"\
- class="select_medium">ST</div>\
- <div id="web_env_list_item_uat" option="3"\
- class="select_medium">UAT</div>\
- <div id="web_env_list_item_all" option="0"\
- class="select_medium">Unclassfied</div>\
- </div>\
- </div>\
- </div>\
- <input style="display:none;" id="web_url_profile_index" type="text">\
- <div id="web_main_url" class="clearboth" style="padding-top:29px;">\
- <div class="control-label-win"><span>业务URL(主屏)</span></div>\
- <div class="controls-win input_normal"><input id="web_main_url_text"\
- onfocus="showInputBorder(this)" onblur="hideInputBorder(this)"\
- type="text" maxlength="128"></div> \
- </div>\
- <div id="web_ad_url" class="clearboth" style="padding-top:29px;">\
- <div class="control-label-win"><span>广告URL(上屏)</span></div>\
- <div class="controls-win input_normal"><input id="web_ad_url_text" placeholder="(目前该值没应用,将使用默认的)"\
- onfocus="showInputBorder(this)" onblur="hideInputBorder(this)"\
- type="text" maxlength="128" disabled></div>\
- </div>\
- <div id="remark" class="clearboth" style="padding-top:29px;">\
- <div class="control-label-win"><span">备注</span></div>\
- <div class="controls-win input_normal"><input id="input_remark" placeholder="(可不填)"\
- onfocus="showInputBorder(this)" onblur="hideInputBorder(this)"\
- type="text" maxlength="63"></div>\
- </div>\
- <div id="web_list_input_set_default_div" class="clearboth" style="padding-top: 27px;">\
- <div class="control-label-win pull-left">\
- <span>设置为当前使用链接</span>\
- </div>\
- <div id="web_list_input_set_default" class="check_off controls-win pull-right" style="margin-top:8px;">\
- </div>\
- </div>\
- <div id="web_select_blank" style="height: 145px; display: none;" class="hide"></div>\
- <div class="clearboth"></div>\
- </div>\
- <div style="padding-top:50px;padding-bottom:8px;" align="center">\
- <button id="web_item_cancel" class="btn_normal_short" >取消</button>\
- <button id="web_item_save" class="btn_normal_short btn_disabled margin-left-20">保存</button>\
- </div>\
- </div>\
- <div class="table_bottom"></div>\
- </div>\
- </div>\
- </div>';
- $("#rightpagearea").prepend(page);
- if (typeof businessRenderPage == "function") {
- beforeRenderPage("business");
- businessRenderPage();
- afterRenderPage("business");
- }
- }
- var businessController = (function() {
- var CONST = {
- SWITCH_ON: '1',
- PROFILE_MAX_NUM: 100
- };
-
- var weblistCount = 0;
- var isNewWebConfig = true;
- var modifyIndex = -1;
- var profilesArray = [];
- var modifyProfile = {};
- function loadData(flag) {
- let req = new Request();
- req.filter1 = 0;
- req.filter2 = 0;
- req.filter3 = 0;
- req.filter4 = '';
- profilesArray = [];
- weblistCount = 0;
- if(typeof flag === 'undefined') {
- utilStartSubmitDialog();
- }
- RVC.CenterSettingEntity.GetWebUrlList(req, function(ret) {
- if(typeof flag === 'undefined'){
- utilStopSubmitDialog();
- }
- console.log('result: ' + ret.errorCode);
- if (ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.CenterSettingEntity.sigResponseUUID])
- console.log('count: ' + result.index.length + ' ' + result);
- if (result.index.length === 0) {
- $('#web_lists').css('height', 0);
- $('#web_lists').hide();
- return;
- } else if (result.index.length <= 8) {
- $('#web_lists').css('height', (result.index.length * 70 - 12) + result.index.length + 'px');
- } else {
- $('#web_lists').css('height', '561px');
- }
- $('#web_lists').show();
- $('#web_lists').empty();
- RVC.Scroll.initScroll('#web_lists');
- for (var n = 0; n < result.index.length; n++)
- {
- var templateData = {
- profileItemIndex: result.index[n],
- profileItemName: result.remark[n],
- profileItemMainUrl: result.futureUrl[n],
- profileItemAdUrl: result.adUrl[n],
- profileItemEnvType: result.env[n],
- profileItemFromType: result.type[n],
- profileItemStatus: result.status[n]
- };
- profilesArray.push(templateData);
- var profileHtml;
- if (n === result.index.length - 1) {
- profileHtml = '<div id="web_list_{{profileItemIndex}}" style="height:59px;cursor:pointer;" class="list_item_hover">';
- profileHtml += '<div id="web_list_name_{{profileItemIndex}}" class="pull-left padding-left-20" style="height:45px;padding-top:14px;width:600px;" onclick="RVC.WebUrlController.ShowWebUrlInfo({{profileItemIndex}})">';
- } else {
- profileHtml = '<div id="web_list_{{profileItemIndex}}" class="border_bottom list_item_hover" style="height:70px;cursor:pointer;">';
- profileHtml += '<div id="web_list_name_{{profileItemIndex}}" class="pull-left padding-left-20" style="height:56px;padding-top:14px;width:600px;" onclick="RVC.WebUrlController.ShowWebUrlInfo({{profileItemIndex}})">';
- }
- if (templateData.profileItemStatus === 1) {
- profileHtml += '<pre class="web_profile_name_{{profileItemIndex}}" style="font-size:16px;margin-top:0px;"><span class="web_profile_itemname pull-left" style="line-height:21px;" title="{{profileItemName}}">{{profileItemName}}</span><span class="pull-left" style="line-height:21px;">(当前采用)</span><div class="clearboth"></div></pre>';
- } else {
- profileHtml += '<pre class="web_profile_name_{{profileItemIndex}}" style="font-size:16px;margin-top:0px;"><span class="web_profile_itemname" title="{{profileItemName}}">{{profileItemName}}</span></pre>';
- }
- profileHtml += '<div class="web_web_name_{{profileItemIndex}} color_descroption_gray web_profile_itemapnname" style="margin-top:-10px;font-size:14px;" title="{{profileItemMainUrl}}">{{profileItemMainUrl}}</div></div>';
- if (templateData.profileItemFromType === 0 || templateData.profileItemStatus === 1 || templateData.profileItemStatus === 2) {
- profileHtml += '<div class="pull-right"></div></div>';
- } else {
- if (n === 0) {
- profileHtml += '<div class="pull-right"><div class="btn_delete mobileconnet_btn_delete" onclick="RVC.WebUrlController.RemoveWebUrlProfile({{profileItemIndex}})" > </div></div></div>';
- } else {
- profileHtml += '<div class="pull-right"><div class="btn_delete mobileconnet_btn_delete" onclick="RVC.WebUrlController.RemoveWebUrlProfile({{profileItemIndex}})" > </div></div></div>';
- }
- }
- $('#web_lists .scroll_text').secureAppend(profileHtml, templateData);
- }
- weblistCount = result.index.length;
- } else if(typeof flag === 'undefined') {
- RVC.CenterSettingEntity.commErrorCallback(ret);
- }
- });
- }
-
- function preShowWebList()
- {
- $('#web_lists').show();
- $('#web_lists').empty();
- RVC.Scroll.initScroll('#web_lists');
- }
- function webProfileCancel() {
- $('#add_web_item_win').hide();
- $('#submit_fade').hide();
- }
- function saveProfileData(newConfig)
- {
- if (!isButtonEnable('web_item_save')) {
- return;
- }
- var mainUrl = $('#web_main_url_text').val();
- var adUrl = $('#web_ad_url_text').val();
- var remark = $('#input_remark').val();
- var isSetDefault = $('#web_list_input_set_default').hasClass('check_on') ? true : false;
- var envType = parseInt($('#web_env').val());
- var index = parseInt($('#web_url_profile_index').val());
- if(mainUrl === '') {
- utilStartAlertDialog('请输入业务链接地址!');
- return;
- }
- let req = new Request();
- if(newConfig) {
- req.operation = 1;
- req.index = 0;
- } else {
- req.operation = 3;
- req.index = index;
- }
- req.futureUrl = mainUrl;
- req.adUrl = adUrl;
- req.remark = remark;
- req.env = envType;
- req.setDefault = isSetDefault;
- utilStartSubmitDialog();
- RVC.CenterSettingEntity.EditWebUrl(req, function(ret) {
- utilStopSubmitDialog();
- if (ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.CenterSettingEntity.sigResponseUUID])
- webProfileCancel();
- utilStartAlertDialog('操作成功!点击确认将重启Chromium实体以让设置生效(该页面由Chromium实体控制,如果出现突然消失属正常现象)', function(){
- RVC.HealthmanagerEntityCtrl.StartEntity('Chromium', function() {
- utilShowToast('Chromium实体重启时会断开与此页面的通讯连接,如果长时间此提示或当前页面未消失,请转到后台管理窗口查看告警或自行重启!', 30000);
- });
- });
- } else {
- RVC.CenterSettingEntity.commErrorCallback(ret);
- }
- });
- }
- function checkboxDisabled(id) {
- var checkElement = $('#' + id);
- if (checkElement.hasClass('check_on') && checkElement.hasClass('disabled')) {
- checkElement.removeClass('check_on').addClass('check_on_disable').addClass('check_on');
- } else {
- checkElement.removeClass('check_on_disable');
- }
- if (checkElement.hasClass('check_off') && checkElement.hasClass('disabled')) {
- checkElement.removeClass('check_off').addClass('check_off_disable').addClass('check_off');
- } else {
- checkElement.removeClass('check_off_disable');
- }
- }
- function showWebBox() {
- clearAllErrorMsg();
- $('#web_item_save').addClass('btn_disabled');
- var outwin = $('#add_web_item_win');
- checkboxDisabled('web_list_input_set_default');
- var heightest = $(document).height();
- $('#submit_fade').css('height', heightest + 'px');
- $('#submit_fade').show();
- outwin.show();
- }
- function setDefaultWebUrlSwitch() {
- if ($('#web_list_input_set_default').hasClass('disabled')) {
- return;
- }
- $('#web_item_save').removeClass('btn_disabled');
- if ($('#web_list_input_set_default').hasClass('check_on')) {
- $('#web_list_input_set_default').removeClass('check_on').addClass('check_off');
- } else {
- $('#web_list_input_set_default').removeClass('check_off').addClass('check_on');
- }
- if ($('#web_list_input_set_default').hasClass('check_off')) {
- $('#web_item_save').addClass('btn_disabled');
- }
- }
- function ResetWebUrlInfoShowDialog()
- {
- $('#web_url_profile_index').val('');
- $('#add_web_item_win input').val('');
- $('#add_web_item_win input').removeAttr('disabled');
- $('#add_web_item_win .select_on_normal').removeClass('disabled');
- }
- RVC.WebUrlController = RVC.ObjController.extend({
- ShowWebUrlInfo: function(index) {
- modifyIndex = index;
- var webUrlShowItem = {};
- for (var i = 0; i < profilesArray.length; i++) {
- if (profilesArray[i].profileItemIndex === index) {
- webUrlShowItem = profilesArray[i];
- break;
- }
- }
- /**
- * profileItemIndex: result.index[n],
- profileItemName: result.remark[n],
- profileItemMainUrl: result.futureUrl[n],
- profileItemAdUrl: result.adUrl[n],
- profileItemEnvType: result.env[n],
- profileItemFromType: result.type[n],
- profileItemStatus: result.status[n]
- */
- ResetWebUrlInfoShowDialog();
- modifyProfile = webUrlShowItem;
- $('#web_url_profile_index').val(webUrlShowItem.profileItemIndex.toString());
- $('#web_main_url_text').val(webUrlShowItem.profileItemMainUrl);
- $('#web_ad_url_text').val(webUrlShowItem.profileItemAdUrl);
- $('#input_remark').val(webUrlShowItem.profileItemName);
- if (webUrlShowItem.profileItemStatus === 1) { //默认配置
- $('#web_list_input_set_default').removeClass('check_off').addClass('check_on');
- $('#web_list_input_set_default').addClass('disabled');
- } else {
- $('#web_list_input_set_default').removeClass('check_on').addClass('check_off');
- $('#web_list_input_set_default').removeClass('disabled');
- }
- showSelectedValue('web_env', webUrlShowItem.profileItemEnvType.toString());
- $(document).off('click', '#web_item_save');
- $(document).on('click', '#web_item_save', function () {
- saveProfileData(false);
- });
- if(webUrlShowItem.profileItemFromType === 0) { //集中配置文件不让修改
- $('#add_web_item_win input').attr('disabled', true);
- $('#add_web_item_win .select_on_normal').addClass('disabled');
- console.log(webUrlShowItem.profileItemName);
- }
- showWebBox();
- },
- RemoveWebUrlProfile: function(index)
- {
- utilStartConfirmDialog("确定要移除该配置吗?", function() {
- let req = new Request();
- req.operation = 2; //删除
- req.index = parseInt(index);
- req.futureUrl = '';
- req.adUrl = '';
- req.remark = '';
- req.env = 0;
- req.setDefault = false;
- utilStartSubmitDialog();
- RVC.CenterSettingEntity.EditWebUrl(req, function(ret) {
- utilStopSubmitDialog();
- if (ret.errorCode === 0) {
- let result = JSON.parse(ret[RVC.CenterSettingEntity.sigResponseUUID])
-
- preShowWebList();
- loadData();
- } else {
- RVC.CenterSettingEntity.commErrorCallback(ret);
- }
- });
- });
- }
- });
- function bindEvents() {
- $('#web_new').click(function () {
- $('#web_select_blank').hide();
- if (weblistCount === CONST.PROFILE_MAX_NUM) {
- utilStartCommonDialog('配置数量超过上限(' + CONST.PROFILE_MAX_NUM + '),请删除再新建!');
- setTimeout(function () {
- utilStopCommonDialog();
- }, 3000);
- return;
- }
- modifyIndex = -1;
- ResetWebUrlInfoShowDialog();
- $('#web_list_input_set_default').removeClass('check_off').addClass('check_on');
- $('#web_list_input_set_default').addClass('disabled');
- showSelectedValue('web_env', '1');
- isNewWebConfig = true;
- showWebBox();
- $(document).off('click', '#web_item_save');
- $(document).on('click', '#web_item_save', function () {
- saveProfileData(true);
- });
- $('#web_main_url_text').focus();
- });
- $('#web_item_cancel').click(webProfileCancel);
- $(document).on('click keyup change', '#add_web_item_win input', function () {
- $('#web_item_save').removeClass('btn_disabled');
- });
- $(document).on('change click', '#add_web_item_win .select_on_normal', function () {
- $('#web_item_save').removeClass('btn_disabled');
- });
- $('#web_list_input_set_default').click(setDefaultWebUrlSwitch);
- $('#web_env').click(function () {
- //RVC.Scroll.setTop('#add_web_item_win_scroll', 200);
- });
- }
- function initPage()
- {
- preShowWebList();
- loadData(true);
- }
- var fistTime = true;
- function init() {
- initPage();
-
- if (fistTime) {
- fistTime = false;
- bindEvents();
- RVC.Scroll.initScroll('#add_web_item_win_scroll');
- }
-
- }
- function destory() {
- clearAllErrorMsg();
- }
-
- return { init: init, destory: destory };
- }());
- window.businessRenderPage = function () {
- businessController.init();
- };
|