xg 2 年之前
父节点
当前提交
2e96822482

+ 74 - 0
application/admin/controller/MobileOrderNo.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 预定号码
+ *
+ * @icon fa fa-circle-o
+ */
+class MobileOrderNo extends Backend
+{
+    
+    /**
+     * MobileOrderNo模型对象
+     * @var \app\admin\model\MobileOrderNo
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\MobileOrderNo;
+
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = false;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                $row->visible(['id','no','price_max','remark','name','city','address','create_time']);
+                
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+}

+ 12 - 0
application/admin/lang/zh-cn/mobile_order_no.php

@@ -0,0 +1,12 @@
+<?php
+
+return [
+    'No'          => '号码',
+    'Price_min'   => '承受最低价',
+    'Price_max'   => '承受最高价',
+    'Remark'      => '备注',
+    'Name'        => '姓名',
+    'City'        => '城市',
+    'Address'     => '详细地址',
+    'Create_time' => '创建时间'
+];

+ 11 - 0
application/admin/model/MobileOrderNo.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class MobileOrderNo extends \app\common\model\MobileOrderNo
+{
+    protected $append=['city_name'];
+}

+ 27 - 0
application/admin/validate/MobileOrderNo.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class MobileOrderNo extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 24 - 0
application/admin/view/mobile_order_no/index.html

@@ -0,0 +1,24 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('mobile_order_no/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="0"
+                           data-operate-del="{:$auth->check('mobile_order_no/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 4 - 6
application/common/model/MobileOrderNo.php

@@ -10,13 +10,11 @@ use Yansongda\Supports\Str;
  */
 class MobileOrderNo extends Model
 {
-
-
-
-
-
-
     // 自动写入时间戳字段
     protected $autoWriteTimestamp = true;
     protected $updateTime=false;
+
+    protected function getCityNameAttr($_,$model){
+        return Area::getNameString($model['city']);
+    }
 }

+ 57 - 0
public/assets/js/backend/mobile_order_no.js

@@ -0,0 +1,57 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'mobile_order_no/index' + location.search,
+                    add_url: 'mobile_order_no/add',
+                    edit_url: 'mobile_order_no/edit',
+                    del_url: 'mobile_order_no/del',
+                    multi_url: 'mobile_order_no/multi',
+                    import_url: 'mobile_order_no/import',
+                    table: 'mobile_order_no',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'no', title: __('No')},
+                        {field: 'price_max', title: __('Price_max')},
+                        {field: 'remark', title: __('Remark')},
+                        {field: 'name', title: __('Name')},
+                        {field: 'city_name', title: __('City'),operate: false},
+                        {field: 'address', title: __('Address'), operate: 'LIKE'},
+                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});