123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- {extend name="base"/}
- {block name="resources"}
- {/block}
- {block name="main"}
- <div class="layui-collapse ns-tips">
- <div class="layui-colla-item">
- <h2 class="layui-colla-title">操作提示</h2>
- <ul class="layui-colla-content layui-show">
- <li>物流公司由平台端进行统计管理和维护。</li>
- <li>系统配置物流公司的地址,联系方式,查询接口,初始打印模板等。</li>
- <li>商家可以根据实际情况选择使用对应平台的物流公司,同时商家可以独立配置自身对应物流公司的打印模板。</li>
- </ul>
- </div>
- </div>
- <div class="ns-single-filter-box">
- <button class="layui-btn ns-bg-color" onclick="add()">添加物流公司</button>
-
- <div class="layui-form">
- <div class="layui-input-inline">
- <input type="text" name="search_text" placeholder="请输入物流公司名称" class="layui-input">
- <button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
- <i class="layui-icon"></i>
- </button>
- </div>
- </div>
- </div>
- <!-- 列表 -->
- <table id="expressCompany" lay-filter="expressCompany"></table>
- <!-- 操作 -->
- <script type="text/html" id="operation">
- <div class="ns-table-btn">
- <a class="layui-btn" lay-event="edit">编辑</a>
- <a class="layui-btn" lay-event="delete">删除</a>
- </div>
- </script>
- <!-- logo -->
- <script type="text/html" id="company">
- <div class="ns-table-tuwen-box">
- <div class="ns-img-box">
- {{# if(d.logo){ }}
- <img layer-src src={{ns.img(d.logo)}} >
- {{# } }}
- </div>
- <div class="ns-font-box">{{d.company_name}}</div>
- </div>
- </script>
- <!-- url -->
- <script type="text/html" id="url">
- <a class="layui-elip" target="_blank" href="{{ns.url(d.url)}}">{{d.url}}</a>
- </script>
- <!-- 批量删除 -->
- <script type="text/html" id="batchOperation">
- <button class="layui-btn layui-btn-primary" lay-event="del">批量删除</button>
- </script>
- <!-- 编辑排序 -->
- <script type="text/html" id="editSort">
- <input name="sort" type="number" onchange="editSort({{d.company_id}}, this)" value="{{d.sort}}" class="layui-input edit-sort ns-sort-len">
- </script>
- {/block}
- {block name="script"}
- <script>
- var form, table;
- layui.use(['form'], function() {
- form = layui.form;
- var repeat_flag = false; //防重复标识
- table = new Table({
- elem: '#expressCompany',
- url: ns.url("admin/express/expressCompany"),
- cols: [
- [{
- width: '3%',
- type: 'checkbox',
- unresize: 'false',
- }, {
- title: '物流公司',
- unresize: 'false',
- templet:'#company',
- width: '32%'
- }, {
- field: 'url',
- title: '物流公司网址',
- unresize: 'false',
- templet:'#url',
- width: '35%'
- },{
- title: '排序',
- unresize: 'false',
- width:'15%',
- align: 'center',
- templet: '#editSort'
- },{
- title: '操作',
- toolbar: '#operation',
- unresize: 'false',
- width: '15%'
- }]
- ],
- bottomToolbar: "#batchOperation"
- });
-
- /**
- * 监听工具栏操作
- */
- table.tool(function(obj) {
- var data = obj.data;
- switch (obj.event) {
- case 'edit': //编辑
- location.href = ns.url("admin/express/editCompany?company_id=" + data.company_id);
- break;
- case 'delete': //删除
- deleteCompany(data.company_id);
- break;
- }
- });
-
- /**
- * 删除
- */
- function deleteCompany(company_ids) {
- if (repeat_flag) return false;
- repeat_flag = true;
-
- layer.confirm('确定要删除该物流公司吗?', function() {
- $.ajax({
- url: ns.url("admin/express/deleteCompany"),
- data: {company_ids},
- dataType: 'JSON',
- type: 'POST',
- success: function(res) {
- layer.msg(res.message);
- repeat_flag = false;
-
- if (res.code == 0) {
- table.reload();
- }
- }
- });
- }, function () {
- layer.close();
- repeat_flag = false;
- });
- }
-
- /**
- * 批量操作
- */
- table.bottomToolbar(function(obj) {
- if (obj.data.length < 1) {
- layer.msg('请选择要操作的数据');
- return;
- }
- switch (obj.event) {
- case "del":
- var id_array = new Array();
- for (i in obj.data) id_array.push(obj.data[i].company_id);
- deleteCompany(id_array.toString());
- break;
- }
- });
-
- /**
- * 搜索功能
- */
- form.on('submit(search)', function(data) {
- table.reload({
- page: {
- curr: 1
- },
- where: data.field
- });
- });
- });
-
- // 监听单元格编辑
- function editSort(id, event){
- var data = $(event).val();
-
- if (data == '') {
- $("input[name=sort]").val(0);
- data = 0;
- }
-
- if(!new RegExp("^-?[0-9]\\d*$").test(data)){
- layer.msg("排序号只能是整数");
- return ;
- }
- if(data<0){
- layer.msg("排序号必须大于0");
- return ;
- }
- $.ajax({
- type: 'POST',
- url: ns.url("admin/express/modifySort"),
- data: {
- sort: data,
- company_id: id
- },
- dataType: 'JSON',
- success: function(res) {
- layer.msg(res.message);
- if(res.code==0){
- table.reload();
- }
- }
- });
- }
-
- function add() {
- location.href = ns.url("admin/express/addCompany");
- }
- </script>
- {/block}
|