hn_cloud_web/smz-web/js/work/smallSubManagement/contentAdjustForm.js

72 lines
2.4 KiB
JavaScript

var example = null;
var pers = null;
var form = null;
var lumpSumContractId = "";
function contentAdjustDetail(id){
lumpSumContractId = id;
layui.use(['layer', 'laydate', 'form'], function () {
form = layui.form;
form.render();
form.verify();
pers = checkPermission();
init(id);
form.on('submit(formDemo)', function (data) {
// 构造最终对象
const submitData = {
id: lumpSumContractId, // 转换为整数
type: "2",
gxInfo: $("#gxInfo").val()
};
// 提交到后端
$.ajax({
url: ctxPath + "/teamSmallBagDryTreaty/operContract", // 替换为你的实际接口
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(submitData),
success: function (res) {
if (res.res === 1) {
layer.msg("保存成功", { icon: 1, time: 2000 });
setTimeout("reloading()", 2001);
} else {
layer.msg(res.resMsg || "保存失败", { icon: 2, time: 2000 });
}
},
error: function (xhr, status, error) {
console.error("保存失败:", error);
layer.msg("网络错误,请重试", { icon: 5, time: 2000 });
}
});
return false; // 阻止表单刷新页面
});
});
}
function init(id) {
$.ajax({
type: 'get',
contentType: "application/x-www-form-urlencoded",
url: ctxPath + '/teamSmallBagDryTreaty/getDataDetail',
data: {"contractId":id},
dataType: 'json',
success: function (data) {
if (data.res === 1){
var data = data.obj.gxInfo;
$("#gxInfo").val(data);
layui.form.render();
}else{
layer.msg("未查询到", { icon: 2, time: 2000 });
}
},
error: function (xhr, status, error) {
console.error("请求失败:", error);
layer.msg("网络异常,请重试", { icon: 5, time: 2000 });
}
})
}
function reloading() {
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
window.parent.location.reload();
}