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.

Form.js 7.8 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. 
  2. /*
  3. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  4. * Copyright (c) 2013-2018 北京泉江科技有限公司
  5. * 创建人:陈彬彬
  6. * 日 期:2018.03.16
  7. * 描 述:功能模块
  8. */
  9. var keyValue = request('keyValue');
  10. var type = request('type');
  11. var acceptClick;
  12. var bootstrap = function ($, learun) {
  13. "use strict";
  14. var lrcomponts = [];
  15. var page = {
  16. init: function () {
  17. page.bind();
  18. page.initData();
  19. },
  20. /*绑定事件和初始化控件*/
  21. bind: function () {
  22. // 列表显示
  23. $('#listTitle').lrselect({
  24. type: 'multiple'
  25. });
  26. $('#listContent1').lrselect({ maxHeight: 160 });
  27. $('#listContent2').lrselect({ maxHeight: 160 });
  28. $('#listContent3').lrselect({ maxHeight: 160 });
  29. // 选择图标
  30. $('#selectIcon').on('click', function () {
  31. learun.layerForm({
  32. id: 'iconForm',
  33. title: '选择图标',
  34. url: top.$.rootUrl + '/Utility/AppIcon',
  35. height: 700,
  36. width: 1000,
  37. btn: null,
  38. maxmin: true,
  39. end: function () {
  40. if (top._learunSelectIcon != '') {
  41. $('#F_Icon').val(top._learunSelectIcon);
  42. }
  43. }
  44. });
  45. });
  46. // 分类
  47. $('#F_Type').lrDataItemSelect({ code: 'function' });
  48. $('#F_Type').lrselectSet(type);
  49. // 选在表单
  50. $('#F_FormId').lrselect({
  51. text: 'F_Name',
  52. value: 'F_Id',
  53. url: top.$.rootUrl + '/LR_FormModule/Custmerform/GetSchemeInfoList',
  54. maxHeight: 180,
  55. allowSearch: true,
  56. select: function (item) {
  57. if (item) {
  58. lrcomponts = [];
  59. $.lrSetForm(top.$.rootUrl + '/LR_FormModule/Custmerform/GetFormData?keyValue=' + item.F_Id, function (data) {
  60. var scheme = JSON.parse(data.schemeEntity.F_Scheme);
  61. for (var i = 0, l = scheme.data.length; i < l; i++) {
  62. var componts = scheme.data[i].componts;
  63. for (var j = 0, jl = componts.length; j < jl; j++) {
  64. var compont = componts[j];
  65. if (compont.type == 'gridtable') {
  66. }
  67. else {
  68. var point = { text: compont.title, id: compont.id };
  69. lrcomponts.push(point);
  70. }
  71. }
  72. }
  73. $('#listTitle').lrselectRefresh({
  74. data: lrcomponts
  75. });
  76. $('#listContent1').lrselectRefresh({
  77. data: lrcomponts
  78. });
  79. $('#listContent2').lrselectRefresh({
  80. data: lrcomponts
  81. });
  82. $('#listContent3').lrselectRefresh({
  83. data: lrcomponts
  84. });
  85. });
  86. } else {
  87. lrcomponts = [];
  88. $('#listTitle').lrselectRefresh({
  89. data: lrcomponts
  90. });
  91. $('#listContent1').lrselectRefresh({
  92. data: lrcomponts
  93. });
  94. $('#listContent2').lrselectRefresh({
  95. data: lrcomponts
  96. });
  97. $('#listContent3').lrselectRefresh({
  98. data: lrcomponts
  99. });
  100. }
  101. }
  102. });
  103. $('#lr_preview').on('click', function () {
  104. var formId = $('#F_FormId').lrselectGet();
  105. if (!!formId) {
  106. learun.layerForm({
  107. id: 'custmerForm_PreviewForm',
  108. title: '预览当前表单',
  109. url: top.$.rootUrl + '/LR_FormModule/Custmerform/PreviewForm?schemeInfoId=' + formId,
  110. width: 800,
  111. height: 600,
  112. maxmin: true,
  113. btn: null
  114. });
  115. }
  116. else {
  117. learun.alert.warning('请选择表单!');
  118. }
  119. });
  120. // 功能类型
  121. $('[name="F_IsSystem"]').on('click', function () {
  122. var value = $(this).val();
  123. if (value == 1) {
  124. $('.system').show();
  125. $('.nosystem').hide();
  126. } else {
  127. $('.system').hide();
  128. $('.nosystem').show();
  129. }
  130. });
  131. },
  132. /*初始化数据*/
  133. initData: function () {
  134. if (!!keyValue) {
  135. $.lrSetForm(top.$.rootUrl + '/AppManager/FunctionManager/GetForm?keyValue=' + keyValue, function (data) {//
  136. $('#form').lrSetFormData(data.entity);
  137. if (data.entity.F_IsSystem != 1 && data.schemeEntity) {
  138. var scheme = JSON.parse(data.schemeEntity.F_Scheme);
  139. $('#listTitle').lrselectSet(scheme.title);
  140. $('#listContent1').lrselectSet(scheme.content[0]);
  141. $('#listContent2').lrselectSet(scheme.content[1]);
  142. $('#listContent3').lrselectSet(scheme.content[2]);
  143. }
  144. });
  145. }
  146. }
  147. };
  148. // 保存数据
  149. acceptClick = function (callBack) {
  150. if (!$('#form').lrValidform()) {
  151. return false;
  152. }
  153. var formData = $('#form').lrGetFormData(keyValue);
  154. formData.F_IsSystem = $('[name="F_IsSystem"]:checked').val();
  155. var entity = {
  156. F_Name: formData.F_Name,
  157. F_Icon: formData.F_Icon,
  158. F_Type: formData.F_Type,
  159. F_SortCode: formData.F_SortCode,
  160. F_FormId: formData.F_FormId,
  161. F_SchemeId: formData.F_SchemeId,
  162. F_Url: formData.F_Url,
  163. F_IsSystem: formData.F_IsSystem,
  164. };
  165. if (formData.F_IsSystem == 1) {
  166. if ($.trim(formData.F_Url || '') == '') {
  167. learun.alert.error('请填写功能地址!');
  168. return false;
  169. }
  170. }
  171. else {
  172. if ($.trim(formData.listTitle || '') == '') {
  173. learun.alert.error('请设置列表展示!');
  174. return false;
  175. }
  176. }
  177. var scheme = {
  178. title: formData.listTitle,
  179. content:['','','']
  180. };
  181. scheme.content[0] = formData.listContent1;
  182. scheme.content[1] = formData.listContent2;
  183. scheme.content[2] = formData.listContent3;
  184. var schemeEntity = {
  185. F_Scheme: JSON.stringify(scheme)
  186. }
  187. // 提交数据
  188. var postData = {
  189. strEntity: JSON.stringify(entity),
  190. strSchemeEntity: JSON.stringify(schemeEntity)
  191. };
  192. $.lrSaveForm(top.$.rootUrl + '/AppManager/FunctionManager/SaveForm?keyValue=' + keyValue, postData, function (res) {
  193. // 保存成功后才回调
  194. if (!!callBack) {
  195. callBack();
  196. }
  197. });
  198. };
  199. page.init();
  200. }