|
|
@@ -19,12 +19,73 @@ class Procuremenarchive extends Backend
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
+ $canArchiveAbandon = $this->canArchiveAbandon();
|
|
|
+ $canDetails = $this->hasProcuremenSiblingPerm(['details']);
|
|
|
+ $this->view->assign('canArchiveAbandon', $canArchiveAbandon);
|
|
|
$this->assignconfig('procuremenAuth', [
|
|
|
- 'details' => $this->auth->check('procuremen/details'),
|
|
|
- 'archiveabandon' => $this->auth->check('procuremen/archiveabandon'),
|
|
|
+ 'details' => $canDetails,
|
|
|
+ 'archiveabandon' => $canArchiveAbandon,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 历史存证「重新下发」权限(规则名在 procuremen 控制器下)
|
|
|
+ */
|
|
|
+ protected function canArchiveAbandon(): bool
|
|
|
+ {
|
|
|
+ if ($this->hasProcuremenSiblingPerm(['archiveabandon', 'archiveAbandon'])) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->hasProcuremenSiblingPerm(['auditabandon', 'auditAbandon']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
+
|
|
|
/** purchase_order.status 为已完结(兼容 varchar / 数字 / 首尾空格) */
|
|
|
protected function applyPurchaseOrderCompletedWhere($query): void
|
|
|
{
|