Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

attr_add.htm 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. {include file="public/layout" /}
  2. <body class="bodystyle" style="overflow: auto;min-width:auto;">
  3. <div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
  4. <div id="append_parent"></div>
  5. <div id="ajaxwaitid"></div>
  6. <div class="page min-hg-c-i" style="min-width: auto;box-shadow:none;padding-bottom: 0px;">
  7. <form class="form-horizontal" id="post_form" action="{:url('Member/attr_add')}" method="post">
  8. <div class="ncap-form-default tab_div_1">
  9. <dl class="row">
  10. <dt class="tit">
  11. <label for="name"><em>*</em>字段标题</label>
  12. </dt>
  13. <dd class="opt" style="width: auto;">
  14. <input type="text" name="title" id="name" class="input-txt" autocomplete="off">
  15. <p class="notic"></p>
  16. </dd>
  17. </dl>
  18. <dl class="row">
  19. <dt class="tit">
  20. <label for="dtype"><em>*</em>字段类型</label>
  21. </dt>
  22. <dd class="opt" style="width: auto;">
  23. <!--<select name="dtype" id="dtype">-->
  24. <!--{volist name='$field' id='vo'}-->
  25. <!--<option value="{$vo.name}" data-ifoption="{$vo.ifoption|default=0}">-->
  26. <!--{$vo.title}-->
  27. <!--</option>-->
  28. <!--{/volist}-->
  29. <!--</select>-->
  30. {volist name='$field' id='vo'}
  31. <div style="width: 150px; float: left;">
  32. <label><input type="radio" name="dtype" value="{$vo.name}" data-ifoption="{$vo.ifoption|default=0}" {eq name='$i' value='1'} checked="checked" {/eq} data-text="{$vo.title}">{$vo.title}</label>&nbsp;
  33. </div>
  34. {if condition="$i % 4 == 0"}<br/>{/if}
  35. {/volist}
  36. <span class="err"></span>
  37. <p class="notic"></p>
  38. </dd>
  39. </dl>
  40. <dl class="row" id="dl_dfvalue">
  41. <dt class="tit">
  42. <label id="label_dfvalue">默认值</label>
  43. </dt>
  44. <dd class="opt" style="width: auto;">
  45. <textarea rows="5" cols="60" id="dfvalue" name="dfvalue" placeholder="前端将默认显示输入的内容" style="height:60px;"></textarea>
  46. <span class="err"></span>
  47. <p class="notic">如字段类型为下拉框、单选项、多选项时,需要填写默认值。</p>
  48. </dd>
  49. </dl>
  50. <dl class="row">
  51. <dt class="tit">
  52. <label>字段状态</label>
  53. </dt>
  54. <dd class="opt" style="width: auto;">
  55. <label class="curpoin">
  56. <input type="radio" name="is_hidden" value="0" checked="checked"/>开启
  57. </label>
  58. &nbsp;&nbsp;&nbsp;
  59. <label class="curpoin">
  60. <input type="radio" name="is_hidden" value="1"/>关闭
  61. </label>
  62. <p class="notic"></p>
  63. </dd>
  64. </dl>
  65. <dl class="row">
  66. <dt class="tit">
  67. <label>字段必填</label>
  68. </dt>
  69. <dd class="opt" style="width: auto;">
  70. <label class="curpoin">
  71. <input type="radio" name="is_required" value="1"/>是
  72. </label>
  73. &nbsp;&nbsp;&nbsp;
  74. <label class="curpoin">
  75. <input type="radio" name="is_required" value="0" checked="checked"/>否
  76. </label>
  77. <p class="notic"></p>
  78. </dd>
  79. </dl>
  80. <dl class="row">
  81. <dt class="tit">
  82. <label>注册显示</label>
  83. </dt>
  84. <dd class="opt" style="width: auto;">
  85. <label class="curpoin">
  86. <input type="radio" name="is_reg" value="1"/>是
  87. </label>
  88. &nbsp;&nbsp;&nbsp;
  89. <label class="curpoin">
  90. <input type="radio" name="is_reg" value="0" checked="checked"/>否
  91. </label>
  92. <p class="notic">只针对前台的会员属性有效。</p>
  93. </dd>
  94. </dl>
  95. </div>
  96. <!-- 常规选项 -->
  97. <div class="ncap-form-default">
  98. <div class="bot">
  99. <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  100. </div>
  101. </div>
  102. </form>
  103. </div>
  104. <script type="text/javascript">
  105. $(function(){
  106. dtype_change($('#dtype'));
  107. $('input[name=dtype]').click(function(){
  108. dtype_change(this);
  109. });
  110. function dtype_change(obj){
  111. var dtype = $(obj).val()
  112. var ifoption = $(obj).data('ifoption');
  113. if (0 <= $.inArray(dtype, ['datetime','switch','img','imgs','file'])) {
  114. $('#dl_dfvalue').hide();
  115. } else {
  116. if (1 == ifoption) {
  117. $('#label_dfvalue').html('<em>*</em>默认值');
  118. } else {
  119. $('#label_dfvalue').html('默认值');
  120. }
  121. $('#dl_dfvalue').show();
  122. }
  123. if (0 <= $.inArray(dtype, ['text','multitext'])) {
  124. $('#dfvalue').attr('placeholder', '前端将默认显示输入的内容');
  125. } else if (0 <= $.inArray(dtype, ['checkbox','radio','select'])) {
  126. $('#dfvalue').attr('placeholder', '此处填写被选择的项目(用“,”分开,如“男,女”)。');
  127. } else {
  128. $('#dfvalue').attr('placeholder', '前端将默认显示输入的内容');
  129. }
  130. }
  131. });
  132. var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  133. function check_submit(){
  134. if($('input[name="name"]').val() == ''){
  135. showErrorMsg('属性标题不能为空!');
  136. $('input[name=name]').focus();
  137. return false;
  138. }
  139. if($('#dtype').val() == ''){
  140. showErrorMsg('请选择属性类型!');
  141. $('input[name=dtype]').focus();
  142. return false;
  143. } else {
  144. var ifoption = $('#dtype').find('option:selected').data('ifoption');
  145. if (1 == ifoption) {
  146. if ($.trim($('#dfvalue').val()) == '') {
  147. showErrorMsg('默认值不能为空!');
  148. $('#dfvalue').focus();
  149. return false;
  150. }
  151. }
  152. }
  153. if($('#dtype').val() == 'radio' || $('#dtype').val() == 'checkbox' || $('#dtype').val() == 'select'){
  154. var data = $.trim($('#dfvalue').val());
  155. data = data.split(',');
  156. for(var i = 0;i < data.length ;i++) {
  157. for(var j = i+1;j < data.length;j++) {
  158. if ($.trim(data[i]) == $.trim(data [j])){
  159. showErrorMsg('默认值不能含有相同的值!');
  160. $('textarea[name=dfvalue]').focus();
  161. return false;
  162. }
  163. }
  164. }
  165. }
  166. layer_loading('正在处理');
  167. $.ajax({
  168. type : 'post',
  169. url : "{:url('Member/attr_add', ['_ajax'=>1])}",
  170. data : $('#post_form').serialize(),
  171. dataType : 'json',
  172. success : function(res){
  173. layer.closeAll();
  174. if(res.code == 1){
  175. var _parent = parent;
  176. _parent.layer.close(parentObj);
  177. _parent.layer.msg(res.msg, {shade: layer_shade, time: 1000}, function(){
  178. _parent.window.location.reload();
  179. });
  180. }else{
  181. showErrorMsg(res.msg);
  182. }
  183. },
  184. error: function(e){
  185. layer.closeAll();
  186. layer.alert(e.responseText, {icon: 5, title:false});
  187. }
  188. });
  189. }
  190. </script>
  191. {include file="public/footer" /}