460 lines
17 KiB
JavaScript
460 lines
17 KiB
JavaScript
var example = null;
|
||
var pers = null;
|
||
var token = localStorage.getItem("token");
|
||
layui.use(['layer', 'form'], function () {
|
||
var layer = layui.layer;
|
||
var form = layui.form;
|
||
getOrg(form);
|
||
var orgId = $("#orgId").val();
|
||
getPro(form, orgId);
|
||
form.on('select(orgId)', function (data) {
|
||
getPro(form, data.value);
|
||
});
|
||
init();
|
||
pers = checkPermission();
|
||
$("#searchBt").click(function () {
|
||
example.ajax.reload();
|
||
});
|
||
});
|
||
|
||
|
||
function init() {
|
||
example =
|
||
$('#dt-table').DataTable({
|
||
"sort": false,
|
||
"searching": false,
|
||
"processing": true, //加载数据时显示进度状态
|
||
"serverSide": true,
|
||
"pagingType": "full_numbers", //首页|尾页
|
||
"language": {
|
||
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
|
||
},
|
||
"ajax": {
|
||
"url": ctxPath + "/contractMode",
|
||
"type": "get",
|
||
"data": function (d) {
|
||
d.companyId = $("#orgId").val();
|
||
d.keyword = $("#keyword").val();
|
||
},
|
||
"error": function (xhr, textStatus, errorThrown) {
|
||
var msg = xhr.responseText;
|
||
console.log(msg);
|
||
var response = JSON.parse(msg);
|
||
var code = response.code;
|
||
var message = response.message;
|
||
if (code == 400) {
|
||
layer.msg(message);
|
||
} else if (code == 401) {
|
||
localStorage.removeItem("token");
|
||
layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
|
||
location.href = ctxPath + '/login.html';
|
||
});
|
||
} else if (code == 403) {
|
||
console.log("未授权:" + message);
|
||
layer.msg('未授权');
|
||
} else if (code == 500) {
|
||
console.log('系统错误:' + message);
|
||
}
|
||
}
|
||
},
|
||
"drawCallback": function() {
|
||
// alert( '表格重绘了' );
|
||
var thisDataTable = $('#dt-table').DataTable();
|
||
$(".pagination").append("<li>" +
|
||
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'>到 <input style='margin:0px;width:40px;' id='changePage'> 页</a>" +
|
||
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
|
||
//点击按钮跳转指定页数
|
||
$('#dataTable-btn').click(function (e) {
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
});
|
||
//敲击回车键跳转指定页数
|
||
$("#changePage").keypress(function (e) {
|
||
if(event.keyCode==13){
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
}
|
||
});
|
||
},
|
||
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>>",
|
||
"columns": [
|
||
{
|
||
width: '40px',
|
||
data: function (row, type, set, meta) {
|
||
var c = meta.settings._iDisplayStart + meta.row + 1;
|
||
return c;
|
||
}
|
||
},
|
||
{"data": "name"},
|
||
{"data": "contractType"},
|
||
{"data": "creator" },
|
||
{"data": "creatTime"},
|
||
{"data": "signNum" },
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var isRelease = row['isRelease'];
|
||
if(isRelease !=null && isRelease !=""){
|
||
content="<a id=links href='' >已发布</a>";
|
||
}else{
|
||
content="未发布";
|
||
}
|
||
return content;
|
||
},
|
||
},
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var filePath = row['filePath'];
|
||
var name = row['name'];
|
||
var isRelease = row['isRelease'];
|
||
var html = '';
|
||
//有合同文档 可以查看和修改,没有文档只可上传
|
||
if(filePath !=null && filePath!=""){
|
||
html += preview(id,filePath,"", pers);//sys:contractInfo:query
|
||
html += "<a class='layui-btn layui-btn-xs' title='下载' onclick='getDownload(\""+name+"\",\""+filePath+"\")'><i class='layui-icon'>下载</i></a>";
|
||
html += setUp(id,"", pers);//sys:contractInfo:query
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
],
|
||
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
|
||
});
|
||
}
|
||
//预览按钮
|
||
function preview(id, filePath, permission, pers){
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
//数据和数据库查出来不一样,这里写死
|
||
filePath = filePath+"?token="+token;
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='预览' onclick='getPreview(\""+id+"\",\""+filePath+"\")'><i class='layui-icon'>预览</i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
//预览按钮
|
||
function getPreview(id, filePath, permission, pers){
|
||
filePreview(filePath);
|
||
}
|
||
|
||
//下载按钮
|
||
function getDownload(name,filePath){
|
||
window.location.href = ctxPath + "/download/download?filename=劳动合同.docx";
|
||
/*var path = filePath;
|
||
if (path.indexOf("http") == -1) {
|
||
path = disphoto + path;
|
||
}
|
||
download(path, "电子合同文档");*/
|
||
|
||
|
||
/*var path = filePath;
|
||
if (path.indexOf("http") == -1) {
|
||
path = disphoto + path;
|
||
}
|
||
var a= document.createElement('a');
|
||
a.href = path;
|
||
a.download = name; //文件名
|
||
a.target="_blank";
|
||
a.click();*/
|
||
}
|
||
|
||
//设置按钮
|
||
function setUp(id,permission,pers){
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='设置' onclick='getsetUp(\""+id+"\")'><i class='layui-icon'>设置</i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
//设置按钮
|
||
function getsetUp(id) {
|
||
localStorage.setItem("id", id);
|
||
var height = '500px';
|
||
var width = '850px';
|
||
var index = layer.open({
|
||
title: ['设置','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'templateManageFrom.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
success:function(layero,index){
|
||
var myIframe = window[layero.find('iframe')[0]['name']];
|
||
// var fnc = myIframe.setData(data); //aaa()为子页面的方法
|
||
},
|
||
yes: function (index, layero) {
|
||
// 获取弹出层中的form表单元素
|
||
var formSubmit = layer.getChildFrame('form', index);
|
||
var submited = formSubmit.find('button')[0];
|
||
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
||
submited.click();
|
||
example.ajax.reload(); // 刷新页面
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function view(idNumber) {
|
||
$.ajax({
|
||
type: 'POST',
|
||
contentType: "application/x-www-form-urlencoded",
|
||
url: ctxPath + '/wagesInfo/getRollBankName',
|
||
data:{"idNumber":idNumber},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
localStorage.setItem("idNumber", data.idNumber);
|
||
localStorage.setItem("rollBankName", data.rollBankName);
|
||
var height = '30%';
|
||
var width = '40%';
|
||
var index = layer.open({
|
||
title: ['修改','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'wagesInfoForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
success:function(layero,index){
|
||
var myIframe = window[layero.find('iframe')[0]['name']];
|
||
var fnc = myIframe.setData(data); //aaa()为子页面的方法*/
|
||
},
|
||
/* yes: function (index, layero) {
|
||
// 获取弹出层中的form表单元素
|
||
/!* var formSubmit = layer.getChildFrame('form', index);
|
||
var submited = formSubmit.find('button')[0];
|
||
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
||
submited.click();
|
||
example.ajax.reload(); // 刷新页面*!/
|
||
},*/
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
},
|
||
error:function (){
|
||
layer.msg('暂无银行卡', {icon: 2});
|
||
}
|
||
})
|
||
}
|
||
// 合同见证
|
||
function getContractImg(id, permission, pers) {
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='合同见证' onclick='getImg(\""+id+"\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
function getImg(idNumber) {
|
||
// var facePhoto = $('#facePhoto option:selected').val();
|
||
$.ajax({
|
||
type: 'POST',
|
||
contentType: "application/x-www-form-urlencoded",
|
||
url: ctxPath + '/contractInfo/getContractImg',
|
||
data:{"idNumber":idNumber},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
localStorage.setItem("list", JSON.stringify(data));
|
||
var height = '585px';
|
||
var width = '675px';
|
||
var index = layer.open({
|
||
title: ['查看图片','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'contractInfoImgForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: [ '关闭'],
|
||
success:function(layero,index){
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
},
|
||
error:function () {
|
||
//layer.msg('暂无银行卡', {icon: 2});
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// 详情按钮
|
||
function buttonView(id,rollBankName, permission, pers) {
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='修改' onclick='view(\""+id+"\",\""+rollBankName+"\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
|
||
// 修改合同见证
|
||
function updateContractImg(id, permission, pers) {
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='修改合同见证' onclick='updateImg(\""+id+"\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
function updateImg(idNumber) {
|
||
$.ajax({
|
||
type: 'POST',
|
||
contentType: "application/x-www-form-urlencoded",
|
||
url: ctxPath + '/contractInfo/getContractImg',
|
||
data:{"idNumber":idNumber},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
localStorage.setItem("list", JSON.stringify(data));
|
||
var height = '585px';
|
||
var width = '675px';
|
||
var index = layer.open({
|
||
title: ['查看图片','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'contractInfoImgForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
success:function(layero,index){
|
||
},
|
||
yes: function (index, layero) {
|
||
submited.click();
|
||
example.ajax.reload(); // 刷新页面
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
},
|
||
error:function () {
|
||
//layer.msg('暂无银行卡', {icon: 2});
|
||
}
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取分公司
|
||
* */
|
||
function getCompanys(orgId) {
|
||
$("#orgId").empty();
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: ctxPath + '/project/getCompanys',
|
||
data: {},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
var str = '<option selected value="">请选择分公司</option>';
|
||
if (data.length > 0) {
|
||
for (var i = 0; i < data.length; i++) {
|
||
if (orgId == data[i].id) {
|
||
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
||
} else {
|
||
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
||
}
|
||
}
|
||
}
|
||
$("#orgId").append(str);
|
||
layui.form.render('select'); //这里就是我们要渲染的地方了
|
||
}
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获取工程
|
||
* */
|
||
function getProject(orgId) {
|
||
$("#proId").empty();
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: ctxPath + '/balls/getPros',
|
||
data: {
|
||
"comId": orgId,
|
||
},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
var str = '<option selected value="">请选择工程</option>';
|
||
if (data.length > 0) {
|
||
for (var i = 0; i < data.length; i++) {
|
||
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
|
||
}
|
||
}
|
||
$("#proId").append(str);
|
||
layui.form.render('select'); //这里就是我们要渲染的地方了
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
|
||
// 上传合同见证
|
||
function uploadContractImg(id,userName, permission, pers) {
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='上传合同见证' onclick='uploadImg(\""+id+"\",\""+userName+"\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
function uploadImg(idNumber,userName) {
|
||
// var facePhoto = $('#facePhoto option:selected').val();
|
||
$.ajax({
|
||
type: 'POST',
|
||
contentType: "application/x-www-form-urlencoded",
|
||
url: ctxPath + '/contractInfo/getContractImg',
|
||
data:{"idNumber":idNumber},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
localStorage.setItem("witnessPath", data.witnessPath);
|
||
localStorage.setItem("userName", userName);
|
||
localStorage.setItem("witnessName", data.witnessName);
|
||
var height = '585px';
|
||
var width = '675px';
|
||
var index = layer.open({
|
||
title: ['查看图片','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'contractInfoImgForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
success:function(layero,index){
|
||
var myIframe = window[layero.find('iframe')[0]['name']];
|
||
var fnc = myIframe.setData(data);
|
||
},
|
||
yes: function (index, layero) {
|
||
submited.click();
|
||
example.ajax.reload(); // 刷新页面
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
},
|
||
error:function () {
|
||
//layer.msg('暂无银行卡', {icon: 2});
|
||
}
|
||
})
|
||
}
|
||
|