You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

879 lines
33 KiB

  1. /*
  2. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  3. * Copyright (c) 2013-2018 上海力软信息技术有限公司
  4. * 创建人:力软-前端开发组
  5. * 日 期:2017.03.16
  6. * 描 述:表单处理方法
  7. */
  8. (function ($, learun) {
  9. "use strict";
  10. /*获取和设置表单数据*/
  11. $.fn.lrGetFormData = function (keyValue) {// 获取表单数据
  12. var resdata = {};
  13. $(this).find('input,select,textarea,.lr-select,.lr-formselect,.lrUploader-wrap,.lr-radio,.lr-checkbox,.edui-default').each(function (r) {
  14. var id = $(this).attr('id');
  15. if (!!id) {
  16. var type = $(this).attr('type');
  17. switch (type) {
  18. case "radio":
  19. if ($("#" + id).is(":checked")) {
  20. var _name = $("#" + id).attr('name');
  21. resdata[_name] = $("#" + id).val();
  22. }
  23. break;
  24. case "checkbox":
  25. if ($("#" + id).is(":checked")) {
  26. resdata[id] = 1;
  27. } else {
  28. resdata[id] = 0;
  29. }
  30. break;
  31. case "lrselect":
  32. resdata[id] = $(this).lrselectGet();
  33. break;
  34. case "formselect":
  35. resdata[id] = $(this).lrformselectGet();
  36. break;
  37. case "lrGirdSelect":
  38. resdata[id] = $(this).lrGirdSelectGet();
  39. break;
  40. case "lr-Uploader":
  41. resdata[id] = $(this).lrUploaderGet();
  42. break;
  43. case "lr-radio":
  44. resdata[id] = $(this).find('input:checked').val();
  45. break;
  46. case "lr-checkbox":
  47. var _idlist = [];
  48. $(this).find('input:checked').each(function () {
  49. _idlist.push($(this).val());
  50. });
  51. resdata[id] = String(_idlist);
  52. break;
  53. default:
  54. if ($("#" + id).hasClass('currentInfo')) {
  55. var value = $("#" + id)[0].lrvalue;
  56. if (value == undefined) {
  57. value = $('#' + id).val();
  58. }
  59. resdata[id] = $.trim(value);
  60. }
  61. else if ($(this).hasClass('edui-default')) {
  62. if ($(this)[0].ue) {
  63. resdata[id] = $(this)[0].ue.getContent(null, null, true).replace(/[<>&"]/g, function (c) { return { '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;' }[c]; });//
  64. }
  65. }
  66. else {
  67. var value = $("#" + id).val();
  68. if (value != undefined && value != 'undefined') {
  69. resdata[id] = $.trim(value);
  70. }
  71. }
  72. break;
  73. }
  74. if (resdata[id] != undefined) {
  75. resdata[id] += '';
  76. if (resdata[id] == '') {
  77. resdata[id] = '&nbsp;';
  78. }
  79. if (resdata[id] == '&nbsp;' && !keyValue) {
  80. resdata[id] = '';
  81. }
  82. }
  83. }
  84. });
  85. return resdata;
  86. };
  87. $.fn.lrSetFormData = function (data) {// 设置表单数据
  88. var $this = $(this);
  89. for (var id in data) {
  90. var value = data[id];
  91. var $obj = $this.find('#' + id);
  92. if ($obj.length == 0 && value != null) {
  93. $obj = $this.find('[name="' + id + '"][value="' + value + '"]');
  94. if ($obj.length > 0) {
  95. if (!$obj.is(":checked")) {
  96. $obj.trigger('click');
  97. }
  98. }
  99. }
  100. else {
  101. var type = $obj.attr('type');
  102. if ($obj.hasClass("lr-input-wdatepicker")) {
  103. type = "datepicker";
  104. }
  105. switch (type) {
  106. case "checkbox":
  107. var isck = 0;
  108. if ($obj.is(":checked")) {
  109. isck = 1;
  110. } else {
  111. isck = 0;
  112. }
  113. if (isck != parseInt(value)) {
  114. $obj.trigger('click');
  115. }
  116. break;
  117. case "lrselect":
  118. $obj.lrselectSet(value);
  119. break;
  120. case "formselect":
  121. $obj.lrformselectSet(value);
  122. break;
  123. case "lrGirdSelect":
  124. $obj.lrGirdSelectSet(value);
  125. break;
  126. case "datepicker":
  127. var _dateFmt = $obj.attr('data-dateFmt') || 'yyyy-MM-dd';
  128. $obj.val(learun.formatDate(value, _dateFmt));
  129. break;
  130. case "lr-Uploader":
  131. $obj.lrUploaderSet(value);
  132. break;
  133. case "lr-radio":
  134. if (!$obj.find('input[value="' + value + '"]').is(":checked")) {
  135. $obj.find('input[value="' + value + '"]').trigger('click');
  136. }
  137. break;
  138. case "lr-checkbox":
  139. var values = value.split(",");
  140. $.each(values, function (index, val) {
  141. if (!$obj.find('input[value="' + val + '"]').is(":checked")) {
  142. $obj.find('input[value="' + val + '"]').trigger('click');
  143. }
  144. });
  145. break;
  146. var _idlist = [];
  147. default:
  148. if ($obj.hasClass('currentInfo')) {
  149. $obj[0].lrvalue = value;
  150. if ($obj.hasClass('lr-currentInfo-user')) {
  151. $obj.val('');
  152. learun.clientdata.getAsync('user', {
  153. key: value,
  154. callback: function (item, op) {
  155. op.obj.val(item.name);
  156. },
  157. obj: $obj
  158. });
  159. }
  160. else if ($obj.hasClass('lr-currentInfo-company')) {
  161. $obj.val('');
  162. learun.clientdata.getAsync('company', {
  163. key: value,
  164. callback: function (_data, op) {
  165. op.obj.val(_data.name);
  166. },
  167. obj: $obj
  168. });
  169. }
  170. else if ($obj.hasClass('lr-currentInfo-department')) {
  171. $obj.val('');
  172. learun.clientdata.getAsync('department', {
  173. key: value,
  174. callback: function (_data, op) {
  175. op.obj.val(_data.name);
  176. },
  177. obj: $obj
  178. });
  179. }
  180. else {
  181. $obj.val(value);
  182. }
  183. }
  184. else if ($obj.hasClass('edui-default')) {
  185. if (!!value) {
  186. var ue = $obj[0].ue;
  187. setUe(ue, value);
  188. }
  189. }
  190. else {
  191. $obj.val(value);
  192. }
  193. break;
  194. }
  195. }
  196. }
  197. };
  198. function setUe(ue, value) {
  199. ue.ready(function () {
  200. var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
  201. var str = value.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
  202. str = str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
  203. ue.setContent(str);
  204. });
  205. }
  206. /*
  207. $.fn.showEditer = function (content) {
  208. var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
  209. var str = content.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
  210. $(this).html(str);
  211. }
  212. $('#id').showEditer();
  213. */
  214. /*表单数据操作*/
  215. $.lrSetForm = function (url, callback) {
  216. learun.loading(true, '正在获取数据');
  217. learun.httpAsyncGet(url, function (res) {
  218. learun.loading(false);
  219. if (res.code == learun.httpCode.success) {
  220. callback(res.data);
  221. }
  222. else {
  223. learun.layerClose(window.name);
  224. learun.alert.error('表单数据获取失败,请重新获取!');
  225. learun.httpErrorLog(res.info);
  226. }
  227. });
  228. };
  229. $.lrSetFormWithParam = function (url, param, callback) {
  230. learun.loading(true, '正在获取数据');
  231. learun.httpAsyncGetWithParam(url, param, function (res) {
  232. learun.loading(false);
  233. if (res.code == learun.httpCode.success) {
  234. callback(res.data);
  235. }
  236. else {
  237. learun.layerClose(window.name);
  238. learun.alert.error('表单数据获取失败,请重新获取!');
  239. learun.httpErrorLog(res.info);
  240. }
  241. });
  242. };
  243. $.lrSaveForm = function (url, param, callback, isNotClosed) {
  244. param['__RequestVerificationToken'] = $.lrToken;
  245. learun.loading(true, '正在保存数据');
  246. learun.httpAsyncPost(url, param, function (res) {
  247. learun.loading(false);
  248. if (res.code == learun.httpCode.success) {
  249. if (!!callback) {
  250. callback(res);
  251. }
  252. learun.alert.success(res.info);
  253. if (!isNotClosed) {
  254. learun.layerClose(window.name);
  255. }
  256. }
  257. else {
  258. learun.alert.error(res.info);
  259. learun.httpErrorLog(res.info);
  260. }
  261. });
  262. };
  263. $.lrPostForm = function (url, param) {
  264. param['__RequestVerificationToken'] = $.lrToken;
  265. learun.loading(true, '正在提交数据');
  266. learun.httpAsyncPost(url, param, function (res) {
  267. learun.loading(false);
  268. if (res.code == learun.httpCode.success) {
  269. learun.alert.success(res.info);
  270. }
  271. else {
  272. learun.alert.error(res.info);
  273. learun.httpErrorLog(res.info);
  274. }
  275. });
  276. };
  277. /*tab页切换*/
  278. $.fn.lrFormTab = function (callback) {
  279. var $this = $(this);
  280. $this.parent().css({ 'padding-top': '44px' });
  281. $this.lrscroll();
  282. $this.on('DOMNodeInserted', function (e) {
  283. var $this = $(this);
  284. var w = 0;
  285. $this.find('li').each(function () {
  286. w += $(this).outerWidth();
  287. });
  288. $this.find('.lr-scroll-box').css({ 'width': w });
  289. });
  290. var $this = $(this);
  291. var w = 0;
  292. $this.find('li').each(function () {
  293. w += $(this).outerWidth();
  294. });
  295. $this.find('.lr-scroll-box').css({ 'width': w });
  296. $this.delegate('li', 'click', { $ul: $this }, function (e) {
  297. var $li = $(this);
  298. if (!$li.hasClass('active')) {
  299. var $parent = $li.parent();
  300. var $content = e.data.$ul.next();
  301. var id = $li.find('a').attr('data-value');
  302. $parent.find('li.active').removeClass('active');
  303. $li.addClass('active');
  304. $content.children('.tab-pane.active').removeClass('active');
  305. $content.children('#' + id).addClass('active');
  306. callback && callback(id);
  307. }
  308. });
  309. }
  310. $.fn.lrFormTabEx = function (callback) {
  311. var $this = $(this);
  312. $this.delegate('li', 'click', { $ul: $this }, function (e) {
  313. var $li = $(this);
  314. if (!$li.hasClass('active')) {
  315. var $parent = $li.parent();
  316. var $content = e.data.$ul.next();
  317. var id = $li.find('a').attr('data-value');
  318. $parent.find('li.active').removeClass('active');
  319. $li.addClass('active');
  320. $content.find('.tab-pane.active').removeClass('active');
  321. $content.find('#' + id).addClass('active');
  322. if (!!callback) {
  323. callback(id);
  324. }
  325. }
  326. });
  327. }
  328. /*检测字段是否重复*/
  329. $.lrExistField = function (keyValue, controlId, url, param) {
  330. var $control = $("#" + controlId);
  331. if (!$control.val()) {
  332. return false;
  333. }
  334. var data = {
  335. keyValue: keyValue
  336. };
  337. data[controlId] = $control.val();
  338. $.extend(data, param);
  339. learun.httpAsync('GET', url, data, function (data) {
  340. if (data == false) {
  341. $.lrValidformMessage($control, '已存在,请重新输入');
  342. }
  343. });
  344. };
  345. /*固定下拉框的一些封装:数据字典,组织机构,省市区级联*/
  346. // 数据字典下拉框
  347. $.fn.lrDataItemSelect = function (op) {
  348. // op:code 码,parentId 父级id,maxHeight 200,allowSearch, childId 级联下级框id
  349. var dfop = {
  350. // 是否允许搜索
  351. allowSearch: false,
  352. // 访问数据接口地址
  353. //url: top.$.rootUrl + '/LR_SystemModule/DataItem/GetDetailListByParentId',
  354. // 访问数据接口参数
  355. param: { itemCode: '', parentId: '0' },
  356. // 级联下级框
  357. select: op.select,
  358. }
  359. op = op || {};
  360. if (!op.code) {
  361. return $(this);
  362. }
  363. if (!!op.type) {
  364. dfop.type = op.type;
  365. }
  366. dfop.param.itemCode = op.code;
  367. dfop.param.parentId = op.parentId || '0';
  368. dfop.allowSearch = op.allowSearch;
  369. var list = [];
  370. if (!!op.childId) {
  371. var list2 = [];
  372. $('#' + op.childId).lrselect({
  373. // 是否允许搜索
  374. allowSearch: dfop.allowSearch
  375. });
  376. dfop.select = function (item) {
  377. if (!item) {
  378. $('#' + op.childId).lrselectRefresh({
  379. data: []
  380. });
  381. } else {
  382. list2 = [];
  383. learun.clientdata.getAllAsync('dataItem',
  384. {
  385. code: dfop.param.itemCode,
  386. callback: function (dataes) {
  387. $.each(dataes,
  388. function (_index, _item) {
  389. if (_item.parentId == item.k) {
  390. list2.push({
  391. id: _item.text,
  392. text: _item.value,
  393. title: _item.text,
  394. k: _index
  395. });
  396. }
  397. });
  398. $('#' + op.childId).lrselectRefresh({
  399. data: list2
  400. });
  401. }
  402. });
  403. }
  404. };
  405. } else {
  406. if (!!op.select)
  407. dfop.select = op.select;
  408. }
  409. var $select = $(this).lrselect(dfop);
  410. learun.clientdata.getAllAsync('dataItem', {
  411. code: dfop.param.itemCode,
  412. callback: function (dataes) {
  413. $.each(dataes, function (_index, _item) {
  414. if (_item.parentId == dfop.param.parentId) {
  415. list.push({ id: _item.value, text: _item.text, title: _item.text, k: _index });
  416. }
  417. });
  418. $select.lrselectRefresh({
  419. data: list
  420. });
  421. }
  422. });
  423. return $select;
  424. };
  425. // 数据源下拉框
  426. $.fn.lrDataSourceSelect = function (op) {
  427. op = op || {};
  428. var dfop = {
  429. // 是否允许搜索
  430. allowSearch: true,
  431. select: op.select,
  432. placeholder: op.placeholder
  433. }
  434. if (!op.code) {
  435. return $(this);
  436. }
  437. var $select = $(this).lrselect(dfop);
  438. learun.clientdata.getAllAsync('sourceData', {
  439. code: op.code,
  440. callback: function (dataes) {
  441. $select.lrselectRefresh({
  442. value: op.value,
  443. text: op.text,
  444. title: op.text,
  445. codeTwo: op.codeTwo,
  446. data: dataes
  447. });
  448. }
  449. });
  450. return $select;
  451. }
  452. // 公司信息下拉框
  453. $.fn.lrCompanySelect = function (op) {
  454. // op:parentId 父级id,maxHeight 200,
  455. var dfop = {
  456. type: 'tree',
  457. // 是否允许搜索
  458. allowSearch: true,
  459. // 访问数据接口地址
  460. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  461. // 访问数据接口参数
  462. param: { parentId: '0' },
  463. };
  464. op = op || {};
  465. dfop.param.parentId = op.parentId || '0';
  466. if (!!op.isLocal) {
  467. dfop.url = '';
  468. }
  469. var $select = $(this).lrselect(dfop);
  470. if (!!op.isLocal) {
  471. learun.clientdata.getAllAsync('company', {
  472. callback: function (dataes) {
  473. var mapdata = {};
  474. var resdata = [];
  475. $.each(dataes, function (_index, _item) {
  476. mapdata[_item.parentId] = mapdata[_item.parentId] || [];
  477. _item.id = _index;
  478. mapdata[_item.parentId].push(_item);
  479. });
  480. _fn(resdata, dfop.param.parentId);
  481. function _fn(_data, vparentId) {
  482. var pdata = mapdata[vparentId] || [];
  483. for (var j = 0, l = pdata.length; j < l; j++) {
  484. var _item = pdata[j];
  485. var _point = {
  486. id: _item.id,
  487. text: _item.name,
  488. value: _item.id,
  489. showcheck: false,
  490. checkstate: false,
  491. hasChildren: false,
  492. isexpand: false,
  493. complete: true,
  494. ChildNodes: []
  495. };
  496. if (_fn(_point.ChildNodes, _item.id)) {
  497. _point.hasChildren = true;
  498. _point.isexpand = true;
  499. }
  500. _data.push(_point);
  501. }
  502. return _data.length > 0;
  503. }
  504. $select.lrselectRefresh({
  505. data: resdata
  506. });
  507. }
  508. });
  509. }
  510. return $select;
  511. };
  512. // 部门信息下拉框
  513. $.fn.lrDepartmentSelect = function (op) {
  514. // op:parentId 父级id,maxHeight 200,
  515. var dfop = {
  516. type: 'tree',
  517. // 是否允许搜索
  518. allowSearch: true,
  519. // 访问数据接口地址
  520. //url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree',
  521. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTreeNoCheck',
  522. // 访问数据接口参数
  523. param: { companyId: '', parentId: '0' },
  524. }
  525. op = op || {};
  526. dfop.param.companyId = op.companyId;
  527. dfop.param.parentId = op.parentId;
  528. dfop.maxHeight = op.maxHeight || 200;
  529. if (!!op.type) {
  530. dfop.type = op.type;
  531. }
  532. if (typeof (op.select) == 'function')
  533. dfop.select = op.select;
  534. if (dfop.type == "treemultiple") {
  535. dfop.url = top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree';
  536. }
  537. return $(this).lrselect(dfop);;
  538. };
  539. $.fn.lrPostSelect = function (op) {
  540. // op:parentId 父级id,maxHeight 200,
  541. var dfop = {
  542. type: 'tree',
  543. // 是否允许搜索
  544. allowSearch: true,
  545. // 访问数据接口地址
  546. url: top.$.rootUrl + '/LR_OrganizationModule/Post/GetAllTree',
  547. // 访问数据接口参数
  548. param: { companyId: '', parentId: '0' }
  549. };
  550. op = op || {};
  551. dfop.param.companyId = op.companyId;
  552. dfop.param.parentId = op.parentId;
  553. if (!!op.type) {
  554. dfop.type = op.type;
  555. }
  556. return $(this).lrselect(dfop);
  557. };
  558. // 人员下拉框
  559. $.fn.lrUserSelect = function (type, select) {//0单选1多选
  560. if (type == 0) {
  561. $(this).lrformselect({
  562. layerUrl: top.$.rootUrl + '/LR_OrganizationModule/User/SelectOnlyForm',
  563. layerUrlW: 400,
  564. layerUrlH: 300,
  565. dataUrl: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByUserIds',
  566. select: select
  567. });
  568. }
  569. else {
  570. $(this).lrformselect({
  571. layerUrl: top.$.rootUrl + '/LR_OrganizationModule/User/SelectForm',
  572. layerUrlW: 800,
  573. layerUrlH: 520,
  574. dataUrl: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByUserIds',
  575. select: select
  576. });
  577. }
  578. }
  579. // 省市区级联
  580. $.fn.lrAreaSelect = function (op) {
  581. // op:parentId 父级id,maxHeight 200,
  582. var dfop = {
  583. // 字段
  584. value: "F_AreaCode",
  585. text: "F_AreaName",
  586. title: "F_AreaName",
  587. // 是否允许搜索
  588. allowSearch: true,
  589. // 访问数据接口地址
  590. url: top.$.rootUrl + '/LR_SystemModule/Area/Getlist',
  591. // 访问数据接口参数
  592. param: { parentId: '' },
  593. }
  594. op = op || {};
  595. if (!!op.parentId) {
  596. dfop.param.parentId = op.parentId;
  597. }
  598. var _obj = [], i = 0;
  599. var $this = $(this);
  600. $(this).find('div').each(function () {
  601. var $div = $('<div></div>');
  602. var $obj = $(this);
  603. dfop.placeholder = $obj.attr('placeholder');
  604. $div.addClass($obj.attr('class'));
  605. $obj.removeAttr('class');
  606. $obj.removeAttr('placeholder');
  607. $div.append($obj);
  608. $this.append($div);
  609. if (i == 0) {
  610. $obj.lrselect(dfop);
  611. }
  612. else {
  613. dfop.url = "";
  614. dfop.parentId = "";
  615. $obj.lrselect(dfop);
  616. _obj[i - 1].on('change', function () {
  617. var _value = $(this).lrselectGet();
  618. if (_value == "") {
  619. $obj.lrselectRefresh({
  620. url: '',
  621. param: { parentId: _value },
  622. data: []
  623. });
  624. }
  625. else {
  626. $obj.lrselectRefresh({
  627. url: top.$.rootUrl + '/LR_SystemModule/Area/Getlist',
  628. param: { parentId: _value },
  629. });
  630. }
  631. });
  632. }
  633. i++;
  634. _obj.push($obj);
  635. });
  636. };
  637. // 数据库选择
  638. $.fn.lrDbSelect = function (op) {
  639. // op:maxHeight 200,
  640. var dfop = {
  641. type: 'tree',
  642. // 是否允许搜索
  643. allowSearch: true,
  644. // 访问数据接口地址
  645. url: top.$.rootUrl + '/LR_SystemModule/DatabaseLink/GetTreeList'
  646. }
  647. op = op || {};
  648. return $(this).lrselect(dfop);
  649. };
  650. // 动态获取和设置radio,checkbox
  651. $.fn.lrRadioCheckbox = function (op) {
  652. var dfop = {
  653. type: 'radio', // checkbox
  654. dataType: 'dataItem', // 默认是数据字典 dataSource(数据源)
  655. code: '',
  656. text: 'F_ItemName',
  657. value: 'F_ItemValue'
  658. };
  659. $.extend(dfop, op || {});
  660. var $this = $(this);
  661. $this.addClass(dfop.type);
  662. $this.addClass('lr-' + dfop.type);
  663. $this.attr('type', 'lr-' + dfop.type);
  664. var thisId = $this.attr('id');
  665. if (op.data != null) {
  666. $.each(op.data, function (id, item) {
  667. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  668. $this.append($point);
  669. });
  670. } else {
  671. if (dfop.dataType == 'dataItem') {
  672. learun.clientdata.getAllAsync('dataItem', {
  673. code: dfop.code,
  674. callback: function (dataes) {
  675. $.each(dataes, function (id, item) {
  676. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  677. $this.append($point);
  678. });
  679. // $this.find('input').eq(0).trigger('click');
  680. }
  681. });
  682. }
  683. else if (dfop.data) {
  684. $.each(dfop.data, function (id, item) {
  685. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  686. $this.append($point);
  687. });
  688. $this.find('input').eq(0).trigger('click');
  689. }
  690. else {
  691. learun.clientdata.getAllAsync('sourceData', {
  692. code: dfop.code,
  693. callback: function (dataes) {
  694. $.each(dataes, function (id, item) {
  695. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  696. $this.append($point);
  697. });
  698. $this.find('input').eq(0).trigger('click');
  699. }
  700. });
  701. }
  702. }
  703. };
  704. // 多条件查询框
  705. $.fn.lrMultipleQuery = function (search, height, width, isreadcard, readcallback) {
  706. var $this = $(this);
  707. var contentHtml = $this.html();
  708. $this.addClass('lr-query-wrap');
  709. var _html = '';
  710. _html += '<div class="lr-query-btn"><i class="fa fa-search"></i>&nbsp;多条件查询</div>';
  711. _html += '<div class="lr-query-content">';
  712. //_html += '<div class="lr-query-formcontent">';
  713. _html += contentHtml;
  714. //_html += '</div>';
  715. _html += '<div class="lr-query-arrow"><div class="lr-query-inside"></div></div>';
  716. _html += '<div class="lr-query-content-bottom">';
  717. if (!!isreadcard)
  718. _html += '<a id="lr_btn_readcard" class="btn btn-default">&nbsp;读&nbsp;&nbsp;取</a>';
  719. _html += '<a id="lr_btn_queryReset" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>';
  720. _html += '<a id="lr_btn_querySearch" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>';
  721. _html += '</div>';
  722. _html += '</div>';
  723. $this.html(_html);
  724. $this.find('.lr-query-formcontent').show();
  725. $this.find('.lr-query-content').css({ 'width': width || 400, 'height': height || 300 });
  726. $this.find('.lr-query-btn').on('click', function () {
  727. var $content = $this.find('.lr-query-content');
  728. if ($content.hasClass('active')) {
  729. $content.removeClass('active');
  730. }
  731. else {
  732. $content.addClass('active');
  733. }
  734. });
  735. $this.find('#lr_btn_querySearch').on('click', function () {
  736. var $content = $this.find('.lr-query-content');
  737. var query = $content.lrGetFormData();
  738. $content.removeClass('active');
  739. search(query);
  740. });
  741. $this.find('#lr_btn_queryReset').on('click', function () {
  742. var $content = $this.find('.lr-query-content');
  743. var query = $content.lrGetFormData();
  744. for (var id in query) {
  745. query[id] = "";
  746. }
  747. $content.lrSetFormData(query);
  748. });
  749. if (!!readcallback) {
  750. $this.find('#lr_btn_readcard').on('click', function () {
  751. readcallback();
  752. });
  753. }
  754. $(document).click(function (e) {
  755. var et = e.target || e.srcElement;
  756. var $et = $(et);
  757. if (!$et.hasClass('lr-query-wrap') && $et.parents('.lr-query-wrap').length <= 0) {
  758. $('.lr-query-content').removeClass('active');
  759. }
  760. });
  761. };
  762. // 获取表单显示数据
  763. $.fn.lrGetFormShow = function () {
  764. var resdata = [];
  765. $(this).find('.lr-form-item').each(function () {
  766. var $this = $(this);
  767. if ($this.is(':hidden')) {
  768. return;
  769. }
  770. var point = {};
  771. point.name = ($this.find('.lr-form-item-title').text() || '').replace('*', '');
  772. for (var i = 1; i < 13; i++) {
  773. if ($this.hasClass('col-xs-' + i)) {
  774. point.col = i;
  775. }
  776. }
  777. if ($this.find('.lr-form-item-title').length == 0) {
  778. if ($this.find('.jfgrid-layout').length == 0) {
  779. point.text = $this.html();
  780. point.type = 'title';
  781. resdata.push(point);
  782. }
  783. else {
  784. point.type = 'gird';
  785. point.gridHead = $this.find('.jfgrid-layout').jfGridGet('settingInfo').headData;
  786. point.data = $this.find('.jfgrid-layout').jfGridGet('showData');
  787. resdata.push(point);
  788. }
  789. }
  790. else {
  791. point.type = 'input';
  792. var list = $this.find('input,textarea,.lr-select,.edui-default');
  793. if (list.length > 0) {
  794. resdata.push(point);
  795. list.each(function () {
  796. var type = $(this).attr('type');
  797. switch (type) {
  798. case "radio":
  799. if ($(this).is(":checked")) {
  800. point.text = $(this).parent().text();
  801. }
  802. break;
  803. case "checkbox":
  804. if ($(this).is(":checked")) {
  805. point.textList = point.textList || [];
  806. point.textList.push($(this).parent().text());
  807. }
  808. break;
  809. case "lrselect":
  810. point.text = $(this).find('.lr-select-placeholder').text();
  811. break;
  812. default:
  813. if ($(this).hasClass('edui-default')) {
  814. if ($(this)[0].ue) {
  815. point.text = $(this)[0].ue.getContent(null, null, true);
  816. }
  817. }
  818. else {
  819. point.text = $(this).val();
  820. }
  821. break;
  822. }
  823. });
  824. }
  825. }
  826. });
  827. return resdata;
  828. }
  829. })(jQuery, top.learun);