hn_cloud_web/smz-web/js/work/basic/SubPrincipalManagement.js

267 lines
11 KiB
JavaScript
Raw Normal View History

2025-11-27 16:55:35 +08:00
var example = null;
var pers = null ;
var form = null;
var usernameLogin = localStorage.getItem("usernameLogin");
$(function () {
layui.use([ 'layer' ,'form'], function() {
var layer = layui.layer;
form = layui.form;
getProject(form);
});
pers = checkPermission();
init();
$("#searchBt").click(function(){
example.ajax.reload();
});
})
function init(){
example =
$('#dt-table').DataTable({
"searching": false,
"processing": true, //加载数据时显示进度状态
"serverSide" : true,
"pagingType": "full_numbers", //首页|尾页
"language": {
2025-12-02 14:22:34 +08:00
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
2025-11-27 16:55:35 +08:00
},
"ajax": {
"url" : ctxPath + "/SubPrincipalManagement",
"type":"get",
"data":function(d){
d.proId = $("#proId").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);
}
}
},
"lengthMenu": [ [10, 20, 50], [10, 20, 50] ], // 设置每页显示数据量选项
"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>><'dt-table-length'l>",
"columns": [
{
width : '40px',
"orderable": false,
data : function(row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
}
},
{ "data": "proName","defaultContent": "","orderable": false,},
{ "data": "subName","defaultContent": "","orderable": false,},
{ "data": "name","defaultContent": "","orderable": false,},
2025-11-27 16:55:35 +08:00
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var idCardJustURL = row['idCardJustURL'];
var html = '';
if(idCardJustURL == '' || idCardJustURL == null){
html = '<span style="color: #ff0000">未上传</span>'
}else{
html = '<span style="color: #2e8b57;cursor: pointer;" onclick="getPhoto(\''+idCardJustURL +'\')">点击预览</span>'
2025-11-27 16:55:35 +08:00
}
return html;
}
},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var idCardBackURL = row['idCardBackURL'];
var html = '';
if(idCardBackURL == '' || idCardBackURL == null){
html = '<span style="color: #ff0000">未上传</span>'
}else{
html = '<span style="color: #2e8b57;cursor: pointer;" onclick="getPhoto(\''+idCardBackURL +'\')">点击预览</span>'
2025-11-27 16:55:35 +08:00
}
return html;
}
},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var operationVideoURL = row['operationVideoURL'];
var html = '';
if(operationVideoURL == '' || operationVideoURL == null){
html = '<span style="color: #ff0000">未上传</span>'
}else{
html = '<span style="color: #2e8b57;cursor: pointer;" onclick="getPhoto(\''+operationVideoURL +'\')">点击预览</span>'
2025-11-27 16:55:35 +08:00
}
return html;
}
},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var esignatureURL = row['esignatureURL'];
var html = '';
if(esignatureURL == '' || esignatureURL == null){
html = '<span style="color: #ff0000">未上传</span>'
}else{
html = '<span style="color: #2e8b57;cursor: pointer;" onclick="getPhoto(\''+esignatureURL +'\')">点击预览</span>'
2025-11-27 16:55:35 +08:00
}
return html;
}
},
{
"data": "",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var powerOfAttorneyURL = row['powerOfAttorneyURL'];
var html = '';
if(powerOfAttorneyURL == '' || powerOfAttorneyURL == null){
html = '<span style="color: #ff0000">未上传</span>'
}else{
html = '<span style="color: #2e8b57;cursor: pointer;" onclick="getPhoto(\''+powerOfAttorneyURL +'\')">点击预览</span>'
2025-11-27 16:55:35 +08:00
}
return html;
}
},
{
"data": "",
"width":"10%",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var buAudit = row['auditResult'];
var html = '';
if (buAudit == '0'){
html+= "<span>待审核</span>";
} else if (buAudit == '1'){
html+= "<span>审核通过</span>";
} else {
html+= "<span>审核不通过</span>";
}
return html;
}
},
{
"data": "auditRemark",
"width":"10%",
"defaultContent": "",
"orderable": false,
},
{
"data": "",
"width":"10%",
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var buAudit = row['auditResult'];
var html = '';
if (buAudit == '0'){
if(usernameLogin == "bnsAdmin" || usernameLogin == "cygrAdmin"){
html+= buttonAudit(id, "", pers);
}
}
return html;
}
},
],
"order": [] //在栏目列上显示排序功能
2025-11-27 16:55:35 +08:00
} );
}
/**
* 审核工程
* */
function audit(id) {
localStorage.setItem("auditId", id);
var height = '75%';
var width = '75%';
2025-11-27 16:55:35 +08:00
var index = layer.open({
title: ['审核', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'SubPrincipalManagementAudit.html',
data: {"id": id},
area: [width, height],
maxmin: false,
btn: ['确定', '关闭'],
success: function (layero, index) {
},
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 buttonAudit(id, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='审核' onclick='audit(\"" + id + "\")' style='background-color: transparent;color: #009688;'>审核</button>");
2025-11-27 16:55:35 +08:00
return btn.prop("outerHTML");
}
function getPhoto(url) {
var filePath = dataPath + "/"+url;
window.open(filePath);
}