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.
 
 
 
 
 
 

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