bug修改
This commit is contained in:
parent
cb0ab5cc93
commit
855c0b9ec9
|
|
@ -48,6 +48,7 @@
|
||||||
let headerRows;
|
let headerRows;
|
||||||
let layer, laydate, table, form;
|
let layer, laydate, table, form;
|
||||||
let tableLoading, tableIns;
|
let tableLoading, tableIns;
|
||||||
|
let targetFieldPrefixForNegativeInput = ''; // 新增:用于存储“加减分项”的字段前缀
|
||||||
|
|
||||||
// 定义一个列表的数据源 作为提交时参数
|
// 定义一个列表的数据源 作为提交时参数
|
||||||
let tableRowList = []
|
let tableRowList = []
|
||||||
|
|
@ -70,59 +71,6 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
function initTable() {
|
function initTable() {
|
||||||
// headerRows = [
|
|
||||||
// [
|
|
||||||
// {title: '序号', mergeType: "rowspan", num: 3, field: 'index'},
|
|
||||||
// {title: '施工业务外包商', mergeType: "rowspan", num: 3, field: 'subName'},
|
|
||||||
// {title: '工程名称', mergeType: "rowspan", num: 3, field: 'proName'},
|
|
||||||
// {title: '现场组织指标', mergeType: "colspan", num: 3},
|
|
||||||
// {title: '安全管理指标', mergeType: "colspan", num: 4},
|
|
||||||
// {title: '得分', mergeType: "rowspan", num: 3, field: 'score'}
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// {title: '入场人员达标率', mergeType: "rowspan", num: 1},
|
|
||||||
// {title: '管理人员到岗履职率', mergeType: "rowspan", num: 1},
|
|
||||||
// {title: '合计', field: 'total1', mergeType: "rowspan", num: 2},
|
|
||||||
// {title: '安全违章记分', mergeType: "colspan", num: 3},
|
|
||||||
// {title: '合计', field: 'total2', mergeType: "rowspan", num: 2}
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// {title: '项目部', field: 'dept1', mergeType: "rowspan", num: 1,edit: 'text'},
|
|
||||||
// {title: '项目部', field: 'dept2', mergeType: "rowspan", num: 1,edit: 'text'},
|
|
||||||
// {title: '项目部', field: 'dept3', mergeType: "rowspan", num: 1,edit: 'text'},
|
|
||||||
// {title: '事业部', field: 'dept4', mergeType: "rowspan", num: 1,edit: 'text'},
|
|
||||||
// {title: '安全监察部', field: 'dept5', mergeType: "rowspan", num: 1,edit: 'text'}
|
|
||||||
// ]
|
|
||||||
// ];
|
|
||||||
//
|
|
||||||
// const data = [
|
|
||||||
// {
|
|
||||||
// "subName": '外包商A',
|
|
||||||
// "proName": '工程A',
|
|
||||||
// "total1": 90,
|
|
||||||
// "dept1": 30,
|
|
||||||
// "dept2": 30,
|
|
||||||
// "dept3": 30,
|
|
||||||
// "total2": 80,
|
|
||||||
// "dept4": 40,
|
|
||||||
// "dept5": 40,
|
|
||||||
// "score": 85
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// "subName": '外包商B',
|
|
||||||
// "proName": '工程B',
|
|
||||||
// "total1": 85,
|
|
||||||
// "dept1": 25,
|
|
||||||
// "dept2": 30,
|
|
||||||
// "dept3": 30,
|
|
||||||
// "total2": 75,
|
|
||||||
// "dept4": 35,
|
|
||||||
// "dept5": 40,
|
|
||||||
// "score": 80
|
|
||||||
// }
|
|
||||||
// ];
|
|
||||||
// //渲染表格
|
|
||||||
// setCols(headerRows,data);
|
|
||||||
getTitle();
|
getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,6 +86,14 @@
|
||||||
tableFieldList = dialogLabelInfo
|
tableFieldList = dialogLabelInfo
|
||||||
tableFieldValueList = dialogLabelList
|
tableFieldValueList = dialogLabelList
|
||||||
|
|
||||||
|
// 根据一级标题“六、加减分项”找到对应的字段前缀
|
||||||
|
for (const col of headerRows[0]) {
|
||||||
|
if (col.title === '六、加减分项') {
|
||||||
|
targetFieldPrefixForNegativeInput = col.field;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clear existing headers
|
// Clear existing headers
|
||||||
const thead = document.querySelector('#baseTable thead');
|
const thead = document.querySelector('#baseTable thead');
|
||||||
if (thead) {
|
if (thead) {
|
||||||
|
|
@ -152,17 +108,6 @@
|
||||||
let dataList = rowData
|
let dataList = rowData
|
||||||
let href = window.location.href
|
let href = window.location.href
|
||||||
|
|
||||||
// if (index === 0 && !href.includes('type=1')) {
|
|
||||||
// let dataList = rowData
|
|
||||||
// dataList.splice(6, 0, {
|
|
||||||
// field: "handle",
|
|
||||||
// mergeType: "rowspan",
|
|
||||||
// minWidth: 75,
|
|
||||||
// num: 3,
|
|
||||||
// title: "操作",
|
|
||||||
// })
|
|
||||||
// // dataList.push()
|
|
||||||
// }
|
|
||||||
dataList.forEach(cellData => {
|
dataList.forEach(cellData => {
|
||||||
cellData.cellMinWidth = 120;
|
cellData.cellMinWidth = 120;
|
||||||
cellData.align = 'center';
|
cellData.align = 'center';
|
||||||
|
|
@ -173,7 +118,7 @@
|
||||||
if (cellData.field.split('-').length === 1) {
|
if (cellData.field.split('-').length === 1) {
|
||||||
cellData.title =
|
cellData.title =
|
||||||
`<span lay-event="checkTips">${cellData.title}<i class="layui-icon layui-icon-tips layui-font-14"
|
`<span lay-event="checkTips">${cellData.title}<i class="layui-icon layui-icon-tips layui-font-14"
|
||||||
title="计算方法" style="margin-left: 5px;"></i></span>`;
|
title="计算方法" style="margin-left: 5px;"></i></span>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cellData.mergeType === "colspan") {
|
if (cellData.mergeType === "colspan") {
|
||||||
|
|
@ -215,9 +160,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index === cols.length - 1) {
|
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')
|
let div = $(this).find('div')
|
||||||
|
|
||||||
// 创建自定义 DOM 元素
|
// 创建自定义 DOM 元素
|
||||||
|
|
@ -243,30 +185,28 @@
|
||||||
let innerHtml = ''
|
let innerHtml = ''
|
||||||
const curRows = tableRowList[rowIndex]
|
const curRows = tableRowList[rowIndex]
|
||||||
dialogLabelList.forEach((e, index) => {
|
dialogLabelList.forEach((e, index) => {
|
||||||
// fileList.push('')
|
|
||||||
|
|
||||||
isFile = null
|
isFile = null
|
||||||
if (curRows[`${dialogLabelInfo[index].field}-file`]) {
|
if (curRows[`${dialogLabelInfo[index].field}-file`]) {
|
||||||
isFile = curRows[`${dialogLabelInfo[index].field}-file`]
|
isFile = curRows[`${dialogLabelInfo[index].field}-file`]
|
||||||
}
|
}
|
||||||
uploadDom.push('#uploadBtn' + index)
|
uploadDom.push('#uploadBtn' + index)
|
||||||
innerHtml += `<div style="padding:6px 0;display: flex; align-items: center;">
|
innerHtml += `<div style="padding:6px 0;display: flex; align-items: center;">
|
||||||
<div style="margin-right: 10px;width: 200px";>${e.title}</div>
|
<div style="margin-right: 10px;width: 200px";>${e.title}</div>
|
||||||
<input type="text" data-value="${tableFieldValueList[index]['standardScore']}" data-id="${dialogLabelInfo[index].field}" name="numberInput" placeholder="请输入" style=";width:180px; padding:1px 5px;" value="${curRows[dialogLabelInfo[index].field]}">
|
<input type="text" data-value="${tableFieldValueList[index]['standardScore']}" data-id="${dialogLabelInfo[index].field}" name="numberInput" placeholder="请输入" 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 && isFile.fileName != '') ? 'none' : 'block'}">
|
<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 && isFile.fileName != '') ? 'none' : 'block'}">
|
||||||
+ 上传评分依据
|
+ 上传评分依据
|
||||||
</button>
|
</button>
|
||||||
<div class="upload-success" id="upload-success_${index}" style="display:${isFile && isFile.fileName != '' ? '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;"></i> </div>
|
<div class="upload-success" id="upload-success_${index}" style="display:${isFile && isFile.fileName != '' ? '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;"></i> </div>
|
||||||
</div>`
|
</div>`
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
formHtml += `
|
formHtml += `
|
||||||
<div style="padding: 12px;">
|
<div style="padding: 12px;">
|
||||||
<form id="uploadForm">
|
<form id="uploadForm">
|
||||||
${innerHtml}
|
${innerHtml}
|
||||||
</form>
|
</form>
|
||||||
</div>`
|
</div>`
|
||||||
|
|
||||||
|
|
||||||
layer.open({
|
layer.open({
|
||||||
|
|
@ -301,9 +241,6 @@
|
||||||
|
|
||||||
let hasIcon = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + dataId + ']').find('.layui-icon') > 0
|
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 {
|
} else {
|
||||||
layer.msg(res.resMsg)
|
layer.msg(res.resMsg)
|
||||||
}
|
}
|
||||||
|
|
@ -329,20 +266,40 @@
|
||||||
$('#uploadForm input[name="numberInput"]').each(function () {
|
$('#uploadForm input[name="numberInput"]').each(function () {
|
||||||
let inputValue = $(this).val().trim();
|
let inputValue = $(this).val().trim();
|
||||||
let maxValue = $(this).data('value')
|
let maxValue = $(this).data('value')
|
||||||
|
const currentDataId = $(this).data('id'); // 获取当前输入框的data-id
|
||||||
|
|
||||||
console.log('inputValueinputValueinputValue', inputValue)
|
let regex;
|
||||||
|
let errorMessage;
|
||||||
|
let inputTitle = '';
|
||||||
|
|
||||||
const regex = /^(0|[1-9]\d*)?$/
|
// 查找对应的标题
|
||||||
|
const dialogInfoIndex = dialogLabelInfo.findIndex(info => info.field === currentDataId);
|
||||||
|
if (dialogInfoIndex !== -1) {
|
||||||
|
inputTitle = dialogLabelList[dialogInfoIndex].title;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据dataId是否以“加减分项”的字段前缀开头来判断
|
||||||
|
if (currentDataId && currentDataId.startsWith(targetFieldPrefixForNegativeInput)) {
|
||||||
|
regex = /^-?(0|[1-9]\d*)?$/; // 允许负数和非负数整数
|
||||||
|
errorMessage = `【${inputTitle}】请输入整数`;
|
||||||
|
} else {
|
||||||
|
regex = /^(0|[1-9]\d*)?$/; // 只允许非负整数
|
||||||
|
errorMessage = `【${inputTitle}】请输入大于等于0的正整数`;
|
||||||
|
}
|
||||||
|
|
||||||
if (!regex.test(inputValue)) {
|
if (!regex.test(inputValue)) {
|
||||||
layer.msg('请输入大于等于0的正整数')
|
layer.msg(errorMessage);
|
||||||
isValidate = true
|
isValidate = true;
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
if (inputValue > maxValue) {
|
|
||||||
layer.msg(`不可当前最大分值是${maxValue}`)
|
// 新增:判断输入值的绝对值是否超过最大分值
|
||||||
isValidate = true
|
if (inputValue !== '' && !isNaN(Number(inputValue))) {
|
||||||
return false
|
if (Math.abs(Number(inputValue)) > maxValue) {
|
||||||
|
layer.msg(`【${inputTitle}】输入值不可超过最大分值${maxValue}`);
|
||||||
|
isValidate = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -359,8 +316,6 @@
|
||||||
const currentRows = tableRowList[rowIndex]
|
const currentRows = tableRowList[rowIndex]
|
||||||
Object.assign(currentRows, formData)
|
Object.assign(currentRows, formData)
|
||||||
|
|
||||||
// currentRows.fileList = fileList
|
|
||||||
|
|
||||||
for (let key in formData) {
|
for (let key in formData) {
|
||||||
let curTd = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + key + ']')
|
let curTd = tableView.find('tr[data-index=' + rowIndex + ']').find('td[data-field=' + key + ']')
|
||||||
|
|
||||||
|
|
@ -399,18 +354,12 @@
|
||||||
var dataIndex = $(this).data('index');
|
var dataIndex = $(this).data('index');
|
||||||
var Index = $(this).data('idx');
|
var Index = $(this).data('idx');
|
||||||
var dataId = $(this).data('id');
|
var dataId = $(this).data('id');
|
||||||
// console.log('删除图标被点击,data-index:', dataIndex);
|
|
||||||
|
|
||||||
// fileList[dataIndex] = ''
|
|
||||||
// 执行删除操作
|
|
||||||
|
|
||||||
tableRowList[dataIndex][`${dataId}-file`] = {
|
tableRowList[dataIndex][`${dataId}-file`] = {
|
||||||
fileName: '',
|
fileName: '',
|
||||||
filePath: '',
|
filePath: '',
|
||||||
}
|
}
|
||||||
// $(this).parent().remove()
|
|
||||||
$(`#upload-success_${Index}`).hide(function () {
|
$(`#upload-success_${Index}`).hide(function () {
|
||||||
// 当隐藏完之后,移除插入的内容
|
|
||||||
$(`#upload-success_${Index} .prepend-content`).remove();
|
$(`#upload-success_${Index} .prepend-content`).remove();
|
||||||
})
|
})
|
||||||
$(`#uploadBtn${Index}`).show()
|
$(`#uploadBtn${Index}`).show()
|
||||||
|
|
@ -467,43 +416,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTableData() {
|
function getTableData() {
|
||||||
|
|
||||||
|
|
||||||
/* for (var i = 0; i < tableRowList.length; i++) {
|
|
||||||
var item = tableRowList[i];
|
|
||||||
for (var key in item) {
|
|
||||||
if (key.indexOf("-") !== -1) {
|
|
||||||
if (item[key] === '' || item[key] === null) {
|
|
||||||
layer.msg('请对所有指标评价完成,再点击提交!');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
// //获取表格填写的数据
|
|
||||||
var tableData = table.cache.baseTable;
|
var tableData = table.cache.baseTable;
|
||||||
// //校验所有单元格是否填写
|
|
||||||
// for (var i = 0; i < tableData.length; i++) {
|
|
||||||
// var item = tableData[i];
|
|
||||||
// for (var key in item) {
|
|
||||||
// if (key.indexOf("-") !== -1) {
|
|
||||||
// if (item[key] === '' || item[key] === null) {
|
|
||||||
// layer.msg('请对所有指标评价完成,再点击提交!');
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// let filed = [];
|
|
||||||
// //定义一个map
|
|
||||||
// let obj = tableData[0];
|
|
||||||
// for (let key in obj) {
|
|
||||||
// if (key.indexOf("-") !== -1) {
|
|
||||||
// filed.push(key);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
let fields = tableFieldList.map((e) => e.field)
|
let fields = tableFieldList.map((e) => e.field)
|
||||||
if (getUrlParam("type") == '2') {
|
if (getUrlParam("type") == '2') {
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,14 @@
|
||||||
`<button class="layui-btn layui-btn-primary layui-border layui-btn-sm" onclick="openPage('${data[i].id}', '${data[i].name}','1')">${data[i].name}</button>`;
|
`<button class="layui-btn layui-btn-primary layui-border layui-btn-sm" onclick="openPage('${data[i].id}', '${data[i].name}','1')">${data[i].name}</button>`;
|
||||||
}
|
}
|
||||||
if (localStorage.getItem("AllAuditTitle") == '审核') {
|
if (localStorage.getItem("AllAuditTitle") == '审核') {
|
||||||
btn =
|
|
||||||
`<button class="layui-btn layui-btn-sm" onclick="openPage('${data[i].id}', '${data[i].name}','0')">${data[i].name}</button>`;
|
let isHide = getHide(data[i].id)
|
||||||
|
if(isHide){
|
||||||
|
btn = `<button class="layui-btn layui-btn-sm" onclick="openPage('${data[i].id}', '${data[i].name}','0')">${data[i].name}</button>`;
|
||||||
|
}else{
|
||||||
|
btn = `<button class="layui-btn layui-btn-primary layui-border layui-btn-sm" onclick="openPage('${data[i].id}', '${data[i].name}','0')">${data[i].name}</button>`;
|
||||||
|
}
|
||||||
|
// btn = `<button class="layui-btn layui-btn-sm" onclick="openPage('${data[i].id}', '${data[i].name}','0')">${data[i].name}</button>`;
|
||||||
}
|
}
|
||||||
btnGroup.append(btn);
|
btnGroup.append(btn);
|
||||||
}
|
}
|
||||||
|
|
@ -548,6 +554,51 @@
|
||||||
content: url,
|
content: url,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getHide(id){
|
||||||
|
let isHide = false;
|
||||||
|
$.ajax({
|
||||||
|
url: ctxPath + '/outsourcer/isCheckOneIsAudit',
|
||||||
|
type: 'get',
|
||||||
|
async:false,
|
||||||
|
data: {
|
||||||
|
templateId: getUrlParam('templateId'),
|
||||||
|
evaluateId: getUrlParam('evaluateId'),
|
||||||
|
deptId: id,
|
||||||
|
evaluateType: '3',
|
||||||
|
type: 'auditAll',
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
if (res.res == '1') {
|
||||||
|
isHide = true
|
||||||
|
$.ajax({
|
||||||
|
url: ctxPath + '/outsourcer/isCheckThreeIsAudit',
|
||||||
|
type: 'get',
|
||||||
|
async:false,
|
||||||
|
data: {
|
||||||
|
templateId: getUrlParam('templateId'),
|
||||||
|
evaluateId: getUrlParam('evaluateId'),
|
||||||
|
deptId: id,
|
||||||
|
evaluateType: '3',
|
||||||
|
type: 'auditAll',
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
debugger
|
||||||
|
if (res.res == '1') {
|
||||||
|
isHide =false;
|
||||||
|
}else{
|
||||||
|
isHide = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
isHide =false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return isHide;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue