Browse Source

修改中獎清單

maa3520 2 years ago
parent
commit
b668bdca5a

+ 2 - 1
app/Http/Controllers/RecipientsController.php

@@ -217,7 +217,8 @@ class RecipientsController extends Controller
         $prizeList = DB::select("SELECT [check_ins].[user_id],[name],[is_claimed],[alias] FROM [recipients] 
         LEFT JOIN [check_ins] ON [recipients].[user_id] = [check_ins].[user_id]
         LEFT JOIN [departments] ON [check_ins].[department_id] = [departments].[department_id]
-        WHERE [prize_id] = ? ORDER BY [check_ins].[department_id],[user_id];", [$prize_id]);
+        WHERE [prize_id] = ? ORDER BY CASE 
+        WHEN [check_ins].[department_id] = 'guest' then 1 END DESC,[check_ins].[department_id],[check_ins].[user_id];", [$prize_id]);
         $prize = DB::select("SELECT [name] FROM [prizes] WHERE [id] = ?;", [$prize_id]);
         $response = [
             "prize" => $prize,

+ 0 - 3
resources/js/src/views/Login.vue

@@ -54,9 +54,6 @@
 							<b-form-group>
 								<div class="d-flex justify-content-between">
 									<label for="login-password">密碼</label>
-									<b-link :to="{ name: 'auth-forgot-password-v2' }">
-										<small>忘記密碼?</small>
-									</b-link>
 								</div>
 								<validation-provider
 									#default="{ errors }"

+ 0 - 1
resources/js/src/views/lottery/Activities/ActivityPage.vue

@@ -39,7 +39,6 @@
                 <b-card no-body border-variant="info" class="text-center">
                     <b-card-body>
                         <b-button variant="success"
-                            target="_blank"
                             :to="{ name: 'playPrizeList', params: { 'activity_id': this.$route.params.activity_id } }">中獎輪播名單</b-button>
                     </b-card-body>
                 </b-card>

+ 24 - 5
resources/js/src/views/lottery/PrizeList.vue

@@ -13,14 +13,14 @@
           id="dropdown-6"
           text="選擇獎項"
           variant="info">
-          <b-dropdown-item :key="index" v-for="(item,index) in prizes" @click="getPrizeList(item.id)">{{item.name}}</b-dropdown-item>
+          <b-dropdown-item :key="index" v-for="(item, index) in prizes"
+            @click="getPrizeList(item.id)">{{ item.name }}</b-dropdown-item>
         </b-dropdown>
       </div>
     </b-card-header>
     <b-row v-if="prizeList.length > 0">
       <b-col cols="12" class="prize-list" :key="index" v-for="(item, index) in prizeList">
-        <b-badge pill variant="light">{{ item.alias.padEnd(6, " ") + " " + item.user_id + " " +
-          item.name.padEnd(4, " ") }}</b-badge>
+        <b-badge pill :style="color(item.alias)">{{ prizeBadge(item) }}</b-badge>
       </b-col>
     </b-row>
     <b-row v-else>
@@ -36,7 +36,7 @@ import BCardCode from '@core/components/b-card-code/BCardCode.vue'
 import { BCard, BCardTitle, BCardHeader, BRow, BCol, BBadge, BButton, BProgress, BDropdown, BDropdownItem } from 'bootstrap-vue'
 
 import useJwt from '@/auth/jwt/useJwt'
-
+const colors = ["250,250,250,1", "128,128,128,1"];
 export default {
   components: {
     BCard,
@@ -58,6 +58,8 @@ export default {
       prizes: [],
       index: 0,
       variant: 'danger',
+      tempAlias: "",
+      tempColor: 0,
     }
   },
   created() {
@@ -72,7 +74,6 @@ export default {
   methods: {
     getPrize(activity_id) {
       useJwt.postData('/api/prize/index_by_activity', { activity_id: activity_id }).then(response => {
-        console.log(response.data);
         this.prizes = response.data;
         this.index = this.prizes.length - 1;
         let prize_id = this.prizes[this.index].id;
@@ -83,6 +84,8 @@ export default {
     },
     getPrizeList(prize_id) {
       useJwt.postData('/api/recipient/indexByPrize', { prize_id: prize_id }).then(response => {
+        console.log(response.data);
+
         this.prizeList = response.data.list;
         this.prizeName = response.data.prize[0].name;
 
@@ -93,6 +96,22 @@ export default {
     padEnd(string) {
       string.padEnd(6, " ");
     },
+    prizeBadge(item) {
+      if (item.alias == '來賓') {
+        return item.alias.padEnd(6, " ") + " " + item.name.padEnd(7, " ")
+      } else {
+        return item.alias.padEnd(6, " ") + " " + item.user_id + " " +
+          item.name.padEnd(4, " ");
+      }
+    },
+    color(alias) {
+      if (this.tempAlias != alias) {
+        this.tempAlias = alias;
+        this.tempColor = (this.tempColor + 1) % colors.length
+      }
+
+      return 'background-color: rgba(' + colors[this.tempColor] + ')';
+    }
   },
   computed: {
     PauseIcon() {