xz-szwhy/src/main/resources/static/route/library/intangiblelibrarydata/save-music-intangiblelibrarydata.html
LiuY f9c2aadfc1 1、替换页面文件相关接口
2、树形插件 替换
2022-08-15 16:23:02 +08:00

529 lines
26 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<base href="/xzszwhy/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>音频资料</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">封面图片<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="hidden" id="libraryDataCover" name="libraryDataCover">
<div class="layui-btn-container" id="libraryDataCoverFileBox" style="border: 1px solid #e6e6e6;"></div>
<script id="libraryDataCoverFileDownload" type="text/html">
{{# var fileName = 'libraryDataCover'; }}
{{# if(d[fileName].length > 0) { }}
{{# var files = d[fileName];}}
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
<div class="upload-image-box">
<span class="upload-image-span">
<img src="route/file/download/false/{{item.fileId}}" align="加载失败">
</span>
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="libraryDataCoverRemoveFile">
<i class="fa fa-trash-o"></i>
</a>
</div>
{{# } }}
{{# } }}
{{# if(d[fileName].length < 9) { }}
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
<a href="javascript:void(0);" lay-form-button data-explain="封面图片" data-name="libraryDataCover" lay-filter="libraryDataCoverUploadFile">
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
</a>
</div>
{{# } }}
</script>
</div>
</div>
<div class="layui-form-item layui-row ">
<div class="layui-col-lg10">
<label class="layui-form-label">资料标题<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="libraryDataTitle" name="libraryDataTitle" class="layui-input" value="" placeholder="请输入资料标题" >
</div>
</div>
<div class="layui-col-lg2">
<label class="layui-form-label">置顶</label>
<div class="layui-input-block">
<input type="checkbox" value="1" name="libraryDataTop" lay-skin="switch" lay-text="置顶|不置顶">
</div>
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg6">
<label class="layui-form-label">资料来源<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="libraryDataResource" name="libraryDataResource" class="layui-input" value="" placeholder="请输入资料来源" >
</div>
</div>
<div class="layui-col-lg6">
<label class="layui-form-label">资料作者<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="libraryDataAuthor" name="libraryDataAuthor" class="layui-input" value="" placeholder="请输入资料作者" >
</div>
</div>
</div>
<div class="layui-form-item layui-row" pane="">
<div class="layui-col-lg6">
<label class="layui-form-label">发布时间<span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="text" id="libraryDataDate" name="libraryDataDate" class="layui-input" value="" placeholder="请输入发布时间" >
</div>
</div>
<div class="layui-col-lg6">
<label class="layui-form-label">发布状态<span style="color: red">*</span></label>
<div class="layui-input-block" >
<input type="radio" name="libraryDataStatus" value="1" title="发布">
<input type="radio" name="libraryDataStatus" value="0" title="不发布">
</div>
</div>
</div>
<div class="layui-row" >
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">资料音频<button type="button" style="margin-left: 20px;" class="layui-btn layui-btn-radius layui-btn-xs" lay-form-button lay-filter="libraryDataImage1AddEvent">添加一行资料</button><span style="color: red">*</span></label>
<div class="layui-input-block">
<input type="hidden" id="libraryDataImage1" name="libraryDataImage1">
<div id="libraryDataImage1FileBox" style="border: 1px solid #e6e6e6;"></div>
<script id="libraryDataImage1FileDownload" type="text/html">
{{# for(var i = 0, iItem; iItem = d[i++];) { }}
{{# var fileId = iItem.fileId }}
<div class="layui-row" style="border: 1px solid #e6e6e6;">
<div class="layui-col-lg4">
<div class=" layui-form-item">
{{# if(iItem.fileValues.length > 0) { }}
{{# var files = iItem.fileValues; }}
{{# for(var j = 0, jItem; jItem = files[j++];) { }}
<div class="upload-audio-box" style="width: auto; height: auto; padding-left: 35px; padding-top: 35px;">
<audio src="route/file/download/false/{{jItem.fileId}}" controls="controls">您的浏览器不支持 audio 标签</audio>
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-audio" href="javascript:void(0);" lay-form-button data-id="{{jItem.fileId}}" data-name="{{fileId}}" lay-filter="libraryDataImage1RemoveFile">
<i class="fa fa-trash-o"></i>
</a>
</div>
{{# } }}
{{# } }}
{{# if(iItem.fileValues.length < 1) { }}
<div class="upload-image-box" style="width: auto; height: auto; padding-left: 55px; padding-top: 40px;">
<a href="javascript:void(0);" lay-form-button data-explain="资料音频" data-name="{{fileId}}" lay-filter="libraryDataImage1UploadFile">
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
</a>
</div>
{{# } }}
</div>
</div>
<div class="layui-col-lg6" style="padding-top: 2px">
<div class="layui-input-block" >
<textarea style="min-height: 150px;" maxlength="1000" placeholder="输入说明" class="layui-textarea data-text" data-textname="{{fileId}}" >{{iItem.fileSummary}}</textarea>
</div>
</div>
<div class="layui-col-lg1" style="padding-top: 2px">
<div class="layui-input-block">
<input style="min-height: 150px;font-size: 50px;" type="number" placeholder="排序" class="layui-input data-sort" data-sortname="{{fileId}}" value="{{iItem.fileSort}}" >
</div>
</div>
<div class="layui-col-lg1" style="padding-top: 60px; padding-left: 30px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-radius layui-btn-danger" data-name="{{fileId}}" lay-form-button lay-filter="libraryDataImage1Remove">删除本行</button>
</div>
</div>
</div>
{{# } }}
</script>
</div>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var wangEditor = window.wangEditor;
var wangEditorObj = {};
var viewerObj = {};
var libraryDataType = top.restAjax.params(window.location.href).libraryDataType;
var intangibleLibraryId = top.restAjax.params(window.location.href).intangibleLibraryId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化视频
function initVideo(fileName, data) {
for(var i = 0, item; item = data[i++];) {
var player = new ckplayer({
container: '#'+ fileName + i,
variable: 'player',
flashplayer: false,
video: {
file: 'route/file/downloadfile/true/'+ item.fileId,
type: 'video/mp4'
}
});
}
}
// 初始化封面图片集图片上传
function initLibraryDataCoverUploadFile() {
var files = $('#libraryDataCover').val();
initFileList('libraryDataCover', files, function(fileName) {
var viewer = new Viewer(document.getElementById(fileName +'FileBox'), {navbar: false});
viewerObj[fileName] = viewer;
});
form.on('button(libraryDataCoverUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'image',
title: '上传'+ explain,
width: '400px',
height: '460px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, function(fileName) {
viewerObj[fileName].update();
});
}
}
});
});
form.on('button(libraryDataCoverRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files, function(fileName) {
viewerObj[fileName].update();
});
});
}
var multiPhotos = [{
fileId: new Date().getTime(),
fileValues: [],
fileSummary: '文字说明',
fileSort: 1
}];
form.on('button(libraryDataImage1AddEvent)', function(obj) {
multiPhotos.push({
fileId: new Date().getTime(),
fileValues: [],
fileSummary: '文字说明',
fileSort: multiPhotos.length + 1
});
laytpl(document.getElementById('libraryDataImage1FileDownload').innerHTML).render(multiPhotos, function(html) {
document.getElementById('libraryDataImage1FileBox').innerHTML = html;
});
updateSummaryAndSort();
});
form.on('button(libraryDataImage1Remove)', function(obj) {
if(multiPhotos.length < 2) {
layer.msg('至少需要一条资料数据');
return;
}
var name = this.dataset.name;
console.log(name);
for(var i = 0; i < multiPhotos.length; i++) {
var item = multiPhotos[i];
if(item.fileId == name) {
multiPhotos.splice(i, 1);
laytpl(document.getElementById('libraryDataImage1FileDownload').innerHTML).render(multiPhotos, function(html) {
document.getElementById('libraryDataImage1FileBox').innerHTML = html;
});
updateSummaryAndSort();
break;
}
}
});
function initLibraryDataImageFile(name, fileValues) {
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: fileValues
}, null, function(code, data) {
// 找到FileId对应的对象
for(var i = 0, iItem; iItem = multiPhotos[i++];) {
if(iItem.fileId == name) {
iItem.fileValues = data;
}
}
laytpl(document.getElementById('libraryDataImage1FileDownload').innerHTML).render(multiPhotos, function(html) {
document.getElementById('libraryDataImage1FileBox').innerHTML = html;
});
updateSummaryAndSort();
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function getLibraryDataImageFileValues(fileId) {
var fileValues = '';
for(var i = 0, iItem; iItem = multiPhotos[i++];) {
if(iItem.fileId == fileId) {
for(var j = 0, jItem; jItem = iItem.fileValues[j++];) {
if(fileValues.length > 0) {
fileValues += ',';
}
fileValues += jItem.fileId;
}
}
}
return fileValues;
}
function updateSummaryAndSort() {
$('.data-text').on('input propertychange', function() {
var name = this.dataset.textname;
console.log(name);
console.log(this.value);
for(var i = 0; i < multiPhotos.length; i++) {
var item = multiPhotos[i];
if(item.fileId == name) {
item.fileSummary = this.value;
break;
}
}
});
$('.data-sort').on('input propertychange', function() {
var name = this.dataset.sortname;
for(var i = 0; i < multiPhotos.length; i++) {
var item = multiPhotos[i];
if(item.fileId == name) {
item.fileSort = this.value;
break;
}
}
});
}
// 初始化封面图片集图片上传
function initLibraryDataImage1UploadFile() {
var viewer = new Viewer(document.getElementById('libraryDataImage1FileBox'), {navbar: false})
viewerObj.libraryDataImage1FileBox = viewer;
laytpl(document.getElementById('libraryDataImage1FileDownload').innerHTML).render(multiPhotos, function(html) {
document.getElementById('libraryDataImage1FileBox').innerHTML = html;
})
updateSummaryAndSort();
form.on('button(libraryDataImage1UploadFile)', function(obj) {
var name = this.dataset.name;
console.log(name);
var explain = this.dataset.explain;
top.dialog.file({
type: 'audio',
title: '上传'+ explain,
width: '400px',
height: '460px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var fileValues = getLibraryDataImageFileValues(name);
for(var j = 0, file; file = uploadFileArray[j++];) {
if(fileValues.length > 0) {
fileValues += ',';
}
fileValues += file.data;
}
initLibraryDataImageFile(name, fileValues);
}
}
});
});
form.on('button(libraryDataImage1RemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var fileValues = getLibraryDataImageFileValues(name);
var files = fileValues.replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initLibraryDataImageFile(name, files);
});
}
// 初始化资料时间日期
function initLibraryDataDateDate() {
laydate.render({
elem: '#libraryDataDate',
type: 'date',
value: new Date(),
trigger: 'click'
});
}
// 初始化内容
function initData() {
top.restAjax.get(top.restAjax.path('api/intangiblelibrarydata/getcurrentuseridinfo', []), {}, null, function(code, data) {
initLibraryDataCoverUploadFile();
initLibraryDataImage1UploadFile();
initLibraryDataDateDate();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
formData.field.libraryDataType = libraryDataType;
formData.field.intangibleLibraryId = intangibleLibraryId;
var fileList = new Array();
for(var i = 0 ; i < multiPhotos.length ; i++) {
var obj = {};
if ( multiPhotos[i].fileValues.length > 0) {
var arr = multiPhotos[i].fileValues;
if(arr.length > 0) {
obj.libraryDataFileFileId = arr[0].fileId;
}else{
continue;
}
obj.libraryDataFileContent = multiPhotos[i].fileSummary;
obj.libraryDataFileOrder = multiPhotos[i].fileSort;
fileList.push(obj);
}
}
formData.field.fileList = fileList;
formData.field['libraryDataTop'] = formData.field['libraryDataTop'] == '1' ? '1' : '0';
top.restAjax.post(top.restAjax.path('api/intangiblelibrarydata/saveintangiblelibrarydata', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>