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.
 
 
 
 
 
 

899 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. if (!!op.type) {
  438. dfop.type = op.type;
  439. }
  440. var $select = $(this).lrselect(dfop);
  441. learun.clientdata.getAllAsync('sourceData', {
  442. code: op.code,
  443. callback: function (dataes) {
  444. $select.lrselectRefresh({
  445. value: op.value,
  446. text: op.text,
  447. title: op.text,
  448. codeTwo: op.codeTwo,
  449. data: dataes
  450. });
  451. }
  452. });
  453. return $select;
  454. }
  455. // 公司信息下拉框
  456. $.fn.lrCompanySelect = function (op) {
  457. // op:parentId 父级id,maxHeight 200,
  458. var dfop = {
  459. type: 'tree',
  460. // 是否允许搜索
  461. allowSearch: true,
  462. // 访问数据接口地址
  463. url: top.$.rootUrl + '/LR_OrganizationModule/Company/GetTree',
  464. // 访问数据接口参数
  465. param: { parentId: '0' },
  466. };
  467. op = op || {};
  468. dfop.param.parentId = op.parentId || '0';
  469. if (!!op.isLocal) {
  470. dfop.url = '';
  471. }
  472. var $select = $(this).lrselect(dfop);
  473. if (!!op.isLocal) {
  474. learun.clientdata.getAllAsync('company', {
  475. callback: function (dataes) {
  476. var mapdata = {};
  477. var resdata = [];
  478. $.each(dataes, function (_index, _item) {
  479. mapdata[_item.parentId] = mapdata[_item.parentId] || [];
  480. _item.id = _index;
  481. mapdata[_item.parentId].push(_item);
  482. });
  483. _fn(resdata, dfop.param.parentId);
  484. function _fn(_data, vparentId) {
  485. var pdata = mapdata[vparentId] || [];
  486. for (var j = 0, l = pdata.length; j < l; j++) {
  487. var _item = pdata[j];
  488. var _point = {
  489. id: _item.id,
  490. text: _item.name,
  491. value: _item.id,
  492. showcheck: false,
  493. checkstate: false,
  494. hasChildren: false,
  495. isexpand: false,
  496. complete: true,
  497. ChildNodes: []
  498. };
  499. if (_fn(_point.ChildNodes, _item.id)) {
  500. _point.hasChildren = true;
  501. _point.isexpand = true;
  502. }
  503. _data.push(_point);
  504. }
  505. return _data.length > 0;
  506. }
  507. $select.lrselectRefresh({
  508. data: resdata
  509. });
  510. }
  511. });
  512. }
  513. return $select;
  514. };
  515. // 部门信息下拉框
  516. $.fn.lrDepartmentSelect = function (op) {
  517. // op:parentId 父级id,maxHeight 200,
  518. var dfop = {
  519. type: 'tree',
  520. // 是否允许搜索
  521. allowSearch: true,
  522. // 访问数据接口地址
  523. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree',
  524. // 访问数据接口参数
  525. param: { companyId: '', parentId: '0' },
  526. }
  527. op = op || {};
  528. dfop.param.companyId = op.companyId;
  529. dfop.param.parentId = op.parentId;
  530. dfop.maxHeight = op.maxHeight || 200;
  531. if (!!op.type) {
  532. dfop.type = op.type;
  533. }
  534. if (typeof (op.select) == 'function')
  535. dfop.select = op.select;
  536. return $(this).lrselect(dfop);;
  537. };
  538. $.fn.lrPostSelect = function (op) {
  539. // op:parentId 父级id,maxHeight 200,
  540. var dfop = {
  541. type: 'tree',
  542. // 是否允许搜索
  543. allowSearch: true,
  544. // 访问数据接口地址
  545. url: top.$.rootUrl + '/LR_OrganizationModule/Post/GetAllTree',
  546. // 访问数据接口参数
  547. param: { companyId: '', parentId: '0' }
  548. };
  549. op = op || {};
  550. dfop.param.companyId = op.companyId;
  551. dfop.param.parentId = op.parentId;
  552. if (!!op.type) {
  553. dfop.type = op.type;
  554. }
  555. return $(this).lrselect(dfop);
  556. };
  557. // 人员下拉框
  558. $.fn.lrUserSelect = function (type, select) {//0单选1多选
  559. if (type == 0) {
  560. $(this).lrformselect({
  561. layerUrl: top.$.rootUrl + '/LR_OrganizationModule/User/SelectOnlyForm',
  562. layerUrlW: 400,
  563. layerUrlH: 300,
  564. dataUrl: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByUserIds',
  565. select: select
  566. });
  567. }
  568. else {
  569. $(this).lrformselect({
  570. layerUrl: top.$.rootUrl + '/LR_OrganizationModule/User/SelectForm',
  571. layerUrlW: 800,
  572. layerUrlH: 520,
  573. dataUrl: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByUserIds',
  574. select: select
  575. });
  576. }
  577. }
  578. // 省市区级联
  579. $.fn.lrAreaSelect = function (op) {
  580. // op:parentId 父级id,maxHeight 200,
  581. var dfop = {
  582. // 字段
  583. value: "F_AreaCode",
  584. text: "F_AreaName",
  585. title: "F_AreaName",
  586. // 是否允许搜索
  587. allowSearch: true,
  588. // 访问数据接口地址
  589. url: top.$.rootUrl + '/LR_SystemModule/Area/Getlist',
  590. // 访问数据接口参数
  591. param: { parentId: '' },
  592. }
  593. op = op || {};
  594. if (!!op.parentId) {
  595. dfop.param.parentId = op.parentId;
  596. }
  597. var _obj = [], i = 0;
  598. var $this = $(this);
  599. $(this).find('div').each(function () {
  600. var $div = $('<div></div>');
  601. var $obj = $(this);
  602. dfop.placeholder = $obj.attr('placeholder');
  603. $div.addClass($obj.attr('class'));
  604. $obj.removeAttr('class');
  605. $obj.removeAttr('placeholder');
  606. $div.append($obj);
  607. $this.append($div);
  608. if (i == 0) {
  609. $obj.lrselect(dfop);
  610. }
  611. else {
  612. dfop.url = "";
  613. dfop.parentId = "";
  614. $obj.lrselect(dfop);
  615. _obj[i - 1].on('change', function () {
  616. var _value = $(this).lrselectGet();
  617. if (_value == "") {
  618. $obj.lrselectRefresh({
  619. url: '',
  620. param: { parentId: _value },
  621. data: []
  622. });
  623. }
  624. else {
  625. $obj.lrselectRefresh({
  626. url: top.$.rootUrl + '/LR_SystemModule/Area/Getlist',
  627. param: { parentId: _value },
  628. });
  629. }
  630. });
  631. }
  632. i++;
  633. _obj.push($obj);
  634. });
  635. };
  636. //获取角色
  637. $.fn.lrRoleSelect = function (op) {
  638. // op:parentId 父级id,maxHeight 200,
  639. var dfop = {
  640. type: 'tree',
  641. // 是否允许搜索
  642. allowSearch: true,
  643. // 访问数据接口地址
  644. url: top.$.rootUrl + '/LR_OrganizationModule/Role/GetTree',
  645. // 访问数据接口参数
  646. param: { parentId: '0' }
  647. };
  648. op = op || {};
  649. dfop.param.companyId = op.companyId;
  650. dfop.param.parentId = op.parentId;
  651. if (!!op.type) {
  652. dfop.type = op.type;
  653. }
  654. return $(this).lrselect(dfop);
  655. };
  656. // 数据库选择
  657. $.fn.lrDbSelect = function (op) {
  658. // op:maxHeight 200,
  659. var dfop = {
  660. type: 'tree',
  661. // 是否允许搜索
  662. allowSearch: true,
  663. // 访问数据接口地址
  664. url: top.$.rootUrl + '/LR_SystemModule/DatabaseLink/GetTreeList'
  665. }
  666. op = op || {};
  667. return $(this).lrselect(dfop);
  668. };
  669. // 动态获取和设置radio,checkbox
  670. $.fn.lrRadioCheckbox = function (op) {
  671. var dfop = {
  672. type: 'radio', // checkbox
  673. dataType: 'dataItem', // 默认是数据字典 dataSource(数据源)
  674. code: '',
  675. text: 'F_ItemName',
  676. value: 'F_ItemValue'
  677. };
  678. $.extend(dfop, op || {});
  679. var $this = $(this);
  680. $this.addClass(dfop.type);
  681. $this.addClass('lr-' + dfop.type);
  682. $this.attr('type', 'lr-' + dfop.type);
  683. var thisId = $this.attr('id');
  684. if (op.data!=null) {
  685. $.each(op.data, function (id, item) {
  686. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  687. $this.append($point);
  688. });
  689. } else {
  690. if (dfop.dataType == 'dataItem') {
  691. learun.clientdata.getAllAsync('dataItem', {
  692. code: dfop.code,
  693. callback: function (dataes) {
  694. $.each(dataes, function (id, item) {
  695. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  696. $this.append($point);
  697. });
  698. // $this.find('input').eq(0).trigger('click');
  699. }
  700. });
  701. }
  702. else if (dfop.data) {
  703. $.each(dfop.data, function (id, item) {
  704. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  705. $this.append($point);
  706. });
  707. $this.find('input').eq(0).trigger('click');
  708. }
  709. else {
  710. learun.clientdata.getAllAsync('sourceData', {
  711. code: dfop.code,
  712. callback: function (dataes) {
  713. $.each(dataes, function (id, item) {
  714. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  715. $this.append($point);
  716. });
  717. $this.find('input').eq(0).trigger('click');
  718. }
  719. });
  720. }
  721. }
  722. };
  723. // 多条件查询框
  724. $.fn.lrMultipleQuery = function (search, height, width, isreadcard, readcallback) {
  725. var $this = $(this);
  726. var contentHtml = $this.html();
  727. $this.addClass('lr-query-wrap');
  728. var _html = '';
  729. _html += '<div class="lr-query-btn"><i class="fa fa-search"></i>&nbsp;多条件查询</div>';
  730. _html += '<div class="lr-query-content">';
  731. //_html += '<div class="lr-query-formcontent">';
  732. _html += contentHtml;
  733. //_html += '</div>';
  734. _html += '<div class="lr-query-arrow"><div class="lr-query-inside"></div></div>';
  735. _html += '<div class="lr-query-content-bottom">';
  736. if (!!isreadcard)
  737. _html += '<a id="lr_btn_readcard" class="btn btn-default">&nbsp;读&nbsp;&nbsp;取</a>';
  738. _html += '<a id="lr_btn_queryReset" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>';
  739. _html += '<a id="lr_btn_querySearch" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>';
  740. _html += '</div>';
  741. _html += '</div>';
  742. $this.html(_html);
  743. $this.find('.lr-query-formcontent').show();
  744. $this.find('.lr-query-content').css({ 'width': width || 400, 'height': height || 300 });
  745. $this.find('.lr-query-btn').on('click', function () {
  746. var $content = $this.find('.lr-query-content');
  747. if ($content.hasClass('active')) {
  748. $content.removeClass('active');
  749. }
  750. else {
  751. $content.addClass('active');
  752. }
  753. });
  754. $this.find('#lr_btn_querySearch').on('click', function () {
  755. var $content = $this.find('.lr-query-content');
  756. var query = $content.lrGetFormData();
  757. $content.removeClass('active');
  758. search(query);
  759. });
  760. $this.find('#lr_btn_queryReset').on('click', function () {
  761. var $content = $this.find('.lr-query-content');
  762. var query = $content.lrGetFormData();
  763. for (var id in query) {
  764. query[id] = "";
  765. }
  766. $content.lrSetFormData(query);
  767. });
  768. if (!!readcallback) {
  769. $this.find('#lr_btn_readcard').on('click', function () {
  770. readcallback();
  771. });
  772. }
  773. $(document).click(function (e) {
  774. var et = e.target || e.srcElement;
  775. var $et = $(et);
  776. if (!$et.hasClass('lr-query-wrap') && $et.parents('.lr-query-wrap').length <= 0) {
  777. $('.lr-query-content').removeClass('active');
  778. }
  779. });
  780. };
  781. // 获取表单显示数据
  782. $.fn.lrGetFormShow = function () {
  783. var resdata = [];
  784. $(this).find('.lr-form-item').each(function () {
  785. var $this = $(this);
  786. if ($this.is(':hidden')) {
  787. return;
  788. }
  789. var point = {};
  790. point.name = ($this.find('.lr-form-item-title').text() || '').replace('*', '');
  791. for (var i = 1; i < 13; i++) {
  792. if ($this.hasClass('col-xs-' + i)) {
  793. point.col = i;
  794. }
  795. }
  796. if ($this.find('.lr-form-item-title').length == 0) {
  797. if ($this.find('.jfgrid-layout').length == 0) {
  798. point.text = $this.html();
  799. point.type = 'title';
  800. resdata.push(point);
  801. }
  802. else {
  803. point.type = 'gird';
  804. point.gridHead = $this.find('.jfgrid-layout').jfGridGet('settingInfo').headData;
  805. point.data = $this.find('.jfgrid-layout').jfGridGet('showData');
  806. resdata.push(point);
  807. }
  808. }
  809. else {
  810. point.type = 'input';
  811. var list = $this.find('input,textarea,.lr-select,.edui-default');
  812. if (list.length > 0) {
  813. resdata.push(point);
  814. list.each(function () {
  815. var type = $(this).attr('type');
  816. switch (type) {
  817. case "radio":
  818. if ($(this).is(":checked")) {
  819. point.text = $(this).parent().text();
  820. }
  821. break;
  822. case "checkbox":
  823. if ($(this).is(":checked")) {
  824. point.textList = point.textList || [];
  825. point.textList.push($(this).parent().text());
  826. }
  827. break;
  828. case "lrselect":
  829. point.text = $(this).find('.lr-select-placeholder').text();
  830. break;
  831. default:
  832. if ($(this).hasClass('edui-default')) {
  833. if ($(this)[0].ue) {
  834. point.text = $(this)[0].ue.getContent(null, null, true);
  835. }
  836. }
  837. else {
  838. point.text = $(this).val();
  839. }
  840. break;
  841. }
  842. });
  843. }
  844. }
  845. });
  846. return resdata;
  847. }
  848. })(jQuery, top.learun);