评价可以输入小数

This commit is contained in:
liang.chao 2025-07-29 18:05:28 +08:00
parent 6abf2eac19
commit a401aafbfa
6 changed files with 402 additions and 384 deletions

View File

@ -18,10 +18,7 @@ import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@ -406,8 +403,8 @@ public class OutsourcerEvaluateController extends BaseController<EvaluateSubBean
String deptId = UserUtil.getLoginUser().getDeptId();
o.setDeptId(deptId);
// 查询该部门是否都已评分
Integer num = outsourcerEvaluateDao.selectScore(o);
if (num > 0){
Integer num = outsourcerEvaluateDao.selectScore(o);
if (num > 0) {
ar.setFailMsg("部门评价未完成,请先评价");
return ar;
}
@ -678,7 +675,7 @@ public class OutsourcerEvaluateController extends BaseController<EvaluateSubBean
public AjaxRes updateJsonData(EvaluateDataBean o) {
AjaxRes ar = new AjaxRes();
try {
ar = outsourcerEvaluateDao.updateJsonData(o);
outsourcerEvaluateDao.updateJsonData(o);
} catch (Exception e) {
ar.setFailMsg(GlobalConst.DATA_FAIL);
}

View File

@ -107,7 +107,7 @@ public interface OutsourcerEvaluateDao {
List<EvaluateDataBean> getAuditBtn(EvaluateDataBean o);
AjaxRes updateJsonData(EvaluateDataBean o);
Integer updateJsonData(EvaluateDataBean o);
EvaluateDataBean getSummaryJsonData(EvaluateSubBean o);
@ -148,7 +148,7 @@ public interface OutsourcerEvaluateDao {
/**
* 重新
* @param o
* @param
*/
void updateEvalStatus(@Param("status") String status,@Param("id")String id);

View File

@ -441,19 +441,26 @@
Object.keys(map).forEach((key) => {
if (key.split('-').length === 3) {
if (key.startsWith(item)) {
subArr.push(parseInt(isEmpty(map[key]) ? '0' : map[key]));
subArr.push(parseFloat(isEmpty(map[key]) ? '0' : map[key]));
}
}
});
//计算小计
// if (twoLevelCountType === '最高分') {
// subTotals = Math.max(...subArr);
// } else if (twoLevelCountType === '平均分') {
// subTotals = (subArr.reduce((prev, curr) => {
// return prev + curr;
// }, 0) / subArr.length).toFixed(2);
// } else if (twoLevelCountType === '最低分') {
// subTotals = Math.min(...subArr);
// }
if (twoLevelCountType === '最高分') {
subTotals = Math.max(...subArr);
subTotals = Math.max(...subArr).toFixed(2);
} else if (twoLevelCountType === '平均分') {
subTotals = (subArr.reduce((prev, curr) => {
return prev + curr;
}, 0) / subArr.length).toFixed(2);
subTotals = (subArr.reduce((a, b) => a + b, 0) / subArr.length).toFixed(2);
} else if (twoLevelCountType === '最低分') {
subTotals = Math.min(...subArr);
subTotals = Math.min(...subArr).toFixed(2);
}
itemData[item + '-subtotal'] = subTotals;
subTotals = 0;

View File

@ -5,7 +5,7 @@
<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"/>
<style>
.dialog-title {
padding: 12px 6px;
@ -25,172 +25,172 @@
</head>
<body>
<form class="layui-form layui-form-pane fromData" action="">
<div style="width: 100%;overflow:auto">
<table class="layui-table" id="baseTable" lay-filter="baseTable" style="overflow-x: auto;">
</table>
<form class="layui-form layui-form-pane fromData" action="">
<div style="width: 100%;overflow:auto">
<table class="layui-table" id="baseTable" lay-filter="baseTable" style="overflow-x: auto;">
</table>
</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>
<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 headerRows;
let layer, laydate, table, form;
let tableLoading, tableIns;
let targetFieldPrefixForNegativeInput = ''; // 新增:用于存储“加减分项”的字段前缀
</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 headerRows;
let layer, laydate, table, form;
let tableLoading, tableIns;
let targetFieldPrefixForNegativeInput = ''; // 新增:用于存储“加减分项”的字段前缀
// 定义一个列表的数据源 作为提交时参数
let tableRowList = []
let tableFieldList = []
let tableFieldValueList = []
$(function () {
layui.use(['layer', 'laydate', 'table', 'form'], function () {
layer = layui.layer;
laydate = layui.laydate;
table = layui.table;
form = layui.form;
//自定义loading
tableLoading = layer.load(2, { shade: [0.1, '#fff'] });
initTable();
form.on('submit(formDemo)', function (data) {
getTableData();
return false;
});
// 定义一个列表的数据源 作为提交时参数
let tableRowList = []
let tableFieldList = []
let tableFieldValueList = []
$(function () {
layui.use(['layer', 'laydate', 'table', 'form'], function () {
layer = layui.layer;
laydate = layui.laydate;
table = layui.table;
form = layui.form;
//自定义loading
tableLoading = layer.load(2, {shade: [0.1, '#fff']});
initTable();
form.on('submit(formDemo)', function (data) {
getTableData();
return false;
});
});
});
function initTable() {
getTitle();
function initTable() {
getTitle();
}
function setCols(data, msg) {
headerRows = [];
headerRows = JSON.parse(data);
tableRowList = JSON.parse(msg)
// 定义弹框内需要的label
const dialogLabelList = headerRows[1]
const dialogLabelInfo = headerRows[2]
tableFieldList = dialogLabelInfo
tableFieldValueList = dialogLabelList
// 根据一级标题“六、加减分项”找到对应的字段前缀
for (const col of headerRows[0]) {
if (col.title === '六、加减分项') {
targetFieldPrefixForNegativeInput = col.field;
break;
}
}
function setCols(data, msg) {
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);
}
tableRowList = JSON.parse(msg)
//动态生成表头
headerRows.forEach((rowData, index) => {
let dataList = rowData
let href = window.location.href
// 定义弹框内需要的label
const dialogLabelList = headerRows[1]
const dialogLabelInfo = headerRows[2]
tableFieldList = dialogLabelInfo
tableFieldValueList = dialogLabelList
// 根据一级标题“六、加减分项”找到对应的字段前缀
for (const col of headerRows[0]) {
if (col.title === '六、加减分项') {
targetFieldPrefixForNegativeInput = col.field;
break;
dataList.forEach(cellData => {
cellData.cellMinWidth = 120;
cellData.align = 'center';
if (cellData.title === '序号') {
cellData.type = 'numbers';
}
}
// 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, index) => {
let dataList = rowData
let href = window.location.href
dataList.forEach(cellData => {
cellData.cellMinWidth = 120;
cellData.align = 'center';
if (cellData.title === '序号') {
cellData.type = 'numbers';
}
if (!['审核', '序号', '施工业务外包商', '工程名称', '评价人', '操作', '审批'].includes(cellData.title)) {
if (cellData.field.split('-').length === 1) {
cellData.title =
`<span lay-event="checkTips">${cellData.title}<i class="layui-icon layui-icon-tips layui-font-14"
if (!['审核', '序号', '施工业务外包商', '工程名称', '评价人', '操作', '审批'].includes(cellData.title)) {
if (cellData.field.split('-').length === 1) {
cellData.title =
`<span lay-event="checkTips">${cellData.title}<i class="layui-icon layui-icon-tips layui-font-14"
title="计算方法" style="margin-left: 5px;"></i></span>`;
}
}
if (cellData.mergeType === "colspan") {
cellData.colspan = cellData.num;
} else if (cellData.mergeType === "rowspan") {
cellData.rowspan = cellData.num;
}
// 去除审核
if (cellData.field === 'examineAndApprove' && href.includes('type=1')) {
cellData.hide = true;
}
});
}
if (cellData.mergeType === "colspan") {
cellData.colspan = cellData.num;
} else if (cellData.mergeType === "rowspan") {
cellData.rowspan = cellData.num;
}
// 去除审核
if (cellData.field === 'examineAndApprove' && href.includes('type=1')) {
cellData.hide = true;
}
});
tableIns = table.render({
elem: '#baseTable',
id: 'baseTable',
cols: headerRows,
data: JSON.parse(msg), // 使用从 API 获取的数据
cellMinWidth: 120, // 设置列的最小宽度以实现自适应
//data: msg, // 使用从 API 获取的数据
loading: true,
done: function (res) {
var tableView = this.elem.next();
layui.each(res.data, function (i, item1) {
if (item1.isApprove == '1') { // Condition to make the row non-editable
}
var cols = tableView.find('tr[data-index=' + i + ']').find('td');
cols.each(function (index, item) {
//对field为subNameproName 的列不进行设置
if (index > 2 && index != cols.length - 1) {
});
tableIns = table.render({
elem: '#baseTable',
id: 'baseTable',
cols: headerRows,
data: JSON.parse(msg), // 使用从 API 获取的数据
cellMinWidth: 120, // 设置列的最小宽度以实现自适应
//data: msg, // 使用从 API 获取的数据
loading: true,
done: function (res) {
var tableView = this.elem.next();
layui.each(res.data, function (i, item1) {
if (item1.isApprove == '1') { // Condition to make the row non-editable
console.log(item, 'item')
let dataId = $(this).data('field')
if (item1[`${dataId}-file`] && item1[`${dataId}-file`]['fileName'] != '') {
$(this).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b file-icon" data-index="${i}" data-id="${dataId}" style="margin-left:6px;cursor:pointer"></i> `)
}
}
var cols = tableView.find('tr[data-index=' + i + ']').find('td');
cols.each(function (index, item) {
//对field为subNameproName 的列不进行设置
if (index > 2 && index != cols.length - 1) {
console.log(item, 'item')
let dataId = $(this).data('field')
if (item1[`${dataId}-file`] && item1[`${dataId}-file`]['fileName'] != '') {
$(this).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b file-icon" data-index="${i}" data-id="${dataId}" style="margin-left:6px;cursor:pointer"></i> `)
}
}
if (index === cols.length - 1) {
let div = $(this).find('div')
if (index === cols.length - 1) {
let div = $(this).find('div')
// 创建自定义 DOM 元素
let customElement = $('<button>', {
class: 'layui-btn layui-btn-sm',
id: 'evaluate-btn',
text: '评价',
type: 'button'
});
let fileList = []
let uploadDom = []
// 创建自定义 DOM 元素
let customElement = $('<button>', {
class: 'layui-btn layui-btn-sm',
id: 'evaluate-btn',
text: '评价',
type: 'button'
});
let fileList = []
let uploadDom = []
// 将自定义元素插入到最后一个单元格
div.append(customElement);
// 将自定义元素插入到最后一个单元格
div.append(customElement);
customElement.on('click', function (event) {
event.stopPropagation()
event.preventDefault()
customElement.on('click', function (event) {
event.stopPropagation()
event.preventDefault()
// 组装dom
let rowIndex = $(this).closest('tr').data('index')
let formHtml = `<div class="dialog-title">${tableRowList[rowIndex].proName}</div>`
let innerHtml = ''
const curRows = tableRowList[rowIndex]
dialogLabelList.forEach((e, index) => {
isFile = null
if (curRows[`${dialogLabelInfo[index].field}-file`]) {
isFile = curRows[`${dialogLabelInfo[index].field}-file`]
}
uploadDom.push('#uploadBtn' + index)
innerHtml += `<div style="padding:6px 0;display: flex; align-items: center;">
// 组装dom
let rowIndex = $(this).closest('tr').data('index')
let formHtml = `<div class="dialog-title">${tableRowList[rowIndex].proName}</div>`
let innerHtml = ''
const curRows = tableRowList[rowIndex]
dialogLabelList.forEach((e, index) => {
isFile = null
if (curRows[`${dialogLabelInfo[index].field}-file`]) {
isFile = curRows[`${dialogLabelInfo[index].field}-file`]
}
uploadDom.push('#uploadBtn' + index)
innerHtml += `<div style="padding:6px 0;display: flex; align-items: center;">
<div style="margin-right: 10px;width: 200px";>${e.title}</div>
<input type="text" data-value="${tableFieldValueList[index]['standardScore']}" data-id="${dialogLabelInfo[index].field}" name="numberInput" placeholder="请输入" style=";width:180px; padding:1px 5px;" value="${curRows[dialogLabelInfo[index].field]}">
<button type="button" data-index="${index}" data-id="${dialogLabelInfo[index].field}" id="uploadBtn${index}" style="color: #4CAF50; border: none; margin-left: 10px; cursor: pointer;display:${(isFile && isFile.fileName != '') ? 'none' : 'block'}">
@ -199,9 +199,9 @@
<div class="upload-success" id="upload-success_${index}" style="display:${isFile && isFile.fileName != '' ? 'block' : 'none'}"><span class="prepend-content">${isFile ? isFile.fileName : ''}</span><i data-index="${rowIndex}" data-id="${dialogLabelInfo[index].field}" data-idx="${index}" class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;">&#xe640;</i> </div>
</div>`
})
})
formHtml += `
formHtml += `
<div style="padding: 12px;">
<form id="uploadForm">
${innerHtml}
@ -209,249 +209,249 @@
</div>`
layer.open({
type: 1,
area: ['auto', 'auto'], // 宽高
content: formHtml,
title: '评分',
btn: ['确定', '取消'],
success: function (layero, index) {
// 点击上传按钮的逻辑
layui.use('upload', function () {
var upload = layui.upload;
// 执行上传功能
var uploadInst = upload.render({
elem: uploadDom.join(','),
url: ctxPath + '/upload/file',
accept: 'file',
multiple: false,
done: function (res) {
// 上传完毕回调
if (res.res === 1) {
var dataId = $(this.elem).data('id');
var dataIndex = $(this.elem).data('index');
tableRowList[rowIndex][`${dataId}-file`] = {
fileName: res.message,
filePath: res.obj,
}
// 隐藏当前上传按钮
$(`#uploadBtn${dataIndex}`).hide()
$(`#upload-success_${dataIndex}`).show()
$(`#upload-success_${dataIndex}`).prepend(`<span class="prepend-content">${res.message}</span>`)
let hasIcon = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + dataId + ']').find('.layui-icon') > 0
} else {
layer.msg(res.resMsg)
layer.open({
type: 1,
area: ['auto', 'auto'], // 宽高
content: formHtml,
title: '评分',
btn: ['确定', '取消'],
success: function (layero, index) {
// 点击上传按钮的逻辑
layui.use('upload', function () {
var upload = layui.upload;
// 执行上传功能
var uploadInst = upload.render({
elem: uploadDom.join(','),
url: ctxPath + '/upload/file',
accept: 'file',
multiple: false,
done: function (res) {
// 上传完毕回调
if (res.res === 1) {
var dataId = $(this.elem).data('id');
var dataIndex = $(this.elem).data('index');
tableRowList[rowIndex][`${dataId}-file`] = {
fileName: res.message,
filePath: res.obj,
}
// 隐藏当前上传按钮
$(`#uploadBtn${dataIndex}`).hide()
$(`#upload-success_${dataIndex}`).show()
$(`#upload-success_${dataIndex}`).prepend(`<span class="prepend-content">${res.message}</span>`)
let hasIcon = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + dataId + ']').find('.layui-icon') > 0
},
error: function () {
layer.msg('请求失败')
} else {
layer.msg(res.resMsg)
}
})
},
error: function () {
layer.msg('请求失败')
}
})
})
},
yes: function (index) {
// 点击"确定"按钮时的逻辑
},
yes: function (index) {
// 点击"确定"按钮时的逻辑
let formData = {};
let fields = dialogLabelInfo.map((e) => e.field)
let formData = {};
let fields = dialogLabelInfo.map((e) => e.field)
let isValidate = false
$('#uploadForm input[name="numberInput"]').each(function () {
let inputValue = $(this).val().trim();
let maxValue = $(this).data('value')
const currentDataId = $(this).data('id'); // 获取当前输入框的data-id
let isValidate = false
$('#uploadForm input[name="numberInput"]').each(function () {
let inputValue = $(this).val().trim();
let maxValue = $(this).data('value')
const currentDataId = $(this).data('id'); // 获取当前输入框的data-id
let regex;
let errorMessage;
let inputTitle = '';
let regex;
let errorMessage;
let inputTitle = '';
// 查找对应的标题
const dialogInfoIndex = dialogLabelInfo.findIndex(info => info.field === currentDataId);
if (dialogInfoIndex !== -1) {
inputTitle = dialogLabelList[dialogInfoIndex].title;
}
// 查找对应的标题
const dialogInfoIndex = dialogLabelInfo.findIndex(info => info.field === currentDataId);
if (dialogInfoIndex !== -1) {
inputTitle = dialogLabelList[dialogInfoIndex].title;
}
// 根据dataId是否以“加减分项”的字段前缀开头来判断
if (currentDataId && currentDataId.startsWith(targetFieldPrefixForNegativeInput)) {
regex = /^-?(0|[1-9]\d*)?$/; // 允许负数和非负数整数
errorMessage = `【${inputTitle}】请输入整数`;
} else {
regex = /^(0|[1-9]\d*)?$/; // 只允许非负
errorMessage = `【${inputTitle}】请输入大于等于0的正数`;
}
// 根据dataId是否以“加减分项”的字段前缀开头来判断
if (currentDataId && currentDataId.startsWith(targetFieldPrefixForNegativeInput)) {
regex = /^-?(0|[1-9]\d*)(\.\d{1,2})?$/; // 允许负数和非负数(包含两位小数)
errorMessage = `【${inputTitle}】请输入最大为2位小数的数字或整数`;
} else {
regex = /^(0|[1-9]\d*)(\.\d{1,2})?$/; // 只允许非负数
errorMessage = `【${inputTitle}】请输入大于等于0的正数,并最大为2位小数`;
}
if (!regex.test(inputValue)) {
layer.msg(errorMessage);
if (!regex.test(inputValue)) {
layer.msg(errorMessage);
isValidate = true;
return false;
}
// 新增:判断输入值的绝对值是否超过最大分值
if (inputValue !== '' && !isNaN(Number(inputValue))) {
if (Math.abs(Number(inputValue)) > maxValue) {
layer.msg(`【${inputTitle}】输入值不可超过最大分值${maxValue}`);
isValidate = true;
return false;
}
}
// 新增:判断输入值的绝对值是否超过最大分值
if (inputValue !== '' && !isNaN(Number(inputValue))) {
if (Math.abs(Number(inputValue)) > maxValue) {
layer.msg(`【${inputTitle}】输入值不可超过最大分值${maxValue}`);
isValidate = true;
return false;
}
let dataId = $(this).data('id') // 获取 data-id
if (dataId && inputValue) {
console.log('inputValue=====', inputValue)
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
} else {
formData[dataId] = ''
}
})
if (isValidate) return
const currentRows = tableRowList[rowIndex]
Object.assign(currentRows, formData)
for (let key in formData) {
let curTd = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + key + ']')
if (curTd.length > 0) {
$(curTd).find('.layui-table-cell').text(formData[key])
let isIcon = $(curTd).find('.layui-table-cell').find('.layui-icon-file-b') > 0
if (tableRowList[rowIndex][`${key}-file`] && tableRowList[rowIndex][`${key}-file`]['fileName'] != '' && !isIcon) {
$(curTd).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-left:6px"></i> `)
}
let dataId = $(this).data('id') // 获取 data-id
if (dataId && inputValue) {
console.log('inputValue=====', inputValue)
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
} else {
formData[dataId] = ''
}
})
if (isValidate) return
const currentRows = tableRowList[rowIndex]
Object.assign(currentRows, formData)
for (let key in formData) {
let curTd = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + key + ']')
if (curTd.length > 0) {
$(curTd).find('.layui-table-cell').text(formData[key])
let isIcon = $(curTd).find('.layui-table-cell').find('.layui-icon-file-b') > 0
if (tableRowList[rowIndex][`${key}-file`] && tableRowList[rowIndex][`${key}-file`]['fileName'] != '' && !isIcon) {
$(curTd).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-left:6px"></i> `)
}
if (tableRowList[rowIndex][`${key}-file`] && tableRowList[rowIndex][`${key}-file`]['fileName'] == '' && isIcon) {
$(curTd).find('.layui-table-cell').find('layui-icon-file-b').remove()
}
if (tableRowList[rowIndex][`${key}-file`] && tableRowList[rowIndex][`${key}-file`]['fileName'] == '' && isIcon) {
$(curTd).find('.layui-table-cell').find('layui-icon-file-b').remove()
}
}
layer.msg('保存成功');
layer.close(index); // 关闭弹框
},
btn2: function (index) {
layer.close(index) // 关闭弹框
return false
}
})
});
}
layer.msg('保存成功');
layer.close(index); // 关闭弹框
});
});
var columsName = ['subName'];//需要合并的列名称 ['business_tenant_name','land','contract_begin','contract_end','history_arrears','period'];
var columsIndex = [1];//需要合并的列索引值 [2,3,5,6,14,15];
merge(res, columsName, columsIndex);
$(document).on('click', '.upload-success i', function () {
var dataIndex = $(this).data('index');
var Index = $(this).data('idx');
var dataId = $(this).data('id');
tableRowList[dataIndex][`${dataId}-file`] = {
fileName: '',
filePath: '',
},
btn2: function (index) {
layer.close(index) // 关闭弹框
return false
}
})
});
}
$(`#upload-success_${Index}`).hide(function () {
$(`#upload-success_${Index} .prepend-content`).remove();
})
$(`#uploadBtn${Index}`).show()
})
tableLoading && layer.close(tableLoading);
}
});
// 表头自定义元素工具事件 --- 2.8.8+
table.on('colTool(baseTable)', function (obj) {
const parentText = $(this).parent().text()
var event = obj.event;
if (event === 'checkTips' && parentText !== '审批') {
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}`,
});
}
});
}
$(document).on('click', '.layui-table-cell', function (e) {
console.log('点击了单元格')
// 判断是否有文件图标
if ($(this).find('.file-icon').length > 0) {
var dataId = $(this).find('.file-icon').data('id');
var dataIndex = $(this).find('.file-icon').data('index');
console.log('File icon clicked', {
dataIndex: dataIndex,
dataId: dataId,
rowData: tableRowList[dataIndex]
});
window.open(ctxPath + "/statics/" + tableRowList[dataIndex][`${dataId}-file`].filePath.split('/upload/')[1])
var columsName = ['subName'];//需要合并的列名称 ['business_tenant_name','land','contract_begin','contract_end','history_arrears','period'];
var columsIndex = [1];//需要合并的列索引值 [2,3,5,6,14,15];
merge(res, columsName, columsIndex);
$(document).on('click', '.upload-success i', function () {
var dataIndex = $(this).data('index');
var Index = $(this).data('idx');
var dataId = $(this).data('id');
tableRowList[dataIndex][`${dataId}-file`] = {
fileName: '',
filePath: '',
}
$(`#upload-success_${Index}`).hide(function () {
$(`#upload-success_${Index} .prepend-content`).remove();
})
$(`#uploadBtn${Index}`).show()
})
tableLoading && layer.close(tableLoading);
}
});
function getTitle() {
let path = getUrlParam("type") == '0' ? '/outsourcer/getTableTitle' : '/outsourcer/getAuditTitleData';
$.ajax({
url: ctxPath + path,
type: 'get',
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('id'),
type: 'evaluate'
},
success: function (res) {
setCols(res.obj, res.resMsg);
}
})
}
function getTableData() {
var tableData = table.cache.baseTable;
let fields = tableFieldList.map((e) => e.field)
if (getUrlParam("type") == '2') {
//对tableData进行处理 appraiser = 当前人
for (let i = 0; i < tableData.length; i++) {
tableRowList[i].appraiser = JSON.parse(localStorage.getItem('loginUser')).nickname;
}
// 表头自定义元素工具事件 --- 2.8.8+
table.on('colTool(baseTable)', function (obj) {
const parentText = $(this).parent().text()
var event = obj.event;
if (event === 'checkTips' && parentText !== '审批') {
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}`,
});
}
//TODO 校验数据
let data = {
});
}
$(document).on('click', '.layui-table-cell', function (e) {
console.log('点击了单元格')
// 判断是否有文件图标
if ($(this).find('.file-icon').length > 0) {
var dataId = $(this).find('.file-icon').data('id');
var dataIndex = $(this).find('.file-icon').data('index');
console.log('File icon clicked', {
dataIndex: dataIndex,
dataId: dataId,
rowData: tableRowList[dataIndex]
});
window.open(ctxPath + "/statics/" + tableRowList[dataIndex][`${dataId}-file`].filePath.split('/upload/')[1])
}
});
function getTitle() {
let path = getUrlParam("type") == '0' ? '/outsourcer/getTableTitle' : '/outsourcer/getAuditTitleData';
$.ajax({
url: ctxPath + path,
type: 'get',
data: {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('id'),
id: getUrlParam('detailsId'),
jsonData: JSON.stringify(tableRowList),
titleFiled: fields.join(',')
};
let path = getUrlParam("type") == '0' ? '/outsourcer/saveEvaluateData' : '/outsourcer/updateEvaluateData';
$.ajax({
url: ctxPath + path,
type: 'post',
data: data,
success: function (res) {
if (res.res == '1') {
layer.msg('保存成功');
closePage();
} else {
layer.msg(res.resMsg);
}
}
})
}
type: 'evaluate'
},
success: function (res) {
setCols(res.obj, res.resMsg);
}
function closePage() {
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
parent.search(1)
parent.layer.close(index); // 再执行关闭
})
}
function getTableData() {
var tableData = table.cache.baseTable;
let fields = tableFieldList.map((e) => e.field)
if (getUrlParam("type") == '2') {
//对tableData进行处理 appraiser = 当前人
for (let i = 0; i < tableData.length; i++) {
tableRowList[i].appraiser = JSON.parse(localStorage.getItem('loginUser')).nickname;
}
}
</script>
//TODO 校验数据
let data = {
templateId: getUrlParam('templateId'),
evaluateId: getUrlParam('id'),
id: getUrlParam('detailsId'),
jsonData: JSON.stringify(tableRowList),
titleFiled: fields.join(',')
};
let path = getUrlParam("type") == '0' ? '/outsourcer/saveEvaluateData' : '/outsourcer/updateEvaluateData';
$.ajax({
url: ctxPath + path,
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>

View File

@ -240,19 +240,26 @@
Object.keys(map).forEach((key) => {
if (key.split('-').length === 3) {
if (key.startsWith(item)) {
subArr.push(parseInt(isEmpty(map[key]) ? 0 : map[key]));
subArr.push(parseFloat(isEmpty(map[key]) ? 0 : map[key]));
}
}
});
//计算小计
// if (twoLevelCountType === '最高分') {
// subTotals = Math.max(...subArr);
// } else if (twoLevelCountType === '平均分') {
// subTotals = (subArr.reduce((prev, curr) => {
// return prev + curr;
// }, 0) / subArr.length).toFixed(2);
// } else if (twoLevelCountType === '最低分') {
// subTotals = Math.min(...subArr);
// }
if (twoLevelCountType === '最高分') {
subTotals = Math.max(...subArr);
subTotals = Math.max(...subArr).toFixed(2);
} else if (twoLevelCountType === '平均分') {
subTotals = (subArr.reduce((prev, curr) => {
return prev + curr;
}, 0) / subArr.length).toFixed(2);
subTotals = (subArr.reduce((a, b) => a + b, 0) / subArr.length).toFixed(2);
} else if (twoLevelCountType === '最低分') {
subTotals = Math.min(...subArr);
subTotals = Math.min(...subArr).toFixed(2);
}
itemData[item + '-subtotal'] = subTotals;
subTotals = 0;

View File

@ -252,12 +252,12 @@
Object.keys(map).forEach((key) => {
if (key.split('-').length === 3) {
if (key.startsWith(item)) {
subArr.push(parseInt(isEmpty(map[key]) ? 0 : map[key]));
subArr.push(parseFloat(isEmpty(map[key]) ? 0 : map[key]));
}
}
});
//计算小计
if (twoLevelCountType === '最高分') {
/* if (twoLevelCountType === '最高分') {
subTotals = Math.max(...subArr);
} else if (twoLevelCountType === '平均分') {
subTotals = (subArr.reduce((prev, curr) => {
@ -265,6 +265,13 @@
}, 0) / subArr.length).toFixed(2);
} else if (twoLevelCountType === '最低分') {
subTotals = Math.min(...subArr);
}*/
if (twoLevelCountType === '最高分') {
subTotals = Math.max(...subArr).toFixed(2);
} else if (twoLevelCountType === '平均分') {
subTotals = (subArr.reduce((a, b) => a + b, 0) / subArr.length).toFixed(2);
} else if (twoLevelCountType === '最低分') {
subTotals = Math.min(...subArr).toFixed(2);
}
itemData[item + '-subtotal'] = subTotals;
subTotals = 0;