班组注册
This commit is contained in:
parent
2c6f508f4f
commit
951dc7e672
|
|
@ -365,6 +365,7 @@ function setParams(id,index){
|
||||||
console.log("暂存班组成员信息数据:", groupMemberList)
|
console.log("暂存班组成员信息数据:", groupMemberList)
|
||||||
|
|
||||||
const submitData = {
|
const submitData = {
|
||||||
|
id:formData.id,
|
||||||
teamGroupName: formData.teamGroupName || "",
|
teamGroupName: formData.teamGroupName || "",
|
||||||
subContractor: formData.subContractor || "",
|
subContractor: formData.subContractor || "",
|
||||||
infoFileUrl: infoFileUrl || "",
|
infoFileUrl: infoFileUrl || "",
|
||||||
|
|
@ -598,21 +599,64 @@ function setParams(id,index){
|
||||||
initMemberInfo();
|
initMemberInfo();
|
||||||
|
|
||||||
// 删除操作
|
// 删除操作
|
||||||
$("#memberInfo").on("click", ".deleteBtn", function (e) {
|
/*$("#memberInfo").on("click", ".deleteBtn", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const index = $(this).attr("id").split("-")[1];
|
const index = $(this).attr("id").split("-")[1];
|
||||||
console.log("删除", index);
|
console.log("删除", index);
|
||||||
memberInfoList.splice(index, 1);
|
memberInfoList.splice(index, 1);
|
||||||
console.log("删除", memberInfoList);
|
console.log("删除", memberInfoList);
|
||||||
$(`#memberInfo-${index}`).remove();
|
$(`#memberInfo-${index}`).remove();
|
||||||
|
});*/
|
||||||
|
|
||||||
// 重新渲染所有成员信息以更新索引
|
// 删除操作
|
||||||
$("#memberInfo").empty()
|
$("#memberInfo").on("click", ".deleteBtn", function (e) {
|
||||||
memberInfoList.forEach((item, newIndex) => {
|
e.preventDefault();
|
||||||
constructMemberInfo(newIndex)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// 确保至少保留一个成员
|
||||||
|
if (memberInfoList.length <= 1) {
|
||||||
|
layer.msg("至少需要保留一个班组成员", { icon: 2, time: 2000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const index = parseInt($(this).attr("id").split("-")[1]);
|
||||||
|
console.log("删除", index);
|
||||||
|
|
||||||
|
// 从数组中移除对应的成员
|
||||||
|
memberInfoList.splice(index, 1);
|
||||||
|
console.log("删除后成员列表", memberInfoList);
|
||||||
|
|
||||||
|
// 移除对应的DOM元素
|
||||||
|
$(`#memberInfo-${index}`).remove();
|
||||||
|
|
||||||
|
// 重新构建所有成员信息的UI,以确保索引连续
|
||||||
|
rebuildMemberInfoUI();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 重新构建成员信息UI的函数
|
||||||
|
async function rebuildMemberInfoUI() {
|
||||||
|
// 清空容器
|
||||||
|
$("#memberInfo").empty();
|
||||||
|
|
||||||
|
// 重新构建所有成员项
|
||||||
|
for (let i = 0; i < memberInfoList.length; i++) {
|
||||||
|
await constructMemberInfo(i);
|
||||||
|
|
||||||
|
// 填充数据
|
||||||
|
const member = memberInfoList[i];
|
||||||
|
$(`#name-${i}`).val(member.name || "");
|
||||||
|
$(`#phone-${i}`).val(member.phone || "");
|
||||||
|
$(`#idCard-${i}`).val(member.idCard || "");
|
||||||
|
$(`#workType-${i}`).val(member.workType || "");
|
||||||
|
$(`#sex-${i}`).val(member.sex || "");
|
||||||
|
|
||||||
|
if (member.faceUrl) {
|
||||||
|
$(`#fileInfo-${i}`).html("已上传文件");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新渲染表单
|
||||||
|
form.render();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -345,44 +345,23 @@ layui.use(["table", "form", "upload", "tree"], function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("班组成员信息数据:", groupMemberList);
|
console.log("班组成员信息数据:", groupMemberList);
|
||||||
const formDataWithFile = new FormData();
|
|
||||||
|
|
||||||
formDataWithFile.append("teamGroupName", field.teamGroupName);
|
|
||||||
formDataWithFile.append("subContractor", field.subContractor);
|
|
||||||
formDataWithFile.append("infoFileUrl", infoFileUrl); // 信息评审表url
|
|
||||||
formDataWithFile.append("teamType", field.teamType);
|
|
||||||
formDataWithFile.append("name", field.name);
|
|
||||||
formDataWithFile.append("tableSource", "pm_dept");
|
|
||||||
formDataWithFile.append("level", 5); // 固定值
|
|
||||||
formDataWithFile.append("phone", field.phone);
|
|
||||||
formDataWithFile.append("idCard", field.idCard);
|
|
||||||
formDataWithFile.append("workType", field.workType);
|
|
||||||
formDataWithFile.append("sex", field.sex);
|
|
||||||
formDataWithFile.append("auditStatus", 1);
|
|
||||||
formDataWithFile.append("isTeamLeader", 0); // 固定值
|
|
||||||
formDataWithFile.append("faceUrl", file); // 人脸照片url
|
|
||||||
|
|
||||||
|
|
||||||
const submitData = {
|
const submitData = {
|
||||||
teamGroupName: field.teamGroupName,
|
teamGroupName: field.teamGroupName,
|
||||||
subContractor: field.subContractor,
|
subContractor: field.subContractor,
|
||||||
infoFileUrl: infoFileUrl,
|
infoFileUrl: infoFileUrl,
|
||||||
teamType: field.teamType,
|
teamType: field.teamType,
|
||||||
name: field.name,
|
name: $("#name").val(),
|
||||||
tableSource:"pm_dept",
|
tableSource:"pm_dept",
|
||||||
level: 5,
|
level: 5,
|
||||||
phone: field.phone,
|
phone: $("#phone").val(),
|
||||||
idCard: field.idCard,
|
idCard: $("#idCard").val(),
|
||||||
workType: field.workType,
|
workType: $("#workType").val(),
|
||||||
sex: field.sex,
|
sex: $("#sex").val(),
|
||||||
auditStatus: 1,
|
auditStatus: 1,
|
||||||
isTeamLeader: 0,
|
isTeamLeader: 0,
|
||||||
faceUrl: faceUrl, // 上传后返回的 URL
|
faceUrl: faceUrl, // 上传后返回的 URL
|
||||||
teamPersons: groupMemberList
|
teamPersons: groupMemberList
|
||||||
};
|
};
|
||||||
|
|
||||||
//班组成员信息
|
|
||||||
formDataWithFile.append("teamPersons", JSON.stringify(groupMemberList));
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: ctxPath + "/organizational/registerTeamGroup",
|
url: ctxPath + "/organizational/registerTeamGroup",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
|
@ -535,7 +514,7 @@ layui.use(["table", "form", "upload", "tree"], function () {
|
||||||
initMemberInfo();
|
initMemberInfo();
|
||||||
|
|
||||||
// 删除操作
|
// 删除操作
|
||||||
$("#memberInfo").on("click", ".deleteBtn", function (e) {
|
/* $("#memberInfo").on("click", ".deleteBtn", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const index = $(this).attr("id").split("-")[1];
|
const index = $(this).attr("id").split("-")[1];
|
||||||
console.log("删除", index);
|
console.log("删除", index);
|
||||||
|
|
@ -549,5 +528,55 @@ layui.use(["table", "form", "upload", "tree"], function () {
|
||||||
constructMemberInfo(newIndex)
|
constructMemberInfo(newIndex)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
});*/
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
$("#memberInfo").on("click", ".deleteBtn", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// 确保至少保留一个成员
|
||||||
|
if (memberInfoList.length <= 1) {
|
||||||
|
layer.msg("至少需要保留一个班组成员", { icon: 2, time: 2000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const index = parseInt($(this).attr("id").split("-")[1]);
|
||||||
|
console.log("删除", index);
|
||||||
|
|
||||||
|
// 从数组中移除对应的成员
|
||||||
|
memberInfoList.splice(index, 1);
|
||||||
|
console.log("删除后成员列表", memberInfoList);
|
||||||
|
|
||||||
|
// 移除对应的DOM元素
|
||||||
|
$(`#memberInfo-${index}`).remove();
|
||||||
|
|
||||||
|
// 重新构建所有成员信息的UI,以确保索引连续
|
||||||
|
rebuildMemberInfoUI();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 重新构建成员信息UI的函数
|
||||||
|
async function rebuildMemberInfoUI() {
|
||||||
|
// 清空容器
|
||||||
|
$("#memberInfo").empty();
|
||||||
|
|
||||||
|
// 重新构建所有成员项
|
||||||
|
for (let i = 0; i < memberInfoList.length; i++) {
|
||||||
|
await constructMemberInfo(i);
|
||||||
|
|
||||||
|
// 填充数据
|
||||||
|
const member = memberInfoList[i];
|
||||||
|
$(`#name-${i}`).val(member.name || "");
|
||||||
|
$(`#phone-${i}`).val(member.phone || "");
|
||||||
|
$(`#idCard-${i}`).val(member.idCard || "");
|
||||||
|
$(`#workType-${i}`).val(member.workType || "");
|
||||||
|
$(`#sex-${i}`).val(member.sex || "");
|
||||||
|
|
||||||
|
if (member.faceUrl) {
|
||||||
|
$(`#fileInfo-${i}`).html("已上传文件");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新渲染表单
|
||||||
|
form.render();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue