This commit is contained in:
BianLzhaoMin 2025-02-27 11:09:01 +08:00
parent 56a1da65d2
commit 3edcfcd3b0
1 changed files with 20 additions and 5 deletions

View File

@ -52,6 +52,7 @@
// 定义一个列表的数据源 作为提交时参数
let tableRowList = []
let tableFieldList = []
let tableFieldValueList = []
$(function () {
layui.use(['layer', 'laydate', 'table', 'form'], function () {
layer = layui.layer;
@ -135,6 +136,7 @@
const dialogLabelList = headerRows[1]
const dialogLabelInfo = headerRows[2]
tableFieldList = dialogLabelInfo
tableFieldValueList = dialogLabelList
// Clear existing headers
const thead = document.querySelector('#baseTable thead');
@ -231,7 +233,7 @@
console.log(item1[`${dataId}-file`])
if (item1[`${dataId}-file`] && item1[`${dataId}-file`]['fileName']) {
$(this).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-right:6px"></i> `)
$(this).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-left:6px"></i> `)
}
}
@ -273,11 +275,11 @@
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-id="${dialogLabelInfo[index].field}" id="numberInput" name="numberInput" min="0.01" step="0.01" placeholder="请输入大于0的数字" style=";width:180px; padding:1px 5px;" value="${curRows[dialogLabelInfo[index].field]}">
<input type="text" data-value="${tableFieldValueList[index]['standardScore']}" data-id="${dialogLabelInfo[index].field}" id="numberInput" name="numberInput" min="0.01" step="0.01" placeholder="请输入大于0的数字" 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 ? 'none' : 'block'}">
+ 上传评分依据
</button>
<div class="upload-success" id="upload-success_${index}" style="display:${isFile ? 'block' : 'none'}">${isFile ? isFile.fileName : ''}<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 class="upload-success" id="upload-success_${index}" style="display:${isFile ? '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>`
})
@ -344,11 +346,24 @@
let fields = dialogLabelInfo.map((e) => e.field)
$('#uploadForm input').each(function () {
let inputValue = $(this).val();
let maxValue = $(this).data('value')
// if (parseFloat(inputValue) < 0) {
// layer.msg('请输入大于0的数字')
// return false
// }
if (parseFloat(inputValue) < 0) {
layer.msg('请输入大于0的数字')
const regex = /^\d+$/
if (!regex.test(parseFloat(inputValue))) {
layer.msg('请输入大于等于0的正整数')
return false
}
if (parseFloat(inputValue) > maxValue) {
layer.msg(`不可当前最大分值是${maxValue}`)
return false
}
let dataId = $(this).data('id') // 获取 data-id
if (dataId && inputValue) {
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值