This commit is contained in:
parent
a17ee9951b
commit
d901dd313c
|
|
@ -223,43 +223,39 @@
|
|||
// $(this).append(fileDom);
|
||||
}
|
||||
|
||||
});
|
||||
if (index === cols.length - 1) {
|
||||
// let lastRow = tableView.find('tr').last(); // 找到最后一行
|
||||
// let lastCell = lastRow.find('td').last(); // 找到最后一个单元格
|
||||
// let div = lastCell.find('div')
|
||||
let div = $(this).find('div')
|
||||
|
||||
});
|
||||
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);
|
||||
// 创建自定义 DOM 元素
|
||||
let customElement = $('<button>', {
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
id: 'evaluate-btn',
|
||||
text: '评价',
|
||||
type: 'button'
|
||||
});
|
||||
let fileList = []
|
||||
let uploadDom = []
|
||||
|
||||
let lastRow = tableView.find('tr').last(); // 找到最后一行
|
||||
let lastCell = lastRow.find('td').last(); // 找到最后一个单元格
|
||||
let div = lastCell.find('div')
|
||||
// 将自定义元素插入到最后一个单元格
|
||||
div.append(customElement);
|
||||
|
||||
// 创建自定义 DOM 元素
|
||||
let customElement = $('<button>', {
|
||||
class: 'layui-btn layui-btn-sm',
|
||||
id: 'evaluate-btn',
|
||||
text: '评价',
|
||||
type: 'button'
|
||||
});
|
||||
let fileList = []
|
||||
let uploadDom = []
|
||||
|
||||
// 将自定义元素插入到最后一个单元格
|
||||
div.append(customElement);
|
||||
customElement.on('click', function (event) {
|
||||
event.stopPropagation()
|
||||
event.preventDefault()
|
||||
let rowIndex = $(this).closest('tr').data('index')
|
||||
const tableList = JSON.parse(msg)
|
||||
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 = ''
|
||||
dialogLabelList.forEach((e, index) => {
|
||||
fileList.push('')
|
||||
uploadDom.push('#uploadBtn' + index)
|
||||
innerHtml += `<div style="padding:6px 0;display: flex; align-items: center;">
|
||||
// 组装dom
|
||||
let formHtml = `<div class="dialog-title">${tableList[rowIndex].proName}</div>`
|
||||
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}" id="uploadBtn${index}" style="color: #4CAF50; border: none; margin-left: 10px; cursor: pointer;">
|
||||
|
|
@ -268,115 +264,126 @@
|
|||
<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>`
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
formHtml += `
|
||||
formHtml += `
|
||||
<div style="padding: 12px;">
|
||||
<form id="uploadForm">
|
||||
${innerHtml}
|
||||
</form>
|
||||
</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) {
|
||||
// 上传完毕回调
|
||||
console.log('文件上传成功');
|
||||
console.log(res);
|
||||
var dataIndex = $(this.elem).data('index');
|
||||
fileList[dataIndex] = res.obj
|
||||
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) {
|
||||
// 上传完毕回调
|
||||
console.log('文件上传成功');
|
||||
console.log(res);
|
||||
var dataIndex = $(this.elem).data('index');
|
||||
fileList[dataIndex] = res.obj
|
||||
|
||||
// 隐藏当前上传按钮
|
||||
$(`#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;"></i> </div>`);
|
||||
// $(this.elem).parent().append(newDom);
|
||||
},
|
||||
error: function () {
|
||||
// 请求异常回调
|
||||
console.log('文件上传失败');
|
||||
}
|
||||
})
|
||||
})
|
||||
// $('.uploadBtn').on('click', function (event) {
|
||||
// event.stopPropagation(); // 阻止事件冒泡
|
||||
// event.preventDefault(); // 阻止默认行为
|
||||
// console.log('上传附件按钮被点击了');
|
||||
// });
|
||||
|
||||
// 隐藏当前上传按钮
|
||||
$(`#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;"></i> </div>`);
|
||||
// $(this.elem).parent().append(newDom);
|
||||
},
|
||||
error: function () {
|
||||
// 请求异常回调
|
||||
console.log('文件上传失败');
|
||||
yes: function (index) {
|
||||
// 点击"确定"按钮时的逻辑
|
||||
|
||||
let formData = {};
|
||||
let fields = dialogLabelInfo.map((e) => e.field)
|
||||
$('#uploadForm input').each(function () {
|
||||
let inputValue = $(this).val();
|
||||
|
||||
if (parseFloat(inputValue) < 0) {
|
||||
layer.msg('请输入大于0的数字')
|
||||
return false
|
||||
}
|
||||
let dataId = $(this).data('id') // 获取 data-id
|
||||
if (dataId && inputValue) {
|
||||
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
|
||||
}
|
||||
})
|
||||
const currentRows = tableList[rowIndex]
|
||||
Object.assign(currentRows, formData)
|
||||
|
||||
currentRows.fileList = fileList
|
||||
let dataForm = {
|
||||
templateId: getUrlParam('templateId'),
|
||||
evaluateId: getUrlParam('id'),
|
||||
id: getUrlParam('detailsId'),
|
||||
jsonData: JSON.stringify([currentRows]),
|
||||
titleFiled: fields.join(','),
|
||||
}
|
||||
|
||||
console.log('提交时的formDat参数', dataForm)
|
||||
let path = getUrlParam("type") == '0' ? '/outsourcer/saveEvaluateData' : '/outsourcer/updateEvaluateData';
|
||||
$.ajax({
|
||||
url: ctxPath + path,
|
||||
type: 'post',
|
||||
data: dataForm,
|
||||
success: function (res) {
|
||||
if (res.res == '1') {
|
||||
layer.msg('保存成功');
|
||||
layer.close(index); // 关闭弹框
|
||||
initTable()
|
||||
} else {
|
||||
layer.msg(res.resMsg);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 这里可以执行你需要的操作
|
||||
|
||||
},
|
||||
btn2: function (index) {
|
||||
layer.close(index) // 关闭弹框
|
||||
return false
|
||||
}
|
||||
})
|
||||
})
|
||||
// $('.uploadBtn').on('click', function (event) {
|
||||
// event.stopPropagation(); // 阻止事件冒泡
|
||||
// event.preventDefault(); // 阻止默认行为
|
||||
// console.log('上传附件按钮被点击了');
|
||||
// });
|
||||
|
||||
},
|
||||
yes: function (index) {
|
||||
// 点击"确定"按钮时的逻辑
|
||||
|
||||
let formData = {};
|
||||
let fields = dialogLabelInfo.map((e) => e.field)
|
||||
$('#uploadForm input').each(function () {
|
||||
let inputValue = $(this).val();
|
||||
|
||||
if (parseFloat(inputValue) < 0) {
|
||||
layer.msg('请输入大于0的数字')
|
||||
return false
|
||||
}
|
||||
let dataId = $(this).data('id') // 获取 data-id
|
||||
if (dataId && inputValue) {
|
||||
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
|
||||
}
|
||||
})
|
||||
const currentRows = tableList[rowIndex]
|
||||
Object.assign(currentRows, formData)
|
||||
|
||||
currentRows.fileList = fileList
|
||||
let dataForm = {
|
||||
templateId: getUrlParam('templateId'),
|
||||
evaluateId: getUrlParam('id'),
|
||||
id: getUrlParam('detailsId'),
|
||||
jsonData: JSON.stringify([currentRows]),
|
||||
titleFiled: fields.join(','),
|
||||
}
|
||||
|
||||
console.log('提交时的formDat参数', dataForm)
|
||||
let path = getUrlParam("type") == '0' ? '/outsourcer/saveEvaluateData' : '/outsourcer/updateEvaluateData';
|
||||
$.ajax({
|
||||
url: ctxPath + path,
|
||||
type: 'post',
|
||||
data: dataForm,
|
||||
success: function (res) {
|
||||
if (res.res == '1') {
|
||||
layer.msg('保存成功');
|
||||
layer.close(index); // 关闭弹框
|
||||
initTable()
|
||||
} else {
|
||||
layer.msg(res.resMsg);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 这里可以执行你需要的操作
|
||||
|
||||
},
|
||||
btn2: function (index) {
|
||||
layer.close(index) // 关闭弹框
|
||||
return false
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue