418 lines
16 KiB
HTML
418 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Document</title>
|
|
<link
|
|
href="https://cdn.bootcdn.net/ajax/libs/layui/2.8.17/css/layui.min.css"
|
|
rel="stylesheet"
|
|
/>
|
|
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
|
<style>
|
|
@font-face {
|
|
font-family: layui-icon;
|
|
src: url(/assets/fonts/iconfont.eot?v=282);
|
|
src: url(/assets/fonts/iconfont.eot?v=282#iefix) format("embedded-opentype"),
|
|
url(/assets/fonts/iconfont.woff2?v=282) format("woff2"),
|
|
url(/assets/fonts/iconfont.woff?v=282) format("woff"),
|
|
url(/assets/fonts/iconfont.ttf?v=282) format("truetype"),
|
|
url(/assets/fonts/iconfont.svg?v=282#layui-icon) format("svg");
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="tabelPage" style="padding: 30px 30px 0 30px">
|
|
<table id="table1"></table>
|
|
</div>
|
|
|
|
<script src="https://cdn.bootcdn.net/ajax/libs/layui/2.8.17/layui.js"></script>
|
|
<script type="text/html" id="game">
|
|
<a href="{{ d.url }}" target="_blank" style="color: #499AFB;">{{ d.title }}</a>
|
|
</script>
|
|
<script type="text/html" id="view">
|
|
<a
|
|
href="https://www.fpvone.cn/index/wrj/live?match_id={{ d.id }}"
|
|
target="_blank"
|
|
style="color: #499AFB;">查看大屏</a>
|
|
</script>
|
|
<script type="text/html" id="setting">
|
|
<div class="layui-clear-space">
|
|
<a class="layui-btn layui-btn-primary layui-border layui-btn-sm" lay-event="setting">设置</a>
|
|
<a class="layui-btn layui-btn-primary layui-border-blue layui-btn-sm" lay-event="addData">赛程添加</a>
|
|
</div>
|
|
</script>
|
|
<script type="text/html" id="operate">
|
|
<div class="layui-clear-space">
|
|
<a class="layui-btn layui-btn-primary layui-border-green layui-btn-sm" lay-event="update">修改</a>
|
|
<a class="layui-btn layui-btn-primary layui-border-red layui-btn-sm" lay-event="delete">删除</a>
|
|
</div>
|
|
</script>
|
|
<script>
|
|
|
|
var setting_windows = 0;
|
|
const overDate = (d) => {
|
|
const now = new Date().getTime();
|
|
const date = new Date(d).getTime();
|
|
if (date > now) {
|
|
return "进行中";
|
|
} else {
|
|
return "已结束";
|
|
}
|
|
};
|
|
const settingform = (data) => {
|
|
$.ajax({
|
|
url: "https://www.fpvone.cn/inback.php/screen/addscreen",
|
|
type: "POST",
|
|
dataType: "json",
|
|
data: data,
|
|
success: function (res) {
|
|
if (res.code != 1) {
|
|
return layer.msg(res.msg);
|
|
}
|
|
layer.close(setting_windows);
|
|
return layer.msg(res.msg);
|
|
},
|
|
});
|
|
};
|
|
// 设置弹框---------------------------------------------------------------------------------------
|
|
const settting = (match_id) => {
|
|
$.ajax({
|
|
url: `https://www.fpvone.cn/inback.php/screen/getScreen?match_id=${match_id}&type=screen`,
|
|
type: "GET",
|
|
dataType: "json",
|
|
success: function (res) {
|
|
// console.log(res)
|
|
setting_windows = layer.open({
|
|
type: 1,
|
|
shade: false,
|
|
title: "设置",
|
|
area: ["600px", "350px"], // 宽高
|
|
content: `
|
|
<div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px 30px 0 20px;">
|
|
<form class="layui-form">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="width: 120px">是否设置密码</label>
|
|
<div class="layui-input-block" style="margin-left: 130px">
|
|
<input type="radio" name="nopass" value="true" title="是" checked lay-filter="radio-filter-pass">
|
|
<input type="radio" name="nopass" value="false" title="否" lay-filter="radio-filter-pass">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item" id="form_pass">
|
|
<label class="layui-form-label" style="width: 120px">大屏查看密码</label>
|
|
<div class="layui-input-block" style="margin-left: 130px">
|
|
<input type="password" name="password" placeholder="请输入大屏查看密码" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="width: 120px">赛事大屏标题</label>
|
|
<div class="layui-input-block" style="margin-left: 130px">
|
|
<input type="text" id="screen_title" name="title" placeholder="请输入赛事大屏标题" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="layui-input-block" style="margin-left: 220px; margin-top: 30px;">
|
|
<button style="width: 120px;" type="submit" class="layui-btn" lay-submit lay-filter="submit1">提交</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
`,
|
|
success: function () {
|
|
$('#screen_title').val(res.data.title)
|
|
layui.use(function () {
|
|
var form = layui.form;
|
|
var layer = layui.layer;
|
|
form.on('radio(radio-filter-pass)', function(data){
|
|
var elem = data.elem;
|
|
var value = elem.value;
|
|
if(value == 'true') {
|
|
$('#form_pass').show()
|
|
} else {
|
|
$('#form_pass').hide()
|
|
}
|
|
});
|
|
form.on("submit(submit1)", function (data) {
|
|
var field = data.field;
|
|
field.match_id = match_id;
|
|
field.type = 'screen'
|
|
settingform(field);
|
|
return false;
|
|
});
|
|
form.render();
|
|
});
|
|
},
|
|
});
|
|
},
|
|
});
|
|
};
|
|
|
|
layui.use(function () {
|
|
var table = layui.table;
|
|
var $ = layui.$;
|
|
var layer = layui.layer;
|
|
var util = layui.util;
|
|
// 渲染,并获得实例对象
|
|
table.render({
|
|
elem: "#table1", // 绑定元素选择器
|
|
cols: [
|
|
[
|
|
{ field: "id", title: "排序", type: "numbers" },
|
|
{ field: "state", title: "状态", width: 80 },
|
|
{ field: "title", title: "赛事名称", templet: "#game" },
|
|
{
|
|
field: "setting",
|
|
title: "设置",
|
|
toolbar: "#setting",
|
|
width: 180,
|
|
},
|
|
{ field: "view", title: "查看", templet: "#view", width: 100 },
|
|
],
|
|
],
|
|
data: [
|
|
{
|
|
state: "进行中",
|
|
name: "2023年中国无人机竞速公开赛 (象山影视城站)",
|
|
},
|
|
],
|
|
page: true,
|
|
lineStyle: "height: 50px;",
|
|
url: "https://www.fpvone.cn/inback.php/cms/archives/content/model_id/2",
|
|
method: "get",
|
|
where: { sort: "id", order: "desc", filter: {} },
|
|
request: {
|
|
pageName: "offset",
|
|
limitName: "nums",
|
|
},
|
|
parseData: function (res) {
|
|
const list = res.rows;
|
|
list.map((item) => {
|
|
item.state = overDate(`${item.etime} ${item.match_end_time}`);
|
|
});
|
|
return {
|
|
code: 0,
|
|
count: res.total,
|
|
data: list,
|
|
};
|
|
console.log(res);
|
|
},
|
|
});
|
|
// 表格事件------------------------------------------------------------------------------------------
|
|
table.on("tool(table1)", function (obj) {
|
|
var id = obj.config.id;
|
|
var checkStatus = table.checkStatus(id);
|
|
var othis = lay(this);
|
|
console.log('obj', obj)
|
|
switch (obj.event) {
|
|
// 设置-------------------------------------------------------------------------------------------
|
|
case "setting":
|
|
// var getData = table.getData(id);
|
|
settting(obj.data.aid);
|
|
break;
|
|
case "addData":
|
|
addData(obj.data.aid)
|
|
}
|
|
});
|
|
|
|
//
|
|
});
|
|
const addData = (id) => {
|
|
let window = 0
|
|
const reloadTable = () => {
|
|
layui.use(async function() {
|
|
var table = layui.table
|
|
table.reload('table11')
|
|
})
|
|
}
|
|
const addData_form = (type, datas) => {
|
|
window = layer.open({
|
|
type: 1,
|
|
shade: false,
|
|
title: type == 1 ? '添加数据' : '修改数据',
|
|
area: ["500px", "380px"],
|
|
zIndex: 101,
|
|
content: `
|
|
<div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px 30px 0 20px;">
|
|
<form class="layui-form">
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="width: 100px">日期</label>
|
|
<div class="layui-input-block" style="margin-left: 110px">
|
|
<input type="text" id="form_date" name="date" class="layui-input" lay-verify="required" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="width: 100px">标题</label>
|
|
<div class="layui-input-block" style="margin-left: 110px">
|
|
<input id="form_title" type="text" name="title" class="layui-input" lay-verify="required" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="width: 100px">内容</label>
|
|
<div class="layui-input-block" style="margin-left: 110px">
|
|
<input id="form_content" type="text" name="content" class="layui-input" lay-verify="required" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<label class="layui-form-label" style="width: 100px">排列顺序</label>
|
|
<div class="layui-input-block" style="margin-left: 110px">
|
|
<input id="form_weigh" type="text" maxlength="4" name="weigh" class="layui-input" autocomplete="off">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item">
|
|
<div class="layui-input-block" style="margin-left: 170px; margin-top: 30px;">
|
|
<button style="width: 120px;" type="submit" class="layui-btn" lay-submit lay-filter="submit11">提交</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
`,
|
|
success: function() {
|
|
layui.use(function () {
|
|
var form = layui.form;
|
|
var layer = layui.layer;
|
|
var laydate = layui.laydate;
|
|
laydate.render({
|
|
elem: '#form_date'
|
|
});
|
|
form.on("submit(submit11)", function (data) {
|
|
var field = data.field;
|
|
field.match_id = id
|
|
if(type == 2) {
|
|
field.id = datas.i
|
|
}
|
|
$.ajax({
|
|
url: type == 1 ? "https://www.fpvone.cn/inback.php/schedule/add" : "https://www.fpvone.cn/inback.php/schedule/editSchedule",
|
|
type: "POST",
|
|
dataType: "json",
|
|
data: field,
|
|
success: function (res) {
|
|
if (res.code != 1) {
|
|
return layer.msg(res.msg);
|
|
}
|
|
layer.close(window);
|
|
reloadTable()
|
|
return layer.msg(res.msg);
|
|
},
|
|
});
|
|
return false;
|
|
});
|
|
form.render();
|
|
if(type == 2) {
|
|
$('#form_date').val(datas.date)
|
|
$('#form_title').val(datas.title)
|
|
$('#form_content').val(datas.content)
|
|
$('#form_weigh').val(datas.weigh)
|
|
}
|
|
});
|
|
}
|
|
})
|
|
}
|
|
layer.open({
|
|
type: 1,
|
|
title: '添加数据',
|
|
shadeClose: true,
|
|
maxmin: true,
|
|
area: ['1000px', '800px'],
|
|
zIndex: 100,
|
|
content: `
|
|
<div style="padding: 25px">
|
|
<div class="btnList" style="margin-bottom: 20px;">
|
|
<div class="left layui-clear-space">
|
|
<a class="layui-btn layui-btn-primary layui-bg-blue" id="addDataBtn">添加数据</a>
|
|
</div>
|
|
</div>
|
|
<table id="table11" lay-filter="table11"></table>
|
|
</div>
|
|
`,
|
|
success: function() {
|
|
layui.use(function () {
|
|
var table = layui.table;
|
|
var $ = layui.$;
|
|
var layer = layui.layer;
|
|
var util = layui.util;
|
|
table.render({
|
|
elem: "#table11",
|
|
id: 'table11',
|
|
cols: [
|
|
[
|
|
{ field: "date", title: "日期" },
|
|
{ field: "title", title: "标题" },
|
|
{ field: "content", title: "内容" },
|
|
{ field: "weigh", title: "排列顺序", width: 90 },
|
|
{
|
|
field: "operate",
|
|
title: "操作",
|
|
toolbar: "#operate",
|
|
width: 180,
|
|
},
|
|
],
|
|
],
|
|
data: [
|
|
],
|
|
lineStyle: "height: 50px;",
|
|
url: "https://www.fpvone.cn/inback.php/schedule/getSchedule?match_id="+id,
|
|
method: "get",
|
|
parseData: function (res) {
|
|
const list = []
|
|
res.data.map(item => {
|
|
list.push({
|
|
content: item.content,
|
|
i: item.id,
|
|
match_id: item.match_id,
|
|
date: item.schedule_date,
|
|
title: item.title,
|
|
weigh: item.weigh,
|
|
})
|
|
})
|
|
return {
|
|
code: 0,
|
|
count: list.length,
|
|
data: list,
|
|
};
|
|
},
|
|
});
|
|
// 表格事件------------------------------------------------------------------------------------------
|
|
table.on("tool(table11)", function (obj) {
|
|
var id = obj.config.id;
|
|
var checkStatus = table.checkStatus(id);
|
|
var othis = lay(this);
|
|
switch (obj.event) {
|
|
case "update":
|
|
addData_form(2, obj.data)
|
|
break;
|
|
case "delete":
|
|
layui.use(function() {
|
|
var layer = layui.layer;
|
|
layer.confirm('是否删除此条数据?', {icon: 3}, function(){
|
|
$.ajax({
|
|
url: "https://www.fpvone.cn/inback.php/schedule/delete",
|
|
type: "POST",
|
|
dataType: "json",
|
|
data: {id: obj.data.i},
|
|
success: function (res) {
|
|
if (res.code != 1) {
|
|
return layer.msg('删除失败');
|
|
}
|
|
reloadTable('table11')
|
|
return layer.msg('删除成功');
|
|
},
|
|
});
|
|
}, function(){
|
|
// layer.msg('点击取消的回调');
|
|
});
|
|
})
|
|
break;
|
|
}
|
|
});
|
|
$('#addDataBtn').click(function() {
|
|
addData_form(1)
|
|
})
|
|
|
|
});
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|