Files
MES/app/views/Admin/employeeEdit.php
T
2026-08-08 18:28:49 +08:00

69 lines
3.4 KiB
PHP

<?php
$activeMenu = 'employee';
include APP_PATH . 'app/views/layouts/admin_header.php';
?>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-edit"></i> 编辑员工</h3>
</div>
<form method="post" action="">
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
<div class="box-body">
<div class="form-group">
<label>员工编号</label>
<input type="text" class="form-control" value="<?php echo htmlspecialchars($emp['emp_no']); ?>" disabled>
</div>
<div class="form-group">
<label>姓名</label>
<input type="text" name="emp_name" class="form-control" value="<?php echo htmlspecialchars($emp['emp_name']); ?>" required>
</div>
<div class="form-group">
<label>权限 <span class="text-danger">*</span></label>
<select name="role" id="roleSelect" class="form-control" onchange="toggleCategory()">
<?php
$roleNames = \core\base\Controller::ROLE_NAMES;
$manageableRoles = $manageableRoles ?? [\core\base\Controller::ROLE_OPERATOR, \core\base\Controller::ROLE_ADMIN];
foreach ($manageableRoles as $r):
?>
<option value="<?php echo $r; ?>" <?php echo ($emp['role'] ?? '') === $r ? 'selected' : ''; ?>><?php echo htmlspecialchars($roleNames[$r] ?? $r); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group" id="categoryGroup">
<label>管理类目 <span class="text-danger">*</span></label>
<select name="category" class="form-control">
<?php
$catNames = \core\base\Controller::CATEGORY_NAMES;
foreach ($catNames as $key => $name):
?>
<option value="<?php echo $key; ?>" <?php echo ($emp['category'] ?? 'mes') === $key ? 'selected' : ''; ?>><?php echo htmlspecialchars($name); ?></option>
<?php endforeach; ?>
</select>
</div>
<script>
function toggleCategory() {
var role = document.getElementById('roleSelect').value;
var catGroup = document.getElementById('categoryGroup');
if (role === 'super_admin') {
catGroup.style.display = 'none';
} else {
catGroup.style.display = 'block';
}
}
toggleCategory();
</script>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-warning"><i class="fa fa-save"></i> 更新</button>
<a href="<?php echo BASE_URL; ?>/Admin/employee" class="btn btn-default"><i class="fa fa-arrow-left"></i> 返回</a>
</div>
</form>
</div>
</div>
</div>
<?php include APP_PATH . 'app/views/layouts/admin_footer.php'; ?>