79 lines
3.3 KiB
HTML
79 lines
3.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-cn">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><%= title %></title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; background: #f7f7f7; margin: 0; padding: 0; }
|
|
.container { max-width: 400px; margin: 40px auto; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px #ddd; padding: 24px; }
|
|
h2 { text-align: center; margin-bottom: 24px; }
|
|
label { display: block; margin-bottom: 8px; font-weight: bold; }
|
|
input { width: 100%; padding: 8px; margin-bottom: 16px; border: 1px solid #ccc; border-radius: 4px; }
|
|
button { width: 100%; padding: 10px; background: #007bff; color: #fff; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; }
|
|
button:hover { background: #0056b3; }
|
|
.msg { margin-top: 16px; text-align: center; color: #28a745; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h2>打印台设置</h2>
|
|
<form id="printerForm">
|
|
<label for="warehouse">仓库ID</label>
|
|
<input type="text" id="warehouse" name="warehouse" required>
|
|
|
|
<label for="printer">打印台名称</label>
|
|
<input type="text" id="printer" name="printer" required>
|
|
|
|
<button type="submit">提交</button>
|
|
</form>
|
|
<div class="msg" id="msg"></div>
|
|
</div>
|
|
<script>
|
|
function showError(msg) {
|
|
const div = document.getElementById('msg');
|
|
div.textContent = msg;
|
|
div.style.color = '#fff';
|
|
div.style.background = '#dc3545';
|
|
div.style.padding = '8px';
|
|
div.style.borderRadius = '4px';
|
|
div.style.marginTop = '16px';
|
|
div.style.fontWeight = 'bold';
|
|
setTimeout(() => {
|
|
div.textContent = '';
|
|
div.style.background = '';
|
|
div.style.color = '#28a745';
|
|
div.style.padding = '';
|
|
div.style.borderRadius = '';
|
|
div.style.fontWeight = '';
|
|
}, 3000);
|
|
}
|
|
document.getElementById('printerForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
const warehouse = document.getElementById('warehouse').value;
|
|
const printer = document.getElementById('printer').value;
|
|
const code = '<%= code %>';
|
|
let msg = '';
|
|
try {
|
|
const res = await fetch('/auth/printSetting/', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ warehouse, printer, code })
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
msg = data.msg || '提交成功';
|
|
document.getElementById('msg').textContent = msg;
|
|
document.getElementById('msg').style.color = '#28a745';
|
|
document.getElementById('msg').style.background = '';
|
|
} else {
|
|
showError(data.error || '提交失败');
|
|
}
|
|
} catch (err) {
|
|
showError('网络错误,提交失败');
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|