软测单独项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

163 lines
6.4 KiB

//注意:选项卡 依赖 element 模块,否则无法进行功能性操作
layui.use(['form', 'element', "upload", 'layer'], function () {
var form = layui.form,
element = layui.element,
layer = layui.layer,
upload = layui.upload;
var UserId = JSON.parse(window.sessionStorage.getItem("userInfo")).UserCode;
var OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID;
var OrgName = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgName;
var loading;
upload.render({
elem: "#uploadFile",
url: "http://192.168.31.205:5055/political/mobile/yqlayuiFileUtils",
accept: "file", //普通文件
exts: 'xls|doc|xlsx|docx|pdf|pptx|ppt', //允许的上传文件格式
before: function (obj) {
this.data = { "dir": "file" };
},
progress: function (n) {//上传进度回调 n进度值
var percent = n + '%'; //计算出进度
$("#uploadFile").attr("lay-percent", percent);
element.render();
loading = layer.load(2, {
shade: [0.1, '#000'],
content: '后台处理中,请耐心等待......',
success: function (layerContentStyle) { // 设置loading样式
layerContentStyle.find('.layui-layer-iframe').css({
'padding-left': '45px',
'text-align': 'left',
'width': '200px',
'line-height': '30px'
});
}
});
},
done: function (data) {
$("#PLAN_URL").val(data.url);
//if ("pptx" == data.fileExt || "pdf" == data.fileExt || "doc" == data.fileExt || "docx" == data.fileExt) {
// $("#totalPage").val(data.totalPage);
//}
layer.close(loading);
layer.msg("上传成功");
$("#checkFile").show();
}
});
$("#checkFile").click(function () {
var url = $("#PLAN_URL").val();
let baseUrl = encodeURIComponent(btoa(url));
parent.layui.layer.open({
id: "office_win_id",
area: ["60%", "90%"],
type: 2,
title: "<i class=\"icon_detail\"></i>预览",
shade: 0.3,
resize: false,
//skin: 'layerWin', //注意这里,靠这个css自定义样式!!!!!
//zIndex: 1,//不设置会导致kindeditor的弹框被遮盖
content: "http://8.142.26.221:8012/onlinePreview?url=" + baseUrl,
//content:"http://192.168.31.95:8012/onlinePreview?url="+baseUrl,
maxmin: true,
success: function () {
}
})
});
form.on("submit(AddEdit)", function (data) {
if (!$("#PLAN_URL").val()) {
top.layer.msg("请先上传文件后在执行保存操作!");
return;
}
//load提交
var index = layer.msg('数据提交中,请稍候', { icon: 16, time: false, shade: 0.8 });
var data = {};
if (!$(".ID").val()) {
data = {
Action: "Save",
ID: $(".ID").val(),
PLAN_TITLE: $("#PLAN_TITLE").val(),
PLAN_URL: $("#PLAN_URL").val(),
AUTHORITY_TYPE: $("#AUTHORITY_TYPE").val(),
ORG_ID: OrgId,
ORG_NAME: OrgName,
CREATE_USERSUID: UserId,
LAST_MODIFICATION_USERSUID: UserId,
random: new Date().getTime() //随机参数(员工表ID ","分割)
};
} else {
data = {
Action: "Save",
ID: $(".ID").val(),
PLAN_TITLE: $("#PLAN_TITLE").val(),
PLAN_URL: $("#PLAN_URL").val(),
AUTHORITY_TYPE: $("#AUTHORITY_TYPE").val(),
ORG_ID: OrgId,
LAST_MODIFICATION_USERSUID: UserId,
random: new Date().getTime() //随机参数(员工表ID ","分割)
};
}
$.post("../../ashx/ZYTFirePlanHandler.ashx", data, function (res) {
layer.close(index);
res = $.parseJSON(res);
if (res.code == 1) {
top.layer.msg(res.msg);
parent.location.reload();
} else {
layer.close(index);
layer.msg(res.msg);
}
});
layer.close(index);
return false;
})
////添加视频
//upload.render({
// elem: "#add_upload_matVideo",
// url: "${ctx}/layuiFileUtils",
// accept: "video", //视频 上传时校验的文件类型,可选值有:images(图片)、file(所有文件)、video(视频)、audio(音频)
// before: function (obj) {
// this.data = { "dir": "media" };
// },
// progress: function (n) {//上传进度回调 n进度值
// var percent = n + '%';
// if (n > 99) {
// myMsg = layer.msg('视频正在处理,请稍后...', {
// shade: 0.4,
// time: false //取消自动关闭
// });
// //layer.msg("视频正在处理,请稍后...");
// } else {
// $("#uploadVideo").attr("lay-percent", percent);
// element.render();
// }
// },
// done: function (data) {
// layer.close(myMsg);
// console.log(data)
// if (data.msg == "success") {
// $("#fileMd5").val(data.fileName);
// setTimeout(() => {
// $("#uploadVideo").attr("lay-percent", "100%");
// element.render();
// var video = document.getElementById('addVideoUrl');
// hlsPlay(data.video.PlayURL, video);
// $("#addVideoUrl").attr("src", data.video.PlayURL);
// $("#aliyunId").attr("value", data.video.VideoId);
// $("#addMatVideoUrl").val(data.video.PlayURL);
// }, 1700)
// } else {
// $("#uploadVideo").attr("lay-percent", "0%");
// element.render();
// layer.msg(data.msg);
// }
// },
// error: function () {//请求异常回调
// $("#uploadVideo").attr("lay-percent", "0%");
// element.render();
// layer.msg("文件上传失败");
// }
//});
});