117 lines
4.5 KiB
JavaScript
117 lines
4.5 KiB
JavaScript
var example = null;
|
||
var pers = null;
|
||
var isSelected = [];
|
||
var teamId;
|
||
$(function () {
|
||
layui.use(['layer', 'form', 'upload'], function () {
|
||
var layer = layui.layer;
|
||
var form = layui.form;
|
||
var upload = layui.upload;
|
||
|
||
var uploadcom = upload.render({
|
||
elem: '#test2',
|
||
url: ctxPath + '/noSignalTeamRecords/uploadFile', //改成您自己的上传接口
|
||
multiple: true, //是否允许多文件上传,默认未false
|
||
dataType: "json",
|
||
// data: {"pickId": id},
|
||
exts: 'jpg|png|jpeg',
|
||
//acceptMime: 'image/jpg,image/png,image/jpeg,file/pdf,file/xlsx',
|
||
auto: false, //是否自动上传 ,默认为true
|
||
number: 6, //最大上传数量
|
||
size: 1024 * 5, //最大文件大小,单位k
|
||
bindAction: '#hideUpload', //绑定的按钮
|
||
field: 'projectInsuranceFile', //传到后台的字段名,默认file
|
||
choose: function (obj) {
|
||
var suffixType = ''; //后缀类型
|
||
uploadcom.config.elem.next()[0].value = '';
|
||
files = obj.pushFile();
|
||
obj.preview(function (index, file, result) {
|
||
var length = $('#demo img').length;
|
||
if (length > 5) {
|
||
return layer.msg("回执单附件为1-6张,请勿过多上传", {icon: 5});
|
||
}
|
||
$('#demo').append('<img src="' + result + '" id="' + index + '" alt="' + file.name + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">');
|
||
$('#' + index).bind('dblclick', function () {//双击删除指定预上传图片
|
||
delete files[index];//删除指定图片
|
||
$(this).remove();
|
||
});
|
||
});
|
||
},
|
||
before: function (obj) {
|
||
this.data = {
|
||
teamId: teamIds
|
||
};
|
||
if ($("[name='brand']").val() == '') {
|
||
return false;
|
||
} else {
|
||
console.log(files);
|
||
var names = '';
|
||
layui.each(files, function (index, file) {
|
||
console.log(file.name)
|
||
names += file.name + ',';
|
||
|
||
});
|
||
$("[name='image']").val(names)
|
||
console.log(names);
|
||
}
|
||
return true;
|
||
},
|
||
done: function (data) {
|
||
},
|
||
allDone: function (data) {
|
||
top.layer.msg('文件保存成功', {icon: 1, time: 2000});
|
||
setTimeout("reloading()", 2100);
|
||
},
|
||
error: function (e) {
|
||
//请求异常回调
|
||
console.log(e)
|
||
}
|
||
});
|
||
})
|
||
});
|
||
function initFile(data,teamId){
|
||
teamIds = teamId;
|
||
var photoT = data[0].filePath.split(",");
|
||
var name = data[0].fileName.split(",");
|
||
var html = "";
|
||
for (var j = 0; j < photoT.length; j++) {
|
||
var path = '';
|
||
if (photoT[j].indexOf("http") != -1) {
|
||
path = photoT[j];
|
||
} else {
|
||
path = dataPath + "/" + photoT[j];
|
||
}
|
||
html += '<div style="text-align: center">';
|
||
//ondblclick="delPhoto(\'' + j + 'BoardFile\',\'' + ids[j] + '\')" id="' + j + 'BoardFile"
|
||
html += '<img ondblclick="delPhotoBtn(\'' + name[j] + '\')" newPhoto="1" src="' + path + '" name="' + photoT[j] + '" style="height: 80px;width: 80px;margin-right: 10px" class="layui-upload-img ">';
|
||
html += '<p>' + name[j] + '</p>';
|
||
html += '</div>';
|
||
}
|
||
$("#preview").append(html);
|
||
}
|
||
function delPhotoBtn(name){
|
||
layer.confirm("确定要删除吗?",function () {
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: ctxPath + '/noSignalTeamRecords/delPhoto',
|
||
data: {
|
||
"fileName": name
|
||
},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if (data.obj == "删除成功") {
|
||
layer.alert('删除成功', {icon: 1});
|
||
reloading(); // 刷新页面
|
||
} else {
|
||
layer.msg('删除失败', {icon: 2});
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}
|
||
//设置弹窗关闭
|
||
function reloading() {
|
||
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
||
parent.layer.close(index); //再执行关闭
|
||
window.parent.location.reload();
|
||
} |