204 lines
7.4 KiB
JavaScript
204 lines
7.4 KiB
JavaScript
|
|
layui.config({
|
|||
|
|
base: '../../js/layuiModules/', // 第三方模块所在目录
|
|||
|
|
version: 'v1.6.4' // 插件版本号
|
|||
|
|
}).extend({
|
|||
|
|
soulTable: 'notice,layNotify', // 模块
|
|||
|
|
});
|
|||
|
|
let id = localStorage.getItem("id");
|
|||
|
|
let subId = localStorage.getItem("subId");
|
|||
|
|
let subName = localStorage.getItem("subName");
|
|||
|
|
let personName = localStorage.getItem("personName");
|
|||
|
|
let sex = localStorage.getItem("sex");
|
|||
|
|
let nation = localStorage.getItem("nation");
|
|||
|
|
let isEmploymentAgreement = localStorage.getItem("isEmploymentAgreement");
|
|||
|
|
let isSocialSecurity = localStorage.getItem("isSocialSecurity");
|
|||
|
|
let isSalaryPaymentCertificate = localStorage.getItem("isSalaryPaymentCertificate");
|
|||
|
|
let status = localStorage.getItem("status");
|
|||
|
|
let proName = localStorage.getItem("proName");
|
|||
|
|
let managePersonName = localStorage.getItem("managePersonName");
|
|||
|
|
let subTeamName = localStorage.getItem("subTeamName");
|
|||
|
|
let subTeamType = localStorage.getItem("subTeamType");
|
|||
|
|
let form;
|
|||
|
|
var tree;
|
|||
|
|
var code;
|
|||
|
|
var table;
|
|||
|
|
var notice;
|
|||
|
|
var layNotify;
|
|||
|
|
var element;
|
|||
|
|
|
|||
|
|
$("#changProgress").click(function () {
|
|||
|
|
localStorage.setItem("id",id)
|
|||
|
|
localStorage.setItem("subId",subId)
|
|||
|
|
localStorage.setItem("subName",subName)
|
|||
|
|
localStorage.setItem("nation",nation)
|
|||
|
|
localStorage.setItem("personName",personName)
|
|||
|
|
localStorage.setItem("sex",sex)
|
|||
|
|
localStorage.setItem("isEmploymentAgreement",isEmploymentAgreement)
|
|||
|
|
localStorage.setItem("isSocialSecurity",isSocialSecurity)
|
|||
|
|
localStorage.setItem("isSalaryPaymentCertificate",isSalaryPaymentCertificate)
|
|||
|
|
localStorage.setItem("status",status)
|
|||
|
|
layerOpenFormForSencond("修改","./branchStaffForm.html");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
layui.use(['table', 'form', 'notice', 'layNotify', 'element'], function () {
|
|||
|
|
table = layui.table;
|
|||
|
|
form = layui.form;
|
|||
|
|
tree = layui.tree;
|
|||
|
|
notice = layui.notice;
|
|||
|
|
layNotify = layui.layNotify;
|
|||
|
|
element = layui.element;
|
|||
|
|
// 加载提示
|
|||
|
|
var addLoadingMsg = top.layer.msg('数据加载中,请稍候...', {
|
|||
|
|
icon: 16,
|
|||
|
|
scrollbar: false,
|
|||
|
|
time: 0,
|
|||
|
|
shade: [0.8, '#393D49']
|
|||
|
|
});
|
|||
|
|
getData()
|
|||
|
|
changeTab(code);
|
|||
|
|
top.layer.close(addLoadingMsg); //再执行关闭
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
function changeTab(){
|
|||
|
|
// hash 地址定位
|
|||
|
|
var hashName = 'tabid'; // hash 名称
|
|||
|
|
var layid = location.hash.replace(new RegExp('^#' + hashName + '='), ''); // 获取 lay-id 值
|
|||
|
|
// 初始切换
|
|||
|
|
element.tabChange('test-hash', layid);
|
|||
|
|
//上传附件后,加载原页面数据
|
|||
|
|
// 切换事件
|
|||
|
|
element.on('tab(test-hash)', function (obj) {
|
|||
|
|
code = hashName + '=' + this.getAttribute('lay-id');
|
|||
|
|
console.log("code=" +code)
|
|||
|
|
location.hash = code;
|
|||
|
|
if (code == "tabid=1") {
|
|||
|
|
getData();
|
|||
|
|
}
|
|||
|
|
if (code == "tabid=2") {
|
|||
|
|
getFileList(id);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getData() {
|
|||
|
|
if (subName !== null && subName !== '' && subName !== "null") {
|
|||
|
|
$("#data1").text(subName || "暂无");
|
|||
|
|
}else{
|
|||
|
|
$("#data1").text("暂无");
|
|||
|
|
}
|
|||
|
|
$("#data2").text(subTeamType || "暂无");
|
|||
|
|
$("#data3").text(subTeamName || "暂无");
|
|||
|
|
|
|||
|
|
$("#data5").text(sex || "暂无");
|
|||
|
|
$("#data6").text(nation || "暂无");
|
|||
|
|
$("#data7").text(id || "暂无");
|
|||
|
|
$("#data8").text(isEmploymentAgreement || "暂无");
|
|||
|
|
$("#data9").text(isSocialSecurity || "暂无");
|
|||
|
|
$("#data10").text(isSalaryPaymentCertificate || "暂无");
|
|||
|
|
$("#data11").text(personName || "暂无");
|
|||
|
|
if (subTeamName !== null && subTeamName !== '' && subTeamName !== "null") {
|
|||
|
|
const positions = managePersonName.split(",");
|
|||
|
|
// 生成一个随机数,范围在 0 到 positions.length - 1 之间
|
|||
|
|
const randomIndex = Math.floor(Math.random() * positions.length);
|
|||
|
|
// 获取随机选择的岗位
|
|||
|
|
const randomPosition = positions[randomIndex];
|
|||
|
|
$("#data12").text(randomPosition || "暂无");
|
|||
|
|
var element = document.getElementById("data12");
|
|||
|
|
var textLength = randomPosition.length;
|
|||
|
|
element.style.width = textLength * 20 + "px";
|
|||
|
|
$("#data4").text(managePersonName || "暂无");
|
|||
|
|
}else {
|
|||
|
|
$("#data12").text("暂无");
|
|||
|
|
$("#data4").text("暂无");
|
|||
|
|
}
|
|||
|
|
// 获取元素
|
|||
|
|
|
|||
|
|
|
|||
|
|
// $("#data14").text(subName || "暂无");
|
|||
|
|
$("#data15").text(proName || "暂无");
|
|||
|
|
let spanElement = "";
|
|||
|
|
if (status === '0') {
|
|||
|
|
spanElement = "<span class='layui-badge-dot'></span> 锁定";
|
|||
|
|
$("#data13").html(spanElement);
|
|||
|
|
}else {
|
|||
|
|
spanElement = "<span class='layui-badge-dot layui-bg-green'></span> 正常";
|
|||
|
|
$("#data13").html(spanElement);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getFileList(id) {
|
|||
|
|
//渲染表格
|
|||
|
|
table.render({
|
|||
|
|
elem: '#fileDemo'
|
|||
|
|
, url: ctxPath + '/personnel/getWorkRecordLists' //数据接口
|
|||
|
|
, method: 'post' //方式默认是get
|
|||
|
|
, toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
|
|||
|
|
, where: {
|
|||
|
|
id: id,
|
|||
|
|
} //post请求必须加where ,post请求需要的参数
|
|||
|
|
, cellMinWidth: 80
|
|||
|
|
, cols: [[ //表头
|
|||
|
|
{
|
|||
|
|
field: 'number', width: 80, title: '序号', align: 'center', type: 'numbers'
|
|||
|
|
}
|
|||
|
|
, {field: 'bindTime', align: 'center', title: '记录时间', templet: d => {
|
|||
|
|
let time = "";
|
|||
|
|
if (d.unbindTime === '' || d.unbindTime == null || d.unbindTime === "null") {
|
|||
|
|
time = d.bindTime +'~'+'至今';
|
|||
|
|
} else {
|
|||
|
|
time = d.bindTime +'~'+d.unbindTime;
|
|||
|
|
}
|
|||
|
|
return time;
|
|||
|
|
}}
|
|||
|
|
, {
|
|||
|
|
field: 'status', align: 'center', title: '状态', templet: d => {
|
|||
|
|
let text = "";
|
|||
|
|
if (d.status === "1") {
|
|||
|
|
text = "<span class='layui-badge-dot layui-bg-green'></span>正在项目上";
|
|||
|
|
} else if (d.status === "0") {
|
|||
|
|
text = "<span class='layui-badge-dot'></span>离开";
|
|||
|
|
}
|
|||
|
|
return text;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
, {field: 'subName', align: 'center', title: '所属分包商'}
|
|||
|
|
, {field: 'proName', align: 'center', title: '所在工程'}
|
|||
|
|
]]
|
|||
|
|
, id: 'fileDemo'
|
|||
|
|
, page: true //开启分页
|
|||
|
|
, loading: true //数据加载中。。。
|
|||
|
|
, limits: [5, 10, 20, 100] //一页选择显示3,5或10条数据
|
|||
|
|
, limit: 10 //一页显示5条数据
|
|||
|
|
, response: {
|
|||
|
|
statusCode: 200 //规定成功的状态码,默认:0
|
|||
|
|
}, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据
|
|||
|
|
let result;
|
|||
|
|
if (res.data !== '' && res.data != null && res.data !== "null") {
|
|||
|
|
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, //解析数据列表
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
toolbar: "#toolbar"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
function reloadTip(tip,message,type){
|
|||
|
|
layNotify.notice({
|
|||
|
|
title: tip+"提示",
|
|||
|
|
type: type,
|
|||
|
|
message: message
|
|||
|
|
});
|
|||
|
|
}
|