专责审批代码调试

This commit is contained in:
BianLzhaoMin 2025-02-19 14:29:45 +08:00
parent eb0bc28afd
commit 8759bde930
3 changed files with 370 additions and 363 deletions

View File

@ -1,258 +1,340 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<link rel="stylesheet" href="../../../layui/css/layui.css"/>
<link rel="stylesheet" href="../../../layui/css/layui.css" />
</head>
<body>
<div class="layui-btn-group" style="margin-top: 10px;display: flex;justify-content: flex-end; margin-right: 10px;" id="btnGroup">
<button class="layui-btn layui-btn-sm" onclick="allAudit(1)" >全部通过</button>
<button class="layui-btn layui-btn-sm" onclick="allAudit(2)" >全部驳回</button>
</div>
<div id="txtTip" style="margin-top: 10px;display: flex;justify-content: flex-end;width: 99%;">注:如无审核按钮,则表示当前评价停留在一级审核处</div>
<form class="layui-form layui-form-pane fromData" action="">
<div style="width: 100%;overflow:auto">
<table class="layui-table" id="baseTable" lay-filter="test">
</table>
<div class="layui-btn-group" style="margin-top: 10px;display: flex;justify-content: flex-end; margin-right: 10px;"
id="btnGroup">
<button class="layui-btn layui-btn-sm" onclick="allAudit(1)">全部通过</button>
<button class="layui-btn layui-btn-sm" onclick="allAudit(2)">全部驳回</button>
</div>
<div class="layui-form-item" style="display: none">
<div class="layui-input-block">
<button type="submit" class="layui-btn subBtn" id="commit" lay-submit lay-filter="formDemo">提交
</button>
<div id="txtTip" style="margin-top: 10px;display: flex;justify-content: flex-end;width: 99%;">
注:如无审核按钮,则表示当前评价停留在一级审核处</div>
<form class="layui-form layui-form-pane fromData" action="">
<div style="width: 100%;overflow:auto">
<table class="layui-table" id="baseTable" lay-filter="test">
</table>
</div>
</div>
</form>
<script src="../../../js/publicJs.js"></script>
<script src="../../../js/common_methon.js"></script>
<script src="../../../js/common.js"></script>
<script type="text/javascript" src="../../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../../js/jq.js"></script>
<script type="text/javascript" src="../../../js/my/permission.js"></script>
<script src="../../../layui/layui.js"></script>
<script>
let noMessage = 0
let headerRows;
let layer, laydate, table, form;
let tableLoading;
$(function () {
layui.use(['layer', 'laydate', 'table', 'form'], function () {
layer = layui.layer;
laydate = layui.laydate;
table = layui.table;
form = layui.form;
tableLoading = layer.load(2, {shade: [0.1, '#fff']});
let deptId = getUrlParam('deptId');
isCheckOneIsAudit(deptId);
initTable(deptId);
form.on('submit(formDemo)', function (data) {
getTableData();
return false;
<div class="layui-form-item" style="display: none">
<div class="layui-input-block">
<button type="submit" class="layui-btn subBtn" id="commit" lay-submit lay-filter="formDemo">提交
</button>
</div>
</div>
</form>
<script src="../../../js/publicJs.js"></script>
<script src="../../../js/common_methon.js"></script>
<script src="../../../js/common.js"></script>
<script type="text/javascript" src="../../../js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../../js/jq.js"></script>
<script type="text/javascript" src="../../../js/my/permission.js"></script>
<script src="../../../layui/layui.js"></script>
<script>
let noMessage = 0
let headerRows;
let layer, laydate, table, form;
let tableLoading;
$(function () {
layui.use(['layer', 'laydate', 'table', 'form'], function () {
layer = layui.layer;
laydate = layui.laydate;
table = layui.table;
form = layui.form;
tableLoading = layer.load(2, { shade: [0.1, '#fff'] });
let deptId = getUrlParam('deptId');
isCheckOneIsAudit(deptId);
initTable(deptId);
form.on('submit(formDemo)', function (data) {
getTableData();
return false;
});
});
});
});
function isCheckOneIsAudit(deptId) {
$.ajax({
url: ctxPath + '/outsourcer/isCheckOneIsAudit',
type: 'get',
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
deptId: deptId,
evaluateType: '2',
type: 'auditAll',
},
success: function (res) {
if (res.res == '1') {
$("#btnGroup").show();
$("#txtTip").hide();
} else {
$("#btnGroup").hide();
}
if (getUrlParam("type") == '1'){
$("#btnGroup").hide();
$("#txtTip").hide();
}
}
})
}
function initTable(deptId) {
getTitle(deptId);
}
function setCols(data, msg) {
//重新加载表格 清空之前的表头和内容
table.reload('baseTable', {
cols: []
});
headerRows = [];
headerRows = JSON.parse(data);
// Clear existing headers
const thead = document.querySelector('#baseTable thead');
if (thead) {
thead.innerHTML = '';
} else {
const newThead = document.createElement('thead');
document.querySelector('#baseTable').appendChild(newThead);
}
//动态生成表头
headerRows.forEach(rowData => {
rowData.forEach(cellData => {
cellData.align = 'center';
if (cellData.title === '序号') {
cellData.type = 'numbers';
}
if (!['审核', '序号', '施工业务外包商', '工程名称','评价人','审批'].includes(cellData.title)) {
if (cellData.field.split('-').length === 1) {
cellData.title =
`${cellData.title}<i class="layui-icon layui-icon-tips layui-font-14" lay-event="checkTips"
title="计算方法" style="margin-left: 5px;"></i>`;
function isCheckOneIsAudit(deptId) {
$.ajax({
url: ctxPath + '/outsourcer/isCheckOneIsAudit',
type: 'get',
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
deptId: deptId,
evaluateType: '2',
type: 'auditAll',
},
success: function (res) {
if (res.res == '1') {
$("#btnGroup").show();
$("#txtTip").hide();
} else {
$("#btnGroup").hide();
}
if (getUrlParam("type") == '1') {
$("#btnGroup").hide();
$("#txtTip").hide();
}
}
if (cellData.mergeType === "colspan") {
cellData.colspan = cellData.num;
} else if (cellData.mergeType === "rowspan") {
cellData.rowspan = cellData.num;
}
if (getUrlParam("type") != '1'){
if (cellData.field === 'examineAndApprove') {
cellData.templet = function (d) {
console.log("ddddd:",d)
//如果d.isApprove == 1 去除当前行的编辑功能
let text = "";
if (d.isTwoApprove == 0 && d.isApprove == 1 ) {
text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
' id="pass">通过</a>';
text +=
'<a lay-event="reject" style="color: #a59e9e;cursor: pointer;font-size: 15px;margin-left: 10px"' +
' id="reject">驳回</a>';
}else{
if (d.isTwoApprove == 1 && d.isApprove == 1 ) {
})
}
function initTable(deptId) {
getTitle(deptId);
}
function setCols(data, msg) {
//重新加载表格 清空之前的表头和内容
table.reload('baseTable', {
cols: []
});
headerRows = [];
headerRows = JSON.parse(data);
// Clear existing headers
const thead = document.querySelector('#baseTable thead');
if (thead) {
thead.innerHTML = '';
} else {
const newThead = document.createElement('thead');
document.querySelector('#baseTable').appendChild(newThead);
}
//动态生成表头
headerRows.forEach(rowData => {
rowData.forEach(cellData => {
cellData.align = 'center';
if (cellData.title === '序号') {
cellData.type = 'numbers';
}
if (!['审核', '序号', '施工业务外包商', '工程名称', '评价人', '审批'].includes(cellData.title)) {
if (cellData.field.split('-').length === 1) {
cellData.title =
`${cellData.title}<i class="layui-icon layui-icon-tips layui-font-14" lay-event="checkTips"
title="计算方法" style="margin-left: 5px;"></i>`;
}
}
if (cellData.mergeType === "colspan") {
cellData.colspan = cellData.num;
} else if (cellData.mergeType === "rowspan") {
cellData.rowspan = cellData.num;
}
if (getUrlParam("type") != '1') {
if (cellData.field === 'examineAndApprove') {
cellData.templet = function (d) {
console.log("ddddd:", d)
//如果d.isApprove == 1 去除当前行的编辑功能
let text = "";
if (d.isTwoApprove == 0 && d.isApprove == 1) {
text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
' id="pass">通过</a>';
text +=
'<a lay-event="reject" style="color: #a59e9e;cursor: pointer;font-size: 15px;margin-left: 10px"' +
' id="reject">驳回</a>';
} else {
if (d.isTwoApprove == 1 && d.isApprove == 1) {
text += '<a style="color: #009688;cursor: pointer;font-size: 15px"' +
' id="pass">已通过</a>';
} else if (d.isTwoApprove == 2 && d.isApprove == 1) {
text += '<a style="color: #a59e9e;cursor: pointer;font-size: 15px"' +
' id="reject">已驳回</a>';
} else {
noMessage++
return ''
}
}
// text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
// ' id="pass">通过</a>';
// text +=
// '<a lay-event="reject" style="color: #a59e9e;cursor: pointer;font-size: 15px;margin-left: 10px"' +
// ' id="reject">驳回</a>';
return text;
}
}
} else {
if (cellData.field === 'examineAndApprove') {
cellData.templet = function (d) {
//如果d.isApprove == 1 去除当前行的编辑功能
let text = "";
if (d.isTwoApprove == 1) {
text += '<a style="color: #009688;cursor: pointer;font-size: 15px"' +
' id="pass">已通过</a>';
}else if (d.isTwoApprove == 2 && d.isApprove == 1 ) {
}
if (d.isTwoApprove == 2) {
text += '<a style="color: #a59e9e;cursor: pointer;font-size: 15px"' +
' id="reject">已驳回</a>';
}else{
noMessage++
return ''
}
// text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
// ' id="pass">通过</a>';
// text +=
// '<a lay-event="reject" style="color: #a59e9e;cursor: pointer;font-size: 15px;margin-left: 10px"' +
// ' id="reject">驳回</a>';
return text;
}
// text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
// ' id="pass">通过</a>';
// text +=
// '<a lay-event="reject" style="color: #a59e9e;cursor: pointer;font-size: 15px;margin-left: 10px"' +
// ' id="reject">驳回</a>';
return text;
}
}
}else{
if (cellData.field === 'examineAndApprove') {
cellData.templet = function (d) {
//如果d.isApprove == 1 去除当前行的编辑功能
let text = "";
if (d.isTwoApprove == 1) {
text += '<a style="color: #009688;cursor: pointer;font-size: 15px"' +
' id="pass">已通过</a>';
}
if (d.isTwoApprove == 2) {
text += '<a style="color: #a59e9e;cursor: pointer;font-size: 15px"' +
' id="reject">已驳回</a>';
}
// text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
// ' id="pass">通过</a>';
// text +=
// '<a lay-event="reject" style="color: #a59e9e;cursor: pointer;font-size: 15px;margin-left: 10px"' +
// ' id="reject">驳回</a>';
return text;
}
}
});
});
table.render({
elem: '#baseTable',
cols: headerRows,
data: JSON.parse(msg), // 使用从 API 获取的数据
//data: msg, // 使用从 API 获取的数据
loading: true,
done: function (res) {
var columsName = ['subName'];//需要合并的列名称 ['business_tenant_name','land','contract_begin','contract_end','history_arrears','period'];
var columsIndex = [1];//需要合并的列索引值 [2,3,5,6,14,15];
// res.data.sort(function (a, b) {
// return a.subName.localeCompare(b.subName);
// });
merge(res, columsName, columsIndex);
tableLoading && layer.close(tableLoading);
}
});
table.on('tool(test)', function (obj) {
var data = obj.data; //当前行数据
var rowIndex = obj.index;
var layEvent = obj.event; //当前点击的事件名
if (layEvent === 'pass') {
data.isTwoApprove = 1;
audit(obj, 1, data);
}
if (layEvent === 'reject') {
data.isTwoApprove = 2;
audit(obj, 2, data);
}
});
// 表头自定义元素工具事件 --- 2.8.8+
table.on('colTool(test)', function (obj) {
var event = obj.event;
if (event === 'checkTips') {
let text = `<span><span style="color: red">*</span>指标定义及计算方法:</span> ${obj.col.method}`;
text += `<br/><span><span style="color: red">*</span>积分标准:</span> ${obj.col.standard}`;
layer.alert(text, {
title: `${obj.col.title}`,
});
}
});
});
table.render({
elem: '#baseTable',
cols: headerRows,
data: JSON.parse(msg), // 使用从 API 获取的数据
//data: msg, // 使用从 API 获取的数据
loading: true,
done: function (res) {
var columsName = ['subName'];//需要合并的列名称 ['business_tenant_name','land','contract_begin','contract_end','history_arrears','period'];
var columsIndex = [1];//需要合并的列索引值 [2,3,5,6,14,15];
// res.data.sort(function (a, b) {
// return a.subName.localeCompare(b.subName);
// });
merge(res, columsName, columsIndex);
tableLoading && layer.close(tableLoading);
}
});
table.on('tool(test)', function (obj) {
var data = obj.data; //当前行数据
var rowIndex = obj.index;
var layEvent = obj.event; //当前点击的事件名
if (layEvent === 'pass') {
data.isTwoApprove = 1;
audit(obj, 1, data);
}
if (layEvent === 'reject') {
data.isTwoApprove = 2;
audit(obj, 2, data);
}
});
// 表头自定义元素工具事件 --- 2.8.8+
table.on('colTool(test)', function (obj) {
var event = obj.event;
if (event === 'checkTips') {
let text = `<span><span style="color: red">*</span>指标定义及计算方法:</span> ${obj.col.method}`;
text += `<br/><span><span style="color: red">*</span>积分标准:</span> ${obj.col.standard}`;
layer.alert(text, {
title: `${obj.col.title}`,
});
}
});
}
function allAudit(type) {
if (noMessage > 0){
layer.msg("当前页面评价驳回数据或者一级审核未通过数据,无法进行全部通过或者全部驳回操作 ")
return
}
let title = type === 1 ? '全部通过' : '全部驳回';
layer.confirm('确定'+title+'吗?', function (index) {
if(type === 1){
$.ajax({
url: ctxPath + '/outsourcer/allAudit',
type: 'post',
async: false,
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
type: type,
evaluateType: '2',
deptId: getUrlParam('deptId'),
isApprove: type
},
success: function (res) {
if (res.res == '1') {
parent.layer.closeAll();
parent.layer.msg(res.resMsg);
parent.getAuditBtn()
} else {
layer.msg(res.resMsg);
function allAudit(type) {
if (noMessage > 0) {
layer.msg("当前页面评价驳回数据或者一级审核未通过数据,无法进行全部通过或者全部驳回操作 ")
return
}
let title = type === 1 ? '全部通过' : '全部驳回';
layer.confirm('确定' + title + '吗?', function (index) {
if (type === 1) {
$.ajax({
url: ctxPath + '/outsourcer/dedicatedAllAudit',
type: 'post',
async: false,
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
type: type,
evaluateType: '2',
deptId: getUrlParam('deptId'),
isApprove: type
},
success: function (res) {
if (res.res == '1') {
parent.layer.closeAll();
parent.layer.msg(res.resMsg);
parent.getAuditBtn()
} else {
layer.msg(res.resMsg);
}
},
});
} else {
let content = '<div style="padding: 20px 100px;"><span style="color: red">*</span>' + title +
'原因:<input type="text" id="rejectReason" autocomplete="off" lay-verify="required" class="layui-input" style="width: 300px;height: 100px"></div>';
layer.open({
type: 1,
title: title,
content: content,
async: false,
btn: ['确定', '取消'],
yes: function (index, layero) {
let rejectReason = $('#rejectReason').val();
if (!rejectReason) {
layer.msg('请输入驳回原因');
return;
}
$.ajax({
url: ctxPath + '/outsourcer/dedicatedAllAudit',
type: 'post',
async: false,
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
type: type,
evaluateType: '2',
deptId: getUrlParam('deptId'),
isApprove: type,
rejectReason: rejectReason,
},
success: function (res) {
if (res.res == '1') {
parent.layer.closeAll();
parent.layer.msg(res.resMsg);
parent.getAuditBtn()
} else {
layer.msg(res.resMsg);
}
}
});
}
},
});
}
});
}
function audit(obj, type, status) {
let title = type === 1 ? '通过' : '驳回';
if (type == 1) {
layer.confirm('确定' + title + '吗?', function (index) {
$.ajax({
url: ctxPath + '/outsourcer/dedicatedAudit',
type: 'post',
async: false,
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
id: status.id,
type: type,
detailsId: status.detailsId,
evaluateType: '2'
},
success: function (res) {
if (res.res == '1') {
status.isTwoApprove = type;
obj.update(status);
layer.msg(res.resMsg);
} else {
status.isTwoApprove = 0;
layer.msg(res.resMsg);
}
}
});
});
}else{
} else {
let content = '<div style="padding: 20px 100px;"><span style="color: red">*</span>' + title +
'原因:<input type="text" id="rejectReason" autocomplete="off" lay-verify="required" class="layui-input" style="width: 300px;height: 100px"></div>';
'原因:<input type="text" id="rejectReason" autocomplete="off" lay-verify="required" class="layui-input" style="width: 300px;height: 100px"></div>';
layer.open({
type: 1,
title: title,
@ -266,25 +348,26 @@
return;
}
$.ajax({
url: ctxPath + '/outsourcer/allAudit',
url: ctxPath + '/outsourcer/dedicatedAudit',
type: 'post',
async: false,
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
id: status.id,
type: type,
detailsId: status.detailsId,
evaluateType: '2',
deptId: getUrlParam('deptId'),
isApprove: type,
rejectReason: rejectReason,
},
success: function (res) {
debugger
layer.close(index);
if (res.res == '1') {
parent.layer.closeAll();
parent.layer.msg(res.resMsg);
parent.getAuditBtn()
status.isTwoApprove = type;
obj.update(status);
layer.msg(res.resMsg);
} else {
status.isTwoApprove = 0;
layer.msg(res.resMsg);
}
}
@ -293,140 +376,61 @@
});
}
});
}
function audit(obj, type, status) {
let title = type === 1 ? '通过' : '驳回';
if(type == 1){
layer.confirm('确定'+title+'吗?', function (index) {
$.ajax({
url: ctxPath + '/outsourcer/audit',
type: 'post',
async: false,
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
id: status.id,
type: type,
detailsId: status.detailsId,
evaluateType: '2'
},
success: function (res) {
if (res.res == '1') {
status.isTwoApprove = type;
obj.update(status);
layer.msg(res.resMsg);
} else {
status.isTwoApprove = 0;
layer.msg(res.resMsg);
}
}
});
});
}else {
let content = '<div style="padding: 20px 100px;"><span style="color: red">*</span>' + title +
'原因:<input type="text" id="rejectReason" autocomplete="off" lay-verify="required" class="layui-input" style="width: 300px;height: 100px"></div>';
layer.open({
type: 1,
title: title,
content: content,
async: false,
btn: ['确定', '取消'],
yes: function (index, layero) {
let rejectReason = $('#rejectReason').val();
if (!rejectReason) {
layer.msg('请输入驳回原因');
return;
}
$.ajax({
url: ctxPath + '/outsourcer/audit',
type: 'post',
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
id: status.id,
type: type,
detailsId: status.detailsId,
evaluateType: '2',
rejectReason: rejectReason,
},
success: function (res) {
debugger
layer.close(index);
if (res.res == '1') {
status.isTwoApprove = type;
obj.update(status);
layer.msg(res.resMsg);
} else {
status.isTwoApprove = 0;
layer.msg(res.resMsg);
}
}
});
}
});
}
}
function getTitle(deptId) {
$.ajax({
url: ctxPath + '/outsourcer/getAuditTitleData',
type: 'get',
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
type: 'auditAll',
deptId: deptId
},
success: function (res) {
setCols(res.obj, res.resMsg);
}
function getTitle(deptId) {
$.ajax({
url: ctxPath + '/outsourcer/getAuditTitleData',
type: 'get',
data: {
})
}
function getTableData() {
//获取表格填写的数据
var tableData = table.cache.baseTable;
let filed = [];
//定义一个map
let obj = tableData[0];
for (let key in obj) {
if (key.indexOf('LAY') === -1 && !['subName', 'proName', 'subId', 'proId'].includes(key)) {
filed.push(key);
}
}
//TODO 校验数据
let data = {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
type: 'auditAll',
deptId: deptId
},
success: function (res) {
setCols(res.obj, res.resMsg);
}
})
}
function getTableData() {
//获取表格填写的数据
var tableData = table.cache.baseTable;
let filed = [];
//定义一个map
let obj = tableData[0];
for (let key in obj) {
if (key.indexOf('LAY') === -1 && !['subName', 'proName', 'subId', 'proId'].includes(key)) {
filed.push(key);
}
}
//TODO 校验数据
let data = {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('evaluateId'),
jsonData: JSON.stringify(tableData),
titleFiled: filed.join(',')
};
$.ajax({
url: ctxPath + '/outsourcer/saveEvaluateData',
type: 'post',
data: data,
success: function (res) {
if (res.res == '1') {
layer.msg('保存成功');
closePage();
} else {
layer.msg(res.resMsg);
jsonData: JSON.stringify(tableData),
titleFiled: filed.join(',')
};
$.ajax({
url: ctxPath + '/outsourcer/saveEvaluateData',
type: 'post',
data: data,
success: function (res) {
if (res.res == '1') {
layer.msg('保存成功');
closePage();
} else {
layer.msg(res.resMsg);
}
}
}
})
}
})
}
function closePage() {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
parent.search(1)
parent.layer.close(index); // 再执行关闭
}
</script>
function closePage() {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
parent.search(1)
parent.layer.close(index); // 再执行关闭
}
</script>

View File

@ -127,7 +127,7 @@
console.log("ddddd:", d)
//如果d.isApprove == 1 去除当前行的编辑功能
let text = "";
if (d.isTwoApprove == 0 && d.isApprove == 1) {
if (d.isTwoApprove == 1 && d.isApprove == 1) {
text += '<a lay-event="pass" style="color: #009688;cursor: pointer;font-size: 15px"' +
' id="pass">通过</a>';
text +=

View File

@ -142,4 +142,7 @@
};
$("#dt-table").treetable(option);
// 递归函数
</script>