361 lines
18 KiB
HTML
361 lines
18 KiB
HTML
<div class="easyui-layout" style="width:100%;height:100%;">
|
||
<div id='southdiv' data-options="region:'south'" style="height:50px;text-align:center;padding:5px">
|
||
<a href="javascript:void(0)" iconCls="fa-check" class="easyui-linkbutton" onclick="pxsubmitForm()" id="submitb">提交</a>
|
||
<a href="javascript:void(0)" iconCls="fa-close" class="easyui-linkbutton" onclick="closeForm()">取消</a>
|
||
</div>
|
||
<div data-options="region:'center'" style="height:100%;padding:15px 15px;">
|
||
<form id="pxff" method="post" name="pxff" enctype="multipart/form-data">
|
||
<div style="margin-bottom:5px" id="trainplandiv">
|
||
<input id="trainplanname" class="easyui-textbox" style="width:480px" data-options="label:'所属计划'" editable=false
|
||
>
|
||
<input type="hidden" name="trainplan" id="trainplan"/>
|
||
<a id="choosetrainplan" class='easyui-linkbutton' onclick="javascript:opendg2('选择计划','html/trainplan/chose/', 'trainplan')" style="width:auto">选择</a>
|
||
</div>
|
||
<div style="margin-bottom:5px;">
|
||
<input id="starttime" editable="false" name="starttime" class="easyui-datetimebox" style="width:480px"
|
||
data-options="label:'培训时间',currentText:'今天',closeText:'关闭',showSeconds:false" required=true />
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="trainplace" class="easyui-textbox" name="trainplace" style="width:480px" data-options="
|
||
label:'培训地点',"
|
||
required=true>
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="trainname" class="easyui-textbox" name="trainname" style="width:480px" data-options="
|
||
label:'培训名称',"
|
||
required=true>
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="traintype" name="traintype" style="width:480px" class="easyui-textbox" data-options="label:'培训类型',"
|
||
required=true /></div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="manlevel" name="manlevel" style="width:480px;" class="easyui-textbox" data-options="label:'人员类型',"
|
||
required=true /></div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="trainpart" name="trainpart" style="width:480px;" class="easyui-textbox" data-options="label:'培训部门',"
|
||
required=true />
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="trainlevel" name="trainlevel" style="width:480px;" class="easyui-textbox" data-options="label:'培训级别',"
|
||
required=true /></div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="traincontent" class="easyui-textbox" name="traincontent" style="width:480px" editable="false"
|
||
data-options="label:'培训内容'" required=true>
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="teacher" name="teacher" class="easyui-textbox" style="width:480px" data-options="label:'授课人',prompt:'可手填'"
|
||
required=true >
|
||
<input type="hidden" name="lecturer" id="lecturer"/>
|
||
<a id="chooselecturer" class='easyui-linkbutton' onclick="choseuser()" style="width:auto">选择</a>
|
||
</div>
|
||
|
||
<div style="margin-bottom:5px">
|
||
<input id="detailcontent" name="detailcontent" class="easyui-textbox" style="width:480px;height:60px" data-options="label:'具体内容',multiline:true," value="">
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input class="easyui-textbox" id="participantname" style="width:480px;height:60px" editable="false"
|
||
data-options="label:'参加人员',multiline:true,prompt:'请选择'" required=true>
|
||
<input type="hidden" id="participant" name="participant" />
|
||
<a id="chooserys" class='easyui-linkbutton' onclick="choseusers()" style="width:auto">选择</a>
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="participantnum" class="easyui-numberbox" name="participantnum" style="width:480px"
|
||
data-options="label:'参加人数'" required=true>
|
||
</div>
|
||
<div style="margin-bottom:5px">
|
||
<input id="duration" class="easyui-numberbox" name="duration" style="width:480px" data-options="min:0,precision:1,label:'培训时长',prompt:'小时'"
|
||
required=true>
|
||
</div>
|
||
<!-- <div style="margin-bottom:5px">
|
||
<input id="jsqd" class="easyui-checkbox" name="jsqd" value=1 label="结束签到:"><span style="color:blue"> 开启后可精确员工培训时间,开始签到默认开启</span>
|
||
</div> -->
|
||
<div id='knownumdiv' style="margin-bottom:5px;display:none">
|
||
<input id="knownum" class="easyui-numberbox" name="knownum" style="width:480px" data-options="label:'掌握人数',required:true">
|
||
</div>
|
||
<div id='pxxgdiv' style="margin-bottom:5px;display:none">
|
||
<input id="pxxg" name="pxxg" class="easyui-textbox" style="width:480px;height:60px" data-options="label:'培训效果',multiline:true,">
|
||
</div>
|
||
<div id="examtestdiv" style="margin-bottom:5px;display:none">
|
||
<input id="examtest" name="examtest" class="easyui-combobox" style="width:480px;" editable=false data-options="label:'关联考试',url:'api/examtest?a=listtrain'">
|
||
</div>
|
||
<div id='filediv' style="margin-bottom:5px;">
|
||
<label>相关资料 </label><input type="file" id="file" name="" accept="image/*,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.zip,.pdf" style="margin-left: 20px" />
|
||
<span id='ps' style="display:none">
|
||
<input type="button" onclick="cancleUploadFile()" value="取消" />
|
||
<progress id="progressBar" value="0" max="100" style="width: 100px;"></progress>
|
||
<span id="percentage"></span>
|
||
<span id="time"></span>
|
||
</span>
|
||
<ol id="fileol"></ol>
|
||
</div>
|
||
|
||
<input id="state" name="state" type="hidden" />
|
||
<input id="submituser" name="submituser" type="hidden" />
|
||
<input id="trainid" name="trainid" type="hidden" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
document.getElementById('file').onchange = function () {
|
||
var fileObj = this.files[0];
|
||
var url = 'upfile'
|
||
var form = new FormData();
|
||
form.append("upfile", fileObj); // 文件对象
|
||
xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
|
||
xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。
|
||
$('#ps').show();
|
||
xhr.onload = function (evt) { //服务断接收完文件返回的结果
|
||
var data = JSON.parse(evt.target.responseText);
|
||
if (data.code = 1) {
|
||
$('#ps').css('display', 'none');
|
||
$("#fileol").append('<li><button onclick="removep(this)" >删除</button><a class = "filea" target="_blank" filepath="' + data.filepath + '" href="' + data.filepath + '" >' + data.filename + '</a></li>');
|
||
} else { alert("上传失败!"); } document.getElementById('file').value = '';
|
||
}; //请求完成
|
||
xhr.onerror = function (evt) { alert("上传失败!"); $('#ps').css('display', 'none'); }; //请求失败
|
||
xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
|
||
xhr.upload.onloadstart = function () {//上传开始执行方法
|
||
ot = new Date().getTime(); //设置上传开始时间
|
||
oloaded = 0;//设置上传开始时,以上传的文件大小为0
|
||
};
|
||
xhr.send(form); //开始上传,发送form数据
|
||
//上传进度实现方法,上传过程中会频繁调用该方法
|
||
}
|
||
//取消上传
|
||
function cancleUploadFile() {
|
||
xhr.abort();
|
||
$('#ps').hide();
|
||
document.getElementById('file').value = '';
|
||
}
|
||
function progressFunction(evt) {
|
||
var progressBar = document.getElementById("progressBar");
|
||
var percentageDiv = document.getElementById("percentage");
|
||
// event.total是需要传输的总字节,event.loaded是已经传输的字节。如果event.lengthComputable不为真,则event.total等于0
|
||
if (evt.lengthComputable) {//
|
||
progressBar.max = evt.total;
|
||
progressBar.value = evt.loaded;
|
||
percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";
|
||
}
|
||
var time = document.getElementById("time");
|
||
var nt = new Date().getTime();//获取当前时间
|
||
var pertime = (nt - ot) / 1000; //计算出上次调用该方法时到现在的时间差,单位为s
|
||
ot = new Date().getTime(); //重新赋值时间,用于下次计算
|
||
var perload = evt.loaded - oloaded; //计算该分段上传的文件大小,单位b
|
||
oloaded = evt.loaded;//重新赋值已上传文件大小,用以下次计算
|
||
//上传速度计算
|
||
var speed = perload / pertime;//单位b/s
|
||
var bspeed = speed;
|
||
var units = 'b/s';//单位名称
|
||
if (speed / 1024 > 1) {
|
||
speed = speed / 1024;
|
||
units = 'k/s';
|
||
}
|
||
if (speed / 1024 > 1) {
|
||
speed = speed / 1024;
|
||
units = 'M/s';
|
||
}
|
||
speed = speed.toFixed(1);
|
||
//剩余时间
|
||
var resttime = ((evt.total - evt.loaded) / bspeed).toFixed(1);
|
||
time.innerHTML = ',速度:' + speed + units + ',剩余时间:' + resttime + 's';
|
||
}
|
||
function aaa(x) {
|
||
if (x == "participant") {
|
||
$('#participant').attr('value', top.$('#in').val());
|
||
$('#participantname').textbox('setValue', top.$('#in').attr('show'));
|
||
$('#participantnum').textbox('setValue', top.$('#in').attr('total'));
|
||
}
|
||
else if (x == "lecturer") {
|
||
$('#lecturer').attr('value', top.$('#in').val());
|
||
$('#teacher').textbox('setValue', top.$('#in').attr('show'));
|
||
}
|
||
else if (x == "trainplan") {
|
||
$('#trainplan').attr('value', top.$('#in').val());
|
||
$('#trainplanname').textbox('setValue', top.$('#in').attr('show'));
|
||
}
|
||
}
|
||
function choseuser() {
|
||
var myh = screen.availHeight * 0.5;
|
||
$('#userdd').dialog({
|
||
maximizable: true,
|
||
title: '选择人员',
|
||
width: 700,
|
||
height: myh,
|
||
closed: false,
|
||
cache: false,
|
||
href: 'getuserf?a=lecturer',
|
||
modal: true,
|
||
border:false,
|
||
});
|
||
$('#userdd').window('center');
|
||
}
|
||
function pxsubmitForm() {
|
||
var a = GetQueryString("a");
|
||
var b = GetQueryString("trainid");
|
||
var fd = new FormData(document.getElementById("pxff"));
|
||
|
||
if (a == 'addtrain') {
|
||
$.messager.confirm('提示', '请仔细核对信息,确定后将向用户发送微信通知!', function (r) {
|
||
var filearray = new Array();
|
||
$(".filea").each(function () {
|
||
filearray.push($(this).attr("filepath"));
|
||
});
|
||
fd.append("upfile", filearray.join('?'));
|
||
if (r) {
|
||
$.ajax({
|
||
type: "POST",
|
||
url: 'addtrain',
|
||
data: fd,
|
||
datatype: "json",
|
||
processData: false,
|
||
contentType: false,
|
||
beforeSend: function () {
|
||
var bo = $('#pxff').form('validate')
|
||
if (bo == false) {
|
||
return bo
|
||
} else {
|
||
$('#submitb').linkbutton('disable');
|
||
}
|
||
},
|
||
success: function (data) {
|
||
if (data.code == 1) {
|
||
$('#pxtable').datagrid('reload');
|
||
$("#dd").dialog("close");
|
||
} else { $.messager.alert('提示', '失败!'); }
|
||
$('#submitb').linkbutton('enable');
|
||
},
|
||
});
|
||
}
|
||
}
|
||
);
|
||
}
|
||
else if (a == 'accesstrain') {
|
||
var filearray = new Array();
|
||
$(".filea").each(function () {
|
||
filearray.push($(this).attr("filepath"));
|
||
});
|
||
fd.append("upfile", filearray.join('?'));
|
||
$.ajax({
|
||
url: "accesstrain?trainid=" + b,
|
||
type: "POST",
|
||
data: fd,
|
||
contentType: false,
|
||
processData: false,
|
||
beforeSend: function () {
|
||
var bo = $('#pxff').form('validate')
|
||
if (bo == false) {
|
||
return bo
|
||
} else {
|
||
$('#submitb').linkbutton('disable');
|
||
}
|
||
},
|
||
success: function (data) {
|
||
if (data.code == 1) {
|
||
$('#pxtable').datagrid('reload');
|
||
$("#dd").dialog("close");
|
||
|
||
}
|
||
else { $.messager.alert('提示', '失败!'); $('#submitb').linkbutton('enable'); }
|
||
},
|
||
});
|
||
}
|
||
}
|
||
$(function () {
|
||
var a = GetQueryString("a");
|
||
if (a == 'accesstrain') {
|
||
$('#trainplandiv').hide()
|
||
$('#chooserys').hide()
|
||
$('#jsqd').hide()
|
||
var b = GetQueryString("trainid");
|
||
$.ajax({
|
||
type: "GET",
|
||
url: 'pxhandle?a=detail&trainid=' + b,
|
||
//async:false,
|
||
datatype: "json",
|
||
beforeSend: function () { },
|
||
success: function (data) {
|
||
$("#traintype").textbox('setValue', data.traintype__dickeyname).textbox('disable');
|
||
$("#manlevel").textbox('setValue', data.manlevel__dickeyname).textbox('disable');
|
||
$("#trainlevel").textbox('setValue', data.trainlevel__dicname).textbox('disable');
|
||
$("#trainpart").textbox('setValue', data.trainpart).textbox('disable');
|
||
$("#starttime").textbox('setValue', data.starttime).textbox('disable');
|
||
$("#trainplace").textbox('setValue', data.trainplace).textbox('disable');
|
||
$("#trainname").textbox('setValue', data.trainname).textbox('disable');
|
||
$("#traincontent").textbox('setValue', data.traincontent__dickeyname).textbox('disable');
|
||
$("#teacher").textbox('setValue', data.teacher).textbox('disable');
|
||
$("#detailcontent").textbox('setValue', data.detailcontent);
|
||
$("#duration").textbox('setValue', data.duration);
|
||
$("#participantnum").textbox('setValue', data.participantnum).textbox('disable');
|
||
$("#participantname").textbox('setValue', data.participantname).textbox('disable');
|
||
$("#trainid").attr('value', data.trainid);
|
||
$("#knownumdiv,#filediv,#pxxgdiv,#examtestdiv").show();
|
||
for(var i=0;i<data.material.length;i++){
|
||
let x = data.material[i]
|
||
if(x){
|
||
$("#fileol").append('<li><button onclick="removep(this)" >删除</button><a class = "filea" target="_blank" filepath="' + x + '" href="/' + x + '" >' + x.split('_').pop() + '</a></li>');
|
||
}
|
||
|
||
}
|
||
|
||
|
||
},
|
||
complete: function (XMLHttpRequest, textStatus) {
|
||
},
|
||
error: function () {
|
||
}
|
||
});
|
||
}
|
||
else {
|
||
$('#knownum').numberbox({ required: false })
|
||
$("#traintype").combobox({
|
||
url: 'getdickey?dicclass=8&a=combobox',
|
||
method: 'get',
|
||
valueField: 'value',
|
||
textField: 'text',
|
||
groupField: 'group',
|
||
editable: false,
|
||
});
|
||
$("#manlevel").combobox({
|
||
url: 'getdickey?dicclass=9&a=combobox',
|
||
method: 'get',
|
||
valueField: 'value',
|
||
textField: 'text',
|
||
groupField: 'group',
|
||
editable: false,
|
||
});
|
||
$("#trainlevel").combobox({
|
||
url: 'getdicclass?dicid=4',
|
||
method: 'get',
|
||
valueField: 'value',
|
||
textField: 'text',
|
||
groupField: 'group',
|
||
editable: false,
|
||
onSelect: function (node) {
|
||
$('#traincontent').combobox({
|
||
label: '培训内容',
|
||
editable: false,
|
||
url: 'getdickey?dicclass=' + node.value + '&a=combobox',
|
||
checkbox: true,
|
||
valueField: 'value',
|
||
textField: 'text'
|
||
});
|
||
}
|
||
});
|
||
$("#trainpart").combotree({
|
||
url: 'parthandle?a=tree',
|
||
method: 'get',
|
||
multiple: true,
|
||
loadFilter: function (rows) {
|
||
return convert(rows);
|
||
},
|
||
formatter: function (node) {
|
||
var s = node.text;
|
||
if (node.children) {
|
||
s += ' <span style=\'color:blue\'>(' + node.children.length + ')</span>';
|
||
}
|
||
return s;
|
||
},
|
||
editable: false,
|
||
});
|
||
}
|
||
});
|
||
</script> |