This commit is contained in:
umono 2022-12-19 20:07:30 +08:00
parent 24d4c928c8
commit f1f38dae33
6 changed files with 57 additions and 6 deletions

View File

@ -32,8 +32,7 @@
"openspout/openspout": "3.7.4", "openspout/openspout": "3.7.4",
"ext-zip": "*", "ext-zip": "*",
"phpoffice/phpspreadsheet": "^1.25", "phpoffice/phpspreadsheet": "^1.25",
"gregwar/captcha": "^1.1", "gregwar/captcha": "^1.1"
"umono/yii2-multiple": "^0.1.0"
}, },
"provide": { "provide": {
"bower-asset/jquery": "*", "bower-asset/jquery": "*",

View File

@ -4,12 +4,13 @@
use app\modules\backend\api\Controller; use app\modules\backend\api\Controller;
use app\modules\backend\api\helpers\DeleteHelper; use app\modules\backend\api\helpers\DeleteHelper;
use app\modules\backend\api\helpers\ExportDeleteHelper;
class DeleteController extends Controller class DeleteController extends Controller
{ {
public function actionSelect() public function actionSelect()
{ {
DeleteHelper::go($this->param); ExportDeleteHelper::can(ExportDeleteHelper::DELETE,$this->param);
return $this->success(SUCCESS); return $this->success(SUCCESS);
} }
} }

View File

@ -3,6 +3,7 @@
namespace app\modules\backend\api\controllers; namespace app\modules\backend\api\controllers;
use app\modules\backend\api\Controller; use app\modules\backend\api\Controller;
use app\modules\backend\api\helpers\ExportDeleteHelper;
use umono\multiple\helpers\ExportHelper; use umono\multiple\helpers\ExportHelper;
class ExportController extends Controller class ExportController extends Controller
@ -12,11 +13,11 @@
*/ */
public function actionSelect() public function actionSelect()
{ {
return ExportHelper::exportSelect($this->param); return ExportDeleteHelper::can(ExportDeleteHelper::EXPORT_SELECT, $this->param);
} }
public function actionAll() public function actionAll()
{ {
return ExportHelper::exportAll($this->param); return ExportDeleteHelper::can(ExportDeleteHelper::EXPORT_ALL, $this->param);
} }
} }

View File

@ -0,0 +1,47 @@
<?php
namespace app\modules\backend\api\helpers;
use app\common\models\admin\AdminGroup;
use app\modules\backend\api\helpers\DeleteHelper;
use app\modules\backend\api\models\other\User;
use umono\multiple\helpers\ExportHelper;
use umono\multiple\interfacing\ExportDelete;
use yii\helpers\Inflector;
use yii\web\ForbiddenHttpException;
class ExportDeleteHelper
{
const DELETE = 'delete';
const EXPORT_SELECT = 'export-select';
const EXPORT_ALL = 'export-all';
public static function can($action, $param)
{
$model = ExportDelete::getModelClass($param['uid']);
$name = $model::camel2id();
$url = $name . '/' . $action;
if (\Yii::$app->user->id !== 1) {
$adminGroupId = \Yii::$app->user->getIdentity()->adminGroupId;
$permissions = AdminGroup::getPermissionsById($adminGroupId);
if (!AdminGroup::checkUrlInPermissions($url, $permissions)) {
throw new ForbiddenHttpException('您没有权限进行此操作');
}
}
switch ($action) {
case self::DELETE:
DeleteHelper::go($param);
break;
case self::EXPORT_SELECT:
return ExportHelper::exportSelect($param);
case self::EXPORT_ALL:
return ExportHelper::exportAll($param);
}
}
}

View File

@ -105,6 +105,7 @@ export default defineComponent({
const reload: any = inject("reload") const reload: any = inject("reload")
const store = useStore(); const store = useStore();
let loading: any = ref(false)
let toUrl: any = ref(''); let toUrl: any = ref('');
let toModel: any = ref({}); let toModel: any = ref({});
let showModal: any = ref(false); let showModal: any = ref(false);
@ -118,6 +119,7 @@ export default defineComponent({
watch(() => props.showModal, (val: boolean) => { watch(() => props.showModal, (val: boolean) => {
showModal.value = val; showModal.value = val;
loading.value = false;
}); });
watch(() => props.selectRowArr, (arr: any) => { watch(() => props.selectRowArr, (arr: any) => {
@ -190,11 +192,11 @@ export default defineComponent({
}) })
}); });
return { return {
loading,
name, name,
toUrl, toUrl,
toModel, toModel,
showModal, showModal,
loading: ref(false),
dragOptions, dragOptions,
dragData, dragData,
selectColumnArr, selectColumnArr,

View File

@ -51,6 +51,7 @@
<p> <n-button strong tertiary type="success" size="small" @click="item.child.push({})"> <p> <n-button strong tertiary type="success" size="small" @click="item.child.push({})">
添加权限</n-button> 添加权限</n-button>
</p> </p>
<p class="text-gray-400">每个实例模型对应都会有***/delete***/export-select***/export-all </p>
<n-table :single-line="false"> <n-table :single-line="false">
<thead> <thead>
<tr class="text-stone-400"> <tr class="text-stone-400">