express_company.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. {extend name="base"/}
  2. {block name="resources"}
  3. {/block}
  4. {block name="main"}
  5. <div class="layui-collapse ns-tips">
  6. <div class="layui-colla-item">
  7. <h2 class="layui-colla-title">操作提示</h2>
  8. <ul class="layui-colla-content layui-show">
  9. <li>物流公司由平台端进行统计管理和维护。</li>
  10. <li>系统配置物流公司的地址,联系方式,查询接口,初始打印模板等。</li>
  11. <li>商家可以根据实际情况选择使用对应平台的物流公司,同时商家可以独立配置自身对应物流公司的打印模板。</li>
  12. </ul>
  13. </div>
  14. </div>
  15. <div class="ns-single-filter-box">
  16. <button class="layui-btn ns-bg-color" onclick="add()">添加物流公司</button>
  17. <div class="layui-form">
  18. <div class="layui-input-inline">
  19. <input type="text" name="search_text" placeholder="请输入物流公司名称" class="layui-input">
  20. <button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
  21. <i class="layui-icon">&#xe615;</i>
  22. </button>
  23. </div>
  24. </div>
  25. </div>
  26. <!-- 列表 -->
  27. <table id="expressCompany" lay-filter="expressCompany"></table>
  28. <!-- 操作 -->
  29. <script type="text/html" id="operation">
  30. <div class="ns-table-btn">
  31. <a class="layui-btn" lay-event="edit">编辑</a>
  32. <a class="layui-btn" lay-event="delete">删除</a>
  33. </div>
  34. </script>
  35. <!-- logo -->
  36. <script type="text/html" id="company">
  37. <div class="ns-table-tuwen-box">
  38. <div class="ns-img-box">
  39. {{# if(d.logo){ }}
  40. <img layer-src src={{ns.img(d.logo)}} >
  41. {{# } }}
  42. </div>
  43. <div class="ns-font-box">{{d.company_name}}</div>
  44. </div>
  45. </script>
  46. <!-- url -->
  47. <script type="text/html" id="url">
  48. <a class="layui-elip" target="_blank" href="{{ns.url(d.url)}}">{{d.url}}</a>
  49. </script>
  50. <!-- 批量删除 -->
  51. <script type="text/html" id="batchOperation">
  52. <button class="layui-btn layui-btn-primary" lay-event="del">批量删除</button>
  53. </script>
  54. <!-- 编辑排序 -->
  55. <script type="text/html" id="editSort">
  56. <input name="sort" type="number" onchange="editSort({{d.company_id}}, this)" value="{{d.sort}}" class="layui-input edit-sort ns-sort-len">
  57. </script>
  58. {/block}
  59. {block name="script"}
  60. <script>
  61. var form, table;
  62. layui.use(['form'], function() {
  63. form = layui.form;
  64. var repeat_flag = false; //防重复标识
  65. table = new Table({
  66. elem: '#expressCompany',
  67. url: ns.url("admin/express/expressCompany"),
  68. cols: [
  69. [{
  70. width: '3%',
  71. type: 'checkbox',
  72. unresize: 'false',
  73. }, {
  74. title: '物流公司',
  75. unresize: 'false',
  76. templet:'#company',
  77. width: '32%'
  78. }, {
  79. field: 'url',
  80. title: '物流公司网址',
  81. unresize: 'false',
  82. templet:'#url',
  83. width: '35%'
  84. },{
  85. title: '排序',
  86. unresize: 'false',
  87. width:'15%',
  88. align: 'center',
  89. templet: '#editSort'
  90. },{
  91. title: '操作',
  92. toolbar: '#operation',
  93. unresize: 'false',
  94. width: '15%'
  95. }]
  96. ],
  97. bottomToolbar: "#batchOperation"
  98. });
  99. /**
  100. * 监听工具栏操作
  101. */
  102. table.tool(function(obj) {
  103. var data = obj.data;
  104. switch (obj.event) {
  105. case 'edit': //编辑
  106. location.href = ns.url("admin/express/editCompany?company_id=" + data.company_id);
  107. break;
  108. case 'delete': //删除
  109. deleteCompany(data.company_id);
  110. break;
  111. }
  112. });
  113. /**
  114. * 删除
  115. */
  116. function deleteCompany(company_ids) {
  117. if (repeat_flag) return false;
  118. repeat_flag = true;
  119. layer.confirm('确定要删除该物流公司吗?', function() {
  120. $.ajax({
  121. url: ns.url("admin/express/deleteCompany"),
  122. data: {company_ids},
  123. dataType: 'JSON',
  124. type: 'POST',
  125. success: function(res) {
  126. layer.msg(res.message);
  127. repeat_flag = false;
  128. if (res.code == 0) {
  129. table.reload();
  130. }
  131. }
  132. });
  133. }, function () {
  134. layer.close();
  135. repeat_flag = false;
  136. });
  137. }
  138. /**
  139. * 批量操作
  140. */
  141. table.bottomToolbar(function(obj) {
  142. if (obj.data.length < 1) {
  143. layer.msg('请选择要操作的数据');
  144. return;
  145. }
  146. switch (obj.event) {
  147. case "del":
  148. var id_array = new Array();
  149. for (i in obj.data) id_array.push(obj.data[i].company_id);
  150. deleteCompany(id_array.toString());
  151. break;
  152. }
  153. });
  154. /**
  155. * 搜索功能
  156. */
  157. form.on('submit(search)', function(data) {
  158. table.reload({
  159. page: {
  160. curr: 1
  161. },
  162. where: data.field
  163. });
  164. });
  165. });
  166. // 监听单元格编辑
  167. function editSort(id, event){
  168. var data = $(event).val();
  169. if (data == '') {
  170. $("input[name=sort]").val(0);
  171. data = 0;
  172. }
  173. if(!new RegExp("^-?[0-9]\\d*$").test(data)){
  174. layer.msg("排序号只能是整数");
  175. return ;
  176. }
  177. if(data<0){
  178. layer.msg("排序号必须大于0");
  179. return ;
  180. }
  181. $.ajax({
  182. type: 'POST',
  183. url: ns.url("admin/express/modifySort"),
  184. data: {
  185. sort: data,
  186. company_id: id
  187. },
  188. dataType: 'JSON',
  189. success: function(res) {
  190. layer.msg(res.message);
  191. if(res.code==0){
  192. table.reload();
  193. }
  194. }
  195. });
  196. }
  197. function add() {
  198. location.href = ns.url("admin/express/addCompany");
  199. }
  200. </script>
  201. {/block}