<style>
|
#newsInfo-update {
|
padding: 20px 25px 25px 0;
|
}
|
|
#newsInfo-update .layui-treeSelect .ztree li a, .ztree li span {
|
margin: 0 0 2px 3px !important;
|
}
|
|
#newsInfo-update #data-permission-tree-block {
|
border: 1px solid #eee;
|
border-radius: 2px;
|
padding: 3px 0;
|
}
|
|
#newsInfo-update .layui-treeSelect .ztree li span.button.switch {
|
top: 1px;
|
left: 3px;
|
}
|
|
#newsInfo-update img {
|
max-width: 100px
|
}
|
|
</style>
|
<div className="layui-fluid" id="newsInfo-update">
|
<form className="layui-form" action="" lay-filter="newsInfo-update-form">
|
<div class="layui-form-item febs-hide">
|
<label class="layui-form-label febs-form-item-require">id:</label>
|
<div class="layui-input-block">
|
<input type="text" name="id" data-th-value="${newsInfo.id}">
|
</div>
|
</div>
|
<div className="layui-form-item">
|
<label className="layui-form-label febs-form-item-require">标题:</label>
|
<div className="layui-input-block">
|
<input type="text" name="title" autoComplete="off" className="layui-input">
|
</div>
|
</div>
|
<div className="layui-form-item">
|
<label className="layui-form-label febs-form-item-require">分类:</label>
|
<div className="layui-input-block">
|
<select name="categoryId" className="news-category" id="news-category">
|
<option value="">请选择</option>
|
</select>
|
</div>
|
</div>
|
|
<div className="layui-form-item">
|
<label className="layui-form-label">视频:</label>
|
<div className="layui-input-block">
|
<button type="button" className="layui-btn upload" id="upload"
|
style="background-color: #009688; margin-bottom: 2px">上传文件
|
</button>
|
<input type="text" name="videoUrl" autoComplete="off" value="" id="videoUrl" className="layui-input"
|
readOnly>
|
</div>
|
</div>
|
|
<div className="layui-form-item">
|
<label className="layui-form-label">缩略图:</label>
|
<div className="layui-input-block">
|
<button type="button" className="layui-btn" id="imageUpload"
|
style="background-color: #009688; margin-bottom: 2px">图片上传
|
</button>
|
<blockquote className="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
|
<div className=" layui-upload-list view-images" id="thumbImage">
|
</div>
|
</blockquote>
|
<div className="febs-hide">
|
<input type="text" id="thumb" name="thumb" autoComplete="off" className="layui-input" readOnly>
|
</div>
|
</div>
|
</div>
|
|
<div className="layui-form-item">
|
<label className="layui-form-label febs-form-item-require">内容:</label>
|
<div className="layui-input-block">
|
<textarea id="lay_edit" name="content" lay-verify="content" className="layui-textarea"></textarea>
|
</div>
|
</div>
|
<div className="layui-form-item febs-hide">
|
<button className="layui-btn" lay-submit="" lay-filter="newsInfo-update-form-submit" id="submit"></button>
|
</div>
|
</form>
|
</div>
|
|
<script data-th-inline="javascript">
|
layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'layedit', 'laydate', 'upload'], function () {
|
var $ = layui.$,
|
febs = layui.febs,
|
layer = layui.layer,
|
upload = layui.upload,
|
formSelects = layui.formSelects,
|
form = layui.form,
|
laydate = layui.laydate,
|
layedit = layui.layedit,
|
newsInfo = [[${newsInfo}]],
|
$view = $('#newsInfo-update'),
|
validate = layui.validate;
|
|
//(下拉框)
|
$.get(ctx + 'admin/news/findAllCategoryList', function (data) {
|
var arr = data.data;
|
for (let i = 0; i < arr.length; i++) {
|
$(".news-category").append("<option value='" + arr[i].id + "'>" + arr[i].title + "</option>");
|
}
|
layui.use('form', function () {
|
var form = layui.form;
|
form.render();
|
});
|
});
|
|
form.render();
|
laydate.render({
|
elem: '#febs-form-group-date'
|
});
|
|
layedit.set({ //设置图片接口
|
uploadImage: {
|
url: 'admin/goods/uploadFileBase64', //接口url
|
type: 'post',
|
}
|
});
|
//创建一个编辑器
|
var index = layedit.build('lay_edit', {
|
height: 300
|
});
|
form.verify({
|
//content富文本域中的lay-verify值
|
content: function (value) {
|
return layedit.sync(index);
|
}
|
});
|
|
formSelects.render();
|
form.on('submit(newsInfo-update-form-submit)', function (data) {
|
febs.post(ctx + 'admin/news/updateNewsInfo', data.field, function () {
|
layer.closeAll();
|
febs.alert.success('操作成功');
|
$('#febs-newInfo').find('#reset').click();
|
});
|
return false;
|
});
|
|
upload.render({
|
elem: '#imageUpload'
|
, url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
|
, multiple: false
|
, before: function (obj) {
|
//预读本地文件示例,不支持ie8
|
obj.preview(function (index, file, result) {
|
$('#thumbImage').html('<img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" style="width: 100px">')
|
});
|
}
|
, done: function (res) {
|
$("#thumb").val(res.data.src);
|
}
|
});
|
|
|
bindUpload();
|
|
function bindUpload() {
|
upload.render({
|
elem: '.upload'
|
, url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
|
, accept: 'file'
|
, before: function (obj) {
|
layer.msg('上传中', {icon: 16, time: 0});
|
}
|
, done: function (res) {
|
var item = this.item;
|
//如果上传失败
|
if (res.code !== 0) {
|
return layer.msg('上传失败');
|
}
|
|
// $(item).parent().prev().find('input').val(res.data[0]);
|
$("#videoUrl").val(res.data.src);
|
layer.msg('上传完毕', {icon: 1});
|
}
|
, error: function (err) {
|
return layer.msg('上传失败');
|
}
|
});
|
}
|
|
initUserValue();
|
function initUserValue() {
|
var thumb = newsInfo.thumb;
|
$('#thumbImage').html('<img src="' + thumb + '" alt="" class="layui-upload-img" style="width: 100px">')
|
form.val("newsInfo-update-form", {
|
"id": newsInfo.id,
|
"categoryId": newsInfo.categoryId,
|
"title": newsInfo.title,
|
"videoUrl": newsInfo.videoUrl,
|
"thumb": newsInfo.thumb,
|
"content": newsInfo.content,
|
});
|
}
|
});
|
</script>
|