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.
 
 
 
 
 
 

900 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.replace('HH','hh')));
  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. dfop.placeholder = op.placeholder;
  370. var list = [];
  371. if (!!op.childId) {
  372. var list2 = [];
  373. $('#' + op.childId).lrselect({
  374. // 是否允许搜索
  375. allowSearch: dfop.allowSearch
  376. });
  377. dfop.select = function (item) {
  378. if (!item) {
  379. $('#' + op.childId).lrselectRefresh({
  380. data: []
  381. });
  382. } else {
  383. list2 = [];
  384. learun.clientdata.getAllAsync('dataItem',
  385. {
  386. code: dfop.param.itemCode,
  387. callback: function (dataes) {
  388. $.each(dataes,
  389. function (_index, _item) {
  390. if (_item.parentId == item.k) {
  391. list2.push({
  392. id: _item.text,
  393. text: _item.value,
  394. title: _item.text,
  395. k: _index
  396. });
  397. }
  398. });
  399. $('#' + op.childId).lrselectRefresh({
  400. data: list2
  401. });
  402. }
  403. });
  404. }
  405. };
  406. } else {
  407. if (!!op.select)
  408. dfop.select = op.select;
  409. }
  410. var $select = $(this).lrselect(dfop);
  411. learun.clientdata.getAllAsync('dataItem', {
  412. code: dfop.param.itemCode,
  413. callback: function (dataes) {
  414. $.each(dataes, function (_index, _item) {
  415. if (_item.parentId == dfop.param.parentId) {
  416. list.push({ id: _item.value, text: _item.text, title: _item.text, k: _index });
  417. }
  418. });
  419. $select.lrselectRefresh({
  420. data: list
  421. });
  422. }
  423. });
  424. return $select;
  425. };
  426. // 数据源下拉框
  427. $.fn.lrDataSourceSelect = function (op) {
  428. op = op || {};
  429. var dfop = {
  430. // 是否允许搜索
  431. allowSearch: true,
  432. select: op.select,
  433. placeholder: op.placeholder
  434. }
  435. if (!op.code) {
  436. return $(this);
  437. }
  438. if (!!op.type) {
  439. dfop.type = op.type;
  440. }
  441. var $select = $(this).lrselect(dfop);
  442. learun.clientdata.getAllAsync('sourceData', {
  443. code: op.code,
  444. callback: function (dataes) {
  445. $select.lrselectRefresh({
  446. value: op.value,
  447. text: op.text,
  448. title: op.text,
  449. codeTwo: op.codeTwo,
  450. data: dataes
  451. });
  452. }
  453. });
  454. return $select;
  455. }
  456. // 公司信息下拉框
  457. $.fn.lrCompanySelect = function (op) {
  458. // op:parentId 父级id,maxHeight 200,
  459. var dfop = {
  460. type: 'tree',
  461. // 是否允许搜索
  462. allowSearch: true,
  463. // 访问数据接口地址
  464. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  465. // 访问数据接口参数
  466. param: { parentId: '0' },
  467. };
  468. op = op || {};
  469. dfop.param.parentId = op.parentId || '0';
  470. if (!!op.isLocal) {
  471. dfop.url = '';
  472. }
  473. var $select = $(this).lrselect(dfop);
  474. if (!!op.isLocal) {
  475. learun.clientdata.getAllAsync('company', {
  476. callback: function (dataes) {
  477. var mapdata = {};
  478. var resdata = [];
  479. $.each(dataes, function (_index, _item) {
  480. mapdata[_item.parentId] = mapdata[_item.parentId] || [];
  481. _item.id = _index;
  482. mapdata[_item.parentId].push(_item);
  483. });
  484. _fn(resdata, dfop.param.parentId);
  485. function _fn(_data, vparentId) {
  486. var pdata = mapdata[vparentId] || [];
  487. for (var j = 0, l = pdata.length; j < l; j++) {
  488. var _item = pdata[j];
  489. var _point = {
  490. id: _item.id,
  491. text: _item.name,
  492. value: _item.id,
  493. showcheck: false,
  494. checkstate: false,
  495. hasChildren: false,
  496. isexpand: false,
  497. complete: true,
  498. ChildNodes: []
  499. };
  500. if (_fn(_point.ChildNodes, _item.id)) {
  501. _point.hasChildren = true;
  502. _point.isexpand = true;
  503. }
  504. _data.push(_point);
  505. }
  506. return _data.length > 0;
  507. }
  508. $select.lrselectRefresh({
  509. data: resdata
  510. });
  511. }
  512. });
  513. }
  514. return $select;
  515. };
  516. // 部门信息下拉框
  517. $.fn.lrDepartmentSelect = function (op) {
  518. // op:parentId 父级id,maxHeight 200,
  519. var dfop = {
  520. type: 'tree',
  521. // 是否允许搜索
  522. allowSearch: true,
  523. // 访问数据接口地址
  524. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree',
  525. // 访问数据接口参数
  526. param: { companyId: '', parentId: '0' },
  527. }
  528. op = op || {};
  529. dfop.param.companyId = op.companyId;
  530. dfop.param.parentId = op.parentId;
  531. dfop.maxHeight = op.maxHeight || 200;
  532. if (!!op.type) {
  533. dfop.type = op.type;
  534. }
  535. if (typeof (op.select) == 'function')
  536. dfop.select = op.select;
  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.lrRoleSelect = function (op) {
  639. // op:parentId 父级id,maxHeight 200,
  640. var dfop = {
  641. type: 'tree',
  642. // 是否允许搜索
  643. allowSearch: true,
  644. // 访问数据接口地址
  645. url: top.$.rootUrl + '/LR_OrganizationModule/Role/GetTree',
  646. // 访问数据接口参数
  647. param: { parentId: '0' }
  648. };
  649. op = op || {};
  650. dfop.param.companyId = op.companyId;
  651. dfop.param.parentId = op.parentId;
  652. if (!!op.type) {
  653. dfop.type = op.type;
  654. }
  655. return $(this).lrselect(dfop);
  656. };
  657. // 数据库选择
  658. $.fn.lrDbSelect = function (op) {
  659. // op:maxHeight 200,
  660. var dfop = {
  661. type: 'tree',
  662. // 是否允许搜索
  663. allowSearch: true,
  664. // 访问数据接口地址
  665. url: top.$.rootUrl + '/LR_SystemModule/DatabaseLink/GetTreeList'
  666. }
  667. op = op || {};
  668. return $(this).lrselect(dfop);
  669. };
  670. // 动态获取和设置radio,checkbox
  671. $.fn.lrRadioCheckbox = function (op) {
  672. var dfop = {
  673. type: 'radio', // checkbox
  674. dataType: 'dataItem', // 默认是数据字典 dataSource(数据源)
  675. code: '',
  676. text: 'F_ItemName',
  677. value: 'F_ItemValue'
  678. };
  679. $.extend(dfop, op || {});
  680. var $this = $(this);
  681. $this.addClass(dfop.type);
  682. $this.addClass('lr-' + dfop.type);
  683. $this.attr('type', 'lr-' + dfop.type);
  684. var thisId = $this.attr('id');
  685. if (op.data!=null) {
  686. $.each(op.data, function (id, item) {
  687. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  688. $this.append($point);
  689. });
  690. } else {
  691. if (dfop.dataType == 'dataItem') {
  692. learun.clientdata.getAllAsync('dataItem', {
  693. code: dfop.code,
  694. callback: function (dataes) {
  695. $.each(dataes, function (id, item) {
  696. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  697. $this.append($point);
  698. });
  699. // $this.find('input').eq(0).trigger('click');
  700. }
  701. });
  702. }
  703. else if (dfop.data) {
  704. $.each(dfop.data, function (id, item) {
  705. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  706. $this.append($point);
  707. });
  708. $this.find('input').eq(0).trigger('click');
  709. }
  710. else {
  711. learun.clientdata.getAllAsync('sourceData', {
  712. code: dfop.code,
  713. callback: function (dataes) {
  714. $.each(dataes, function (id, item) {
  715. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  716. $this.append($point);
  717. });
  718. $this.find('input').eq(0).trigger('click');
  719. }
  720. });
  721. }
  722. }
  723. };
  724. // 多条件查询框
  725. $.fn.lrMultipleQuery = function (search, height, width, isreadcard, readcallback) {
  726. var $this = $(this);
  727. var contentHtml = $this.html();
  728. $this.addClass('lr-query-wrap');
  729. var _html = '';
  730. _html += '<div class="lr-query-btn"><i class="fa fa-search"></i>&nbsp;多条件查询</div>';
  731. _html += '<div class="lr-query-content">';
  732. //_html += '<div class="lr-query-formcontent">';
  733. _html += contentHtml;
  734. //_html += '</div>';
  735. _html += '<div class="lr-query-arrow"><div class="lr-query-inside"></div></div>';
  736. _html += '<div class="lr-query-content-bottom">';
  737. if (!!isreadcard)
  738. _html += '<a id="lr_btn_readcard" class="btn btn-default">&nbsp;读&nbsp;&nbsp;取</a>';
  739. _html += '<a id="lr_btn_queryReset" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>';
  740. _html += '<a id="lr_btn_querySearch" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>';
  741. _html += '</div>';
  742. _html += '</div>';
  743. $this.html(_html);
  744. $this.find('.lr-query-formcontent').show();
  745. $this.find('.lr-query-content').css({ 'width': width || 400, 'height': height || 300 });
  746. $this.find('.lr-query-btn').on('click', function () {
  747. var $content = $this.find('.lr-query-content');
  748. if ($content.hasClass('active')) {
  749. $content.removeClass('active');
  750. }
  751. else {
  752. $content.addClass('active');
  753. }
  754. });
  755. $this.find('#lr_btn_querySearch').on('click', function () {
  756. var $content = $this.find('.lr-query-content');
  757. var query = $content.lrGetFormData();
  758. $content.removeClass('active');
  759. search(query);
  760. });
  761. $this.find('#lr_btn_queryReset').on('click', function () {
  762. var $content = $this.find('.lr-query-content');
  763. var query = $content.lrGetFormData();
  764. for (var id in query) {
  765. query[id] = "";
  766. }
  767. $content.lrSetFormData(query);
  768. });
  769. if (!!readcallback) {
  770. $this.find('#lr_btn_readcard').on('click', function () {
  771. readcallback();
  772. });
  773. }
  774. $(document).click(function (e) {
  775. var et = e.target || e.srcElement;
  776. var $et = $(et);
  777. if (!$et.hasClass('lr-query-wrap') && $et.parents('.lr-query-wrap').length <= 0) {
  778. $('.lr-query-content').removeClass('active');
  779. }
  780. });
  781. };
  782. // 获取表单显示数据
  783. $.fn.lrGetFormShow = function () {
  784. var resdata = [];
  785. $(this).find('.lr-form-item').each(function () {
  786. var $this = $(this);
  787. if ($this.is(':hidden')) {
  788. return;
  789. }
  790. var point = {};
  791. point.name = ($this.find('.lr-form-item-title').text() || '').replace('*', '');
  792. for (var i = 1; i < 13; i++) {
  793. if ($this.hasClass('col-xs-' + i)) {
  794. point.col = i;
  795. }
  796. }
  797. if ($this.find('.lr-form-item-title').length == 0) {
  798. if ($this.find('.jfgrid-layout').length == 0) {
  799. point.text = $this.html();
  800. point.type = 'title';
  801. resdata.push(point);
  802. }
  803. else {
  804. point.type = 'gird';
  805. point.gridHead = $this.find('.jfgrid-layout').jfGridGet('settingInfo').headData;
  806. point.data = $this.find('.jfgrid-layout').jfGridGet('showData');
  807. resdata.push(point);
  808. }
  809. }
  810. else {
  811. point.type = 'input';
  812. var list = $this.find('input,textarea,.lr-select,.edui-default');
  813. if (list.length > 0) {
  814. resdata.push(point);
  815. list.each(function () {
  816. var type = $(this).attr('type');
  817. switch (type) {
  818. case "radio":
  819. if ($(this).is(":checked")) {
  820. point.text = $(this).parent().text();
  821. }
  822. break;
  823. case "checkbox":
  824. if ($(this).is(":checked")) {
  825. point.textList = point.textList || [];
  826. point.textList.push($(this).parent().text());
  827. }
  828. break;
  829. case "lrselect":
  830. point.text = $(this).find('.lr-select-placeholder').text();
  831. break;
  832. default:
  833. if ($(this).hasClass('edui-default')) {
  834. if ($(this)[0].ue) {
  835. point.text = $(this)[0].ue.getContent(null, null, true);
  836. }
  837. }
  838. else {
  839. point.text = $(this).val();
  840. }
  841. break;
  842. }
  843. });
  844. }
  845. }
  846. });
  847. return resdata;
  848. }
  849. })(jQuery, top.learun);