[FEAT] 實作角色權限分類、租戶角控管理與介面多語系優化

1. [FEAT] 權限劃分為「系統層級」與「客戶層級」,並在後端強制過濾跨權限分配。
2. [FEAT] 整合選單權限至主選單層級 (基本設定、權限設定),簡化角色管理 UI。
3. [STYLE] 側邊欄優化:補齊多語系翻譯,並為基本設定子選單增加視覺圖示。
4. [REFACTOR] 更新 RoleSeeder,將 tenant-admin 重新分類為客戶層級角色。
This commit is contained in:
2026-03-17 16:53:28 +08:00
parent 3ce88ed342
commit fc79148879
38 changed files with 2398 additions and 303 deletions

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('machine_models', function (Blueprint $table) {
$table->id();
$table->string('name')->comment('型號名稱');
$table->foreignId('company_id')->nullable()->constrained()->onDelete('cascade')->comment('關聯公司');
$table->foreignId('creator_id')->nullable()->constrained('users')->nullOnDelete()->comment('建立者');
$table->foreignId('updater_id')->nullable()->constrained('users')->nullOnDelete()->comment('修改者');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('machine_models');
}
};

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('payment_configs', function (Blueprint $table) {
$table->id();
$table->foreignId('company_id')->constrained()->onDelete('cascade')->comment('關聯公司');
$table->string('name')->comment('組合名稱');
$table->json('settings')->nullable()->comment('金流參數 (JSON)');
$table->foreignId('creator_id')->nullable()->constrained('users')->nullOnDelete()->comment('建立者');
$table->foreignId('updater_id')->nullable()->constrained('users')->nullOnDelete()->comment('修改者');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('payment_configs');
}
};

View File

@@ -0,0 +1,76 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('machines', function (Blueprint $table) {
$table->integer('card_reader_seconds')->nullable()->default(30)->comment('刷卡機秒數');
$table->time('card_reader_checkout_time_1')->nullable()->default('22:30:00')->comment('卡機結帳時間1');
$table->time('card_reader_checkout_time_2')->nullable()->default('23:45:00')->comment('卡機結帳時間2');
$table->time('heating_start_time')->default('00:00:00')->comment('開啟-加熱時間');
$table->time('heating_end_time')->default('00:00:00')->comment('關閉-加熱時間');
$table->integer('payment_buffer_seconds')->nullable()->default(5)->comment('金流緩衝時間(s)');
$table->string('card_reader_no')->nullable()->comment('刷卡機編號');
$table->string('key_no')->nullable()->comment('鑰匙編號');
$table->tinyInteger('invoice_status')->default(0)->comment('發票狀態碼: 0=不開發票, 1=預設捐, 2=預設不捐');
$table->boolean('welcome_gift_enabled')->default(0)->comment('來店禮開關');
$table->boolean('is_spring_slot_1_10')->default(0)->comment('貨道類型(1~10): 0=履帶, 1=彈簧');
$table->boolean('is_spring_slot_11_20')->default(0)->comment('貨道類型(11~20): 0=履帶, 1=彈簧');
$table->boolean('is_spring_slot_21_30')->default(0)->comment('貨道類型(21~30): 0=履帶, 1=彈簧');
$table->boolean('is_spring_slot_31_40')->default(0)->comment('貨道類型(31~40): 0=履帶, 1=彈簧');
$table->boolean('is_spring_slot_41_50')->default(0)->comment('貨道類型(41~50): 0=履帶, 1=彈簧');
$table->boolean('is_spring_slot_51_60')->default(0)->comment('貨道類型(51~60): 0=履帶, 1=彈簧');
$table->boolean('member_system_enabled')->default(0)->comment('會員系統開關');
$table->foreignId('payment_config_id')->nullable()->constrained('payment_configs')->nullOnDelete()->comment('關聯金流參數組合');
$table->foreignId('machine_model_id')->nullable()->constrained('machine_models')->nullOnDelete()->comment('關類型號組合');
$table->foreignId('creator_id')->nullable()->constrained('users')->nullOnDelete()->comment('建立者');
$table->foreignId('updater_id')->nullable()->constrained('users')->nullOnDelete()->comment('修改者');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('machines', function (Blueprint $table) {
$table->dropForeign(['payment_config_id']);
$table->dropForeign(['machine_model_id']);
$table->dropForeign(['creator_id']);
$table->dropForeign(['updater_id']);
$table->dropColumn([
'card_reader_seconds',
'card_reader_checkout_time_1',
'card_reader_checkout_time_2',
'heating_start_time',
'heating_end_time',
'payment_buffer_seconds',
'card_reader_no',
'key_no',
'invoice_status',
'welcome_gift_enabled',
'is_spring_slot_1_10',
'is_spring_slot_11_20',
'is_spring_slot_21_30',
'is_spring_slot_31_40',
'is_spring_slot_41_50',
'is_spring_slot_51_60',
'member_system_enabled',
'payment_config_id',
'machine_model_id',
'creator_id',
'updater_id',
]);
});
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('machines', function (Blueprint $table) {
$table->json('images')->after('firmware_version')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('machines', function (Blueprint $table) {
$table->dropColumn('images');
});
}
};

View File

@@ -31,9 +31,8 @@ class RoleSeeder extends Seeder
'menu.line',
'menu.reservation',
'menu.special-permission',
'menu.companies',
'menu.accounts',
'menu.roles',
'menu.basic-settings',
'menu.permissions',
];
foreach ($permissions as $permission) {
@@ -47,9 +46,23 @@ class RoleSeeder extends Seeder
);
$superAdmin->syncPermissions(Permission::all());
Role::updateOrCreate(
$tenantAdmin = Role::updateOrCreate(
['name' => 'tenant-admin'],
['is_system' => true]
['is_system' => false]
);
$tenantAdmin->syncPermissions([
'menu.members',
'menu.machines',
'menu.app',
'menu.warehouses',
'menu.sales',
'menu.analysis',
'menu.audit',
'menu.data-config',
'menu.remote',
'menu.line',
'menu.reservation',
'menu.special-permission',
]);
}
}