Archived
58 lines
1.9 KiB
JavaScript
Executable File
58 lines
1.9 KiB
JavaScript
Executable File
function modify() {
|
|
if (!confirm("确认修改吗")) {
|
|
return
|
|
}
|
|
if (
|
|
basicToolType.value == "",
|
|
basicToolId.value == "",
|
|
platformName.value == "",
|
|
dangerLevel.value == "",
|
|
userName.value == ""
|
|
) {
|
|
alert("未填写完整")
|
|
return
|
|
}
|
|
|
|
if (!determineIfFieldValid()) {
|
|
alert("输入的危险等级不合法")
|
|
return
|
|
}
|
|
|
|
const basicToolTypeOld = document.getElementById("basic_tool_type_old")
|
|
const basicToolIdOld = document.getElementById("basic_tool_id_old")
|
|
const platformNameOld = document.getElementById("platform_name_old")
|
|
const userNameOld = document.getElementById("user_name_old")
|
|
const dangerLevelOld = document.getElementById("danger_level_old")
|
|
const userPasswordOld = document.getElementById("user_password_old")
|
|
const remarkOld = document.getElementById("remark_old")
|
|
const data = JSON.stringify({
|
|
basic_tool_type_old: basicToolTypeOld.value,
|
|
basic_tool_id_old: basicToolIdOld.value,
|
|
platform_name_old: platformNameOld.value,
|
|
danger_level_old: dangerLevelOld.value,
|
|
user_name_old: userNameOld.value,
|
|
user_password_old: userPasswordOld.value,
|
|
remark_old: remarkOld.value,
|
|
basic_tool_type: basicToolType.value,
|
|
basic_tool_id: basicToolId.value,
|
|
platform_name: platformName.value,
|
|
danger_level: dangerLevel.value,
|
|
user_name: userName.value,
|
|
user_password: userPassword.value,
|
|
remark: remark.value
|
|
});
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = true;
|
|
|
|
xhr.addEventListener('readystatechange', function () {
|
|
if (this.readyState === this.DONE) {
|
|
alert(this.responseText)
|
|
window.location = ""
|
|
}
|
|
});
|
|
|
|
xhr.open('PATCH', `http://${SERVER_IP}:${SERVER_PORT}/api/user`);
|
|
xhr.setRequestHeader('content-type', 'application/json');
|
|
xhr.send(data);
|
|
} |