截流自动化的商城平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

edit.html 11KB

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