attribute_edit.htm 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. {include file="public/layout" /}
  2. <body style="background-color: #FFF; overflow: 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" style="box-shadow:none;">
  7. <div class="fixed-bar">
  8. <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-chevron-left"></i></a>
  9. <div class="subject">
  10. <h3>编辑参数</h3>
  11. <h5></h5>
  12. </div>
  13. </div>
  14. </div>
  15. <form class="form-horizontal" id="post_form" action="{:U('Product/attribute_edit')}" method="post">
  16. <div class="ncap-form-default">
  17. <dl class="row">
  18. <dt class="tit">
  19. <label for="typeid"><em>*</em>所属栏目</label>
  20. </dt>
  21. <dd class="opt">
  22. <select name="typeid" id="typeid">
  23. {$arctype_html}
  24. </select>
  25. <span class="err" id="err_typeid" style="color:#F00; display:none;"></span>
  26. <p class="notic"></p>
  27. </dd>
  28. </dl>
  29. <dl class="row">
  30. <dt class="tit">
  31. <label for="ac_name"><em>*</em>参数名称</label>
  32. </dt>
  33. <dd class="opt">
  34. <input type="text" name="attr_name" value="{$field.attr_name}" id="attr_name" class="input-txt">
  35. <span class="err" id="err_attr_name" style="color:#F00; display:none;"></span>
  36. <p class="notic"></p>
  37. </dd>
  38. </dl>
  39. <dl class="row">
  40. <dt class="tit">
  41. <label for="attr_input_type"><em>*</em>表单类型</label>
  42. </dt>
  43. <dd class="opt">
  44. <label><input type="radio" value="0" name="attr_input_type" {empty name="field.attr_input_type"}checked="checked"{/empty} />单行文本</label>
  45. <label><input type="radio" value="2" name="attr_input_type" {eq name="field.attr_input_type" value="2"}checked="checked"{/eq} />多行文本</label>
  46. <label><input type="radio" value="1" name="attr_input_type" {eq name="field.attr_input_type" value="1"}checked="checked"{/eq} />下拉框</label>
  47. <span class="err" id="err_attr_input_type" style="color:#F00; display:none;"></span>
  48. <p class="notic"></p>
  49. </dd>
  50. </dl>
  51. <dl class="row attr_input_type2 {neq name='field.attr_input_type' value='1'}none{/neq}">
  52. <dt class="tit">
  53. <label for="attr_values"><em>*</em>可选值列表</label>
  54. </dt>
  55. <dd class="opt">
  56. <textarea rows="10" cols="30" name="attr_values" id="attr_values" class="input-txt" style="height:100px;" placeholder="一行代表一个可选值">{$field.attr_values}</textarea>
  57. <span id="err_attr_values" class="err" style="color:#F00; display:none;"></span>
  58. <p class="notic">一行代表一个可选值</p>
  59. </dd>
  60. </dl>
  61. <dl class="row">
  62. <dt class="tit">
  63. <label>排序</label>
  64. </dt>
  65. <dd class="opt">
  66. <input type="text" value="{$field.sort_order}" name="sort_order" id="sort_order" class="input-txt">
  67. <span class="err"></span>
  68. <p class="notic">越小越靠前</p>
  69. </dd>
  70. </dl>
  71. <div class="bot">
  72. <input type="hidden" name="attr_id" value="{$field.attr_id}">
  73. <a href="JavaScript:void(0);" onclick="check_submit('post_form');" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  74. </div>
  75. </form>
  76. </div>
  77. <script type="text/javascript">
  78. $(function(){
  79. $('input[name=attr_input_type]').click(function(){
  80. var val = $(this).val();
  81. if (val == 1) {
  82. $('.attr_input_type2').show();
  83. } else {
  84. $('.attr_input_type2').hide();
  85. }
  86. });
  87. var dftypeid = {$field.typeid|default='0'};
  88. $('#typeid').change(function(){
  89. var current_channel = $(this).find('option:selected').data('current_channel');
  90. if (0 < $(this).val() && {$channeltype} != current_channel) {
  91. showErrorMsg('请选择对应模型的栏目!');
  92. $(this).val(dftypeid);
  93. } else if ({$channeltype} == current_channel) {
  94. layer.closeAll();
  95. }
  96. });
  97. });
  98. /**
  99. * ajax 提交表单 到后台去验证然后回到前台提示错误
  100. * 验证通过后,再通过 form 自动提交
  101. */
  102. function check_submit(form_id)
  103. {
  104. if ($('#typeid').val() == 0) {
  105. showErrorMsg('请选择栏目…!');
  106. $('#typeid').focus();
  107. return false;
  108. }
  109. if($.trim($('input[name=attr_name]').val()) == ''){
  110. showErrorMsg('参数名称不能为空!');
  111. $('input[name=attr_name]').focus();
  112. return false;
  113. }
  114. if ($('input[name=attr_input_type]').is(':checked') == false) {
  115. showErrorMsg('请选择表单类型!');
  116. $($('input[name=attr_input_type]')[0]).focus();
  117. return false;
  118. }
  119. if ($('input[name=attr_input_type]:checked').val() == 1 && $.trim($('#attr_values').val()) == '') {
  120. showErrorMsg('可选值列表不能为空!');
  121. $('#attr_values').focus();
  122. return false;
  123. }
  124. layer_loading('正在处理');
  125. $.ajax({
  126. type : "POST",
  127. url : "{:url('Product/attribute_edit', ['_ajax'=>1])}",
  128. data : $('#'+form_id).serialize(),// 你的formid
  129. dataType: "JSON",
  130. error: function(request) {
  131. layer.closeAll();
  132. layer.alert(ey_unknown_error, {icon: 5, title:false});
  133. return false;
  134. },
  135. success: function(v) {
  136. layer.closeAll();
  137. if(v.status == 1)
  138. {
  139. if(v.hasOwnProperty('data')){
  140. if(v.data.hasOwnProperty('url')){
  141. location.href = v.data.url;
  142. }else{
  143. location.href = location.href;
  144. }
  145. }else{
  146. location.href = location.href;
  147. }
  148. return true;
  149. } else {
  150. showErrorMsg(v.msg);
  151. return false;
  152. }
  153. }
  154. });
  155. }
  156. </script>
  157. {include file="public/footer" /}