截流自动化的商城平台
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. {layout name="layout2" /}
  2. <div class="layui-form" lay-filter="layuiadmin-form-ad_position" id="layuiadmin-form-category" style="padding: 20px 30px 0 0;background-color: #ffffff">
  3. <div class="layui-form-item">
  4. <label class="layui-form-label">模板名称</label>
  5. <div class="layui-input-inline">
  6. <input type="text" name="name" lay-verify="required" placeholder="请输入模板名称" autocomplete="off" class="layui-input">
  7. </div>
  8. </div>
  9. <div class="layui-form-item">
  10. <label class="layui-form-label">计费方式</label>
  11. <div class="layui-input-block" id="charge_way">
  12. <input type="radio" class="type" name="charge_way" lay-filter="charge_way" value="1" title="按重量" checked>
  13. <input type="radio" class="type" name="charge_way" lay-filter="charge_way" value="2" title="按体积">
  14. <input type="radio" class="type" name="charge_way" lay-filter="charge_way" value="3" title="按件数">
  15. </div>
  16. </div>
  17. <div class="layui-form-item">
  18. <label class="layui-form-label">备注</label>
  19. <div class="layui-input-inline">
  20. <textarea name="remark" placeholder="备注信息" class="layui-textarea"></textarea>
  21. </div>
  22. </div>
  23. <div class="layui-form-item">
  24. <label class="layui-form-label">配送区域</label>
  25. <div class="layui-input-block">
  26. <table class="layui-table">
  27. <colgroup>
  28. <col width="25%">
  29. <col width="15%">
  30. <col width="15%">
  31. <col width="15%">
  32. <col width="15%">
  33. <col width="20%">
  34. </colgroup>
  35. <thead>
  36. <tr>
  37. <th>可配送区域</th>
  38. <th class="th_first_unit">首重 (kg)</th>
  39. <th class="th_first_money">运费 (元)</th>
  40. <th class="th_continue_unit">续重 (kg)</th>
  41. <th class="th_continue_money">续费 (元)</th>
  42. <th class="able-operat">操作</th>
  43. </tr>
  44. </thead>
  45. <tbody >
  46. <!--全国-->
  47. <tr class='area_all'>
  48. <td><span class='all_area_name'>全国</span></td>
  49. <input type='hidden' class='region' name='region[]' value='all'>
  50. <td><input type='number' name='first_unit[]' lay-verify='required' autocomplete='off' class='layui-input '></td>
  51. <td><input type='number' name='first_money[]' lay-verify='required' autocomplete='off' class='layui-input '></td>
  52. <td><input type='number' name='continue_unit[]' lay-verify='required' autocomplete='off' class='layui-input '></td>
  53. <td><input type='number' name='continue_money[]' lay-verify='required' autocomplete='off' class='layui-input '></td>
  54. <td></td>
  55. </tr>
  56. <tr class="area_tbody"></tr>
  57. </tbody>
  58. </table>
  59. </div>
  60. </div>
  61. <div class="layui-form-item">
  62. <label class="layui-form-label"></label>
  63. <div class="layui-input-inline">
  64. <button type="button" id="btn-area" class="layui-btn layui-btn-sm layui-btn-normal layuiadmin-btn-select_area" >添加运费规则</button>
  65. </div>
  66. </div>
  67. <div class="layui-form-item layui-hide">
  68. <input type="button" lay-submit lay-filter="add-freight-submit" id="add-freight-submit" value="确认">
  69. </div>
  70. </div>
  71. <script>
  72. $("html").css('background-color','#FFFFFF');
  73. var araeDataIds = '';
  74. var araeDataNmae = '';
  75. layui.config({
  76. version:"{$front_version}",
  77. base: '/static/lib/'
  78. }).extend({
  79. likeedit: 'likeedit/likeedit',
  80. dtree:'dtree/dtree'
  81. }).use(['table', 'form', 'element', 'likeedit','dtree'], function() {
  82. var form = layui.form
  83. , $ = layui.$
  84. , table = layui.table
  85. , element = layui.element
  86. , dtree = layui.dtree
  87. , likeedit = layui.likeedit;
  88. window.callTree = function (data) {
  89. for (var i =0;i< data.length; i++){
  90. araeDataNmae += data[i]['context']+',';
  91. araeDataIds += data[i]['nodeId'] + ',';
  92. }
  93. araeDataNmae = araeDataNmae.substring(0,araeDataNmae.length-1);
  94. araeDataIds = araeDataIds.substring(0,araeDataIds.length-1);
  95. };
  96. $(document).on('click', '#btn-area', function () {
  97. layer.open({
  98. type: 2
  99. ,title: '配送区域'
  100. ,content: '{:url("freight/area")}'
  101. ,area: ['90%', '90%']
  102. ,btn: ['确定','返回']
  103. ,yes: function(index, layero){
  104. var iframeWindow = window['layui-layer-iframe'+ index]
  105. ,submitID = 'area-freight-submit'
  106. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  107. //监听提交
  108. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  109. if (araeDataIds == ''){
  110. layer.msg('请选择地区');
  111. return ;
  112. }
  113. addArea(araeDataNmae);
  114. $('input.region:last').val(araeDataIds);
  115. araeDataNmae = '';
  116. araeDataIds = '';
  117. layer.close(index);
  118. });
  119. submit.trigger('click');
  120. }
  121. });
  122. });
  123. form.on('submit(add-freight-submit)', function (data) {
  124. var field = data.field;
  125. like.ajax({
  126. url: '{:url("freight/add")}'
  127. , data: field
  128. , type: 'post'
  129. , success: function (res) {
  130. if (res.code == 1) {
  131. layui.layer.msg(res.msg, {
  132. offset: '15px'
  133. , icon: 1
  134. , time: 1000
  135. },function () {
  136. });
  137. }
  138. },
  139. });
  140. });
  141. // 切换计费方式变动表格描述
  142. form.on('radio(charge_way)', function (data) {
  143. var value = data.value;
  144. showChargeWay(value)
  145. });
  146. });
  147. function addArea(data) {
  148. var add = ".area_tr";
  149. var id = $('tr.area_tr:last').attr('data-id');
  150. if (id === undefined){
  151. id = 1;
  152. add = ".area_tbody";
  153. }else{
  154. add = add+id;
  155. }
  156. var v = parseInt(id) + 1;
  157. var str = "<tr class='area_tr area_tr"+v+"' data-id='" + v + "'>" +
  158. "<td><span class=' area_name area_name"+v+" '>"+data+"</span></td>" +
  159. "<input type='hidden' class='region region"+v+" ' name='region["+v+"]' value=''>" +
  160. "<td><input type='number' name='first_unit["+v+"]' lay-verify='required' autocomplete='off' class='layui-input '></td>" +
  161. "<td><input type='number' name='first_money["+v+"]' lay-verify='required' autocomplete='off' class='layui-input '></td>" +
  162. "<td><input type='number' name='continue_unit["+v+"]' lay-verify='required' autocomplete='off' class='layui-input '></td>" +
  163. "<td><input type='number' name='continue_money["+v+"]' lay-verify='required' autocomplete='off' class='layui-input '></td>" +
  164. "<td style='text-align:center'>" +
  165. "<button class='layui-btn layui-btn-sm layui-btn-normal' type='button' onclick='editArea(" + v + ")'>" +
  166. "<i class='layui-icon layui-icon-edit'></i>" +
  167. "</button>" +
  168. "<button class='layui-btn layui-btn-sm layui-btn-danger' type='button' onclick='delArea(" + v + ")'>" +
  169. "<i class='layui-icon layui-icon-delete'></i>" +
  170. "</button>" +
  171. "</td>" +
  172. "</tr>";
  173. $(add).after(str);
  174. }
  175. function delArea(value) {
  176. $(".area_tr" + value).remove();
  177. }
  178. //编辑模板行
  179. function editArea(value) {
  180. var regionSelected = '.region'+value;//选择编辑的行
  181. var selectIds = $(regionSelected).val();//选中行的地区id
  182. layer.open({
  183. type: 2
  184. , title: '配送区域'
  185. , content: '{:url("freight/areaEdit")}'
  186. , area: ['90%', '90%']
  187. , btn: ['确定', '返回']
  188. , success: function (layero,index) {
  189. var iframe = window['layui-layer-iframe' + index];
  190. iframe.editSelected(selectIds);
  191. }
  192. , yes: function (index, layero) {
  193. var iframeWindow = window['layui-layer-iframe' + index]
  194. , submitID = 'area-freight-submit'
  195. , submit = layero.find('iframe').contents().find('#' + submitID);
  196. //监听提交
  197. iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
  198. if (araeDataIds == '') {
  199. layer.msg('请选择地区');
  200. return;
  201. }
  202. $(".area_name" + value).text(araeDataNmae);
  203. $(".region" + value).val(araeDataIds);
  204. araeDataNmae = '';
  205. araeDataIds = '';
  206. layer.close(index);
  207. });
  208. submit.trigger('click');
  209. }
  210. });
  211. }
  212. // 显示不同计费方式单位
  213. function showChargeWay(value)
  214. {
  215. switch (value) {
  216. case '1': // 重量
  217. $('.th_first_unit').text("首重 (kg)");
  218. $('.th_continue_unit').text("续重 (kg)");
  219. break;
  220. case '2': // 体积
  221. $('.th_first_unit').text("首体积 (m³)");
  222. $('.th_continue_unit').text("续体积 (m³)");
  223. break;
  224. case '3': // 件数
  225. $('.th_first_unit').text("首件 (件)");
  226. $('.th_continue_unit').text("续件 (件)");
  227. break;
  228. }
  229. }
  230. </script>