初始化
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
$activeMenu = 'employee';
|
||||
include APP_PATH . 'app/views/layouts/admin_header.php';
|
||||
?>
|
||||
|
||||
<?php if ($saved): ?>
|
||||
<div class="alert alert-success alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-check"></i> 保存成功!</h4>
|
||||
员工 <strong><?php echo htmlspecialchars($emp['emp_name']); ?></strong> 的工位权限已更新。
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
<i class="fa fa-lock"></i>
|
||||
工位权限设置 -
|
||||
<strong><?php echo htmlspecialchars($emp['emp_name']); ?></strong>
|
||||
<small class="text-muted">(<?php echo htmlspecialchars($emp['emp_no']); ?>)</small>
|
||||
</h3>
|
||||
<div class="box-tools">
|
||||
<?php
|
||||
$roleNames = \core\base\Controller::ROLE_NAMES;
|
||||
$isAdminRole = ($emp['role'] === \core\base\Controller::ROLE_SUPER_ADMIN || $emp['role'] === \core\base\Controller::ROLE_ADMIN);
|
||||
$labelClass = $emp['role'] === \core\base\Controller::ROLE_SUPER_ADMIN ? 'danger' : ($emp['role'] === \core\base\Controller::ROLE_ADMIN ? 'warning' : 'info');
|
||||
?>
|
||||
<span class="label label-<?php echo $labelClass; ?>">
|
||||
<?php echo htmlspecialchars($roleNames[$emp['role']] ?? $emp['role']); ?>
|
||||
<?php echo $isAdminRole ? '(默认拥有全部权限)' : ''; ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" action="">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<div class="box-body">
|
||||
<?php if ($isAdminRole): ?>
|
||||
<div class="callout callout-info">
|
||||
<h4><i class="icon fa fa-info"></i> 提示</h4>
|
||||
<p>超级管理员和管理员默认拥有所有工位的访问权限,无需单独设置。</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="callout callout-warning">
|
||||
<h4><i class="icon fa fa-exclamation-triangle"></i> 权限说明</h4>
|
||||
<ul style="margin-bottom:0;">
|
||||
<li><strong>勾选</strong>:允许该员工访问对应工位</li>
|
||||
<li><strong>不勾选</strong>:该员工无法进入对应工位(前台左侧菜单不显示,直接访问会提示无权限)</li>
|
||||
<li>如果员工没有任何工位被勾选,则默认允许访问所有<strong>已启用</strong>工位</li>
|
||||
<li><span class="label label-danger">禁用</span> 状态的工位<strong>所有人都无法访问</strong>,即使勾选了也无效</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:60px;text-align:center;">
|
||||
<input type="checkbox" id="checkAll" onclick="toggleAll(this)">
|
||||
</th>
|
||||
<th style="width:60px;">#</th>
|
||||
<th>工位编码</th>
|
||||
<th>工位名称</th>
|
||||
<th>工位类型</th>
|
||||
<th style="width:80px;">状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($stations)): ?>
|
||||
<?php foreach ($stations as $i => $station):
|
||||
$stype = $station['station_type'];
|
||||
$isDisabled = $station['status'] == 0;
|
||||
$isChecked = isset($currentPermissions[$stype])
|
||||
? ($currentPermissions[$stype] === 1)
|
||||
: true; // 未配置时默认允许
|
||||
?>
|
||||
<tr class="<?php echo $isDisabled ? 'text-muted' : ''; ?>" style="<?php echo $isDisabled ? 'background:#f5f5f5;' : ''; ?>">
|
||||
<td style="text-align:center;">
|
||||
<input type="checkbox" name="allow[]" value="<?php echo htmlspecialchars($stype); ?>"
|
||||
class="station-check" <?php echo $isChecked ? 'checked' : ''; ?>>
|
||||
</td>
|
||||
<td><?php echo $i + 1; ?></td>
|
||||
<td><code><?php echo htmlspecialchars($station['station_code']); ?></code></td>
|
||||
<td>
|
||||
<?php echo htmlspecialchars($station['station_name']); ?>
|
||||
<?php if ($isDisabled): ?>
|
||||
<small class="text-danger"><i class="fa fa-ban"></i> 已禁用,权限无效</small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><span class="label label-default"><?php echo htmlspecialchars($stype); ?></span></td>
|
||||
<td>
|
||||
<?php if ($station['status'] == 1): ?>
|
||||
<span class="label label-success">启用</span>
|
||||
<?php else: ?>
|
||||
<span class="label label-danger">禁用</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr><td colspan="6" class="text-center text-muted">暂无工位数据,请先在「工位管理」中添加</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn btn-primary btn-lg">
|
||||
<i class="fa fa-save"></i> 保存权限设置
|
||||
</button>
|
||||
<a href="<?php echo BASE_URL; ?>/Admin/employee" class="btn btn-default btn-lg">
|
||||
<i class="fa fa-arrow-left"></i> 返回员工列表
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleAll(source) {
|
||||
var checkboxes = document.querySelectorAll('.station-check');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = source.checked;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php include APP_PATH . 'app/views/layouts/admin_footer.php'; ?>
|
||||
Reference in New Issue
Block a user