ligerOverwrite.js 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990
  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 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. _setDisabled: function (value)
  200. {
  201. //禁用样式
  202. if (value)
  203. {
  204. this.wrapper.addClass('l-text-disabled');
  205. $(".l-trigger-cancel").remove();
  206. } else
  207. {
  208. this.wrapper.removeClass('l-text-disabled');
  209. }
  210. },
  211. //获取扩展字段
  212. getExtendValue: function () {
  213. try {
  214. var me = this;
  215. var options = me.options;
  216. var selected = me.selectedValue;
  217. for (var i = 0; i < me.data.length; i++) {
  218. var item = me.data[i];
  219. if (item[options.valueField] == selected) {
  220. return item[options.extendField];
  221. }
  222. }
  223. }
  224. catch (e) {
  225. return "";
  226. }
  227. }
  228. });
  229. //重写Grid控件 add by hzp at 20160107
  230. $.extend($.ligerDefaults.Grid, {
  231. // 存储总记录数的字段名
  232. record: 'totalCount',
  233. // 数据源字段名
  234. root: 'detailModelList',
  235. // 每页记录数
  236. pageSize: 20,
  237. // 页记录数参数名,(提交给服务器)
  238. pagesizeParmName: 'rows',
  239. // 高度补差,当设置height:100%时,可能会有高度的误差,可以通过这个属性调整
  240. heightDiff: -14,
  241. height: '100%',
  242. // 是否显示行序号
  243. rownumbers: true,
  244. // 表头行的高度
  245. headerRowHeight: 40,
  246. // 行的高度
  247. rowHeight: 40,
  248. // 编辑器位置误差调整
  249. editorTopDiff: 1,
  250. allowAdjustColWidth: true
  251. });
  252. $.extend($.ligerui.controls.Grid.prototype, {
  253. _setHeight: function (h) {
  254. var g = this, p = this.options;
  255. g.unbind("SysGridHeightChanged");
  256. if (h == "auto")
  257. {
  258. g.bind("SysGridHeightChanged", function ()
  259. {
  260. if (g.enabledFrozen())
  261. g.gridview.height(Math.max(g.gridview1.height(), g.gridview2.height()));
  262. });
  263. return;
  264. }
  265. h = g._calculateGridBodyHeight(h);
  266. if (h > 0)
  267. {
  268. /** 列表高度计算bug修改 **/
  269. var gridHeaderHeight = (p.headerRowHeight+1) * (g._columnMaxLevel - 1) + p.headerRowHeight + 1;
  270. /***********************/
  271. /******** 隐藏表头 add by hzp at 2016-05-05 ************/
  272. if(p.hideHeader)
  273. {
  274. h += 41;
  275. g.gridheader.hide();
  276. gridHeaderHeight = 0;
  277. }
  278. /*****************************************************/
  279. g.gridbody.height(h);
  280. if (p.frozen)
  281. {
  282. /*** 滚动条样式修改 add by hzp at 20160215***/
  283. //解决冻结列和活动列由上至下滚动错位的问题
  284. var w = g.gridbody.width(), w2 = $(":first-child", g.gridbody).width();
  285. if (w2 && (w2 + 6 >= w))
  286. {
  287. if (h > 6)
  288. g.f.gridbody.height(h - 6);
  289. }
  290. else
  291. {
  292. g.f.gridbody.height(h);
  293. }
  294. /********************************************/
  295. }
  296. g.gridview.height(h + gridHeaderHeight);
  297. }
  298. g._updateHorizontalScrollStatus.ligerDefer(g, 10);
  299. },
  300. //是否固定列
  301. _onResize: function ()
  302. {
  303. var g = this, p = this.options;
  304. if (p.height && p.height != 'auto')
  305. {
  306. var windowHeight = $(window).height();
  307. //if(g.windowHeight != undefined && g.windowHeight == windowHeight) return;
  308. var h = 0;
  309. var parentHeight = null;
  310. if (typeof (p.height) == "string" && p.height.indexOf('%') > 0)
  311. {
  312. var gridparent = g.grid.parent();
  313. if (p.inWindow)
  314. {
  315. parentHeight = windowHeight;
  316. parentHeight -= parseInt($('body').css('paddingTop'));
  317. parentHeight -= parseInt($('body').css('paddingBottom'));
  318. }
  319. else
  320. {
  321. parentHeight = gridparent.height();
  322. }
  323. h = parentHeight * parseInt(p.height) * 0.01;
  324. if (p.inWindow || gridparent[0].tagName.toLowerCase() == "body")
  325. h -= (g.grid.offset().top - parseInt($('body').css('paddingTop')));
  326. }
  327. else
  328. {
  329. h = parseInt(p.height);
  330. }
  331. h += p.heightDiff;
  332. g.windowHeight = windowHeight;
  333. g._setHeight(h);
  334. }
  335. else
  336. {
  337. g._updateHorizontalScrollStatus.ligerDefer(g, 10);
  338. }
  339. if (g.enabledFrozen())
  340. {
  341. var gridView1Width = g.gridview1.width();
  342. var gridViewWidth = g.gridview.width();
  343. g.gridview2.css({
  344. width: gridViewWidth - gridView1Width
  345. });
  346. if(gridView1Width>0)
  347. {
  348. g.gridview1.css({
  349. position:"absolute",
  350. top:"0px",
  351. left:"0px"
  352. }).show();
  353. g.gridview2.css({
  354. position:"absolute",
  355. top:"0px"
  356. });
  357. }
  358. }
  359. else{
  360. var gridView1Width = g.gridview1.width();
  361. var gridViewWidth = g.gridview.width();
  362. if(gridView1Width>0)
  363. {
  364. g.gridview1.hide();
  365. g.gridview2.css({
  366. position:"absolute",
  367. left:"0px",
  368. width: gridViewWidth
  369. });
  370. }
  371. }
  372. g.trigger('SysGridHeightChanged');
  373. },
  374. _calculateGridBodyHeight: function (h) {
  375. var g = this, p = this.options;
  376. if (typeof h == "string" && h.indexOf('%') > 0) {
  377. if (p.inWindow)
  378. h = $(window).height() * parseInt(h) * 0.01;
  379. else
  380. h = g.grid.parent().height() * parseInt(h) * 0.01;
  381. }
  382. if (p.title) h -= 24;
  383. /*** 隐藏分页 高度BUG修复 add by hzp at20160121 **/
  384. if (p.usePager && (p.pagerRender || !p.scrollToPage)) h -= g.toolbar.outerHeight();
  385. /******************************/
  386. if (p.totalRender) h -= 25;
  387. if (p.toolbar) h -= g.topbar.outerHeight();
  388. /** 列表高度计算bug修改 **/
  389. var gridHeaderHeight = (p.headerRowHeight+1) * (g._columnMaxLevel - 1) + p.headerRowHeight + 1;
  390. /***********************/
  391. h -= (gridHeaderHeight || 0);
  392. return h;
  393. },
  394. getColumns: function (columnLevel) {
  395. var g = this, p = this.options;
  396. var columns = [];
  397. for (var id in g._columns) {
  398. var col = g._columns[id];
  399. /********* 字典列翻译 ***********/
  400. if (col['dict']) {
  401. var dictName = col.dictName;
  402. //提前加载字典
  403. $.ehrDict.getDictData(dictName, col.dictType, col.dictWhere);
  404. //渲染字典字段
  405. col.render = function (row, index, data, _col) {
  406. var dict = $.ehrDict.getDictData(_col.dictName, col.dictType, col.dictWhere, function (response) {
  407. g.refreshColumn(_col.dictName, response);
  408. });
  409. dict = $.ehrDict.listToDict(dict);
  410. if (dict != null) {
  411. if (dict[data] != null) {
  412. return dict[data].value;
  413. }
  414. else {
  415. return data;
  416. }
  417. }
  418. else {
  419. return "";
  420. }
  421. }
  422. }
  423. /********************/
  424. if (columnLevel != undefined) {
  425. if (col['__level'] == columnLevel) columns.push(col);
  426. }
  427. else {
  428. if (col['__leaf']) columns.push(col);
  429. }
  430. }
  431. return columns;
  432. },
  433. //字典返回后刷新列值
  434. refreshColumn: function (dictName, dict) {
  435. try {
  436. var me = this;
  437. for (var i = 0; i < me.columns.length; i++) {
  438. var col = me.columns[i];
  439. if (col.dict && col.dictName == dictName) {
  440. var colName = col.columnname;
  441. $.each($.find("td[id$='|" + col.__id + "']", me.gridbody[0]), function (index, obj) {
  442. var code = me.rows[index][colName];
  443. var cell = $.find("div.l-grid-row-cell-inner", obj)[0];
  444. if (dict[code] != null) {
  445. var val = dict[code].value;
  446. if (val != undefined && val != null) {
  447. $(cell).html(val);
  448. }
  449. }
  450. else {
  451. $(cell).html(code);
  452. }
  453. });
  454. }
  455. }
  456. }
  457. catch (e) {
  458. return;
  459. }
  460. },
  461. queryByText: function (filedName, text) {
  462. var data = this.data.detailModelList;
  463. for (var i = 0; i < data.length; i++) {
  464. var obj=JSON.stringify(data[i]);
  465. var r = eval("("+obj+"." + filedName+")");
  466. if (r.indexOf(text) >= 0) {
  467. this.select(data[i]);
  468. break;
  469. }
  470. }
  471. }
  472. });
  473. //重写树函数 add by hzp at 20160107
  474. $.extend($.ligerDefaults.Tree, {
  475. checkbox:false,
  476. parentIcon:false,
  477. childIcon:false,
  478. treeLine:false
  479. });
  480. $.extend($.ligerui.controls.Tree.prototype, {
  481. _upadteTreeWidth: function ()
  482. {
  483. var g = this, p = this.options;
  484. var treeWidth = g.maxOutlineLevel * 22;
  485. if (p.checkbox) treeWidth += 22;
  486. if (p.parentIcon || p.childIcon) treeWidth += 22;
  487. treeWidth += p.nodeWidth;
  488. treeWidth = p.adjustToWidth? $(g.element).width(): treeWidth; // TODO [代码片段001][修复树宽度自适应问题][yezehua]
  489. g.tree.width(treeWidth);
  490. },
  491. getDataByID: function (id) {
  492. var g = this, p = this.options;
  493. var data = null;
  494. if (g.data && g.data.length) {
  495. return find(g.data);
  496. }
  497. function find(items) {
  498. for (var i = 0; i < items.length; i++) {
  499. var dataItem = items[i];
  500. if (dataItem[p.idFieldName] == id) return dataItem;
  501. if (dataItem.children && dataItem.children.length) {
  502. /*** BUG修复 ***/
  503. var pre = find(dataItem.children);
  504. if (pre != null) return pre;
  505. /*************/
  506. }
  507. }
  508. return null;
  509. }
  510. $("li", g.tree).each(function () {
  511. if (data) return;
  512. var treeitem = $(this);
  513. var treedataindex = parseInt(treeitem.attr("treedataindex"));
  514. var treenodedata = g._getDataNodeByTreeDataIndex(g.data, treedataindex);
  515. if (treenodedata[p.idFieldName].toString() == id.toString()) {
  516. data = treenodedata;
  517. }
  518. });
  519. return data;
  520. },
  521. /**
  522. * 扩展方法1:
  523. * queryByText: 根据名字找出树的节点,并且打开节点
  524. */
  525. queryByText: function (text) {
  526. var $g = this, p = this.options;
  527. var nodeText = $("span", $g.tree);
  528. for (var i = 0; i < nodeText.length; i++) {
  529. if ($(nodeText[i]).text().indexOf(text) >= 0) {
  530. var id = $(nodeText[i]).closest("li").attr("id");
  531. $g.expandNode(id);
  532. $g.selectNode(id);
  533. break;
  534. }
  535. }
  536. },
  537. /**
  538. * expandNode:根据id打开节点
  539. * @param id
  540. */
  541. expandNode: function (id) {
  542. var $li = $("#" + id, this.tree).closest("li");
  543. var outlinelevel = $li.attr("outlinelevel");
  544. for (var j = 0; j < outlinelevel; j++) {
  545. if (j == 0) {
  546. $li.parent().parent().children(".l-body").children(".l-expandable-close").removeClass("l-expandable-close").addClass("l-expandable-open");
  547. $li = $li.parent().show();
  548. } else {
  549. $li.parent().children(".l-body").children(".l-expandable-close").removeClass("l-expandable-close").addClass("l-expandable-open");
  550. $li = $li.parent().parent().show();
  551. }
  552. }
  553. },
  554. /**
  555. * 扩展方法2:子节点是否全选
  556. * @param treenodedata
  557. * @returns {boolean}
  558. */
  559. isIncomplete: function (treenodedata)
  560. {
  561. var str = JSON.stringify(treenodedata.children);
  562. return (str.indexOf('"ischecked":null')!=-1 || str.indexOf('"ischecked":false')!=-1)
  563. && str.indexOf('"ischecked":true')!=-1;
  564. },
  565. //根据data生成最终完整的tree html
  566. _getTreeHTMLByData: function (data, outlineLevel, isLast, isExpand)
  567. {
  568. var g = this, p = this.options;
  569. if (g.maxOutlineLevel < outlineLevel)
  570. g.maxOutlineLevel = outlineLevel;
  571. isLast = isLast || [];
  572. outlineLevel = outlineLevel || 1;
  573. var treehtmlarr = [];
  574. if (!isExpand) treehtmlarr.push('<ul class="l-children" style="display:none">');
  575. else treehtmlarr.push("<ul class='l-children'>");
  576. for (var i = 0; i < data.length; i++)
  577. {
  578. var o = data[i];
  579. var isFirst = i == 0;
  580. var isLastCurrent = i == data.length - 1;
  581. var delay = g._getDelay(o, outlineLevel);
  582. var isExpandCurrent = delay ? false : g._isExpand(o, outlineLevel);
  583. treehtmlarr.push('<li ');
  584. if (o.treedataindex != undefined)
  585. treehtmlarr.push('treedataindex="' + o.treedataindex + '" ');
  586. if (isExpandCurrent)
  587. treehtmlarr.push('isexpand=' + o.isexpand + ' ');
  588. treehtmlarr.push('outlinelevel=' + outlineLevel + ' ');
  589. //增加属性支持
  590. for (var j = 0; j < g.sysAttribute.length; j++)
  591. {
  592. if ($(this).attr(g.sysAttribute[j]))
  593. data[dataindex][g.sysAttribute[j]] = $(this).attr(g.sysAttribute[j]);
  594. }
  595. for (var j = 0; j < p.attribute.length; j++)
  596. {
  597. if (o[p.attribute[j]])
  598. treehtmlarr.push(p.attribute[j] + '="' + o[p.attribute[j]] + '" ');
  599. }
  600. //css class
  601. treehtmlarr.push('class="');
  602. isFirst && treehtmlarr.push('l-first ');
  603. isLastCurrent && treehtmlarr.push('l-last ');
  604. isFirst && isLastCurrent && treehtmlarr.push('l-onlychild ');
  605. treehtmlarr.push('"');
  606. treehtmlarr.push('>');
  607. treehtmlarr.push('<div class="l-body');
  608. if (p.selectable && p.selectable(o) == false)
  609. {
  610. treehtmlarr.push(' l-unselectable');
  611. }
  612. treehtmlarr.push('">');
  613. for (var k = 0; k <= outlineLevel - 2; k++)
  614. {
  615. if (isLast[k]) treehtmlarr.push('<div class="l-box"></div>');
  616. else treehtmlarr.push('<div class="l-box l-line"></div>');
  617. }
  618. if (g.hasChildren(o))
  619. {
  620. if (isExpandCurrent) treehtmlarr.push('<div class="l-box l-expandable-open"></div>');
  621. else treehtmlarr.push('<div class="l-box l-expandable-close"></div>');
  622. if (p.checkbox)
  623. {
  624. if (o.ischecked)
  625. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-checked"></div>');
  626. // TODO add by lincl start
  627. else if(g.isIncomplete(o))
  628. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-incomplete"></div>');
  629. // add by lincl end
  630. else
  631. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-unchecked"></div>');
  632. }
  633. if (p.parentIcon)
  634. {
  635. //node icon
  636. treehtmlarr.push('<div class="l-box l-tree-icon ');
  637. treehtmlarr.push(g._getParentNodeClassName(isExpandCurrent ? true : false) + " ");
  638. if (p.iconFieldName && o[p.iconFieldName])
  639. treehtmlarr.push('l-tree-icon-none');
  640. treehtmlarr.push('">');
  641. if (p.iconFieldName && o[p.iconFieldName])
  642. treehtmlarr.push('<img src="' + o[p.iconFieldName] + '" />');
  643. treehtmlarr.push('</div>');
  644. }
  645. }
  646. else
  647. {
  648. if (isLastCurrent) treehtmlarr.push('<div class="l-box l-note-last"></div>');
  649. else treehtmlarr.push('<div class="l-box l-note"></div>');
  650. if (p.checkbox)
  651. {
  652. if (o.ischecked)
  653. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-checked"></div>');
  654. else
  655. treehtmlarr.push('<div class="l-box l-checkbox l-checkbox-unchecked"></div>');
  656. }
  657. if (p.childIcon)
  658. {
  659. //node icon
  660. treehtmlarr.push('<div class="l-box l-tree-icon ');
  661. treehtmlarr.push(g._getChildNodeClassName() + " ");
  662. if (p.iconFieldName && o[p.iconFieldName])
  663. treehtmlarr.push('l-tree-icon-none');
  664. treehtmlarr.push('">');
  665. if (p.iconFieldName && o[p.iconFieldName])
  666. treehtmlarr.push('<img src="' + o[p.iconFieldName] + '" />');
  667. treehtmlarr.push('</div>');
  668. }
  669. }
  670. if (p.render)
  671. {
  672. //treehtmlarr.push('<span>' + p.render(o, o[p.textFieldName]) + '</span>');
  673. treehtmlarr.push('<span title="'+ o[p.textFieldName] +'">' + p.render(o, o[p.textFieldName]) + '</span>');
  674. } else
  675. {
  676. // treehtmlarr.push('<span>' + o[p.textFieldName] + '</span>');
  677. treehtmlarr.push('<span title="'+ o[p.textFieldName] +'">' + o[p.textFieldName] + '</span>');
  678. }
  679. treehtmlarr.push('</div>');
  680. if (g.hasChildren(o))
  681. {
  682. var isLastNew = [];
  683. for (var k = 0; k < isLast.length; k++)
  684. {
  685. isLastNew.push(isLast[k]);
  686. }
  687. isLastNew.push(isLastCurrent);
  688. if (delay)
  689. {
  690. if (delay == true)
  691. {
  692. g.toggleNodeCallbacks.push({
  693. data: o,
  694. callback: function (dom, o)
  695. {
  696. var content = g._getTreeHTMLByData(o.children, outlineLevel + 1, isLastNew, isExpandCurrent).join('');
  697. $(dom).append(content);
  698. $(">.l-children .l-body", dom).hover(function ()
  699. {
  700. $(this).addClass("l-over");
  701. }, function ()
  702. {
  703. $(this).removeClass("l-over");
  704. });
  705. g._removeToggleNodeCallback(o);
  706. }
  707. });
  708. }
  709. else if (delay.url)
  710. {
  711. (function (o, url, parms)
  712. {
  713. g.toggleNodeCallbacks.push({
  714. data: o,
  715. callback: function (dom, o)
  716. {
  717. g.loadData(dom, url, parms, {
  718. showLoading: function ()
  719. {
  720. $("div.l-expandable-close:first", dom).addClass("l-box-loading");
  721. },
  722. hideLoading: function ()
  723. {
  724. $("div.l-box-loading:first", dom).removeClass("l-box-loading");
  725. }
  726. });
  727. g._removeToggleNodeCallback(o);
  728. }
  729. });
  730. })(o, delay.url, delay.parms);
  731. }
  732. }
  733. else
  734. {
  735. treehtmlarr.push(g._getTreeHTMLByData(o.children, outlineLevel + 1, isLastNew, isExpandCurrent).join(''));
  736. }
  737. }
  738. treehtmlarr.push('</li>');
  739. }
  740. treehtmlarr.push("</ul>");
  741. return treehtmlarr;
  742. }
  743. });
  744. //重写radio方法 add by hzp at 20160107
  745. $.extend($.ligerui.controls.Radio.prototype, {
  746. setValue: function (val) {
  747. var name = this.element.name;
  748. $('input[name="' + name + '"]').each(function () {
  749. var typeObj = $(this).closest('.l-radio-wrapper').find('a.l-radio');
  750. if (this.value == val) {
  751. typeObj.addClass("l-radio-checked");
  752. this.checked = true;
  753. }
  754. else {
  755. typeObj.removeClass("l-radio-checked");
  756. this.checked = false;
  757. }
  758. });
  759. },
  760. getValue: function () {
  761. var name = this.element.name;
  762. var re = "";
  763. $('input[name="' + name + '"]').each(function () {
  764. if (this.checked) {
  765. re = this.value;
  766. return;
  767. }
  768. });
  769. return re;
  770. }
  771. });
  772. //重写CheckBox方法 add by hzp at 20160107
  773. $.extend($.ligerui.controls.CheckBox.prototype, {
  774. setValue: function (val) {
  775. var name = this.element.name;
  776. var vals = null;
  777. if (val != null && val.length > 0) {
  778. vals = val.split(',');
  779. }
  780. $('input[name="' + name + '"]').each(function () {
  781. var typeObj = $(this).closest('.l-checkbox-wrapper').find('a.l-checkbox');
  782. var isChecked = false;
  783. if (vals != null) {
  784. for (var i = 0; i < vals.length; i++) {
  785. if (this.value == vals[i]) {
  786. isChecked = true;
  787. }
  788. }
  789. }
  790. if (isChecked) {
  791. typeObj.addClass("l-checkbox-checked");
  792. this.checked = true;
  793. }
  794. else {
  795. typeObj.removeClass("l-checkbox-checked");
  796. this.checked = false;
  797. }
  798. });
  799. },
  800. getValue: function () {
  801. var name = this.element.name;
  802. var re = "";
  803. $('input[name="' + name + '"]').each(function () {
  804. if (this.checked) {
  805. re += this.value + ",";
  806. }
  807. });
  808. if (re.length > 0) {
  809. re = re.substr(0, re.length - 1);
  810. }
  811. return re;
  812. }
  813. });
  814. //重写时间控件方法 add by hzp at 20160107
  815. $.extend($.ligerDefaults.DateEditor,{
  816. format: "yyyy-MM-dd hh:mm:ss"
  817. });
  818. $.extend($.ligerui.controls.DateEditor.prototype, {
  819. getYear: function () {
  820. return this.currentDate.year;
  821. },
  822. getMonth: function () {
  823. return this.currentDate.month;
  824. },
  825. getDate: function () {
  826. return this.currentDate.date;
  827. },
  828. getHour: function () {
  829. return this.currentDate.hour;
  830. },
  831. getMinute: function () {
  832. return this.currentDate.minute;
  833. },
  834. _render: function ()
  835. {
  836. var g = this, p = this.options;
  837. /**** 增加秒显示 *****/
  838. if (!p.showTime && p.format.indexOf(" hh:mm:ss") > -1)
  839. p.format = p.format.replace(" hh:mm:ss", "");
  840. /********************/
  841. if (this.element.tagName.toLowerCase() != "input" || this.element.type != "text")
  842. return;
  843. g.inputText = $(this.element);
  844. if (!g.inputText.hasClass("l-text-field"))
  845. g.inputText.addClass("l-text-field");
  846. g.link = $('<div class="l-trigger"><div class="l-trigger-icon"></div></div>');
  847. g.text = g.inputText.wrap('<div class="l-text l-text-date"></div>').parent();
  848. g.text.append('<div class="l-text-l"></div><div class="l-text-r"></div>');
  849. g.text.append(g.link);
  850. //添加个包裹,
  851. g.textwrapper = g.text.wrap('<div class="l-text-wrapper"></div>').parent();
  852. var dateeditorHTML = "";
  853. dateeditorHTML += "<div class='l-box-dateeditor' style='display:none'>";
  854. dateeditorHTML += " <div class='l-box-dateeditor-header'>";
  855. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-prevyear'><span></span></div>";
  856. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-prevmonth'><span></span></div>";
  857. 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>";
  858. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-nextmonth'><span></span></div>";
  859. dateeditorHTML += " <div class='l-box-dateeditor-header-btn l-box-dateeditor-header-nextyear'><span></span></div>";
  860. dateeditorHTML += " </div>";
  861. dateeditorHTML += " <div class='l-box-dateeditor-body'>";
  862. dateeditorHTML += " <table cellpadding='0' cellspacing='0' border='0' class='l-box-dateeditor-calendar'>";
  863. dateeditorHTML += " <thead>";
  864. 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>";
  865. dateeditorHTML += " </thead>";
  866. dateeditorHTML += " <tbody>";
  867. 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>";
  868. dateeditorHTML += " </tbody>";
  869. dateeditorHTML += " </table>";
  870. 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>";
  871. 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>";
  872. 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>";
  873. 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>";
  874. dateeditorHTML += " </div>";
  875. dateeditorHTML += " <div class='l-box-dateeditor-toolbar'>";
  876. /**************** 添加“时间:”标识 add by hzp at 20160217 *********/
  877. dateeditorHTML += " <div class='l-box-dateeditor-time'>时间:</div>";
  878. /********************************************************/
  879. dateeditorHTML += " <div class='l-button l-button-today'></div>";
  880. dateeditorHTML += " <div class='l-button l-button-close'></div>";
  881. dateeditorHTML += " <div class='l-clear'></div>";
  882. dateeditorHTML += " </div>";
  883. dateeditorHTML += "</div>";
  884. g.dateeditor = $(dateeditorHTML);
  885. if (p.absolute)
  886. g.dateeditor.appendTo('body').addClass("l-box-dateeditor-absolute");
  887. else
  888. g.textwrapper.append(g.dateeditor);
  889. g.header = $(".l-box-dateeditor-header", g.dateeditor);
  890. g.body = $(".l-box-dateeditor-body", g.dateeditor);
  891. g.toolbar = $(".l-box-dateeditor-toolbar", g.dateeditor);
  892. g.body.thead = $("thead", g.body);
  893. g.body.tbody = $("tbody", g.body);
  894. g.body.monthselector = $(".l-box-dateeditor-monthselector", g.body);
  895. g.body.yearselector = $(".l-box-dateeditor-yearselector", g.body);
  896. g.body.hourselector = $(".l-box-dateeditor-hourselector", g.body);
  897. g.body.minuteselector = $(".l-box-dateeditor-minuteselector", g.body);
  898. g.toolbar.time = $(".l-box-dateeditor-time", g.toolbar);
  899. g.toolbar.time.hour = $("<a></a>");
  900. g.toolbar.time.minute = $("<a></a>");
  901. g.buttons = {
  902. btnPrevYear: $(".l-box-dateeditor-header-prevyear", g.header),
  903. btnNextYear: $(".l-box-dateeditor-header-nextyear", g.header),
  904. btnPrevMonth: $(".l-box-dateeditor-header-prevmonth", g.header),
  905. btnNextMonth: $(".l-box-dateeditor-header-nextmonth", g.header),
  906. btnYear: $(".l-box-dateeditor-header-year", g.header),
  907. btnMonth: $(".l-box-dateeditor-header-month", g.header),
  908. btnToday: $(".l-button-today", g.toolbar),
  909. btnClose: $(".l-button-close", g.toolbar)
  910. };
  911. var nowDate = new Date();
  912. g.now = {
  913. year: nowDate.getFullYear(),
  914. month: nowDate.getMonth() + 1, //注意这里
  915. day: nowDate.getDay(),
  916. date: nowDate.getDate(),
  917. hour: nowDate.getHours(),
  918. minute: nowDate.getMinutes()
  919. };
  920. //当前的时间
  921. g.currentDate = {
  922. year: nowDate.getFullYear(),
  923. month: nowDate.getMonth() + 1,
  924. day: nowDate.getDay(),
  925. date: nowDate.getDate(),
  926. hour: nowDate.getHours(),
  927. minute: nowDate.getMinutes()
  928. };
  929. //选择的时间
  930. g.selectedDate = null;
  931. //使用的时间
  932. g.usedDate = null;
  933. //初始化数据
  934. //设置周日至周六
  935. $("td", g.body.thead).each(function (i, td)
  936. {
  937. $(td).html(p.dayMessage[i]);
  938. });
  939. //设置一月到十一二月
  940. $("li", g.body.monthselector).each(function (i, li)
  941. {
  942. $(li).html(p.monthMessage[i]);
  943. });
  944. //设置按钮
  945. g.buttons.btnToday.html(p.todayMessage);
  946. g.buttons.btnClose.html(p.closeMessage);
  947. //设置时间
  948. if (p.showTime)
  949. {
  950. g.toolbar.time.show();
  951. g.toolbar.time.append(g.toolbar.time.hour).append(":").append(g.toolbar.time.minute);
  952. $("li", g.body.hourselector).each(function (i, item)
  953. {
  954. var str = i;
  955. if (i < 10) str = "0" + i.toString();
  956. $(this).html(str);
  957. });
  958. $("li", g.body.minuteselector).each(function (i, item)
  959. {
  960. var str = i;
  961. if (i < 10) str = "0" + i.toString();
  962. $(this).html(str);
  963. });
  964. }
  965. //设置主体
  966. g.bulidContent();
  967. //初始化
  968. //初始值
  969. if (p.initValue)
  970. {
  971. g.inputText.val(p.initValue);
  972. }
  973. if (g.inputText.val() != "")
  974. {
  975. g.onTextChange();
  976. }
  977. /**************
  978. **bulid evens**
  979. *************/
  980. g.dateeditor.hover(null, function (e)
  981. {
  982. if (g.dateeditor.is(":visible") && !g.editorToggling)
  983. {
  984. g.toggleDateEditor(true);
  985. }
  986. });
  987. //toggle even
  988. g.link.hover(function ()
  989. {
  990. if (p.disabled) return;
  991. this.className = "l-trigger-hover";
  992. }, function ()
  993. {
  994. if (p.disabled) return;
  995. this.className = "l-trigger";
  996. }).mousedown(function ()
  997. {
  998. if (p.disabled) return;
  999. this.className = "l-trigger-pressed";
  1000. }).mouseup(function ()
  1001. {
  1002. if (p.disabled) return;
  1003. this.className = "l-trigger-hover";
  1004. }).click(function ()
  1005. {
  1006. if (p.disabled) return;
  1007. g.bulidContent();
  1008. g.toggleDateEditor(g.dateeditor.is(":visible"));
  1009. });
  1010. //不可用属性时处理
  1011. if (p.disabled)
  1012. {
  1013. g.inputText.attr("readonly", "readonly");
  1014. g.text.addClass('l-text-disabled');
  1015. }
  1016. g.buttons.btnClose.click(function ()
  1017. {
  1018. g.toggleDateEditor(true);
  1019. });
  1020. //日期 点击
  1021. $("td", g.body.tbody).hover(function ()
  1022. {
  1023. if ($(this).hasClass("l-box-dateeditor-today")) return;
  1024. $(this).addClass("l-box-dateeditor-over");
  1025. }, function ()
  1026. {
  1027. $(this).removeClass("l-box-dateeditor-over");
  1028. }).click(function ()
  1029. {
  1030. $(".l-box-dateeditor-selected", g.body.tbody).removeClass("l-box-dateeditor-selected");
  1031. if (!$(this).hasClass("l-box-dateeditor-today"))
  1032. $(this).addClass("l-box-dateeditor-selected");
  1033. g.currentDate.date = parseInt($(this).html());
  1034. g.currentDate.day = new Date(g.currentDate.year, g.currentDate.month - 1, 1).getDay();
  1035. if ($(this).hasClass("l-box-dateeditor-out"))
  1036. {
  1037. if ($("tr", g.body.tbody).index($(this).parent()) == 0)
  1038. {
  1039. if (--g.currentDate.month == 0)
  1040. {
  1041. g.currentDate.month = 12;
  1042. g.currentDate.year--;
  1043. }
  1044. } else
  1045. {
  1046. if (++g.currentDate.month == 13)
  1047. {
  1048. g.currentDate.month = 1;
  1049. g.currentDate.year++;
  1050. }
  1051. }
  1052. }
  1053. g.selectedDate = {
  1054. year: g.currentDate.year,
  1055. month: g.currentDate.month,
  1056. date: g.currentDate.date
  1057. };
  1058. g.showDate();
  1059. g.editorToggling = true;
  1060. g.dateeditor.slideToggle('fast', function ()
  1061. {
  1062. g.editorToggling = false;
  1063. });
  1064. });
  1065. $(".l-box-dateeditor-header-btn", g.header).hover(function ()
  1066. {
  1067. $(this).addClass("l-box-dateeditor-header-btn-over");
  1068. }, function ()
  1069. {
  1070. $(this).removeClass("l-box-dateeditor-header-btn-over");
  1071. });
  1072. //选择年份
  1073. g.buttons.btnYear.click(function ()
  1074. {
  1075. //build year list
  1076. if (!g.body.yearselector.is(":visible"))
  1077. {
  1078. $("li", g.body.yearselector).each(function (i, item)
  1079. {
  1080. var currentYear = g.currentDate.year + (i - 4);
  1081. if (currentYear == g.currentDate.year)
  1082. $(this).addClass("l-selected");
  1083. else
  1084. $(this).removeClass("l-selected");
  1085. $(this).html(currentYear);
  1086. });
  1087. }
  1088. g.body.yearselector.slideToggle();
  1089. });
  1090. g.body.yearselector.hover(function () { }, function ()
  1091. {
  1092. $(this).slideUp();
  1093. });
  1094. $("li", g.body.yearselector).click(function ()
  1095. {
  1096. g.currentDate.year = parseInt($(this).html());
  1097. g.body.yearselector.slideToggle();
  1098. g.bulidContent();
  1099. });
  1100. //select month
  1101. g.buttons.btnMonth.click(function ()
  1102. {
  1103. $("li", g.body.monthselector).each(function (i, item)
  1104. {
  1105. //add selected style
  1106. if (g.currentDate.month == i + 1)
  1107. $(this).addClass("l-selected");
  1108. else
  1109. $(this).removeClass("l-selected");
  1110. });
  1111. g.body.monthselector.slideToggle();
  1112. });
  1113. g.body.monthselector.hover(function () { }, function ()
  1114. {
  1115. $(this).slideUp("fast");
  1116. });
  1117. $("li", g.body.monthselector).click(function ()
  1118. {
  1119. var index = $("li", g.body.monthselector).index(this);
  1120. g.currentDate.month = index + 1;
  1121. g.body.monthselector.slideToggle();
  1122. g.bulidContent();
  1123. });
  1124. //选择小时
  1125. g.toolbar.time.hour.click(function ()
  1126. {
  1127. $("li", g.body.hourselector).each(function (i, item)
  1128. {
  1129. //add selected style
  1130. if (g.currentDate.hour == i)
  1131. $(this).addClass("l-selected");
  1132. else
  1133. $(this).removeClass("l-selected");
  1134. });
  1135. g.body.hourselector.slideToggle();
  1136. });
  1137. g.body.hourselector.hover(function () { }, function ()
  1138. {
  1139. $(this).slideUp("fast");
  1140. });
  1141. $("li", g.body.hourselector).click(function ()
  1142. {
  1143. var index = $("li", g.body.hourselector).index(this);
  1144. g.currentDate.hour = index;
  1145. g.body.hourselector.slideToggle();
  1146. g.bulidContent();
  1147. g.showDate();
  1148. });
  1149. //选择分钟
  1150. g.toolbar.time.minute.click(function ()
  1151. {
  1152. $("li", g.body.minuteselector).each(function (i, item)
  1153. {
  1154. //add selected style
  1155. if (g.currentDate.minute == i)
  1156. $(this).addClass("l-selected");
  1157. else
  1158. $(this).removeClass("l-selected");
  1159. });
  1160. g.body.minuteselector.slideToggle("fast", function ()
  1161. {
  1162. var index = $("li", this).index($('li.l-selected', this));
  1163. if (index > 29)
  1164. {
  1165. var offSet = ($('li.l-selected', this).offset().top - $(this).offset().top);
  1166. $(this).animate({ scrollTop: offSet });
  1167. }
  1168. });
  1169. });
  1170. g.body.minuteselector.hover(function () { }, function ()
  1171. {
  1172. $(this).slideUp("fast");
  1173. });
  1174. $("li", g.body.minuteselector).click(function ()
  1175. {
  1176. var index = $("li", g.body.minuteselector).index(this);
  1177. g.currentDate.minute = index;
  1178. g.body.minuteselector.slideToggle("fast");
  1179. g.bulidContent();
  1180. g.showDate();
  1181. });
  1182. //上个月
  1183. g.buttons.btnPrevMonth.click(function ()
  1184. {
  1185. if (--g.currentDate.month == 0)
  1186. {
  1187. g.currentDate.month = 12;
  1188. g.currentDate.year--;
  1189. }
  1190. g.bulidContent();
  1191. });
  1192. //下个月
  1193. g.buttons.btnNextMonth.click(function ()
  1194. {
  1195. if (++g.currentDate.month == 13)
  1196. {
  1197. g.currentDate.month = 1;
  1198. g.currentDate.year++;
  1199. }
  1200. g.bulidContent();
  1201. });
  1202. //上一年
  1203. g.buttons.btnPrevYear.click(function ()
  1204. {
  1205. g.currentDate.year--;
  1206. g.bulidContent();
  1207. });
  1208. //下一年
  1209. g.buttons.btnNextYear.click(function ()
  1210. {
  1211. g.currentDate.year++;
  1212. g.bulidContent();
  1213. });
  1214. //今天
  1215. g.buttons.btnToday.click(function ()
  1216. {
  1217. g.currentDate = {
  1218. year: g.now.year,
  1219. month: g.now.month,
  1220. day: g.now.day,
  1221. date: g.now.date
  1222. };
  1223. g.selectedDate = {
  1224. year: g.now.year,
  1225. month: g.now.month,
  1226. day: g.now.day,
  1227. date: g.now.date
  1228. };
  1229. g.showDate();
  1230. g.dateeditor.slideToggle("fast");
  1231. });
  1232. //文本框
  1233. g.inputText.change(function ()
  1234. {
  1235. g.onTextChange();
  1236. }).blur(function ()
  1237. {
  1238. g.text.removeClass("l-text-focus");
  1239. }).focus(function ()
  1240. {
  1241. g.text.addClass("l-text-focus");
  1242. });
  1243. g.text.hover(function ()
  1244. {
  1245. g.text.addClass("l-text-over");
  1246. }, function ()
  1247. {
  1248. g.text.removeClass("l-text-over");
  1249. });
  1250. //LEABEL 支持
  1251. if (p.label)
  1252. {
  1253. g.labelwrapper = g.textwrapper.wrap('<div class="l-labeltext"></div>').parent();
  1254. g.labelwrapper.prepend('<div class="l-text-label" style="float:left;display:inline;">' + p.label + ':&nbsp</div>');
  1255. g.textwrapper.css('float', 'left');
  1256. if (!p.labelWidth)
  1257. {
  1258. p.labelWidth = $('.l-text-label', g.labelwrapper).outerWidth();
  1259. } else
  1260. {
  1261. $('.l-text-label', g.labelwrapper).outerWidth(p.labelWidth);
  1262. }
  1263. $('.l-text-label', g.labelwrapper).width(p.labelWidth);
  1264. $('.l-text-label', g.labelwrapper).height(g.text.height());
  1265. g.labelwrapper.append('<br style="clear:both;" />');
  1266. if (p.labelAlign)
  1267. {
  1268. $('.l-text-label', g.labelwrapper).css('text-align', p.labelAlign);
  1269. }
  1270. g.textwrapper.css({ display: 'inline' });
  1271. g.labelwrapper.width(g.text.outerWidth() + p.labelWidth + 2);
  1272. }
  1273. g.set(p);
  1274. //增加鼠标在日期控件外点击隐藏日期选择框功能
  1275. $(document).bind("click.dateeditor", function (e)
  1276. {
  1277. if (g.dateeditor.is(":visible") && $((e.target || e.srcElement)).closest( ".l-box-dateeditor, .l-text-date" ).length == 0)
  1278. {
  1279. g.toggleDateEditor(true);
  1280. }
  1281. });
  1282. },
  1283. updateSelectBoxPosition: function ()
  1284. {
  1285. var g = this, p = this.options;
  1286. if (p.absolute)
  1287. {
  1288. var contentHeight = $(document).height();
  1289. /** 定位BUG修复 add by hzp at 20160217 ***********/
  1290. if (Number(g.text.offset().top + 1 + g.text.outerHeight() + g.dateeditor.height()) > contentHeight
  1291. && contentHeight > Number(g.dateeditor.height() + 1))
  1292. {
  1293. //若下拉框大小超过当前document下边框,且当前document上留白大于下拉内容高度,下拉内容向上展现
  1294. g.dateeditor.css({ left: g.text.offset().left, top: g.text.offset().top + 1 - g.dateeditor.height() });
  1295. } else
  1296. {
  1297. g.dateeditor.css({ left: g.text.offset().left, top: g.text.offset().top - 1 + g.text.outerHeight() });
  1298. }
  1299. /********************************************/
  1300. }
  1301. else
  1302. {
  1303. if (g.text.offset().top + 4 > g.dateeditor.height() && g.text.offset().top + g.dateeditor.height() + textHeight + 4 - $(window).scrollTop() > $(window).height())
  1304. {
  1305. g.dateeditor.css("marginTop", -1 * (g.dateeditor.height() + textHeight + 5));
  1306. g.showOnTop = true;
  1307. }
  1308. else
  1309. {
  1310. g.showOnTop = false;
  1311. }
  1312. }
  1313. },
  1314. getValue: function(){
  1315. return $(this.element).val();
  1316. },
  1317. setValue: function (value)
  1318. {
  1319. var g = this;
  1320. if (!value) g.inputText.val('');
  1321. if (typeof value == "string")
  1322. {
  1323. if (/^\/Date/.test(value))
  1324. {
  1325. value = value.replace(/^\//, "new ").replace(/\/$/, "");
  1326. eval("value = " + value);
  1327. }
  1328. /******* 时间格式BUG ***********/
  1329. else{
  1330. if(value.length > g.options.format.length)
  1331. {
  1332. value = value.substr(0,g.options.format.length);
  1333. }
  1334. }
  1335. g.inputText.val(value);
  1336. g.usedDate = value;
  1337. /******* 时间格式BUG ***********/
  1338. g.onTextChange();
  1339. /******************/
  1340. }
  1341. if (typeof value == "object")
  1342. {
  1343. if (value instanceof Date)
  1344. {
  1345. g.inputText.val(g.getFormatDate(value));
  1346. g.onTextChange();
  1347. }
  1348. }
  1349. }
  1350. });
  1351. //重写弹窗控件 add by hzp at 20160217
  1352. $.extend($.ligerui.controls.Dialog.prototype,{
  1353. _setImage: function ()
  1354. {
  1355. var g = this, p = this.options;
  1356. if (p.type)
  1357. {
  1358. /************* 修改弹出对话框样式 *******************************/
  1359. var alertCss = { padding:"10px",textAlign:"center",fontWeight:"bolder",fontSize:"14px",lineHeight:"24px"};
  1360. g.dialog.body.css({width:300});
  1361. /*******************************************************/
  1362. if (p.type == 'success' || p.type == 'donne' || p.type == 'ok')
  1363. {
  1364. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-donne").show();
  1365. g.dialog.content.css(alertCss);
  1366. }
  1367. else if (p.type == 'error')
  1368. {
  1369. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-error").show();
  1370. g.dialog.content.css(alertCss);
  1371. }
  1372. else if (p.type == 'warn')
  1373. {
  1374. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-warn").show();
  1375. g.dialog.content.css(alertCss);
  1376. }
  1377. else if (p.type == 'question')
  1378. {
  1379. $(".l-dialog-image", g.dialog).addClass("l-dialog-image-question").show();
  1380. g.dialog.content.css(alertCss);
  1381. }
  1382. }
  1383. }
  1384. });
  1385. //重写layout控件 add by hzp at 20160229
  1386. $.extend($.ligerui.controls.Layout.prototype,{
  1387. _render: function ()
  1388. {
  1389. var g = this, p = this.options;
  1390. g.layout = $(this.element);
  1391. g.layout.addClass("l-layout");
  1392. g.width = g.layout.width();
  1393. //top
  1394. if ($("> div[position=top]", g.layout).length > 0)
  1395. {
  1396. g.top = $("> div[position=top]", g.layout).wrap('<div class="l-layout-top" style="top:0px;"></div>').parent();
  1397. g.top.content = $("> div[position=top]", g.top);
  1398. if (!g.top.content.hasClass("l-layout-content"))
  1399. g.top.content.addClass("l-layout-content");
  1400. g.topHeight = p.topHeight;
  1401. if (g.topHeight)
  1402. {
  1403. g.top.height(g.topHeight);
  1404. }
  1405. }
  1406. //bottom
  1407. if ($("> div[position=bottom]", g.layout).length > 0)
  1408. {
  1409. g.bottom = $("> div[position=bottom]", g.layout).wrap('<div class="l-layout-bottom"></div>').parent();
  1410. g.bottom.content = $("> div[position=bottom]", g.bottom);
  1411. if (!g.bottom.content.hasClass("l-layout-content"))
  1412. g.bottom.content.addClass("l-layout-content");
  1413. g.bottomHeight = p.bottomHeight;
  1414. if (g.bottomHeight)
  1415. {
  1416. g.bottom.height(g.bottomHeight);
  1417. }
  1418. //set title
  1419. var bottomtitle = g.bottom.content.attr("title");
  1420. if (bottomtitle)
  1421. {
  1422. g.bottom.header = $('<div class="l-layout-header"></div>');
  1423. g.bottom.prepend(g.bottom.header);
  1424. g.bottom.header.html(bottomtitle);
  1425. g.bottom.content.attr("title", "");
  1426. }
  1427. }
  1428. //left
  1429. if ($("> div[position=left]", g.layout).length > 0)
  1430. {
  1431. g.left = $("> div[position=left]", g.layout).wrap('<div class="l-layout-left" style="left:0px;"></div>').parent();
  1432. g.left.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
  1433. g.left.header.toggle = $(".l-layout-header-toggle", g.left.header);
  1434. g.left.content = $("> div[position=left]", g.left);
  1435. if (!g.left.content.hasClass("l-layout-content"))
  1436. g.left.content.addClass("l-layout-content");
  1437. if (!p.allowLeftCollapse) $(".l-layout-header-toggle", g.left.header).remove();
  1438. //set title
  1439. var lefttitle = g.left.content.attr("title");
  1440. if (lefttitle)
  1441. {
  1442. g.left.prepend(g.left.header);
  1443. g.left.content.attr("title", "");
  1444. $(".l-layout-header-inner", g.left.header).html(lefttitle);
  1445. }
  1446. //set title
  1447. if (g.left.content.attr("hidetitle"))
  1448. {
  1449. g.left.content.attr("title", "");
  1450. g.left.header.remove();
  1451. }
  1452. //set width
  1453. g.leftWidth = p.leftWidth;
  1454. if (g.leftWidth)
  1455. g.left.width(g.leftWidth);
  1456. }
  1457. //center
  1458. if ($("> div[position=center]", g.layout).length > 0)
  1459. {
  1460. g.center = $("> div[position=center]", g.layout).wrap('<div class="l-layout-center" ></div>').parent();
  1461. g.center.content = $("> div[position=center]", g.center);
  1462. g.center.content.addClass("l-layout-content");
  1463. //set title
  1464. var centertitle = g.center.content.attr("title");
  1465. if (centertitle)
  1466. {
  1467. g.center.content.attr("title", "");
  1468. g.center.header = $('<div class="l-layout-header"></div>');
  1469. g.center.prepend(g.center.header);
  1470. g.center.header.html(centertitle);
  1471. }
  1472. if (g.center.content.attr("hidetitle"))
  1473. {
  1474. g.center.content.attr("title", "");
  1475. g.center.header.remove();
  1476. }
  1477. //set width
  1478. g.centerWidth = p.centerWidth;
  1479. if (g.centerWidth)
  1480. g.center.width(g.centerWidth);
  1481. //centerBottom
  1482. if ($("> div[position=centerbottom]", g.layout).length > 0)
  1483. {
  1484. g.centerBottom = $("> div[position=centerbottom]", g.layout).wrap('<div class="l-layout-centerbottom" ></div>').parent();
  1485. g.centerBottom.content = $("> div[position=centerbottom]", g.centerBottom);
  1486. g.centerBottom.content.addClass("l-layout-content");
  1487. //set title
  1488. var centertitle = g.centerBottom.content.attr("title");
  1489. if (centertitle)
  1490. {
  1491. g.centerBottom.content.attr("title", "");
  1492. g.centerBottom.header = $('<div class="l-layout-header"></div>');
  1493. g.centerBottom.prepend(g.centerBottom.header);
  1494. g.centerBottom.header.html(centertitle);
  1495. }
  1496. if (g.centerBottom.content.attr("hidetitle"))
  1497. {
  1498. g.centerBottom.content.attr("title", "");
  1499. if (g.centerBottom.header)
  1500. {
  1501. g.centerBottom.header.remove();
  1502. }
  1503. }
  1504. if (g.centerWidth)
  1505. g.centerBottom.width(g.centerWidth);
  1506. }
  1507. }
  1508. //right
  1509. if ($("> div[position=right]", g.layout).length > 0)
  1510. {
  1511. g.right = $("> div[position=right]", g.layout).wrap('<div class="l-layout-right"></div>').parent();
  1512. g.right.header = $('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');
  1513. g.right.prepend(g.right.header);
  1514. g.right.header.toggle = $(".l-layout-header-toggle", g.right.header);
  1515. if (!p.allowRightCollapse) $(".l-layout-header-toggle", g.right.header).remove();
  1516. g.right.content = $("> div[position=right]", g.right);
  1517. if (!g.right.content.hasClass("l-layout-content"))
  1518. g.right.content.addClass("l-layout-content");
  1519. //set title
  1520. var righttitle = g.right.content.attr("title");
  1521. if (righttitle)
  1522. {
  1523. g.right.content.attr("title", "");
  1524. $(".l-layout-header-inner", g.right.header).html(righttitle);
  1525. }
  1526. if (g.right.content.attr("hidetitle"))
  1527. {
  1528. g.right.content.attr("title", "");
  1529. g.right.header.remove();
  1530. }
  1531. //set width
  1532. g.rightWidth = p.rightWidth;
  1533. if (g.rightWidth)
  1534. g.right.width(g.rightWidth);
  1535. }
  1536. //lock
  1537. g.layout.lock = $("<div class='l-layout-lock'></div>");
  1538. g.layout.append(g.layout.lock);
  1539. //DropHandle
  1540. g._addDropHandle();
  1541. //Collapse
  1542. g.isLeftCollapse = p.isLeftCollapse;
  1543. g.isRightCollapse = p.isRightCollapse;
  1544. g.leftCollapse = $('<div class="l-layout-collapse-left" style="display: none; "><div class="l-layout-collapse-left-toggle"></div></div>');
  1545. g.rightCollapse = $('<div class="l-layout-collapse-right" style="display: none; "><div class="l-layout-collapse-right-toggle"></div></div>');
  1546. g.layout.append(g.leftCollapse).append(g.rightCollapse);
  1547. g.leftCollapse.toggle = $("> .l-layout-collapse-left-toggle", g.leftCollapse);
  1548. g.rightCollapse.toggle = $("> .l-layout-collapse-right-toggle", g.rightCollapse);
  1549. g._setCollapse();
  1550. //init
  1551. g._bulid();
  1552. $(window).resize(function ()
  1553. {
  1554. g._onResize();
  1555. });
  1556. g.set(p);
  1557. g.mask.height(g.layout.height());
  1558. },
  1559. _onResize: function ()
  1560. {
  1561. var g = this, p = this.options;
  1562. var oldheight = g.layout.height();
  1563. //set layout height
  1564. var h = 0;
  1565. var windowHeight = $(window).height();
  1566. var parentHeight = null;
  1567. if (typeof (p.height) == "string" && p.height.indexOf('%') > 0)
  1568. {
  1569. var layoutparent = g.layout.parent();
  1570. if (p.inWindow || layoutparent[0].tagName.toLowerCase() == "body")
  1571. {
  1572. parentHeight = windowHeight;
  1573. parentHeight -= parseInt($('body').css('paddingTop'));
  1574. parentHeight -= parseInt($('body').css('paddingBottom'));
  1575. }
  1576. else
  1577. {
  1578. parentHeight = layoutparent.height();
  1579. }
  1580. h = parentHeight * parseFloat(p.height) * 0.01;
  1581. if (p.inWindow || layoutparent[0].tagName.toLowerCase() == "body")
  1582. h -= (g.layout.offset().top - parseInt($('body').css('paddingTop')));
  1583. /****** 判断是否比外层高 add by hzp at 2016-03-15 **********/
  1584. if(layoutparent.height() >0 && h > layoutparent.height())
  1585. {
  1586. var padding = layoutparent.innerHeight() - layoutparent.height();
  1587. var margin = layoutparent.outerHeight(true) - layoutparent.outerHeight();
  1588. h = layoutparent.height() - padding - margin;
  1589. }
  1590. /*************************************************/
  1591. }
  1592. else
  1593. {
  1594. h = parseInt(p.height);
  1595. }
  1596. h += p.heightDiff;
  1597. g.layout.height(h);
  1598. g.layoutHeight = g.layout.height();
  1599. g.middleWidth = g.layout.width();
  1600. g.middleHeight = g.layout.height();
  1601. if (g.top)
  1602. {
  1603. g.middleHeight -= g.top.height();
  1604. g.middleHeight -= parseInt(g.top.css('borderTopWidth'));
  1605. g.middleHeight -= parseInt(g.top.css('borderBottomWidth'));
  1606. g.middleHeight -= p.space;
  1607. }
  1608. if (g.bottom)
  1609. {
  1610. g.middleHeight -= g.bottom.height();
  1611. g.middleHeight -= parseInt(g.bottom.css('borderTopWidth'));
  1612. g.middleHeight -= parseInt(g.bottom.css('borderBottomWidth'));
  1613. g.middleHeight -= p.space;
  1614. }
  1615. //specific
  1616. g.middleHeight -= 2;
  1617. if (g.hasBind('heightChanged') && g.layoutHeight != oldheight)
  1618. {
  1619. g.trigger('heightChanged', [{ layoutHeight: g.layoutHeight, diff: g.layoutHeight - oldheight, middleHeight: g.middleHeight}]);
  1620. }
  1621. if (g.center)
  1622. {
  1623. g.centerWidth = g.middleWidth;
  1624. if (g.left)
  1625. {
  1626. if (g.isLeftCollapse)
  1627. {
  1628. g.centerWidth -= g.leftCollapse.width();
  1629. g.centerWidth -= parseInt(g.leftCollapse.css('borderLeftWidth'));
  1630. g.centerWidth -= parseInt(g.leftCollapse.css('borderRightWidth'));
  1631. g.centerWidth -= parseInt(g.leftCollapse.css('left'));
  1632. g.centerWidth -= p.space;
  1633. }
  1634. else
  1635. {
  1636. g.centerWidth -= g.leftWidth;
  1637. g.centerWidth -= parseInt(g.left.css('borderLeftWidth'));
  1638. g.centerWidth -= parseInt(g.left.css('borderRightWidth'));
  1639. g.centerWidth -= parseInt(g.left.css('left'));
  1640. g.centerWidth -= p.space;
  1641. }
  1642. }
  1643. if (g.right)
  1644. {
  1645. if (g.isRightCollapse)
  1646. {
  1647. g.centerWidth -= g.rightCollapse.width();
  1648. g.centerWidth -= parseInt(g.rightCollapse.css('borderLeftWidth'));
  1649. g.centerWidth -= parseInt(g.rightCollapse.css('borderRightWidth'));
  1650. g.centerWidth -= parseInt(g.rightCollapse.css('right'));
  1651. g.centerWidth -= p.space;
  1652. }
  1653. else
  1654. {
  1655. g.centerWidth -= g.rightWidth;
  1656. g.centerWidth -= parseInt(g.right.css('borderLeftWidth'));
  1657. g.centerWidth -= parseInt(g.right.css('borderRightWidth'));
  1658. g.centerWidth -= p.space;
  1659. }
  1660. }
  1661. g.centerLeft = 0;
  1662. if (g.left)
  1663. {
  1664. if (g.isLeftCollapse)
  1665. {
  1666. g.centerLeft += g.leftCollapse.width();
  1667. g.centerLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
  1668. g.centerLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
  1669. g.centerLeft += parseInt(g.leftCollapse.css('left'));
  1670. g.centerLeft += p.space;
  1671. }
  1672. else
  1673. {
  1674. g.centerLeft += g.left.width();
  1675. g.centerLeft += parseInt(g.left.css('borderLeftWidth'));
  1676. g.centerLeft += parseInt(g.left.css('borderRightWidth'));
  1677. g.centerLeft += p.space;
  1678. }
  1679. }
  1680. g.center.css({ left: g.centerLeft });
  1681. g.centerWidth >= 0 && g.center.width(g.centerWidth);
  1682. g.middleHeight >= 0 && g.center.height(g.middleHeight);
  1683. var contentHeight = g.middleHeight;
  1684. if (g.center.header) contentHeight -= g.center.header.height();
  1685. var padding = g.center.content.innerHeight() - g.center.content.height();
  1686. var margin = g.center.content.outerHeight(true) - g.center.content.outerHeight();
  1687. contentHeight = contentHeight-padding-margin;
  1688. contentHeight >= 0 && g.center.content.height(contentHeight);
  1689. g._updateCenterBottom(true);
  1690. }
  1691. if (g.left)
  1692. {
  1693. g.leftCollapse.height(g.middleHeight);
  1694. g.left.height(g.middleHeight);
  1695. /********* 左布局高度BUG修复 add by hzp at 20160229 *******/
  1696. var contentHeight = g.middleHeight;
  1697. if (g.left.header) contentHeight -= g.left.header.height();
  1698. var padding = g.left.content.innerHeight() - g.left.content.height();
  1699. var margin = g.left.content.outerHeight(true) - g.left.content.outerHeight();
  1700. contentHeight = contentHeight-padding-margin;
  1701. contentHeight >= 0 && g.left.content.height(contentHeight);
  1702. /***************************************************/
  1703. }
  1704. if (g.right)
  1705. {
  1706. g.rightCollapse.height(g.middleHeight);
  1707. g.right.height(g.middleHeight);
  1708. //set left
  1709. g.rightLeft = 0;
  1710. if (g.left)
  1711. {
  1712. if (g.isLeftCollapse)
  1713. {
  1714. g.rightLeft += g.leftCollapse.width();
  1715. g.rightLeft += parseInt(g.leftCollapse.css('borderLeftWidth'));
  1716. g.rightLeft += parseInt(g.leftCollapse.css('borderRightWidth'));
  1717. g.rightLeft += p.space;
  1718. }
  1719. else
  1720. {
  1721. g.rightLeft += g.left.width();
  1722. g.rightLeft += parseInt(g.left.css('borderLeftWidth'));
  1723. g.rightLeft += parseInt(g.left.css('borderRightWidth'));
  1724. g.rightLeft += parseInt(g.left.css('left'));
  1725. g.rightLeft += p.space;
  1726. }
  1727. }
  1728. if (g.center)
  1729. {
  1730. g.rightLeft += g.center.width();
  1731. g.rightLeft += parseInt(g.center.css('borderLeftWidth'));
  1732. g.rightLeft += parseInt(g.center.css('borderRightWidth'));
  1733. g.rightLeft += p.space;
  1734. }
  1735. g.right.css({ left: g.rightLeft });
  1736. }
  1737. if (g.bottom)
  1738. {
  1739. g.bottomTop = g.layoutHeight - g.bottom.height() - 2;
  1740. g.bottom.css({ top: g.bottomTop });
  1741. }
  1742. g._setDropHandlePosition();
  1743. }
  1744. });
  1745. //重写数值控件 add by hzp at 20160308
  1746. $.extend($.ligerDefaults.DateEditor,{
  1747. isNegative:false
  1748. });
  1749. $.extend($.ligerui.controls.Spinner.prototype,{
  1750. _showValue: function (value)
  1751. {
  1752. var g = this, p = this.options;
  1753. /**** 默认值为空 ************/
  1754. if (!value || value == "NaN") value = "";
  1755. /***************************/
  1756. if (p.type == 'float')
  1757. {
  1758. value = parseFloat(value).toFixed(p.decimalplace);
  1759. }
  1760. this.inputText.val(value)
  1761. },
  1762. _render: function ()
  1763. {
  1764. var g = this, p = this.options;
  1765. g.interval = null;
  1766. g.inputText = null;
  1767. g.value = null;
  1768. g.textFieldID = "";
  1769. if (this.element.tagName.toLowerCase() == "input" && this.element.type && this.element.type == "text")
  1770. {
  1771. g.inputText = $(this.element);
  1772. if (this.element.id)
  1773. g.textFieldID = this.element.id;
  1774. }
  1775. else
  1776. {
  1777. g.inputText = $('<input type="text"/>');
  1778. g.inputText.appendTo($(this.element));
  1779. }
  1780. if (g.textFieldID == "" && p.textFieldID)
  1781. g.textFieldID = p.textFieldID;
  1782. g.link = $('<div class="l-trigger"><div class="l-spinner-up"><div class="l-spinner-icon"></div></div><div class="l-spinner-split"></div><div class="l-spinner-down"><div class="l-spinner-icon"></div></div></div>');
  1783. g.wrapper = g.inputText.wrap('<div class="l-text"></div>').parent();
  1784. g.wrapper.append('<div class="l-text-l"></div><div class="l-text-r"></div>');
  1785. g.wrapper.append(g.link).after(g.selectBox).after(g.valueField);
  1786. g.link.up = $(".l-spinner-up", g.link);
  1787. g.link.down = $(".l-spinner-down", g.link);
  1788. g.inputText.addClass("l-text-field");
  1789. if (p.disabled)
  1790. {
  1791. g.wrapper.addClass("l-text-disabled");
  1792. }
  1793. //初始化
  1794. if (!g._isVerify(g.inputText.val()))
  1795. {
  1796. g.value = g._getDefaultValue();
  1797. g._showValue(g.value);
  1798. }
  1799. //事件
  1800. g.link.up.hover(function ()
  1801. {
  1802. if (!p.disabled)
  1803. $(this).addClass("l-spinner-up-over");
  1804. }, function ()
  1805. {
  1806. clearInterval(g.interval);
  1807. $(document).unbind("selectstart.spinner");
  1808. $(this).removeClass("l-spinner-up-over");
  1809. }).mousedown(function ()
  1810. {
  1811. if (!p.disabled)
  1812. {
  1813. g._uping.call(g);
  1814. /********* 向上延时500 *************/
  1815. g.interval = setInterval(function ()
  1816. {
  1817. g._uping.call(g);
  1818. }, p.interval+500);
  1819. /**********************************/
  1820. $(document).bind("selectstart.spinner", function () { return false; });
  1821. }
  1822. }).mouseup(function ()
  1823. {
  1824. clearInterval(g.interval);
  1825. g.inputText.trigger("change").focus();
  1826. $(document).unbind("selectstart.spinner");
  1827. });
  1828. g.link.down.hover(function ()
  1829. {
  1830. if (!p.disabled)
  1831. $(this).addClass("l-spinner-down-over");
  1832. }, function ()
  1833. {
  1834. clearInterval(g.interval);
  1835. $(document).unbind("selectstart.spinner");
  1836. $(this).removeClass("l-spinner-down-over");
  1837. }).mousedown(function ()
  1838. {
  1839. if (!p.disabled)
  1840. {
  1841. g.interval = setInterval(function ()
  1842. {
  1843. g._downing.call(g);
  1844. }, p.interval);
  1845. $(document).bind("selectstart.spinner", function () { return false; });
  1846. }
  1847. }).mouseup(function ()
  1848. {
  1849. clearInterval(g.interval);
  1850. g.inputText.trigger("change").focus();
  1851. $(document).unbind("selectstart.spinner");
  1852. });
  1853. g.inputText.change(function ()
  1854. {
  1855. var value = g.inputText.val();
  1856. g.value = g._getVerifyValue(value);
  1857. g.trigger('changeValue', [g.value]);
  1858. g._showValue(g.value);
  1859. }).blur(function ()
  1860. {
  1861. g.wrapper.removeClass("l-text-focus");
  1862. }).focus(function ()
  1863. {
  1864. g.wrapper.addClass("l-text-focus");
  1865. });
  1866. g.wrapper.hover(function ()
  1867. {
  1868. if (!p.disabled)
  1869. g.wrapper.addClass("l-text-over");
  1870. }, function ()
  1871. {
  1872. g.wrapper.removeClass("l-text-over");
  1873. });
  1874. g.set(p);
  1875. }
  1876. });
  1877. //重写Tip控件 add by hzp at 20160314
  1878. $.extend($.ligerui.controls.Tip.prototype,{
  1879. _render: function ()
  1880. {
  1881. var g = this, p = this.options;
  1882. var tip = $('<div class="l-verify-tip"><div class="l-verify-tip-corner"></div><div class="l-verify-tip-content"></div></div>');
  1883. g.tip = tip;
  1884. g.tip.attr("id", g.id);
  1885. if (p.content)
  1886. {
  1887. $("> .l-verify-tip-content:first", tip).html(p.content);
  1888. tip.appendTo('body');
  1889. }
  1890. else
  1891. {
  1892. return;
  1893. }
  1894. /************* 样式调整修改 *********************************/
  1895. tip.css({ left: p.x, top: p.y+3 }).show();
  1896. p.width && $("> .l-verify-tip-content:first", tip).width(p.width - 36);
  1897. /**********************************************/
  1898. p.height && $("> .l-verify-tip-content:first", tip).width(p.height);
  1899. eee = p.appendIdTo;
  1900. if (p.appendIdTo)
  1901. {
  1902. p.appendIdTo.attr("ligerTipId", g.id);
  1903. }
  1904. if (p.target)
  1905. {
  1906. $(p.target).attr("ligerTipId", g.id);
  1907. p.target.ligeruitipid = g.id;
  1908. }
  1909. p.callback && p.callback(tip);
  1910. g.set(p);
  1911. },
  1912. });
  1913. })(jQuery, window);