427 lines
19 KiB
Plaintext
427 lines
19 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8"%>
|
||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||
<%@page import="com.sipai.entity.maintenance.Maintenance"%>
|
||
<%request.setAttribute("Status_Launch",Maintenance.Status_Launch);%>
|
||
<%request.setAttribute("Status_Edit",Maintenance.Status_Edit);%>
|
||
<style type="text/css">
|
||
.select2-container .select2-selection--single{
|
||
height:34px;
|
||
line-height: 34px;
|
||
}
|
||
.select2-selection__arrow{
|
||
margin-top:3px;
|
||
}
|
||
</style>
|
||
<!-- 语音js -->
|
||
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/recorder/recorder.js" charset="utf-8"></script>
|
||
<!-- 时间js -->
|
||
<script type="text/javascript" src="<%=request.getContextPath()%>/plugins/bootstrap-daterangepicker/moment.min.js" charset="utf-8"></script>
|
||
<script type="text/javascript">
|
||
var showFaultLibrary4SelectFun = function() {
|
||
$.post(ext.contextPath + '/maintenance/faultLibrary/showActiveList4Select.do', {formId:"subForm",hiddenId:"pid",textId:"problem"} , function(data) {
|
||
$("#fault4SelectDiv").html(data);
|
||
openModal('fault4SelectModal');
|
||
});
|
||
};
|
||
//提交问题
|
||
function dolaunch() {
|
||
$('#status').val('${Status_Launch}')
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/maintenance/update.do", $("#subForm").serialize(), function(data) {
|
||
if (data.res == 1) {
|
||
$(".modal").modal("hide");
|
||
$("#table").bootstrapTable('refresh');
|
||
}else if(data.res == 0){
|
||
showAlert('d','保存失败');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
}
|
||
},'json');
|
||
}
|
||
}
|
||
//更新问题
|
||
function doupdateProblem() {
|
||
$('#status').val('${Status_Edit}');
|
||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||
$.post(ext.contextPath + "/maintenance/updateData.do", $("#subForm").serialize(), function(data) {
|
||
if (data.res == 1) {
|
||
$(".modal").modal("hide");
|
||
$("#table").bootstrapTable('refresh');
|
||
}else if(data.res == 0){
|
||
showAlert('d','保存失败');
|
||
}else{
|
||
showAlert('d',data.res);
|
||
}
|
||
},'json');
|
||
}
|
||
}
|
||
|
||
var fileinput = function() {
|
||
//var url='/maintenance/updateProblemFile.do';//保存数据表方法
|
||
$.post(ext.contextPath + '/base/fileinput.do', {masterId:masterId,tbName:tbName,nameSpace:nameSpace} , function(data) {
|
||
$("#fileInputDiv").html(data);
|
||
openModal('fileInputModal');
|
||
});
|
||
};
|
||
var masterId=$('#maintenanceId').val();
|
||
var tbName='tb_maintenance_problem_fille'; //数据表
|
||
var nameSpace='MaintenanceProblem';//保存文件夹
|
||
var previews = new Array();
|
||
var previewConfigs = new Array();
|
||
/* var student = {
|
||
"caption":"lilei",
|
||
|
||
}
|
||
previewConfigs[0]=student; */
|
||
//初始化fileinput控件(第一次初始化)
|
||
function showFileInput(ctrlName) {
|
||
var control = $('#' + ctrlName);
|
||
|
||
control.fileinput('destroy');
|
||
control.fileinput({
|
||
language: 'zh', //设置语言
|
||
showUpload: false, //是否显示上传按钮
|
||
showRemove:false,
|
||
showCaption: false,//是否显示标题
|
||
showBrowse:false,//选择按钮
|
||
showClose:false,//右上角关闭按钮
|
||
dropZoneEnabled: false,//是否显示拖拽区域
|
||
fileActionSettings:{
|
||
showDrag:false
|
||
},
|
||
browseClass: "btn btn-primary", //按钮样式
|
||
maxFileCount: 10, //表示允许同时上传的最大文件个数
|
||
enctype: 'multipart/form-data',
|
||
validateInitialCount:true,
|
||
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
|
||
initialPreviewAsData: true,
|
||
initialPreview: previews,
|
||
initialPreviewConfig:previewConfigs,
|
||
layoutTemplates:{
|
||
actionUpload:''
|
||
},
|
||
deleteUrl:ext.contextPath+"/base/deleteInputFile.do",
|
||
deleteExtraData:function () { //传参
|
||
var data = {
|
||
"tbName": tbName
|
||
};
|
||
return data;
|
||
}
|
||
});
|
||
$('#kvFileinputModal').on("hidden.bs.modal", function() {
|
||
$(this).removeData("bs.modal");
|
||
//modal重复打开会导致前面的滚动条失去作用
|
||
$('.modal').css("overflow","auto");
|
||
});
|
||
}
|
||
//名称定义不可修改
|
||
var getFileList = function() {
|
||
$.post(ext.contextPath + '/base/getInputFileList.do', {masterId:masterId,tbName:tbName} , function(data) {
|
||
//console.info(data)
|
||
previews=new Array();
|
||
|
||
for(var i=0;i<data.length;i++){
|
||
var path = data[i].abspath;
|
||
path=path.substring(path.indexOf('webapps')+7,path.length);
|
||
path =ext.basePath.replace(ext.contextPath,'')+ path.replace(/\\/g,"\/");;
|
||
if(data[i].type.indexOf("audio")!=-1){
|
||
var id=data[i].id;
|
||
var blob=path;
|
||
//console.info(blob)
|
||
if($("#"+id).length>0){
|
||
continue;
|
||
}
|
||
recblob[id]={blob:blob,rec:rec};
|
||
|
||
reclog('<div class="form-group" id='+id+'> '+data[i].insdt.substring(0,16)+'录制 '+
|
||
'<div class="btn-group">'+
|
||
'<button class="btn btn-primary btn-sm" onclick="recplay(\''+id+'\')" type="button"><i class="fa fa-play " ></i></button>'+
|
||
'<button class="btn btn-danger btn-sm" onclick="deleteFIleInput(\''+id+'\')" type="button"><i class="fa fa-remove "></i></button>'+
|
||
'</div>'+
|
||
'</div>');
|
||
}else{
|
||
var previewConfig = new Object();
|
||
|
||
previews.push(path);
|
||
previewConfig['width']= '50px';
|
||
previewConfig['caption']= data[i].filename;
|
||
previewConfig['key']= data[i].id;
|
||
previewConfigs.push(previewConfig);
|
||
}
|
||
|
||
}
|
||
if(previews.length>0){
|
||
$('#maintenancefile').show();
|
||
showFileInput("maintenancefile");
|
||
}else{
|
||
$('#maintenancefile').hide();
|
||
}
|
||
|
||
},'json');
|
||
|
||
};
|
||
var deleteFIleInput = function(id) {
|
||
swal({
|
||
text: "您确定要删除此录音?",
|
||
dangerMode: true,
|
||
buttons: {
|
||
cancel: {
|
||
text: "取消",
|
||
value: null,
|
||
visible: true,
|
||
className: "btn btn-default btn-sm",
|
||
closeModal: true,
|
||
},
|
||
confirm: {
|
||
text: "确定",
|
||
value: true,
|
||
visible: true,
|
||
className: "btn btn-danger btn-sm",
|
||
closeModal: true
|
||
}
|
||
}
|
||
})
|
||
.then(function(willDelete) {
|
||
if (willDelete) {
|
||
$.post(ext.contextPath + '/base/deleteInputFile.do', {tbName:tbName,key:id} , function(data) {
|
||
if(data.suc==false){
|
||
showAlert('d','删除失败,请重试!');
|
||
}else{
|
||
showAlert('s','删除成功!');
|
||
$("div#"+id).remove();
|
||
}
|
||
},'json');
|
||
|
||
}
|
||
});
|
||
|
||
};
|
||
var rec
|
||
function reclog(s){
|
||
$(".reclog").prepend(s);
|
||
};
|
||
function recopen(){
|
||
var bit=16;//比特率
|
||
rec=Recorder({bitRate:bit,onProcess:function(a,level,time){
|
||
$(".recpowerx").css("width",level+"%");
|
||
$(".recpowert").html(time+"/"+level);
|
||
}});
|
||
rec.open(function(){
|
||
},function(e){
|
||
$('#btn_record_start').hide();
|
||
});
|
||
};
|
||
function recclose(){
|
||
if(rec){
|
||
rec.close(function(){
|
||
|
||
});
|
||
}
|
||
};
|
||
function recstart(){
|
||
if(rec){
|
||
$('.recpower').show();
|
||
$('#btn_record_stop').show();
|
||
$('#btn_record_start').hide();
|
||
rec.start();
|
||
|
||
};
|
||
};
|
||
var recblob={};
|
||
var filelist={};
|
||
function recstop(){
|
||
if(rec){
|
||
var t1=Date.now();
|
||
$('.recpower').hide();
|
||
$('#btn_record_stop').hide();
|
||
$('#btn_record_start').show();
|
||
rec.stop(function(blob,time){
|
||
var fd = new FormData();
|
||
fd.append('masterId', masterId);
|
||
fd.append('tbName', tbName);
|
||
fd.append('nameSpace', nameSpace);
|
||
fd.append('filelist', blob);
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: ext.contextPath + "/base/inputFile.do",
|
||
data: fd,
|
||
processData: false, // 不会将 data 参数序列化字符串
|
||
contentType: false, // 根据表单 input 提交的数据使用其默认的 contentType
|
||
xhr: function() {
|
||
var xhr = new window.XMLHttpRequest();
|
||
/* xhr.upload.addEventListener("progress", function(evt) {
|
||
if (evt.lengthComputable) {
|
||
var percentComplete = evt.loaded / evt.total;
|
||
console.log('进度', percentComplete);
|
||
}
|
||
}, false); */
|
||
return xhr;
|
||
}
|
||
}).success(function (resp) { // 拿到提交的结果
|
||
|
||
var res = JSON.parse(resp);
|
||
if(res.suc==true){
|
||
var id=res.msg;
|
||
recblob[id]={blob:blob,rec:rec};
|
||
var now=moment().format('YYYY-MM-DD HH:mm');
|
||
reclog('<div class="form-group" id='+id+'> '+now+'录制 '+
|
||
'<div class="btn-group">'+
|
||
'<button class="btn btn-primary btn-sm" onclick="recplay(\''+id+'\')" type="button"><i class="fa fa-play "></i></button>'+
|
||
'<button class="btn btn-danger btn-sm" onclick="deleteFIleInput(\''+id+'\')" type="button"><i class="fa fa-remove "></i></button>'+
|
||
'</div>'+
|
||
'</div>');
|
||
}
|
||
|
||
}).error(function (err) {
|
||
console.error(err);
|
||
});
|
||
|
||
|
||
},function(e){
|
||
showAlert('d',"失败:"+e);
|
||
});
|
||
};
|
||
};
|
||
function recplay(key){
|
||
var o=recblob[key];
|
||
if(o){
|
||
var audio=$(".recPlay")[0];
|
||
if(!(audio.ended || audio.paused)){
|
||
audio.pause();
|
||
};
|
||
//blob类型或者网络图片路径类型
|
||
if(typeof o.blob =="string"){
|
||
audio.src=o.blob;
|
||
}else{
|
||
audio.src=URL.createObjectURL(o.blob);
|
||
}
|
||
|
||
audio.play();
|
||
};
|
||
};
|
||
$(function() {
|
||
//modal关闭时关闭录音功能
|
||
$('#subModal').on("hidden.bs.modal", function() {
|
||
recclose();
|
||
$(this).removeData("bs.modal");
|
||
//modal重复打开会导致前面的滚动条失去作用
|
||
$('.modal').css("overflow","auto");
|
||
});
|
||
$.post(ext.contextPath + "/user/getBizsByUserId4Select.do", {}, function(data) {
|
||
|
||
var selelct =$("#companyid").select2({
|
||
/* ajax: {
|
||
type:'POST',
|
||
url: ext.contextPath +"/user/getBizsByUserId4Select.do",
|
||
dataType: 'json',
|
||
delay: 250,
|
||
processResults: function (data) {
|
||
return {
|
||
results: data
|
||
}
|
||
},
|
||
cache: true
|
||
}, */
|
||
data: data,
|
||
placeholder:'请选择',//默认文字提示
|
||
allowClear: false,//允许清空
|
||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||
formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
|
||
});
|
||
if(data.length==1){
|
||
//选择厂区为一个厂时隐藏选择框
|
||
selelct.attr("disabled","disabled");
|
||
$("#companyid").next().css("display", "none");
|
||
var companyText = $("#companyid").text();
|
||
//console.info(companyText);
|
||
$("#company").text(companyText);
|
||
}else{
|
||
//selelct.val("").trigger("change");
|
||
$("#companyname").attr("disabled","disabled");
|
||
$("#company").css("display", "none");
|
||
selelct.val('${maintenance.companyid}').trigger("change");
|
||
}
|
||
},'json');
|
||
recopen();
|
||
getFileList();
|
||
})
|
||
</script>
|
||
<div class="modal fade" id="subModal">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">编辑问题</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<!-- 新增界面formid强制为subForm -->
|
||
<form class="form-horizontal" id="subForm" enctype="multipart/form-data" >
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<input type="hidden" class="form-control" id ="maintenanceId" name ="id" value="${maintenance.id}">
|
||
<input type="hidden" class="form-control" id ="status" name ="status" value="${maintenance.status}">
|
||
<input type="hidden" class="form-control" id ="insuser" name ="insuser" value="${maintenance.insuser}">
|
||
<div class="form-group " >
|
||
<label class="control-label col-sm-2">*所在厂区</label>
|
||
<div class="col-sm-10">
|
||
<select class="form-control select2" id="companyid" name ="companyid" style="display:none;width: 220px;" ></select>
|
||
<span class="form-control" id="company" style="width:220px;border: none;background: transparent;" ></span>
|
||
<input class="form-control" type="hidden" id="companyname" name ="companyid" value="${maintenance.companyid}" style="width:220px;" >
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">问题描述</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" rows="3" id="problem" name ="problem" placeholder="问题描述..." >${maintenance.problem}</textarea>
|
||
</div>
|
||
</div>
|
||
<c:if test='${not empty maintenance.cancelreason}'>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">驳回理由</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control" rows="3" id="cancelreason" name ="cancelreason" placeholder="驳回理由..." disabled="disabled">${maintenance.cancelreason}</textarea>
|
||
</div>
|
||
</div>
|
||
</c:if>
|
||
<div class="form-group" style="margin:8px">
|
||
<button type="button" class="btn btn-default btn-file btn-sm" onclick="fileinput()" id="btn_save"><i class="fa fa-paperclip"></i> 上传图片</button>
|
||
<button type="button" class="btn btn-default btn-file btn-sm" onclick="showFaultLibrary4SelectFun()" id="btn_save"><i class="fa fa-file-o"></i> 问题库</button>
|
||
<button type="button" class="btn btn-default btn-file btn-sm" onclick="recstart();" id="btn_record_start"><i class="fa fa-microphone"></i> 录音</button>
|
||
<button type="button" class="btn btn-default btn-file btn-sm" onclick="recstop();" id="btn_record_stop" style="display:none;"><i class="fa fa-stop"></i> 停止</button>
|
||
</div>
|
||
<div class="form-group" style="margin:8px;">
|
||
<div class="recpower" style="display:none;" ><!-- style="display:none;" -->
|
||
<div style="height:40px;width:300px;background:#999;position:relative;">
|
||
<div class="recpowerx" style="height:40px;background:#0B1;position:absolute;"></div>
|
||
<div class="recpowert" style="padding-left:50px; line-height:40px; position: relative;"></div>
|
||
</div>
|
||
</div>
|
||
<div class="reclog form-group" style="margin-left:14px;margin-top:7px;"></div>
|
||
<audio class="recPlay"></audio>
|
||
</div>
|
||
<div class="form-group" style="margin:8px;">
|
||
<input type="file" name="maintenancefile" id="maintenancefile" multiple class="file-loading" />
|
||
</div>
|
||
|
||
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="doupdateProblem()" >保存</button>
|
||
<button type="button" class="btn btn-primary" onclick="dolaunch()" >提交</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div>
|
||
|