functions.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <php>
  2. if (!function_exists('_parse_vars')) {
  3. function _parse_vars($vars,$inputName,$level=1,$widget='',$file_id=''){
  4. </php>
  5. <foreach name="vars" item="var" key="varName">
  6. <fieldset>
  7. <div class="form-group">
  8. <present name="var.title">
  9. <label class="control-label">
  10. {$var.title}
  11. <notempty name="var.rule.require">
  12. <span class="form-required">*</span>
  13. </notempty>
  14. </label>
  15. </present>
  16. <switch name="var.type">
  17. <case value="text">
  18. <div class="controls">
  19. <present name="var.dataSource">
  20. <input type="text" name="{$inputName}[{$varName}_text_]" class="form-control"
  21. onclick="doSelectData(this)"
  22. data-source="{:base64_encode(json_encode($var['dataSource']))}"
  23. data-title="请选择{$var.title}"
  24. value="{$vars[$varName]['valueText']|default=''}">
  25. <input type="hidden" name="{$inputName}[{$varName}]" class="form-control"
  26. value="{$vars[$varName]['value']}">
  27. <else/>
  28. <input type="text" name="{$inputName}[{$varName}]" class="form-control"
  29. value="{$vars[$varName]['value']}">
  30. </present>
  31. <present name="var.tip">
  32. <p class="help-block">{$var.tip}</p>
  33. </present>
  34. </div>
  35. </case>
  36. <case value="textarea">
  37. <div class="controls">
  38. <textarea name="{$inputName}[{$varName}]"
  39. class="form-control">{$vars[$varName]['value']}</textarea>
  40. <present name="var.tip">
  41. <p class="help-block">{$var.tip}</p>
  42. </present>
  43. </div>
  44. </case>
  45. <case value="date">
  46. <div class="controls">
  47. <input type="text" name="{$inputName}[{$varName}]" class="form-control js-bootstrap-date"
  48. value="{$vars[$varName]['value']}">
  49. <present name="var.tip">
  50. <p class="help-block">{$var.tip}</p>
  51. </present>
  52. </div>
  53. </case>
  54. <case value="datetime">
  55. <div class="controls">
  56. <input type="text" name="{$inputName}[{$varName}]" class="form-control js-bootstrap-datetime"
  57. value="{$vars[$varName]['value']}">
  58. <present name="var.tip">
  59. <p class="help-block">{$var.tip}</p>
  60. </present>
  61. </div>
  62. </case>
  63. <case value="image">
  64. <div class="controls">
  65. <input type="hidden" name="{$inputName}[{$varName}]" class="form-control"
  66. value="{$vars[$varName]['value']}" id="js-{$widget}{$varName}-input">
  67. <div>
  68. <a href="javascript:uploadOneImage('图片上传','#js-{$widget}{$varName}-input');">
  69. <if condition="empty($vars[$varName]['value'])">
  70. <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  71. id="js-{$widget}{$varName}-input-preview"
  72. width="135" style="cursor: pointer"/>
  73. <else/>
  74. <img src="{:cmf_get_image_preview_url($vars[$varName]['value'])}"
  75. id="js-{$widget}{$varName}-input-preview"
  76. width="135" style="cursor: pointer"/>
  77. </if>
  78. </a>
  79. <if condition="!empty($vars[$varName]['value'])">
  80. <br>
  81. <button id="js-{$widget}{$varName}-button-remove" defaultImage="__TMPL__/public/assets/images/default-thumbnail.png" class="removeImage btn btn-sm" type="button" onclick="removeImage('{$widget}{$varName}')">取消图片</button>
  82. </if>
  83. </div>
  84. <present name="var.tip">
  85. <p class="help-block">{$var.tip}</p>
  86. </present>
  87. </div>
  88. </case>
  89. <case value="number">
  90. <div class="controls">
  91. <input type="number" name="{$inputName}[{$varName}]" class="form-control"
  92. value="{$vars[$varName]['value']}">
  93. <present name="var.tip">
  94. <p class="help-block">{$var.tip}</p>
  95. </present>
  96. </div>
  97. </case>
  98. <case value="location">
  99. <div class="controls">
  100. <input type="text" name="{$inputName}[{$varName}_text_]" class="form-control"
  101. onclick="doSelectLocation(this)"
  102. data-title="请选择{$var.title}"
  103. value="{$vars[$varName]['valueText']|default=''}">
  104. <input type="hidden" name="{$inputName}[{$varName}]" class="form-control"
  105. value="{$vars[$varName]['value']}">
  106. <present name="var.tip">
  107. <p class="help-block">{$var.tip}</p>
  108. </present>
  109. </div>
  110. </case>
  111. <case value="file">
  112. <div class="controls">
  113. <div class="input-group">
  114. <input type="text" name="{$inputName}[{$varName}]" class="form-control"
  115. value="{$vars[$varName]['value']}" id="js-{$widget}{$varName}-input-file">
  116. <span class="input-group-addon"> <a href="javascript:uploadOne('图片上传','#js-{$widget}{$varName}-input-file','file');">上传</a></span>
  117. </div>
  118. <present name="var.tip">
  119. <p class="help-block">{$var.tip}</p>
  120. </present>
  121. </div>
  122. </case>
  123. <case value="color">
  124. <div class="controls">
  125. <input type="text" name="{$inputName}[{$varName}]" class="form-control js-color"
  126. value="{$vars[$varName]['value']}" id="js-color-{$widget}{$varName}">
  127. <present name="var.tip">
  128. <p class="help-block">{$var.tip}</p>
  129. </present>
  130. </div>
  131. </case>
  132. <case value="array">
  133. <div class="controls">
  134. <php>
  135. $arrayValueText=is_array($var['value'])&&count($var['value'])>0?count($var['value']).'条数据,点击添加更多...':'';
  136. </php>
  137. <textarea class="form-control" placeholder="点击添加数据"
  138. onclick="doEditArrayData(this)"
  139. data-var="{$varName}"
  140. data-widget="{$widget}"
  141. data-title="编辑{$var.title}"
  142. data-file_id="{$file_id}">{$arrayValueText}</textarea>
  143. <present name="var.tip">
  144. <p class="help-block">{$var.tip}</p>
  145. </present>
  146. </div>
  147. </case>
  148. <case value="select">
  149. <div class="controls">
  150. <php>
  151. $value= $vars[$varName]['value'];
  152. $options = $vars[$varName]['options'];
  153. </php>
  154. <select name="{$inputName}[{$varName}]" class="form-control">
  155. <foreach name="options" item="optionItem" key="optionKey">
  156. <php>$optionSelected=$optionKey==$value?"selected":"";</php>
  157. <option value="{$optionKey}" {$optionSelected}>{$optionItem}
  158. </option>
  159. </foreach>
  160. </select>
  161. <present name="var.tip">
  162. <p class="help-block">{$var.tip}</p>
  163. </present>
  164. </div>
  165. </case>
  166. <case value="slide">
  167. <div class="controls">
  168. <input type="text" name="{$inputName}[{$varName}]" class="form-control"
  169. value="{$vars[$varName]['value']}">
  170. <present name="var.tip">
  171. <p class="help-block">{$var.tip}</p>
  172. </present>
  173. </div>
  174. </case>
  175. </switch>
  176. </div>
  177. </fieldset>
  178. </foreach>
  179. <php>
  180. }
  181. }
  182. </php>