代码调试
This commit is contained in:
parent
138173ac71
commit
178b6af0e8
|
|
@ -238,6 +238,7 @@
|
|||
type: 'button'
|
||||
});
|
||||
let fileList = []
|
||||
let uploadDom = []
|
||||
|
||||
// 将自定义元素插入到最后一个单元格
|
||||
div.append(customElement);
|
||||
|
|
@ -253,13 +254,14 @@
|
|||
let innerHtml = ''
|
||||
dialogLabelList.forEach((e, index) => {
|
||||
fileList.push('')
|
||||
|
||||
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="${tableList[rowIndex][dialogLabelInfo[index].field]}">
|
||||
<button type="button" data-index="${index}" class="uploadBtn" id="uploadBtn${index}" style="color: #4CAF50; border: none; margin-left: 10px; cursor: pointer;">
|
||||
<button type="button" data-index="${index}" id="uploadBtn${index}" style="color: #4CAF50; border: none; margin-left: 10px; cursor: pointer;">
|
||||
+ 上传评分依据
|
||||
</button>
|
||||
<div class="upload-success" id="upload-success_${index}" style="display:none">${res.message}<i data-index="${index}" class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;"></i> </div>
|
||||
</div>`
|
||||
|
||||
})
|
||||
|
|
@ -283,24 +285,10 @@
|
|||
var upload = layui.upload;
|
||||
// 执行上传功能
|
||||
var uploadInst = upload.render({
|
||||
elem: '.uploadBtn',
|
||||
elem: uploadDom.join(','),
|
||||
url: ctxPath + '/upload/file',
|
||||
accept: 'file',
|
||||
multiple: false,
|
||||
auto: true, // 禁用自动上传,点击确定按钮后上传
|
||||
choose: function (obj) {
|
||||
|
||||
// 当选择文件时会触发这个方法
|
||||
obj.preview(function (index, file, result) {
|
||||
console.log(file); // 打印当前选择的文件
|
||||
});
|
||||
|
||||
var files = obj.pushFile()[obj.pushFile().length - 1] // 获取文件列表
|
||||
|
||||
console.log(files, 'files')
|
||||
return files
|
||||
|
||||
},
|
||||
done: function (res) {
|
||||
// 上传完毕回调
|
||||
console.log('文件上传成功');
|
||||
|
|
@ -310,10 +298,11 @@
|
|||
|
||||
// 隐藏当前上传按钮
|
||||
$(`#uploadBtn${dataIndex}`).hide()
|
||||
$('#upload-success_${dataIndex}').show()
|
||||
|
||||
// 插入新的 DOM 元素,
|
||||
var newDom = $(`<div class="upload-success">${res.message}<i data-index="${dataIndex}" class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;"></i> </div>`);
|
||||
$(this.elem).parent().append(newDom);
|
||||
// var newDom = $(`<div class="upload-success">${res.message}<i data-index="${dataIndex}" class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;"></i> </div>`);
|
||||
// $(this.elem).parent().append(newDom);
|
||||
},
|
||||
error: function () {
|
||||
// 请求异常回调
|
||||
|
|
@ -391,7 +380,8 @@
|
|||
|
||||
fileList[dataIndex] = ''
|
||||
// 执行删除操作
|
||||
$(this).parent().remove()
|
||||
// $(this).parent().remove()
|
||||
$('#upload-success_${dataIndex}').hide()
|
||||
$(`#uploadBtn${dataIndex}`).show()
|
||||
});
|
||||
tableLoading && layer.close(tableLoading);
|
||||
|
|
|
|||
Loading…
Reference in New Issue