update
This commit is contained in:
173
storage/view/news/import.blade.php
Normal file
173
storage/view/news/import.blade.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
$platforms = call_user_func(function () {
|
||||
return \App\Model\AppWebsiteConfig::query()->where('is_delete', 0)->get()->toArray();
|
||||
});
|
||||
|
||||
$columnTag = call_user_func(function () {
|
||||
return \App\Model\AppNewsColumn::query()->get()->toArray();
|
||||
});
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>导入</title>
|
||||
<link rel="stylesheet" href="/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/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">
|
||||
<select name="platform" lay-search="">
|
||||
<option value="">请选择</option>
|
||||
<?php foreach ($platforms ?: [] as $platform): ?>
|
||||
<option value="<?= $platform['id'] ?>"><?= $platform['app_name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">栏目</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="column" lay-search="">
|
||||
<option value="">请选择</option>
|
||||
<?php foreach ($columnTag ?: [] as $tag): ?>
|
||||
<option value="<?= $tag['id'] ?>"><?= $tag['name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">json数据</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="submit">
|
||||
提交
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/component/pear/pear.js"></script>
|
||||
<script>
|
||||
// api
|
||||
const SAVE_API = "/admin/api/news/import"; // 插入新闻
|
||||
const UPLOAD_API = '/upload/image' // 上传图片
|
||||
|
||||
layui.use(['upload', 'jquery', 'popup'], function(){
|
||||
const upload = layui.upload;
|
||||
const $ = layui.jquery;
|
||||
layui.form.on("submit(submit)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: SAVE_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>
|
||||
<style>
|
||||
#editor—wrapper {
|
||||
border: 1px solid #ccc;
|
||||
z-index: 100; /* 按需定义 */
|
||||
}
|
||||
#toolbar-container {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
#editor-container {
|
||||
height: 500px;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.res-options {
|
||||
padding: 0 10px;
|
||||
line-height: 36px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.layui-upload-list {
|
||||
margin-top: 20px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, 120px);
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.img-item {
|
||||
position: relative;
|
||||
border: 1px solid #e6e6e6;
|
||||
border-radius: 4px;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.img-preview {
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.img-operate {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
opacity: 0;
|
||||
transition: .3s;
|
||||
}
|
||||
|
||||
.img-item:hover .img-operate {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#images-tpl-container .layui-icon-close,
|
||||
#images-tpl-container .layui-icon-util {
|
||||
color: #fff;
|
||||
background: #ff5722;
|
||||
border-radius: 50%;
|
||||
padding: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-upload-list {
|
||||
/* 保持原有样式 */
|
||||
margin-top: 20px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, 120px);
|
||||
gap: 15px;
|
||||
}
|
||||
/* 新增显示限制 */
|
||||
.img-item:nth-child(n+31) {
|
||||
display: none;
|
||||
}
|
||||
.load-more-btn {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
padding: 10px 0;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
@ -63,9 +63,9 @@
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
</button>
|
||||
{{-- <button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">--}}
|
||||
{{-- <i class="layui-icon layui-icon-delete"></i>删除--}}
|
||||
{{-- </button>--}}
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="import">
|
||||
<i class="layui-icon layui-icon-file"></i>导入
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<!-- 表格行工具栏 -->
|
||||
@ -97,6 +97,7 @@
|
||||
const VIEW_API = "/admin/news/view";
|
||||
const INSERT_API = "/admin/api/news/insert";
|
||||
const INSERT_URL = "/admin/news/insert";
|
||||
const IMPORT_URL = "/admin/news/import";
|
||||
const DELETE_API = "/admin/api/news/delete";
|
||||
|
||||
// 字段 创建时间 created_at
|
||||
@ -191,8 +192,8 @@
|
||||
add();
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
} else if (obj.event === "import") {
|
||||
importNews(obj);
|
||||
}
|
||||
});
|
||||
|
||||
@ -237,6 +238,17 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 导入数据
|
||||
let importNews = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "导入",
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? "100%" : "98%", common.isModile() ? "100%" : "95%"],
|
||||
content: IMPORT_URL
|
||||
});
|
||||
}
|
||||
|
||||
// 表格编辑数据
|
||||
let edit = function (obj) {
|
||||
let value = obj.data['id'];
|
||||
|
Reference in New Issue
Block a user