This commit is contained in:
parent
bbb3dde68d
commit
a7e665cee3
|
|
@ -48,6 +48,9 @@
|
|||
let headerRows;
|
||||
let layer, laydate, table, form;
|
||||
let tableLoading, tableIns;
|
||||
|
||||
// 定义一个列表的数据源 作为提交时参数
|
||||
let tableRowList = []
|
||||
$(function () {
|
||||
layui.use(['layer', 'laydate', 'table', 'form'], function () {
|
||||
layer = layui.layer;
|
||||
|
|
@ -125,6 +128,8 @@
|
|||
headerRows = [];
|
||||
headerRows = JSON.parse(data);
|
||||
|
||||
tableRowList = JSON.parse(msg)
|
||||
|
||||
// 定义弹框内需要的label
|
||||
const dialogLabelList = headerRows[1]
|
||||
const dialogLabelInfo = headerRows[2]
|
||||
|
|
@ -232,8 +237,8 @@
|
|||
text: '评价',
|
||||
type: 'button'
|
||||
});
|
||||
let fileList = []
|
||||
let uploadDom = []
|
||||
// let fileList = []
|
||||
let uploadDom = {}
|
||||
|
||||
// 将自定义元素插入到最后一个单元格
|
||||
div.append(customElement);
|
||||
|
|
@ -241,23 +246,22 @@
|
|||
customElement.on('click', function (event) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
let rowIndex = $(this).closest('tr').data('index')
|
||||
const tableList = JSON.parse(msg)
|
||||
|
||||
|
||||
// 组装dom
|
||||
let formHtml = `<div class="dialog-title">${tableList[rowIndex].proName}</div>`
|
||||
let innerHtml = ''
|
||||
let rowIndex = $(this).closest('tr').data('index')
|
||||
const curRows = tableRowList[rowIndex]
|
||||
dialogLabelList.forEach((e, index) => {
|
||||
fileList.push('')
|
||||
// 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}" id="uploadBtn${index}" style="color: #4CAF50; border: none; margin-left: 10px; cursor: pointer;">
|
||||
<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]}">
|
||||
<button type="button" data-index="${index}" data-id="${dialogLabelInfo[index].field}" 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"><i data-index="${index}" class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;"></i> </div>
|
||||
<div class="upload-success" id="upload-success_${index}" style="display:none"><i data-index="${rowIndex}" data-id="${dialogLabelInfo[index].field}" data-idx="${index} class="layui-icon" style="font-size: 18px; color: red; cursor: pointer;"></i> </div>
|
||||
</div>`
|
||||
|
||||
})
|
||||
|
|
@ -269,6 +273,7 @@
|
|||
</form>
|
||||
</div>`
|
||||
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['auto', 'auto'], // 宽高
|
||||
|
|
@ -289,9 +294,14 @@
|
|||
// 上传完毕回调
|
||||
console.log('文件上传成功');
|
||||
console.log(res);
|
||||
var dataIndex = $(this.elem).data('index');
|
||||
fileList[dataIndex] = res.obj
|
||||
var dataId = $(this.elem).data('id');
|
||||
|
||||
|
||||
|
||||
tableRowList[rowIndex][`${dataId}-file`] = {
|
||||
fileName: res.message,
|
||||
filePath: res.obj,
|
||||
}
|
||||
// 隐藏当前上传按钮
|
||||
$(`#uploadBtn${dataIndex}`).hide()
|
||||
$(`#upload-success_${dataIndex}`).show()
|
||||
|
|
@ -409,16 +419,23 @@
|
|||
|
||||
$(document).on('click', '.upload-success i', function () {
|
||||
var dataIndex = $(this).data('index');
|
||||
console.log('删除图标被点击,data-index:', dataIndex);
|
||||
var Index = $(this).data('idx');
|
||||
var dataId = $(this).data('id');
|
||||
// console.log('删除图标被点击,data-index:', dataIndex);
|
||||
|
||||
fileList[dataIndex] = ''
|
||||
// fileList[dataIndex] = ''
|
||||
// 执行删除操作
|
||||
|
||||
tableRowList[dataIndex][`${dataId}-file`] = {
|
||||
fileName: '',
|
||||
filePath: '',
|
||||
}
|
||||
// $(this).parent().remove()
|
||||
$(`#upload-success_${dataIndex}`).hide(function () {
|
||||
$(`#upload-success_${Index}`).hide(function () {
|
||||
// 当隐藏完之后,移除插入的内容
|
||||
$(`#upload-success_${dataIndex} .prepend-content`).remove();
|
||||
$(`#upload-success_${Index} .prepend-content`).remove();
|
||||
})
|
||||
$(`#uploadBtn${dataIndex}`).show()
|
||||
$(`#uploadBtn${Index}`).show()
|
||||
});
|
||||
tableLoading && layer.close(tableLoading);
|
||||
}
|
||||
|
|
@ -504,6 +521,9 @@
|
|||
}
|
||||
|
||||
function getTableData() {
|
||||
|
||||
console.log('tableRowList上传了', tableRowList)
|
||||
if (true) return
|
||||
//获取表格填写的数据
|
||||
var tableData = table.cache.baseTable;
|
||||
//校验所有单元格是否填写
|
||||
|
|
|
|||
Loading…
Reference in New Issue