背景图、轮播图
This commit is contained in:
parent
7d2507bd1a
commit
18fea029f8
25
app/api/controller/BackgroundController.php
Normal file
25
app/api/controller/BackgroundController.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\model\Background;
|
||||||
|
use app\constant\ResponseCode;
|
||||||
|
|
||||||
|
class BackgroundController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $noNeedLogin = ['*'];
|
||||||
|
|
||||||
|
public function getBackground()
|
||||||
|
{
|
||||||
|
$background = Background::where(['id' => 1])->field('url')->find();
|
||||||
|
|
||||||
|
return $this->json([
|
||||||
|
'code' => ResponseCode::SUCCESS,
|
||||||
|
'data' => $background,
|
||||||
|
'msg' => 'success'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
app/api/controller/SlideshowController.php
Normal file
20
app/api/controller/SlideshowController.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\BaseController;
|
||||||
|
use app\common\service\SlideshowService;
|
||||||
|
use support\Request;
|
||||||
|
|
||||||
|
class SlideshowController extends BaseController
|
||||||
|
{
|
||||||
|
protected $noNeedLogin = ['*'];
|
||||||
|
|
||||||
|
public function getSlideshow(Request $request)
|
||||||
|
{
|
||||||
|
$service = new SlideshowService();
|
||||||
|
$result = $service->getSlideshow();
|
||||||
|
return $this->json($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
app/common/model/Background.php
Normal file
19
app/common/model/Background.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use app\BaseModel;
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wa_background 背景图
|
||||||
|
* @property integer $id (主键)
|
||||||
|
* @property string $url 背景图
|
||||||
|
* @property mixed $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
* @property string $deleted_at
|
||||||
|
*/
|
||||||
|
class Background extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
22
app/common/model/Slideshow.php
Normal file
22
app/common/model/Slideshow.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use app\BaseModel;
|
||||||
|
use support\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wa_slideshow 轮播图
|
||||||
|
* @property integer $id (主键)
|
||||||
|
* @property string $img 轮播图
|
||||||
|
* @property integer $sort 排序(越大越靠前)
|
||||||
|
* @property mixed $created_at 创建时间
|
||||||
|
* @property string $updated_at 更新时间
|
||||||
|
* @property string $deleted_at 删除时间
|
||||||
|
*/
|
||||||
|
class Slideshow extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
29
app/common/service/SlideshowService.php
Normal file
29
app/common/service/SlideshowService.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\service;
|
||||||
|
|
||||||
|
use app\common\model\Slideshow;
|
||||||
|
use app\constant\ResponseCode;
|
||||||
|
|
||||||
|
class SlideshowService
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc 轮播图
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function getSlideshow()
|
||||||
|
{
|
||||||
|
$list = Slideshow::order('sort desc, id asc')->field('img')->select();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::SUCCESS,
|
||||||
|
'data' => $list,
|
||||||
|
'msg' => 'success'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
plugin/admin/app/controller/BackgroundController.php
Normal file
68
plugin/admin/app/controller/BackgroundController.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use plugin\admin\app\model\Background;
|
||||||
|
use plugin\admin\app\controller\Crud;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 背景图
|
||||||
|
*/
|
||||||
|
class BackgroundController extends Crud
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Background
|
||||||
|
*/
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->model = new Background;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return view('background/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function insert(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
return parent::insert($request);
|
||||||
|
}
|
||||||
|
return view('background/insert');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function update(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
return parent::update($request);
|
||||||
|
}
|
||||||
|
return view('background/update');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
plugin/admin/app/controller/SlideshowController.php
Normal file
68
plugin/admin/app/controller/SlideshowController.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\controller;
|
||||||
|
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use plugin\admin\app\model\Slideshow;
|
||||||
|
use plugin\admin\app\controller\Crud;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 轮播图
|
||||||
|
*/
|
||||||
|
class SlideshowController extends Crud
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Slideshow
|
||||||
|
*/
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->model = new Slideshow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 浏览
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
return view('slideshow/index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function insert(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
return parent::insert($request);
|
||||||
|
}
|
||||||
|
return view('slideshow/insert');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
* @throws BusinessException
|
||||||
|
*/
|
||||||
|
public function update(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
return parent::update($request);
|
||||||
|
}
|
||||||
|
return view('slideshow/update');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
plugin/admin/app/model/Background.php
Normal file
32
plugin/admin/app/model/Background.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\model;
|
||||||
|
|
||||||
|
use plugin\admin\app\model\Base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property integer $id (主键)
|
||||||
|
* @property string $url 背景图
|
||||||
|
* @property mixed $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
* @property string $deleted_at
|
||||||
|
*/
|
||||||
|
class Background extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'wa_background';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
33
plugin/admin/app/model/Slideshow.php
Normal file
33
plugin/admin/app/model/Slideshow.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\model;
|
||||||
|
|
||||||
|
use plugin\admin\app\model\Base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property integer $id (主键)
|
||||||
|
* @property string $img 轮播图
|
||||||
|
* @property integer $sort 排序(越大越靠前)
|
||||||
|
* @property mixed $created_at 创建时间
|
||||||
|
* @property string $updated_at 更新时间
|
||||||
|
* @property string $deleted_at 删除时间
|
||||||
|
*/
|
||||||
|
class Slideshow extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The table associated with the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = 'wa_slideshow';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary key associated with the table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
262
plugin/admin/app/view/background/index.html
Normal file
262
plugin/admin/app/view/background/index.html
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>浏览页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
</head>
|
||||||
|
<body class="pear-container">
|
||||||
|
|
||||||
|
<!-- 顶部查询表单 -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 数据表格 -->
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<table id="data-table" lay-filter="data-table"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 表格顶部工具栏 -->
|
||||||
|
<script type="text/html" id="table-toolbar">
|
||||||
|
<!-- <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.background.insert">-->
|
||||||
|
<!-- <i class="layui-icon layui-icon-add-1"></i>新增-->
|
||||||
|
<!-- </button>-->
|
||||||
|
<!-- <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="app.admin.background.delete">-->
|
||||||
|
<!-- <i class="layui-icon layui-icon-delete"></i>删除-->
|
||||||
|
<!-- </button>-->
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- 表格行工具栏 -->
|
||||||
|
<script type="text/html" id="table-bar">
|
||||||
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.background.update">编辑</button>
|
||||||
|
<!-- <button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.background.delete">删除</button>-->
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/common.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关常量
|
||||||
|
const PRIMARY_KEY = "id";
|
||||||
|
const SELECT_API = "/app/admin/background/select";
|
||||||
|
const UPDATE_API = "/app/admin/background/update";
|
||||||
|
const DELETE_API = "/app/admin/background/delete";
|
||||||
|
const INSERT_URL = "/app/admin/background/insert";
|
||||||
|
const UPDATE_URL = "/app/admin/background/update";
|
||||||
|
|
||||||
|
// 表格渲染
|
||||||
|
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||||
|
let table = layui.table;
|
||||||
|
let form = layui.form;
|
||||||
|
let $ = layui.$;
|
||||||
|
let common = layui.common;
|
||||||
|
let util = layui.util;
|
||||||
|
|
||||||
|
// 表头参数
|
||||||
|
let cols = [
|
||||||
|
{
|
||||||
|
type: "checkbox",
|
||||||
|
align: "center"
|
||||||
|
},{
|
||||||
|
title: "id",align: "center",
|
||||||
|
field: "id",
|
||||||
|
},{
|
||||||
|
title: "背景图",align: "center",
|
||||||
|
field: "url",
|
||||||
|
templet: function (d) {
|
||||||
|
return '<img src="'+encodeURI(d['url'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "created_at",align: "center",
|
||||||
|
field: "created_at",
|
||||||
|
},{
|
||||||
|
title: "updated_at",align: "center",
|
||||||
|
field: "updated_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
title: "deleted_at",align: "center",
|
||||||
|
field: "deleted_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
title: "操作",
|
||||||
|
toolbar: "#table-bar",
|
||||||
|
align: "center",
|
||||||
|
fixed: "right",
|
||||||
|
width: 120,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// 渲染表格
|
||||||
|
table.render({
|
||||||
|
elem: "#data-table",
|
||||||
|
url: SELECT_API,
|
||||||
|
page: true,
|
||||||
|
cols: [cols],
|
||||||
|
skin: "line",
|
||||||
|
size: "lg",
|
||||||
|
toolbar: "#table-toolbar",
|
||||||
|
autoSort: false,
|
||||||
|
defaultToolbar: [{
|
||||||
|
title: "刷新",
|
||||||
|
layEvent: "refresh",
|
||||||
|
icon: "layui-icon-refresh",
|
||||||
|
}, "filter", "print", "exports"],
|
||||||
|
done: function () {
|
||||||
|
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 编辑或删除行事件
|
||||||
|
table.on("tool(data-table)", function(obj) {
|
||||||
|
if (obj.event === "remove") {
|
||||||
|
remove(obj);
|
||||||
|
} else if (obj.event === "edit") {
|
||||||
|
edit(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部工具栏事件
|
||||||
|
table.on("toolbar(data-table)", function(obj) {
|
||||||
|
if (obj.event === "add") {
|
||||||
|
add();
|
||||||
|
} else if (obj.event === "refresh") {
|
||||||
|
refreshTable();
|
||||||
|
} else if (obj.event === "batchRemove") {
|
||||||
|
batchRemove(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部搜索事件
|
||||||
|
form.on("submit(table-query)", function(data) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
page: {
|
||||||
|
curr: 1
|
||||||
|
},
|
||||||
|
where: data.field
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部搜索重置事件
|
||||||
|
form.on("submit(table-reset)", function(data) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
where: []
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段允许为空
|
||||||
|
form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格排序事件
|
||||||
|
table.on("sort(data-table)", function(obj){
|
||||||
|
table.reload("data-table", {
|
||||||
|
initSort: obj,
|
||||||
|
scrollPos: "fixed",
|
||||||
|
where: {
|
||||||
|
field: obj.field,
|
||||||
|
order: obj.type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格新增数据
|
||||||
|
let add = function() {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "新增",
|
||||||
|
shade: 0.1,
|
||||||
|
maxmin: true,
|
||||||
|
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||||
|
content: INSERT_URL
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格编辑数据
|
||||||
|
let edit = function(obj) {
|
||||||
|
let value = obj.data[PRIMARY_KEY];
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "修改",
|
||||||
|
shade: 0.1,
|
||||||
|
maxmin: true,
|
||||||
|
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||||
|
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除一行
|
||||||
|
let remove = function(obj) {
|
||||||
|
return doRemove(obj.data[PRIMARY_KEY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除多行
|
||||||
|
let batchRemove = function(obj) {
|
||||||
|
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||||
|
if (checkIds === "") {
|
||||||
|
layui.popup.warning("未选中数据");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
doRemove(checkIds.split(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
let doRemove = function (ids) {
|
||||||
|
let data = {};
|
||||||
|
data[PRIMARY_KEY] = ids;
|
||||||
|
layer.confirm("确定删除?", {
|
||||||
|
icon: 3,
|
||||||
|
title: "提示"
|
||||||
|
}, function(index) {
|
||||||
|
layer.close(index);
|
||||||
|
let loading = layer.load();
|
||||||
|
$.ajax({
|
||||||
|
url: DELETE_API,
|
||||||
|
data: data,
|
||||||
|
dataType: "json",
|
||||||
|
type: "post",
|
||||||
|
success: function(res) {
|
||||||
|
layer.close(loading);
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", refreshTable);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新表格数据
|
||||||
|
window.refreshTable = function() {
|
||||||
|
table.reloadData("data-table", {
|
||||||
|
scrollPos: "fixed",
|
||||||
|
done: function (res, curr) {
|
||||||
|
if (curr > 1 && res.data && !res.data.length) {
|
||||||
|
curr = curr - 1;
|
||||||
|
table.reloadData("data-table", {
|
||||||
|
page: {
|
||||||
|
curr: curr
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
121
plugin/admin/app/view/background/insert.html
Normal file
121
plugin/admin/app/view/background/insert.html
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>新增页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form class="layui-form" action="">
|
||||||
|
|
||||||
|
<div class="mainBox">
|
||||||
|
<div class="main-container mr-5">
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">背景图</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<img class="img-3" src=""/>
|
||||||
|
<input type="text" style="display:none" name="url" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="url" permission="app.admin.upload.image">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-url" permission="app.admin.upload.attachment">
|
||||||
|
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bottom">
|
||||||
|
<div class="button-container">
|
||||||
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit=""
|
||||||
|
lay-filter="save">
|
||||||
|
提交
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md">
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关接口
|
||||||
|
const INSERT_API = "/app/admin/background/insert";
|
||||||
|
|
||||||
|
// 字段 背景图 url
|
||||||
|
layui.use(["upload", "layer"], function() {
|
||||||
|
let input = layui.$("#url").prev();
|
||||||
|
input.prev().attr("src", input.val());
|
||||||
|
layui.$("#attachment-choose-url").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().attr("src", data.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#url",
|
||||||
|
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||||
|
url: "/app/admin/upload/image",
|
||||||
|
field: "__file__",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
layui.use(["form", "popup"], function () {
|
||||||
|
// 字段验证允许为空
|
||||||
|
layui.form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
layui.form.on("submit(save)", function (data) {
|
||||||
|
layui.$.ajax({
|
||||||
|
url: INSERT_API,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
data: data.field,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
159
plugin/admin/app/view/background/update.html
Normal file
159
plugin/admin/app/view/background/update.html
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>更新页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form class="layui-form">
|
||||||
|
|
||||||
|
<div class="mainBox">
|
||||||
|
<div class="main-container mr-5">
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label required">背景图</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<img class="img-3" src=""/>
|
||||||
|
<input type="text" style="display:none" name="url" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="url" permission="app.admin.upload.image">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-url" permission="app.admin.upload.attachment">
|
||||||
|
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bottom">
|
||||||
|
<div class="button-container">
|
||||||
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||||
|
提交
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md">
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关接口
|
||||||
|
const PRIMARY_KEY = "id";
|
||||||
|
const SELECT_API = "/app/admin/background/select" + location.search;
|
||||||
|
const UPDATE_API = "/app/admin/background/update";
|
||||||
|
|
||||||
|
// 获取数据库记录
|
||||||
|
layui.use(["form", "util", "popup"], function () {
|
||||||
|
let $ = layui.$;
|
||||||
|
$.ajax({
|
||||||
|
url: SELECT_API,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (res) {
|
||||||
|
|
||||||
|
// 给表单初始化数据
|
||||||
|
layui.each(res.data[0], function (key, value) {
|
||||||
|
let obj = $('*[name="'+key+'"]');
|
||||||
|
if (key === "password") {
|
||||||
|
obj.attr("placeholder", "不更新密码请留空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||||
|
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||||
|
obj.val(value);
|
||||||
|
} else {
|
||||||
|
obj.attr("value", value);
|
||||||
|
obj[0].value = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 背景图 url
|
||||||
|
layui.use(["upload", "layer"], function() {
|
||||||
|
let input = layui.$("#url").prev();
|
||||||
|
input.prev().attr("src", input.val());
|
||||||
|
layui.$("#attachment-choose-url").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().attr("src", data.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#url",
|
||||||
|
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||||
|
url: "/app/admin/upload/image",
|
||||||
|
field: "__file__",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// ajax返回失败
|
||||||
|
if (res.code) {
|
||||||
|
layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
layui.use(["form", "popup"], function () {
|
||||||
|
// 字段验证允许为空
|
||||||
|
layui.form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
layui.form.on("submit(save)", function (data) {
|
||||||
|
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||||
|
layui.$.ajax({
|
||||||
|
url: UPDATE_API,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
data: data.field,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
265
plugin/admin/app/view/slideshow/index.html
Normal file
265
plugin/admin/app/view/slideshow/index.html
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>浏览页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
</head>
|
||||||
|
<body class="pear-container">
|
||||||
|
|
||||||
|
<!-- 顶部查询表单 -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 数据表格 -->
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<table id="data-table" lay-filter="data-table"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 表格顶部工具栏 -->
|
||||||
|
<script type="text/html" id="table-toolbar">
|
||||||
|
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.slideshow.insert">
|
||||||
|
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||||
|
</button>
|
||||||
|
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="app.admin.slideshow.delete">
|
||||||
|
<i class="layui-icon layui-icon-delete"></i>删除
|
||||||
|
</button>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- 表格行工具栏 -->
|
||||||
|
<script type="text/html" id="table-bar">
|
||||||
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.slideshow.update">编辑</button>
|
||||||
|
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.slideshow.delete">删除</button>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/common.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关常量
|
||||||
|
const PRIMARY_KEY = "id";
|
||||||
|
const SELECT_API = "/app/admin/slideshow/select";
|
||||||
|
const UPDATE_API = "/app/admin/slideshow/update";
|
||||||
|
const DELETE_API = "/app/admin/slideshow/delete";
|
||||||
|
const INSERT_URL = "/app/admin/slideshow/insert";
|
||||||
|
const UPDATE_URL = "/app/admin/slideshow/update";
|
||||||
|
|
||||||
|
// 表格渲染
|
||||||
|
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||||
|
let table = layui.table;
|
||||||
|
let form = layui.form;
|
||||||
|
let $ = layui.$;
|
||||||
|
let common = layui.common;
|
||||||
|
let util = layui.util;
|
||||||
|
|
||||||
|
// 表头参数
|
||||||
|
let cols = [
|
||||||
|
{
|
||||||
|
type: "checkbox",
|
||||||
|
align: "center"
|
||||||
|
},{
|
||||||
|
title: "id",align: "center",
|
||||||
|
field: "id",
|
||||||
|
},{
|
||||||
|
title: "轮播图",align: "center",
|
||||||
|
field: "img",
|
||||||
|
templet: function (d) {
|
||||||
|
return '<img src="'+encodeURI(d['img'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
title: "排序(越大越靠前)",align: "center",
|
||||||
|
field: "sort",
|
||||||
|
},{
|
||||||
|
title: "创建时间",align: "center",
|
||||||
|
field: "created_at",
|
||||||
|
},{
|
||||||
|
title: "更新时间",align: "center",
|
||||||
|
field: "updated_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
title: "删除时间",align: "center",
|
||||||
|
field: "deleted_at",
|
||||||
|
hide: true,
|
||||||
|
},{
|
||||||
|
title: "操作",
|
||||||
|
toolbar: "#table-bar",
|
||||||
|
align: "center",
|
||||||
|
fixed: "right",
|
||||||
|
width: 120,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// 渲染表格
|
||||||
|
table.render({
|
||||||
|
elem: "#data-table",
|
||||||
|
url: SELECT_API,
|
||||||
|
page: true,
|
||||||
|
cols: [cols],
|
||||||
|
skin: "line",
|
||||||
|
size: "lg",
|
||||||
|
toolbar: "#table-toolbar",
|
||||||
|
autoSort: false,
|
||||||
|
defaultToolbar: [{
|
||||||
|
title: "刷新",
|
||||||
|
layEvent: "refresh",
|
||||||
|
icon: "layui-icon-refresh",
|
||||||
|
}, "filter", "print", "exports"],
|
||||||
|
done: function () {
|
||||||
|
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 编辑或删除行事件
|
||||||
|
table.on("tool(data-table)", function(obj) {
|
||||||
|
if (obj.event === "remove") {
|
||||||
|
remove(obj);
|
||||||
|
} else if (obj.event === "edit") {
|
||||||
|
edit(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部工具栏事件
|
||||||
|
table.on("toolbar(data-table)", function(obj) {
|
||||||
|
if (obj.event === "add") {
|
||||||
|
add();
|
||||||
|
} else if (obj.event === "refresh") {
|
||||||
|
refreshTable();
|
||||||
|
} else if (obj.event === "batchRemove") {
|
||||||
|
batchRemove(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部搜索事件
|
||||||
|
form.on("submit(table-query)", function(data) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
page: {
|
||||||
|
curr: 1
|
||||||
|
},
|
||||||
|
where: data.field
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格顶部搜索重置事件
|
||||||
|
form.on("submit(table-reset)", function(data) {
|
||||||
|
table.reload("data-table", {
|
||||||
|
where: []
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段允许为空
|
||||||
|
form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格排序事件
|
||||||
|
table.on("sort(data-table)", function(obj){
|
||||||
|
table.reload("data-table", {
|
||||||
|
initSort: obj,
|
||||||
|
scrollPos: "fixed",
|
||||||
|
where: {
|
||||||
|
field: obj.field,
|
||||||
|
order: obj.type
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 表格新增数据
|
||||||
|
let add = function() {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "新增",
|
||||||
|
shade: 0.1,
|
||||||
|
maxmin: true,
|
||||||
|
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||||
|
content: INSERT_URL
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 表格编辑数据
|
||||||
|
let edit = function(obj) {
|
||||||
|
let value = obj.data[PRIMARY_KEY];
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "修改",
|
||||||
|
shade: 0.1,
|
||||||
|
maxmin: true,
|
||||||
|
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||||
|
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除一行
|
||||||
|
let remove = function(obj) {
|
||||||
|
return doRemove(obj.data[PRIMARY_KEY]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除多行
|
||||||
|
let batchRemove = function(obj) {
|
||||||
|
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||||
|
if (checkIds === "") {
|
||||||
|
layui.popup.warning("未选中数据");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
doRemove(checkIds.split(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行删除
|
||||||
|
let doRemove = function (ids) {
|
||||||
|
let data = {};
|
||||||
|
data[PRIMARY_KEY] = ids;
|
||||||
|
layer.confirm("确定删除?", {
|
||||||
|
icon: 3,
|
||||||
|
title: "提示"
|
||||||
|
}, function(index) {
|
||||||
|
layer.close(index);
|
||||||
|
let loading = layer.load();
|
||||||
|
$.ajax({
|
||||||
|
url: DELETE_API,
|
||||||
|
data: data,
|
||||||
|
dataType: "json",
|
||||||
|
type: "post",
|
||||||
|
success: function(res) {
|
||||||
|
layer.close(loading);
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", refreshTable);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新表格数据
|
||||||
|
window.refreshTable = function() {
|
||||||
|
table.reloadData("data-table", {
|
||||||
|
scrollPos: "fixed",
|
||||||
|
done: function (res, curr) {
|
||||||
|
if (curr > 1 && res.data && !res.data.length) {
|
||||||
|
curr = curr - 1;
|
||||||
|
table.reloadData("data-table", {
|
||||||
|
page: {
|
||||||
|
curr: curr
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
128
plugin/admin/app/view/slideshow/insert.html
Normal file
128
plugin/admin/app/view/slideshow/insert.html
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>新增页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form class="layui-form" action="">
|
||||||
|
|
||||||
|
<div class="mainBox">
|
||||||
|
<div class="main-container mr-5">
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">轮播图</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<img class="img-3" src=""/>
|
||||||
|
<input type="text" style="display:none" name="img" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="img" permission="app.admin.upload.image">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-img" permission="app.admin.upload.attachment">
|
||||||
|
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">排序(越大越靠前)</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="sort" value="0" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bottom">
|
||||||
|
<div class="button-container">
|
||||||
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit=""
|
||||||
|
lay-filter="save">
|
||||||
|
提交
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md">
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关接口
|
||||||
|
const INSERT_API = "/app/admin/slideshow/insert";
|
||||||
|
|
||||||
|
// 字段 轮播图 img
|
||||||
|
layui.use(["upload", "layer"], function() {
|
||||||
|
let input = layui.$("#img").prev();
|
||||||
|
input.prev().attr("src", input.val());
|
||||||
|
layui.$("#attachment-choose-img").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().attr("src", data.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#img",
|
||||||
|
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||||
|
url: "/app/admin/upload/image",
|
||||||
|
field: "__file__",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
layui.use(["form", "popup"], function () {
|
||||||
|
// 字段验证允许为空
|
||||||
|
layui.form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
layui.form.on("submit(save)", function (data) {
|
||||||
|
layui.$.ajax({
|
||||||
|
url: INSERT_API,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
data: data.field,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
166
plugin/admin/app/view/slideshow/update.html
Normal file
166
plugin/admin/app/view/slideshow/update.html
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-cn">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>更新页面</title>
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||||
|
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form class="layui-form">
|
||||||
|
|
||||||
|
<div class="mainBox">
|
||||||
|
<div class="main-container mr-5">
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">轮播图</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<img class="img-3" src=""/>
|
||||||
|
<input type="text" style="display:none" name="img" value="" />
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="img" permission="app.admin.upload.image">
|
||||||
|
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||||
|
</button>
|
||||||
|
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-img" permission="app.admin.upload.attachment">
|
||||||
|
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">排序(越大越靠前)</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="number" name="sort" value="" class="layui-input">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bottom">
|
||||||
|
<div class="button-container">
|
||||||
|
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||||
|
提交
|
||||||
|
</button>
|
||||||
|
<button type="reset" class="pear-btn pear-btn-md">
|
||||||
|
重置
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||||
|
<script src="/app/admin/component/pear/pear.js"></script>
|
||||||
|
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||||
|
<script src="/app/admin/admin/js/permission.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
// 相关接口
|
||||||
|
const PRIMARY_KEY = "id";
|
||||||
|
const SELECT_API = "/app/admin/slideshow/select" + location.search;
|
||||||
|
const UPDATE_API = "/app/admin/slideshow/update";
|
||||||
|
|
||||||
|
// 获取数据库记录
|
||||||
|
layui.use(["form", "util", "popup"], function () {
|
||||||
|
let $ = layui.$;
|
||||||
|
$.ajax({
|
||||||
|
url: SELECT_API,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (res) {
|
||||||
|
|
||||||
|
// 给表单初始化数据
|
||||||
|
layui.each(res.data[0], function (key, value) {
|
||||||
|
let obj = $('*[name="'+key+'"]');
|
||||||
|
if (key === "password") {
|
||||||
|
obj.attr("placeholder", "不更新密码请留空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||||
|
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||||
|
obj.val(value);
|
||||||
|
} else {
|
||||||
|
obj.attr("value", value);
|
||||||
|
obj[0].value = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 字段 轮播图 img
|
||||||
|
layui.use(["upload", "layer"], function() {
|
||||||
|
let input = layui.$("#img").prev();
|
||||||
|
input.prev().attr("src", input.val());
|
||||||
|
layui.$("#attachment-choose-img").on("click", function() {
|
||||||
|
parent.layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: "选择附件",
|
||||||
|
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||||
|
area: ["95%", "90%"],
|
||||||
|
success: function (layero, index) {
|
||||||
|
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||||
|
input.val(data.url).prev().attr("src", data.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
layui.upload.render({
|
||||||
|
elem: "#img",
|
||||||
|
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||||
|
url: "/app/admin/upload/image",
|
||||||
|
field: "__file__",
|
||||||
|
done: function (res) {
|
||||||
|
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||||
|
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// ajax返回失败
|
||||||
|
if (res.code) {
|
||||||
|
layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//提交事件
|
||||||
|
layui.use(["form", "popup"], function () {
|
||||||
|
// 字段验证允许为空
|
||||||
|
layui.form.verify({
|
||||||
|
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||||
|
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||||
|
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||||
|
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||||
|
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||||
|
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||||
|
});
|
||||||
|
layui.form.on("submit(save)", function (data) {
|
||||||
|
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||||
|
layui.$.ajax({
|
||||||
|
url: UPDATE_API,
|
||||||
|
type: "POST",
|
||||||
|
dateType: "json",
|
||||||
|
data: data.field,
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code) {
|
||||||
|
return layui.popup.failure(res.msg);
|
||||||
|
}
|
||||||
|
return layui.popup.success("操作成功", function () {
|
||||||
|
parent.refreshTable();
|
||||||
|
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user