330 lines
9.8 KiB
Plaintext
330 lines
9.8 KiB
Plaintext
|
|
let table, form, layer, rate, util, laydate
|
|||
|
|
let pageNum = 1, limitSize = 30;
|
|||
|
|
let data = '';
|
|||
|
|
$(function () {
|
|||
|
|
layui.use(['rate', 'laydate', 'layer', 'form', 'table', 'util'], function () {
|
|||
|
|
layer = layui.layer;
|
|||
|
|
form = layui.form;
|
|||
|
|
rate = layui.rate;
|
|||
|
|
table = layui.table;
|
|||
|
|
util = layui.util;
|
|||
|
|
laydate = layui.laydate
|
|||
|
|
//日期范围
|
|||
|
|
laydate.render({
|
|||
|
|
elem: '#startTime'
|
|||
|
|
, type: 'date'
|
|||
|
|
, range: '~'
|
|||
|
|
, format: 'yyyy-MM-dd',
|
|||
|
|
value: getNowTime() + ' ~ ' + getNowTime(),
|
|||
|
|
max: Date.parse(new Date()),
|
|||
|
|
});
|
|||
|
|
util.event('lay-active', {
|
|||
|
|
query: function () {
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
},
|
|||
|
|
release:function(){
|
|||
|
|
//执行一次任务分配
|
|||
|
|
layer.msg('确定刷新任务分配?', {
|
|||
|
|
time: 10000, //10s后自动关闭
|
|||
|
|
btn: ['确定', '取消']
|
|||
|
|
,yes: function(index,leyuo){
|
|||
|
|
layer.closeAll();
|
|||
|
|
initRwFp();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
reset: function () {
|
|||
|
|
$('#checkName').val('');
|
|||
|
|
$('#loginName').val('');
|
|||
|
|
$('#startTime').val(getNowTime() + ' ~ ' + getNowTime());
|
|||
|
|
form.render();
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
form.on('checkbox(checkBox)', function (data) {//checkBox 监听
|
|||
|
|
console.log( data.elem.checked);
|
|||
|
|
var value = data.value; //获取选中的value值
|
|||
|
|
var checked=0;
|
|||
|
|
if(data.elem.checked){//选中
|
|||
|
|
checked=1;
|
|||
|
|
}else{
|
|||
|
|
checked=0
|
|||
|
|
}
|
|||
|
|
if("checkboxOnDuty"==data.elem.className){//在岗
|
|||
|
|
updateUserInformation(value,"1",checked);
|
|||
|
|
}else if("checkboxCommissioner"==data.elem.className){//专员
|
|||
|
|
updateUserInformation(value,"2",checked);
|
|||
|
|
}else if('quality'==data.elem.className){//质量专员
|
|||
|
|
updateUserInformation(value,"3",checked);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
pages(1, 10, 1);
|
|||
|
|
//触发单元格工具事件
|
|||
|
|
table.on('tool(table)', function (obj) { // 双击 toolDouble
|
|||
|
|
let data = obj.data;
|
|||
|
|
console.log(data);
|
|||
|
|
if (obj.event === 'detail') {
|
|||
|
|
toAddPage(data.checkUser,data.commissioner,data.quality);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
function pages(pageNum, pageSize, typeNum) {
|
|||
|
|
let params = getReqParams(pageNum, pageSize);
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify(params))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + "proteam/pot/allocation/getList" + '?token=' + token,
|
|||
|
|
data: params,
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
console.log(result);
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
if (result.rows) {
|
|||
|
|
initTable(result.rows, limitSize, pageNum)
|
|||
|
|
laypages(result.total, pageNum, limitSize)
|
|||
|
|
}
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.alert(result.msg, {icon: 2})
|
|||
|
|
} else if (result.code === 401) {
|
|||
|
|
logout(1);
|
|||
|
|
}
|
|||
|
|
}, error: function () {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function laypages(total, page, limit) {
|
|||
|
|
layui.use(['laypage'], function () {
|
|||
|
|
let laypage = layui.laypage;
|
|||
|
|
laypage.render({
|
|||
|
|
elem: 'voi-page',
|
|||
|
|
count: total,
|
|||
|
|
curr: page,
|
|||
|
|
limit: limit,
|
|||
|
|
limits: [30, 50, 100],
|
|||
|
|
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
|||
|
|
groups: 5,
|
|||
|
|
jump: function (obj, first) {
|
|||
|
|
if (!first) {
|
|||
|
|
pageNum = obj.curr, limitSize = obj.limit;
|
|||
|
|
pages(obj.curr, obj.limit, null);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取参数
|
|||
|
|
function getReqParams(page, limit) {
|
|||
|
|
let startTime = isEmpty($('#startTime').val().split('~')[0]) ? "" : $('#startTime').val().split('~')[0];
|
|||
|
|
let endTime = isEmpty($('#startTime').val().split('~')[1]) ? "" : $('#startTime').val().split('~')[1];
|
|||
|
|
return {
|
|||
|
|
pageNum: page + "",
|
|||
|
|
pageSize: limit + "",
|
|||
|
|
startTime: startTime.trim(),
|
|||
|
|
endTime: endTime.trim(),
|
|||
|
|
checkName: $('#checkName').val(),
|
|||
|
|
loginName: $('#loginName').val()
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
function initTable(dataList, limit, page) {
|
|||
|
|
table.render({
|
|||
|
|
elem: "#table",
|
|||
|
|
id: "table",
|
|||
|
|
height: "full-175",
|
|||
|
|
data: dataList,
|
|||
|
|
cols: [
|
|||
|
|
[//表头
|
|||
|
|
{
|
|||
|
|
title: "序号",
|
|||
|
|
width: 80,
|
|||
|
|
unresize: true,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return (page - 1) * limit + d.LAY_INDEX;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{field: 'onDuty', title: '在岗',width: 100, align: 'center',templet:function(row){
|
|||
|
|
var html = "<input type='checkbox' lay-skin='primary' lay-filter='checkBox' table-index='"+row.LAY_TABLE_INDEX+"' class='checkboxOnDuty' value='"+row.checkUser+"' ";
|
|||
|
|
if(row.onDuty == 1 || row.onDuty==null || row.onDuty==''){
|
|||
|
|
html += " checked ";
|
|||
|
|
}
|
|||
|
|
html += ">";
|
|||
|
|
return html;
|
|||
|
|
}},
|
|||
|
|
{field: 'commissioner', title: '专员',width: 100, align: 'center',templet:function(row){
|
|||
|
|
var html = "<input type='checkbox' lay-skin='primary' lay-filter='checkBox' table-index='"+row.LAY_TABLE_INDEX+"' class='checkboxCommissioner' value='"+row.checkUser+"' ";
|
|||
|
|
if(row.commissioner == 1){
|
|||
|
|
html += " checked ";
|
|||
|
|
}
|
|||
|
|
html += ">";
|
|||
|
|
return html;
|
|||
|
|
}},
|
|||
|
|
{field: 'quality', title: '质量专员',width: 100, align: 'center',templet:function(row){
|
|||
|
|
var html = "<input type='checkbox' lay-skin='primary' lay-filter='checkBox' table-index='"+row.LAY_TABLE_INDEX+"' class='quality' value='"+row.checkUser+"' ";
|
|||
|
|
if(row.quality == 1){
|
|||
|
|
html += " checked ";
|
|||
|
|
}
|
|||
|
|
html += ">";
|
|||
|
|
return html;
|
|||
|
|
}},
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
field: "checkName",
|
|||
|
|
title: "用户",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 200,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'loginName',
|
|||
|
|
title: "账号",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 200,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'num',
|
|||
|
|
title: "分配任务数量",
|
|||
|
|
unresize: false,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 200,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return "<span onclick='toPage(" + d.checkUser + ")' style='color: blue;cursor: pointer;'>" + d.num + "</span>";
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
fixed: 'right',
|
|||
|
|
title: "操作",
|
|||
|
|
align: 'center',
|
|||
|
|
minWidth: 200,
|
|||
|
|
toolbar: '#barDemo'
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
],
|
|||
|
|
limit: limit,
|
|||
|
|
done: function (res, curr, count) {
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 跳转今日人员页面
|
|||
|
|
* @param userId
|
|||
|
|
*/
|
|||
|
|
function toPage(userId) {
|
|||
|
|
let width = '90%', height = '80%';
|
|||
|
|
layer.open({
|
|||
|
|
title: ['任务详情', 'font-size:24px;'],
|
|||
|
|
type: 2,
|
|||
|
|
skin: 'shadows',
|
|||
|
|
content: '../../html/allocation/child/allocationChild.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
let body = layer.getChildFrame('body', index);
|
|||
|
|
let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法:
|
|||
|
|
iframeWin.setForm(userId);//调用子页面的方法,页面锁定
|
|||
|
|
},
|
|||
|
|
end: function () {
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
function initRwFp(){
|
|||
|
|
let loadingMsg = layer.msg('数据刷新中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({"userId":""}))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + "proteam/pot/allocation/initRwFp" + '?token=' + token,
|
|||
|
|
data: {
|
|||
|
|
"userId":""
|
|||
|
|
},
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}, error: function () {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 更新人员在岗及专机
|
|||
|
|
*/
|
|||
|
|
function updateUserInformation(userId,type,value) {
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({
|
|||
|
|
"userId":userId,
|
|||
|
|
"type":type,
|
|||
|
|
"value":value
|
|||
|
|
}))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + "proteam/pot/allocation/updateUserInformation" + '?token=' + token,
|
|||
|
|
data: {
|
|||
|
|
"userId":userId,
|
|||
|
|
"type":type,
|
|||
|
|
"value":value
|
|||
|
|
},
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
console.log(result)
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}, error: function () {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 跳转今日人员页面
|
|||
|
|
* @param userId
|
|||
|
|
*/
|
|||
|
|
function toAddPage(userId,commissioner,quality) {
|
|||
|
|
let width = '90%', height = '80%';
|
|||
|
|
layer.open({
|
|||
|
|
title: ['任务详情', 'font-size:24px;'],
|
|||
|
|
type: 2,
|
|||
|
|
skin: 'shadows',
|
|||
|
|
content: '../../html/allocation/child/allocationAdd.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
let body = layer.getChildFrame('body', index);
|
|||
|
|
let iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法:
|
|||
|
|
iframeWin.setForm(userId,commissioner,quality);//调用子页面的方法,页面锁定
|
|||
|
|
}, end: function () {
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|