learun-applayout.js 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551
  1. //表单设计
  2. $.fn.frmDesign = function (options) {
  3. var $frmdesigh = $(this);
  4. if (!$frmdesigh.attr('id')) {
  5. return false;
  6. }
  7. var defaults = {
  8. controlDataJson: [],
  9. tablefiledJsonData: "",
  10. frmContent: "",
  11. Height: 572,
  12. url: "",
  13. param: "",
  14. isSystemTable: 0,//默认是不绑定数据表的
  15. getData: function (isTest) {
  16. var postData = [];
  17. var j = 0;
  18. var _controlfieldHistory = {};
  19. for (var i in options.controlDataJson) {
  20. var rowJson = options.controlDataJson[i];
  21. if (rowJson.control_field == "" && isTest != true) {
  22. dialogTop("请输入字段Id", "error");
  23. $("#app_layout_list").find('[data-value=' + i + ']').addClass('activeerror');
  24. return false;
  25. }
  26. if (rowJson.control_label == "" && isTest != true) {
  27. dialogTop("请输入字段名称", "error");
  28. $("#app_layout_list").find('[data-value=' + i + ']').addClass('activeerror');
  29. return false;
  30. }
  31. if (isTest != true)
  32. {
  33. if (_controlfieldHistory[rowJson.control_field] != undefined)
  34. {
  35. dialogTop("字段Id有重复", "error");
  36. return false;
  37. }
  38. _controlfieldHistory[rowJson.control_field] = "1";
  39. }
  40. if (rowJson.control_item != undefined) {
  41. var controlitem = [];
  42. for (var j in rowJson.control_item) {
  43. controlitem.push(rowJson.control_item[j]);
  44. }
  45. rowJson.control_item = controlitem;
  46. }
  47. j++;
  48. postData.push(rowJson);
  49. }
  50. if (j == 0 && isTest != true)
  51. {
  52. dialogTop("不能是空表单", "error");
  53. return false;
  54. }
  55. return postData;
  56. }
  57. };
  58. var options = $.extend(defaults, options);
  59. var divhtml = '<div class="app_body"><div id="move_item_list" class="app_field">';
  60. divhtml += '<div class="item_row"><i id="text" class="fa fa-italic"></i>文本框</div>';
  61. divhtml += '<div class="item_row"><i id="textarea" class="fa fa-align-justify"></i>文本区</div>';
  62. divhtml += '<div class="item_row"><i id="texteditor" class="fa fa-edit"></i>编辑器</div>';
  63. divhtml += '<div class="item_row"><i id="radio" class="fa fa-circle-thin"></i>单选框</div>';
  64. divhtml += '<div class="item_row"><i id="checkbox" class="fa fa-square-o"></i>多选框</div>';
  65. divhtml += '<div class="item_row"><i id="select" class="fa fa-caret-square-o-right"></i>下拉框</div>';
  66. divhtml += '<div class="item_row"><i id="datetime" class="fa fa-calendar"></i>日期框</div>';
  67. divhtml += '<div class="item_row"><i id="image" class="fa fa-photo"></i>图片</div>';
  68. divhtml += '<div class="item_row"><i id="upload" class="fa fa-paperclip"></i>附件</div>';
  69. // divhtml += '<div class="item_row"><i id="departmentlist" class="fa fa-sitemap"></i>单位组织</div>';
  70. // divhtml += '<div class="item_row"><i id="dataitemlist" class="fa fa-book"></i>数据字典</div>';
  71. divhtml += '</div>';
  72. divhtml += '<div class="app_layout">';
  73. divhtml += ' <div id="app_layout_list" class="item_table notclose connectedSortable">';
  74. divhtml += ' <div class="guideareas"></div>';
  75. divhtml += ' </div>';
  76. divhtml += '</div>';
  77. divhtml += ' <div id="app_layout_option" class="field_option notclose">';
  78. divhtml += ' </div>';
  79. divhtml += '</div>';
  80. $frmdesigh.html(divhtml);
  81. $frmdesigh.find(".app_body").height(options.Height);
  82. $frmdesigh.find(".field_option").height(options.Height - 14).css("right", -240);
  83. $frmdesigh.find(".guideareas").height(options.Height - 33);
  84. var item_field_value_width = $(window).width() - 558;
  85. //表单控件拖动
  86. function formdesigner_move() {
  87. $("#move_item_list .item_row").draggable({
  88. connectToSortable: "#app_layout_list",
  89. helper: "clone",
  90. revert: "invalid"
  91. });
  92. $("#app_layout_list").sortable({
  93. opacity: 0.4,
  94. delay: 300,
  95. cursor: 'move',
  96. placeholder: "ui-state-highlight",
  97. stop: function (event, ui) {
  98. var random_id = String(Math.random()).substr(2);
  99. var $item_control = null;
  100. var $this_place = $(ui.item[0]);
  101. var controltype = $this_place.find('i').attr('id');
  102. var controlrowJson = {};
  103. controlrowJson["control_type"] = controltype;
  104. if (!!controltype) {
  105. switch (controltype) {
  106. case "text":
  107. $item_control = $('<div class="item_field_label"><span>文本框</span></div><div class="item_field_value">文本框</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  108. controlrowJson["control_label"] = "文本框";
  109. controlrowJson["control_field"] = "";
  110. controlrowJson["control_verify"] = "";
  111. controlrowJson["control_default"] = "";
  112. controlrowJson["control_required"] = "0";
  113. //controlrowJson["control_only"] = "0";
  114. options.controlDataJson[random_id] = controlrowJson;
  115. break;
  116. case "textarea":
  117. $item_control = $('<div class="item_field_label"><span>文本区</span></div><div class="item_field_value">文本区</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  118. controlrowJson["control_label"] = "文本区";
  119. controlrowJson["control_field"] = "";
  120. controlrowJson["control_verify"] = "";
  121. controlrowJson["control_height"] = "100px";
  122. controlrowJson["control_default"] = "";
  123. controlrowJson["control_required"] = "0";
  124. options.controlDataJson[random_id] = controlrowJson;
  125. break;
  126. case "texteditor":
  127. $item_control = $('<div class="item_field_label"><span>编辑器</span></div><div class="item_field_value">编辑器</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  128. controlrowJson["control_label"] = "编辑器";
  129. controlrowJson["control_field"] = "";
  130. controlrowJson["control_verify"] = "";
  131. controlrowJson["control_height"] = "200px";
  132. controlrowJson["control_default"] = "";
  133. controlrowJson["control_required"] = "0";
  134. options.controlDataJson[random_id] = controlrowJson;
  135. break;
  136. case "radio":
  137. $item_control = $('<div class="item_field_label"><span>单选项</span></div><div class="item_field_value">单选项/未添加选项</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  138. controlrowJson["control_label"] = "单选项";
  139. controlrowJson["control_field"] = "";
  140. controlrowJson["control_item"] = [];
  141. controlrowJson["control_required"] = "0";
  142. options.controlDataJson[random_id] = controlrowJson;
  143. break;
  144. case "checkbox":
  145. $item_control = $('<div class="item_field_label"><span>多选项</span></div><div class="item_field_value">多选项/未添加选项</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  146. controlrowJson["control_label"] = "多选项";
  147. controlrowJson["control_field"] = "";
  148. controlrowJson["control_item"] = [];
  149. controlrowJson["control_required"] = "0";
  150. options.controlDataJson[random_id] = controlrowJson;
  151. break;
  152. case "select":
  153. $item_control = $('<div class="item_field_label"><span>下拉框</span></div><div class="item_field_value">下拉框/未添加选项</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  154. controlrowJson["control_label"] = "下拉框";
  155. controlrowJson["control_field"] = "";
  156. controlrowJson["control_item"] = [];
  157. controlrowJson["control_required"] = "0";
  158. options.controlDataJson[random_id] = controlrowJson;
  159. break;
  160. case "datetime":
  161. $item_control = $('<div class="item_field_label"><span>日期框</span></div><div class="item_field_value">年-月-日</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  162. controlrowJson["control_label"] = "日期框";
  163. controlrowJson["control_field"] = "";
  164. controlrowJson["control_dateformat"] = "date";
  165. controlrowJson["control_default"] = "";
  166. controlrowJson["control_required"] = "0";
  167. options.controlDataJson[random_id] = controlrowJson;
  168. break;
  169. case "image":
  170. $item_control = $('<div class="item_field_label"><span>上传图片</span></div><div class="item_field_value">上传图片/jpg,gif,png,bmp</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  171. controlrowJson["control_label"] = "上传图片";
  172. controlrowJson["control_field"] = "";
  173. controlrowJson["control_fileformat"] = "jpg,gif,png,bmp";
  174. controlrowJson["control_required"] = "0";
  175. options.controlDataJson[random_id] = controlrowJson;
  176. break;
  177. case "upload":
  178. $item_control = $('<div class="item_field_label"><span>上传文件</span></div><div class="item_field_value">上传文件/doc,xls,ppt,pdf</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div>');
  179. controlrowJson["control_label"] = "上传文件";
  180. controlrowJson["control_field"] = "";
  181. controlrowJson["control_fileformat"] = "doc,xls,ppt,pdf";
  182. controlrowJson["control_required"] = "0";
  183. options.controlDataJson[random_id] = controlrowJson;
  184. break;
  185. case "departmentlist":
  186. break;
  187. case "dataitemlist":
  188. break;
  189. default:
  190. break;
  191. }
  192. if ($item_control) {
  193. $this_place.html($item_control);
  194. $this_place.find('.item_field_value').width(item_field_value_width);
  195. $this_place.attr('data-value', random_id)
  196. item_rowclick();
  197. $this_place.trigger("click");
  198. }
  199. } else {
  200. $this_place.trigger("click");
  201. }
  202. },
  203. start: function (event, ui) {
  204. $(".guideareas").hide()
  205. $(".ui-state-highlight").html('拖放控件到这里');
  206. $(".field_option").hide();
  207. $("#app_layout_list .item_row").removeClass('active')
  208. },
  209. out: function (event, ui) {
  210. if (ui.helper != null) {
  211. var falg = true;
  212. for (item in options.controlDataJson) {
  213. falg = false;
  214. break;
  215. }
  216. if (falg) {
  217. $(".guideareas").show();
  218. }
  219. }
  220. }
  221. });
  222. item_rowclick();
  223. function item_rowclick() {
  224. $("#app_layout_list .item_row").find('.item_field_remove i').click(function () {
  225. var $item_row = $(this).parents('.item_row');
  226. delete options.controlDataJson[$item_row.attr('data-value')];
  227. $item_row.remove();
  228. $(".field_option").animate({ right: -240, speed: 2000 });
  229. var falg = true;
  230. for (item in options.controlDataJson) {
  231. falg = false;
  232. break;
  233. }
  234. if (falg) {
  235. $(".guideareas").show();
  236. }
  237. });//移除空件
  238. $("#app_layout_list .item_row").unbind('click');
  239. $("#app_layout_list .item_row").click(function () {
  240. var $this = $(this);
  241. var $field_option = $(".field_option");
  242. $("#app_layout_list .item_row").removeClass('active').removeClass('activeerror');
  243. $this.addClass('active');
  244. $('.field_option').animate({ right: 0, speed: 2000 }).show();
  245. initControlProperty($this);
  246. });
  247. document.onclick = function (event) {
  248. try
  249. {
  250. var _event = event ? event : window.event;
  251. var _target = _event.target ? _event.target : _event.srcElement;
  252. var className = "";
  253. while (className != "app_body") {
  254. className = _target.className;
  255. if (className == undefined || className.indexOf("notclose") > 0) {
  256. break;
  257. }
  258. _target = _target.parentNode;
  259. if (_target == null) {
  260. break;
  261. }
  262. }
  263. if (className != undefined && className.indexOf("notclose") < 0 && _target != null) {
  264. $(".field_option").animate({ right: -240, speed: 2000 });
  265. $("#app_layout_list .item_row").removeClass('active').removeClass('activeerror');
  266. }
  267. }
  268. catch(e)
  269. {
  270. }
  271. };
  272. }
  273. //初始化控件属性
  274. function initControlProperty(e) {
  275. var rowJson = options.controlDataJson[e.attr('data-value')];
  276. if (rowJson) {
  277. switch (rowJson.control_type) {
  278. case "text":
  279. textProperty(e);
  280. break;
  281. case "textarea":
  282. textareaProperty(e);
  283. break;
  284. case "texteditor":
  285. texteditorProperty(e);
  286. break;
  287. break;
  288. case "radio":
  289. radioProperty(e);
  290. break;
  291. case "checkbox":
  292. checkboxProperty(e);
  293. break;
  294. case "select":
  295. selectProperty(e);
  296. break;
  297. case "datetime":
  298. datetimeProperty(e);
  299. break;
  300. case "image":
  301. imageProperty(e);
  302. break;
  303. case "upload":
  304. uploadProperty(e);
  305. break;
  306. case "departmentlist":
  307. break;
  308. case "dataitemlist":
  309. break;
  310. default:
  311. break;
  312. }
  313. } else {
  314. //$(".field_option").html("");
  315. }
  316. }
  317. //获取表单
  318. if (options.frmContent != "" && options.frmContent != null)
  319. {
  320. frmToHtml(options.frmContent);
  321. }
  322. else if (options.url != "") {
  323. $.ajax({
  324. url: options.url,
  325. data: options.param,
  326. type: "GET",
  327. dataType: "json",
  328. async: false,
  329. success: function (data) {
  330. if (data.FrmContent != null)
  331. {
  332. frmToHtml(data.FrmContent);
  333. }
  334. },
  335. error: function (XMLHttpRequest, textStatus, errorThrown) {
  336. dialogMsg(errorThrown, -1);
  337. }
  338. });
  339. }
  340. //json=>html
  341. function frmToHtml(frmContent) {
  342. var frmContentJson = eval('(' + frmContent + ')');
  343. var num = 0;
  344. $app_layout_list = $('#app_layout_list');
  345. $.each(frmContentJson, function (id, item) {
  346. $(".guideareas").hide();
  347. var random_id = String(Math.random()).substr(2);
  348. options.controlDataJson[random_id] = item;
  349. var controlitemstr = "";
  350. if (item.control_item != undefined) {
  351. var controlitem = [];
  352. $.each(item.control_item, function (i, n) {
  353. controlitem[n.identify] = n;
  354. if (controlitemstr != "") {
  355. controlitemstr += "、";
  356. }
  357. controlitemstr += n.name;
  358. });
  359. options.controlDataJson[random_id].control_item = controlitem;
  360. }
  361. var controlrequired = item.control_required == '1' ? '<font face="宋体">*</font>' : '';
  362. var _item_field_value = "";
  363. switch (item.control_type) {
  364. case "text":
  365. _item_field_value = "文本框";
  366. break;
  367. case "textarea":
  368. _item_field_value = "文本区";
  369. break;
  370. case "texteditor":
  371. _item_field_value = "编辑器";
  372. break;
  373. case "radio":
  374. _item_field_value = "单选项/";
  375. break;
  376. case "checkbox":
  377. _item_field_value = "多选项/";
  378. break;
  379. case "select":
  380. _item_field_value = "下拉框/";
  381. break;
  382. case "datetime":
  383. _item_field_value = "年-月-日";
  384. break;
  385. case "image":
  386. _item_field_value = "上传图片/" + item.control_fileformat;
  387. break;
  388. case "upload":
  389. _item_field_value = "上传文件/"+ item.control_fileformat;
  390. break;
  391. case "departmentlist":
  392. break;
  393. case "dataitemlist":
  394. break;
  395. default:
  396. break;
  397. }
  398. var $item_control = $('<div class="item_row ui-draggable" ><div class="item_field_label"><span>' + item.control_label + '</span>' + controlrequired + '</div><div class="item_field_value">' + _item_field_value + controlitemstr + '</div><div class="item_field_remove"><i title="移除控件" class="del fa fa-close"></i></div></div>');
  399. if ($item_control) {
  400. $item_control.attr('data-value', random_id);
  401. $app_layout_list.append($item_control);
  402. item_rowclick();
  403. if (num == 0) {
  404. $item_control.trigger("click");
  405. }
  406. num++;
  407. }
  408. });
  409. $app_layout_list.find('.item_field_value').width(item_field_value_width);
  410. }
  411. }
  412. formdesigner_move();
  413. function textProperty(e_row) {
  414. var _html = '';
  415. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>无样式的单行文本框</span></div>';
  416. _html += '<div class="field_title">字段标识</div>';
  417. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';//<input id="control_field" type="text" class="form-control" placeholder="必填项"/>
  418. _html += '<div class="field_title">字段说明</div>';
  419. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"/></div>';
  420. _html += '<div class="field_title">字段验证</div>';
  421. _html += '<div class="field_control"><select id="control_verify" class="form-control"><option value="">==请选择==</option><option value="Num">数字</option><option value="Double">小数</option><option value="Phone">必须电话格式</option><option value="Mobile">手机格式</option><option value="Email">电子邮件格式</option><option value="IDCard">身份证格式</option></select></div>';
  422. _html += '<div class="field_title">默认值<i title="仅在添加数据时默认填入" class="help fa fa-question-circle"></i></div>';
  423. _html += '<div class="field_control"><input id="control_default" type="text" class="form-control" placeholder="无则不填"/></div>';
  424. _html += '<div class="field_title">设置</div>';
  425. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox" />必填</label></div></div>';//<label><input id="control_only" type="checkbox" />唯一<i title="字段中填入的值不可重复" class="help fa fa-question-circle"></i></label>
  426. var $html = $(_html);
  427. $(".field_option").html($html);
  428. var rowJson = options.controlDataJson[e_row.attr('data-value')];
  429. if (rowJson == null) {
  430. return false;
  431. }
  432. setControlField(rowJson, e_row, $html);
  433. $html.find('#control_label').val(rowJson.control_label);
  434. $html.find('#control_verify').val(rowJson.control_verify);
  435. $html.find('#control_default').val(rowJson.control_default);
  436. if (rowJson.control_required == 1) {
  437. $html.find('#control_required').attr("checked", 'checked');
  438. } else {
  439. $html.find('#control_required').removeAttr("checked");
  440. }
  441. $html.find('#control_label').keyup(function (e) {
  442. var value = $(this).val();
  443. e_row.find('.item_field_label').find('span').html(value);
  444. rowJson[$(this).attr('id')] = value;
  445. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  446. });
  447. $html.find('#control_verify').change(function (e) {
  448. var value = $(this).val();
  449. rowJson[$(this).attr('id')] = value;
  450. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  451. });
  452. $html.find('#control_default').keyup(function (e) {
  453. var value = $(this).val();
  454. rowJson[$(this).attr('id')] = value;
  455. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  456. });
  457. $html.find('#control_required').click(function (e) {
  458. var value = 0;
  459. if ($(this).attr("checked")) {
  460. value = 0;
  461. $(this).attr("checked", false);
  462. e_row.find('.item_field_label').find('font').remove();
  463. } else {
  464. value = 1;
  465. $(this).attr("checked", true);
  466. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  467. }
  468. rowJson[$(this).attr('id')] = value;
  469. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  470. });
  471. //$html.find('#control_only').click(function (e) {
  472. // var value = 0;
  473. // if ($(this).attr("checked")) {
  474. // $(this).attr("checked", false);
  475. // value = 0;
  476. // } else {
  477. // $(this).attr("checked", true);
  478. // value = 1;
  479. // }
  480. // rowJson[$(this).attr('id')] = value;
  481. // controlDataJson[e_row.attr('data-value')] = rowJson;
  482. //});
  483. }
  484. function textareaProperty(e_row) {
  485. var _html = '';
  486. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>无样式的多行文本框</span></div>';
  487. _html += '<div class="field_title">字段标识</div>';
  488. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  489. _html += '<div class="field_title">字段说明</div>';
  490. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  491. _html += '<div class="field_title">字段高度</div>';
  492. _html += '<div class="field_control"><input id="control_height" type="text" class="form-control" value="100px"></div>';
  493. _html += '<div class="field_title">默认值<i title="仅在添加数据时默认填入" class="help fa fa-question-circle"></i></div>';
  494. _html += '<div class="field_control"><input id="control_default" type="text" class="form-control" placeholder="无则不填"></div>';
  495. _html += '<div class="field_title">设置</div>';
  496. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  497. var $html = $(_html);
  498. $(".field_option").html($html);
  499. var rowJson = options.controlDataJson[e_row.attr('data-value')];
  500. if (rowJson == null) {
  501. return false;
  502. }
  503. setControlField(rowJson, e_row, $html);
  504. $html.find('#control_label').val(rowJson.control_label);
  505. $html.find('#control_verify').val(rowJson.control_verify);
  506. $html.find('#control_height').val(rowJson.control_height);
  507. $html.find('#control_default').val(rowJson.control_default);
  508. if (rowJson.control_required == 1) {
  509. $html.find('#control_required').attr("checked", 'checked');
  510. } else {
  511. $html.find('#control_required').removeAttr("checked");
  512. }
  513. $html.find('#control_label').keyup(function (e) {
  514. var value = $(this).val();
  515. e_row.find('.item_field_label').find('span').html(value);
  516. rowJson[$(this).attr('id')] = value;
  517. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  518. });
  519. $html.find('#control_verify').change(function (e) {
  520. var value = $(this).val();
  521. rowJson[$(this).attr('id')] = value;
  522. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  523. });
  524. $html.find('#control_height').change(function (e) {
  525. var value = $(this).val();
  526. rowJson[$(this).attr('id')] = value;
  527. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  528. });
  529. $html.find('#control_default').keyup(function (e) {
  530. var value = $(this).val();
  531. rowJson[$(this).attr('id')] = value;
  532. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  533. });
  534. $html.find('#control_required').click(function (e) {
  535. var value = 0;
  536. if ($(this).attr("checked")) {
  537. value = 0;
  538. $(this).attr("checked", false);
  539. e_row.find('.item_field_label').find('font').remove();
  540. } else {
  541. value = 1;
  542. $(this).attr("checked", true);
  543. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  544. }
  545. rowJson[$(this).attr('id')] = value;
  546. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  547. });
  548. }
  549. function texteditorProperty(e_row) {
  550. var _html = '';
  551. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>类似word,可设置丰富文字样式的多行文本编辑区</span></div>';
  552. _html += '<div class="field_title">字段标识</div>';
  553. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  554. _html += '<div class="field_title">字段说明</div>';
  555. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  556. _html += '<div class="field_title">字段高度</div>';
  557. _html += '<div class="field_control"><input id="control_height" type="text" class="form-control" value="200px"></div>';
  558. _html += '<div class="field_title">默认值<i title="仅在添加数据时默认填入" class="help fa fa-question-circle"></i></div>';
  559. _html += '<div class="field_control"><input id="control_default" type="text" class="form-control" placeholder="无则不填"></div>';
  560. _html += '<div class="field_title">设置</div>';
  561. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  562. var $html = $(_html);
  563. $(".field_option").html($html);
  564. var rowJson = options.controlDataJson[e_row.attr('data-value')];
  565. if (rowJson == null) {
  566. return false;
  567. }
  568. setControlField(rowJson, e_row, $html);
  569. $html.find('#control_label').val(rowJson.control_label);
  570. $html.find('#control_verify').val(rowJson.control_verify);
  571. $html.find('#control_height').val(rowJson.control_height);
  572. $html.find('#control_default').val(rowJson.control_default);
  573. if (rowJson.control_required == 1) {
  574. $html.find('#control_required').attr("checked", 'checked');
  575. } else {
  576. $html.find('#control_required').removeAttr("checked");
  577. }
  578. $html.find('#control_label').keyup(function (e) {
  579. var value = $(this).val();
  580. e_row.find('.item_field_label').find('span').html(value);
  581. rowJson[$(this).attr('id')] = value;
  582. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  583. });
  584. $html.find('#control_verify').change(function (e) {
  585. var value = $(this).val();
  586. rowJson[$(this).attr('id')] = value;
  587. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  588. });
  589. $html.find('#control_height').change(function (e) {
  590. var value = $(this).val();
  591. rowJson[$(this).attr('id')] = value;
  592. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  593. });
  594. $html.find('#control_default').keyup(function (e) {
  595. var value = $(this).val();
  596. rowJson[$(this).attr('id')] = value;
  597. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  598. });
  599. $html.find('#control_required').click(function (e) {
  600. var value = 0;
  601. if ($(this).attr("checked")) {
  602. value = 0;
  603. $(this).attr("checked", false);
  604. e_row.find('.item_field_label').find('font').remove();
  605. } else {
  606. value = 1;
  607. $(this).attr("checked", true);
  608. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  609. }
  610. rowJson[$(this).attr('id')] = value;
  611. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  612. });
  613. }
  614. function radioProperty(e_row) {
  615. var _html = '';
  616. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>显示所有备选项,从中只可选择一项</span></div>';
  617. _html += '<div class="field_title">字段标识</div>';
  618. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  619. _html += '<div class="field_title">字段说明</div>';
  620. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  621. _html += '<div class="field_title">备选项<div class="addclassify"><a><i class="fa fa-plus"></i>添加</a></div></div>';
  622. _html += '<div class="field_control"><ul class="classify"></ul></div>';
  623. _html += '<div class="field_title">设置</div>';
  624. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  625. var $html = $(_html);
  626. $(".field_option").html($html);
  627. var getRowJson = options.controlDataJson[e_row.attr('data-value')];
  628. if (getRowJson == null) {
  629. return false;
  630. }
  631. setControlField(getRowJson, e_row, $html);
  632. $html.find('#control_label').val(getRowJson.control_label);
  633. if (getRowJson.control_required == 1) {
  634. $html.find('#control_required').attr("checked", 'checked');
  635. } else {
  636. $html.find('#control_required').removeAttr("checked");
  637. }
  638. $html.find('#control_label').keyup(function (e) {
  639. var value = $(this).val();
  640. e_row.find('.item_field_label').find('span').html(value);
  641. getRowJson[$(this).attr('id')] = value;
  642. options.controlDataJson[e_row.attr('data-value')] = getRowJson;
  643. });
  644. $html.find('#control_required').click(function (e) {
  645. var value = 0;
  646. if ($(this).attr("checked")) {
  647. value = 0;
  648. $(this).attr("checked", false);
  649. e_row.find('.item_field_label').find('font').remove();
  650. } else {
  651. value = 1;
  652. $(this).attr("checked", true);
  653. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  654. }
  655. getRowJson[$(this).attr('id')] = value;
  656. options.controlDataJson[e_row.attr('data-value')] = getRowJson;
  657. });
  658. //处理备选项
  659. var $classify = $(".field_control .classify");
  660. $classify.sortable({
  661. handle: '.dragitem',
  662. stop: function (event, ui) {
  663. var tempitemjson = controlItemListJson;
  664. controlItemListJson = {};
  665. $classify.find('li').each(function (i) {
  666. var id = $(this).attr('data-value');
  667. controlItemListJson[id] = tempitemjson[id];
  668. });
  669. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  670. var _name = [];
  671. for (var i in controlItemListJson) {
  672. if (controlItemListJson[i].name) {
  673. _name.push(controlItemListJson[i].name)
  674. };
  675. }
  676. e_row.find('.item_field_value').html('单选项/' + String(_name).replace(/,/g, '、'));
  677. }
  678. });
  679. //选项列表Json
  680. var controlItemListJson = options.controlDataJson[e_row.attr('data-value')]["control_item"];
  681. for (var i in controlItemListJson) {
  682. additem(i);
  683. var $thisObjectRow = $classify.find('[data-value=' + i + ']');
  684. $thisObjectRow.find('input[name=name]').val(controlItemListJson[i].name);
  685. $thisObjectRow.find('em').attr('class', controlItemListJson[i].color);
  686. $thisObjectRow.find('input[name=defaults]').attr("checked", controlItemListJson[i].defaults == 1 ? true : false);
  687. }
  688. //添加一项li
  689. $('.addclassify').find('a').click(function () {
  690. var random_id = String(Math.random()).substr(2);
  691. controlItemListJson[random_id] = {
  692. identify: random_id,
  693. color: "color_a",
  694. name: "",
  695. defaults: "0",
  696. }
  697. additem(random_id);
  698. })
  699. function additem(random_id) {
  700. var $li = $('<li><span><em title="色彩" class="color_a"></em><i title="移除" class="fa fa-close"></i></span><i class="dragitem fa fa-arrows"></i><input name="defaults" type="radio" title="设置默认值"><input name="name" type="text" placeholder="请填写备选项"></li>');
  701. $li.attr('data-value', random_id)
  702. $classify.append($li);
  703. //移除一项li
  704. $li.find('i.fa-close').click(function () {
  705. var id = $(this).parents('li').attr('data-value');
  706. delete controlItemListJson[id];
  707. $(this).parents('li').remove();
  708. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  709. var _name = [];
  710. for (var i in controlItemListJson) {
  711. if (controlItemListJson[i].name) {
  712. _name.push(controlItemListJson[i].name)
  713. };
  714. }
  715. e_row.find('.item_field_value').html('单选项/' + String(_name).replace(/,/g, '、'));
  716. });
  717. //点击切换色彩
  718. var clickindex = 1;
  719. $li.find('em').click(function () {
  720. var color = ['color_a', 'color_b', 'color_c', 'color_d', 'color_e', 'color_f', 'color_g', 'color_h', 'color_i'];
  721. $(this).attr('class', color[clickindex]);
  722. controlItemListJson[$(this).parents('li').attr('data-value')].color = color[clickindex];
  723. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  724. clickindex++;
  725. if (clickindex == 9) {
  726. clickindex = 0
  727. }
  728. });
  729. //默认值事件
  730. $li.find('input[name=defaults]').click(function () {
  731. for (var i in controlItemListJson) {
  732. controlItemListJson[i].defaults = 0;
  733. }
  734. controlItemListJson[$(this).parents('li').attr('data-value')].defaults = 1;
  735. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  736. });
  737. //输入事件
  738. $li.find('input[name=name]').change(function () {
  739. var value = $(this).val();
  740. controlItemListJson[$(this).parents('li').attr('data-value')].name = value;
  741. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  742. var _name = [];
  743. for (var i in controlItemListJson) {
  744. if (controlItemListJson[i].name) {
  745. _name.push(controlItemListJson[i].name);
  746. }
  747. }
  748. e_row.find('.item_field_value').html('单选项/' + String(_name).replace(/,/g, '、'));
  749. })
  750. }
  751. if ($classify.find('li').length == 0) {
  752. $('.addclassify').find('a').trigger("click");
  753. }
  754. }
  755. function checkboxProperty(e_row) {
  756. var _html = '';
  757. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>显示所有备选项,从中可以选择多项</span></div>';
  758. _html += '<div class="field_title">字段标识</div>';
  759. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  760. _html += '<div class="field_title">字段说明</div>';
  761. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  762. _html += '<div class="field_title">备选项<div class="addclassify"><a><i class="fa fa-plus"></i>添加</a></div></div>';
  763. _html += '<div class="field_control"><ul class="classify"></ul></div>';
  764. _html += '<div class="field_title">设置</div>';
  765. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  766. var $html = $(_html);
  767. $(".field_option").html($html);
  768. var getRowJson = options.controlDataJson[e_row.attr('data-value')];
  769. if (getRowJson == null) {
  770. return false;
  771. }
  772. setControlField(getRowJson, e_row, $html);
  773. $html.find('#control_label').val(getRowJson.control_label);
  774. if (getRowJson.control_required == 1) {
  775. $html.find('#control_required').attr("checked", 'checked');
  776. } else {
  777. $html.find('#control_required').removeAttr("checked");
  778. }
  779. $html.find('#control_label').keyup(function (e) {
  780. var value = $(this).val();
  781. e_row.find('.item_field_label').find('span').html(value);
  782. getRowJson[$(this).attr('id')] = value;
  783. options.controlDataJson[e_row.attr('data-value')] = getRowJson;
  784. });
  785. $html.find('#control_required').click(function (e) {
  786. var value = 0;
  787. if ($(this).attr("checked")) {
  788. value = 0;
  789. $(this).attr("checked", false);
  790. e_row.find('.item_field_label').find('font').remove();
  791. } else {
  792. value = 1;
  793. $(this).attr("checked", true);
  794. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  795. }
  796. getRowJson[$(this).attr('id')] = value;
  797. options.controlDataJson[e_row.attr('data-value')] = getRowJson;
  798. });
  799. //处理备选项
  800. var $classify = $(".field_control .classify");
  801. $classify.sortable({
  802. handle: '.dragitem',
  803. stop: function (event, ui) {
  804. var tempitemjson = controlItemListJson;
  805. controlItemListJson = {};
  806. $classify.find('li').each(function (i) {
  807. var id = $(this).attr('data-value');
  808. controlItemListJson[id] = tempitemjson[id];
  809. });
  810. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  811. var _name = [];
  812. for (var i in controlItemListJson) {
  813. if (controlItemListJson[i].name) {
  814. _name.push(controlItemListJson[i].name)
  815. };
  816. }
  817. e_row.find('.item_field_value').html('多选项/' + String(_name).replace(/,/g, '、'));
  818. }
  819. });
  820. //选项列表Json
  821. var controlItemListJson = options.controlDataJson[e_row.attr('data-value')]["control_item"];
  822. for (var i in controlItemListJson) {
  823. additem(i);
  824. var $thisObjectRow = $classify.find('[data-value=' + i + ']');
  825. $thisObjectRow.find('input[name=name]').val(controlItemListJson[i].name);
  826. $thisObjectRow.find('em').attr('class', controlItemListJson[i].color);
  827. $thisObjectRow.find('input[name=defaults]').attr("checked", controlItemListJson[i].defaults == 1 ? true : false);
  828. }
  829. //添加一项li
  830. $('.addclassify').find('a').click(function () {
  831. var random_id = String(Math.random()).substr(2);
  832. controlItemListJson[random_id] = {
  833. identify: random_id,
  834. color: "color_a",
  835. name: "",
  836. defaults: "0",
  837. }
  838. additem(random_id);
  839. })
  840. function additem(random_id) {
  841. var $li = $('<li><span><em title="色彩" class="color_a"></em><i title="移除" class="fa fa-close"></i></span><i class="dragitem fa fa-arrows"></i><input name="defaults" type="checkbox" title="设置默认值"><input name="name" type="text" placeholder="请填写备选项"></li>');
  842. $li.attr('data-value', random_id)
  843. $classify.append($li);
  844. //移除一项li
  845. $li.find('i.fa-close').click(function () {
  846. var id = $(this).parents('li').attr('data-value');
  847. delete controlItemListJson[id];
  848. $(this).parents('li').remove();
  849. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  850. var _name = [];
  851. for (var i in controlItemListJson) {
  852. if (controlItemListJson[i].name) {
  853. _name.push(controlItemListJson[i].name)
  854. };
  855. }
  856. e_row.find('.item_field_value').html('多选项/' + String(_name).replace(/,/g, '、'));
  857. });
  858. //点击切换色彩
  859. var clickindex = 1;
  860. $li.find('em').click(function () {
  861. var color = ['color_a', 'color_b', 'color_c', 'color_d', 'color_e', 'color_f', 'color_g', 'color_h', 'color_i'];
  862. $(this).attr('class', color[clickindex]);
  863. controlItemListJson[$(this).parents('li').attr('data-value')].color = color[clickindex];
  864. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  865. clickindex++;
  866. if (clickindex == 9) {
  867. clickindex = 0
  868. }
  869. });
  870. //复选框事件
  871. $li.find('input[name=defaults]').click(function () {
  872. controlItemListJson[$(this).parents('li').attr('data-value')].defaults = 1;
  873. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  874. });
  875. //输入事件
  876. $li.find('input[name=name]').keyup(function () {
  877. var value = $(this).val();
  878. controlItemListJson[$(this).parents('li').attr('data-value')].name = value;
  879. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  880. var _name = [];
  881. for (var i in controlItemListJson) {
  882. if (controlItemListJson[i].name) {
  883. _name.push(controlItemListJson[i].name);
  884. }
  885. }
  886. e_row.find('.item_field_value').html('多选项/' + String(_name).replace(/,/g, '、'));
  887. })
  888. }
  889. if ($classify.find('li').length == 0) {
  890. $('.addclassify').find('a').trigger("click");
  891. }
  892. }
  893. function selectProperty(e_row) {
  894. var _html = '';
  895. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>显示所有备选项,从中只可选择一项</span></div>';
  896. _html += '<div class="field_title">字段标识</div>';
  897. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  898. _html += '<div class="field_title">字段说明</div>';
  899. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  900. _html += '<div class="field_title">备选项<div class="addclassify"><a><i class="fa fa-plus"></i>添加</a></div></div>';
  901. _html += '<div class="field_control"><ul class="classify"></ul></div>';
  902. _html += '<div class="field_title">设置</div>';
  903. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  904. var $html = $(_html);
  905. $(".field_option").html($html);
  906. var getRowJson = options.controlDataJson[e_row.attr('data-value')];
  907. if (getRowJson == null) {
  908. return false;
  909. }
  910. setControlField(getRowJson, e_row, $html);
  911. $html.find('#control_label').val(getRowJson.control_label);
  912. if (getRowJson.control_required == 1) {
  913. $html.find('#control_required').attr("checked", 'checked');
  914. } else {
  915. $html.find('#control_required').removeAttr("checked");
  916. }
  917. $html.find('#control_label').keyup(function (e) {
  918. var value = $(this).val();
  919. e_row.find('.item_field_label').find('span').html(value);
  920. getRowJson[$(this).attr('id')] = value;
  921. options.controlDataJson[e_row.attr('data-value')] = getRowJson;
  922. });
  923. $html.find('#control_required').click(function (e) {
  924. var value = 0;
  925. if ($(this).attr("checked")) {
  926. value = 0;
  927. $(this).attr("checked", false);
  928. e_row.find('.item_field_label').find('font').remove();
  929. } else {
  930. value = 1;
  931. $(this).attr("checked", true);
  932. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  933. }
  934. getRowJson[$(this).attr('id')] = value;
  935. options.controlDataJson[e_row.attr('data-value')] = getRowJson;
  936. });
  937. //处理备选项
  938. var $classify = $(".field_control .classify");
  939. $classify.sortable({
  940. handle: '.dragitem',
  941. stop: function (event, ui) {
  942. var tempitemjson = controlItemListJson;
  943. controlItemListJson = {};
  944. $classify.find('li').each(function (i) {
  945. var id = $(this).attr('data-value');
  946. controlItemListJson[id] = tempitemjson[id];
  947. });
  948. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  949. var _name = [];
  950. for (var i in controlItemListJson) {
  951. if (controlItemListJson[i].name) {
  952. _name.push(controlItemListJson[i].name)
  953. };
  954. }
  955. e_row.find('.item_field_value').html('下拉框/' + String(_name).replace(/,/g, '、'));
  956. }
  957. });
  958. //选项列表Json
  959. var controlItemListJson = options.controlDataJson[e_row.attr('data-value')]["control_item"];
  960. for (var i in controlItemListJson) {
  961. additem(i);
  962. var $thisObjectRow = $classify.find('[data-value=' + i + ']');
  963. $thisObjectRow.find('input[name=name]').val(controlItemListJson[i].name);
  964. $thisObjectRow.find('em').attr('class', controlItemListJson[i].color);
  965. $thisObjectRow.find('input[name=defaults]').attr("checked", controlItemListJson[i].defaults == 1 ? true : false);
  966. }
  967. //添加一项li
  968. $('.addclassify').find('a').click(function () {
  969. var random_id = String(Math.random()).substr(2);
  970. controlItemListJson[random_id] = {
  971. identify: random_id,
  972. color: "color_a",
  973. name: "",
  974. defaults: "0",
  975. }
  976. additem(random_id);
  977. })
  978. function additem(random_id) {
  979. var $li = $('<li><span><em title="色彩" class="color_a"></em><i title="移除" class="fa fa-close"></i></span><i class="dragitem fa fa-arrows"></i><input name="defaults" type="radio" title="设置默认值"><input name="name" type="text" placeholder="请填写备选项"></li>');
  980. $li.attr('data-value', random_id)
  981. $classify.append($li);
  982. //移除一项li
  983. $li.find('i.fa-close').click(function () {
  984. var id = $(this).parents('li').attr('data-value');
  985. delete controlItemListJson[id];
  986. $(this).parents('li').remove();
  987. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  988. var _name = [];
  989. for (var i in controlItemListJson) {
  990. if (controlItemListJson[i].name) {
  991. _name.push(controlItemListJson[i].name)
  992. };
  993. }
  994. e_row.find('.item_field_value').html('下拉框/' + String(_name).replace(/,/g, '、'));
  995. });
  996. //点击切换色彩
  997. var clickindex = 1;
  998. $li.find('em').click(function () {
  999. var color = ['color_a', 'color_b', 'color_c', 'color_d', 'color_e', 'color_f', 'color_g', 'color_h', 'color_i'];
  1000. $(this).attr('class', color[clickindex]);
  1001. controlItemListJson[$(this).parents('li').attr('data-value')].color = color[clickindex];
  1002. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  1003. clickindex++;
  1004. if (clickindex == 9) {
  1005. clickindex = 0
  1006. }
  1007. });
  1008. //默认值事件
  1009. $li.find('input[name=defaults]').click(function () {
  1010. for (var i in controlItemListJson) {
  1011. controlItemListJson[i].defaults = 0;
  1012. }
  1013. controlItemListJson[$(this).parents('li').attr('data-value')].defaults = 1;
  1014. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  1015. });
  1016. //输入事件
  1017. $li.find('input[name=name]').keyup(function () {
  1018. var value = $(this).val();
  1019. controlItemListJson[$(this).parents('li').attr('data-value')].name = value;
  1020. options.controlDataJson[e_row.attr('data-value')]["control_item"] = controlItemListJson;
  1021. var _name = [];
  1022. for (var i in controlItemListJson) {
  1023. if (controlItemListJson[i].name) {
  1024. _name.push(controlItemListJson[i].name);
  1025. }
  1026. }
  1027. e_row.find('.item_field_value').html('下拉框/' + String(_name).replace(/,/g, '、'));
  1028. })
  1029. }
  1030. if ($classify.find('li').length == 0) {
  1031. $('.addclassify').find('a').trigger("click");
  1032. }
  1033. }
  1034. function datetimeProperty(e_row) {
  1035. var _html = '';
  1036. _html += '<div class="field_tips"><i class="fa fa-info-circle"></i><span>选择日期、时间控件</span></div>';
  1037. _html += '<div class="field_title">字段标识</div>';
  1038. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  1039. _html += '<div class="field_title">字段说明</div>';
  1040. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  1041. _html += '<div class="field_title">日期格式</div>';
  1042. _html += '<div class="field_control"><select id="control_dateformat" class="form-control"><option value="date">仅日期</option><option value="datetime">日期和时间</option></select></div>';
  1043. _html += '<div class="field_title">默认值<i title="仅在添加数据时默认填入" class="help fa fa-question-circle"></i></div>';
  1044. _html += '<div class="field_control"><select id="control_default" class="form-control"><option value="">请选择</option><option value="Yesterday">昨天</option><option value="Today">今天</option><option value="Tomorrow">明天</option></select></div>';
  1045. _html += '<div class="field_title">设置</div>';
  1046. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  1047. var $html = $(_html);
  1048. $(".field_option").html($html);
  1049. var rowJson = options.controlDataJson[e_row.attr('data-value')];
  1050. if (rowJson == null) {
  1051. return false;
  1052. }
  1053. setControlField(rowJson, e_row, $html);
  1054. $html.find('#control_label').val(rowJson.control_label);
  1055. $html.find('#control_dateformat').val(rowJson.control_dateformat);
  1056. $html.find('#control_default').val(rowJson.control_default);
  1057. if (rowJson.control_required == 1) {
  1058. $html.find('#control_required').attr("checked", 'checked');
  1059. } else {
  1060. $html.find('#control_required').removeAttr("checked");
  1061. }
  1062. $html.find('#control_label').keyup(function (e) {
  1063. var value = $(this).val();
  1064. e_row.find('.item_field_label').find('span').html(value);
  1065. rowJson[$(this).attr('id')] = value;
  1066. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1067. });
  1068. $html.find('#control_dateformat').change(function (e) {
  1069. var value = $(this).val();
  1070. if (value == 'date') {
  1071. e_row.find('.item_field_value').html('年-月-日');
  1072. } else if (value == 'datetime') {
  1073. e_row.find('.item_field_value').html('年-月-日 时:分');
  1074. }
  1075. rowJson[$(this).attr('id')] = value;
  1076. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1077. });
  1078. $html.find('#control_default').change(function (e) {
  1079. var value = $(this).val();
  1080. rowJson[$(this).attr('id')] = value;
  1081. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1082. });
  1083. $html.find('#control_required').click(function (e) {
  1084. var value = 0;
  1085. if ($(this).attr("checked")) {
  1086. value = 0;
  1087. $(this).attr("checked", false);
  1088. e_row.find('.item_field_label').find('font').remove();
  1089. } else {
  1090. value = 1;
  1091. $(this).attr("checked", true);
  1092. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  1093. }
  1094. rowJson[$(this).attr('id')] = value;
  1095. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1096. });
  1097. }
  1098. function imageProperty(e_row) {
  1099. var _html = '';
  1100. _html += '<div class="field_title">字段标识</div>';
  1101. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  1102. _html += '<div class="field_title">字段说明</div>';
  1103. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  1104. _html += '<div class="field_title">图片格式<i title=".jpg .gif .png .bmp" class="help fa fa-question-circle"></i></div>';
  1105. _html += '<div class="field_control"><input id="control_fileformat" type="text" class="form-control" placeholder="如:jpg,gif,png,bmp"></div>';
  1106. _html += '<div class="field_title">设置</div>';
  1107. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  1108. var $html = $(_html);
  1109. $(".field_option").html($html);
  1110. var rowJson = options.controlDataJson[e_row.attr('data-value')];
  1111. if (rowJson == null) {
  1112. return false;
  1113. }
  1114. setControlField(rowJson, e_row, $html);
  1115. $html.find('#control_label').val(rowJson.control_label);
  1116. $html.find('#control_fileformat').val(rowJson.control_fileformat);
  1117. if (rowJson.control_required == 1) {
  1118. $html.find('#control_required').attr("checked", 'checked');
  1119. } else {
  1120. $html.find('#control_required').removeAttr("checked");
  1121. }
  1122. $html.find('#control_label').keyup(function (e) {
  1123. var value = $(this).val();
  1124. e_row.find('.item_field_label').find('span').html(value);
  1125. rowJson[$(this).attr('id')] = value;
  1126. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1127. });
  1128. $html.find('#control_fileformat').keyup(function (e) {
  1129. var value = $(this).val();
  1130. e_row.find('.item_field_value').html('上传图片/' + value);
  1131. rowJson[$(this).attr('id')] = value;
  1132. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1133. });
  1134. $html.find('#control_required').click(function (e) {
  1135. var value = 0;
  1136. if ($(this).attr("checked")) {
  1137. value = 0;
  1138. $(this).attr("checked", false);
  1139. e_row.find('.item_field_label').find('font').remove();
  1140. } else {
  1141. value = 1;
  1142. $(this).attr("checked", true);
  1143. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  1144. }
  1145. rowJson[$(this).attr('id')] = value;
  1146. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1147. });
  1148. }
  1149. function uploadProperty(e_row) {
  1150. var _html = '';
  1151. _html += '<div class="field_title">字段标识</div>';
  1152. _html += '<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>';
  1153. _html += '<div class="field_title">字段说明</div>';
  1154. _html += '<div class="field_control"><input id="control_label" type="text" class="form-control" placeholder="必填项"></div>';
  1155. _html += '<div class="field_title">文件格式<i title=".doc .xls .ppt .pdf " class="help fa fa-question-circle"></i></div>';
  1156. _html += '<div class="field_control"><input id="control_fileformat" type="text" class="form-control" placeholder="如:doc,xls,ppt,pdf"></div>';
  1157. _html += '<div class="field_title">设置</div>';
  1158. _html += '<div class="field_control"><div class="checkbox notclose" style="padding-left: 3px;"><label><input id="control_required" type="checkbox">必填</label></div></div>';
  1159. var $html = $(_html);
  1160. $(".field_option").html($html);
  1161. var rowJson = options.controlDataJson[e_row.attr('data-value')];
  1162. if (rowJson == null) {
  1163. return false;
  1164. }
  1165. setControlField(rowJson, e_row, $html);
  1166. $html.find('#control_label').val(rowJson.control_label);
  1167. $html.find('#control_fileformat').val(rowJson.control_fileformat);
  1168. if (rowJson.control_required == 1) {
  1169. $html.find('#control_required').attr("checked", 'checked');
  1170. } else {
  1171. $html.find('#control_required').removeAttr("checked");
  1172. }
  1173. $html.find('#control_label').keyup(function (e) {
  1174. var value = $(this).val();
  1175. e_row.find('.item_field_label').find('span').html(value);
  1176. rowJson[$(this).attr('id')] = value;
  1177. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1178. });
  1179. $html.find('#control_fileformat').keyup(function (e) {
  1180. var value = $(this).val();
  1181. e_row.find('.item_field_value').html('上传文件/' + value);
  1182. rowJson[$(this).attr('id')] = value;
  1183. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1184. });
  1185. $html.find('#control_required').click(function (e) {
  1186. var value = 0;
  1187. if ($(this).attr("checked")) {
  1188. value = 0;
  1189. $(this).attr("checked", false);
  1190. e_row.find('.item_field_label').find('font').remove();
  1191. } else {
  1192. value = 1;
  1193. $(this).attr("checked", true);
  1194. e_row.find('.item_field_label').append('<font face="宋体">*</font>');
  1195. }
  1196. rowJson[$(this).attr('id')] = value;
  1197. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1198. });
  1199. }
  1200. function dataitemlistProperty(e_row) {
  1201. }
  1202. //绑定数据表字段
  1203. function setControlField(rowJson, e_row, $html) {
  1204. var _value = (rowJson.control_field == "" ? newGuid() : rowJson.control_field);
  1205. if (options.isSystemTable == 0) {
  1206. $html.find("#control_field").parents('.field_control').html('<input id="control_field" type="text" class="form-control" disabled data-text="' + _value + '" value="' + _value + '" />');
  1207. rowJson.control_field = _value;
  1208. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1209. }
  1210. else {
  1211. $html.find("#control_field").parents('.field_control').html('<div class="field_control"><div id="control_field" type="select" class="ui-select"></div></div>');
  1212. $html.find("#control_field").ComboBox({
  1213. data: options.tablefiledJsonData,
  1214. id: "column",
  1215. text: "remark",
  1216. description: "==请选择==",
  1217. height: "230px",
  1218. allowSearch: true
  1219. });
  1220. $html.find("#control_field").ComboBoxSetValue(rowJson.control_field);
  1221. $html.find('#control_field').change(function (e) {
  1222. var value = $(this).attr('data-value');
  1223. rowJson[$(this).attr('id')] = value;
  1224. options.controlDataJson[e_row.attr('data-value')] = rowJson;
  1225. });
  1226. }
  1227. }
  1228. return options;
  1229. }
  1230. //表单预览
  1231. $.fn.frmPreview = function (options)
  1232. {
  1233. var $frmpreview= $(this);
  1234. if (!$frmpreview.attr('id')) {
  1235. return false;
  1236. }
  1237. $frmpreview.html("");
  1238. var defaults = {
  1239. tablecotent: [],
  1240. width:0,
  1241. datetime:new Date()
  1242. };
  1243. var options = $.extend(defaults, options);
  1244. if (options.tablecotent == "")
  1245. {
  1246. return false;
  1247. }
  1248. var frmContentJson = eval('(' + options.tablecotent + ')');
  1249. $.each(frmContentJson, function (id, item) {
  1250. var $item_control = $('<div class="item_row"></div>');
  1251. var controlrequired = item.control_required == '1' ? '<font face="宋体">*</font>' : '';
  1252. var controlrequired1 = item.control_required == '1' ? 'isvalid="yes" checkexpession="NotNull"' : '';
  1253. item.control_field = 'frm_' + item.control_field;
  1254. $item_control.html('<div class="item_field_label"><span>' + item.control_label + '</span>' + controlrequired + '</div>');
  1255. switch (item.control_type) {
  1256. case "text":
  1257. $item_control.append('<div class="item_field_value"><input id="' + item.control_field + '" type="text" class="form-control" ' + controlrequired1 + ' /></div>');
  1258. break;
  1259. case "textarea":
  1260. $item_control.append('<div class="item_field_value"><textarea id="' + item.control_field + '" style=height:' + item.control_height + '; class="form-control" ' + controlrequired1 + ' /></div>');
  1261. break;
  1262. case "texteditor":
  1263. $item_control.append('<div class="item_field_value"><textarea id="' + item.control_field + '" style=height:' + item.control_height + '; class="form-control" ' + controlrequired1 + ' /></div>');
  1264. $frmpreview.append($item_control);
  1265. new Simditor({
  1266. textarea: $('#' + item.control_field),
  1267. placeholder: '这里输入内容...',
  1268. toolbar: ['color', 'title', 'bold', 'underline', 'strikethrough', '|', 'ol', 'ul', 'blockquote', 'table', '|', 'link', 'image']
  1269. });
  1270. $item_control = null;
  1271. break;
  1272. case "radio":
  1273. var radiohtml = "";
  1274. $.each(item.control_item, function (id, childitem) {
  1275. radiohtml += '<div class="rdio rdio-' + childitem.color + '" ><input name="' + item.control_field + '" id = "' + item.control_field + childitem.identify + '" type="radio" data-value="' + childitem.identify + '" value="' + childitem.name + '" /><label for="' + item.control_field + childitem.identify + '">' + childitem.name + '</label></div>';
  1276. });
  1277. $item_control.append('<div class="item_field_value">' + radiohtml + '</div>');
  1278. break;
  1279. case "checkbox":
  1280. var ckboxhtml = "";
  1281. $.each(item.control_item, function (id, childitem) {
  1282. ckboxhtml += '<div class="ckbox ckbox-' + childitem.color + '" ><input id = "' + item.control_field + childitem.identify + '" type="checkbox" data-value="' + childitem.identify + '" value="' + childitem.name + '" /><label for="' + item.control_field + childitem.identify + '">' + childitem.name + '</label></div>';
  1283. });
  1284. $item_control.append('<div class="item_field_value">' + ckboxhtml + '</div>');
  1285. break;
  1286. case "select":
  1287. $item_control.append('<div class="item_field_value"><div id="' + item.control_field + '" type="select" class="ui-select" isvalid="yes" ' + controlrequired1 + '></div></div>');
  1288. $frmpreview.append($item_control);
  1289. $("#" + item.control_field).ComboBox({
  1290. data: item.control_item,
  1291. id: "name",
  1292. text: "name",
  1293. description: "==请选择==",
  1294. height: "200px",
  1295. allowSearch: true
  1296. });
  1297. $item_control = null;
  1298. break;
  1299. case "datetime":
  1300. var dateformat = item.control_dateformat == 'date' ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm';
  1301. var datedefault = "";
  1302. switch (item.control_default)
  1303. {
  1304. case "Yesterday":
  1305. datedefault = options.datetime.DateAdd('d',-1);
  1306. break;
  1307. case "Today":
  1308. datedefault = options.datetime.DateAdd('d', 0);
  1309. break;
  1310. case "Tomorrow":
  1311. datedefault = options.datetime.DateAdd('d', 1);;
  1312. break;
  1313. }
  1314. datedefault = formatDate(datedefault, dateformat.replace(/H/g,'h'));
  1315. $item_control.append('<div class="item_field_value"><input value="' + datedefault + '" onClick="WdatePicker({dateFmt:\'' + dateformat + '\',qsEnabled:false,isShowClear:false,isShowOK:false,isShowToday:false})" id="' + item.control_field + '" readonly type="text" class="form-control input-datepicker" ' + controlrequired1 + '/></div>');
  1316. break;
  1317. case "image":
  1318. $item_control.append('<div class="item_field_value"><input id="' + item.control_field + '" type="file" /></div>');
  1319. $frmpreview.append($item_control);
  1320. fuploadify(item.control_field, "添加图片");
  1321. $item_control = null;
  1322. break;
  1323. case "upload":
  1324. $item_control.append('<div class="item_field_value"><input id="' + item.control_field + '" type="file" /></div>');
  1325. $frmpreview.append($item_control);
  1326. fuploadify(item.control_field, "添加附件");
  1327. $item_control = null;
  1328. break;
  1329. case "departmentlist":
  1330. break;
  1331. case "dataitemlist":
  1332. break;
  1333. default:
  1334. break;
  1335. }
  1336. if ($item_control != null)
  1337. {
  1338. $frmpreview.append($item_control);
  1339. }
  1340. });
  1341. var _field_value_width = options.width - 132;
  1342. if (options.width == 0) {
  1343. _field_value_width = $frmpreview[0].scrollWidth - 132;
  1344. }
  1345. $frmpreview.find('.item_field_value').width(_field_value_width);
  1346. function fuploadify(control_field,btnName) {
  1347. $("#" + control_field).uploadify({
  1348. method: 'post',
  1349. uploader: '/FlowManage/FormDesign/UploadifyFile',
  1350. swf: top.contentPath + '/Content/scripts/plugins/uploadify/uploadify.swf',
  1351. buttonText: btnName,
  1352. height: 30,
  1353. width: 90,
  1354. fileTypeExts: '*.avi;*.mp3;*.mp4;*.bmp;*.ico;*.gif;*.jpeg;*.jpg;*.png;*.psd; *.rar;*.zip;*.swf;*.log;*.pdf;*.doc;*.docx;*.ppt;*.pptx;*.txt; *.xls; *.xlsx;',
  1355. removeCompleted: false,
  1356. onSelect: function (file) {
  1357. $("#" + file.id).prepend('<div style="float:left;width:50px;margin-right:2px;"><img src="/Content/images/filetype/' + file.type.replace('.', '') + '.png" style="width:40px;height:40px;" /></div>');
  1358. $(".uploadify-queue-item").find('.cancel').find('a').html('<i class="fa fa-trash-o "></i>');
  1359. $(".uploadify-queue-item").find('.cancel').find('a').attr('title','删除');
  1360. $(".uploadify-queue-item").hover(function () {
  1361. $(this).find('.cancel').find('a').show();
  1362. }, function () {
  1363. $(this).find('.cancel').find('a').hide();
  1364. });
  1365. },
  1366. onUploadSuccess: function (file) {
  1367. $("#" + file.id).find('.uploadify-progress').remove();
  1368. $("#" + file.id).find('.data').html(' 恭喜您,上传成功!');
  1369. $("#" + file.id).prepend('<a class="succeed" title="成功"><i class="fa fa-check-circle"></i></a>');
  1370. Loading(false);
  1371. },
  1372. onUploadError: function (file) {
  1373. $("#" + file.id).removeClass('uploadify-error');
  1374. $("#" + file.id).find('.uploadify-progress').remove();
  1375. $("#" + file.id).find('.data').html(' 很抱歉,上传失败!');
  1376. $("#" + file.id).prepend('<span class="error" title="失败"><i class="fa fa-exclamation-circle"></i></span>');
  1377. },
  1378. onUploadStart: function () {
  1379. $('#' + control_field + '-queue').show();
  1380. },
  1381. onCancel: function (file) {
  1382. }
  1383. });
  1384. $("#" + control_field + "-button").prepend('<i style="opacity: 0.6;" class="fa fa-cloud-upload"></i>&nbsp;');
  1385. $('#' + control_field + '-queue').hide();
  1386. }
  1387. }
  1388. //获取表单数据
  1389. $.fn.frmGetData = function () {
  1390. var reVal = ""; var checkboxValue = {};
  1391. $(this).find('input,select,textarea,.ui-select').each(function (r) {
  1392. var id = $(this).attr('id');
  1393. if (id != undefined)
  1394. {
  1395. var filedid = id.replace('frm_', '');
  1396. var type = $(this).attr('type');
  1397. switch (type) {
  1398. case "checkbox":
  1399. var datavalue = $("#" + id).attr('data-value');
  1400. var value = $("#" + id).val();
  1401. if ($("#" + id).is(":checked")) {
  1402. //reVal += '"' + filedid.replace(datavalue, '') + '"' + ':' + '"' + $.trim(value) + '",'
  1403. if (checkboxValue[filedid.replace(datavalue, '')] == undefined) {
  1404. checkboxValue[filedid.replace(datavalue, '')] = "";
  1405. }
  1406. else {
  1407. checkboxValue[filedid.replace(datavalue, '')] += '|';
  1408. }
  1409. checkboxValue[filedid.replace(datavalue, '')] += $.trim(value);
  1410. }
  1411. break;
  1412. case "radio":
  1413. var datavalue = $("#" + id).attr('data-value');
  1414. var value = $("#" + id).val();
  1415. if ($("#" + id).is(":checked")) {
  1416. reVal += '"' + filedid.replace(datavalue, '') + '"' + ':' + '"' + $.trim(value) + '",'
  1417. }
  1418. break;
  1419. case "select":
  1420. var value = $("#" + id).attr('data-value');
  1421. if (value == "") {
  1422. value = "&nbsp;";
  1423. }
  1424. reVal += '"' + filedid + '"' + ':' + '"' + $.trim(value) + '",'
  1425. break;
  1426. case "selectTree":
  1427. var value = $("#" + id).attr('data-value');
  1428. if (value == "") {
  1429. value = "&nbsp;";
  1430. }
  1431. reVal += '"' + filedid + '"' + ':' + '"' + $.trim(value) + '",'
  1432. break;
  1433. default:
  1434. var value = $("#" + id).val();
  1435. if (value == "") {
  1436. value = "&nbsp;";
  1437. }
  1438. reVal += '"' + filedid + '"' + ':' + '"' + $.trim(value) + '",'
  1439. break;
  1440. }
  1441. }
  1442. });
  1443. for (var i in checkboxValue)
  1444. {
  1445. reVal += '"' + i + '"' + ':' + '"' + checkboxValue[i] + '",'
  1446. }
  1447. reVal = reVal.substr(0, reVal.length - 1);
  1448. reVal = reVal.replace(/\\/g, '\\\\');
  1449. reVal = reVal.replace(/\n/g, '\\n');
  1450. var postdata = jQuery.parseJSON('{' + reVal + '}');
  1451. //阻止伪造请求
  1452. //if ($('[name=__RequestVerificationToken]').length > 0) {
  1453. // postdata["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
  1454. //}
  1455. return postdata;
  1456. }
  1457. //设置表单数据
  1458. $.fn.frmSetData = function (data) {
  1459. //console.log("data:"+JSON.stringify(data));
  1460. var $id = $(this)
  1461. for (var key in data) {
  1462. var id = $id.find('#frm_' + key);
  1463. var value = $.trim(data[key]).replace(/&nbsp;/g, '');
  1464. if (id.attr('id')) {
  1465. var type = id.attr('type');
  1466. switch (type) {
  1467. case "radio":
  1468. break;
  1469. case "checkbox":
  1470. if (value == 1) {
  1471. id.attr("checked", 'checked');
  1472. } else {
  1473. id.removeAttr("checked");
  1474. }
  1475. break;
  1476. case "select":
  1477. id.ComboBoxSetValue(value);
  1478. break;
  1479. case "selectTree":
  1480. id.ComboBoxTreeSetValue(value);
  1481. break;
  1482. default:
  1483. id.val(value);
  1484. break;
  1485. }
  1486. }
  1487. else {
  1488. $(this).find('input').each(function (r) {
  1489. var checkid = $(this).attr('id');
  1490. var checkfiledid = checkid.replace('frm_', '');
  1491. var checktype = $(this).attr('type');
  1492. var checkValue = $(this).val();
  1493. switch (checktype) {
  1494. case "checkbox":
  1495. var datavalue = $(this).attr('data-value');
  1496. if ((key + datavalue) == checkfiledid )
  1497. {
  1498. var vlist = value.split('|');
  1499. for (var i in vlist)
  1500. {
  1501. if (vlist[i] == checkValue)
  1502. {
  1503. $(this).attr("checked", 'checked');
  1504. break;
  1505. }
  1506. }
  1507. }
  1508. break;
  1509. case "radio":
  1510. var datavalue = $(this).attr('data-value');
  1511. if ((key + datavalue) == checkfiledid && checkValue == value) {
  1512. $(this).attr("checked", 'checked');
  1513. }
  1514. break;
  1515. default:
  1516. break;
  1517. }
  1518. });
  1519. }
  1520. }
  1521. }