248 lines
7.6 KiB
JavaScript
248 lines
7.6 KiB
JavaScript
let form, layer, table, tableIns;
|
||
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
||
let orgData,selectOrgId;
|
||
|
||
layui.use(['form', 'layer', 'table', 'laydate'], function () {
|
||
form = layui.form;
|
||
layer = layui.layer;
|
||
table = layui.table;
|
||
layui.form.render();
|
||
pages(1, 10, 1);
|
||
getToolsSelected();
|
||
})
|
||
|
||
|
||
function getToolsSelected() {
|
||
let url = dataUrl + '/tools/all';
|
||
ajaxRequest(url, "POST", null, true, function () {
|
||
}, function (result) {
|
||
if (result.code === 200) {
|
||
setSelectValue(result.data, 'sampleTools');
|
||
// return result.data
|
||
} else {
|
||
layer.alert(result.msg, {icon: 2})
|
||
}
|
||
}, function (xhr) {
|
||
error(xhr)
|
||
});
|
||
}
|
||
|
||
|
||
function pages(pageNum, pageSize, typeNum) {
|
||
let params = getReqParams(pageNum, pageSize, typeNum);
|
||
let url = dataUrl + "/samples/getList"
|
||
ajaxRequest(url, "POST", params, true, function () {
|
||
}, function (result) {
|
||
console.log("result.data:",result.data);
|
||
if (result.code === 200) {
|
||
if (result.data) {
|
||
initTable(result.data, result.limit, result.curr)
|
||
laypages(result.count, result.curr, result.limit)
|
||
}
|
||
} else if (result.code === 500) {
|
||
layer.alert(result.msg, {icon: 2})
|
||
}
|
||
}, function (xhr) {
|
||
error(xhr)
|
||
});
|
||
|
||
}
|
||
|
||
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: [10, 20, 50, 100, 200, 500],
|
||
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 initTable(dataList, limit, page) {
|
||
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
||
tableIns = table.render({
|
||
elem: "#table_data",
|
||
height: "full-130",
|
||
data: dataList,
|
||
limit: limit,
|
||
cols: [
|
||
[
|
||
//表头
|
||
{title: "序号", width: 80, unresize: true, align: "center",
|
||
templet: function (d) {
|
||
return (page - 1) * limit + d.LAY_INDEX;
|
||
}
|
||
},
|
||
{field: "customName", title: "送样单位", unresize: true, align: "center"},
|
||
{field: "sampleUser", title: "送样人", unresize: true, align: "center"},
|
||
{field: "sampleTime", title: "送样时间", unresize: true, align: "center"},
|
||
{field: "sampleTools", title: "送样设备", unresize: true, align: "center"},
|
||
{field: "collectSamplesUser", title: "收样人", unresize: true, align: "center"},
|
||
{field: "collectSamplesTime", title: "收样时间", unresize: true, align: "center"},
|
||
{
|
||
field: "teamName", title: "试验班组", unresize: true, align: "center", templet: function (d) {
|
||
let html = '';
|
||
let view ='';
|
||
if (d.teamName == null) {
|
||
view="<a style='cursor:pointer; background: #F2F3FF'' >未派工</a>";
|
||
} else {
|
||
view="<a style='color: black;'>" + d.teamName + "</a>";
|
||
}
|
||
html=view;
|
||
return html;
|
||
}
|
||
},
|
||
{title: "操作", unresize: true, width: 85, align: "center",
|
||
templet: function (d) {
|
||
|
||
let html = '';
|
||
let view="<a style='cursor:pointer;' onclick=\"addData('" + d.id + "')\">详情</a>";
|
||
html=view;
|
||
if(d.delFlag==1){
|
||
return '';
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
],
|
||
],
|
||
done: function (res, curr, count) {
|
||
layer.close(loadingMsg);
|
||
table.resize("table_data");
|
||
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
|
||
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
|
||
},
|
||
});
|
||
}
|
||
|
||
function handleClick1(sampleTools,devModule,devCode,experTime,nextExperTime,experUser,experConclu,customName) {
|
||
title = '合格证';
|
||
let param = {
|
||
'sampleTools' : sampleTools,
|
||
'devModule' : devModule,
|
||
'devCode' : devCode,
|
||
'experTime' : experTime,
|
||
'nextExperTime' : nextExperTime,
|
||
'experUser': experUser,
|
||
'experConclu': experConclu,
|
||
'customName': customName
|
||
}
|
||
openIframe2("addOrEditUser", title, "child/certificateView.html", '30%', '70%', param);
|
||
}
|
||
|
||
function handleClick2(view1) {
|
||
alert('Clicked on: ' + view1);
|
||
}
|
||
|
||
|
||
// 获取参数
|
||
function getReqParams(page, limit, type) {
|
||
var selectedValue =$('#sampleTools').val()
|
||
// 2. 查找对应的选项文本
|
||
var selectedText = $('#sampleTools option[value="' + selectedValue + '"]').text();
|
||
if (selectedText=='请选择设备类型'){
|
||
selectedText=''
|
||
}
|
||
let obj = {};
|
||
if (!type) {
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
sampleTools: selectedText,
|
||
collectSamplesUser:$('#collectSamplesUser').val(),
|
||
keyWord:$('#keyWord').val()
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: '1',
|
||
limit: '10',
|
||
sampleTools: '',
|
||
collectSamplesUser: '',
|
||
keyWord: ''
|
||
};
|
||
}
|
||
console.log(obj)
|
||
obj={
|
||
encryptedData:encryptCBC(JSON.stringify(obj))
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
// 查询/重置
|
||
function query() {
|
||
let pattern = new RegExp("[%_<>]");
|
||
if (pattern.test($("#loginName").val())) {
|
||
$("#loginName").val('');
|
||
return layer.msg('用户名查询包含特殊字符,请重新输入', {
|
||
icon: 2,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
});
|
||
}
|
||
if (pattern.test($("#phone").val())) {
|
||
$("#phone").val('');
|
||
return layer.msg('手机号查询包含特殊字符,请重新输入', {
|
||
icon: 2,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
});
|
||
}
|
||
pageNum = 1;
|
||
pages(1, limitSize);
|
||
}
|
||
|
||
|
||
//重置
|
||
function reset() {
|
||
pages(1, limitSize, 1)
|
||
}
|
||
|
||
|
||
function reloadData() {
|
||
pages(pageNum, limitSize);
|
||
}
|
||
|
||
// 新增/修改平台用户
|
||
function addData(id) {
|
||
if (id) {
|
||
title = '收样管理/详情';
|
||
}
|
||
let param = {
|
||
'id': id
|
||
}
|
||
openIframe2("addOrEditUser", title, "child/samplesForm.html", '100%', '100%', param);
|
||
}
|
||
|
||
/**
|
||
* 收样
|
||
*/
|
||
function collectSamples(id) {
|
||
title = '收样';
|
||
let param = {
|
||
'id': id
|
||
}
|
||
openIframe2("addOrEditUser", title, "child/samplesAdd.html", '70%', '90%', param);
|
||
}
|
||
|
||
|
||
/*下拉选表单赋值*/
|
||
function setSelectValue(list, selectName) {
|
||
console.log("list",list)
|
||
let html = '<option value="" selected>请选择设备类型</option>';
|
||
$.each(list, function (index, item) {
|
||
html += '<option value="' + item.id + '">' + item.name + '</option>';
|
||
})
|
||
$('#' + selectName).empty().append(html);
|
||
layui.form.render();
|
||
}
|