Sfoglia il codice sorgente

新增首頁 修改權限 及 初始帳號

maa3520 2 anni fa
parent
commit
e252686054

+ 1 - 1
app/Http/Kernel.php

@@ -64,6 +64,6 @@ class Kernel extends HttpKernel
         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
         'abilities' => \Laravel\Sanctum\Http\Middleware\CheckAbilities::class,
-        //'ability' => \Laravel\Sanctum\Http\Middleware\CheckForAnyAbility::class,
+        'ability' => \Laravel\Sanctum\Http\Middleware\CheckForAnyAbility::class,
     ];
 }

+ 42 - 5
database/MAA.json

@@ -3309,19 +3309,56 @@
         "department_id": "J20"
     },
     {
-        "user_id": "northdept",
+        "user_id": "northdept1",
         "name": "北區",
         "department_id": "xxx"
     },
     {
-        "user_id": "centerdept",
+        "user_id": "northdept2",
+        "name": "北區",
+        "department_id": "xxx"
+    },
+    {
+        "user_id": "northdept3",
+        "name": "北區",
+        "department_id": "xxx"
+    },
+    {
+        "user_id": "northdept4",
+        "name": "北區",
+        "department_id": "xxx"
+    },
+    {
+        "user_id": "centerdept1",
+        "name": "中區",
+        "department_id": "xxx"
+    }, 
+    {
+        "user_id": "centerdept2",
         "name": "中區",
         "department_id": "xxx"
-    }, {
-        "user_id": "southdept",
+    }, 
+    {
+        "user_id": "centerdept3",
+        "name": "中區",
+        "department_id": "xxx"
+    }, 
+    {
+        "user_id": "southdept1",
         "name": "南區",
         "department_id": "xxx"
-    }, {
+    }, 
+    {
+        "user_id": "southdept2",
+        "name": "南區",
+        "department_id": "xxx"
+    }, 
+    {
+        "user_id": "southdept3",
+        "name": "南區",
+        "department_id": "xxx"
+    }, 
+    {
         "user_id": "host",
         "name": "主持人",
         "department_id": "xxx"

+ 39 - 18
database/seeders/DatabaseSeeder.php

@@ -25,32 +25,53 @@ class DatabaseSeeder extends Seeder
     public function run()
     {
         $admin = ["3520","3444","3606"];
+        $draw = ["2659"];
         User::truncate();
 
         $json = File::get("database/MAA.json");
         $countries = json_decode($json);
 
         foreach ($countries as $key => $value) {
-            $role = in_array($value->user_id, $admin) ? "Admin" : "User";
-            $role = $value->department_id == "xxx" ? "host" : $role;
-            User::create([
-                'user_id' => $value->user_id,
-                'name' => $value->name,
-                'department_id' => $value->department_id,
-                'password' => Hash::make($value->user_id),
-                'email' => $value->user_id." ".$value->name."/maa",
-                'account' => "maa".$value->user_id,
-                'role' => $role,
-            ]);
+            if(in_array($value->user_id, $admin) ){
+                $role ="Admin";
+            }else if(in_array($value->user_id, $draw)){
+                $role ="Draw";
+            }else{
+                $role = "User";
+            }
+            if($value->department_id == "xxx"){
+                $role = "Checkin";
+                User::create([
+                    'user_id' => $value->user_id,
+                    'name' => $value->name,
+                    'department_id' => $value->department_id,
+                    'password' => Hash::make($value->user_id),
+                    'email' => $value->user_id." ".$value->name."/maa",
+                    'account' => $value->user_id,
+                    'role' => $role,
+                ]);
+            }else{
+                User::create([
+                    'user_id' => $value->user_id,
+                    'name' => $value->name,
+                    'department_id' => $value->department_id,
+                    'password' => Hash::make($value->user_id),
+                    'email' => $value->user_id." ".$value->name."/maa",
+                    'account' => "maa".$value->user_id,
+                    'role' => $role,
+                ]);
+            }
+            
+            
 
         }
 
-        $this->call([
-            ActivitySeeder::class,
-            CheckInSeeder::class,
-            PrizeSeeder::class,
-            RecipientsSeeder::class,
-            DepartmentSeeder::class,
-        ]);
+        // $this->call([
+        //     ActivitySeeder::class,
+        //     CheckInSeeder::class,
+        //     PrizeSeeder::class,
+        //     RecipientsSeeder::class,
+        //     DepartmentSeeder::class,
+        // ]);
     }
 }

+ 1 - 1
resources/js/src/@core/layouts/components/AppBreadcrumb.vue

@@ -47,7 +47,7 @@
                 </b-dropdown-item>
             </b-dropdown>
 
-            <b-button v-if="this.userData.role == 'Admin' && this.$route.name == 'activityList'" variant="success"
+            <b-button v-if="this.userData && this.userData.role == 'Admin' && this.$route.name == 'activityList'" variant="success"
                 :to="{ name: 'activityStore' }">新增活動</b-button>
 
             <b-dropdown v-if="$can('mange', this.$route.name)" variant="link" no-caret toggle-class="p-0" right>

BIN
resources/js/src/assets/images/banner/home-1.jpg


BIN
resources/js/src/assets/images/banner/home-2.gif


BIN
resources/js/src/assets/images/banner/home-3.jpg


BIN
resources/js/src/assets/images/banner/home-4.jpg


BIN
resources/js/src/assets/images/banner/home-5.jpg


BIN
resources/js/src/assets/images/banner/home-6.jpg


BIN
resources/js/src/assets/images/banner/home-7.jpg


+ 1 - 2
resources/js/src/libs/acl/ability.js

@@ -33,7 +33,6 @@ export const defineRulesFor = (user) => {
             break;
         case 'User':
             can('read', 'all');
-            can('upload', 'blog')
             cannot('read', 'permission');
             cannot('read', '模板');
             cannot('read', '管理功能');
@@ -48,7 +47,7 @@ export const defineRulesFor = (user) => {
             break;
         default:
             cannot('manage', 'all');
-            can("read", 'Blog');
+            can('read', 'activityList');
             settings.routes.forEach(route => {
                 let requiresAuth = route && route.meta && route.meta.requiresAuth ? route.meta.requiresAuth : false;
                 if (route.name != undefined && !requiresAuth) {

+ 1 - 1
resources/js/src/navigation/vertical/index.js

@@ -2,7 +2,7 @@ export default [{
         header: '基本功能',
     },
     {
-        title: 'Home',
+        title: '首頁',
         route: 'home',
         icon: 'HomeIcon',
     },

+ 4 - 4
resources/js/src/router/config.js

@@ -12,9 +12,9 @@ export const settings = {
             name: 'home',
             component: () => import('@/views/Home.vue'),
             meta: {
-                pageTitle: 'Home',
+                pageTitle: '首頁',
                 breadcrumb: [{
-                    text: 'Home',
+                    text: '首頁',
                     active: true,
                 }, ],
             },
@@ -29,7 +29,7 @@ export const settings = {
                     text: '活動列表',
                     active: true,
                 }, ],
-                requiresAuth: true,
+                requiresAuth: false,
             },
         },
         {
@@ -47,7 +47,7 @@ export const settings = {
                         active: true,
                     },
                 ],
-                requiresAuth: true,
+                requiresAuth: false,
             },
         },
         {

+ 72 - 23
resources/js/src/views/Home.vue

@@ -1,34 +1,83 @@
-<template>
-  <div>
-    <b-card title="Kick start your project 🚀">
-      <b-card-text>All the best for your new project.</b-card-text>
-      <b-card-text>Please make sure to read our <b-link
-        href="https://pixinvent.com/demo/vuexy-vuejs-admin-dashboard-template/documentation/guide/development/installation.html"
-        target="_blank"
-      >
-        Template Documentation
-      </b-link> to understand where to go from here and how to use our template.</b-card-text>
-    </b-card>
-
-    <b-card title="Want to integrate JWT? 🔒">
-      <b-card-text>We carefully crafted JWT flow so you can implement JWT with ease and with minimum efforts.</b-card-text>
-      <b-card-text>Please read our  JWT Documentation to get more out of JWT authentication.</b-card-text>
-    </b-card>
-  </div>
+<template md="12" sm="12">
+  <b-card>
+    <swiper
+      class="swiper-autoplay"
+      :options="swiperOptions"
+      :dir="$store.state.appConfig.isRTL ? 'rtl' : 'ltr'">
+      <swiper-slide
+        v-for="data in swiperData"
+        :key="data.img">
+        <a :href="data.href" target="_blank">
+          <b-img
+            style="display: block;
+        margin-left: auto;
+        margin-right: auto;
+        width: 80%;"
+            :src="data.img"
+            fluid />
+        </a>
+      </swiper-slide>
+      <div
+        slot="pagination"
+        class="swiper-pagination" />
+      <div
+        slot="button-next"
+        class="swiper-button-next" />
+      <div
+        slot="button-prev"
+        class="swiper-button-prev" />
+    </swiper>
+  </b-card>
 </template>
 
 <script>
-import { BCard, BCardText, BLink } from 'bootstrap-vue'
+import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
+import { BRow, BCol, BCard, BCardText, BLink, BImg } from 'bootstrap-vue'
+import 'swiper/css/swiper.css'
 
 export default {
   components: {
+    BRow,
+    BCol,
     BCard,
     BCardText,
     BLink,
+    Swiper,
+    SwiperSlide,
+    BImg,
   },
-}
-</script>
-
-<style>
+  data() {
+    return {
+      swiperOptions: {
+        spaceBetween: 30,
+        effect: 'fade',
+        centeredSlides: true,
+        autoplay: {
+          delay: 5000,
+          disableOnInteraction: false,
+        },
+        pagination: {
+          el: '.swiper-pagination',
+          clickable: true,
+        },
+        navigation: {
+          nextEl: '.swiper-button-next',
+          prevEl: '.swiper-button-prev',
+        },
+      },
 
-</style>
+      /* eslint-disable global-require */
+      swiperData: [
+        { img: require('@/assets/images/banner/home-1.jpg'), href: "http://www2.maaconsultants.com/tw/about/detail.php?dpid=2" },
+        { img: require('@/assets/images/banner/home-2.gif'), href: "http://www2.maaconsultants.com/tw/projects/detail.php?dpid=486" },
+        { img: require('@/assets/images/banner/home-3.jpg'), href: "http://www2.maaconsultants.com/tw/projects/detail.php?dpid=484" },
+        { img: require('@/assets/images/banner/home-4.jpg'), href: "http://www2.maaconsultants.com/tw/projects/detail.php?dpid=481" },
+        { img: require('@/assets/images/banner/home-5.jpg'), href: "http://www2.maaconsultants.com/tw/projects/detail.php?dpid=475" },
+        { img: require('@/assets/images/banner/home-6.jpg'), href: "http://www2.maaconsultants.com/tw/projects/detail.php?dpid=512" },
+        { img: require('@/assets/images/banner/home-7.jpg'), href: "http://www2.maaconsultants.com/tw/projects/detail.php?dpid=503" },
+      ],
+      /* eslint-disable global-require */
+    }
+  },
+}
+</script>

+ 12 - 11
resources/js/src/views/lottery/Activities/ActivityPage.vue

@@ -1,7 +1,7 @@
 <template>
     <div>
         <b-row class="match-height">
-            <b-col v-if="checkinPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col v-if="checkinPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -9,7 +9,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col v-if="drawPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col v-if="drawPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -17,7 +17,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col v-if="drawPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col v-if="drawPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -26,7 +26,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col v-if="checkinPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col v-if="checkinPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -34,7 +34,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col v-if="checkinPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col v-if="checkinPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -43,7 +43,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col v-if="drawPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col v-if="drawPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -51,7 +51,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col  v-if="checkinPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col  v-if="checkinPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -59,7 +59,7 @@
                     </b-card-body>
                 </b-card>
             </b-col>
-            <b-col  v-if="checkinPage.includes(this.userData.role)" md="6" :lg="lg">
+            <b-col  v-if="checkinPage.includes(role)" md="6" :lg="lg">
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
@@ -102,14 +102,15 @@ export default {
     data() {
         return {
             userData: getUserData(),
-            lg: 0,
+            lg: 4,
             adminPage: ['Admin'],
             drawPage: ['Admin', 'Draw'],
-            checkinPage: ['Admin', 'Draw', 'Checkin'],
+            checkinPage: ['Admin', 'Checkin'],
+            role: "guest",
         }
     },
     created() {
-        this.userData.role == 'User' ? this.lg = 4 : this.lg = 4;
+       this.role = this.userData && this.userData.role ? this.userData.role : "guest"
     },
     methods: {
         downloadFile() {

+ 1 - 1
resources/js/src/views/lottery/Search.vue

@@ -148,7 +148,7 @@ export default {
         },
         awardStatus(is_awarded, prize_name) {
             if (is_awarded == true) {
-                return prize_name ? prize_name : "獎品已捐出"
+                return prize_name ? prize_name : "已中獎"
             }
             return "未中獎";
         },

+ 0 - 20
resources/js/src/views/lottery/Slot.vue

@@ -33,17 +33,6 @@
 		<div>
 			<button class="draw" @click="draw()"></button>
 		</div>
-		<div class="draw-img">
-			<b-img
-				id="img"
-				:src="avatar()"
-				blank-color="#ccc"
-				fluid
-				alt="placeholder"
-				style="width:42vh;"
-				onerror="this.src='/images/error.png'" />
-
-		</div>
 
 		<!--Model Start-->
 		<b-modal ref="draw-animation" title="獎項列表" centered no-stacking hide-footer>
@@ -451,7 +440,6 @@ export default {
 							if (i == 3) {
 								document.querySelector("div.slot.counter_" + index + " > div > div:nth-child(3) > span").innerText = element.user_name;
 								this.user_id = element.user_id;
-								document.getElementById("img").style.display = 'block';
 							}
 						}
 					}, 50);
@@ -465,7 +453,6 @@ export default {
 			document.querySelectorAll("div.slot.counter_0 > div > div:nth-child(2) > span > i")[2].innerText = "0";
 			document.querySelectorAll("div.slot.counter_0 > div > div:nth-child(2) > span > i")[3].innerText = "0";
 			document.querySelector("div.slot.counter_0 > div > div:nth-child(3) > span").innerText = "";
-			document.getElementById("img").style.display = 'none';
 			this.isDrawn = false;
 		},
 		count() {
@@ -477,13 +464,6 @@ export default {
 		activitySpacing(length) {
 			return 'letter-spacing: ' + (725 - (length * 75)) / (length - 1) + 'px;';
 		},
-		avatar() {
-			if (this.department_name == "來賓") {
-				return '/images/vip.jpg';
-			} else {
-				return '/images/profile-picture/' + this.user_id + '.jpg';
-			}
-		}
 	},
 	watch: {
 		prizeId: function (newValue) {

+ 13 - 11
routes/api.php

@@ -90,29 +90,31 @@ Route::middleware('auth:sanctum')->group(function () {
 });
 
 Route::middleware(['auth:sanctum', 'abilities:Admin'])->group(function () {
-
     //activity
     Route::post('/activity/store', [ActivityController::class, 'store']);
     Route::post('/activity/update', [ActivityController::class, 'update']);
     Route::post('/activity/sql', [ActivityController::class, 'sql']);
     Route::post('/activity/uploadFile', [ActivityController::class, 'uploadFile']);
+});
 
-    // CheckIn
-    Route::post('/check_in/update', [CheckInController::class, 'update']);
-    Route::post('/check_in/check_out', [CheckInController::class, 'check_out']);
-    Route::post('/checkin/show', [CheckInController::class, 'show']);
-    Route::post('/checkin/export', [CheckInController::class, 'export']);
-
+Route::middleware(['auth:sanctum', 'ability:Draw,Admin'])->group(function () {
     // Draw
     Route::post('/draw/draw', [DrawController::class, 'draw']);
     Route::post('/draw/store', [DrawController::class, 'store']);
     Route::post('/draw/donate', [DrawController::class, 'donate']);
     Route::post('/draw/test', [DrawController::class, 'test']);
 
-    // Prize
-    Route::post('/prize/store', [PrizeController::class, 'store']);
-    Route::post('/prize/count_by_prize', [PrizeController::class, 'count_by_prize']);
-
+     // Prize
+     Route::post('/prize/store', [PrizeController::class, 'store']);
+     Route::post('/prize/count_by_prize', [PrizeController::class, 'count_by_prize']);
+});
+Route::middleware(['auth:sanctum', 'ability:Checkin,Admin'])->group(function () {
+    // CheckIn
+    Route::post('/check_in/update', [CheckInController::class, 'update']);
+    Route::post('/check_in/check_out', [CheckInController::class, 'check_out']);
+    Route::post('/checkin/show', [CheckInController::class, 'show']);
+    Route::post('/checkin/export', [CheckInController::class, 'export']);
+    
     // Recipients
     Route::post('/recipient/claim', [RecipientsController::class, 'claim']);
     Route::post('/recipient/isClaimed', [RecipientsController::class, 'isClaimed']);