No Description
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.

attribute_add.htm 6.9KB

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