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.
 
 
 
 
 
 

906 lines
34 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. 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. url: top.$.rootUrl + '/LR_OrganizationModule/Department/GetTreeNoCheck',
  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. if (dfop.type == "treemultiple") {
  538. dfop.url = top.$.rootUrl + '/LR_OrganizationModule/Department/GetTree';
  539. }
  540. return $(this).lrselect(dfop);;
  541. };
  542. $.fn.lrPostSelect = function (op) {
  543. // op:parentId 父级id,maxHeight 200,
  544. var dfop = {
  545. type: 'tree',
  546. // 是否允许搜索
  547. allowSearch: true,
  548. // 访问数据接口地址
  549. url: top.$.rootUrl + '/LR_OrganizationModule/Post/GetAllTree',
  550. // 访问数据接口参数
  551. param: { companyId: '', parentId: '0' }
  552. };
  553. op = op || {};
  554. dfop.param.companyId = op.companyId;
  555. dfop.param.parentId = op.parentId;
  556. if (!!op.type) {
  557. dfop.type = op.type;
  558. }
  559. return $(this).lrselect(dfop);
  560. };
  561. // 人员下拉框
  562. $.fn.lrUserSelect = function (type, select) {//0单选1多选
  563. if (type == 0) {
  564. $(this).lrformselect({
  565. layerUrl: top.$.rootUrl + '/LR_OrganizationModule/User/SelectOnlyForm',
  566. layerUrlW: 400,
  567. layerUrlH: 300,
  568. dataUrl: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByUserIds',
  569. select: select
  570. });
  571. }
  572. else {
  573. $(this).lrformselect({
  574. layerUrl: top.$.rootUrl + '/LR_OrganizationModule/User/SelectForm',
  575. layerUrlW: 800,
  576. layerUrlH: 520,
  577. dataUrl: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByUserIds',
  578. select: select
  579. });
  580. }
  581. }
  582. //角色下拉框
  583. $.fn.lrRoleSelect = function (op) {
  584. // op:parentId 父级id,maxHeight 200,
  585. var dfop = {
  586. type: 'tree',
  587. // 是否允许搜索
  588. allowSearch: true,
  589. // 访问数据接口地址
  590. url: top.$.rootUrl + '/LR_OrganizationModule/Role/GetTree',
  591. // 访问数据接口参数
  592. param: { parentId: '0' }
  593. };
  594. op = op || {};
  595. dfop.param.companyId = op.companyId;
  596. dfop.param.parentId = op.parentId;
  597. if (!!op.type) {
  598. dfop.type = op.type;
  599. }
  600. return $(this).lrselect(dfop);
  601. };
  602. // 省市区级联
  603. $.fn.lrAreaSelect = function (op) {
  604. // op:parentId 父级id,maxHeight 200,
  605. var dfop = {
  606. // 字段
  607. value: "F_AreaCode",
  608. text: "F_AreaName",
  609. title: "F_AreaName",
  610. // 是否允许搜索
  611. allowSearch: true,
  612. // 访问数据接口地址
  613. url: top.$.rootUrl + '/LR_SystemModule/Area/Getlist',
  614. // 访问数据接口参数
  615. param: { parentId: '' },
  616. }
  617. op = op || {};
  618. if (!!op.parentId) {
  619. dfop.param.parentId = op.parentId;
  620. }
  621. var _obj = [], i = 0;
  622. var $this = $(this);
  623. $(this).find('div').each(function () {
  624. var $div = $('<div></div>');
  625. var $obj = $(this);
  626. dfop.placeholder = $obj.attr('placeholder');
  627. $div.addClass($obj.attr('class'));
  628. $obj.removeAttr('class');
  629. $obj.removeAttr('placeholder');
  630. $div.append($obj);
  631. $this.append($div);
  632. if (i == 0) {
  633. $obj.lrselect(dfop);
  634. }
  635. else {
  636. dfop.url = "";
  637. dfop.parentId = "";
  638. $obj.lrselect(dfop);
  639. _obj[i - 1].on('change', function () {
  640. var _value = $(this).lrselectGet();
  641. if (_value == "") {
  642. $obj.lrselectRefresh({
  643. url: '',
  644. param: { parentId: _value },
  645. data: []
  646. });
  647. }
  648. else {
  649. $obj.lrselectRefresh({
  650. url: top.$.rootUrl + '/LR_SystemModule/Area/Getlist',
  651. param: { parentId: _value },
  652. });
  653. }
  654. });
  655. }
  656. i++;
  657. _obj.push($obj);
  658. });
  659. };
  660. // 数据库选择
  661. $.fn.lrDbSelect = function (op) {
  662. // op:maxHeight 200,
  663. var dfop = {
  664. type: 'tree',
  665. // 是否允许搜索
  666. allowSearch: true,
  667. // 访问数据接口地址
  668. url: top.$.rootUrl + '/LR_SystemModule/DatabaseLink/GetTreeList'
  669. }
  670. op = op || {};
  671. return $(this).lrselect(dfop);
  672. };
  673. // 动态获取和设置radio,checkbox
  674. $.fn.lrRadioCheckbox = function (op) {
  675. var dfop = {
  676. type: 'radio', // checkbox
  677. dataType: 'dataItem', // 默认是数据字典 dataSource(数据源)
  678. code: '',
  679. text: 'F_ItemName',
  680. value: 'F_ItemValue'
  681. };
  682. $.extend(dfop, op || {});
  683. var $this = $(this);
  684. $this.addClass(dfop.type);
  685. $this.addClass('lr-' + dfop.type);
  686. $this.attr('type', 'lr-' + dfop.type);
  687. var thisId = $this.attr('id');
  688. if (op.data != null) {
  689. $.each(op.data, function (id, item) {
  690. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  691. $this.append($point);
  692. });
  693. } else {
  694. if (dfop.dataType == 'dataItem') {
  695. learun.clientdata.getAllAsync('dataItem', {
  696. code: dfop.code,
  697. callback: function (dataes) {
  698. $.each(dataes, function (id, item) {
  699. var $point = $('<label><input name="' + thisId + '" value="' + item.value + '"' + ' type="' + dfop.type + '">' + item.text + '</label>');
  700. $this.append($point);
  701. });
  702. // $this.find('input').eq(0).trigger('click');
  703. }
  704. });
  705. }
  706. else if (dfop.data) {
  707. $.each(dfop.data, function (id, item) {
  708. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  709. $this.append($point);
  710. });
  711. $this.find('input').eq(0).trigger('click');
  712. }
  713. else {
  714. learun.clientdata.getAllAsync('sourceData', {
  715. code: dfop.code,
  716. callback: function (dataes) {
  717. $.each(dataes, function (id, item) {
  718. var $point = $('<label><input name="' + thisId + '" value="' + item[dfop.value] + '"' + '" type="' + dfop.type + '">' + item[dfop.text] + '</label>');
  719. $this.append($point);
  720. });
  721. $this.find('input').eq(0).trigger('click');
  722. }
  723. });
  724. }
  725. }
  726. };
  727. // 多条件查询框
  728. $.fn.lrMultipleQuery = function (search, height, width, isreadcard, readcallback) {
  729. var $this = $(this);
  730. var contentHtml = $this.html();
  731. $this.addClass('lr-query-wrap');
  732. var _html = '';
  733. _html += '<div class="lr-query-btn"><i class="fa fa-search"></i>&nbsp;多条件查询</div>';
  734. _html += '<div class="lr-query-content">';
  735. //_html += '<div class="lr-query-formcontent">';
  736. _html += contentHtml;
  737. //_html += '</div>';
  738. _html += '<div class="lr-query-arrow"><div class="lr-query-inside"></div></div>';
  739. _html += '<div class="lr-query-content-bottom">';
  740. if (!!isreadcard)
  741. _html += '<a id="lr_btn_readcard" class="btn btn-default">&nbsp;读&nbsp;&nbsp;取</a>';
  742. _html += '<a id="lr_btn_queryReset" class="btn btn-default">&nbsp;重&nbsp;&nbsp;置</a>';
  743. _html += '<a id="lr_btn_querySearch" class="btn btn-primary">&nbsp;查&nbsp;&nbsp;询</a>';
  744. _html += '</div>';
  745. _html += '</div>';
  746. $this.html(_html);
  747. $this.find('.lr-query-formcontent').show();
  748. $this.find('.lr-query-content').css({ 'width': width || 400, 'height': height || 300 });
  749. $this.find('.lr-query-btn').on('click', function () {
  750. var $content = $this.find('.lr-query-content');
  751. if ($content.hasClass('active')) {
  752. $content.removeClass('active');
  753. }
  754. else {
  755. $content.addClass('active');
  756. }
  757. });
  758. $this.find('#lr_btn_querySearch').on('click', function () {
  759. var $content = $this.find('.lr-query-content');
  760. var query = $content.lrGetFormData();
  761. $content.removeClass('active');
  762. search(query);
  763. });
  764. $this.find('#lr_btn_queryReset').on('click', function () {
  765. var $content = $this.find('.lr-query-content');
  766. var query = $content.lrGetFormData();
  767. for (var id in query) {
  768. query[id] = "";
  769. }
  770. $content.lrSetFormData(query);
  771. });
  772. if (!!readcallback) {
  773. $this.find('#lr_btn_readcard').on('click', function () {
  774. readcallback();
  775. });
  776. }
  777. $(document).click(function (e) {
  778. var et = e.target || e.srcElement;
  779. var $et = $(et);
  780. if (!$et.hasClass('lr-query-wrap') && $et.parents('.lr-query-wrap').length <= 0) {
  781. $('.lr-query-content').removeClass('active');
  782. }
  783. });
  784. };
  785. // 获取表单显示数据
  786. $.fn.lrGetFormShow = function () {
  787. var resdata = [];
  788. $(this).find('.lr-form-item').each(function () {
  789. var $this = $(this);
  790. if ($this.is(':hidden')) {
  791. return;
  792. }
  793. var point = {};
  794. point.name = ($this.find('.lr-form-item-title').text() || '').replace('*', '');
  795. for (var i = 1; i < 13; i++) {
  796. if ($this.hasClass('col-xs-' + i)) {
  797. point.col = i;
  798. }
  799. }
  800. if ($this.find('.lr-form-item-title').length == 0) {
  801. if ($this.find('.jfgrid-layout').length == 0) {
  802. point.text = $this.html();
  803. point.type = 'title';
  804. resdata.push(point);
  805. }
  806. else {
  807. point.type = 'gird';
  808. point.gridHead = $this.find('.jfgrid-layout').jfGridGet('settingInfo').headData;
  809. point.data = $this.find('.jfgrid-layout').jfGridGet('showData');
  810. resdata.push(point);
  811. }
  812. }
  813. else {
  814. point.type = 'input';
  815. var list = $this.find('input,textarea,.lr-select,.edui-default');
  816. if (list.length > 0) {
  817. resdata.push(point);
  818. list.each(function () {
  819. var type = $(this).attr('type');
  820. switch (type) {
  821. case "radio":
  822. if ($(this).is(":checked")) {
  823. point.text = $(this).parent().text();
  824. }
  825. break;
  826. case "checkbox":
  827. if ($(this).is(":checked")) {
  828. point.textList = point.textList || [];
  829. point.textList.push($(this).parent().text());
  830. }
  831. break;
  832. case "lrselect":
  833. point.text = $(this).find('.lr-select-placeholder').text();
  834. break;
  835. default:
  836. if ($(this).hasClass('edui-default')) {
  837. if ($(this)[0].ue) {
  838. point.text = $(this)[0].ue.getContent(null, null, true);
  839. } else {
  840. if ($(this)[0].getAttribute('id') == 'edui1_iframeholder') {
  841. var idNowIframe = $(this)[0].getElementsByTagName('iframe')[0].getAttribute('id')
  842. point.text = window.frames[idNowIframe].contentWindow.document.body.innerHTML
  843. }
  844. }
  845. }
  846. else {
  847. point.text = $(this).val();
  848. }
  849. break;
  850. }
  851. });
  852. }
  853. }
  854. });
  855. return resdata;
  856. }
  857. })(jQuery, top.learun);