hn_cloud_web/smz-web/js/work/person/constructionIdentityInfo.js

199 lines
7.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var example = null;
var pers = null;
$(function () {
layui.use(['layer'], function () {
var layer = layui.layer;
});
pers = checkPermission();
init();
$("#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 + "/ConstructionIdentityInfo",
"type": "get",
"data": function (d) {
d.name = $("#name").val();
d.idNumber = $("#idNumber").val();
d.photoName = $("#photoName").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);
}
}
},
"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: '5%',
data: function (row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
}
},
{"data": "name",width: '10%'},
{"data": "idNumber",width: '30%'},
{"data": "photoName", "defaultContent": "",width: '30%',
"render": function (data, type, row) {
var photoType = row['photoType'];
if(photoType == 1 || photoType=="1"){
var html = '<span cursor: pointer" >身份证正面照片</span>';
}else if (photoType == 2 || photoType=="2"){
var html = '<span cursor: pointer" >身份证反面照片</span>';
}else if (photoType == 3 || photoType=="3"){
var html = '<span cursor: pointer" >人脸照片</span>';
}else if (photoType == 4 || photoType=="4"){
var html = '<span cursor: pointer" >银行卡照片</span>';
}else if (photoType == 5 || photoType=="5"){
var html = '<span cursor: pointer" >签名照片</span>';
}else{
var html = '<span cursor: pointer" >'+photoType+'</span>';
}
return html;
}},
{"data": "", "defaultContent": "",width: '10%',
"render": function (data, type, row) {
var photoType = row['photoType'];
var idNumber = row['idNumber'];
var photoNum = row['photoNum'];
var html = '<span style = "color:#35B3F1;cursor: pointer" onclick="view(\''+idNumber +'\',\''+ photoType+'\')">'+photoNum+'</span>';
return html;
}
},
{
"data": "",
"defaultContent": "",width: '10%',
"orderable": false,
"render": function (data, type, row) {
var idNumber = row['idNumber'];
var photoName = row['photoName'];
var html = '';
html += buttonView(idNumber,photoName,"sys:ConstructionIdentityInfo:query", pers);
return html;
}
},
],
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
});
}
function view(idNumber,photoType) {
localStorage.setItem("photoType",photoType);
$.ajax({
type: 'POST',
contentType: "application/x-www-form-urlencoded",
url: ctxPath + '/ConstructionIdentityInfo/getPhotoByIdcardAndPhotoType',
data:{"idNumber":idNumber,"photoType":photoType},
dataType: 'json',
success: function (data) {
localStorage.setItem("photoPath", data.photoPath);
localStorage.setItem("uploadTime", data.uploadTime);
localStorage.setItem("username", data.username);
var height = '585px';
var width = '675px';
var index = layer.open({
title: ['查看图片','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'ConstructionIdentityInfoForm.html',
area: [width, height],
maxmin: false,
btn: ['关闭'],
success:function(layero,index){
var myIframe = window[layero.find('iframe')[0]['name']];
},
btn2: function (index, layero) {
}
});
}
})
}
// 详情按钮
function buttonView(id,photoName, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='detail(\""+id+"\",\""+photoName+"\")'><i class='layui-icon'>&#xe63c;</i></button>");
return btn.prop("outerHTML");
}
function detail(id,photoName) {
$.ajax({
type: 'POST',
contentType: "application/x-www-form-urlencoded",
url: ctxPath + '/BaseManager/getBaseManagerId',
data:{"id":id},
dataType: 'json',
success: function (data) {
var height = '525px';
var width = '975px';
var index = layer.open({
title: ['查看','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'BaseViewManagerForm.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()为子页面的方法
},
});
}
})
}
function addFeaturesInfo(){
var height = '600px';
var width = '780px';
var index = layer.open({
title: '新增',
type: 2,
content: 'addFeaturesInfo.html',
area: [width, height],
maxmin: false,
btn:['确定','关闭'],
yes:function(index,layero){
var formSubmit=layer.getChildFrame('form', index);
var submited = formSubmit.find('button')[2];
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
submited.click();
example.ajax.reload(); // 刷新页面
},
btn2:function(index,layero){
}
});
}