|
|
@@ -19,12 +19,63 @@ class Procuremenexport extends Backend
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
+ $canExport = $this->hasProcuremenSiblingPerm(['export_month_outward', 'exportMonthOutward']);
|
|
|
+ $canDetails = $this->hasProcuremenSiblingPerm(['details']);
|
|
|
+ $this->view->assign('canExportMonthOutward', $canExport);
|
|
|
$this->assignconfig('procuremenAuth', [
|
|
|
- 'details' => $this->auth->check('procuremen/details'),
|
|
|
- 'export_month_outward' => $this->auth->check('procuremen/export_month_outward'),
|
|
|
+ 'details' => $canDetails,
|
|
|
+ 'export_month_outward' => $canExport,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 月度导出页引用的采购子权限(规则名在 procuremen 控制器下)
|
|
|
+ *
|
|
|
+ * @param string[] $actions
|
|
|
+ */
|
|
|
+ protected function hasProcuremenSiblingPerm(array $actions): bool
|
|
|
+ {
|
|
|
+ foreach ($actions as $action) {
|
|
|
+ $action = strtolower(trim((string)$action));
|
|
|
+ if ($action === '') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (strpos($action, 'procuremen/') !== 0) {
|
|
|
+ $action = 'procuremen/' . $action;
|
|
|
+ }
|
|
|
+ if ($this->auth->check($action)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $suffixes = [];
|
|
|
+ foreach ($actions as $action) {
|
|
|
+ $action = strtolower(trim((string)$action));
|
|
|
+ $action = preg_replace('#^procuremen/#', '', $action);
|
|
|
+ if ($action !== '') {
|
|
|
+ $suffixes[$action] = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($suffixes === []) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ foreach ($this->auth->getRuleList() as $rule) {
|
|
|
+ $rule = strtolower((string)$rule);
|
|
|
+ if (strpos($rule, 'procuremen/') !== 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach (array_keys($suffixes) as $suffix) {
|
|
|
+ if ($rule === 'procuremen/' . $suffix || strpos($rule, 'procuremen/' . $suffix . '/') === 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
public function index()
|
|
|
{
|
|
|
$this->relationSearch = false;
|