var Platform_Directive_APP = angular.module(APP_NAME); //鏃ユ湡閫夋嫨鎺т欢淇敼鍓嶅浠? /*Platform_Directive_APP.directive("datePicker",['$timeout',function ($timeout) { return{ restrict:'A', scope : { model : "=ngModel", type : "@ngType", config : "=ngConfig", disabled : "=ngDisabled", writeAble : "@ngWriteAble", format : "@ngFormat", divid : "@divid", initValue : "@ngInitValue" }, template: function(tElement,tAttrs){ var _html = ''; // var divid = tAttrs.divid ? tAttrs.divid : "static"; var className = tAttrs.divclass ? tAttrs.divclass : 'date-picker-class'; _html += '
' + '' + '' + '' + ''+ '
'; return _html; }, link: function($scope,element,attrs) { //鐩戝惉鏄惁瀛樺湪鍒濆鍖栨暟鎹 if($scope.initValue && !$scope.model){ $scope.model = $scope.initValue; } // 鐩戞帶鍙灞炴€ $scope.inputid = 'inputid_' + new Date().getTime(); $scope.$watch("disabled",function (newValue, oldValue) { if (newValue){ var obj = $("#" + $scope.inputid); obj.attr("disabled","disabled"); obj.attr("readOnly",true); obj.parent().find(".input-group-addon").unbind("click").css({ 'cursor':'not-allowed', "display" : "none" }).attr("disabled","disabled"); obj.css({ 'cursor':'not-allowed', "border-bottom" : "0" }); } },true); var forceParse = true; var divid = attrs.divid ? attrs.divid : 'date-default-id'; var className = attrs.divclass ? attrs.divclass : 'date-picker-class'; $scope.divid = divid $scope.type = $scope.type ? $scope.type : "date"; $scope.format = $scope.format ? $scope.format : "yyyy-mm-dd"; if($scope.writeAble && $scope.format && ($scope.type !== 'min') && ($scope.type !== 'hour')){ if($scope.type !== 'month'){ forceParse = false; } $(element).find("input").attr("readonly",false); $scope.$watch("_model",function (newValue, oldValue) { if(newValue && (newValue !== oldValue) && (newValue !== $scope.model)){ if(!platform.date.checkDate(newValue,$scope.format)){ $scope.model = newValue; } } }); }else { $scope.$watch("_model",function (newValue, oldValue) { if(newValue && (newValue !== oldValue) && (newValue !== $scope.model)){ $scope.model = newValue; } }); $(element).find("input").css({ "border-bottom" : "1px solid #e8e8e8", "cursor" : "pointer" }) } $scope._model = ''; $scope.$watch("model",function (newValue,oldValue) { if(newValue == $scope._model){ return false; } if(!newValue) { $scope._model = ''; }else { var length = 0; switch ($scope.type) { case "year": length = 4; break; case 'month': length = 7; break; case 'date': length = 10; break; case 'hour': length = 16; break; case 'min': length = 19; break; case "second" : length = 19; break; default : length = 10; break; } if(newValue != parseInt(newValue)){ $scope._model = newValue; $scope._model = platform.getStrLeft(newValue,length); }else { newValue = newValue + ""; if(($scope.type !=="year") || (($scope.type ==="year") && (newValue.toString()).length > 4)){ $scope._model = platform.getStrLeft(platform.date.formatDate(newValue,"-"),length); $scope.model = platform.getStrLeft(platform.date.formatDate(newValue,"-"),length); }else { $scope._model = newValue; $scope._model = platform.getStrLeft(newValue,length); } } $timeout(function () { $("#"+divid).datetimepicker("update",$scope.model); },5000) } }); $scope.$watch("config",function (newValue, oldValue) { if(newValue === oldValue){ return false } if (newValue){ $('#'+divid).datetimepicker('remove'); $scope.initDatePicker(); } },true); $scope.initDatePicker = function () { var config = { type : $scope.type, forceParse: forceParse, container: $('#'+divid), initialDate:($scope.model ? $scope.model : new Date()), onChoose: function(date){ $scope.model = date; $scope.$apply(); } }; if(attrs.divid){ config.id = divid; config.className = ''; }else { config.id = ''; config.className = className; } if($scope.config){ $.each($scope.config,function (key, value) { if(key !== 'onChoose'){ config[key] = value; }else if($.isFunction($scope.config[key])){ config[key] = function () { $scope.model = date; $scope.config[key]() $scope.$apply(); } } }) } Common.datePicker.dateInit(config); }; /!*杩欓噷鏈夊潙锛屼絾鏄湭鎵惧埌濂界殑瑙e喅鏂规硶銆 鐩殑鏄负浜嗚В鍐虫爣绛句腑浼犲叆id鍚庨渶瑕佺瓑寰呮ā鐗堟覆鏌撴垚鍔熷悗鎵嶆墽琛屽垵濮嬪寲鏃ユ湡閫夋嫨妗嗐€?!/ $timeout(function () { $scope.initDatePicker(); },300); } }; }]);*/ Platform_Directive_APP.directive("datePicker",['$timeout',function ($timeout) { return{ restrict:'A', scope : { model : "=ngModel", type : "@ngType", config : "=ngConfig", disabled : "=ngDisabled", writeAble : "@ngWriteAble", format : "@ngFormat", divid : "@divid", initValue : "@ngInitValue" }, template: function(tElement,tAttrs){ var _html = ''; // var divid = tAttrs.divid ? tAttrs.divid : "static"; var className = tAttrs.divclass ? tAttrs.divclass : 'date-picker-class'; _html += '
' + '' + '' + '' + ''+ '
'; return _html; }, link: function($scope,element,attrs) { var splitType = '-'; if($scope.format){ splitType = $scope.format.split("")[4]; } //鐩戝惉鏄惁瀛樺湪鍒濆鍖栨暟鎹 if($scope.initValue && !$scope.model){ $scope.model = $scope.initValue; } // 鐩戞帶鍙灞炴€ $scope.inputid = 'inputid_' + new Date().getTime(); $scope.$watch("disabled",function (newValue, oldValue) { if (newValue){ var obj = $("#" + $scope.inputid); obj.attr("disabled","disabled"); obj.attr("readOnly",true); obj.parent().find(".input-group-addon").unbind("click").css({ 'cursor':'not-allowed', "display" : "none" }).attr("disabled","disabled"); obj.css({ 'cursor':'not-allowed', "border-bottom" : "0" }); } },true); var forceParse = true; var divid = attrs.divid ? attrs.divid : 'date-default-id'; var className = attrs.divclass ? attrs.divclass : 'date-picker-class'; $scope.divid = divid $scope.type = $scope.type ? $scope.type : "date"; $scope.format = $scope.format ? $scope.format : "yyyy-mm-dd"; if(($scope.writeAble == 'true' || $scope.writeAble == true) && $scope.format && ($scope.type !== 'min') && ($scope.type !== 'hour')){ if($scope.type !== 'month'){ forceParse = false; } $(element).find("input").attr("readonly",false); $scope.$watch("_model",function (newValue, oldValue) { if(newValue && (newValue !== oldValue) && (newValue !== $scope.model)){ if(!platform.date.checkDate(newValue,$scope.format)){ $scope.model = newValue; } } }); }else { $scope.$watch("_model",function (newValue, oldValue) { if(newValue && (newValue !== oldValue) && (newValue !== $scope.model)){ $scope.model = newValue; } }); $(element).find("input").css({ "border-bottom" : "1px solid #e8e8e8", "cursor" : "pointer" }) } // 娣诲姞鐐瑰嚮杈撳叆妗嗕簨浠堕€変腑鐣岄潰鏄剧ず锛堝師鎻掍欢鐐瑰嚮鍚庡啀娆$偣鍑讳細闅愯棌鏃堕棿鎻掍欢锛 element.bind('click', function(){ $("#"+divid).datetimepicker('show'); }); $scope._model = ''; $scope.$watch("model",function (newValue,oldValue) { if(newValue == $scope._model){ return false; } if(!newValue) { $scope._model = ''; }else { var length = 0; switch ($scope.type) { case "year": length = 4; break; case 'month': length = 7; break; case 'date': length = 10; break; case 'hour': length = 16; break; case 'min': length = 19; break; case "second" : length = 19; break; default : length = 10; break; } if(newValue != parseInt(newValue)){ $scope._model = newValue; $scope._model = platform.getStrLeft(newValue,length); }else { newValue = newValue + ""; if(($scope.type !=="year") || (($scope.type ==="year") && (newValue.toString()).length > 4)){ $scope._model = platform.getStrLeft(platform.date.formatDate(newValue,splitType),length); $scope.model = platform.getStrLeft(platform.date.formatDate(newValue,splitType),length); }else { $scope._model = newValue; $scope._model = platform.getStrLeft(newValue,length); } } $timeout(function () { $("#"+divid).datetimepicker("update",$scope.model); },5000) } }); $scope.$watch("config",function (newValue, oldValue) { if(newValue === oldValue){ return false } if (newValue){ $('#'+divid).datetimepicker('remove'); $scope.initDatePicker(); } },true); $scope.initDatePicker = function () { var config = { type : $scope.type, forceParse: forceParse, splicDate : splitType, container: $('#'+divid), initialDate:($scope.model ? $scope.model : new Date()), onChoose: function(date){ $scope.model = date; $scope.$apply(); } }; if(attrs.divid){ config.id = divid; config.className = ''; }else { config.id = ''; config.className = className; } if($scope.config){ $.each($scope.config,function (key, value) { if(key !== 'onChoose'){ config[key] = value; }else if($.isFunction($scope.config[key])){ config[key] = function (date) { $scope.model = date; $scope.config[key](date) $scope.$apply(); } } }) } Common.datePicker.dateInit(config); }; /*杩欓噷鏈夊潙锛屼絾鏄湭鎵惧埌濂界殑瑙e喅鏂规硶銆 鐩殑鏄负浜嗚В鍐虫爣绛句腑浼犲叆id鍚庨渶瑕佺瓑寰呮ā鐗堟覆鏌撴垚鍔熷悗鎵嶆墽琛屽垵濮嬪寲鏃ユ湡閫夋嫨妗嗐€?/ $timeout(function () { $scope.initDatePicker(); },300); } }; }]); Platform_Directive_APP.directive("gridDirective",[function () { return { restrict: 'A', transclude:true, template : function (element,tAttr) { var option = eval('('+tAttr.options+')') ? eval('('+tAttr.options+')') : {}; var type = tAttr.paginationtext ? tAttr.paginationtext : 'iconText'; var gridName = tAttr.id ? tAttr.id : 'gridOptions'; var optionName = tAttr.id ? (tAttr.id + '.gridOptions') : 'gridOptions.gridOptions'; var dependence = option.dependence; var isPageable = (option.isPageable == 'false') ? false : true; var pageMaxSize = option.pageMaxSize ? option.pageMaxSize : '3'; var showEditTips = option.showEditTips; var showButtomTips = option.showButtomTips; /** * 澧炲姞鑷畾涔夊ご閮ㄥ唴瀹广€ */ var headerHtml = ''; if(option && option.isCustomHeader){ if(option.isMergeHeader == true){ headerHtml = '
\ \ \ \ \ \ \ \
{{item.name}}
\
' }else { headerHtml = '
\ \ \ \
\
'; } } if(!showButtomTips){ return headerHtml+'
' + // '
娌℃湁鏌ヨ鍒版暟鎹?/div>'+ '' + '
'+ '
' + '
' + '' + '' + '' + ''+ ''+ '姣忛〉' + ''+ '鏉狘/span>'+ '
' + '
鍏 {{ '+gridName+'.page.bigTotalItems }} 鏉? + '
' + '
' }else{ return headerHtml+'
' + '
娌℃湁鏌ヨ鍒版暟鎹?/div>'+ '
'+ '
'+ '
' + '
*鍙屽嚮鍗曞厓鏍煎彲杩涜缂栬緫
'+ '
' + '
鍏 {{ bigTotalItems }} 鏉? + '
' + '
' } }, link: function ($scope, element,attr,modelController) { $scope[attr.id].gridEvent._onRowHover = function (row, event) { $(".ui-grid-hover").removeClass('ui-grid-hover'); $(event.target).parent().parent().find('.ui-grid-cell').addClass("ui-grid-hover"); }; $scope[attr.id].gridEvent._onRowLeave = function (row, event) { $(".ui-grid-hover").removeClass('ui-grid-hover') }; if($("#"+attr.id).prev().find("#appendHtml") && $scope[attr.id].gridHeader){ $("#"+attr.id).prev().find("#appendHtml").html($scope[attr.id].gridHeader.html) } } } }]); Platform_Directive_APP.directive("createdate",[function () { return{ restrict:'AE', transclude: true, template: function(tElement,tAttrs){ if (!tAttrs.placeholder) { tAttrs.placeholder = ""; } if(tAttrs.hasOwnProperty("datareadonly")){ tAttrs.datareadonly = "readonly"; }else{ tAttrs.datareadonly = ""; } if(tAttrs.hasOwnProperty("dataline")){ tAttrs.dataline = "border-bottom: 1px solid;"; }else{ tAttrs.dataline = ""; } var _html = ''; _html += '
' + '' + ''+ '
' + '
'+ ''; return _html; }, link: function($scope,element,attrs) { $scope._DateSelect = {}; $scope._DateSelect._hideDateSelectIcon = false; $scope._DateSelect._changeToReadOnly = function () { $scope._DateSelect._hideDateSelectIcon = true; $(".date-select-for-disabled > input").attr('placeholder','').css({ border : 'none' }) }; $scope._DateSelect._changeToReadWrite = function () { $scope._DateSelect._hideDateSelectIcon = false; $(".date-select-for-disabled > input").attr('placeholder',attrs.placeholder).css({ 'border-bottom' : '1px solid' }) }; var option = eval('('+attrs.options+')') ? eval('('+attrs.options+')') : ''; if(option && option.isAutoInit){ var config = { id : attrs.divid, onChoose: function(date){ eval("$scope." + attrs.model + "='" + date+"'"); //date = "'2016-12-17'" if(option.onChoose){ if($.isFunction($scope[option.onChoose])){ $scope[option.onChoose](date); } } } }; Common.datePicker.dateInit(config); } } }; }]); Platform_Directive_APP.directive("elastic",['$timeout',function ($timeout) { return { restrict: 'A', link: function($scope, element,attr,modelController) { $scope.maxHeight = $scope.maxHeight || element[0].style['max-height']; $scope.minHeight = element[0].style['min-height']; $scope.initialHeight = $scope.initialHeight || element[0].style.height; var resize = function() { element[0].style.height = $scope.initialHeight; element[0].style.height = $scope.minHeight; if(element[0].scrollHeight >= $scope.maxHeight || $scope.initialHeight >= $scope.maxHeight){ return; } element[0].style.height = parseFloat(element[0].scrollHeight) +1 + "px"; }; element.on("blur focus input change", resize); $timeout(resize, 0); } }; }]); Platform_Directive_APP.directive("dropselect",[function () { return{ restrict:'E', template: function(tElement,tAttrs){ var option = eval('('+tAttrs.options+')'); var data = eval('('+option.data+')'); var _html = ''; _html += '' + 'hello' + '
' + '
'; for(var i=0;i' + ''+data[i].name+'

' } return _html; }, transclude: true, replace: true }; }]); Platform_Directive_APP.directive("openSelect",[function () { return { restrict: 'EA', transclude: true, // replace: true, template: function(tElement, tAttr){ var option = eval('('+tAttr.options+')'); if(!option){ return '
' + '' + '' + '
'; } else { var selectClass = option.selectClass ? option.selectClass : 'input-group'; var modelName = option.modelName ? option.modelName : 'data'; var modelBH = option.modelBH ? option.modelBH : 'modelID'; var inputClass = option.inputClass ? option.inputClass : 'form-control'; var selectType = option.selectType ? option.selectType : 'info'; var placeholder = option.placeholder ? option.placeholder : ''; var _html = '
' + '' + ''; if(selectType == 'user'){ _html += ''; } else if(selectType == 'dept'){ _html += ''; _html += ''; _html += ''; } else { _html += ''; } _html += '
'; if (option.onClick) {//甯﹀弬鏁 var methodName = option.onClick; if (methodName.charAt(methodName.length-1) != ')') { methodName = methodName + '($event)'; } var rex = new RegExp('_selectData[\(][\$]event[\)]',"g"); _html = _html.replace(rex,methodName); } return _html; } }, controller: function($scope) { $scope._OpenSelect = {}; $scope._OpenSelect._hideOpenSelectIcon = false; $scope._OpenSelect._changeToReadOnly = function () { $scope._OpenSelect._hideOpenSelectIcon = true; $(".open-select-for-disabled > input").css({ border : 'none' }) }; $scope._OpenSelect._changeToReadWrite = function () { $scope._OpenSelect._hideOpenSelectIcon = false; $(".open-select-for-disabled > input").css({ 'border-bottom' : '1px solid' }) }; }, link : function ($scope, element,attr) { $scope._selectData = function (event) { if(($(event.target).parent().parent().parent().find(".only-read").length) || $(event.target).parent().parent().parent().hasClass("only-read")){ return false; } if($.isFunction($scope.selectData)){ $scope.selectData(); } } } } }]); Platform_Directive_APP.directive("onFinishRenderFilters",['$timeout',function ($timeout) { return { restrict: 'A', link: function(scope, element, attr) { if (scope.$last === true) { $timeout(function() { scope.$emit('ngRepeatFinished'); }); } } }; }]); Platform_Directive_APP.directive("regionSelect",[function () { return { restrict: 'EA', scope: true, controller: function($scope){ var ctrl = this; ctrl.currentProvince = ''; ctrl.currentCity = ''; ctrl.currentArea = ''; ctrl.currentTown = ''; $scope.$on("change_city",function($event,data){ $scope.$broadcast('changeCityArray',data); }); $scope.$on("change_area",function($event,data){ $scope.$broadcast('changeAreaArray',data); }); $scope.$on("change_town",function($event,data){ $scope.$broadcast('changeTownArray',data); }); } }; }]); Platform_Directive_APP.directive("province",[function () { return { restrict : 'E', require: ['^?regionSelect'], scope : { getObject : "=ngGetobject", model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢╟ode浼犺緭 showGlJG : "@ngShowGljg", cityData : "@ngCityData", proData : "@ngProvinceData", validate : "@ngValidate", disabled : "=ngDisabled", initValue : "@ngInitValue", position : "@ngPosition" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + ''+ ''+ '
', link : function(scope, element, attrs,ctrl){ // 鏍囪瘑鏄惁閫氳繃閫夋嫨涓嬫媺鍒楄〃璋冪敤涓嬫媺鍥炶皟鍑芥暟锛宖alse琛ㄧず鍚?鍏朵粬鍊艰〃绀烘槸 var flag = false; switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } var proData = (scope.proData) ? scope.proData.split(",") : null; var cityData = (scope.cityData) ? scope.cityData.split(",") : null; scope.hasClass = function () { if($(element).find("#valid").hasClass("validatebox-invalid")){ if(!scope.model){ return "pt-invalid" } } return ""; }; scope._provinces = [{label : '璇烽€夋嫨',value : ''}]; scope.proCodes = scope.proData ? scope.proData.split(",") : undefined; scope.cityCodes = scope.cityData ? scope.cityData.split(",") : undefined; scope.$watch("model", function(newValue, oldValue) { if(newValue){ $("#valid").removeClass("validatebox-invalid") } scope.model = newValue; if (newValue === oldValue) { return; } if (ctrl.currentProvince === newValue) { return; } for(var i=0; i< scope._provinces.length;i++){ if(newValue == scope._provinces[i].value){ scope._provinces.selected = scope._provinces[i]; scope.getObject = scope._provinces[i]; ctrl.currentProvince = scope._provinces[i].value; scope._changeSelectedProvince(scope._provinces[i],null); break; } } }); scope._changeSelectedProvince = function (item, model,outside) { flag = true; if(scope.model == item.value && model){ return false; } scope.model = item.value; scope.getObject = item; if(scope.model){ $.ajax({ url : Common.webRoot() + '/platform/system/administrativeregioncontroller/queryAdministrativeRegionByCondition', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ "XZJB" : "2", "XZQHDMS" : cityData, "FDM" : scope.model }), success : function (result){ var cities = [{label : '璇烽€夋嫨',value : ''}]; for(var j = 0;j < result.length;j++){ var obj = {}; /* * 淇敼闇€姹傦紝鑻ュ~鍐欎簡琛屾斂鍖哄垝涓樉绀虹鐞嗘満鏋勶紝鍒欏彧鍒ゆ柇鏄惁鍦ㄧ鐞嗘満鏋勪腑鏄惁鏈夋暟鎹?鑻ユ棤鏁版嵁锛屼笉鏄剧ず閫夐」 * */ if(scope.showGlJG && scope.showGlJG.toLowerCase() == 'true'){ if(result[j].GLJG){ obj = {label : result[j].GLJG,value : result[j].XZQHDM}; cities.push(obj); } }else { obj = {label : result[j].JC,value : result[j].XZQHDM}; cities.push(obj); } } outside = outside ? outside : false; var data = {value : cities,key : outside}; scope.$emit("change_city",data); } }); }else { var cities = [{label : '璇烽€夋嫨',value : ''}]; outside = outside ? outside : false; var data = {value : cities,key : outside}; scope.$emit("change_city",data); } }; $.ajax({ url : Common.webRoot() + '/platform/system/administrativeregioncontroller/queryAdministrativeRegionByCondition', type : "POST", dataType : 'json', contentType : 'application/json', data : JSON.stringify({ "XZJB" : "1", "XZQHDMS" : proData }), success : function (result){ //鍒濆鍖栫渷浠戒笅鎷夋 for(var i = 0;i < result.length;i++){ var obj = {}; /* * 淇敼闇€姹傦紝鑻ュ~鍐欎簡琛屾斂鍖哄垝涓樉绀虹鐞嗘満鏋勶紝鍒欏彧鍒ゆ柇鏄惁鍦ㄧ鐞嗘満鏋勪腑鏄惁鏈夋暟鎹?鑻ユ棤鏁版嵁锛屼笉鏄剧ず閫夐」 * */ if(scope.showGlJG && scope.showGlJG.toLowerCase() == 'true'){ if(result[i].GLJG){ obj = {label : result[i].GLJG,value : result[i].XZQHDM}; scope._provinces.push(obj); } }else { obj = {label : result[i].JC,value : result[i].XZQHDM}; scope._provinces.push(obj); } } //澶栭儴鍒濆鍖栬祴鍊煎姩浣 if(scope.model){ for(var i=0; i< scope._provinces.length;i++){ if(scope.model == scope._provinces[i].value){ scope._provinces.selected = scope._provinces[i]; ctrl.currentProvince = scope._provinces[i].value; scope._changeSelectedProvince(scope._provinces[i],null,true); } } } scope.$apply(); } }); } }; }]); Platform_Directive_APP.directive("city",[function () { return { restrict : 'E', require: '^?regionSelect', scope : { getObject : "=ngGetobject", model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢╟ode浼犺緭 showGlJG : "@ngShowGljg", areaCodes : "@ngAreaData", validate : "@ngValidate", disabled : "=ngDisabled", initValue : "@ngInitValue", position : "@ngPosition" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
', link : function(scope, element, attrs,ctrl){ // 鏍囪瘑鏄惁閫氳繃閫夋嫨涓嬫媺鍒楄〃璋冪敤涓嬫媺鍥炶皟鍑芥暟锛宖alse琛ㄧず鍚?鍏朵粬鍊艰〃绀烘槸 var flag = false; switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } var areaCodes = (scope.areaCodes) ? scope.areaCodes.split(",") : null; scope.hasClass = function () { if($(element).find("#valid-city").hasClass("validatebox-invalid")){ if(!scope.model){ return 'pt-invalid' } } return false }; scope._cities = []; /** * 鏇存柊model鐨勫€ */ scope.$watch("model", function(newValue, oldValue) { if (newValue === oldValue) { return; } if (ctrl.currentCity === newValue) { return; } for(var i=0; i< scope._cities.length;i++){ if(newValue == scope._cities[i].value){ scope._cities.selected = scope._cities[i]; scope.getObject = scope._cities[i]; ctrl.currentCity = scope._cities[i].value; scope._changeSelectedCity(scope._cities[i],null); break; } } }); /** * 鏇存柊鍩庡競鏁扮粍 */ scope.$on("changeCityArray",function($event,data){ scope._cities = data.value; if(!data.value.length){ scope.model = ''; } if(data.key === "select"){ scope.model = ''; scope.$emit("change_area",{value : []}); }else { for(var i=0; i< scope._cities.length;i++){ if(scope.model == scope._cities[i].value){ scope._cities.selected = scope._cities[i]; ctrl.currentCity = scope._cities[i].value; scope._changeSelectedCity(scope._cities[i],null,true); } } } }); scope._changeSelectedCity = function (item, model,outside) { flag = true; if(model && scope.model == item.value){ return false } scope.model = item.value; scope.getObject = item; if(scope.model){ $.ajax({ url : Common.webRoot() + '/platform/system/administrativeregioncontroller/queryAdministrativeRegionByCondition', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ /*"XZJB" : "3",*/ "XZQHDMS" : areaCodes, "FDM" : scope.model }), success : function (result){ var areas = [{label : '璇烽€夋嫨',value : ''}]; for(var j = 0;j < result.length;j++){ var obj = {}; /* * 淇敼闇€姹傦紝鑻ュ~鍐欎簡琛屾斂鍖哄垝涓樉绀虹鐞嗘満鏋勶紝鍒欏彧鍒ゆ柇鏄惁鍦ㄧ鐞嗘満鏋勪腑鏄惁鏈夋暟鎹?鑻ユ棤鏁版嵁锛屼笉鏄剧ず閫夐」 * */ if(scope.showGlJG && scope.showGlJG.toLowerCase() == 'true'){ if(result[j].GLJG){ obj = {label : result[j].GLJG,value : result[j].XZQHDM}; areas.push(obj); } }else { obj = {label : result[j].JC,value : result[j].XZQHDM}; areas.push(obj); } } outside = outside ? outside : false; var data = {key : outside,value :areas} scope.$emit("change_area",data); } }); }else { var areas = [{label : '璇烽€夋嫨',value : ''}]; outside = outside ? outside : false; var data = {key : outside,value :areas} scope.$emit("change_area",data); } }; } }; }]); Platform_Directive_APP.directive("district",[function () { return { restrict : 'E', require: '^?regionSelect', scope : { getObject : "=ngGetobject", model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢╟ode浼犺緭 showGlJG : "@ngShowGljg", townCodes : "@ngTownData", validate : "@ngValidate", disabled : "=ngDisabled", initValue : "@ngInitValue", position : "@ngPosition" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
', link : function(scope, element, attrs,ctrl){ // 鏍囪瘑鏄惁閫氳繃閫夋嫨涓嬫媺鍒楄〃璋冪敤涓嬫媺鍥炶皟鍑芥暟锛宖alse琛ㄧず鍚?鍏朵粬鍊艰〃绀烘槸 var flag = false; switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } var townCodes = (scope.townCodes) ? scope.townCodes.split(",") : null; scope.hasClass = function (className) { if($(element).find("#valid-area").hasClass("validatebox-invalid")){ if(!scope.model){ return 'pt-invalid' } } return false }; scope._areas = []; /** * 鏇存柊model鐨勫€ */ scope.$watch("model", function(newValue, oldValue) { if(!newValue){ scope.model = ''; scope.$emit("change_town",{value : []}); } if (newValue === oldValue) { return; } for(var i=0; i< scope._areas.length;i++){ if(newValue == scope._areas[i].value){ scope._areas.selected = scope._areas[i]; scope.getObject = scope._areas[i]; ctrl.currentArea = scope._areas[i].value; scope._changeSelectedArea(scope._areas[i],null); break; } } }); /** * 鏇存柊鍖哄幙鏁扮粍 */ scope.$on("changeAreaArray",function($event,data){ scope._areas = data.value; if(!data.value.length){ scope.model = ''; } if(data.key === "select" ){ scope.model = ''; scope.$emit("change_town",{value : []}); }else if(data.key && scope._areas.length){ for(var i=0; i< scope._areas.length;i++){ if(scope.model == scope._areas[i].value){ scope._areas.selected = scope._areas[i]; ctrl.currentArea = scope._areas[i].value; scope._changeSelectedArea(scope._areas[i],null,true); } } }else { scope.$emit("change_town",{value : []}); } }); scope._changeSelectedArea = function (item, model,outside) { flag = true; if(scope.model == item.value && model){ return false; } scope.model = item.value; scope.getObject = item; if(scope.model){ $.ajax({ url : Common.webRoot() + '/platform/system/administrativeregioncontroller/queryAdministrativeRegionByCondition', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ "XZJB" : "4", "XZQHDMS" : townCodes, "FDM" : scope.model }), success : function (result){ var towns = [{label : '璇烽€夋嫨',value : ''}]; for(var j = 0;j < result.length;j++){ var obj = {}; /* * 淇敼闇€姹傦紝鑻ュ~鍐欎簡琛屾斂鍖哄垝涓樉绀虹鐞嗘満鏋勶紝鍒欏彧鍒ゆ柇鏄惁鍦ㄧ鐞嗘満鏋勪腑鏄惁鏈夋暟鎹?鑻ユ棤鏁版嵁锛屼笉鏄剧ず閫夐」 * */ if(scope.showGlJG && scope.showGlJG.toLowerCase() == 'true'){ if(result[j].GLJG){ obj = {label : result[j].GLJG,value : result[j].XZQHDM}; towns.push(obj); } }else { obj = {label : result[j].JC,value : result[j].XZQHDM}; towns.push(obj); } } outside = outside ? outside : false; var data = {key : outside ,value : towns}; scope.$emit("change_town",data); } }); }else { var towns = [{label : '璇烽€夋嫨',value : ''}]; outside = outside ? outside : false; var data = {key : outside ,value : towns}; scope.$emit("change_town",data); } }; } }; }]); Platform_Directive_APP.directive("town",[function () { return { restrict : 'E', require: '^?regionSelect', scope : { getObject : "=ngGetobject", model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢╟ode浼犺緭 showGlJG : "@ngShowGljg", validate : "@ngValidate", disabled : "=ngDisabled", initValue : "@ngInitValue", position : "@ngPosition" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
', link : function(scope, element, attrs,ctrl){ // 瀛樺偍鐢ㄦ埛璁剧疆鐨 鏄惁鏍¢獙 var originalValidate = scope.validate; // 鏍囪瘑鏄惁閫氳繃閫夋嫨涓嬫媺鍒楄〃璋冪敤涓嬫媺鍥炶皟鍑芥暟锛宖alse琛ㄧず鍚?鍏朵粬鍊艰〃绀烘槸 var flag = false; switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } scope.hasClass = function (className) { if($(element).find("#valid-town").hasClass("validatebox-invalid")){ if(!scope.model){ return 'pt-invalid'; } } return false }; scope._towns = []; /** *鏇存柊model閫変腑鐨勫€ */ scope.$watch("model", function(newValue, oldValue) { for(var i=0; i< scope._towns.length;i++){ if(newValue == scope._towns[i].value){ scope._towns.selected = scope._towns[i]; ctrl.currentTown = scope._towns[i].value; scope.getObject = scope._towns[i]; scope._changeSelectedTown(scope._towns[i],null); break; } } }); /** * 鏇存柊鍩庨晣鏁版嵁鏁扮粍 */ scope.$on("changeTownArray",function($event,data){ scope._towns = data.value; if(!data.value.length){ // 鎭㈠鐢ㄦ埛璁剧疆鐨 鏄惁鏍¢獙 scope.validate = originalValidate; scope.model = ''; } if(data.key === "select"){ // 绗笁绾ц鏀垮尯鍒掍笉鍚鍥涚骇琛屾斂鍖哄垝锛屽垯瀵圭鍥涚骇琛屾斂鍖哄垝涓嶆牎楠 if (scope._towns.length == 1) { scope.validate = false; } scope.model = ''; }else { // 鎭㈠鐢ㄦ埛璁剧疆鐨 鏄惁鏍¢獙 if (scope._towns.length > 1) { scope.validate = originalValidate; } for(var i=0; i< scope._towns.length;i++){ if(scope.model == scope._towns[i].value){ scope._towns.selected = scope._towns[i]; ctrl.currentTown = scope._towns[i].value; scope._changeSelectedTown(scope._towns[i],null,true); } } } }); scope._changeSelectedTown = function (item, model,outside) { flag = true; if(scope.model == item.value && model){ return false; } scope.model = item.value; scope.getObject =item; }; } }; }]); Platform_Directive_APP.directive("codeset",[function () { return { restrict : 'E', scope : { dm : "@dm", dmjbh : "@dmjbh", fdm : "@fdm", config : "=ngConfig", model : "=ngModel", type : "@ngType", getList : "=ngGetlist", validate : "@ngValidate", multip : "@ngMultiple", disabled : "=ngDisabled", onSelectCallback : "&onSelectCallback", initValue : "@ngInitValue", position : "@ngPosition", option : "@option", editable : "@editable" }, template : '
\
\ \ \ \ \ \ \ \ \
\
\ \ \ \ \ \ \ \ \
\ \
\ \ \ \ \
\
\ \ \ \ \
\
\
    \
  • \ {{item.label}}\
  • \
\
\ \
', link : function(scope, element, attrs){ switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } scope.multiple = false; switch (scope.multip){ case "false" : scope.multiple = false; break; case "true" : scope.multiple = true; break; default : break; } if(scope.initValue && !scope.model){ var initData = scope.initValue.split(","); if(scope.multiple){ scope.model = initData; }else { scope.model = initData[0]; } } scope.hasClass = function (className) { if($(element).find("#valid-code").hasClass("validatebox-invalid")){ if(!scope.model || !scope.model.length){ return 'pt-invalid'; } } return '' }; scope.currentCode = ''; scope._codes = []; scope.radio = {}; scope.checkbox = []; /*scope.$watch('radio.radioSelected', function(val,oldValue) { if (val) scope.model = val.value; });*/ scope.clickRadio = function (item) { //2017-09-28 渚濆寳浜垎鍏徃鎻愬嚭鐨勪慨鏀归渶姹傦紝鍒犻櫎鍦ㄥ凡閫変腑鎯呭喌涓嬬偣鍑诲綋鍓嶄竴涓椂锛屽彇娑堥€変腑鐨勫姛鑳 /*if(scope.model && item.value && (item.value == scope.model)){ scope.radio.radioSelected = null; }*/ scope.model = scope.radio.radioSelected ? scope.radio.radioSelected.value : null; }; scope.getEntityFromModal = function (item) { scope.currentCode = ''; if(item && item.check){ if($.inArray(item.value,scope.checkbox) == -1){ scope.checkbox.push(item.value); } }else if(item && (item.check == false)){ for(var i= 0;i
', link : function(scope, element, attrs){ var dmjbh = attrs.dmjbh ?attrs.dmjbh.replace(/\s/g, "") : ''; var ngModel = attrs.ngModel ? attrs.ngModel.replace(/\s/g, "") : null; if(null == dmjbh || 'undefined' == typeof(dmjbh) || '' == dmjbh){ return; } scope._openCodeList = function () { if(null == dmjbh || 'undefined' == typeof(dmjbh) || '' == dmjbh){ Common.RBTips('浠g爜闆嗙紪鍙蜂笉鑳戒负绌?', 2); return; } Common.dataSelect4CommonCode.open(function(data){ //鏇存柊model涓殑鍊 if(null != ngModel && '' != ngModel && 'undefined' != typeof(ngModel)){ var objs_code = ngModel.split(".") if('undefined' == typeof(scope[objs_code[0]])){ scope[objs_code[0]] = {}; } var obj_code = scope[objs_code[0]]; for(var i=1;i Platform_Directive_APP.directive("codetree",function () { return { restrict : 'E', scope : {}, template :'
' + '' + '' + '
', //'', link : function(scope, element, attrs){ var dmjbh = attrs.dmjbh ?attrs.dmjbh.replace(/\s/g, "") : ''; var ngModel = attrs.ngModel ? attrs.ngModel.replace(/\s/g, "") : null; var treeRoot = attrs.rootId ? attrs.rootId.replace(/\s/g, "") : 'ROOT'; var isMulti = attrs.isMulti ? attrs.isMulti.replace(/\s/g, "") : true; var readonly = attrs.readonly ? attrs.readonly.replace(/\s/g, "") : false; readonly = readonly == 'readonly' ? true : readonly; var title = attrs.title ? attrs.title.replace(/\s/g, "") : '鍏叡浠g爜鍊?; var callback = attrs.callback ?attrs.callback.replace(/\s/g, ""): null; var initXHList = []; var isOpenFlag = false; if(null == dmjbh || 'undefined' == typeof(dmjbh) || '' == dmjbh){ return; } scope.$parent.$watch(ngModel,function (newValue, oldValue) { var XHList = []; if(newValue && (newValue !== oldValue || !scope.names)){ if (newValue instanceof Array){ for(var i=0;i= 0){ XHList = newValue.split(','); }else{ XHList.push(newValue); } } } if(XHList.length >0 && !isOpenFlag){ $.ajax({ url : Common.webRoot() + '/platform/system/commoncodecontroller/getCommonCodes', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ XHList : XHList }), success : function (result){ if(result && result.length >0){ var showNames = ''; scope.names = ''; for(var i=0; i < result.length; i++){ showNames += result[i].DMMC +','; } scope.names = showNames.substring(0,showNames.length-1); } } }); } } }); scope._openCodeList = function () { isOpenFlag = true; var objs_code = []; var obj_code = {}; if(null == dmjbh || 'undefined' == typeof(dmjbh) || '' == dmjbh){ Common.RBTips('浠g爜闆嗙紪鍙蜂笉鑳戒负绌?', 2); return; } if(readonly == true || readonly == "true"){ return; } if(null != ngModel && '' != ngModel && 'undefined' != typeof(ngModel)){ objs_code = ngModel.split(".") if('undefined' == typeof(scope.$parent[objs_code[0]])){ scope.$parent[objs_code[0]] = {}; } obj_code = scope.$parent[objs_code[0]]; for(var i=1;i0){ for(var i=0; i < data.length; i++){ showNames += data[i].name +','; XHList.push(data[i].XH); } scope.$apply(function(){ scope.names = showNames.substring(0,showNames.length-1); }); } var xhs = XHList.toString(); eval("scope.$parent." + ngModel + "=('" + xhs +"')"); } if('' != callback && 'undefined' != typeof(callback)){ // callback = 'scope.$parent.'+callback; callback = callback.substring(0,callback.indexOf('(')+1)+'XHList'+')'; eval('scope.$parent.'+callback); } },dmjbh,title,'','TREE',{'treeRoot':treeRoot, 'isMulti':isMulti, 'initXHList':initXHList}); }; } }; }); Platform_Directive_APP.directive("popupSelect",['$http',function ($http) { return { restrict: 'A', scope : { model : "=ngModel", modelName : "=ngModelName", type : "@ngType", dataInfo : "@ngDataInfo", disabled : "=ngDisabled", className : "@ngClassName", multi : "@ngMulti", splitType : "@ngSplit", openTitle : "@ngOpenTitle", validate : "@ngValidate", placeholder : "@placeholder", callback : "&ngCallback", initValue: "@ngInitValue" }, template: function(tElement, tAttr){ var HTMLTemp = '
\ \ \ \ \
'; return HTMLTemp; }, link : function ($scope, element,attr) { $scope.modelName = ''; //鐢ㄤ簬锛屾牴鎹紶鍏ョ殑ID鍊艰嚜鍔ㄨ繘琛屾洿鎹 $scope.AllSelectData = null; //淇濆瓨褰撳墠缁勪欢鐨勬墍鏈夊緟閫夋暟鎹 $scope.type = $scope.type ? $scope.type : 'USER';//榛樿涓虹敤鎴烽€夋嫨锛 $scope.isValidate = true; //榛樿闇€瑕佸繀閫夋牎楠 if($scope.validate == "false"){ $scope.isValidate = false; } $scope.isArrayModel = $scope.splitType ? false : true; //瀛楃涓查粯璁ゅ垎闅旂 $scope.splitType = $scope.splitType ? $scope.splitType : ","; //瀛楃涓查粯璁ゅ垎闅旂 var _isMulti = false; //榛樿鍗曢€ if($scope.multi == true || $scope.multi == "true"){ _isMulti = true; } $scope.style = { iconClass : "glyphicon-user", _openTitle : "鐢ㄦ埛閫夋嫨", }; //鍦ㄦ爣绛句腑璧嬩簣鍒濆鍊肩殑鎯呭喌锛岃嫢initValue鏈夊€硷紝涓攎odel鍊间负绌虹殑鎯呭喌涓嬩娇鐢 if($scope.initValue && !$scope.model){ //灏唅nitValue 灞炴€т腑鐨勫€艰浆鍖栦负model鐨勫€ var XHList = $scope.initValue.split($scope.splitType); //鍗曢€夋椂锛宮odel涓哄瓧绗︿覆锛屽閫夋椂涓哄瓧绗︿覆鏁扮粍 if(_isMulti){ $scope.model = XHList }else { $scope.model = XHList[0] } } var queryAllDataURL = ''; var queryData = {}; if($scope.type && $scope.type.toUpperCase()){ switch ($scope.type.toUpperCase()){ case "USER" : $scope.style.iconClass = "glyphicon-user"; $scope.style._openTitle = "鐢ㄦ埛閫夋嫨"; if(!$scope.placeholder){ $scope.placeholder = "璇烽€夋嫨鐢ㄦ埛" } queryAllDataURL = Common.webRoot() +'/platform/component/tree/commontreecontroller/initTree'; queryData = { classpath: 'com.szboanda.platform.rms.user.service.impl.UserServiceImpl', ROOTXH: "ROOT", }; break; case "DEPT" : $scope.style.iconClass = "glyphicon-pt-organization"; $scope.style._openTitle = "閮ㄩ棬閫夋嫨"; if(!$scope.placeholder){ $scope.placeholder = "璇烽€夋嫨閮ㄩ棬" } queryAllDataURL = Common.webRoot() +'/platform/component/tree/commontreecontroller/initTree'; queryData = { classpath: 'com.szboanda.platform.rms.dept.service.impl.DeptServiceImpl', ROOTXH: "ROOT" }; break; case "HYLX" : $scope.style.iconClass = "glyphicon-info-sign"; $scope.style._openTitle = "琛屼笟绫诲瀷閫夋嫨"; if(!$scope.placeholder){ $scope.placeholder = "璇烽€夋嫨琛屼笟绫诲瀷" } queryAllDataURL = Common.webRoot() +'/platfrom/common/component/hylx/hylxcontroller/queryhylxs'; break; default : $scope.style.iconClass = "glyphicon-user"; $scope.style._openTitle = "鐢ㄦ埛閫夋嫨"; if(!$scope.placeholder){ $scope.placeholder = "璇烽€夋嫨鐢ㄦ埛" } queryAllDataURL = Common.webRoot() +'/platform/component/tree/commontreecontroller/initTree'; queryData = { classpath: 'com.szboanda.platform.rms.user.service.impl.UserServiceImpl', ROOTXH: "ROOT", }; break; } }; if($scope.openTitle){ $scope.style._openTitle = $scope.openTitle; }; var _dataInfo = {}; try { _dataInfo = eval('(' + $scope.dataInfo + ')'); } catch (e) { } $scope._openSelectData = function(event){ event.target.blur(); if($scope.disabled){ return false; } var forEchoData = []; if($scope.model){ //涓轰簡鍏煎鏃х増鏈紝浠嶅彲浼犲叆model鍊间负鏁扮粍 if($.isArray($scope.model)){ $.each($scope.model,function (index, value) { forEchoData.push({id:$scope.model[index]}) }) } else { var arrayTemp = $scope.model.split($scope.splitType); $.each(arrayTemp,function (index, value) { forEchoData.push({id:value}) }); // forEchoData.push({id:$scope.model}) } } Common.dataSelect.open(function(data){ if(data && data.length && data.length > 0){ if($scope.multi == 'true' ||$scope.multi == "" || $scope.multi == true){ // update begin by wwupower for 淇敼鏀寔鈥?鈥濈殑鏀寔 @date 2017-11-9 //姝ゅ鏄负浜嗗仛鍏煎锛屽綋杈撳叆鍊间负鏁扮粍鏃讹紝杩斿洖鏁扮粍鍊 锛岄粯璁ょ┖鏃朵负鏁扮粍 if($.isArray($scope.model) || $scope.model == null||$scope.isArrayModel){ $scope.modelName = ''; $scope.model = []; var modelName = []; for(var i=0;i0 ? modelName.join($scope.splitType) : ""; }else { //褰撹緭鍏ュ€间负瀛楃涓叉椂锛岃繑鍥炲瓧绗︿覆 $scope.modelName = ''; $scope.model = ''; var modelName = []; var modelId = []; for(var i=0;i0 ? modelName.join($scope.splitType) : ""; $scope.model = modelId.length>0 ? modelId.join($scope.splitType) : ""; } // update end by wwupower for 淇敼鏀寔鈥?鈥濈殑鏀寔 @date 2017-11-9 }else if($scope.multi == 'false'){ $scope.modelName = data[0].name; $scope.model = data[0].id; }else { $scope.modelName = data[0].name; $scope.model = data[0].id; } } else { $scope.modelName = ''; $scope.model = ''; } $scope.$apply(); if($scope.callback && $.isFunction($scope.callback)){ $scope.callback(); } }, $scope.type.toUpperCase(), _isMulti, $scope.style._openTitle, _dataInfo, forEchoData); } $scope.checkByModel = function (modelValue) { var result = $scope.AllSelectData; if(result){ switch ($scope.type.toUpperCase()){ case "USER" : if(result && result.data && result.data.length){ // update begin by wwupower for 淇敼鏀寔鈥?鈥濈殑鏀寔 @date 2017-11-9 $scope.modelName = ''; if($scope.multi == 'true' || $scope.multi == true){ //榛樿浠嶄互鏁扮粍鐨勫舰寮忎紶澶氶€夊舰寮忕殑model if(!$scope.isArrayModel){ $scope.model = modelValue.concat(); modelValue = modelValue.split($scope.splitType); }else{ $scope.model = modelValue; } var usrName = []; for(var i=0;i 0 ? usrName.join(",") :"" ; // update end by wwupower for 淇敼鏀寔鈥?鈥濈殑鏀寔 @date 2017-11-9 }else { for(var i=0;i
' } return htmlTemp; }, link : function($scope, element, attrs){ switch ($scope.position){ case "bottom": $scope.showPosition = "down"; break; case "top": $scope.showPosition = "up"; break; case "auto": $scope.showPosition = "auto"; break; default: $scope.showPosition = "auto"; break } $scope.hasClass = function (className) { if($(element).find("#valid-code").hasClass("validatebox-invalid")){ if(!$scope.model || !$scope.model.length){ return 'pt-invalid'; } } return '' }; $scope.currentCode = null; if(!attrs || !attrs.type || (attrs && attrs.type && (attrs.type.toUpperCase() == "JSON"))){ if(attrs && attrs.multiple){ $scope.isMultiple = true; } }else { $scope.isMultiple = false; } if($scope.validate == "false"){ $scope.validate = false }else { $scope.validate = true; } if(!$scope.model){ if($scope.isMultiple){ $scope.model = []; }else { $scope.model = ''; } } $scope._codes = []; $scope.key = $scope.key ? $scope.key : "*"; Common.dict.getDictByName($scope,$http,"bd.sys.platform.config.systemConfig.dict."+$scope.key,function (data) { $scope._codes = data; }); $scope.changeSelected = function ($item, $model) { if($scope.isMultiple){ $scope.currentCode = ''; $scope.model = []; for(var i = 0;i<$scope._codes.selected.length;i++){ $scope.model.push($scope._codes.selected[i].value); } }else { $scope.model = $model.value; } }; $scope.$watch("model",function (newValue,oldValue) { if(newValue == oldValue) return; $scope.checkByModel(); if($.isArray($scope.model)){ if($scope.model.length){ $scope.currentCode = $scope.model.join(","); }else { $scope.currentCode = null; } }else { $scope.currentCode = $scope.model } },true); $scope.checkByModel = function () { if($scope.model && $.isArray($scope.model) && $scope.model.length){ $scope._codes.selected = [] for(var i=0;i<$scope.model.length;i++){ for(var j=0;j<$scope._codes.length;j++){ if($scope.model[i] == $scope._codes[j].value){ $scope._codes.selected.push($scope._codes[j]); } } } }else { for(var j=0;j<$scope._codes.length;j++){ if($scope.model == $scope._codes[j].value){ $scope._codes.selected = $scope._codes[j]; } } } } } }; }]); Platform_Directive_APP.directive("ptSelect",["$timeout",'$http',function ($timeout,$http) { return { restrict: 'AE', scope : { model : "=ngModel", modelSelect : "=ngModelSelect", multip : "@multiple", disabled : "=ngDisabled", dataField : "=ngDatafield", dataUrl : "@ngDataUrl", initValue : "@ngInitValue", modelValue: "=ngModelValue", position:"@ngPosition", callback : "&ngCallback", splitType:"@ngSplit" }, template : function (tEle,tAttr) { return '
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
' }, link: function($scope, $element,attr) { //鏄剧ず鏂瑰悜锛氫笂銆佷笅銆侀粯璁ゆ牴鎹睆骞曡嚜鍔 switch ($scope.position){ case "bottom": $scope.showPosition = "down"; break; case "top": $scope.showPosition = "up"; break; case "auto": $scope.showPosition = "auto"; break; default: $scope.showPosition = "auto"; break } //瀛楃涓插垎闅旂锛岄粯璁や互','鍒嗗壊 $scope.splitType = $scope.splitType ? $scope.splitType : ',' //鏄惁鍙 $scope.onlyRead = false; //榛樿鍗曢€ $scope.multiple = false; //initValue鍦ㄦ爣绛句笂瀛樺湪鍒濆鍖栧€兼椂銆佷笖model涓巑odelValue鍧囨棤鍒濆鍖栧€兼椂銆 if ($scope.initValue && !$scope.model && !$scope.modelValue){ $scope.modelValue = $scope.initValue; } switch ($scope.disabled){ case "false" : $scope.onlyRead = false; break; case "true" : $scope.onlyRead = true; break; default : $scope.onlyRead = $scope.disabled; break; } switch ($scope.multip){ case "false" : $scope.multiple = false; break; case "true" : $scope.multiple = true; break; default : $scope.multiple = $scope.multip; break; } $scope.validate = false; $scope.$watch("disabled",function (newValue) { switch ($scope.disabled){ case "false" : $scope.onlyRead = false; break; case "true" : $scope.onlyRead = true; break; default : $scope.onlyRead = $scope.disabled; break; } if($scope.onlyRead){ $scope.validate = false; } }); if (attr && attr.ngValidate == "true"){ $scope.validate = true; } $scope.hasClass = function (className) { if($($element).find("#valid-select").hasClass("validatebox-invalid")){ if(!$scope.currentCode){ return 'pt-invalid'; } } return '' }; $scope._types = []; $scope.currentCode = ""; $scope.changeSelected = function (item, model) { $scope.$apply(function() { $scope.model = $scope._types.selected; }); if ($scope.callback && $.isFunction($scope.callback)){ $scope.callback({ $item : item }); } }; $scope.resetTypes = function (newValue, oldValue) { // 涓嶈兘鍋氱疮鍔狅紝缃┖搴旇鍦ㄥ墠闈 $scope._types = []; if (newValue && $.isArray(newValue) && newValue.length){ for (var i=0;i'; }, link: function($scope, $element, attr) { $scope.loadDataFunction = function () { var Config = {}; /* * config閰嶇疆椤圭殑URL涓巆kazz鍙兘浜岄€変竴 * */ if($scope.url){ Config.url = $scope.url; }else { Config.data = {clazz:$scope.clazz}; } return (Common.autoComplete($scope,$element,Config)); } } }; }]); Platform_Directive_APP.directive("editTableSon",[function () { return { restrict : 'A', scope:true, link :function ($scope,element,attr) { var getNewObject = function (item) { var data = {}; $.each(item,function (k, v) { data[k] = v }) return data; } $scope.addLinePrev = function (index, tableData, item) { var data = getNewObject(item) tableData.splice(index, 0, data); }; $scope.addLine = function (tableData, item) { var data = getNewObject(item) tableData.push(data); }; $scope.deleteLine = function (index, tableData) { tableData.splice(index, 1); }; $scope.copyLineToIndex = function (item, tableData, $event) { var layer = Common.dialog({ type:'prompt', title:'澶嶅埗鍒扮鍑犺', callback:function (index) { var data = getNewObject(item) tableData.splice(index, 0, data); Common.dialog({ type:"close", index:layer }); $scope.$apply(); } }); $event.stopPropagation(); } } } }]); Platform_Directive_APP.directive("industrySelect",[function () { return { restrict: 'EA', scope: true, controller: function($scope){ var ctrl = this; ctrl.currIndustry = ''; ctrl.currBigIndustry = ''; ctrl.currMediumIndustry = ''; ctrl.currSmallIndustry = ''; $scope.$on("change_bigIndustry",function($event,data){ $scope.$broadcast('changeBigIndustryArray',data); }); $scope.$on("change_mediumIndustry",function($event,data){ $scope.$broadcast('changeMediumIndustryArray',data); }); $scope.$on("change_smallIndustry",function($event,data){ $scope.$broadcast('changeSmallIndustryArray',data); }); } }; }]); Platform_Directive_APP.directive("industry",[function () { return { restrict : 'E', require: ['^?industrySelect'], scope : { model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢℉YLXDM浼犺緭 validate : "@ngValidate", disabled : "=ngDisabled", industryType : "@ngType", callback : "=ngSelected", initValue : "@ngInitValue", position : "@ngPosition", getObject : "=ngGetobject" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + ''+ ''+ '
', link : function(scope, element, attrs, ctrl){ switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } scope.hasClass = function () { if($(element).find("#valid-industry").hasClass("validatebox-invalid")){ if(!scope.model){ return "pt-invalid" } } return ""; }; scope._industries = []; scope.$watch("model", function(newValue, oldValue) { if(newValue){ $("#valid").removeClass("validatebox-invalid") } if (newValue === oldValue) { return; } if (ctrl.currIndustry === newValue) { return; } for(var i=0; i< scope._industries.length; i++){ if(newValue == scope._industries[i].value){ scope._industries.selected = scope._industries[i]; ctrl.currIndustry = scope._industries[i].value; scope.getObject = scope._industries[i]; scope._changeIndustry(scope._industries[i], null); } } }); scope._changeIndustry = function (item, model, outside) { if(scope.model == item.value && model){ return false; } scope.model = item.value; scope.getObject = item; $.ajax({ url : Common.webRoot() + '/platfrom/common/component/hylx/hylxcontroller/queryhylxs', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ "HYJB" : "2", "HYDMXZ" : scope.model }), success : function (result){ var bigIndustries = []; for(var i = 0; i < result.length; i++){ var obj = {label : result[i].HYLX, value : result[i].HYLXDM}; bigIndustries.push(obj); } outside = outside ? outside : false; var data = {value : bigIndustries,key : outside}; scope.$emit("change_bigIndustry", data); // 璋冪敤鑷畾涔変笅鎷夊洖璋冩柟娉 if (scope.callback && $.isFunction(scope.callback)) { scope.callback(item); } } }); }; // 璁剧疆琛屼笟鎬ц川 var industryType = (scope.industryType) ? (scope.industryType + '').replace(/\s/g, "").split(",") : null; $.ajax({ url : Common.webRoot() + '/platfrom/common/component/hylx/hylxcontroller/queryhylxs', type : "POST", dataType : 'json', contentType : 'application/json', data : JSON.stringify({ "HYJB" : "1", "DMXZList" : industryType }), success : function (result){ //鍒濆鍖栬涓氱被鍨嬩笅鎷夋 for (var i = 0; i < result.length; i++) { var obj = {label : result[i].HYLX, value : result[i].HYLXDM}; scope._industries.push(obj); } //澶栭儴鍒濆鍖栬祴鍊煎姩浣 if(scope.model){ for(var i = 0; i < scope._industries.length; i++){ if(scope.model == scope._industries[i].value){ scope._industries.selected = scope._industries[i]; ctrl.currIndustry = scope._industries[i].value; scope._changeIndustry(scope._industries[i], null, true); } } } scope.$apply(); } }); } }; }]); Platform_Directive_APP.directive("industryBig",[function () { return { restrict : 'E', require: '^?industrySelect', scope : { model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢℉YLXDM浼犺緭 validate : "@ngValidate", disabled : "=ngDisabled", callback : "=ngSelected", initValue : "@ngInitValue", position:'@ngPosition', getObject : "=ngGetobject" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
', link : function(scope, element, attrs,ctrl){ switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } scope.hasClass = function () { if($(element).find("#valid-big-industry").hasClass("validatebox-invalid")){ if(!scope.model){ return 'pt-invalid'; } } return false; }; scope._bigIndustries = []; /** * 鏇存柊model鐨勫€ */ scope.$watch("model", function(newValue, oldValue) { if (newValue === oldValue) { return; } if (ctrl.currBigIndustry === newValue) { return; } for(var i=0; i< scope._bigIndustries.length;i++){ if(newValue == scope._bigIndustries[i].value){ scope._bigIndustries.selected = scope._bigIndustries[i]; scope.getObject = scope._bigIndustries[i]; ctrl.currBigIndustry = scope._bigIndustries[i].value; scope._changeBigIndustry(scope._bigIndustries[i], null); } } }); /** * 鏇存柊瀛愯涓氱被鍨嬪ぇ绫绘暟缁 */ scope.$on("changeBigIndustryArray",function($event,data){ scope._bigIndustries = data.value; if(!data.value.length){ scope.model = ''; } if(data.key === "select"){ scope.model = ''; scope.$emit("change_mediumIndustry", {value : []}); }else { for(var i=0; i< scope._bigIndustries.length; i++){ if(scope.model == scope._bigIndustries[i].value){ scope._bigIndustries.selected = scope._bigIndustries[i]; ctrl.currBigIndustry = scope._bigIndustries[i].value; scope._changeBigIndustry(scope._bigIndustries[i], null, true); } } } }); scope._changeBigIndustry = function (item, model,outside) { if(model && scope.model == item.value){ return false; } scope.model = item.value; scope.getObject = item; $.ajax({ url : Common.webRoot() + '/platfrom/common/component/hylx/hylxcontroller/queryhylxs', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ "HYJB" : "3", "HYDMXZ" : scope.model }), success : function (result){ var mediumIndustries = []; for (var i = 0; i < result.length; i++) { var obj = {label : result[i].HYLX, value : result[i].HYLXDM}; mediumIndustries.push(obj); } outside = outside ? outside : false; var data = {key : outside, value : mediumIndustries}; scope.$emit("change_mediumIndustry",data); // 璋冪敤鑷畾涔変笅鎷夊洖璋冩柟娉 if (scope.callback && $.isFunction(scope.callback)) { scope.callback(item); } } }); }; } }; }]); Platform_Directive_APP.directive("industryMedium",[function () { return { restrict : 'E', require: '^?industrySelect', scope : { model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢℉YLXDM浼犺緭 validate : "@ngValidate", disabled : "=ngDisabled", callback : "=ngSelected", initValue : "@ngInitValue", position:"@ngPosition", getObject : "=ngGetobject" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
', link : function(scope, element, attrs,ctrl){ switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } scope.hasClass = function (className) { if($(element).find("#valid-medium-industry").hasClass("validatebox-invalid")){ if(!scope.model){ return 'pt-invalid' } } return false }; scope._mediumIndustries = []; /** * 鏇存柊model鐨勫€ */ scope.$watch("model", function(newValue, oldValue) { if(!newValue){ scope.model = ''; scope.$emit("change_smallIndustry", {value : []}); } if (newValue === oldValue) { return; } for(var i=0; i< scope._mediumIndustries.length;i++){ if(newValue == scope._mediumIndustries[i].value){ scope._mediumIndustries.selected = scope._mediumIndustries[i]; scope.getObject = scope._mediumIndustries[i]; ctrl.currMediumIndustry = scope._mediumIndustries[i].value; scope._changeMediumIndustry(scope._mediumIndustries[i],null); } } }); /** * 鏇存柊瀛愯涓氱被鍨嬩腑绫绘暟缁 */ scope.$on("changeMediumIndustryArray", function($event, data){ scope._mediumIndustries = data.value; if(!data.value.length){ scope.model = ''; } if(data.key === "select" ){ scope.model = ''; scope.$emit("change_smallIndustry",{value : []}); }else if(data.key && scope._mediumIndustries.length){ for(var i=0; i< scope._mediumIndustries.length; i++){ if(scope.model == scope._mediumIndustries[i].value){ scope._mediumIndustries.selected = scope._mediumIndustries[i]; ctrl.currMediumIndustry = scope._mediumIndustries[i].value; scope._changeMediumIndustry(scope._mediumIndustries[i], null, true); } } }else { scope.$emit("change_smallIndustry",{value : []}); } }); scope._changeMediumIndustry = function (item, model, outside) { if(scope.model == item.value && model){ return false; } scope.model = item.value; scope.getObject = item; $.ajax({ url : Common.webRoot() + '/platfrom/common/component/hylx/hylxcontroller/queryhylxs', type : "POST", dataType : 'json', async : false, contentType : 'application/json', data : JSON.stringify({ "HYJB" : "4", "HYDMXZ" : scope.model }), success : function (result){ var smallIndustries = []; for(var i = 0; i < result.length; i++){ var obj = {label : result[i].HYLX, value : result[i].HYLXDM}; smallIndustries.push(obj); } outside = outside ? outside : false; var data = {key : outside ,value : smallIndustries}; scope.$emit("change_smallIndustry",data); // 璋冪敤鑷畾涔変笅鎷夊洖璋冩柟娉 if (scope.callback && $.isFunction(scope.callback)) { scope.callback(item); } } }); }; } }; }]); Platform_Directive_APP.directive("industrySmall",[function () { return { restrict : 'E', require: '^?industrySelect', scope : { model : "=ngModel", //model 鐨勭粦瀹氬叏閮ㄤ娇鐢℉YLXDM浼犺緭 validate : "=ngValidate", disabled : "=ngDisabled", callback : "=ngSelected", initValue : "@ngInitValue", position : "@ngPosition", getObject : "=ngGetobject" }, template : '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
', link : function(scope, element, attrs,ctrl){ switch (scope.position){ case "bottom": scope.showPosition = "down"; break; case "top": scope.showPosition = "up"; break; case "auto": scope.showPosition = "auto"; break; default: scope.showPosition = "auto"; break } if(scope.initValue && !scope.model){ scope.model = scope.initValue; } scope.hasClass = function (className) { if($(element).find("#valid-small-industry").hasClass("validatebox-invalid")){ if(!scope.model){ return 'pt-invalid'; } } return false }; scope._smallIndustries = []; /** *鏇存柊model閫変腑鐨勫€ */ scope.$watch("model", function(newValue, oldValue) { for(var i=0; i< scope._smallIndustries.length;i++){ if(newValue == scope._smallIndustries[i].value){ scope._smallIndustries.selected = scope._smallIndustries[i]; scope.getObject = scope._smallIndustries[i]; ctrl.currSmallIndustry = scope._smallIndustries[i].value; scope._changeSmallIndustry(scope._smallIndustries[i],null); } } }); /** * 鏇存柊瀛愯涓氱被鍨嬪皬绫绘暟缁 */ scope.$on("changeSmallIndustryArray",function($event,data){ scope._smallIndustries = data.value; if(!data.value.length){ scope.model = ''; } if(data.key === "select"){ scope.model = ''; }else { for(var i=0; i< scope._smallIndustries.length;i++){ if(scope.model == scope._smallIndustries[i].value){ scope._smallIndustries.selected = scope._smallIndustries[i]; ctrl.currSmallIndustry = scope._smallIndustries[i].value; scope._changeSmallIndustry(scope._smallIndustries[i],null,true); } } } }); scope._changeSmallIndustry = function (item, model,outside) { if(scope.model == item.value && model){ return false; } scope.model = item.value; scope.getObject = item; // 璋冪敤鑷畾涔変笅鎷夊洖璋冩柟娉 if (scope.callback && $.isFunction(scope.callback)) { scope.callback(item); } }; } }; }]); Platform_Directive_APP.directive('infiniteScroll', [ '$rootScope', '$window', '$timeout', function($rootScope, $window, $timeout) { return { link: function(scope, elem, attrs) { var checkWhenEnabled, handler, scrollDistance, scrollEnabled; $window = angular.element($window); scrollDistance = 0; if (attrs.infiniteScrollDistance != null) { scope.$watch(attrs.infiniteScrollDistance, function(value) { return scrollDistance = parseInt(value, 10); }); } scrollEnabled = true; checkWhenEnabled = false; if (attrs.infiniteScrollDisabled != null) { scope.$watch(attrs.infiniteScrollDisabled, function(value) { scrollEnabled = !value; if (scrollEnabled && checkWhenEnabled) { checkWhenEnabled = false; return handler(); } }); } handler = function() { var elementBottom, remaining, shouldScroll, windowBottom; windowBottom = $(window).height() + $(window).scrollTop(); elementBottom = $(elem).offset().top + $(elem).height(); remaining = elementBottom - windowBottom; shouldScroll = remaining <= $(window).height() * scrollDistance; if (shouldScroll && scrollEnabled) { if ($rootScope.$$phase) { return scope.$eval(attrs.infiniteScroll); } else { return scope.$apply(attrs.infiniteScroll); } } else if (shouldScroll) { return checkWhenEnabled = true; } }; $(elem).on('scroll', handler); scope.$on('$destroy', function() { return $(window).off('scroll', handler); }); return $timeout((function() { if (attrs.infiniteScrollImmediateCheck) { if (scope.$eval(attrs.infiniteScrollImmediateCheck)) { return handler(); } } else { return handler(); } }), 0); } }; } ]);