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

214 lines
7.3 KiB
JavaScript
Raw Normal View History

2025-11-27 16:55:35 +08:00
var example = null;
var pers = null;
$(function () {
layui.use(['layer','form','table'], function () {
var layer = layui.layer;
var form = layui.form;
var table = layui.table;
init(table,form,'');
$("#searchBt").click(function () {
var keyWord = $("#keyWord").val();
init(table,form,keyWord)
});
});
pers = checkPermission();
})
function init(table,form,keyWord) {
table.render({
elem: '#dt-table'
2025-12-09 18:44:29 +08:00
,url: smz_ht_url + "/releaseWorkInfo/contactInfo?keyWord="+keyWord
2025-11-27 16:55:35 +08:00
,method:'post'
,cols: [[
{ field: 'ID', title: '序号',width:100, sort: true, type:'numbers'}
, { field: 'departMent',width:290, title: '部门'}
, { field: 'releasePeople',width:200, title: '联系人'}
, { field: 'releaseWay',width:385, title: '联系方式'}
, { field: 'auditType',width:300, title: '审核类型',templet:function (res){
let auditType = res.auditType;
if(auditType == 0 || auditType == "0"){
return "务工"
}else if (auditType == 1 || auditType == "1"){
return "用工"
}
}
}
, { field: 'isEnable',width:300, title: '是否启用',templet:function (res){
let menuId = res.isEnable;
let id = res.id;
if(menuId == 0 || menuId == "0"){
//menuId -- 自定义id
return "<input type='checkbox' menuId = '"+id+"' lay-filter='state' lay-skin='switch' lay-text='启用|禁用'>"
}else if (menuId == 1 || menuId == "1"){
return "<input type='checkbox' menuId = '"+id+"' lay-filter='state' lay-skin='switch' lay-text='启用|禁用' checked>"
}
}
}
, {field:'right',width: 310, title: '操作',toolbar:"#barDemo"}
]]
,limits: [5,10,20,50] //一页选择显示3,5或10条数据
,limit: 10 //一页显示10条数据
,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据res为从url中get到的数据
var result;
if(this.page.curr){
result = res.data.slice(this.limit*(this.page.curr-1),this.limit*this.page.curr);
}
else{
result=res.data.slice(0,this.limit);
}
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.count, //解析数据长度
"data": result //解析数据列表
};
}
,id: 'testReload'
,page: true //开启分页
,height: 840
});
table.on('tool(contact)', function(obj){
var data = obj.data;
if(obj.event === 'del'){
del(data.id);
} else if(obj.event === 'edit'){
edit(data.id);
}
});
isEnable(form);
}
function isEnable(form){
form.on('switch(state)',function(data){
var tf = data.elem.checked;
var id = data.elem.attributes['menuId'].nodeValue;
if(tf == true){
layer.confirm("确定启用吗?",{btn:['确定','取消']},function () {
$.ajax({
type: 'post',
2025-12-09 18:44:29 +08:00
url: smz_ht_url + '/releaseWorkInfo/updateIsEnable',
2025-11-27 16:55:35 +08:00
data: {
"id":id,
isEnable:'1'
},
dataType: 'text',
success: function (data) {
layer.alert('启用成功', {icon: 1});
location.reload(); // 刷新页面
}
},)
},function(){
location.reload(); // 刷新页面
})
}else {
layer.confirm("确定禁用吗?",{btn:['确定','取消']},function () {
$.ajax({
type: 'post',
2025-12-09 18:44:29 +08:00
url: smz_ht_url + '/releaseWorkInfo/updateIsEnable',
2025-11-27 16:55:35 +08:00
data: {
"id":id,
isEnable:'0'
},
dataType: 'text',
success: function (data) {
layer.alert('禁用成功', {icon: 1});
location.reload(); // 刷新页面
}
})
},function(){
location.reload(); // 刷新页面
},)
}
});
}
/**
* 修改
* */
function edit(id) {
localStorage.setItem("type",2);
localStorage.setItem("id",id);
$.ajax({
type: 'POST',
contentType: "application/x-www-form-urlencoded",
2025-12-09 18:44:29 +08:00
url: smz_ht_url + '/releaseWorkInfo/getContactInfoById',
2025-11-27 16:55:35 +08:00
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: 'contactInfoForm.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();
location.reload(); // 刷新页面
},
});
}
})
}
/**
* 删除
* */
function del(id) {
layer.confirm("确定删除吗?",function () {
$.ajax({
type: 'post',
2025-12-09 18:44:29 +08:00
url: smz_ht_url + '/releaseWorkInfo/delContactById',
2025-11-27 16:55:35 +08:00
data: {
"id":id
},
dataType: 'text',
success: function (data) {
layer.alert('删除成功', {icon: 1});
location.reload();
}
})
})
}
/**
* 新增用工发布信息
*/
function addContactInfo(){
localStorage.setItem("type",1);
var height = '600px';
var width = '780px';
var index = layer.open({
title: '新增',
type: 2,
content: 'contactInfoForm.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();
},
btn2:function(index,layero){
}
});
}