jquery_common_content.js 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427
  1. //绑定查询框,bindTable需要绑定的table,copy的对象,需要查询的表
  2. function bindQueryInput(copyFromTr,queryTable,trOnly){
  3. var trStr = "<tr>";
  4. var totalTr = "<tr id='detailTotal'>";
  5. $(copyFromTr).find("label,input,select").each(
  6. function (){
  7. var widthStr = $(this).attr("width");
  8. if($(this).attr("type") && $(this).attr("type") == 'checkbox'){
  9. trStr=trStr+"<td width='"+widthStr+"'>&nbsp;</td>";
  10. totalTr = totalTr + "<td>合计</td>";
  11. }else{
  12. if($(this).attr("unUseOrder")!="Y"){
  13. var tdStr = "<td width='"+widthStr+"'><input style='width: 100%' type='text' name='"+$(this).attr("name")+"' id='"+$(this).attr("name")+"' onkeydown='javascript:doBindQueryInput(this)'/></td>"
  14. var totalTd = "<td><label name='"+$(this).attr("name")+"'></label></td>";
  15. trStr=trStr+tdStr;
  16. totalTr = totalTr+totalTd;
  17. }
  18. }
  19. }
  20. );
  21. trStr=trStr+"</tr>";
  22. totalTr=totalTr+"</tr>";
  23. $("#"+queryTable).find("tr:first").before(trStr);
  24. // $("#"+queryTable).find("tr:last").append(totalTr);
  25. }
  26. function bindQueryInput_(copyFromTr,queryTable,trOnly){
  27. var trStr = "<tr>";
  28. var totalTr = "<tr id='detailTotal'>";
  29. $(copyFromTr).find("label,input").each(
  30. function (){
  31. var widthStr = $(this).attr("width");
  32. if($(this).attr("type") && $(this).attr("type") == 'checkbox'){
  33. trStr=trStr+"<td width='"+widthStr+"'>&nbsp;</td>";
  34. totalTr = totalTr + "<td>合计</td>";
  35. }else{
  36. if($(this).attr("unUseOrder")!="Y"){
  37. var tdStr = "<td width='"+widthStr+"'><input style='width: 100%' queryTable='"+queryTable+"' trOnly='"+trOnly+"' type='text' name='tablesearch_"+$(this).attr("name")+"' id='tablesearch_"+$(this).attr("name")+"' onkeydown='javascript:doBindQueryInput_(this)'/></td>"
  38. var totalTd = "<td><label name='"+$(this).attr("name")+"'></label></td>";
  39. trStr=trStr+tdStr;
  40. totalTr = totalTr+totalTd;
  41. }
  42. }
  43. }
  44. );
  45. trStr=trStr+"</tr>";
  46. totalTr=totalTr+"</tr>";
  47. $("#"+queryTable).find("tr:first").before(trStr);
  48. }
  49. function doBindQueryInput_(obj,evt){
  50. var queryTable = $(obj).attr("queryTable");
  51. var trOnly = $(obj).attr("trOnly");
  52. evt = (evt) ? evt : ((window.event) ? window.event : "");
  53. var keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode);
  54. if(keyCode==13){
  55. $("#"+queryTable).find("tr").each(
  56. function (){
  57. if($(this).attr(trOnly)){
  58. $(this).css("display","");
  59. }
  60. }
  61. );
  62. $(obj).parent().parent().find("input").each(
  63. function (){
  64. if($(this).val()){
  65. var inputValue = $(this).val();
  66. var attrName = ($(this).attr("name")).replace("tablesearch_","");
  67. $("#"+queryTable).find("tr").each(
  68. function (){
  69. if($(this).css("display") != "none"){
  70. if($(this).attr(trOnly)){
  71. $(this).find("label[name="+attrName+"]").each(
  72. function (){
  73. if($(this).text().indexOf(inputValue) >= 0){
  74. $(this).parent().parent().css("display","");
  75. }else{
  76. $(this).parent().parent().css("display","none");
  77. }
  78. }
  79. );
  80. }
  81. }
  82. }
  83. );
  84. }
  85. }
  86. );
  87. }
  88. }
  89. // 公共信息变更函数
  90. function contentChange(contentChangeList, _this) {
  91. try {
  92. if (!$.isArray(contentChangeList) || !_this) {
  93. return;
  94. }
  95. // no change的标志
  96. if ($(_this).attr("noChange") == "true" || $(_this).attr("noChange") == true) {
  97. return;
  98. }
  99. if ( $(_this).attr("name") != undefined
  100. && $(_this).attr("name") != ""
  101. && $.inArray($(_this).attr("name"),contentChangeList) == -1 ) {
  102. contentChangeList.push($(_this).attr("name"));
  103. }else if( $(_this).attr("comboname") != undefined
  104. && $(_this).attr("comboname") != ""
  105. && $.inArray($(_this).attr("comboname"),contentChangeList) == -1 ){
  106. contentChangeList.push($(_this).attr("comboname"));
  107. } else if( $(_this).attr("numberboxname") != undefined
  108. && $(_this).attr("numberboxname") != ""
  109. && $.inArray($(_this).attr("numberboxname"),contentChangeList) == -1 ){
  110. contentChangeList.push($(_this).attr("numberboxname"));
  111. }
  112. else if ($(_this).attr("nativeChangeField") != undefined && $(_this).attr("nativeChangeField") != "" && $.inArray($(_this).attr("nativeChangeField"),contentChangeList) == -1) {
  113. contentChangeList.push($(_this).attr("nativeChangeField"));
  114. }
  115. } catch (e) {
  116. // do nothing
  117. }
  118. }
  119. function isObject(v) {
  120. return typeof v == 'object' && v.constructor == Object ? true : false;
  121. };
  122. function isJQuery(v) {
  123. return typeof v.jquery != 'undefined';
  124. }
  125. // bind jQueryDatepicker to <input/>
  126. function initDatePicker(selector) {
  127. if (!isJQuery(selector || {})) {
  128. return;
  129. }
  130. $.loadJQueryDatepickerWidegt();
  131. selector.each(function() {
  132. // alert(this.outerHTML);
  133. _this = $(this);
  134. $(this).datepicker({
  135. showDateFormater : true,
  136. changeMonth : true, // 设置可选 mouth
  137. changeYear : true, // 设置可选 year
  138. showButtonPanel : true, // 显示 下方 今天、关闭 button
  139. // numberOfMonths: 3, // 同时显示3列datepicker
  140. showOn : '', // 取消 自动 show
  141. duration : 0
  142. // 取消动态效果
  143. });
  144. $(this).next(".time_img").click(function() {
  145. try {
  146. // alert($(this).prev(".hasDatepicker").get(0).outerHTML);
  147. $(this).prev(".hasDatepicker").datepicker('show');
  148. } catch (e) {
  149. // it is not a datepicker
  150. }
  151. });
  152. })
  153. }
  154. (function($) {
  155. $.fn.getFormValue = function() {
  156. var o = {};
  157. $(this).find('input,select,textarea').each(function() {
  158. if ($(this).attr("name") != "") {
  159. if ($(this).val() || $(this).val() == 0) {
  160. if ($(this).val() == "") {
  161. if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
  162. o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
  163. }else {
  164. o[$(this).attr("name")] = null;
  165. }
  166. } else {
  167. if ($(this).attr("editType") == "suggestBox") {
  168. o[$(this).attr("name")] = $(this).attr("hiddenValue");
  169. o[$(this).attr("name") + "_name"] = $(this).val();
  170. } else if ($(this).attr("editType") == "simpleCheckbox") {
  171. if ($(this).attr("checked")) {
  172. o[$(this).attr("name")] = 1;
  173. } else {
  174. o[$(this).attr("name")] = 0;
  175. }
  176. } else if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
  177. o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
  178. }else {
  179. if( $(this).attr("class")=="easyui-numberbox numberbox-f validatebox-text" ) {//数值型
  180. var field = $(this).attr("numberboxname");
  181. var value = $(this).next().val();
  182. o[field] = value;
  183. }else if( $(this).attr("class")=="easyui-datebox datebox-f combo-f" ) {//日期型
  184. var field = $(this).attr("comboname");
  185. var value = $(this).next()[0].children[2].value;
  186. o[field] = value;
  187. }else if( $(this).hasClass("easyui-combobox")){//下拉框
  188. var field = $(this).attr("comboname");
  189. var value = $(".combo-value[name="+field+"]").val();
  190. o[field] = value;
  191. }else if( $(this).attr("type")=="checkbox" ){//复选框
  192. var field = $(this).attr("name");
  193. var value = $(this).val();
  194. if( this.checked ) {
  195. o[field] = ( value=="on" ? 1:value );
  196. }else{
  197. o[field] = 0;
  198. }
  199. }else if( $(this).attr("type")=="radio" ){//单选框
  200. var field = $(this).attr("name");
  201. var value = $(this).val();
  202. if( this.checked ) {
  203. o[field] = ( value=="on" ? 1:value );
  204. }else{
  205. o[field] = 0;
  206. }
  207. }
  208. else{
  209. //解决IE8下 时间控件的值为"NULL"的问题
  210. if ("null" == $(this).val())
  211. {
  212. o[$(this).attr("name")] = null;
  213. }
  214. else
  215. {
  216. o[$(this).attr("name")] = $(this).attr("hiddenValue") || $.trim($(this).val());
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. });
  224. return o;
  225. };
  226. $.fn.fillForm = function( data ) {
  227. $(this).form("load", data);
  228. $(this).find('input').each(function() {
  229. if ($(this).attr("name") != "") {
  230. var name = $(this).attr("name") ;
  231. if( $(this).attr("type")=="checkbox" || $(this).attr("type")=="radio" ){//复选框
  232. var value = $(this).val();
  233. if( ( value == data[name] || data[name] ==1) && data[name] !=0 ){
  234. this.checked = true;
  235. }
  236. }
  237. }
  238. });
  239. $(this).find("input[myType='easyui-combobox']").each(function(i){
  240. var a = this;
  241. var comboname = $(a).attr("comboname");
  242. if (comboname != "")
  243. {
  244. var lastSub = comboname.substring(comboname.length-2,comboname.length);
  245. var textName = "";
  246. if ("Id" == lastSub)
  247. {
  248. textName = comboname.replace("Id","Name");
  249. }
  250. else
  251. {
  252. textName = comboname + "Name";
  253. }
  254. if (!data[textName])
  255. {
  256. data[textName]=data[comboname];
  257. }
  258. $(a).combobox('setValue',data[comboname]);
  259. if ($(a).combobox('getText') == $(a).combobox('getValue'))
  260. {
  261. $(a).combobox('setText',data[textName]);
  262. }
  263. }
  264. });
  265. $(this).find("input[myType='easyui-combogrid']").each(function(i){
  266. var a = this;
  267. var comboname = $(a).attr("comboname");
  268. if (comboname != "")
  269. {
  270. var lastSub = comboname.substring(comboname.length-2,comboname.length);
  271. var textName = "";
  272. if ("Id" == lastSub)
  273. {
  274. textName = comboname.replace("Id","Name");
  275. }
  276. else
  277. {
  278. textName = comboname + "Name";
  279. }
  280. if (!data[textName])
  281. {
  282. data[textName]=data[comboname];
  283. }
  284. var opts = $(a).combogrid('options');
  285. var ele = {};
  286. ele[opts.idField] = data[comboname];
  287. ele[opts.textField] = data[textName];
  288. // $(a).combogrid('grid').datagrid({data:[ele]});
  289. $(a).combogrid('setValue',data[comboname]);
  290. if (!$(a).combogrid('getText'))
  291. {
  292. $(a).combogrid('setText',data[textName]);
  293. }
  294. //$(".combo-value[name="+comboname+"]").val(data[comboname]);
  295. }
  296. });
  297. };
  298. $.fn.disabledContentFeild = function(fields) {
  299. $(this).find('input,select,textarea').each(
  300. function() {
  301. var isDisabled = true;
  302. if (fields == "all") {
  303. $(this).attr("disabled", true);
  304. } else if (fields[0] == "all") {
  305. $(this).attr("disabled", true);
  306. } else if (fields.contains($(this).attr("name")) || fields.contains($(this).attr("nativeChangeField"))) {
  307. $(this).attr("disabled", true);
  308. } else {
  309. isDisabled = false;
  310. }
  311. if (isDisabled && $(this).hasClass("hasDatepicker")) {
  312. $(this).next(".time_img").unbind("click");
  313. }
  314. if (isDisabled && $(this).attr("editType") == "comment") {
  315. //$(this).next(".commentClass").css("display", 'none');
  316. $(this).next(".commentClass").attr("disabled", true);
  317. }
  318. if (isDisabled && $(this).attr("editType") == "suggestBox" && $(this).attr("hasShowTrigger") == true) {
  319. //$(this).next(".suggestbox-trigger-img").css("display", 'none');
  320. $(this).next(".suggestbox-trigger-img").attr("disabled", true);
  321. }
  322. });
  323. }
  324. })(jQuery);
  325. /**
  326. * 绑定DOM对象的事件
  327. * @param {} _scope 绑定范围
  328. */
  329. function bindEditTypeEvent(_scope) {
  330. if (!_scope) {
  331. _scope = $("body");
  332. }
  333. $(_scope).find('input,textarea,select').each(function() {
  334. if ($(this).attr("notBlank") && ($(this).parent(0).prev().text()).indexOf("*") == -1) {
  335. $(this).parent(0).prev().html("<font color='red'>*</font>"+$(this).parent(0).prev().text());
  336. }
  337. if(typeof($(this).attr("editType")) != 'undefined') {
  338. if ($(this).attr("editType") == "int") {
  339. $(this).bindIntKeyDown();
  340. }
  341. else if ($(this).attr("editType") == "float") {
  342. $(this).bindDecimalKeyDown();
  343. }
  344. else if ($(this).attr("editType") == "combo") {
  345. if (typeof(dictionary) != 'undefined' && dictionary) {
  346. if (dictionary[$(this).attr("name")]) {
  347. if (!$(this).attr("notBlank") || $(this).attr("emptyOption")) {
  348. var op = new Option('', '');
  349. $(this).get(0).options.add(op);
  350. $(this).val('');
  351. }
  352. var dictionaryList = dictionary[$(this).attr("name")];
  353. for (var i = 0; i < dictionaryList.length; i++) {
  354. var op = new Option(dictionaryList[i]['dictionaryName'],dictionaryList[i]['dictionaryId']);
  355. $(this).get(0).options.add(op);
  356. }
  357. // 扩展defaultValue属性
  358. if($(this).attr("defaultValue")) {
  359. $(this).val($(this).attr("defaultValue"));
  360. }
  361. }
  362. }
  363. }
  364. else if ($(this).attr("editType") == "date" || $(this).attr("editType") == "dateTime") {
  365. $(this).nextAll('.hh').attr("maxLength",2);
  366. $(this).nextAll('.mm').attr("maxLength",2);
  367. }
  368. else if ($(this).attr("editType") == "comment") {
  369. if ($(this).nextAll(".commentClass").length == 0) {
  370. $(this).after("<button class='commentClass'>添加备注</button>");
  371. var _field = $(this).attr("id");
  372. $(this).nextAll(".commentClass").click(function() { addCommentDetail(_field);});
  373. $(this).attr("readonly",true);
  374. }
  375. }
  376. else if ($(this).attr("editType").toLowerCase() == "signedint") {
  377. $(this).bindSignedIntKeyDown();
  378. }
  379. else if ($(this).attr("editType").toLowerCase() == "signedfloat") {
  380. $(this).bindSignedDecimalKeyDown();
  381. }
  382. }
  383. if($(this).attr("maxLength") == 'undefined' && $(this).attr("tagName").toUpperCase() == "TEXTAREA") {
  384. $(this).attr("maxLength",65534);
  385. }
  386. });
  387. }
  388. // 校验和取得日期控件的值
  389. function generatDateTimeFromInput(object, fileds, tag) {
  390. var isOk = true;
  391. for (var i = 0; i < fileds.length; i++) {
  392. var fieldName = fileds[i];
  393. if (object[fieldName] != "" && object[fieldName] != undefined && object[fieldName] != null) {
  394. var dateFormat = /^(\d{4})\-(\d{2})\-(\d{2}) ([01]{0,1}[0-9]|2[0-3]):([0-5]{0,1}[0-9]):(\d{2})$/;
  395. var _this = $(tag).find("input[name='" + fieldName + "']");
  396. $(_this).each(function() {
  397. var hh = $(this).nextAll('.hh').val();
  398. var mm = $(this).nextAll('.mm').val();
  399. var ss = "00";
  400. if (hh == null || hh == "") {
  401. hh = "00";
  402. }
  403. if (mm == null || mm == "") {
  404. mm = "00";
  405. }
  406. object[fieldName] = object[fieldName] + " " + hh + ":" + mm + ":" + ss;
  407. if (!dateFormat.test(object[fieldName])) {
  408. commonErrorPrompt($(this).attr("promptName")==undefined?"必填项":$(this).attr("promptName") + "日期格式不正确");
  409. _this.focus();
  410. isOk = false;
  411. }
  412. });
  413. }
  414. }
  415. return isOk;
  416. }
  417. /**
  418. * 验证表单数据
  419. * @param {} _scope 查找域
  420. * @return {}
  421. */
  422. function validateValue(_scope) {
  423. var result = true;
  424. $(_scope).each(function() {
  425. if (result) {
  426. var _thisObject=$(this);
  427. if($(this).attr("editType")){
  428. var t_editType = $(this).attr("editType").toLowerCase();
  429. if(t_editType=='int'||t_editType=='float'||t_editType=='signedint'||t_editType=='signedfloat'){
  430. if($(this).val()){
  431. if(isNaN($(this).val())){
  432. result = false;
  433. _thisObject.focus();
  434. commonErrorPrompt($(this).attr("promptName") + "数值类型不正确");
  435. return;
  436. }
  437. if (typeof($(this).attr("maxValue")) == 'undefined') {
  438. $(this).attr("maxValue","999999999");
  439. }
  440. if (typeof($(this).attr("minValue")) == 'undefined') {
  441. $(this).attr("minValue","-999999999");
  442. }
  443. }
  444. }
  445. if(t_editType=='simplecheckbox'){
  446. if ($(this).attr("notBlank") && !$(this).attr("checked")) {
  447. result = false;
  448. commonErrorPrompt(($(this).attr("promptName")==undefined?"必填项":$(this).attr("promptName")) + "不能为空");
  449. return _thisObject.focus();
  450. }
  451. }
  452. }
  453. if ($(this).attr("notBlank")) {
  454. if (typeof($(this).val()) == 'undefined' || $(this).val() == null || $(this).val().trim() == "") {
  455. result = false;
  456. commonErrorPrompt(($(this).attr("promptName")==undefined?"必填项":$(this).attr("promptName")) + "不能为空");
  457. return _thisObject.focus();
  458. }
  459. }
  460. if ($(this).val() != null && $(this).val() != "null" ) {
  461. if ($(this).attr("minValue")) {
  462. if ($(this).val() != "") {
  463. if (!isNaN($(this).attr("minValue")
  464. && !isNaN($(this).val()))) {
  465. if (parseFloat($(this).attr("minValue")) > parseFloat($(this).val())) {
  466. //alert($(this).val());
  467. result = false;
  468. _thisObject.focus();
  469. commonErrorPrompt($(this).attr("promptName") + "不能小于" + $(this).attr("minValue"));
  470. return;
  471. }
  472. }
  473. }
  474. }
  475. if ($(this).attr("maxValue")) {
  476. if ($(this).val() != "") {
  477. if (!isNaN($(this).attr("maxValue")
  478. && !isNaN($(this).val()))) {
  479. if (parseFloat($(this).attr("maxValue")) < parseFloat($(this).val())) {
  480. result = false;
  481. _thisObject.focus();
  482. commonErrorPrompt($(this).attr("promptName") + "不能大于" + $(this).attr("maxValue"));
  483. return;
  484. }
  485. }
  486. }
  487. }
  488. if ($(this).attr("maxLength")&&$(this).attr("maxLength")<65535) {
  489. if ($(this).val() != "") {
  490. if ($(this).val().length > $(this).attr("maxLength")) {
  491. result = false;
  492. _thisObject.focus();
  493. commonErrorPrompt($(this).attr("promptName") + "长度不能大于"+ $(this).attr("maxLength"));
  494. return;
  495. }
  496. }
  497. }else{
  498. if ($(this).val() != "") {
  499. if ($(this).val().length > 30 && $(this).attr("editType")!="suggestBox") {
  500. result = false;
  501. _thisObject.focus();
  502. commonErrorPrompt($(this).attr("promptName") + "长度不能大于"+ 30);
  503. return;
  504. }
  505. }
  506. }
  507. if ($(this).attr("regularExpression")) {
  508. if ($(this).val() != "") {
  509. var target = $(this).val();
  510. if (!$.jquery_Utils_FormVTypes[$(this).attr("regularExpression")](target,this)) {
  511. result = false;
  512. commonErrorPrompt($.i18n('adageCommonAllJS',$(this).attr("regularExpression")+ "Text"));
  513. return _thisObject.focus();
  514. };
  515. }
  516. }
  517. }
  518. }
  519. });
  520. return result;
  521. }
  522. /**
  523. * 勾选表格
  524. * @param {} _this
  525. * @param {} objStr
  526. */
  527. function checkAllForTable(_this, objStr) {
  528. var isChecked = false;
  529. if (_this.checked) {
  530. isChecked = true;
  531. }
  532. var checkboxs = document.getElementsByName(objStr);
  533. for (var i = 0; i < checkboxs.length; i++) {
  534. checkboxs[i].checked = isChecked;
  535. }
  536. }
  537. /**
  538. * 获取表单内的数值
  539. * @param {} _this
  540. * @return {}
  541. */
  542. function getFormValue(_this) {
  543. var o = {};
  544. $(_this).each(function() {
  545. if ($(this).attr("name") != "") {
  546. if ($(this).val() || $(this).val() == 0) {
  547. if ($(this).val() == "") {
  548. if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
  549. o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
  550. }else {
  551. o[$(this).attr("name")] = null;
  552. }
  553. } else {
  554. if ($(this).attr("editType") == "suggestBox") {
  555. o[$(this).attr("name")] = $(this).attr("hiddenValue");
  556. o[$(this).attr("name") + "_name"] = $(this).val();
  557. } else if ($(this).attr("editType") == "simpleCheckbox") {
  558. if ($(this).attr("checked")) {
  559. o[$(this).attr("name")] = 1;
  560. } else {
  561. o[$(this).attr("name")] = 0;
  562. }
  563. } else if(typeof($(this).attr("editType")) != 'undefined' && $(this).attr("editType").toUpperCase() == "CKEDITOR") {
  564. o[$(this).attr("name")] = CKEDITOR.instances[$(this).attr("name")].getData();
  565. }else {
  566. o[$(this).attr("name")] = $(this).attr("hiddenValue") || $(this).val().trim();
  567. }
  568. }
  569. }
  570. }
  571. });
  572. return o;
  573. }
  574. // 获得日期类型的控件
  575. function getDateTimeFields(_this) {
  576. var returnArray = [];
  577. var inputArray = $(_this).find("input[editType=dateTime],input[editType=date]");
  578. $(inputArray).each(function() {
  579. if ($(this).attr("name")) {
  580. returnArray.push($(this).attr("name"));
  581. }
  582. });
  583. return returnArray;
  584. }
  585. // 处理时间填充
  586. function fillFieldWithDateTime(_this, dateValue) {
  587. var dateArray = dateValue.split(" ");
  588. $(_this).val(dateArray[0]);
  589. var hhMMArray = dateArray[1].split(":");
  590. $(_this).nextAll('.hh').val(hhMMArray[0]);
  591. $(_this).nextAll('.mm').val(hhMMArray[1]);
  592. }
  593. // 处理时间填充
  594. function fillFieldWithDate(_this, dateValue) {
  595. var dateArray = dateValue.split(" ");
  596. $(_this).val(dateArray[0]);
  597. }
  598. // 根据组件类型来进行赋值
  599. function fillingData(_this, information) {
  600. $(_this).find('input,select,textarea').each(function() {
  601. if (information[$(this).attr("name")]
  602. || information[$(this).attr("name")] == 0) {
  603. if ($(this).attr("editType") == "suggestBox") {
  604. $(this).attr("hiddenValue", information[$(this).attr("name")]);
  605. $(this).val(information[$(this).attr("name") + "_name"]);
  606. } else if ($(this).attr("editType") == "dateTime") {
  607. fillFieldWithDateTime(this, information[$(this).attr("name")]);
  608. } else if ($(this).attr("editType") == "date") {
  609. fillFieldWithDate(this, information[$(this).attr("name")]);
  610. } else if ($(this).attr("editType") == "simpleCheckbox") {
  611. if (information[$(this).attr("name")] == 1 || information[$(this).attr("name")] == "1") {
  612. $(this).attr("checked", true);
  613. } else {
  614. $(this).attr("checked", false);
  615. }
  616. }
  617. else if ($(this).attr("editType") == "my97Date")
  618. {
  619. if($(this).attr("dateFmt") == "yyyy-MM-dd HH:mm:ss")
  620. {
  621. var strTime = information[$(this).attr("name")];
  622. var datTime = new Date(Date.parse(strTime.replace(/-/g, "/")));
  623. var mon = datTime.getMonth().toString().length ==1 ? "0"+(datTime.getMonth()+1).toString():(datTime.getMonth()+1).toString();
  624. var d = datTime.getDate().toString().length ==1 ? "0"+datTime.getDate().toString():datTime.getDate().toString();
  625. var h = datTime.getHours().toString().length ==1 ? "0"+datTime.getHours().toString():datTime.getHours().toString();
  626. var m = datTime.getMinutes().toString().length ==1 ? "0"+datTime.getMinutes().toString():datTime.getMinutes().toString();
  627. var s = datTime.getSeconds().toString().length ==1 ? "0"+datTime.getSeconds().toString():datTime.getSeconds().toString();
  628. $(this).val(datTime.getFullYear()+"-"+mon+"-"+d+" "+h+":"+m+":"+s);
  629. }
  630. else if($(this).attr("dateFmt") == "yyyy-MM-dd HH:mm")
  631. {
  632. var strTime = information[$(this).attr("name")];
  633. var datTime = new Date(Date.parse(strTime.replace(/-/g, "/")));
  634. var mon = datTime.getMonth().toString().length ==1 ? "0"+(datTime.getMonth()+1).toString():(datTime.getMonth()+1).toString();
  635. var d = datTime.getDate().toString().length ==1 ? "0"+datTime.getDate().toString():datTime.getDate().toString();
  636. var h = datTime.getHours().toString().length ==1 ? "0"+datTime.getHours().toString():datTime.getHours().toString();
  637. var m = datTime.getMinutes().toString().length ==1 ? "0"+datTime.getMinutes().toString():datTime.getMinutes().toString();
  638. var s = datTime.getSeconds().toString().length ==1 ? "0"+datTime.getSeconds().toString():datTime.getSeconds().toString();
  639. $(this).val(datTime.getFullYear()+"-"+mon+"-"+d+" "+h+":"+m);
  640. }
  641. else if($(this).attr("dateFmt") == "yyyy-MM-dd")
  642. {
  643. var strTime = information[$(this).attr("name")];
  644. var datTime = new Date(Date.parse(strTime.replace(/-/g, "/")));
  645. var mon = datTime.getMonth().toString().length ==1 ? "0"+(datTime.getMonth()+1).toString():(datTime.getMonth()+1).toString();
  646. var d = datTime.getDate().toString().length ==1 ? "0"+datTime.getDate().toString():datTime.getDate().toString();
  647. $(this).val(datTime.getFullYear()+"-"+mon+"-"+d);
  648. }
  649. }
  650. else {
  651. $(this).val(information[$(this).attr("name")]);
  652. }
  653. }
  654. });
  655. }
  656. // 不可编辑操作
  657. function disabledFeild(_scope, fields) {
  658. $(_scope).each(function() {
  659. if (fields == "all") {
  660. $(this).attr("disabled", true);
  661. } else if (fields[0] == "all") {
  662. $(this).attr("disabled", true);
  663. } else if (fields.contains($(this).attr("name"))
  664. || fields.contains($(this).attr("nativeChangeField"))) {
  665. $(this).attr("disabled", true);
  666. }
  667. })
  668. }
  669. /**
  670. * <p>
  671. * Description:[设置页面不可编辑属性]
  672. * </p>
  673. * @param {} _scope
  674. * @param {} fields
  675. */
  676. function disabledAttributes(_scope, fields) {
  677. if(fields.hasOwnProperty("unEditableFields")) {
  678. _scope.find('input,select,textarea').each(function() {
  679. var isDisabled = true;
  680. if (fields["unEditableFields"] == "all") {
  681. isDisabled = true;
  682. //$(this).attr("disabled", true);
  683. } else if (fields["unEditableFields"][0] == "all") {
  684. isDisabled = true;
  685. //$(this).attr("disabled", true);
  686. } else if (fields["unEditableFields"].contains($(this).attr("name"))) {
  687. isDisabled = true;
  688. } else if (fields["unEditableFields"].contains($(this).attr("numberboxname"))
  689. || fields["unEditableFields"].contains($(this).attr("comboname"))) {
  690. isDisabled = true;
  691. }else {
  692. isDisabled = false;
  693. }
  694. if(isDisabled) {
  695. var bgFlg = true;
  696. if($(this).hasClass("combo-value")) {
  697. var $ele = $(this).parent().prev();
  698. if ($ele.attr("myType") == 'easyui-combobox' || $ele.hasClass("easyui-combobox"))
  699. {
  700. $ele.combobox('disable');
  701. }
  702. else if ($ele.attr("myType") == 'easyui-combogrid' || $ele.hasClass("easyui-combogrid"))
  703. {
  704. $ele.combogrid('disable');
  705. $ele.attr("disabled", "disabled");
  706. }
  707. else
  708. {
  709. $ele.attr("disabled", "disabled");
  710. }
  711. }
  712. else if($(this).hasClass("easyui-numberbox")) {
  713. $(this).numberbox('disable');
  714. }
  715. else if($(this).hasClass("easyui-datebox")) {
  716. $(this).datebox('disable');
  717. }
  718. else if($(this).attr("myType") == 'easyui-combogrid') {
  719. $(this).combogrid('disable');
  720. $(this).attr("disabled", "disabled");
  721. }
  722. else if($(this).attr("type") == 'hidden')
  723. {
  724. // $(this).removeAttr("disabled");
  725. }
  726. else
  727. {
  728. $(this).attr("disabled", "disabled");
  729. }
  730. }
  731. });
  732. }
  733. if(fields.hasOwnProperty("unEditableButtons")) {
  734. _scope.find('a').each(function() {
  735. if ($(this).hasClass("easyui-linkbutton"))
  736. {
  737. if (fields["unEditableButtons"] == "all") {
  738. $(this).hide();
  739. } else if (fields["unEditableButtons"][0] == "all") {
  740. $(this).hide();
  741. } else if (fields["unEditableButtons"].contains($(this).attr("id"))) {
  742. $(this).hide();
  743. }
  744. }
  745. });
  746. }
  747. }
  748. /**
  749. * <p>
  750. * Description:[设置页面可编辑属性]
  751. * </p>
  752. * @param {} _scope
  753. * @param {} fields
  754. */
  755. function unDisabledAttributes(_scope, fields) {
  756. if(fields.hasOwnProperty("editableFields")) {
  757. _scope.find('input,select,textarea').each(function() {
  758. var isDisabled = true;
  759. if (fields["editableFields"] == "all") {
  760. $(this).attr("disabled", false);
  761. } else if (fields["editableFields"][0] == "all") {
  762. $(this).attr("disabled", false);
  763. } else if (fields["editableFields"].contains($(this).attr("name"))
  764. || fields["editableFields"].contains($(this).attr("nativeChangeField"))) {
  765. $(this).attr("disabled", false);
  766. } else {
  767. isDisabled = false;
  768. }
  769. if(isDisabled) {
  770. var bgFlg = true;
  771. if($(this).attr("tagName").toUpperCase() == 'TEXTAREA') {
  772. $(this).attr('readonly',false);
  773. $(this).next(".commentClass").attr("disabled", false);
  774. isDisabled = false;
  775. }
  776. else if ($(this).attr("editType") == "suggestBox") {
  777. //$(this).next(".suggestbox-trigger-img").css("display", 'none');
  778. $(this).next(".suggestbox-trigger-img").attr("disabled", false);
  779. }
  780. else if(isDisabled && $(this).attr("editType") == "container") {
  781. $(this).next().attr("disabled", false);
  782. }
  783. else if (isDisabled && $(this).hasClass("hasDatepicker")) {
  784. $(this).next(".time_img").unbind("click");
  785. $(this).next(".time_img").attr("disabled",false);
  786. }
  787. else if($(this).attr("editType") == "simpleCheckbox") {
  788. bgFlg = false;
  789. }
  790. if(isDisabled) {
  791. $(this).attr("disabled", false);
  792. }
  793. if(bgFlg) {
  794. $(this).css('background','');
  795. }
  796. }
  797. });
  798. }
  799. if(fields.hasOwnProperty("editableButtons")) {
  800. _scope.find('button').each(function() {
  801. if (fields["editableButtons"] == "all") {
  802. $(this).attr("disabled", false);
  803. } else if (fields["editableButtons"][0] == "all") {
  804. $(this).attr("disabled", false);
  805. } else if (fields["editableButtons"].contains($(this).attr("name"))) {
  806. $(this).attr("disabled", false);
  807. }
  808. });
  809. _scope.find('input[type=button]').each(function() {
  810. if (fields["editableButtons"] == "all") {
  811. $(this).attr("disabled", false);
  812. } else if (fields["editableButtons"][0] == "all") {
  813. $(this).attr("disabled", false);
  814. } else if (fields["editableButtons"].contains($(this).attr("name"))) {
  815. $(this).attr("disabled", false);
  816. }
  817. });
  818. }
  819. }
  820. /**
  821. * 添加备注浮层
  822. * @param {} _field 绑定的textarea
  823. */
  824. function addCommentDetail(_field) {
  825. $.Window.showWindow('addCommentDetailForCommentFormate', {
  826. intervalLoad : true,
  827. width : '310px',
  828. height : '40%',
  829. onRender : function(config, winId) {// set comment window's
  830. // z-index for over other
  831. // window
  832. $("#" + winId).find("#__jWin_mask-msg").css("z-index",90000);
  833. },
  834. url : 'addCommentDetailForCommentFormate.action',
  835. params : {
  836. field : _field
  837. },
  838. waitText : 'load...'
  839. }, function(data) {
  840. });
  841. }
  842. function openCommonQueryPage(pageName, action, _params, width, height,fieldUseScope) {
  843. $.Window.showWindow(pageName, {
  844. intervalLoad : true,
  845. width : width,
  846. height : height,
  847. onRender : function(config, winId) {// set comment window's
  848. // z-index for over other
  849. // window
  850. $("#" + winId).find("#__jWin_mask-msg").css("z-index",90000);
  851. },
  852. url : action,
  853. params : _params,
  854. waitText : 'load...'
  855. }, function(data) {
  856. _fieldUseScope = fieldUseScope;
  857. });
  858. }
  859. /**
  860. * <p>
  861. * Description:[前台js浮点数-乘法]
  862. * </p>
  863. * @param {} arg1
  864. * @param {} arg2
  865. * @return {}
  866. */
  867. function accMul(arg1,arg2){
  868. var m=0,s1=arg1.toString(),s2=arg2.toString();
  869. try{m+=s1.split(".")[1].length;}catch(e){}
  870. try{m+=s2.split(".")[1].length;}catch(e){}
  871. return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m);
  872. }
  873. /**
  874. * <p>
  875. * Description:[前台js浮点数-除法]
  876. * </p>
  877. * @param {} arg1
  878. * @param {} arg2
  879. * @return {}
  880. */
  881. function accDiv(arg1,arg2){
  882. var t1=0,t2=0,r1,r2;
  883. try{t1=arg1.toString().split(".")[1].length}catch(e){}
  884. try{t2=arg2.toString().split(".")[1].length}catch(e){}
  885. with(Math){
  886. r1=Number(arg1.toString().replace(".",""))
  887. r2=Number(arg2.toString().replace(".",""))
  888. return (r1/r2)*pow(10,t2-t1);
  889. }
  890. }
  891. /**
  892. * <p>
  893. * Description:[前台js浮点数-加法和减法]
  894. * </p>
  895. * @param {} arg1
  896. * @param {} arg2
  897. * @return {}
  898. */
  899. function accAdd(arg1, arg2) {
  900. var r1, r2, m;
  901. try {r1 = arg1.toString().split(".")[1].length} catch (e) {r1 = 0}
  902. try {r2 = arg2.toString().split(".")[1].length} catch (e) {r2 = 0}
  903. m = Math.pow(10, Math.max(r1, r2))
  904. return (arg1 * m + arg2 * m) / m;
  905. }
  906. /**
  907. * <p>
  908. * Description:[suggestBox附加信息填充]
  909. * </p>
  910. *
  911. * @param {} _data 选择SuggestBox行数据
  912. * @param {} _scope 设值范围
  913. * @param {} _mappingExtend 映射关系
  914. */
  915. function fillSuggestBoxExtraData(_data,_scope,_mappingExtend) {
  916. var _params = _data["params"];
  917. if(typeof(_params) != 'undefined' && _params != null) {
  918. for(var _filed in _mappingExtend) {
  919. // 首先先清空之前的数据
  920. $(_scope).find("input[name='"+_filed+"'],select[name='"+_filed+"'],textarea[name='"+_filed+"']").each(
  921. function() {
  922. if ($(this).attr("editType") == "suggestBox") {
  923. $(this).attr("hiddenValue", "");
  924. $(this).val("");
  925. } else if ($(this).attr("editType") == "dateTime") {
  926. fillFieldWithDateTime(this, "");
  927. } else if ($(this).attr("editType") == "date") {
  928. fillFieldWithDate(this, "");
  929. } else if ($(this).attr("editType") == "simpleCheckbox") {
  930. $(this).attr("checked", false);
  931. } else {
  932. $(this).val("");
  933. }
  934. $(this).change();
  935. }
  936. );
  937. $(_scope).find("input[name='"+_filed+"'],select[name='"+_filed+"'],textarea[name='"+_filed+"']").each(
  938. function() {
  939. var __value__ = _params[_mappingExtend[_filed]];
  940. if(typeof(__value__) == 'undefined' || __value__ == null || __value__== 'null') {
  941. __value__ = "";
  942. }
  943. if($(this).attr("tagName").toUpperCase() == "SELECT" && !(typeof($(this).attr("defaultValue")) =="undefined" || $(this).attr("defaultValue") == null) && __value__ == "") {
  944. __value__ = $(this).attr("defaultValue");
  945. }
  946. if ($(this).attr("editType") == "suggestBox") {
  947. $(this).attr("hiddenValue", __value__);
  948. $(this).val(_params[_mappingExtend[_filed + "_name"]]);
  949. } else if ($(this).attr("editType") == "dateTime") {
  950. fillFieldWithDateTime(this, __value__);
  951. } else if ($(this).attr("editType") == "date") {
  952. fillFieldWithDate(this, __value__);
  953. } else if ($(this).attr("editType") == "simpleCheckbox") {
  954. if (__value__ == 1 || __value__ == "1") {
  955. $(this).attr("checked", true);
  956. } else {
  957. $(this).attr("checked", false);
  958. }
  959. } else {
  960. $(this).val(__value__);
  961. }
  962. $(this).change();
  963. }
  964. );
  965. }
  966. }
  967. }
  968. /**
  969. * 比较开始时间和结束时间的大小。
  970. * 如果有一个为空,不比较,并返回true。
  971. * @param _scope
  972. * @param dateFrom
  973. * @param dateTo
  974. * @returns {Boolean}
  975. */
  976. function compareDate(_scope,dateFrom,dateTo){
  977. var fromV;
  978. var toV;
  979. var from = $(_scope).find("input[name="+dateFrom+"]");
  980. var to = $(_scope).find("input[name="+dateTo+"]");
  981. if (from.val() == null || from.val() == undefined || from.val() == null) {
  982. return true;
  983. }else{
  984. fromV = from.val();
  985. var hh = $(from).nextAll('.hh').val();
  986. var mm = $(from).nextAll('.mm').val();
  987. var ss = "00";
  988. if (hh == null || hh == "") {
  989. hh = "00";
  990. }
  991. if (mm == null || mm == "") {
  992. mm = "00";
  993. }
  994. fromV = fromV + " "+hh+":"+mm+":"+ss;
  995. }
  996. if (to.val() == "" || to.val() == undefined || to.val() == null) {
  997. return true;
  998. }else{
  999. toV = to.val();
  1000. var hh = $(to).nextAll('.hh').val();
  1001. var mm = $(to).nextAll('.mm').val();
  1002. var ss = "00";
  1003. if (hh == null || hh == "") {
  1004. hh = "00";
  1005. }
  1006. if (mm == null || mm == "") {
  1007. mm = "00";
  1008. }
  1009. toV = toV + " "+hh+":"+mm+":"+ss;
  1010. }
  1011. if(fromV > toV){
  1012. commonErrorPrompt(from.attr("promptName") + "不能大于" + to.attr("promptName"));
  1013. return false;
  1014. }
  1015. return true;
  1016. }
  1017. /**
  1018. * 比较开始时间和结束时间的大小。
  1019. * 如果有一个为空,不比较,并返回true。
  1020. * @param _scope
  1021. * @param dateFrom
  1022. * @param dateTo
  1023. * @returns {Boolean}
  1024. */
  1025. function compareNowDate(_scope,dateFrom,dateTo){
  1026. var fromV;
  1027. var toV;
  1028. var from = $(_scope).find("input[name="+dateFrom+"]");
  1029. var to = $(_scope).find("input[name="+dateTo+"]");
  1030. if (from.val() == null || from.val() == undefined || from.val() == null) {
  1031. return true;
  1032. }else{
  1033. fromV = from.val();
  1034. var hh = $(from).nextAll('.hh').val();
  1035. var mm = $(from).nextAll('.mm').val();
  1036. var ss = "00";
  1037. if (hh == null || hh == "") {
  1038. hh = "00";
  1039. }
  1040. if (mm == null || mm == "") {
  1041. mm = "00";
  1042. }
  1043. fromV = fromV + " "+hh+":"+mm+":"+ss;
  1044. }
  1045. if (to.val() == "" || to.val() == undefined || to.val() == null) {
  1046. return true;
  1047. }else{
  1048. toV = to.val();
  1049. var hh = $(to).nextAll('.hh').val();
  1050. var mm = $(to).nextAll('.mm').val();
  1051. var ss = "00";
  1052. if (hh == null || hh == "") {
  1053. hh = "00";
  1054. }
  1055. if (mm == null || mm == "") {
  1056. mm = "00";
  1057. }
  1058. toV = toV + " "+hh+":"+mm+":"+ss;
  1059. }
  1060. if(fromV > toV){
  1061. commonErrorPrompt(to.attr("promptName") + "不能小于" + from.attr("promptName"));
  1062. return false;
  1063. }
  1064. return true;
  1065. }
  1066. /**
  1067. *
  1068. * @param _scope
  1069. * @param dateFrom
  1070. * @return
  1071. */
  1072. function compareCurrentDate(_scope,dateFrom){
  1073. var fromV;
  1074. var from = $(_scope).find("input[name="+dateFrom+"]");
  1075. if (from.val() == null || from.val() == undefined) {
  1076. return true;
  1077. }else{
  1078. fromV = from.val();
  1079. var hh = $(from).nextAll('.hh').val();
  1080. var mm = $(from).nextAll('.mm').val();
  1081. var ss = "00";
  1082. if (hh == null || hh == "") {
  1083. hh = "00";
  1084. }
  1085. if (mm == null || mm == "") {
  1086. mm = "00";
  1087. }
  1088. fromV = fromV + " "+hh+":"+mm+":"+ss;
  1089. }
  1090. var current = new Date();
  1091. //过滤统一时间,分钟格式
  1092. var month = current.getMonth()+1;
  1093. var day = current.getDate();
  1094. if(month<10){
  1095. month = "0"+month;
  1096. }
  1097. if(day<10){
  1098. day="0"+day;
  1099. }
  1100. var l = current.getFullYear()+"-"+month+"-"+day+" "+current.getHours()+":"+current.getMinutes()+":"+current.getSeconds();
  1101. if(fromV<l){
  1102. commonErrorPrompt(from.attr("promptName") + "必须大于当前日期");
  1103. return false;
  1104. }
  1105. return true;
  1106. }
  1107. /**
  1108. * 刷新调用js
  1109. */
  1110. function refreshDataPart(_scope,df){
  1111. fillingData(_scope,df);
  1112. }
  1113. /**
  1114. *
  1115. * @param {} _scope 设置范围
  1116. * @param {} privilegeConfig 权限配置
  1117. */
  1118. function hiddenOrDisabledWithPrivilege(_scope,privilegeConfig) {
  1119. if(typeof(privilegeConfig) == 'undefined') {
  1120. return;
  1121. }
  1122. if(privilegeConfig.hasOwnProperty("hiddenTabs")) {
  1123. $(_scope).find('li').each(function() {
  1124. if (privilegeConfig["hiddenTabs"].contains($(this).attr("name"))) {
  1125. $(this).css("display", "none");
  1126. // 隐藏Tab 映射对应的DIV
  1127. var tab_div = $(this).find("a").eq(0).attr("href");
  1128. if(typeof(tab_div) !="undefined" && tab_div.length !=0) {
  1129. $(_scope).find(tab_div).css("display", "none");
  1130. }
  1131. }
  1132. });
  1133. $(_scope).find("div").each(function(){
  1134. if (privilegeConfig["hiddenTabs"].contains($(this).attr("name"))) {
  1135. $(this).css("display", "none");
  1136. // 隐藏Tab 映射对应的DIV
  1137. }
  1138. })
  1139. $(_scope).find("tr").each(function(){
  1140. if (privilegeConfig["hiddenTabs"].contains($(this).attr("name"))) {
  1141. $(this).css("display", "none");
  1142. // 隐藏Tab 映射对应的DIV
  1143. }
  1144. })
  1145. }
  1146. if(privilegeConfig.hasOwnProperty("hiddenProperties")) {
  1147. var hidden_properties = privilegeConfig["hiddenProperties"];
  1148. $(_scope).find('input,select,textarea,button').each(function() {
  1149. if (hidden_properties.contains($(this).attr("name"))) {
  1150. // if($(this).attr("tagName").toUpperCase()=="BUTTON") {
  1151. // $(this).css("display", "none");
  1152. //
  1153. // if($(this).parent(0).attr("tagName").toUpperCase()=="LI") {
  1154. // $(this).parent(0).css("display", "none");
  1155. // }
  1156. // }
  1157. // else {
  1158. // $(this).parent().prev().css("display", "none");
  1159. // $(this).parent().css("display", "none");
  1160. // }
  1161. $(this).css("display", "none");
  1162. // remove 已处理的属性
  1163. var _property_name = $(this).attr("name");
  1164. hidden_properties = $.grep(hidden_properties,function(n,i) {
  1165. return $.inArray(_property_name,hidden_properties) != -1;
  1166. },false);
  1167. }
  1168. });
  1169. }
  1170. if(privilegeConfig.hasOwnProperty("disabledProperties")) {
  1171. var _disabled_properties = privilegeConfig["disabledProperties"]
  1172. $(_scope).find('input,select,textarea,button').each(function() {
  1173. var isDisabled = true;
  1174. var _property_name;
  1175. if (_disabled_properties.contains($(this).attr("name")) ) {
  1176. $(this).attr("disabled", true);
  1177. _property_name = $(this).attr("name");
  1178. }
  1179. else if (_disabled_properties.contains($(this).attr("nativeChangeField"))) {
  1180. $(this).attr("disabled", true);
  1181. _property_name = $(this).attr("nativeChangeField");
  1182. }
  1183. else {
  1184. isDisabled = false;
  1185. }
  1186. if(isDisabled) {
  1187. // remove 已处理的属性
  1188. _disabled_properties = $.grep(_disabled_properties,function(n,i) {
  1189. return $.inArray(_property_name,_disabled_properties) != -1;
  1190. },false);
  1191. }
  1192. if (isDisabled && $(this).hasClass("hasDatepicker")) {
  1193. $(this).next(".time_img").unbind("click");
  1194. $(this).next(".time_img").attr("disabled",true);
  1195. }
  1196. if (isDisabled && $(this).attr("editType") == "comment") {
  1197. //$(this).next(".commentClass").css("display", 'none');
  1198. $(this).next(".commentClass").attr("disabled", true);
  1199. }
  1200. if (isDisabled && $(this).attr("editType") == "suggestBox" && $(this).attr("hasShowTrigger") == true) {
  1201. //$(this).next(".suggestbox-trigger-img").css("display", 'none');
  1202. $(this).next(".suggestbox-trigger-img").attr("disabled", true);
  1203. }
  1204. //if (isDisabled && $(this).attr("tagName").toUpperCase() == 'INPUT') {
  1205. if (isDisabled) {
  1206. $(this).css('background','#eeeeee');
  1207. }
  1208. });
  1209. }
  1210. }
  1211. function fillingLabelData(_this, information) {
  1212. $(_this).find('label').each(function() {
  1213. if (information[$(this).attr("name")] || information[$(this).attr("name")] != 0) {
  1214. $(this).text(information[$(this).attr("name")]);
  1215. }
  1216. });
  1217. }
  1218. function timeBasic(timeName)
  1219. {
  1220. if ($("#"+timeName).attr("name") != "") {
  1221. if (!basicChangeList.contains($("#"+timeName).attr("name"))) {
  1222. basicChangeList.push($("#"+timeName).attr("name"));
  1223. }
  1224. } else if ($("#"+timeName).attr("nativeChangeField") != "") {
  1225. if (!basicChangeList.contains($("#"+timeName).attr("nativeChangeField"))) {
  1226. basicChangeList.push($("#"+timeName).attr("nativeChangeField"));
  1227. }
  1228. }
  1229. }
  1230. function timeBasicDetail(timeName)
  1231. {
  1232. if ($("#"+timeName).attr("name") != "") {
  1233. if (!batchChangeList.contains($("#"+timeName).attr("name"))) {
  1234. batchChangeList.push($("#"+timeName).attr("name"));
  1235. }
  1236. } else if ($("#"+timeName).attr("nativeChangeField") != "") {
  1237. if (!batchChangeList.contains($("#"+timeName).attr("nativeChangeField"))) {
  1238. batchChangeList.push($("#"+timeName).attr("nativeChangeField"));
  1239. }
  1240. }
  1241. }
  1242. function timeBasicDetail2(timeName)
  1243. {
  1244. if ($("#"+timeName).attr("name") != "") {
  1245. if (!detailChangeList.contains($("#"+timeName).attr("name"))) {
  1246. detailChangeList.push($("#"+timeName).attr("name"));
  1247. }
  1248. } else if ($("#"+timeName).attr("nativeChangeField") != "") {
  1249. if (!detailChangeList.contains($("#"+timeName).attr("nativeChangeField"))) {
  1250. detailChangeList.push($("#"+timeName).attr("nativeChangeField"));
  1251. }
  1252. }
  1253. }
  1254. //获取当前时间
  1255. function GetCurrentDate()
  1256. {
  1257. var year=0;
  1258. var Month=0;
  1259. var day=0;
  1260. var CurrentDate = new Date();
  1261. return ChangeDateToString(CurrentDate);
  1262. }
  1263. function ChangeDateToString(DateIn)
  1264. {
  1265. var Year=0;
  1266. var Month=0;
  1267. var Day=0;
  1268. var CurrentDate="";
  1269. //初始化时间
  1270. Year = DateIn.getYear();
  1271. Month = DateIn.getMonth()+1;
  1272. Day = DateIn.getDate();
  1273. CurrentDate = Year + "-";
  1274. if (Month >= 10 ){
  1275. CurrentDate = CurrentDate + Month + "-";
  1276. }else{
  1277. CurrentDate = CurrentDate + "0" + Month + "-";
  1278. }
  1279. if (Day >= 10 ){
  1280. CurrentDate = CurrentDate + Day ;
  1281. }else{
  1282. CurrentDate = CurrentDate + "0" + Day ;
  1283. }
  1284. return CurrentDate;
  1285. }
  1286. /**
  1287. * 自动click收放内容
  1288. */
  1289. function autoTRClick(array){
  1290. for (i = 0; i < array.length; i++)
  1291. {
  1292. var rid = array[i];
  1293. $("#"+rid).click();
  1294. }
  1295. }
  1296. /**
  1297. * tr信息收放
  1298. * @param rid
  1299. * @return
  1300. */
  1301. function toggerTR(obj){
  1302. var rid = $(obj).attr("id");
  1303. $("tr[name="+rid+"]").toggle();
  1304. }