- = $this->render('../curd/content', [
+ = $this->render('../curd/_form', [
'model' => $model,
'form' => $form,
]); ?>
diff --git a/addons/RfExample/backend/views/mongo-db-curd/index.php b/addons/RfExample/backend/views/mongo-db-curd/index.php
index 8a5a7fe64..1e704f209 100644
--- a/addons/RfExample/backend/views/mongo-db-curd/index.php
+++ b/addons/RfExample/backend/views/mongo-db-curd/index.php
@@ -34,9 +34,9 @@
= $model['title']?> |
= Html::sort($model['sort']) ?> |
- = Html::edit(['edit', '_id' => $model['_id']]); ?>
+ = Html::edit(['edit', 'id' => $model['_id']]); ?>
= Html::status($model['status'] ?? 1); ?>
- = Html::delete(['delete', '_id' => $model['_id']]); ?>
+ = Html::delete(['delete', 'id' => $model['_id']]); ?>
|
diff --git a/addons/RfExample/common/models/MongoDbCurd.php b/addons/RfExample/common/models/MongoDbCurd.php
index 83415f471..e243febc6 100644
--- a/addons/RfExample/common/models/MongoDbCurd.php
+++ b/addons/RfExample/common/models/MongoDbCurd.php
@@ -1,9 +1,10 @@
'intval'],
[['author'], 'safe'],
];
@@ -60,6 +63,7 @@ public function attributeLabels()
{
return [
'_id' => 'ID',
+ 'merchant_id' => '商户ID',
'title' => '标题',
'sort' => '排序',
'status' => '状态',
@@ -71,20 +75,4 @@ public function attributeLabels()
'updated_at' => '更新时间',
];
}
-
- /**
- * @return array
- */
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
- ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
- ],
- ],
- ];
- }
}
\ No newline at end of file
diff --git a/addons/RfHelpers/backend/controllers/DataBaseController.php b/addons/RfHelpers/backend/controllers/DataBaseController.php
index b72efd2ca..b2f1af13d 100644
--- a/addons/RfHelpers/backend/controllers/DataBaseController.php
+++ b/addons/RfHelpers/backend/controllers/DataBaseController.php
@@ -81,6 +81,11 @@ public function actionExport()
// 读取备份配置
$config = $this->config;
+ // 检查备份目录是否可写
+ if (!is_writeable($config['path'])) {
+ return ResultDataHelper::json(404, '备份目录不存在或不可写,请检查后重试!');
+ }
+
// 检查是否有正在执行的任务
$lock = $config['path'] . $config['lock'];
if (is_file($lock)) {
@@ -90,11 +95,6 @@ public function actionExport()
// 创建锁文件
file_put_contents($lock, time());
- // 检查备份目录是否可写
- if (!is_writeable($config['path'])) {
- return ResultDataHelper::json(404, '备份目录不存在或不可写,请检查后重试!');
- }
-
// 生成备份文件信息
$file = [
'name' => date('Ymd-His', time()),
diff --git a/addons/RfHelpers/backend/views/data-base/backups.php b/addons/RfHelpers/backend/views/data-base/backups.php
index 72961ad46..cd609d023 100644
--- a/addons/RfHelpers/backend/views/data-base/backups.php
+++ b/addons/RfHelpers/backend/views/data-base/backups.php
@@ -229,9 +229,8 @@ function repair() {
if (this.checked) {
$("#list :checkbox").prop("checked", true);
} else {
- $("#list :checkbox").attr("checked", false);
+ $("#list :checkbox").prop("checked", false);
}
});
-
})
\ No newline at end of file
diff --git a/addons/RfMerchants/backend/controllers/RoleController.php b/addons/RfMerchants/backend/controllers/RoleController.php
index 8752f5a8f..efddeb6c4 100644
--- a/addons/RfMerchants/backend/controllers/RoleController.php
+++ b/addons/RfMerchants/backend/controllers/RoleController.php
@@ -3,13 +3,13 @@
namespace addons\RfMerchants\backend\controllers;
use Yii;
+use yii\data\ActiveDataProvider;
use common\helpers\ArrayHelper;
use common\components\Curd;
use common\models\common\AuthRole;
use common\enums\AppEnum;
use common\enums\AuthTypeEnum;
use common\helpers\ResultDataHelper;
-use yii\data\ActiveDataProvider;
/**
* Class RoleController
@@ -55,13 +55,6 @@ public function actionIndex()
'pagination' => false
]);
- foreach ($childRoles as &$childRole) {
- $role_id = $role['id'] ?? 0;
- if ($childRole['pid'] == $role_id) {
- $childRole['pid'] = 0;
- };
- }
-
$dataProvider->setModels($childRoles);
return $this->render('index', [
@@ -92,15 +85,36 @@ public function actionEdit()
}
// 创建角色关联的权限信息
- Yii::$app->services->authRole->accredit($model->id, $data['userTreeIds'] ?? [], AuthTypeEnum::TYPE_DEFAULT);
- Yii::$app->services->authRole->accredit($model->id, $data['plugTreeIds'] ?? [], AuthTypeEnum::TYPE_ADDONS);
+ Yii::$app->services->authRole->accredit($model->id, $data['userTreeIds'] ?? [], AuthTypeEnum::TYPE_DEFAULT, $this->appId);
+ Yii::$app->services->authRole->accredit($model->id, $data['plugTreeIds'] ?? [], AuthTypeEnum::TYPE_ADDONS, $this->appId);
return ResultDataHelper::json(200, '提交成功');
}
// 获取当前角色权限
- list($defaultFormAuth, $defaultCheckIds, $addonsFormAuth, $addonsCheckIds) = Yii::$app->services->authRole->getJsTreeData($id);
+ list($defaultFormAuth, $defaultCheckIds, $addonsFormAuth, $addonsCheckIds) = Yii::$app->services->authRole->getJsTreeData($id, $this->appId);
+
+ return $this->render($this->action->id, [
+ 'model' => $model,
+ 'defaultFormAuth' => $defaultFormAuth,
+ 'defaultCheckIds' => $defaultCheckIds,
+ 'addonsFormAuth' => $addonsFormAuth,
+ 'addonsCheckIds' => $addonsCheckIds,
+ 'dropDownList' => $this->getDropDownList($id),
+ 'merchant_id' => $this->merchant_id
+ ]);
+ }
+ /**
+ * 获取上级角色
+ *
+ * 注意:如果是其他应用则需要自行获取上级
+ *
+ * @param $id
+ * @return array
+ */
+ protected function getDropDownList($id)
+ {
// 获取父级
$role = Yii::$app->services->authRole->getRole();
$childRoles = Yii::$app->services->authRole->getChildList($this->appId, $role);
@@ -112,19 +126,10 @@ public function actionEdit()
}
$dropDownList = ArrayHelper::itemsMerge($childRoles, $role['pid'] ?? 0);
- $dropDownList = ArrayHelper::map(ArrayHelper::itemsMergeDropDown($dropDownList, 'id', 'title',
- $role['level'] ?? 1), 'id', 'title');
+ $dropDownList = ArrayHelper::map(ArrayHelper::itemsMergeDropDown($dropDownList, 'id', 'title', $role['level'] ?? 1), 'id', 'title');
Yii::$app->services->auth->isSuperAdmin() && $dropDownList = ArrayHelper::merge([0 => '顶级角色'], $dropDownList);
- return $this->render($this->action->id, [
- 'model' => $model,
- 'defaultFormAuth' => $defaultFormAuth,
- 'defaultCheckIds' => $defaultCheckIds,
- 'addonsFormAuth' => $addonsFormAuth,
- 'addonsCheckIds' => $addonsCheckIds,
- 'dropDownList' => $dropDownList,
- 'merchant_id' => $this->merchant_id
- ]);
+ return $dropDownList;
}
/**
diff --git a/addons/RfMerchants/backend/views/role/edit.php b/addons/RfMerchants/backend/views/role/edit.php
index 3c249ee5f..a9dd9c277 100644
--- a/addons/RfMerchants/backend/views/role/edit.php
+++ b/addons/RfMerchants/backend/views/role/edit.php
@@ -1,8 +1,8 @@
title = $model->isNewRecord ? '创建' : '编辑';
$this->params['breadcrumbs'][] = ['label' => '商户管理', 'url' => ['merchant/index']];
@@ -10,8 +10,6 @@
$this->params['breadcrumbs'][] = ['label' => $this->title];
?>
-= Html::cssFile('@web/resources/plugins/jsTree/style.min.css')?>
-
@@ -26,11 +24,23 @@
= $form->field($model, 'pid')->dropDownList($dropDownList) ?>
= $form->field($model, 'title')->textInput(); ?>
+ = $form->field($model, 'status')->radioList(StatusEnum::$listExplain); ?>
= $form->field($model, 'sort')->textInput(); ?>
- field($model, 'status')->radioList(StatusEnum::$listExplain); ?>
-
-
+
+ = \backend\widgets\jstree\JsTree::widget([
+ 'name' => "userTree",
+ 'defaultData' => $defaultFormAuth,
+ 'selectIds' => $defaultCheckIds,
+ ])?>
+
+
+ = \backend\widgets\jstree\JsTree::widget([
+ 'name' => "plugTree",
+ 'defaultData' => $addonsFormAuth,
+ 'selectIds' => $addonsCheckIds,
+ ])?>
+
-
-= Html::jsFile('@web/resources/plugins/jsTree/jstree.min.js')?>
-= $this->render('_footer')?>
+= $this->render('_footer') ?>
endBody() ?>