This commit is contained in:
BianLzhaoMin 2025-02-27 11:22:01 +08:00
parent 3edcfcd3b0
commit f003a0c4be
1 changed files with 30 additions and 35 deletions

View File

@ -216,22 +216,8 @@
delete item.dataset.edit
let fileDom = '';
// 只要有文件列表并且文件列表数量大于0添加文件信息
// if (item1.fileList && item1.fileList.length > 0) {
// // 根据文件列表的索引判断将哪个文件添加到相应的列
// fileDom = `<span>${item1.fileList[index - 3]}</span>`;
// }
// console.log('fileDomfileDomfileDomfileDom', fileDom)
// // 将fileDom添加到当前单元格
// $(this).append(fileDom);
let dataId = $(this).data('field')
console.log(dataId)
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-left:6px"></i> `)
}
@ -310,33 +296,36 @@
multiple: false,
done: function (res) {
// 上传完毕回调
console.log('文件上传成功');
console.log(res);
var dataId = $(this.elem).data('id');
var dataIndex = $(this.elem).data('index');
tableRowList[rowIndex][`${dataId}-file`] = {
fileName: res.message,
filePath: res.obj,
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
if (!hasIcon) {
tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + dataId + ']').find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-left:6px"></i> `)
}
} else {
layer.msg(res.resMsg)
}
// 隐藏当前上传按钮
$(`#uploadBtn${dataIndex}`).hide()
$(`#upload-success_${dataIndex}`).show()
$(`#upload-success_${dataIndex}`).prepend(`<span class="prepend-content">${res.message}</span>`)
// 插入新的 DOM 元素,
// var newDom = $(`<div class="upload-success">${res.message}<i data-index="${dataIndex}" class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;">&#xe640;</i> </div>`);
// $(this.elem).parent().append(newDom);
},
error: function () {
// 请求异常回调
console.log('文件上传失败');
layer.msg('请求失败')
}
})
})
// $('.uploadBtn').on('click', function (event) {
// event.stopPropagation(); // 阻止事件冒泡
// event.preventDefault(); // 阻止默认行为
// console.log('上传附件按钮被点击了');
// });
},
yes: function (index) {
@ -344,6 +333,8 @@
let formData = {};
let fields = dialogLabelInfo.map((e) => e.field)
let isValidate = false
$('#uploadForm input').each(function () {
let inputValue = $(this).val();
let maxValue = $(this).data('value')
@ -356,10 +347,12 @@
if (!regex.test(parseFloat(inputValue))) {
layer.msg('请输入大于等于0的正整数')
isValidate = true
return false
}
if (parseFloat(inputValue) > maxValue) {
layer.msg(`不可当前最大分值是${maxValue}`)
isValidate = true
return false
}
@ -369,6 +362,8 @@
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
}
})
if (isValidate) return
const currentRows = tableRowList[rowIndex]
Object.assign(currentRows, formData)