From 32521adc7ede7e03bb2c477faa6e991a238b4420 Mon Sep 17 00:00:00 2001 From: kaiend Date: Tue, 27 Feb 2018 17:29:49 +0800 Subject: [PATCH] travel notes --- .../controller/travelnotes/Travelnotes.php | 37 ++++++++++ .../lang/zh-cn/travelnotes/travelnotes.php | 18 +++++ application/admin/model/Travelnotes.php | 53 ++++++++++++++ application/admin/validate/Travelnotes.php | 27 +++++++ .../view/travelnotes/travelnotes/add.html | 72 +++++++++++++++++++ .../view/travelnotes/travelnotes/edit.html | 72 +++++++++++++++++++ .../view/travelnotes/travelnotes/index.html | 33 +++++++++ .../js/backend/travelnotes/travelnotes.js | 57 +++++++++++++++ 8 files changed, 369 insertions(+) create mode 100644 application/admin/controller/travelnotes/Travelnotes.php create mode 100644 application/admin/lang/zh-cn/travelnotes/travelnotes.php create mode 100644 application/admin/model/Travelnotes.php create mode 100644 application/admin/validate/Travelnotes.php create mode 100644 application/admin/view/travelnotes/travelnotes/add.html create mode 100644 application/admin/view/travelnotes/travelnotes/edit.html create mode 100644 application/admin/view/travelnotes/travelnotes/index.html create mode 100644 public/assets/js/backend/travelnotes/travelnotes.js diff --git a/application/admin/controller/travelnotes/Travelnotes.php b/application/admin/controller/travelnotes/Travelnotes.php new file mode 100644 index 00000000..9c4b67ae --- /dev/null +++ b/application/admin/controller/travelnotes/Travelnotes.php @@ -0,0 +1,37 @@ +model = model('Travelnotes'); + $this->view->assign("starList", $this->model->getStarList()); + } + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法 + * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/lang/zh-cn/travelnotes/travelnotes.php b/application/admin/lang/zh-cn/travelnotes/travelnotes.php new file mode 100644 index 00000000..4a4e2549 --- /dev/null +++ b/application/admin/lang/zh-cn/travelnotes/travelnotes.php @@ -0,0 +1,18 @@ + 'ID', + 'Image' => '游记头图', + 'Title' => '游记标题', + 'Content' => '游记正文', + 'Userid' => 'userid', + 'Create_time' => '创建时间', + 'Update_time' => '更新时间', + 'Read_number' => '阅读量', + 'Star' => '评论', + 'Star 1' => '1', + 'Star 2' => '2', + 'Star 3' => '3', + 'Star 4' => '4', + 'Star 5' => '5' +]; diff --git a/application/admin/model/Travelnotes.php b/application/admin/model/Travelnotes.php new file mode 100644 index 00000000..e57ae479 --- /dev/null +++ b/application/admin/model/Travelnotes.php @@ -0,0 +1,53 @@ + __('Star 1'),'2' => __('Star 2'),'3' => __('Star 3'),'4' => __('Star 4'),'5' => __('Star 5')]; + } + + + public function getCreateTimeTextAttr($value, $data) + { + $value = $value ? $value : $data['create_time']; + return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; + } + + + public function getStarTextAttr($value, $data) + { + $value = $value ? $value : $data['star']; + $list = $this->getStarList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + protected function setCreateTimeAttr($value) + { + return $value && !is_numeric($value) ? strtotime($value) : $value; + } + + +} diff --git a/application/admin/validate/Travelnotes.php b/application/admin/validate/Travelnotes.php new file mode 100644 index 00000000..e77f8ccb --- /dev/null +++ b/application/admin/validate/Travelnotes.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/travelnotes/travelnotes/add.html b/application/admin/view/travelnotes/travelnotes/add.html new file mode 100644 index 00000000..2c5c6c36 --- /dev/null +++ b/application/admin/view/travelnotes/travelnotes/add.html @@ -0,0 +1,72 @@ +
+ +
+ +
+
+ +
+ + +
+ +
+
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + + + +
    +
    + +
    diff --git a/application/admin/view/travelnotes/travelnotes/edit.html b/application/admin/view/travelnotes/travelnotes/edit.html new file mode 100644 index 00000000..1d51658e --- /dev/null +++ b/application/admin/view/travelnotes/travelnotes/edit.html @@ -0,0 +1,72 @@ +
    + +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + + + +
      +
      + +
      diff --git a/application/admin/view/travelnotes/travelnotes/index.html b/application/admin/view/travelnotes/travelnotes/index.html new file mode 100644 index 00000000..aa2781dc --- /dev/null +++ b/application/admin/view/travelnotes/travelnotes/index.html @@ -0,0 +1,33 @@ +
      + {:build_heading()} + + +
      diff --git a/public/assets/js/backend/travelnotes/travelnotes.js b/public/assets/js/backend/travelnotes/travelnotes.js new file mode 100644 index 00000000..f6b56bb3 --- /dev/null +++ b/public/assets/js/backend/travelnotes/travelnotes.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: 'travelnotes/travelnotes/index', + add_url: 'travelnotes/travelnotes/add', + edit_url: 'travelnotes/travelnotes/edit', + del_url: 'travelnotes/travelnotes/del', + multi_url: 'travelnotes/travelnotes/multi', + table: 'travelnotes', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'image', title: __('Image'), formatter: Table.api.formatter.image}, + {field: 'title', title: __('Title')}, + {field: 'userid', title: __('Userid')}, + {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, + {field: 'read_number', title: __('Read_number')}, + {field: 'star', title: __('Star'), visible:false, searchList: {"star 1":__('Star 1'),"star 2":__('Star 2'),"star 3":__('Star 3'),"star 4":__('Star 4'),"star 5":__('Star 5')}}, + {field: 'star_text', title: __('Star'), operate:false}, + {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; +}); \ No newline at end of file