文件调整
This commit is contained in:
parent
f839e865bd
commit
85e1feb420
|
@ -230,58 +230,42 @@
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
if (row.status === '1'){
|
if (row.status === '1'){
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if (row.status === '2'){
|
}else if (row.status === '2'){
|
||||||
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
||||||
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if(row.status === '3'){
|
}else if(row.status === '3'){
|
||||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>重新上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>重新上传附件</a> ');
|
||||||
}else if (row.status === '4'){
|
}else if (row.status === '4'){
|
||||||
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
||||||
}
|
}
|
||||||
if (row.files && row.status !=='3'){
|
|
||||||
actions.push('<a data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>查看附件</a> ');
|
|
||||||
}
|
|
||||||
// actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
|
|
||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
$.table.init(options);
|
$.table.init(options);
|
||||||
$("#bootstrap-table").on('click',".openUpload",function () {
|
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
||||||
let _id = $(this)[0].dataset.id;
|
let _id = $(this)[0].dataset.id;
|
||||||
let header = $(this)[0].dataset.header;
|
let header = $(this)[0].dataset.header;
|
||||||
let deptName = $(this)[0].dataset.deptname;
|
let deptName = $(this)[0].dataset.deptname;
|
||||||
let shotName = $(this)[0].dataset.shotname;
|
let shotName = $(this)[0].dataset.shotname;
|
||||||
layer.open({
|
|
||||||
title:'上传附件',
|
|
||||||
area:['80%','80%'],
|
|
||||||
type:2,
|
|
||||||
content:'/base/affairs/upload',
|
|
||||||
success(res,index){
|
|
||||||
//传值
|
|
||||||
parent.a_upload_id = _id;
|
|
||||||
parent.a_header = header;
|
|
||||||
parent.a_deptName = deptName;
|
|
||||||
parent.a_shotName = shotName;
|
|
||||||
parent.a_upload_index = index;
|
|
||||||
parent.a_upload_type = "1";
|
|
||||||
},
|
|
||||||
end(){
|
|
||||||
$.table.search()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
|
||||||
let _files = $(this)[0].dataset.files;
|
let _files = $(this)[0].dataset.files;
|
||||||
layer.open({
|
layer.open({
|
||||||
title:'查看附件',
|
title:'上传附件',
|
||||||
area:['80%','90%'],
|
area:['80%','90%'],
|
||||||
type:2,
|
type:2,
|
||||||
content:'/base/affairs/viewFiles',
|
content:'/base/affairs/viewFiles',
|
||||||
success(res,index){
|
success(res,index){
|
||||||
|
parent.a_upload_obj = {
|
||||||
|
id:_id,
|
||||||
|
header:header,
|
||||||
|
deptName:deptName,
|
||||||
|
shotName:shotName,
|
||||||
|
files:_files,
|
||||||
|
url:'/base/affairs/commit'
|
||||||
|
}
|
||||||
parent.a_upload_index = index;
|
parent.a_upload_index = index;
|
||||||
parent.a_upload_files = _files;
|
|
||||||
},
|
},
|
||||||
end(){
|
end(){
|
||||||
$.table.search()
|
$.table.search()
|
||||||
|
|
|
@ -255,52 +255,42 @@
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
if (row.status === '1'){
|
if (row.status === '1'){
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if (row.status === '2'){
|
}else if (row.status === '2'){
|
||||||
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
||||||
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if(row.status === '3'){
|
}else if(row.status === '3'){
|
||||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>重新上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>重新上传附件</a> ');
|
||||||
}else if (row.status === '4'){
|
}else if (row.status === '4'){
|
||||||
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
||||||
}
|
}
|
||||||
if (row.files && row.status !=='3'){
|
|
||||||
actions.push('<a data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>查看附件</a> ');
|
|
||||||
}
|
|
||||||
// actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
|
|
||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
$.table.init(options);
|
$.table.init(options);
|
||||||
$("#bootstrap-table").on('click','.openUpload',function () {
|
|
||||||
let _id = $(this)[0].dataset.id;
|
|
||||||
layer.open({
|
|
||||||
title:'上传附件',
|
|
||||||
area:['80%','80%'],
|
|
||||||
type:2,
|
|
||||||
content:'/base/affairs/upload',
|
|
||||||
success(res,index){
|
|
||||||
//传值
|
|
||||||
parent.a_upload_id = _id;
|
|
||||||
parent.a_upload_index = index;
|
|
||||||
parent.a_upload_type = "1";
|
|
||||||
},
|
|
||||||
end(){
|
|
||||||
$.table.search()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
||||||
|
let _id = $(this)[0].dataset.id;
|
||||||
|
let header = $(this)[0].dataset.header;
|
||||||
|
let deptName = $(this)[0].dataset.deptname;
|
||||||
|
let shotName = $(this)[0].dataset.shotname;
|
||||||
let _files = $(this)[0].dataset.files;
|
let _files = $(this)[0].dataset.files;
|
||||||
layer.open({
|
layer.open({
|
||||||
title:'查看附件',
|
title:'上传附件',
|
||||||
area:['80%','90%'],
|
area:['80%','90%'],
|
||||||
type:2,
|
type:2,
|
||||||
content:'/base/affairs/viewFiles',
|
content:'/base/affairs/viewFiles',
|
||||||
success(res,index){
|
success(res,index){
|
||||||
|
parent.a_upload_obj = {
|
||||||
|
id:_id,
|
||||||
|
header:header,
|
||||||
|
deptName:deptName,
|
||||||
|
shotName:shotName,
|
||||||
|
files:_files,
|
||||||
|
url:'/base/affairs/commit'
|
||||||
|
}
|
||||||
parent.a_upload_index = index;
|
parent.a_upload_index = index;
|
||||||
parent.a_upload_files = _files;
|
|
||||||
},
|
},
|
||||||
end(){
|
end(){
|
||||||
$.table.search()
|
$.table.search()
|
||||||
|
|
|
@ -224,52 +224,42 @@
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
if (row.status === '1'){
|
if (row.status === '1'){
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if (row.status === '2'){
|
}else if (row.status === '2'){
|
||||||
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
||||||
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if(row.status === '3'){
|
}else if(row.status === '3'){
|
||||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>重新上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>重新上传附件</a> ');
|
||||||
}else if (row.status === '4'){
|
}else if (row.status === '4'){
|
||||||
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
||||||
}
|
}
|
||||||
if (row.files && row.status !=='3'){
|
|
||||||
actions.push('<a data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>查看附件</a> ');
|
|
||||||
}
|
|
||||||
// actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
|
|
||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
$.table.init(options);
|
$.table.init(options);
|
||||||
$("#bootstrap-table").on('click','.openUpload',function () {
|
|
||||||
let _id = $(this)[0].dataset.id;
|
|
||||||
layer.open({
|
|
||||||
title:'上传附件',
|
|
||||||
area:['80%','80%'],
|
|
||||||
type:2,
|
|
||||||
content:'/base/affairs/upload',
|
|
||||||
success(res,index){
|
|
||||||
//传值
|
|
||||||
parent.a_upload_id = _id;
|
|
||||||
parent.a_upload_index = index;
|
|
||||||
parent.a_upload_type = "1";
|
|
||||||
},
|
|
||||||
end(){
|
|
||||||
$.table.search()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
||||||
|
let _id = $(this)[0].dataset.id;
|
||||||
|
let header = $(this)[0].dataset.header;
|
||||||
|
let deptName = $(this)[0].dataset.deptname;
|
||||||
|
let shotName = $(this)[0].dataset.shotname;
|
||||||
let _files = $(this)[0].dataset.files;
|
let _files = $(this)[0].dataset.files;
|
||||||
layer.open({
|
layer.open({
|
||||||
title:'查看附件',
|
title:'上传附件',
|
||||||
area:['80%','90%'],
|
area:['80%','90%'],
|
||||||
type:2,
|
type:2,
|
||||||
content:'/base/affairs/viewFiles',
|
content:'/base/affairs/viewFiles',
|
||||||
success(res,index){
|
success(res,index){
|
||||||
|
parent.a_upload_obj = {
|
||||||
|
id:_id,
|
||||||
|
header:header,
|
||||||
|
deptName:deptName,
|
||||||
|
shotName:shotName,
|
||||||
|
files:_files,
|
||||||
|
url:'/base/affairs/commit'
|
||||||
|
}
|
||||||
parent.a_upload_index = index;
|
parent.a_upload_index = index;
|
||||||
parent.a_upload_files = _files;
|
|
||||||
},
|
},
|
||||||
end(){
|
end(){
|
||||||
$.table.search()
|
$.table.search()
|
||||||
|
|
|
@ -6,22 +6,15 @@
|
||||||
.pre_view{
|
.pre_view{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.pdf_pre_view{
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-color: rgba(61, 61, 61, 0.47);
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.pre_view_list{
|
.pre_view_list{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 80vh;
|
||||||
box-sizing: border-box;
|
overflow-y: auto;
|
||||||
padding: 10px;
|
margin-top: 10px;
|
||||||
border:1px solid #e3e3e3;
|
border:1px solid #e3e3e3;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -56,35 +49,86 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
.upload_input{
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.err_tips{
|
||||||
|
font-size: 14px;
|
||||||
|
color: #e32525;
|
||||||
|
}
|
||||||
|
.no_data{
|
||||||
|
margin-top: 4%;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #5d5d5d;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="pre_view">
|
<div class="pre_view">
|
||||||
|
<div class="upload_btn">
|
||||||
|
<div class="upload_input">
|
||||||
|
<input type="file" multiple="multiple" />
|
||||||
|
</div>
|
||||||
|
<span class="err_tips"></span>
|
||||||
|
</div>
|
||||||
<div class="pre_view_list"></div>
|
<div class="pre_view_list"></div>
|
||||||
|
<div style="width: 96%;margin: 10px auto 0;text-align: right">
|
||||||
|
<span class="btn btn-primary submit_files">保存</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<th:block th:include="include :: footer"/>
|
<th:block th:include="include :: footer"/>
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
let _files = parent.parent.a_upload_files.split(',');
|
//限制文件的数据格式
|
||||||
//初始化文件列表
|
let _typeArr = ['jpg','png','pdf','docx','xlsx','xls','zip','rar','7z'];
|
||||||
let _file_list_str = "";
|
//传过来的参数
|
||||||
|
let _data= parent.parent.a_upload_obj;
|
||||||
|
let _closeIndex = parent.parent.a_upload_index;
|
||||||
|
let _files;
|
||||||
|
if(_data.files === 'null' || !_data.files){
|
||||||
|
_files = [];
|
||||||
|
}else{
|
||||||
|
_files = _data.files.split(',');
|
||||||
|
}
|
||||||
|
//重新编译的新文件数组
|
||||||
|
let _newFilesArr = [];
|
||||||
_files.forEach((item,index) => {
|
_files.forEach((item,index) => {
|
||||||
let _nameFile = item.substr(item.lastIndexOf('/')+1,item.length-1);
|
_newFilesArr.push({
|
||||||
if(item.indexOf('png') > -1 || item.indexOf('jpg')>-1){
|
name:item,index:index
|
||||||
_file_list_str += '<div class="pre_view_item">' +
|
})
|
||||||
'<div class="item_left"><img src="'+window.location.origin+item+'" /><span>('+(index+1)+') '+_nameFile+'</span></div>' +
|
|
||||||
'<div class="item_right"><span data-url="'+item+'" class="btn btn-primary btn-xs down_load_file">下载</span></div></div>';
|
|
||||||
}else if(item.indexOf('pdf') > -1){
|
|
||||||
_file_list_str += '<div class="pre_view_item">' +
|
|
||||||
'<div class="item_left"><img src="/img/file_word.png" /><span>('+(index+1)+') '+_nameFile+'</span></div>' +
|
|
||||||
'<div class="item_right"><span data-url="'+item+'" class="btn btn-primary btn-xs pre_view_pdf">预览</span><span data-url="'+item+'" class="btn btn-primary btn-xs down_load_file">下载</span></div></div>';
|
|
||||||
}else{
|
|
||||||
_file_list_str += '<div class="pre_view_item">' +
|
|
||||||
'<div class="item_left"><img src="/img/file_word.png" /><span>('+(index+1)+') '+_nameFile+'</span></div>' +
|
|
||||||
'<div class="item_right"><span data-url="'+item+'" class="btn btn-primary btn-xs down_load_file">下载</span></div></div>';
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
$(".pre_view_list").append(_file_list_str);
|
|
||||||
|
//初始化文件列表
|
||||||
|
initFileList(_newFilesArr);
|
||||||
|
|
||||||
|
//选择文件后的事件
|
||||||
|
$('input[type="file"]').on('change',function(e){
|
||||||
|
let _files = e.currentTarget.files;
|
||||||
|
if(_files.length === 0){
|
||||||
|
$(".err_tips").text("请先选择文件!");
|
||||||
|
}else{
|
||||||
|
let _isFlag = false;
|
||||||
|
_files.forEach(item => {
|
||||||
|
let _lastNum = item.name.lastIndexOf('.')+1;
|
||||||
|
let _endType = item.name.substr(_lastNum,item.name.length);
|
||||||
|
if(!_typeArr.includes(_endType)){
|
||||||
|
_isFlag = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(_isFlag){
|
||||||
|
$(".err_tips").text("文件格式有误!上传文件格式以jpg、png、pdf、docx、xlsx、xls、zip、rar、7z为结尾!");
|
||||||
|
$(this).val("");
|
||||||
|
}else{
|
||||||
|
$(".err_tips").text("");
|
||||||
|
_files.forEach(item => {
|
||||||
|
uploadFileFn(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
//PDF文件进行预览查看
|
//PDF文件进行预览查看
|
||||||
$(".pre_view_list").on("click",'.pre_view_pdf',function () {
|
$(".pre_view_list").on("click",'.pre_view_pdf',function () {
|
||||||
|
@ -116,6 +160,98 @@
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//文件删除
|
||||||
|
$(".pre_view_list").on('click','.del_file',function () {
|
||||||
|
let _index = $(this).attr('data-index');
|
||||||
|
_newFilesArr.forEach((item,index) => {
|
||||||
|
if(String(item.index) === _index){
|
||||||
|
_newFilesArr.splice(index,1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
_newFilesArr.forEach((item,index) => {
|
||||||
|
item.index = index;
|
||||||
|
})
|
||||||
|
initFileList(_newFilesArr);
|
||||||
|
})
|
||||||
|
|
||||||
|
//保存文件
|
||||||
|
$(".submit_files").click(function () {
|
||||||
|
let _filsArr = [];
|
||||||
|
_newFilesArr.forEach(item => {
|
||||||
|
_filsArr.push(item.name);
|
||||||
|
})
|
||||||
|
let _submitData = {
|
||||||
|
id:_data.id,
|
||||||
|
header:_data.header,
|
||||||
|
deptName:_data.deptName,
|
||||||
|
shotName:_data.shotName,
|
||||||
|
files:_filsArr.join(',')
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url:_data.url,
|
||||||
|
type:'post',
|
||||||
|
dataType:'json',
|
||||||
|
data:_submitData,
|
||||||
|
success(res){
|
||||||
|
if(res.code === 0){
|
||||||
|
layer.msg('保存成功', {icon: 1});
|
||||||
|
setTimeout(function () {
|
||||||
|
parent.layer.close(_closeIndex);
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
//渲染文件列表的方法
|
||||||
|
function initFileList(data){
|
||||||
|
$(".pre_view_list").empty();
|
||||||
|
let _file_list_str = "";
|
||||||
|
if(data.length === 0){
|
||||||
|
_file_list_str += '<div class="no_data">暂无数据</div>'
|
||||||
|
}else{
|
||||||
|
data.forEach((item,index) => {
|
||||||
|
let _nameFile = item.name.substr(item.name.lastIndexOf('/')+1,item.name.length-1);
|
||||||
|
if(item.name.indexOf('png') > -1 || item.name.indexOf('jpg')>-1){
|
||||||
|
_file_list_str += '<div class="pre_view_item">' +
|
||||||
|
'<div class="item_left"><img src="'+window.location.origin+item.name+'" /><span>('+(index+1)+') '+_nameFile+'</span></div>' +
|
||||||
|
'<div class="item_right"><span data-url="'+item.name+'" class="btn btn-primary btn-xs down_load_file">下载</span><span data-index="'+item.index+'" class="btn btn-danger btn-xs del_file">删除</span></div></div>';
|
||||||
|
}else if(item.name.indexOf('pdf') > -1){
|
||||||
|
_file_list_str += '<div class="pre_view_item">' +
|
||||||
|
'<div class="item_left"><img src="/img/file_word.png" /><span>('+(index+1)+') '+_nameFile+'</span></div>' +
|
||||||
|
'<div class="item_right"><span data-url="'+item.name+'" class="btn btn-primary btn-xs pre_view_pdf">预览</span><span data-url="'+item.name+'" class="btn btn-primary btn-xs down_load_file">下载</span><span data-index="'+item.index+'" class="btn btn-danger btn-xs del_file">删除</span></div></div>';
|
||||||
|
}else{
|
||||||
|
_file_list_str += '<div class="pre_view_item">' +
|
||||||
|
'<div class="item_left"><img src="/img/file_word.png" /><span>('+(index+1)+') '+_nameFile+'</span></div>' +
|
||||||
|
'<div class="item_right"><span data-url="'+item.name+'" class="btn btn-primary btn-xs down_load_file">下载</span><span data-index="'+item.index+'" class="btn btn-danger btn-xs del_file">删除</span></div></div>';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$(".pre_view_list").append(_file_list_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传附件的方法
|
||||||
|
function uploadFileFn(_file){
|
||||||
|
let _formData = new FormData();
|
||||||
|
_formData.append("file",_file);
|
||||||
|
$.ajax({
|
||||||
|
url:'/common/upload',
|
||||||
|
type:'POST',
|
||||||
|
data:_formData,
|
||||||
|
processData:false,
|
||||||
|
contentType:false,
|
||||||
|
success:function (res) {
|
||||||
|
_newFilesArr.push({
|
||||||
|
name:res.fileName,index:_newFilesArr.length
|
||||||
|
})
|
||||||
|
initFileList(_newFilesArr);
|
||||||
|
},
|
||||||
|
error:function () {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -171,16 +171,12 @@
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
if (row.status === '1'){
|
if (row.status === '1'){
|
||||||
actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if (row.status === '2'){
|
}else if (row.status === '2'){
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-score="'+row.score+'" data-updatetime="'+row.updateTime+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-reviewer="'+row.reviewer+'" data-detailed="'+row.detailed+'" data-demand="'+row.demand+'" data-type="'+row.type+'" data-nowscore="'+row.nowScore+'" class="shenhe btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)">审批</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-score="'+row.score+'" data-updatetime="'+row.updateTime+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-reviewer="'+row.reviewer+'" data-detailed="'+row.detailed+'" data-demand="'+row.demand+'" data-type="'+row.type+'" data-nowscore="'+row.nowScore+'" class="shenhe btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)">审批</a> ');
|
||||||
}else if (row.status === '3'){
|
}else if (row.status === '3'){
|
||||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
||||||
actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.upload(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>重新上传附件</a> ');
|
||||||
}
|
|
||||||
if (row.files && row.status !=='3'){
|
|
||||||
actions.push('<a data-files="'+row.files+'" data-type="1" class="viewFiles0828 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>查看图片</a> ');
|
|
||||||
actions.push('<a data-files="'+row.files+'" data-type="2" class="viewFiles0828 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-download"></i>下载附件</a> ');
|
|
||||||
}
|
}
|
||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
|
@ -225,54 +221,33 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
||||||
$("#bootstrap-table").on("click",".viewFiles0828",function () {
|
let _id = $(this)[0].dataset.id;
|
||||||
let _files = $(this)[0].dataset.files.split(',');
|
let header = $(this)[0].dataset.header;
|
||||||
let _type = $(this)[0].dataset.type;
|
let deptName = $(this)[0].dataset.deptname;
|
||||||
let _dataImg = [];
|
let shotName = $(this)[0].dataset.shotname;
|
||||||
let _downData = [];
|
let _files = $(this)[0].dataset.files;
|
||||||
_files.forEach((item,index) => {
|
layer.open({
|
||||||
if(item.indexOf(".jpg")>-1 || item.indexOf(".png")>-1){
|
title:'上传附件',
|
||||||
_dataImg.push({
|
area:['80%','90%'],
|
||||||
"alt": "",
|
type:2,
|
||||||
"pid": index, //图片id
|
content:'/base/affairs/viewFiles',
|
||||||
"src": window.location.origin+item, //原图地址
|
success(res,index){
|
||||||
"thumb": window.location.origin+item //缩略图地址
|
parent.a_upload_obj = {
|
||||||
})
|
id:_id,
|
||||||
}else if(item.indexOf(".docx")> -1 || item.indexOf(".doc") > -1 || item.indexOf(".xlsx") > -1 || item.indexOf(".xls") > -1 || item.indexOf(".pdf") > -1){
|
header:header,
|
||||||
_downData.push(item);
|
deptName:deptName,
|
||||||
|
shotName:shotName,
|
||||||
|
files:_files,
|
||||||
|
url:'/base/affairs/commit'
|
||||||
|
}
|
||||||
|
parent.a_upload_index = index;
|
||||||
|
},
|
||||||
|
end(){
|
||||||
|
$.table.search()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(_type === '1'){ //查看图片
|
})
|
||||||
let json = {
|
|
||||||
"title": "查看图片", //相册标题
|
|
||||||
"id": 123, //相册id
|
|
||||||
"start": 0, //初始显示的图片序号,默认0
|
|
||||||
"data": _dataImg
|
|
||||||
};
|
|
||||||
layer.photos({
|
|
||||||
photos: json,
|
|
||||||
closeBtn: 0, //右上角按钮,可通过配置1和2来展示,如果不显示,则closeBtn: 0
|
|
||||||
anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
|
|
||||||
});
|
|
||||||
}else{ //下载附件
|
|
||||||
if(_downData.length === 0){
|
|
||||||
$.modal.msgError('暂无文件!')
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_downData.forEach(item => {
|
|
||||||
let _lastNum = item.lastIndexOf('/')+1;
|
|
||||||
let _title = item.substr(_lastNum,item.length-1);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.style.display = 'none';
|
|
||||||
a.download = _title;
|
|
||||||
a.href = window.location.origin+item;
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -249,52 +249,42 @@
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
var actions = [];
|
var actions = [];
|
||||||
if (row.status === '1'){
|
if (row.status === '1'){
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if (row.status === '2'){
|
}else if (row.status === '2'){
|
||||||
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)">待审核</a> ');
|
||||||
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>上传附件</a> ');
|
||||||
}else if(row.status === '3'){
|
}else if(row.status === '3'){
|
||||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)">已驳回</a> ');
|
||||||
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" class="openUpload btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-upload"></i>重新上传附件</a> ');
|
actions.push('<a data-id="'+row.id+'" data-header="'+row.header+'" data-shotname="'+row.shotName+'" data-deptname="'+row.deptName+'" data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>重新上传附件</a> ');
|
||||||
}else if (row.status === '4'){
|
}else if (row.status === '4'){
|
||||||
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)">已完成</a> ');
|
||||||
}
|
}
|
||||||
if (row.files && row.status !=='3'){
|
|
||||||
actions.push('<a data-files="'+row.files+'" class="viewFiles912 btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-picture-o"></i>查看附件</a> ');
|
|
||||||
}
|
|
||||||
// actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
|
|
||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
$.table.init(options);
|
$.table.init(options);
|
||||||
$("#bootstrap-table").on('click','.openUpload',function () {
|
|
||||||
let _id = $(this)[0].dataset.id;
|
|
||||||
layer.open({
|
|
||||||
title:'上传附件',
|
|
||||||
area:['80%','80%'],
|
|
||||||
type:2,
|
|
||||||
content:'/base/affairs/upload',
|
|
||||||
success(res,index){
|
|
||||||
//传值
|
|
||||||
parent.a_upload_id = _id;
|
|
||||||
parent.a_upload_index = index;
|
|
||||||
parent.a_upload_type = "1";
|
|
||||||
},
|
|
||||||
end(){
|
|
||||||
$.table.search()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
$("#bootstrap-table").on("click",".viewFiles912",function () {
|
||||||
|
let _id = $(this)[0].dataset.id;
|
||||||
|
let header = $(this)[0].dataset.header;
|
||||||
|
let deptName = $(this)[0].dataset.deptname;
|
||||||
|
let shotName = $(this)[0].dataset.shotname;
|
||||||
let _files = $(this)[0].dataset.files;
|
let _files = $(this)[0].dataset.files;
|
||||||
layer.open({
|
layer.open({
|
||||||
title:'查看附件',
|
title:'上传附件',
|
||||||
area:['80%','90%'],
|
area:['80%','90%'],
|
||||||
type:2,
|
type:2,
|
||||||
content:'/base/affairs/viewFiles',
|
content:'/base/affairs/viewFiles',
|
||||||
success(res,index){
|
success(res,index){
|
||||||
|
parent.a_upload_obj = {
|
||||||
|
id:_id,
|
||||||
|
header:header,
|
||||||
|
deptName:deptName,
|
||||||
|
shotName:shotName,
|
||||||
|
files:_files,
|
||||||
|
url:'/base/affairs/commit'
|
||||||
|
}
|
||||||
parent.a_upload_index = index;
|
parent.a_upload_index = index;
|
||||||
parent.a_upload_files = _files;
|
|
||||||
},
|
},
|
||||||
end(){
|
end(){
|
||||||
$.table.search()
|
$.table.search()
|
||||||
|
|
Loading…
Reference in New Issue