ligerOverwrite.js 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577
  1. /**
  2. * ligerUI BUG修复和重写
  3. */
  4. (function ($, win) {
  5. /***************** 字典相关扩展 *************************/
  6. //字典数据
  7. $.ehrDict = {
  8. dictDataUrl: window.root + "/basedict/getDict", //字典数据获取路径
  9. dictCodeName: "code", //字典code字段
  10. dictValueName: "value", //字典Value字段
  11. dictExtendName: "extend", //字典扩展字段
  12. sysDict: {}, //系统字典
  13. orgDict: {}, //机构字典
  14. stdDitc: {}, //标准字典
  15. //后台加载数据
  16. loadDictData: function (dictName, type, where, callBack) {
  17. var me = this;
  18. $.post(
  19. me.dictDataUrl,
  20. {type: type, name: dictName, where: where},
  21. function (data, status) {
  22. try {
  23. if (data.successFlg) {
  24. var list = data.detailModelList;
  25. if (type == "1") //机构字典
  26. {
  27. me.orgDict[dictName] = list;
  28. }
  29. else if (type == "2") { //标准字典
  30. me.stdDitc[dictName] = list;
  31. }
  32. else { //系统字典
  33. me.sysDict[dictName] = list;
  34. }
  35. if ($.isFunction(callBack)) {
  36. callBack(me.listToDict(list));
  37. }
  38. }
  39. }
  40. catch (e) {
  41. return;
  42. }
  43. });
  44. },
  45. //格式转化
  46. listToDict: function (list) {
  47. var me = this;
  48. var dictItem = {};
  49. for (var item in list) {
  50. dictItem[list[item][me.dictCodeName]] = {
  51. value: list[item][me.dictValueName],
  52. extend: list[item][me.dictExtendName]
  53. };
  54. }
  55. return dictItem;
  56. },
  57. //获取字典数据
  58. getDictData: function (dictName, type, where, callBack) {
  59. var me = this;
  60. if (dictName != null && dictName.length > 0) {
  61. var re = null;
  62. if (type == "1") //机构字典
  63. {
  64. re = me.orgDict[dictName];
  65. }
  66. else if (type == "2") { //标准字典
  67. re = me.stdDitc[dictName];
  68. }
  69. else { //系统字典
  70. re = me.sysDict[dictName];
  71. }
  72. if (re != null) {
  73. if (re != "loading") {
  74. return me.listToDict(re);
  75. }
  76. }
  77. else {
  78. if (type == "1") {
  79. me.orgDict[dictName] = "loading";
  80. }
  81. else if (type == "2") {
  82. me.stdDitc[dictName] = "loading";
  83. }
  84. else {
  85. me.sysDict[dictName] = "loading";
  86. }
  87. //加载数据
  88. me.loadDictData(dictName, type, where, callBack);
  89. }
  90. }
  91. return null;
  92. }
  93. };
  94. /******************************************************/
  95. //重写条件选择控件 add by hzp at 20160119
  96. $.extend($.ligerui.controls.Filter.prototype, {
  97. getValue: function () {
  98. var me = this;
  99. var options = me.options;
  100. var datas = me.getData();
  101. return datas;
  102. }
  103. });
  104. //重写下拉控件 add by hzp at 20160108
  105. $.extend($.ligerDefaults.ComboBox, {
  106. selectBoxWidth: 240,
  107. resize: false,
  108. valueField: 'code',
  109. textField: 'value',
  110. extendField: 'extend',
  111. dataParmName: 'detailModelList',
  112. dict: false, //是否下拉字典控件
  113. dictName: null, //字典名称
  114. dictType: null, //1机构字典 2标准字典 默认系统字典
  115. dictWhere: "" //表字典附加SQL条件
  116. });
  117. $.extend($.ligerui.controls.ComboBox.prototype, {
  118. _setUrl: function (url, callback) {
  119. var g = this, p = this.options;
  120. /****************** 下拉字典 ***********************/
  121. if (p.dict) {
  122. var dict = $.ehrDict.getDictData(p.dictName, p.dictType, p.dictWhere);
  123. if (dict != null) {
  124. g.setData(dict);
  125. return;
  126. }
  127. else {
  128. p.url = url = $.ehrDict.dictDataUrl;
  129. p.urlParms = {name: p.dictName, type: p.dictType, where: p.dictWhere};
  130. }
  131. }
  132. /***************************************************/
  133. if (!url) return;
  134. if (p.readonly) //只读状态不加载数据
  135. {
  136. return;
  137. }
  138. if (p.delayLoad && !g.isAccessDelay && !g.triggerLoaded) {
  139. g.isAccessDelay = true;//已经有一次延时加载了
  140. return;
  141. }
  142. url = $.isFunction(url) ? url.call(g) : url;
  143. var urlParms = $.isFunction(p.urlParms) ? p.urlParms.call(g) : p.urlParms;
  144. if (urlParms) {
  145. for (name in urlParms) {
  146. url += url.indexOf('?') == -1 ? "?" : "&";
  147. url += name + "=" + urlParms[name];
  148. }
  149. }
  150. var parms = $.isFunction(p.parms) ? p.parms.call(g) : p.parms;
  151. if (p.ajaxContentType == "application/json" && typeof (parms) != "string") {
  152. parms = liger.toJSON(parms);
  153. }
  154. var ajaxOp = {
  155. type: p.ajaxType,
  156. url: url,
  157. data: parms,
  158. cache: false,
  159. dataType: 'json',
  160. beforeSend: p.ajaxBeforeSend,
  161. complete: p.ajaxComplete,
  162. success: function (result) {
  163. var data = $.isFunction(p.dataGetter) ? data = p.dataGetter.call(g, result) : result;
  164. data = p.dataParmName && data ? data[p.dataParmName] : data;
  165. if (g.trigger('beforeSetData', [data]) == false) {
  166. return;
  167. }
  168. g.setData(data);
  169. g.trigger('success', [data]);
  170. if ($.isFunction(callback)) callback(data);
  171. },
  172. error: function (XMLHttpRequest, textStatus) {
  173. g.trigger('error', [XMLHttpRequest, textStatus]);
  174. }
  175. };
  176. if (p.ajaxContentType) {
  177. ajaxOp.contentType = p.ajaxContentType;
  178. }
  179. $.ajax(ajaxOp);
  180. },
  181. /***** 获取选中BUG修复 add by hzp at 20160224 **************/
  182. getSelected:function(){
  183. if(this.selected!=null)
  184. {
  185. return this.selected;
  186. }
  187. else{
  188. var me = this;
  189. var options = me.options;
  190. var selected = me.selectedValue;
  191. for (var i = 0; i < me.data.length; i++) {
  192. var item = me.data[i];
  193. if (item[options.valueField] == selected) {
  194. return item;
  195. }
  196. }
  197. }
  198. },
  199. //获取扩展字段
  200. getExtendValue: function () {
  201. try {
  202. var me = this;
  203. var options = me.options;
  204. var selected = me.selectedValue;
  205. for (var i = 0; i < me.data.length; i++) {
  206. var item = me.data[i];
  207. if (item[options.valueField] == selected) {
  208. return item[options.extendField];
  209. }
  210. }
  211. }
  212. catch (e) {
  213. return "";
  214. }
  215. }
  216. });
  217. //重写Grid控件 add by hzp at 20160107
  218. $.extend($.ligerDefaults.Grid, {
  219. // 存储总记录数的字段名
  220. record: 'totalCount',
  221. // 数据源字段名
  222. root: 'detailModelList',
  223. // 每页记录数
  224. pageSize: 20,
  225. // 页记录数参数名,(提交给服务器)
  226. pagesizeParmName: 'rows',
  227. // 高度补差,当设置height:100%时,可能会有高度的误差,可以通过这个属性调整
  228. heightDiff: -14,
  229. height: '100%',
  230. // 是否显示行序号
  231. rownumbers: true,
  232. // 表头行的高度
  233. headerRowHeight: 40,
  234. // 行的高度
  235. rowHeight: 40,
  236. // 编辑器位置误差调整
  237. editorTopDiff: 1,
  238. allowAdjustColWidth: true
  239. });
  240. $.extend($.ligerui.controls.Grid.prototype, {
  241. _setHeight: function (h) {
  242. var g = this, p = this.options;
  243. g.unbind("SysGridHeightChanged");
  244. if (h == "auto")
  245. {
  246. g.bind("SysGridHeightChanged", function ()
  247. {
  248. if (g.enabledFrozen())
  249. g.gridview.height(Math.max(g.gridview1.height(), g.gridview2.height()));
  250. });
  251. return;
  252. }
  253. h = g._calculateGridBodyHeight(h);
  254. if (h > 0)
  255. {
  256. g.gridbody.height(h);
  257. if (p.frozen)
  258. {
  259. /*** 滚动条样式修改 add by hzp at 20160215***/
  260. //解决冻结列和活动列由上至下滚动错位的问题
  261. var w = g.gridbody.width(), w2 = $(":first-child", g.gridbody).width();
  262. if (w2 && (w2 + 6 >= w))
  263. {
  264. if (h > 6)
  265. g.f.gridbody.height(h - 6);
  266. } else
  267. {
  268. g.f.gridbody.height(h);
  269. }
  270. /********************************************/
  271. }
  272. /** 列表高度计算bug修改 **/
  273. var gridHeaderHeight = (p.headerRowHeight+1) * (g._columnMaxLevel - 1) + p.headerRowHeight + 1;
  274. /***********************/
  275. g.gridview.height(h + gridHeaderHeight);
  276. }
  277. g._updateHorizontalScrollStatus.ligerDefer(g, 10);
  278. },
  279. _calculateGridBodyHeight: function (h) {
  280. var g = this, p = this.options;
  281. if (typeof h == "string" && h.indexOf('%') > 0) {
  282. if (p.inWindow)
  283. h = $(window).height() * parseInt(h) * 0.01;
  284. else
  285. h = g.grid.parent().height() * parseInt(h) * 0.01;
  286. }
  287. if (p.title) h -= 24;
  288. /*** 隐藏分页 高度BUG修复 add by hzp at20160121 **/
  289. if (p.usePager && (p.pagerRender || !p.scrollToPage)) h -= g.toolbar.outerHeight();
  290. /******************************/
  291. if (p.totalRender) h -= 25;
  292. if (p.toolbar) h -= g.topbar.outerHeight();
  293. /** 列表高度计算bug修改 **/
  294. var gridHeaderHeight = (p.headerRowHeight+1) * (g._columnMaxLevel - 1) + p.headerRowHeight + 1;
  295. /***********************/
  296. h -= (gridHeaderHeight || 0);
  297. return h;
  298. },
  299. getColumns: function (columnLevel) {
  300. var g = this, p = this.options;
  301. var columns = [];
  302. for (var id in g._columns) {
  303. var col = g._columns[id];
  304. /********* 字典列翻译 ***********/
  305. if (col['dict']) {
  306. var dictName = col.dictName;
  307. //提前加载字典
  308. $.ehrDict.getDictData(dictName, col.dictType, col.dictWhere);
  309. //渲染字典字段
  310. col.render = function (row, index, data, _col) {
  311. var dict = $.ehrDict.getDictData(_col.dictName, col.dictType, col.dictWhere, function (response) {
  312. g.refreshColumn(_col.dictName, response);
  313. });
  314. if (dict != null) {
  315. if (dict[data] != null) {
  316. return dict[data].value;
  317. }
  318. else {
  319. return data;
  320. }
  321. }
  322. else {
  323. return "";
  324. }
  325. }
  326. }
  327. /********************/
  328. if (columnLevel != undefined) {
  329. if (col['__level'] == columnLevel) columns.push(col);
  330. }
  331. else {
  332. if (col['__leaf']) columns.push(col);
  333. }
  334. }
  335. return columns;
  336. },
  337. //字典返回后刷新列值
  338. refreshColumn: function (dictName, dict) {
  339. try {
  340. var me = this;
  341. for (var i = 0; i < me.columns.length; i++) {
  342. var col = me.columns[i];
  343. if (col.dict && col.dictName == dictName) {
  344. var colName = col.columnname;
  345. $.each($.find("td[id$='|" + col.__id + "']", me.gridbody[0]), function (index, obj) {
  346. var code = me.rows[index][colName];
  347. var cell = $.find("div.l-grid-row-cell-inner", obj)[0];
  348. if (dict[code] != null) {
  349. var val = dict[code].value;
  350. if (val != undefined && val != null) {
  351. $(cell).html(val);
  352. }
  353. }
  354. else {
  355. $(cell).html(code);
  356. }
  357. });
  358. }
  359. }
  360. }
  361. catch (e) {
  362. return;
  363. }
  364. },
  365. queryByText: function (filedName, text) {
  366. var data = this.data.detailModelList;
  367. for (var i = 0; i < data.length; i++) {
  368. var obj=JSON.stringify(data[i]);
  369. var r = eval("("+obj+"." + filedName+")");
  370. if (r.indexOf(text) > 0) {
  371. this.select(data[i]);
  372. }
  373. }
  374. }
  375. });
  376. //重写树函数 add by hzp at 20160107
  377. $.extend($.ligerDefaults.Tree, {
  378. checkbox:false,
  379. parentIcon:false,
  380. childIcon:false,
  381. treeLine:false
  382. });
  383. $.extend($.ligerui.controls.Tree.prototype, {
  384. _upadteTreeWidth: function ()
  385. {
  386. var g = this, p = this.options;
  387. var treeWidth = g.maxOutlineLevel * 22;
  388. if (p.checkbox) treeWidth += 22;
  389. if (p.parentIcon || p.childIcon) treeWidth += 22;
  390. treeWidth += p.nodeWidth;
  391. treeWidth = p.adjustToWidth? $(g.element).width(): treeWidth; // TODO [代码片段001][修复树宽度自适应问题][yezehua]
  392. g.tree.width(treeWidth);
  393. },
  394. getDataByID: function (id) {
  395. var g = this, p = this.options;
  396. var data = null;
  397. if (g.data && g.data.length) {
  398. return find(g.data);
  399. }
  400. function find(items) {
  401. for (var i = 0; i < items.length; i++) {
  402. var dataItem = items[i];
  403. if (dataItem[p.idFieldName] == id) return dataItem;
  404. if (dataItem.children && dataItem.children.length) {
  405. /*** BUG修复 ***/
  406. var pre = find(dataItem.children);
  407. if (pre != null) return pre;
  408. /*************/
  409. }
  410. }
  411. return null;
  412. }
  413. $("li", g.tree).each(function () {
  414. if (data) return;
  415. var treeitem = $(this);
  416. var treedataindex = parseInt(treeitem.attr("treedataindex"));
  417. var treenodedata = g._getDataNodeByTreeDataIndex(g.data, treedataindex);
  418. if (treenodedata[p.idFieldName].toString() == id.toString()) {
  419. data = treenodedata;
  420. }
  421. });
  422. return data;
  423. },
  424. /**
  425. * 扩展方法1:
  426. * queryByText: 根据名字找出树的节点,并且打开节点
  427. */
  428. queryByText: function (text) {
  429. var $g = this, p = this.options;
  430. var nodeText = $("span", $g.tree);
  431. for (var i = 0; i < nodeText.length; i++) {
  432. if ($(nodeText[i]).text().indexOf(text) >= 0) {
  433. var id = $(nodeText[i]).closest("li").attr("id");
  434. $g.expandNode(id);
  435. $g.selectNode(id);
  436. break;
  437. }
  438. }
  439. },
  440. /**
  441. * expandNode:根据id打开节点
  442. * @param id
  443. */
  444. expandNode: function (id) {
  445. var $li = $("#" + id, this.tree).closest("li");
  446. var outlinelevel = $li.attr("outlinelevel");
  447. for (var j = 0; j < outlinelevel; j++) {
  448. if (j == 0) {
  449. $li.parent().parent().children(".l-body").children(".l-expandable-close").removeClass("l-expandable-close").addClass("l-expandable-open");
  450. $li = $li.parent().show();
  451. } else {
  452. $li.parent().children(".l-body").children(".l-expandable-close").removeClass("l-expandable-close").addClass("l-expandable-open");
  453. $li = $li.parent().parent().show();
  454. }
  455. }
  456. }
  457. });
  458. //重写radio方法 add by hzp at 20160107
  459. $.extend($.ligerui.controls.Radio.prototype, {
  460. setValue: function (val) {
  461. var name = this.element.name;
  462. $('input[name="' + name + '"]').each(function () {
  463. var typeObj = $(this).closest('.l-radio-wrapper').find('a.l-radio');
  464. if (this.value == val) {
  465. typeObj.addClass("l-radio-checked");
  466. this.checked = true;
  467. }
  468. else {
  469. typeObj.removeClass("l-radio-checked");
  470. this.checked = false;
  471. }
  472. });
  473. },
  474. getValue: function () {
  475. var name = this.element.name;
  476. var re = "";
  477. $('input[name="' + name + '"]').each(function () {
  478. if (this.checked) {
  479. re = this.value;
  480. return;
  481. }
  482. });
  483. return re;
  484. }
  485. });
  486. //重写CheckBox方法 add by hzp at 20160107
  487. $.extend($.ligerui.controls.CheckBox.prototype, {
  488. setValue: function (val) {
  489. var name = this.element.name;
  490. var vals = null;
  491. if (val != null && val.length > 0) {
  492. vals = val.split(',');
  493. }
  494. $('input[name="' + name + '"]').each(function () {
  495. var typeObj = $(this).closest('.l-checkbox-wrapper').find('a.l-checkbox');
  496. var isChecked = false;
  497. if (vals != null) {
  498. for (var i = 0; i < vals.length; i++) {
  499. if (this.value == vals[i]) {
  500. isChecked = true;
  501. }
  502. }
  503. }
  504. if (isChecked) {
  505. typeObj.addClass("l-checkbox-checked");
  506. this.checked = true;
  507. }
  508. else {
  509. typeObj.removeClass("l-checkbox-checked");
  510. this.checked = false;
  511. }
  512. });
  513. },
  514. getValue: function () {
  515. var name = this.element.name;
  516. var re = "";
  517. $('input[name="' + name + '"]').each(function () {
  518. if (this.checked) {
  519. re += this.value + ",";
  520. }
  521. });
  522. if (re.length > 0) {
  523. re = re.substr(0, re.length - 1);
  524. }
  525. return re;
  526. }
  527. });
  528. //重写时间控件方法 add by hzp at 20160107
  529. $.extend($.ligerDefaults.DateEditor,{
  530. format: "yyyy-MM-dd hh:mm:ss"
  531. });
  532. $.extend($.ligerui.controls.DateEditor.prototype, {
  533. getYear: function () {
  534. return this.currentDate.year;
  535. },
  536. getMonth: function () {
  537. return this.currentDate.month;
  538. },
  539. getDate: function () {
  540. return this.currentDate.date;
  541. },
  542. getHour: function () {
  543. return this.currentDate.hour;
  544. },
  545. getMinute: function () {
  546. return this.currentDate.minute;
  547. },
  548. _render: function ()
  549. {
  550. var g = this, p = this.options;
  551. /**** 增加秒显示 *****/
  552. if (!p.showTime && p.format.indexOf(" hh:mm:ss") > -1)
  553. p.format = p.format.replace(" hh:mm:ss", "");
  554. /********************/
  555. if (this.element.tagName.toLowerCase() != "input" || this.element.type != "text")
  556. return;
  557. g.inputText = $(this.element);
  558. if (!g.inputText.hasClass("l-text-field"))
  559. g.inputText.addClass("l-text-field");
  560. g.link = $('<div class="l-trigger"><div class="l-trigger-icon"></div></div>');
  561. g.text = g.inputText.wrap('<div class="l-text l-text-date"></div>').parent();
  562. g.text.append('<div class="l-text-l"></div><div class="l-text-r"></div>');
  563. g.text.append(g.link);
  564. //添加个包裹,
  565. g.textwrapper = g.text.wrap('<div class="l-text-wrapper"></div>').parent();
  566. var dateeditorHTML = "";
  567. dateeditorHTML += "<div class='l-box-dateeditor' style='display:none'>";
  568. dateeditorHTML += " <div class='l-box-dateeditor-header'>";
  569. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-prevyear'><span></span></div>";
  570. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-prevmonth'><span></span></div>";
  571. dateeditorHTML += " <div class='l-box-dateeditor-header-text'><a class='l-box-dateeditor-header-month'></a> , <a class='l-box-dateeditor-header-year'></a></div>";
  572. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-nextmonth'><span></span></div>";
  573. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-nextyear'><span></span></div>";
  574. dateeditorHTML += " </div>";
  575. dateeditorHTML += " <div class='l-box-dateeditor-body'>";
  576. dateeditorHTML += " <table cellpadding='0' cellspacing='0' border='0' class='l-box-dateeditor-calendar'>";
  577. dateeditorHTML += " <thead>";
  578. dateeditorHTML += " <tr><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr>";
  579. dateeditorHTML += " </thead>";
  580. dateeditorHTML += " <tbody>";
  581. dateeditorHTML += " <tr class='l-first'><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr><tr><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr><tr><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr><tr><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr><tr><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr><tr><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td><td align='center'></td></tr>";
  582. dateeditorHTML += " </tbody>";
  583. dateeditorHTML += " </table>";
  584. dateeditorHTML += " <ul class='l-box-dateeditor-monthselector'><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>";
  585. dateeditorHTML += " <ul class='l-box-dateeditor-yearselector'><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>";
  586. dateeditorHTML += " <ul class='l-box-dateeditor-hourselector'><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>";
  587. dateeditorHTML += " <ul class='l-box-dateeditor-minuteselector'><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>";
  588. dateeditorHTML += " </div>";
  589. dateeditorHTML += " <div class='l-box-dateeditor-toolbar'>";
  590. /**************** 添加“时间:”标识 add by hzp at 20160217 *********/
  591. dateeditorHTML += " <div class='l-box-dateeditor-time'>时间:</div>";
  592. /********************************************************/
  593. dateeditorHTML += " <div class='l-button l-button-today'></div>";
  594. dateeditorHTML += " <div class='l-button l-button-close'></div>";
  595. dateeditorHTML += " <div class='l-clear'></div>";
  596. dateeditorHTML += " </div>";
  597. dateeditorHTML += "</div>";
  598. g.dateeditor = $(dateeditorHTML);
  599. if (p.absolute)
  600. g.dateeditor.appendTo('body').addClass("l-box-dateeditor-absolute");
  601. else
  602. g.textwrapper.append(g.dateeditor);
  603. g.header = $(".l-box-dateeditor-header", g.dateeditor);
  604. g.body = $(".l-box-dateeditor-body", g.dateeditor);
  605. g.toolbar = $(".l-box-dateeditor-toolbar", g.dateeditor);
  606. g.body.thead = $("thead", g.body);
  607. g.body.tbody = $("tbody", g.body);
  608. g.body.monthselector = $(".l-box-dateeditor-monthselector", g.body);
  609. g.body.yearselector = $(".l-box-dateeditor-yearselector", g.body);
  610. g.body.hourselector = $(".l-box-dateeditor-hourselector", g.body);
  611. g.body.minuteselector = $(".l-box-dateeditor-minuteselector", g.body);
  612. g.toolbar.time = $(".l-box-dateeditor-time", g.toolbar);
  613. g.toolbar.time.hour = $("<a></a>");
  614. g.toolbar.time.minute = $("<a></a>");
  615. g.buttons = {
  616. btnPrevYear: $(".l-box-dateeditor-header-prevyear", g.header),
  617. btnNextYear: $(".l-box-dateeditor-header-nextyear", g.header),
  618. btnPrevMonth: $(".l-box-dateeditor-header-prevmonth", g.header),
  619. btnNextMonth: $(".l-box-dateeditor-header-nextmonth", g.header),
  620. btnYear: $(".l-box-dateeditor-header-year", g.header),
  621. btnMonth: $(".l-box-dateeditor-header-month", g.header),
  622. btnToday: $(".l-button-today", g.toolbar),
  623. btnClose: $(".l-button-close", g.toolbar)
  624. };
  625. var nowDate = new Date();
  626. g.now = {
  627. year: nowDate.getFullYear(),
  628. month: nowDate.getMonth() + 1, //注意这里
  629. day: nowDate.getDay(),
  630. date: nowDate.getDate(),
  631. hour: nowDate.getHours(),
  632. minute: nowDate.getMinutes()
  633. };
  634. //当前的时间
  635. g.currentDate = {
  636. year: nowDate.getFullYear(),
  637. month: nowDate.getMonth() + 1,
  638. day: nowDate.getDay(),
  639. date: nowDate.getDate(),
  640. hour: nowDate.getHours(),
  641. minute: nowDate.getMinutes()
  642. };
  643. //选择的时间
  644. g.selectedDate = null;
  645. //使用的时间
  646. g.usedDate = null;
  647. //初始化数据
  648. //设置周日至周六
  649. $("td", g.body.thead).each(function (i, td)
  650. {
  651. $(td).html(p.dayMessage[i]);
  652. });
  653. //设置一月到十一二月
  654. $("li", g.body.monthselector).each(function (i, li)
  655. {
  656. $(li).html(p.monthMessage[i]);
  657. });
  658. //设置按钮
  659. g.buttons.btnToday.html(p.todayMessage);
  660. g.buttons.btnClose.html(p.closeMessage);
  661. //设置时间
  662. if (p.showTime)
  663. {
  664. g.toolbar.time.show();
  665. g.toolbar.time.append(g.toolbar.time.hour).append(":").append(g.toolbar.time.minute);
  666. $("li", g.body.hourselector).each(function (i, item)
  667. {
  668. var str = i;
  669. if (i < 10) str = "0" + i.toString();
  670. $(this).html(str);
  671. });
  672. $("li", g.body.minuteselector).each(function (i, item)
  673. {
  674. var str = i;
  675. if (i < 10) str = "0" + i.toString();
  676. $(this).html(str);
  677. });
  678. }
  679. //设置主体
  680. g.bulidContent();
  681. //初始化
  682. //初始值
  683. if (p.initValue)
  684. {
  685. g.inputText.val(p.initValue);
  686. }
  687. if (g.inputText.val() != "")
  688. {
  689. g.onTextChange();
  690. }
  691. /**************
  692. **bulid evens**
  693. *************/
  694. g.dateeditor.hover(null, function (e)
  695. {
  696. if (g.dateeditor.is(":visible") && !g.editorToggling)
  697. {
  698. g.toggleDateEditor(true);
  699. }
  700. });
  701. //toggle even
  702. g.link.hover(function ()
  703. {
  704. if (p.disabled) return;
  705. this.className = "l-trigger-hover";
  706. }, function ()
  707. {
  708. if (p.disabled) return;
  709. this.className = "l-trigger";
  710. }).mousedown(function ()
  711. {
  712. if (p.disabled) return;
  713. this.className = "l-trigger-pressed";
  714. }).mouseup(function ()
  715. {
  716. if (p.disabled) return;
  717. this.className = "l-trigger-hover";
  718. }).click(function ()
  719. {
  720. if (p.disabled) return;
  721. g.bulidContent();
  722. g.toggleDateEditor(g.dateeditor.is(":visible"));
  723. });
  724. //不可用属性时处理
  725. if (p.disabled)
  726. {
  727. g.inputText.attr("readonly", "readonly");
  728. g.text.addClass('l-text-disabled');
  729. }
  730. g.buttons.btnClose.click(function ()
  731. {
  732. g.toggleDateEditor(true);
  733. });
  734. //日期 点击
  735. $("td", g.body.tbody).hover(function ()
  736. {
  737. if ($(this).hasClass("l-box-dateeditor-today")) return;
  738. $(this).addClass("l-box-dateeditor-over");
  739. }, function ()
  740. {
  741. $(this).removeClass("l-box-dateeditor-over");
  742. }).click(function ()
  743. {
  744. $(".l-box-dateeditor-selected", g.body.tbody).removeClass("l-box-dateeditor-selected");
  745. if (!$(this).hasClass("l-box-dateeditor-today"))
  746. $(this).addClass("l-box-dateeditor-selected");
  747. g.currentDate.date = parseInt($(this).html());
  748. g.currentDate.day = new Date(g.currentDate.year, g.currentDate.month - 1, 1).getDay();
  749. if ($(this).hasClass("l-box-dateeditor-out"))
  750. {
  751. if ($("tr", g.body.tbody).index($(this).parent()) == 0)
  752. {
  753. if (--g.currentDate.month == 0)
  754. {
  755. g.currentDate.month = 12;
  756. g.currentDate.year--;
  757. }
  758. } else
  759. {
  760. if (++g.currentDate.month == 13)
  761. {
  762. g.currentDate.month = 1;
  763. g.currentDate.year++;
  764. }
  765. }
  766. }
  767. g.selectedDate = {
  768. year: g.currentDate.year,
  769. month: g.currentDate.month,
  770. date: g.currentDate.date
  771. };
  772. g.showDate();
  773. g.editorToggling = true;
  774. g.dateeditor.slideToggle('fast', function ()
  775. {
  776. g.editorToggling = false;
  777. });
  778. });
  779. $(".l-box-dateeditor-header-btn", g.header).hover(function ()
  780. {
  781. $(this).addClass("l-box-dateeditor-header-btn-over");
  782. }, function ()
  783. {
  784. $(this).removeClass("l-box-dateeditor-header-btn-over");
  785. });
  786. //选择年份
  787. g.buttons.btnYear.click(function ()
  788. {
  789. //build year list
  790. if (!g.body.yearselector.is(":visible"))
  791. {
  792. $("li", g.body.yearselector).each(function (i, item)
  793. {
  794. var currentYear = g.currentDate.year + (i - 4);
  795. if (currentYear == g.currentDate.year)
  796. $(this).addClass("l-selected");
  797. else
  798. $(this).removeClass("l-selected");
  799. $(this).html(currentYear);
  800. });
  801. }
  802. g.body.yearselector.slideToggle();
  803. });
  804. g.body.yearselector.hover(function () { }, function ()
  805. {
  806. $(this).slideUp();
  807. });
  808. $("li", g.body.yearselector).click(function ()
  809. {
  810. g.currentDate.year = parseInt($(this).html());
  811. g.body.yearselector.slideToggle();
  812. g.bulidContent();
  813. });
  814. //select month
  815. g.buttons.btnMonth.click(function ()
  816. {
  817. $("li", g.body.monthselector).each(function (i, item)
  818. {
  819. //add selected style
  820. if (g.currentDate.month == i + 1)
  821. $(this).addClass("l-selected");
  822. else
  823. $(this).removeClass("l-selected");
  824. });
  825. g.body.monthselector.slideToggle();
  826. });
  827. g.body.monthselector.hover(function () { }, function ()
  828. {
  829. $(this).slideUp("fast");
  830. });
  831. $("li", g.body.monthselector).click(function ()
  832. {
  833. var index = $("li", g.body.monthselector).index(this);
  834. g.currentDate.month = index + 1;
  835. g.body.monthselector.slideToggle();
  836. g.bulidContent();
  837. });
  838. //选择小时
  839. g.toolbar.time.hour.click(function ()
  840. {
  841. $("li", g.body.hourselector).each(function (i, item)
  842. {
  843. //add selected style
  844. if (g.currentDate.hour == i)
  845. $(this).addClass("l-selected");
  846. else
  847. $(this).removeClass("l-selected");
  848. });
  849. g.body.hourselector.slideToggle();
  850. });
  851. g.body.hourselector.hover(function () { }, function ()
  852. {
  853. $(this).slideUp("fast");
  854. });
  855. $("li", g.body.hourselector).click(function ()
  856. {
  857. var index = $("li", g.body.hourselector).index(this);
  858. g.currentDate.hour = index;
  859. g.body.hourselector.slideToggle();
  860. g.bulidContent();
  861. g.showDate();
  862. });
  863. //选择分钟
  864. g.toolbar.time.minute.click(function ()
  865. {
  866. $("li", g.body.minuteselector).each(function (i, item)
  867. {
  868. //add selected style
  869. if (g.currentDate.minute == i)
  870. $(this).addClass("l-selected");
  871. else
  872. $(this).removeClass("l-selected");
  873. });
  874. g.body.minuteselector.slideToggle("fast", function ()
  875. {
  876. var index = $("li", this).index($('li.l-selected', this));
  877. if (index > 29)
  878. {
  879. var offSet = ($('li.l-selected', this).offset().top - $(this).offset().top);
  880. $(this).animate({ scrollTop: offSet });
  881. }
  882. });
  883. });
  884. g.body.minuteselector.hover(function () { }, function ()
  885. {
  886. $(this).slideUp("fast");
  887. });
  888. $("li", g.body.minuteselector).click(function ()
  889. {
  890. var index = $("li", g.body.minuteselector).index(this);
  891. g.currentDate.minute = index;
  892. g.body.minuteselector.slideToggle("fast");
  893. g.bulidContent();
  894. g.showDate();
  895. });
  896. //上个月
  897. g.buttons.btnPrevMonth.click(function ()
  898. {
  899. if (--g.currentDate.month == 0)
  900. {
  901. g.currentDate.month = 12;
  902. g.currentDate.year--;
  903. }
  904. g.bulidContent();
  905. });
  906. //下个月
  907. g.buttons.btnNextMonth.click(function ()
  908. {
  909. if (++g.currentDate.month == 13)
  910. {
  911. g.currentDate.month = 1;
  912. g.currentDate.year++;
  913. }
  914. g.bulidContent();
  915. });
  916. //上一年
  917. g.buttons.btnPrevYear.click(function ()
  918. {
  919. g.currentDate.year--;
  920. g.bulidContent();
  921. });
  922. //下一年
  923. g.buttons.btnNextYear.click(function ()
  924. {
  925. g.currentDate.year++;
  926. g.bulidContent();
  927. });
  928. //今天
  929. g.buttons.btnToday.click(function ()
  930. {
  931. g.currentDate = {
  932. year: g.now.year,
  933. month: g.now.month,
  934. day: g.now.day,
  935. date: g.now.date
  936. };
  937. g.selectedDate = {
  938. year: g.now.year,
  939. month: g.now.month,
  940. day: g.now.day,
  941. date: g.now.date
  942. };
  943. g.showDate();
  944. g.dateeditor.slideToggle("fast");
  945. });
  946. //文本框
  947. g.inputText.change(function ()
  948. {
  949. g.onTextChange();
  950. }).blur(function ()
  951. {
  952. g.text.removeClass("l-text-focus");
  953. }).focus(function ()
  954. {
  955. g.text.addClass("l-text-focus");
  956. });
  957. g.text.hover(function ()
  958. {
  959. g.text.addClass("l-text-over");
  960. }, function ()
  961. {
  962. g.text.removeClass("l-text-over");
  963. });
  964. //LEABEL 支持
  965. if (p.label)
  966. {
  967. g.labelwrapper = g.textwrapper.wrap('<div class="l-labeltext"></div>').parent();
  968. g.labelwrapper.prepend('<div class="l-text-label" style="float:left;display:inline;">' + p.label + ':&nbsp</div>');
  969. g.textwrapper.css('float', 'left');
  970. if (!p.labelWidth)
  971. {
  972. p.labelWidth = $('.l-text-label', g.labelwrapper).outerWidth();
  973. } else
  974. {
  975. $('.l-text-label', g.labelwrapper).outerWidth(p.labelWidth);
  976. }
  977. $('.l-text-label', g.labelwrapper).width(p.labelWidth);
  978. $('.l-text-label', g.labelwrapper).height(g.text.height());
  979. g.labelwrapper.append('<br style="clear:both;" />');
  980. if (p.labelAlign)
  981. {
  982. $('.l-text-label', g.labelwrapper).css('text-align', p.labelAlign);
  983. }
  984. g.textwrapper.css({ display: 'inline' });
  985. g.labelwrapper.width(g.text.outerWidth() + p.labelWidth + 2);
  986. }
  987. g.set(p);
  988. //增加鼠标在日期控件外点击隐藏日期选择框功能
  989. $(document).bind("click.dateeditor", function (e)
  990. {
  991. if (g.dateeditor.is(":visible") && $((e.target || e.srcElement)).closest( ".l-box-dateeditor, .l-text-date" ).length == 0)
  992. {
  993. g.toggleDateEditor(true);
  994. }
  995. });
  996. },
  997. updateSelectBoxPosition: function ()
  998. {
  999. var g = this, p = this.options;
  1000. if (p.absolute)
  1001. {
  1002. var contentHeight = $(document).height();
  1003. /** 定位BUG修复 add by hzp at 20160217 ***********/
  1004. if (Number(g.text.offset().top + 1 + g.text.outerHeight() + g.dateeditor.height()) > contentHeight
  1005. && contentHeight > Number(g.dateeditor.height() + 1))
  1006. {
  1007. //若下拉框大小超过当前document下边框,且当前document上留白大于下拉内容高度,下拉内容向上展现
  1008. g.dateeditor.css({ left: g.text.offset().left, top: g.text.offset().top + 1 - g.dateeditor.height() });
  1009. } else
  1010. {
  1011. g.dateeditor.css({ left: g.text.offset().left, top: g.text.offset().top - 1 + g.text.outerHeight() });
  1012. }
  1013. /********************************************/
  1014. }
  1015. else
  1016. {
  1017. if (g.text.offset().top + 4 > g.dateeditor.height() && g.text.offset().top + g.dateeditor.height() + textHeight + 4 - $(window).scrollTop() > $(window).height())
  1018. {
  1019. g.dateeditor.css("marginTop", -1 * (g.dateeditor.height() + textHeight + 5));
  1020. g.showOnTop = true;
  1021. }
  1022. else
  1023. {
  1024. g.showOnTop = false;
  1025. }
  1026. }
  1027. },
  1028. getValue: function(){
  1029. return $(this.element).val();
  1030. },
  1031. setValue: function (value)
  1032. {
  1033. var g = this;
  1034. if (!value) g.inputText.val('');
  1035. if (typeof value == "string")
  1036. {
  1037. if (/^\/Date/.test(value))
  1038. {
  1039. value = value.replace(/^\//, "new ").replace(/\/$/, "");
  1040. eval("value = " + value);
  1041. }
  1042. /******* 时间格式BUG ***********/
  1043. else{
  1044. if(value.length > g.options.format.length)
  1045. {
  1046. value = value.substr(0,g.options.format.length);
  1047. }
  1048. }
  1049. g.inputText.val(value);
  1050. g.usedDate = value;
  1051. /******* 时间格式BUG ***********/
  1052. g.onTextChange();
  1053. /******************/
  1054. }
  1055. if (typeof value == "object")
  1056. {
  1057. if (value instanceof Date)
  1058. {
  1059. g.inputText.val(g.getFormatDate(value));
  1060. g.onTextChange();
  1061. }
  1062. }
  1063. }
  1064. });
  1065. //重写弹窗控件 add by hzp at 20160217
  1066. $.extend($.ligerui.controls.Dialog.prototype,{
  1067. _setImage: function ()
  1068. {
  1069. var g = this, p = this.options;
  1070. if (p.type)
  1071. {
  1072. /************* 修改弹出对话框样式 *******************************/
  1073. var alertCss = { padding:"10px",textAlign:"center",fontWeight:"bolder",fontSize:"14px",lineHeight:"24px"};
  1074. g.dialog.body.css({width:300});
  1075. /*******************************************************/
  1076. if (p.type == 'success' || p.type == 'donne' || p.type == 'ok')
  1077. {
  1078. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-donne").show();
  1079. g.dialog.content.css(alertCss);
  1080. }
  1081. else if (p.type == 'error')
  1082. {
  1083. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-error").show();
  1084. g.dialog.content.css(alertCss);
  1085. }
  1086. else if (p.type == 'warn')
  1087. {
  1088. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-warn").show();
  1089. g.dialog.content.css(alertCss);
  1090. }
  1091. else if (p.type == 'question')
  1092. {
  1093. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-question").show();
  1094. g.dialog.content.css(alertCss);
  1095. }
  1096. }
  1097. }
  1098. });
  1099. //重写layout控件 add by hzp at 20160229
  1100. $.extend($.ligerui.controls.Layout.prototype,{
  1101. _render: function ()
  1102. {
  1103. var g = this, p = this.options;
  1104. g.layout = $(this.element);
  1105. g.layout.addClass("l-layout");
  1106. g.width = g.layout.width();
  1107. //top
  1108. if ($("> div[position=top]", g.layout).length > 0)
  1109. {
  1110. g.top = $("> div[position=top]", g.layout).wrap('<div class="l-layout-top" style="top:0px;"></div>').parent();
  1111. g.top.content = $("> div[position=top]", g.top);
  1112. if (!g.top.content.hasClass("l-layout-content"))
  1113. g.top.content.addClass("l-layout-content");
  1114. g.topHeight = p.topHeight;
  1115. if (g.topHeight)
  1116. {
  1117. g.top.height(g.topHeight);
  1118. }
  1119. }
  1120. //bottom
  1121. if ($("> div[position=bottom]", g.layout).length > 0)
  1122. {
  1123. g.bottom = $("> div[position=bottom]", g.layout).wrap('<div class="l-layout-bottom"></div>').parent();
  1124. g.bottom.content = $("> div[position=bottom]", g.bottom);
  1125. if (!g.bottom.content.hasClass("l-layout-content"))
  1126. g.bottom.content.addClass("l-layout-content");
  1127. g.bottomHeight = p.bottomHeight;
  1128. if (g.bottomHeight)
  1129. {
  1130. g.bottom.height(g.bottomHeight);
  1131. }
  1132. //set title
  1133. var bottomtitle = g.bottom.content.attr("title");
  1134. if (bottomtitle)
  1135. {
  1136. g.bottom.header = $('<div class="l-layout-header"></div>');
  1137. g.bottom.prepend(g.bottom.header);
  1138. g.bottom.header.html(bottomtitle);
  1139. g.bottom.content.attr("title", "");
  1140. }
  1141. }
  1142. //left
  1143. if ($("> div[position=left]", g.layout).length > 0)
  1144. {
  1145. g.left = $("> div[position=left]", g.layout).wrap('<div class="l-layout-left" style="left:0px;"></div>').parent();
  1146. g.left.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
  1147. g.left.header.toggle = $(".l-layout-header-toggle", g.left.header);
  1148. g.left.content = $("> div[position=left]", g.left);
  1149. if (!g.left.content.hasClass("l-layout-content"))
  1150. g.left.content.addClass("l-layout-content");
  1151. if (!p.allowLeftCollapse) $(".l-layout-header-toggle", g.left.header).remove();
  1152. //set title
  1153. var lefttitle = g.left.content.attr("title");
  1154. if (lefttitle)
  1155. {
  1156. g.left.prepend(g.left.header);
  1157. g.left.content.attr("title", "");
  1158. $(".l-layout-header-inner", g.left.header).html(lefttitle);
  1159. }
  1160. //set title
  1161. if (g.left.content.attr("hidetitle"))
  1162. {
  1163. g.left.content.attr("title", "");
  1164. g.left.header.remove();
  1165. }
  1166. //set width
  1167. g.leftWidth = p.leftWidth;
  1168. if (g.leftWidth)
  1169. g.left.width(g.leftWidth);
  1170. }
  1171. //center
  1172. if ($("> div[position=center]", g.layout).length > 0)
  1173. {
  1174. g.center = $("> div[position=center]", g.layout).wrap('<div class="l-layout-center" ></div>').parent();
  1175. g.center.content = $("> div[position=center]", g.center);
  1176. g.center.content.addClass("l-layout-content");
  1177. //set title
  1178. var centertitle = g.center.content.attr("title");
  1179. if (centertitle)
  1180. {
  1181. g.center.content.attr("title", "");
  1182. g.center.header = $('<div class="l-layout-header"></div>');
  1183. g.center.prepend(g.center.header);
  1184. g.center.header.html(centertitle);
  1185. }
  1186. if (g.center.content.attr("hidetitle"))
  1187. {
  1188. g.center.content.attr("title", "");
  1189. g.center.header.remove();
  1190. }
  1191. //set width
  1192. g.centerWidth = p.centerWidth;
  1193. if (g.centerWidth)
  1194. g.center.width(g.centerWidth);
  1195. //centerBottom
  1196. if ($("> div[position=centerbottom]", g.layout).length > 0)
  1197. {
  1198. g.centerBottom = $("> div[position=centerbottom]", g.layout).wrap('<div class="l-layout-centerbottom" ></div>').parent();
  1199. g.centerBottom.content = $("> div[position=centerbottom]", g.centerBottom);
  1200. g.centerBottom.content.addClass("l-layout-content");
  1201. //set title
  1202. var centertitle = g.centerBottom.content.attr("title");
  1203. if (centertitle)
  1204. {
  1205. g.centerBottom.content.attr("title", "");
  1206. g.centerBottom.header = $('<div class="l-layout-header"></div>');
  1207. g.centerBottom.prepend(g.centerBottom.header);
  1208. g.centerBottom.header.html(centertitle);
  1209. }
  1210. if (g.centerBottom.content.attr("hidetitle"))
  1211. {
  1212. g.centerBottom.content.attr("title", "");
  1213. if (g.centerBottom.header)
  1214. {
  1215. g.centerBottom.header.remove();
  1216. }
  1217. }
  1218. if (g.centerWidth)
  1219. g.centerBottom.width(g.centerWidth);
  1220. }
  1221. }
  1222. //right
  1223. if ($("> div[position=right]", g.layout).length > 0)
  1224. {
  1225. g.right = $("> div[position=right]", g.layout).wrap('<div class="l-layout-right"></div>').parent();
  1226. g.right.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
  1227. g.right.prepend(g.right.header);
  1228. g.right.header.toggle = $(".l-layout-header-toggle", g.right.header);
  1229. if (!p.allowRightCollapse) $(".l-layout-header-toggle", g.right.header).remove();
  1230. g.right.content = $("> div[position=right]", g.right);
  1231. if (!g.right.content.hasClass("l-layout-content"))
  1232. g.right.content.addClass("l-layout-content");
  1233. //set title
  1234. var righttitle = g.right.content.attr("title");
  1235. if (righttitle)
  1236. {
  1237. g.right.content.attr("title", "");
  1238. $(".l-layout-header-inner", g.right.header).html(righttitle);
  1239. }
  1240. if (g.right.content.attr("hidetitle"))
  1241. {
  1242. g.right.content.attr("title", "");
  1243. g.right.header.remove();
  1244. }
  1245. //set width
  1246. g.rightWidth = p.rightWidth;
  1247. if (g.rightWidth)
  1248. g.right.width(g.rightWidth);
  1249. }
  1250. //lock
  1251. g.layout.lock = $("<div class='l-layout-lock'></div>");
  1252. g.layout.append(g.layout.lock);
  1253. //DropHandle
  1254. g._addDropHandle();
  1255. //Collapse
  1256. g.isLeftCollapse = p.isLeftCollapse;
  1257. g.isRightCollapse = p.isRightCollapse;
  1258. g.leftCollapse = $('<div class="l-layout-collapse-left" style="display: none; "><div class="l-layout-collapse-left-toggle"></div></div>');
  1259. g.rightCollapse = $('<div class="l-layout-collapse-right" style="display: none; "><div class="l-layout-collapse-right-toggle"></div></div>');
  1260. g.layout.append(g.leftCollapse).append(g.rightCollapse);
  1261. g.leftCollapse.toggle = $("> .l-layout-collapse-left-toggle", g.leftCollapse);
  1262. g.rightCollapse.toggle = $("> .l-layout-collapse-right-toggle", g.rightCollapse);
  1263. g._setCollapse();
  1264. //init
  1265. g._bulid();
  1266. $(window).resize(function ()
  1267. {
  1268. g._onResize();
  1269. });
  1270. g.set(p);
  1271. g.mask.height(g.layout.height());
  1272. },
  1273. _onResize: function ()
  1274. {
  1275. var g = this, p = this.options;
  1276. var oldheight = g.layout.height();
  1277. //set layout height
  1278. var h = 0;
  1279. var windowHeight = $(window).height();
  1280. var parentHeight = null;
  1281. if (typeof (p.height) == "string" && p.height.indexOf('%') > 0)
  1282. {
  1283. var layoutparent = g.layout.parent();
  1284. if (p.inWindow || layoutparent[0].tagName.toLowerCase() == "body")
  1285. {
  1286. parentHeight = windowHeight;
  1287. parentHeight -= parseInt($('body').css('paddingTop'));
  1288. parentHeight -= parseInt($('body').css('paddingBottom'));
  1289. }
  1290. else
  1291. {
  1292. parentHeight = layoutparent.height();
  1293. }
  1294. h = parentHeight * parseFloat(p.height) * 0.01;
  1295. if (p.inWindow || layoutparent[0].tagName.toLowerCase() == "body")
  1296. h -= (g.layout.offset().top - parseInt($('body').css('paddingTop')));
  1297. /****** 判断是否比外层高 add by hzp at 2016-03-15 **********/
  1298. if(layoutparent.height() >0 && h > layoutparent.height())
  1299. {
  1300. var padding = layoutparent.innerHeight() - layoutparent.height();
  1301. var margin = layoutparent.outerHeight(true) - layoutparent.outerHeight();
  1302. h = layoutparent.height() - padding - margin;
  1303. }
  1304. /*************************************************/
  1305. }
  1306. else
  1307. {
  1308. h = parseInt(p.height);
  1309. }
  1310. h += p.heightDiff;
  1311. g.layout.height(h);
  1312. g.layoutHeight = g.layout.height();
  1313. g.middleWidth = g.layout.width();
  1314. g.middleHeight = g.layout.height();
  1315. if (g.top)
  1316. {
  1317. g.middleHeight -= g.top.height();
  1318. g.middleHeight -= parseInt(g.top.css('borderTopWidth'));
  1319. g.middleHeight -= parseInt(g.top.css('borderBottomWidth'));
  1320. g.middleHeight -= p.space;
  1321. }
  1322. if (g.bottom)
  1323. {
  1324. g.middleHeight -= g.bottom.height();
  1325. g.middleHeight -= parseInt(g.bottom.css('borderTopWidth'));
  1326. g.middleHeight -= parseInt(g.bottom.css('borderBottomWidth'));
  1327. g.middleHeight -= p.space;
  1328. }
  1329. //specific
  1330. g.middleHeight -= 2;
  1331. if (g.hasBind('heightChanged') && g.layoutHeight != oldheight)
  1332. {
  1333. g.trigger('heightChanged', [{ layoutHeight: g.layoutHeight, diff: g.layoutHeight - oldheight, middleHeight: g.middleHeight}]);
  1334. }
  1335. if (g.center)
  1336. {
  1337. g.centerWidth = g.middleWidth;
  1338. if (g.left)
  1339. {
  1340. if (g.isLeftCollapse)
  1341. {
  1342. g.centerWidth -= g.leftCollapse.width();
  1343. g.centerWidth -= parseInt(g.leftCollapse.css('borderLeftWidth'));
  1344. g.centerWidth -= parseInt(g.leftCollapse.css('borderRightWidth'));
  1345. g.centerWidth -= parseInt(g.leftCollapse.css('left'));
  1346. g.centerWidth -= p.space;
  1347. }
  1348. else
  1349. {
  1350. g.centerWidth -= g.leftWidth;
  1351. g.centerWidth -= parseInt(g.left.css('borderLeftWidth'));
  1352. g.centerWidth -= parseInt(g.left.css('borderRightWidth'));
  1353. g.centerWidth -= parseInt(g.left.css('left'));
  1354. g.centerWidth -= p.space;
  1355. }
  1356. }
  1357. if (g.right)
  1358. {
  1359. if (g.isRightCollapse)
  1360. {
  1361. g.centerWidth -= g.rightCollapse.width();
  1362. g.centerWidth -= parseInt(g.rightCollapse.css('borderLeftWidth'));
  1363. g.centerWidth -= parseInt(g.rightCollapse.css('borderRightWidth'));
  1364. g.centerWidth -= parseInt(g.rightCollapse.css('right'));
  1365. g.centerWidth -= p.space;
  1366. }
  1367. else
  1368. {
  1369. g.centerWidth -= g.rightWidth;
  1370. g.centerWidth -= parseInt(g.right.css('borderLeftWidth'));
  1371. g.centerWidth -= parseInt(g.right.css('borderRightWidth'));
  1372. g.centerWidth -= p.space;
  1373. }
  1374. }
  1375. g.centerLeft = 0;
  1376. if (g.left)
  1377. {
  1378. if (g.isLeftCollapse)
  1379. {
  1380. g.centerLeft += g.leftCollapse.width();
  1381. g.centerLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
  1382. g.centerLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
  1383. g.centerLeft += parseInt(g.leftCollapse.css('left'));
  1384. g.centerLeft += p.space;
  1385. }
  1386. else
  1387. {
  1388. g.centerLeft += g.left.width();
  1389. g.centerLeft += parseInt(g.left.css('borderLeftWidth'));
  1390. g.centerLeft += parseInt(g.left.css('borderRightWidth'));
  1391. g.centerLeft += p.space;
  1392. }
  1393. }
  1394. g.center.css({ left: g.centerLeft });
  1395. g.centerWidth >= 0 && g.center.width(g.centerWidth);
  1396. g.middleHeight >= 0 && g.center.height(g.middleHeight);
  1397. var contentHeight = g.middleHeight;
  1398. if (g.center.header) contentHeight -= g.center.header.height();
  1399. var padding = g.center.content.innerHeight() - g.center.content.height();
  1400. var margin = g.center.content.outerHeight(true) - g.center.content.outerHeight();
  1401. contentHeight = contentHeight-padding-margin;
  1402. contentHeight >= 0 && g.center.content.height(contentHeight);
  1403. g._updateCenterBottom(true);
  1404. }
  1405. if (g.left)
  1406. {
  1407. g.leftCollapse.height(g.middleHeight);
  1408. g.left.height(g.middleHeight);
  1409. /********* 左布局高度BUG修复 add by hzp at 20160229 *******/
  1410. var contentHeight = g.middleHeight;
  1411. if (g.left.header) contentHeight -= g.left.header.height();
  1412. var padding = g.left.content.innerHeight() - g.left.content.height();
  1413. var margin = g.left.content.outerHeight(true) - g.left.content.outerHeight();
  1414. contentHeight = contentHeight-padding-margin;
  1415. contentHeight >= 0 && g.left.content.height(contentHeight);
  1416. /***************************************************/
  1417. }
  1418. if (g.right)
  1419. {
  1420. g.rightCollapse.height(g.middleHeight);
  1421. g.right.height(g.middleHeight);
  1422. //set left
  1423. g.rightLeft = 0;
  1424. if (g.left)
  1425. {
  1426. if (g.isLeftCollapse)
  1427. {
  1428. g.rightLeft += g.leftCollapse.width();
  1429. g.rightLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
  1430. g.rightLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
  1431. g.rightLeft += p.space;
  1432. }
  1433. else
  1434. {
  1435. g.rightLeft += g.left.width();
  1436. g.rightLeft += parseInt(g.left.css('borderLeftWidth'));
  1437. g.rightLeft += parseInt(g.left.css('borderRightWidth'));
  1438. g.rightLeft += parseInt(g.left.css('left'));
  1439. g.rightLeft += p.space;
  1440. }
  1441. }
  1442. if (g.center)
  1443. {
  1444. g.rightLeft += g.center.width();
  1445. g.rightLeft += parseInt(g.center.css('borderLeftWidth'));
  1446. g.rightLeft += parseInt(g.center.css('borderRightWidth'));
  1447. g.rightLeft += p.space;
  1448. }
  1449. g.right.css({ left: g.rightLeft });
  1450. }
  1451. if (g.bottom)
  1452. {
  1453. g.bottomTop = g.layoutHeight - g.bottom.height() - 2;
  1454. g.bottom.css({ top: g.bottomTop });
  1455. }
  1456. g._setDropHandlePosition();
  1457. }
  1458. });
  1459. //重写数值控件 add by hzp at 20160308
  1460. $.extend($.ligerDefaults.DateEditor,{
  1461. isNegative:false
  1462. });
  1463. $.extend($.ligerui.controls.Spinner.prototype,{
  1464. _showValue: function (value)
  1465. {
  1466. var g = this, p = this.options;
  1467. /**** 默认值为空 ************/
  1468. if (!value || value == "NaN") value = "";
  1469. /***************************/
  1470. if (p.type == 'float')
  1471. {
  1472. value = parseFloat(value).toFixed(p.decimalplace);
  1473. }
  1474. this.inputText.val(value)
  1475. }
  1476. });
  1477. //重写Tip控件 add by hzp at 20160314
  1478. $.extend($.ligerui.controls.Tip.prototype,{
  1479. _render: function ()
  1480. {
  1481. var g = this, p = this.options;
  1482. var tip = $('<div class="l-verify-tip"><div class="l-verify-tip-corner"></div><div class="l-verify-tip-content"></div></div>');
  1483. g.tip = tip;
  1484. g.tip.attr("id", g.id);
  1485. if (p.content)
  1486. {
  1487. $("> .l-verify-tip-content:first", tip).html(p.content);
  1488. tip.appendTo('body');
  1489. }
  1490. else
  1491. {
  1492. return;
  1493. }
  1494. /************* 样式调整修改 *********************************/
  1495. tip.css({ left: p.x, top: p.y+3 }).show();
  1496. p.width && $("> .l-verify-tip-content:first", tip).width(p.width - 36);
  1497. /**********************************************/
  1498. p.height && $("> .l-verify-tip-content:first", tip).width(p.height);
  1499. eee = p.appendIdTo;
  1500. if (p.appendIdTo)
  1501. {
  1502. p.appendIdTo.attr("ligerTipId", g.id);
  1503. }
  1504. if (p.target)
  1505. {
  1506. $(p.target).attr("ligerTipId", g.id);
  1507. p.target.ligeruitipid = g.id;
  1508. }
  1509. p.callback && p.callback(tip);
  1510. g.set(p);
  1511. },
  1512. });
  1513. })(jQuery, window);