hn_cloud_web/smz-web/js/work/talentTrade/releaseWorkInfo.js

278 lines
10 KiB
JavaScript
Raw Permalink 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": "../../../js/plugin/datatables/Chinese.lang"
},
"ajax": {
"url": smz_ht_url + "/releaseWorkInfo",
"type": "get",
"data": function (d) {
d.project = $("#project").val();
d.releaseStatus = $("#releaseStatus").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("public_token");
localStorage.removeItem("smz_token");
layer.msg("token过期请先登录", {shift: -1, time: 1000}, function () {
top.location.href= contentPath + '/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": "project",'width': '60px'},
{"data": "subcontract",'width': '150px'},
{"data": "teamCategory",'width': '40px'},
{"data": "numberPeople",'width': '40px'},
{"data": "teamNumber",'width': '40px'},
{"data": "holderReq",'width': '90px'},
{"data": "contactPerson",'width': '150px'},
{"data": "contactWay",'width': '210px'},
{"data": "remark",'width': '110px'},
{"data": "releaseTime",'width': '110px'},
{"data": "auditor",'width': '110px'},
{
"data": "",
'width': '160px',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var html = '';
var releaseStatus = row['releaseStatus'];
if(releaseStatus == 0){
html = "<span style='color: orange;cursor: pointer;' title=''>待审核</span>";
}else if(releaseStatus == 1){
html = "<span style='color: green;cursor: pointer;' title=''>已通过</span>";
}else if(releaseStatus == 2){
html = "<span style='color: red;cursor: pointer;' title=''>未通过</span>";
}
return html;
}
},
{
"data": "",
'width': '200px',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var isOnline = row['isOnline'];
var releaseStatus = row['releaseStatus'];
var html = '';
html += buttonIsOnline(id,isOnline,releaseStatus, "", pers);
html += buttonView(id, "", pers);
html += buttonDel(id, "sys:releaseWorkInfo:del", pers);
return html;
}
},
],
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
});
}
/**
* 查看
* */
function view(id) {
$.ajax({
type: 'POST',
contentType: "application/x-www-form-urlencoded",
url: smz_ht_url + '/releaseWorkInfo/getReleaseWorkInfoById',
data:{"id":id},
dataType: 'json',
success: function (data) {
var height = '80%';
var width = '60%';
var index = layer.open({
title: ['查看','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'releaseWorkInfoView.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 del(id) {
layer.confirm("确定删除吗?",function () {
$.ajax({
type: 'post',
url: smz_ht_url + '/releaseWorkInfo/delReleaseWorkInfoById',
data: {
"id":id
},
dataType: 'text',
success: function (data) {
layer.alert('删除成功', {icon: 1});
example.ajax.reload(); // 刷新页面
}
})
})
}
// 详情按钮
function buttonView(id, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='view(\""+id+"\")'>查看</button>");
return btn.prop("outerHTML");
}
// 下线按钮
function buttonIsOnline(id,isOnline,releaseStatus, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
if(releaseStatus == "2" || releaseStatus == 2){
var btn = $("<button style='color: grey; margin-right: 5%; height: 22px;width: 37px;margin-top: -5px;font-size: 10px;' title='下线'>下线</button>");
return btn.prop("outerHTML");
}else {
if(isOnline == 1 || isOnline == "1"){
var btn = $("<button class='layui-btn layui-btn-xs' title='下线' onclick='offline(\""+id+"\")'>下线</button>");
return btn.prop("outerHTML");
}else if(isOnline == 0 || isOnline == "0"){
var btn = $("<button style='color: grey; margin-right: 5%; height: 22px;width: 37px;margin-top: -5px;font-size: 10px;' title='下线'>下线</button>");
return btn.prop("outerHTML");
}
}
}
// 删除按钮
function buttonDel(data, permission, pers){
if(permission != ""){
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='删除' onclick='del(\"" + data +"\")'>刪除</button>");
return btn.prop("outerHTML");
}
function offline(id) {
layer.confirm("确定下线此条用工信息吗?",function () {
$.ajax({
type: 'post',
url: smz_ht_url + '/releaseWorkInfo/offlineInfoById',
data: {
"id":id
},
dataType: 'text',
success: function (data) {
layer.alert('下线成功', {icon: 1});
example.ajax.reload(); // 刷新页面
}
})
})
}
/**
* 新增用工发布信息
*/
function addReleaseWorkInfo(){
var height = '600px';
var width = '780px';
var index = layer.open({
title: '新增',
type: 2,
content: 'releaseWorkInfoForm.html',
area: [width, height],
maxmin: false,
btn:['发布','取消'],
yes:function(index,layero){
var formSubmit=layer.getChildFrame('form', index);
var submited = formSubmit.find('button')[0];
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
submited.click();
example.ajax.reload(); // 刷新页面
},
btn2:function(index,layero){
}
});
}