addForm.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <style>
  2. [class*="span"] {
  3. float: left;
  4. min-height: 1px;
  5. margin-left: 20px;
  6. }
  7. .span6 {
  8. width: 460px;
  9. }
  10. #components{
  11. min-height: 600px;
  12. }
  13. #target{
  14. min-height: 200px;
  15. border: 1px solid #ccc;
  16. padding: 5px;
  17. }
  18. #target .component{
  19. border: 1px solid #fff;
  20. }
  21. #temp{
  22. width: 500px;
  23. background: white;
  24. border: 1px dotted #ccc;
  25. border-radius: 10px;
  26. }
  27. .popover-content form {
  28. margin: 0 auto;
  29. width: 213px;
  30. }
  31. .popover-content form .btn{
  32. margin-right: 10px
  33. }
  34. #source{
  35. min-height: 500px;
  36. }
  37. </style>
  38. <div class="container" style="margin-left: 200px;">
  39. <div class="row clearfix">
  40. <!-- 拖拽表单begin -->
  41. <div class="row clearfix">
  42. <div class="span6">
  43. <div class="clearfix">
  44. <h2></h2>
  45. <hr>
  46. <br />
  47. <br />
  48. <div id="build" style="width: 530px;">
  49. <form id="target" class="form-horizontal">
  50. <fieldset>
  51. <div id="legend" class="" rel="popover" trigger="manual" data-content="
  52. <form class='form'>
  53. <div class='controls'>
  54. <label class='control-label'>表单名称</label> <input type='text' id='orgvalue' placeholder='请输入表单名称'>
  55. <hr/>
  56. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  57. </div>
  58. </form>" data-original-title="编辑属性" style="border-top: 1px solid white; border-bottom: none;">
  59. <input type="hidden" name="form_name" value="" class="leipiplugins" leipiplugins="form_name">
  60. <legend class="leipiplugins-orgvalue">自定义表单内容</legend>
  61. </div>
  62. <?php
  63. foreach($form_data as $data ){
  64. ?>
  65. <?php
  66. if( $data['type'] == 'text' ){
  67. ?>
  68. <div class="control-group component" rel="popover" trigger="manual" data-content="
  69. <form class='form'>
  70. <div class='controls'>
  71. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  72. <label class='control-label'>默认值</label> <input type='text' id='orgvalue' placeholder='默认值'>
  73. <hr/>
  74. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  75. </div>
  76. </form>" data-original-title="文本框控件" style="border-top: 1px solid white; border-bottom: none;">
  77. <!-- Text -->
  78. <label class="control-label leipiplugins-orgname"><?php echo $data['title']; ?></label>
  79. <div class="controls">
  80. <input name="leipiNewField" type="text" style="width:220px;height:30px;" placeholder="默认值" title="<?php echo $data['title']; ?>" value="<?php echo $data['value']; ?>" class="leipiplugins" leipiplugins="text">
  81. </div>
  82. </div>
  83. <?php } ?>
  84. <?php
  85. if( $data['type'] == 'textarea' ){
  86. ?>
  87. <div class="control-group component" rel="popover" trigger="manual" data-content="
  88. <form class='form'>
  89. <div class='controls'>
  90. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  91. <label class='control-label'>默认值</label> <input type='text' id='orgvalue' placeholder='默认值'>
  92. <hr/>
  93. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  94. </div>
  95. </form>" data-original-title="多行文本控件" style="border-top: 1px solid white; border-bottom: none;">
  96. <!-- Textarea -->
  97. <label class="control-label leipiplugins-orgname"><?php echo $data['title']; ?></label>
  98. <div class="controls">
  99. <div class="textarea">
  100. <textarea title="<?php echo $data['title']; ?>" style="width:220px;" name="leipiNewField" class="leipiplugins" leipiplugins="textarea"><?php echo $data['value']; ?></textarea>
  101. </div>
  102. </div>
  103. </div>
  104. <?php } ?>
  105. <?php
  106. if( $data['type'] == 'select' ){
  107. ?>
  108. <div class="control-group component" rel="popover" trigger="manual" data-content="
  109. <form class='form'>
  110. <div class='controls'>
  111. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  112. <label class='control-label'>下拉选项</label>
  113. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  114. <p class='help-block'>一行一个选项</p>
  115. <hr/>
  116. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  117. </div>
  118. </form>" data-original-title="下拉控件" style="border-top: 1px solid white; border-bottom: none;">
  119. <!-- Select -->
  120. <label class="control-label leipiplugins-orgname"><?php echo $data['title']; ?></label>
  121. <div class="controls">
  122. <select name="leipiNewField" title="<?php echo $data['title']; ?>" class="leipiplugins" leipiplugins="select" style="width:220px;">
  123. <?php foreach($data['value'] as $vv){ ?>
  124. <option><?php echo $vv['value']; ?></option>
  125. <?php } ?>
  126. </select>
  127. </div>
  128. </div>
  129. <?php } ?>
  130. <?php
  131. if( $data['type'] == 'checkbox' ){
  132. ?>
  133. <div class="control-group component" rel="popover" trigger="manual" data-content="
  134. <form class='form'>
  135. <div class='controls'>
  136. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  137. <label class='control-label'>复选框</label>
  138. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  139. <p class='help-block'>一行一个选项</p>
  140. <hr/>
  141. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  142. </div>
  143. </form>" data-original-title="复选控件" style="border-top: 1px solid white; border-bottom: none;">
  144. <label class="control-label leipiplugins-orgname"><?php echo $data['title']; ?></label>
  145. <div class="controls leipiplugins-orgvalue">
  146. <!-- Multiple Checkboxes -->
  147. <?php foreach($data['value'] as $vv){ ?>
  148. <label class="checkbox inline">
  149. <input type="checkbox" name="leipiNewField" title="<?php echo $data['title']; ?>" value="<?php echo $vv['value']; ?>" class="leipiplugins" leipiplugins="checkbox" orginline="inline" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  150. <?php echo $vv['value']; ?>
  151. </label>
  152. <?php } ?>
  153. </div>
  154. </div>
  155. <?php } ?>
  156. <?php
  157. if( $data['type'] == 'radio' ){
  158. ?>
  159. <div class="control-group component" rel="popover" trigger="manual" data-content="
  160. <form class='form'>
  161. <div class='controls'>
  162. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  163. <label class='control-label'>单选框</label>
  164. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  165. <p class='help-block'>一行一个选项</p>
  166. <hr/>
  167. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  168. </div>
  169. </form>" data-original-title="单选控件">
  170. <label class="control-label leipiplugins-orgname"><?php echo $data['title']; ?></label>
  171. <div class="controls leipiplugins-orgvalue">
  172. <!-- Multiple Checkboxes -->
  173. <?php foreach($data['value'] as $vv){ ?>
  174. <label class="radio inline">
  175. <input type="radio" name="leipiNewField" title="单选框" value=" <?php echo $vv['value']; ?>" class="leipiplugins" leipiplugins="radio" orginline="inline" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  176. <?php echo $vv['value']; ?>
  177. </label>
  178. <?php } ?>
  179. </div>
  180. </div>
  181. <?php
  182. }
  183. ?>
  184. <?php
  185. }
  186. ?>
  187. </fieldset>
  188. </form>
  189. </div>
  190. </div>
  191. </div>
  192. <div class="span6">
  193. <h2></h2>
  194. <hr>
  195. <br />
  196. <br />
  197. <div class="tabbable" style="height:485px;margin-left: 100px;">
  198. <ul class="nav nav-tabs" id="navtab" style="width: 420px;">
  199. <li class="active"><a href="#1" data-toggle="tab">拖拽所需组件到左侧</a></li>
  200. </ul>
  201. <form class="form-horizontal" id="components">
  202. <fieldset>
  203. <div class="tab-content">
  204. <div class="tab-pane active" id="1">
  205. <!-- Text start -->
  206. <div class="control-group component" rel="popover" title="文本框控件" trigger="manual" data-content="
  207. <form class='form'>
  208. <div class='controls'>
  209. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  210. <label class='control-label'>默认值</label> <input type='text' id='orgvalue' placeholder='默认值'>
  211. <hr/>
  212. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  213. </div>
  214. </form>">
  215. <!-- Text -->
  216. <label class="control-label leipiplugins-orgname">文本框</label>
  217. <div class="controls">
  218. <input name="leipiNewField" type="text" placeholder="默认值" title="文本框" value="" class="leipiplugins" leipiplugins="text" style="width:220px;height:30px;">
  219. </div>
  220. </div>
  221. <!-- Text end -->
  222. <!-- Textarea start -->
  223. <div class="control-group component" rel="popover" title="多行文本控件" trigger="manual" data-content="
  224. <form class='form'>
  225. <div class='controls'>
  226. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  227. <label class='control-label'>默认值</label> <input type='text' id='orgvalue' placeholder='默认值'>
  228. <hr/>
  229. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  230. </div>
  231. </form>">
  232. <!-- Textarea -->
  233. <label class="control-label leipiplugins-orgname">多行文本</label>
  234. <div class="controls">
  235. <div class="textarea">
  236. <textarea title="多行文本" name="leipiNewField" class="leipiplugins" leipiplugins="textarea" style="width:220px;"> </textarea>
  237. </div>
  238. </div>
  239. </div>
  240. <!-- Textarea end -->
  241. <!-- Select start -->
  242. <div class="control-group component" rel="popover" title="下拉控件" trigger="manual" data-content="
  243. <form class='form'>
  244. <div class='controls'>
  245. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  246. <label class='control-label'>下拉选项</label>
  247. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  248. <p class='help-block'>一行一个选项</p>
  249. <hr/>
  250. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  251. </div>
  252. </form>">
  253. <!-- Select -->
  254. <label class="control-label leipiplugins-orgname">下拉菜单</label>
  255. <div class="controls">
  256. <select name="leipiNewField" title="下拉菜单" class="leipiplugins" leipiplugins="select" style="width:220px;">
  257. <option>选项一</option>
  258. <option>选项二</option>
  259. <option>选项三</option>
  260. </select>
  261. </div>
  262. </div>
  263. <!-- Select end -->
  264. <!-- Select start -->
  265. <div style="display:none;" class="control-group component" rel="popover" title="多选下拉控件" trigger="manual" data-content="
  266. <form class='form'>
  267. <div class='controls'>
  268. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  269. <label class='control-label'>下拉选项</label>
  270. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  271. <p class='help-block'>一行一个选项</p>
  272. <hr/>
  273. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  274. </div>
  275. </form>">
  276. <!-- Select -->
  277. <label class="control-label leipiplugins-orgname">下拉菜单</label>
  278. <div class="controls">
  279. <select multiple="multiple" name="leipiNewField" title="下拉菜单" class="leipiplugins" leipiplugins="select">
  280. <option>选项一</option>
  281. <option>选项二</option>
  282. <option>选项三</option>
  283. <option>选项四</option>
  284. </select>
  285. </div>
  286. </div>
  287. <!-- Select end -->
  288. <!-- Multiple Checkboxes start -->
  289. <div class="control-group component" rel="popover" title="复选控件" trigger="manual" data-content="
  290. <form class='form'>
  291. <div class='controls'>
  292. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  293. <label class='control-label'>复选框</label>
  294. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  295. <p class='help-block'>一行一个选项</p>
  296. <hr/>
  297. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  298. </div>
  299. </form>">
  300. <label class="control-label leipiplugins-orgname">复选框</label>
  301. <div class="controls leipiplugins-orgvalue">
  302. <!-- Multiple Checkboxes -->
  303. <label class="checkbox inline">
  304. <input type="checkbox" name="leipiNewField" title="复选框" value="选项1" class="leipiplugins" leipiplugins="checkbox" orginline="inline" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  305. 选项1
  306. </label>
  307. <label class="checkbox inline">
  308. <input type="checkbox" name="leipiNewField" title="复选框" value="选项2" class="leipiplugins" leipiplugins="checkbox" orginline="inline" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  309. 选项2
  310. </label>
  311. </div>
  312. </div>
  313. <div class="control-group component" style="display:none;" rel="popover" title="复选控件" trigger="manual" data-content="
  314. <form class='form'>
  315. <div class='controls'>
  316. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  317. <label class='control-label'>复选框</label>
  318. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  319. <p class='help-block'>一行一个选项</p>
  320. <hr/>
  321. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  322. </div>
  323. </form>">
  324. <label class="control-label leipiplugins-orgname">复选框</label>
  325. <div class="controls leipiplugins-orgvalue">
  326. <!-- Multiple Checkboxes -->
  327. <label class="checkbox">
  328. <input type="checkbox" name="leipiNewField" title="复选框" value="选项1" class="leipiplugins" leipiplugins="checkbox" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  329. 选项1
  330. </label>
  331. <label class="checkbox">
  332. <input type="checkbox" name="leipiNewField" title="复选框" value="选项2" class="leipiplugins" leipiplugins="checkbox" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  333. 选项2
  334. </label>
  335. </div>
  336. </div>
  337. <!-- Multiple Checkboxes end -->
  338. <!-- Multiple radios start -->
  339. <div class="control-group component" rel="popover" title="单选控件" trigger="manual" data-content="
  340. <form class='form'>
  341. <div class='controls'>
  342. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  343. <label class='control-label'>单选框</label>
  344. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  345. <p class='help-block'>一行一个选项</p>
  346. <hr/>
  347. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  348. </div>
  349. </form>">
  350. <label class="control-label leipiplugins-orgname">单选</label>
  351. <div class="controls leipiplugins-orgvalue">
  352. <!-- Multiple Checkboxes -->
  353. <label class="radio inline">
  354. <input type="radio" name="leipiNewField" title="单选框" value="选项1" class="leipiplugins" leipiplugins="radio" orginline="inline" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  355. 选项1
  356. </label>
  357. <label class="radio inline">
  358. <input type="radio" name="leipiNewField" title="单选框" value="选项2" class="leipiplugins" leipiplugins="radio" orginline="inline" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  359. 选项2
  360. </label>
  361. </div>
  362. </div>
  363. <div class="control-group component" style="display:none;" rel="popover" title="单选控件" trigger="manual" data-content="
  364. <form class='form'>
  365. <div class='controls'>
  366. <label class='control-label'>控件名称</label> <input type='text' id='orgname' placeholder='必填项'>
  367. <label class='control-label'>单选框</label>
  368. <textarea style='min-height: 200px' id='orgvalue'></textarea>
  369. <p class='help-block'>一行一个选项</p>
  370. <hr/>
  371. <button class='btn btn-info' type='button'>确定</button><button class='btn btn-danger' type='button'>取消</button>
  372. </div>
  373. </form>">
  374. <label class="control-label leipiplugins-orgname">单选</label>
  375. <div class="controls leipiplugins-orgvalue">
  376. <!-- Multiple Checkboxes -->
  377. <label class="radio">
  378. <input type="radio" name="leipiNewField" title="单选框" value="选项1" class="leipiplugins" leipiplugins="radio" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  379. 选项1
  380. </label>
  381. <label class="radio">
  382. <input type="radio" name="leipiNewField" title="单选框" value="选项2" class="leipiplugins" leipiplugins="radio" style="zoom:125%;margin-left: -15;margin-top: 2px;">
  383. 选项2
  384. </label>
  385. </div>
  386. </div>
  387. <!-- Multiple radios end -->
  388. </div>
  389. </div></fieldset>
  390. </form>
  391. </div><!--tab-content-->
  392. </div><!---tabbable-->
  393. </div>
  394. <!-- 拖拽表单end -->
  395. </div>
  396. <div class="row clearfix">
  397. <input type="button" value="提交" class="btn btn-primary" id="sbu_form" />
  398. </div>
  399. </div>
  400. <link href="/static/Formbuild/Public/css/bootstrap/css/bootstrap.css?2024" rel="stylesheet" type="text/css" />
  401. <link href="/static/Formbuild/Public/css/site.css?2024" rel="stylesheet" type="text/css" />
  402. <script type="text/javascript" charset="utf-8" src="/static/Formbuild/Public/js/jquery-1.7.2.min.js?2024"></script>
  403. <script type="text/javascript" src="/static/Formbuild/Public/js/formbuild/bootstrap/js/bootstrap.min.js?2024"></script>
  404. <script type="text/javascript" charset="utf-8" src="/static/Formbuild/Public/js/formbuild/leipi.form.build.core.js?2024"></script>
  405. <script type="text/javascript" charset="utf-8" src="/static/Formbuild/Public/js/formbuild/leipi.form.build.plugins.js?2024"></script>
  406. <script>
  407. $(function(){
  408. $('#sbu_form').click(function(){
  409. var obj_s = $('#legend').siblings();
  410. var need_data = [];
  411. $(obj_s).each(function(){
  412. var need_obj = {};
  413. var stitle = $(this).children('label').html();
  414. need_obj.title = stitle;
  415. var s_length = $(this).children('div').children('input').length ;
  416. if( s_length == 1 )
  417. {
  418. var s_content_obj = $(this).children('div').children('input');
  419. need_obj.type = $(s_content_obj).attr('type');
  420. need_obj.value = $(s_content_obj).attr('value');
  421. }else{
  422. var checkbox_length = $(this).children('div').children('label.checkbox').length;
  423. if(checkbox_length > 0)
  424. {
  425. var checkbox_obj = $(this).children('div').children('label.checkbox');
  426. need_obj.type = 'checkbox';
  427. var s_v = [];
  428. $(checkbox_obj).each(function(){
  429. s_v.push({text:$(this).children('input').val(),value:$(this).children('input').val()});
  430. })
  431. need_obj.value = s_v;
  432. }
  433. var radio_length = $(this).children('div').children('label.radio').length;
  434. if(radio_length > 0)
  435. {
  436. var radio_obj = $(this).children('div').children('label.radio');
  437. need_obj.type = 'radio';
  438. var s_v = [];
  439. $(radio_obj).each(function(){
  440. s_v.push({text:$(this).children('input').val(),value:$(this).children('input').val()});
  441. })
  442. need_obj.value = s_v;
  443. }
  444. var sel_length = $(this).children('div').children('select').length;
  445. if(sel_length == 1)
  446. {
  447. var selcect_obj = $(this).children('div').children('select');
  448. need_obj.type = 'select';
  449. var s_v = [];
  450. $(selcect_obj).children('option').each(function(){
  451. var value = $(this).val();
  452. var text = $(this).text();
  453. s_v.push({text:text,value:value});
  454. });
  455. need_obj.value = s_v;
  456. }
  457. var textarea_length = $(this).children('div').children('div.textarea').length ;
  458. if(textarea_length > 0)
  459. {
  460. var textarea_obj = $(this).children('div').children('div.textarea').children('textarea');
  461. need_obj.type = 'textarea';
  462. need_obj.value = $(textarea_obj).html();
  463. }
  464. }
  465. need_data.push(need_obj);
  466. })
  467. console.log('最终结果:');
  468. console.log(need_data);
  469. $.ajax({
  470. url: "{:U('distribution/addForm')}",
  471. type: 'post',
  472. data: {data:need_data},
  473. dataType:'json',
  474. success: function (info) {
  475. if(info.status == 0)
  476. {
  477. alert('设置成功');
  478. var index = parent.layer.getFrameIndex(window.name);
  479. parent.layer.close(index)
  480. return false;
  481. }else if(info.status == 1){
  482. alert('设置失败');
  483. location.href = "{:U('distribution/addForm')}";
  484. return false;
  485. }
  486. }
  487. });
  488. })
  489. })
  490. </script>