Просмотр исходного кода

基本完成了订单/优惠券模块的修改。

chillqi 2 лет назад
Родитель
Сommit
9897490abd

+ 1 - 0
components.d.ts

@@ -7,6 +7,7 @@ export {}
 
 declare module 'vue' {
   export interface GlobalComponents {
+    ElAlert: typeof import('element-plus/es')['ElAlert']
     ElAside: typeof import('element-plus/es')['ElAside']
     ElAvatar: typeof import('element-plus/es')['ElAvatar']
     ElButton: typeof import('element-plus/es')['ElButton']

+ 3 - 3
src/components/Header.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import {UserFilled, Discount, SwitchButton, Document} from "@element-plus/icons-vue";
+import {User, Discount, SwitchButton, Document} from "@element-plus/icons-vue";
 import {router} from '../router'
 
 function logout() {
@@ -56,14 +56,14 @@ const currentIdentity = sessionStorage.getItem('role')
       </el-col>
 
       <el-col :span="1" class="header-icon">
-        <router-link to="/customer/coupon" v-slot="{navigate}">
+        <router-link to="/allCoupon" v-slot="{navigate}">
           <el-icon @click="navigate" :size="35" color="white" ><Discount /></el-icon>
         </router-link>
       </el-col>
 
       <el-col :span="1" class="header-icon">
         <router-link to="/dashboard" v-slot="{navigate}">
-          <el-icon @click="navigate" :size="35" color="white" ><UserFilled /></el-icon>
+          <el-icon @click="navigate" :size="35" color="white" ><User /></el-icon>
         </router-link>
       </el-col>
 

+ 186 - 141
src/components/OrderItem.vue

@@ -18,13 +18,15 @@ const commentDialogVisible = ref(false)
 const userId = ref(0)
 const productId = ref(0)
 const productName = ref('')
+const price = ref(0)
+const totalPrice = ref(0)
 const amount = ref(0)
 const paid = ref(0)
 const type = ref('')
 const content = ref('')
 const rating = ref(0)
 const status = ref('')
-const createTime= ref('')
+const createTime = ref('')
 const finishTime = ref('')
 const storeId = ref(0)
 
@@ -38,6 +40,7 @@ function getOrderDetail() {
     productId.value = res.result.productId
     productName.value = res.result.productName
     amount.value = res.result.amount
+    price.value = res.result.price
     paid.value = res.result.paid
     type.value = res.result.type
     content.value = res.result.content
@@ -46,28 +49,41 @@ function getOrderDetail() {
     createTime.value = res.result.createTime
     finishTime.value = res.result.finishTime
     storeId.value = res.result.storeId
+
+    totalPrice.value = amount.value * price.value
   })
 }
 
 // 对于变化的内容使用计算属性返回响应式结果
 const statusText = computed(() => {
   switch (status.value) {
-    case 'UNPAID': return "待支付"
-    case 'UNSEND': return "待发货"
-    case 'UNGET': return "待收货"
-    case 'UNCOMMENT': return "待评价"
-    case 'DONE':return "已完成"
-    default: return "状态标签"
+    case 'UNPAID':
+      return "待支付"
+    case 'UNSEND':
+      return "待发货"
+    case 'UNGET':
+      return "待收货"
+    case 'UNCOMMENT':
+      return "待评价"
+    case 'DONE':
+      return "已完成"
+    default:
+      return "状态标签"
   }
 })
 
 const buttonText = computed(() => {
   switch (status.value) {
-    case 'UNPAID': return "去支付"
-    case 'UNSEND': return "去发货"
-    case 'UNGET': return "去收货"
-    case 'UNCOMMENT': return "去评价"
-    default: return "按钮"
+    case 'UNPAID':
+      return "去支付"
+    case 'UNSEND':
+      return "去发货"
+    case 'UNGET':
+      return "去收货"
+    case 'UNCOMMENT':
+      return "去评价"
+    default:
+      return "按钮"
   }
 })
 
@@ -165,13 +181,13 @@ function handleSendComment() {
 
   commentOrder(payload).then(res => {
     if (res.code === '000') {
-        ElMessage({
-          message: '评价成功!',
-          type: 'success',
-          center: true,
-        })
-        getOrderDetail()
-        commentDialogVisible.value = false
+      ElMessage({
+        message: '评价成功!',
+        type: 'success',
+        center: true,
+      })
+      getOrderDetail()
+      commentDialogVisible.value = false
     } else {
       ElMessage({
         message: res.msg,
@@ -183,13 +199,22 @@ function handleSendComment() {
 }
 
 function switchButtonFunction() {
-    switch (status.value) {
-      case 'UNPAID': handlePay(); break;
-      case 'UNSEND': handleDeliver(); break;
-      case 'UNGET': handleGet(); break;
-      case 'UNCOMMENT': handleComment(); break;
-      default: break;
-    }
+  switch (status.value) {
+    case 'UNPAID':
+      handlePay();
+      break;
+    case 'UNSEND':
+      handleDeliver();
+      break;
+    case 'UNGET':
+      handleGet();
+      break;
+    case 'UNCOMMENT':
+      handleComment();
+      break;
+    default:
+      break;
+  }
 }
 
 // 处理优惠券
@@ -224,132 +249,152 @@ const setCurrent = (row?: User) => {
   singleTableRef.value!.setCurrentRow(row)
 }
 
-function handleCouponType(type) {
+function parsePaid() {
+  if (paid.value === null) {
+    return "暂未支付"
+  } else {
+    return paid.value + " 元"
+  }
+}
+
+function parseCouponType(type) {
   if (type === "FULL_REDUCTION") {
     return "满减"
   } else if (type === "SPECIAL") {
     return "折扣"
   }
 }
+
+function parseOrderType(type) {
+  if (type === "PICKUP") {
+    return "到店自提"
+  } else if (type === "DELIVERY") {
+    return "快递到家"
+  }
+}
 </script>
 
 <template>
-    <el-card class="order-item-card" shadow="hover">
-
-      <template #header>
-        <div class="card-header">
-          <div>
-            <span> 订单号 {{props.orderId}}</span>
-            <el-tag style="margin-left: 8px" v-if="status!=='DONE'"> {{statusText}} </el-tag>
-            <el-tag style="margin-left: 8px" v-if="status==='DONE'" type="success"> {{statusText}} </el-tag>
-          </div>
-          <el-button @click="switchButtonFunction" v-if="!(status==='DONE')" class="status-change-button" size="small" type="primary">
-              {{ buttonText }}
-          </el-button>
+  <el-card class="order-item-card" shadow="hover">
+
+    <template #header>
+      <div class="card-header">
+        <div>
+          <span> 订单号 {{ props.orderId }}</span>
+          <el-tag style="margin-left: 8px" v-if="status!=='DONE'"> {{ statusText }}</el-tag>
+          <el-tag style="margin-left: 8px" v-if="status==='DONE'" type="success"> {{ statusText }}</el-tag>
         </div>
-      </template>
-
-      <el-descriptions
-          :column="1"
-      >
-        <el-descriptions-item style="font-size: 15px" label="商品">
-          {{ productName }}
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="数量">
-          {{ amount }} 件
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="支付金额">
-          {{ paid }} 元
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="取货类型">
-          <el-tag> {{ parseType() }}</el-tag>
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="创建时间">
-          {{ parseTime(createTime) }}
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="完成时间">
-          {{ parseTime(finishTime) }}
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="评分" v-if="status==='DONE'">
-          <el-rate
-              v-model="rating"
-              disabled
-              show-score
-              text-color="#ff9900"
-              score-template="{value} 分"
-              size="small"
-          />
-        </el-descriptions-item>
-        <el-descriptions-item style="font-size: 15px" label="评价内容" v-if="status==='DONE'">
-          {{ content }}
-        </el-descriptions-item >
-      </el-descriptions>
-    </el-card>
-
-    <el-dialog v-model="orderDialogVisible">
-      <el-form>
-        <el-form-item>
-          <label for="amount">购买数量:</label>
-          {{ amount }} 件
-        </el-form-item>
-        <el-form-item>
-          <label for="discountPrice">总价:</label>
-          {{ paid }} 元
-        </el-form-item>
-        <el-form-item>
-          <label for="type">提货方式:</label>
-          {{ parseType() }}
-        </el-form-item>
-        <el-form-item>
-          <label for="type">优惠券:</label> <el-button @click="setCurrent()">不使用优惠券</el-button>
-          <el-table
-              ref="singleTableRef"
-              :data="availableCouponList"
-              highlight-current-row
-              style="width: 100%"
-              @current-change="handleCurrentChange"
-          >
-            <el-table-column type="index" width="50"/>
-            <el-table-column prop="type" label="类型" width="180">
-              <template #default="scope">
-                {{ handleCouponType(scope.row.type) }}
-              </template>
-            </el-table-column>
-            <el-table-column prop="satisfaction" label="满(元)" width="180"/>
-            <el-table-column prop="minus" label="减(元)" width="180"/>
-          </el-table>
-        </el-form-item>
-      </el-form>
-      <el-button @click="handleConfirmOrder">确认支付</el-button>
-    </el-dialog>
-
-
-    <el-dialog
-        v-model="commentDialogVisible"
-        title="发起评价"
+        <el-button @click="switchButtonFunction" v-if="!(status==='DONE')" class="status-change-button" size="small"
+                   type="primary">
+          {{ buttonText }}
+        </el-button>
+      </div>
+    </template>
+
+    <el-descriptions
+        :column="1"
     >
-      <el-form>
-
-        <el-form-item >
-            <span style="margin-right: 30px">商品满意度</span>
-            <el-rate v-model="rating" clearable
-                     :texts="['非常差', '差', '普通', '好', '非常好']"
-                     show-text/>
-        </el-form-item>
-
-        <el-form-item>
-          <label>文字评价</label>
-          <el-input v-model="content" type="textarea" rows="10" placeholder="说点什么吧">
-
-          </el-input>
-        </el-form-item>
-
-        <el-form-item>
-          <el-button type="primary" @click="handleSendComment">评价</el-button>
-          <el-button @click="commentDialogVisible = false">取消</el-button>
-        </el-form-item>
-      </el-form>
-    </el-dialog>
+      <el-descriptions-item style="font-size: 15px" label="商品">
+        {{ productName }}
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="数量">
+        {{ amount }} 件
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="订单原价">
+        {{ totalPrice }} 元
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="实付金额">
+        {{ parsePaid() }}
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="取货类型">
+        <el-tag> {{ parseType() }}</el-tag>
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="创建时间">
+        {{ parseTime(createTime) }}
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="完成时间">
+        {{ parseTime(finishTime) }}
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="评分" v-if="status==='DONE'">
+        <el-rate
+            v-model="rating"
+            disabled
+            show-score
+            text-color="#ff9900"
+            score-template="{value} 分"
+            size="small"
+        />
+      </el-descriptions-item>
+      <el-descriptions-item style="font-size: 15px" label="评价内容" v-if="status==='DONE'">
+        {{ content }}
+      </el-descriptions-item>
+    </el-descriptions>
+  </el-card>
+
+  <el-dialog v-model="orderDialogVisible" title="订单详情">
+    <el-form>
+      <el-form-item>
+        <label for="amount">购买数量:</label>
+        {{ amount }} 件
+      </el-form-item>
+      <el-form-item>
+        <label for="discountPrice">折扣前总价:</label>
+        {{ totalPrice }} 元
+      </el-form-item>
+      <el-form-item>
+        <label for="type">提货方式:</label>
+        {{ parseOrderType(type) }}
+      </el-form-item>
+      <el-form-item>
+        <label for="type">优惠券:</label>
+        <el-button @click="setCurrent()">不使用优惠券</el-button>
+        <el-table
+            ref="singleTableRef"
+            :data="availableCouponList"
+            highlight-current-row
+            style="width: 100%"
+            @current-change="handleCurrentChange"
+        >
+          <el-table-column type="index" width="50"/>
+          <el-table-column prop="type" label="类型" width="180">
+            <template #default="scope">
+              {{ parseCouponType(scope.row.type) }}
+            </template>
+          </el-table-column>
+          <el-table-column prop="satisfaction" label="满(元)" width="180"/>
+          <el-table-column prop="minus" label="减(元)" width="180"/>
+        </el-table>
+      </el-form-item>
+    </el-form>
+    <el-button @click="handleConfirmOrder" type="primary" plain>确认支付</el-button>
+  </el-dialog>
+
+  <el-dialog
+      v-model="commentDialogVisible"
+      title="发起评价"
+  >
+    <el-form>
+
+      <el-form-item>
+        <span style="margin-right: 30px">商品满意度</span>
+        <el-rate v-model="rating" clearable
+                 :texts="['非常差', '差', '普通', '好', '非常好']"
+                 show-text/>
+      </el-form-item>
+
+      <el-form-item>
+        <label>文字评价</label>
+        <el-input v-model="content" type="textarea" rows="10" placeholder="说点什么吧">
+
+        </el-input>
+      </el-form-item>
+
+      <el-form-item>
+        <el-button type="primary" @click="handleSendComment">评价</el-button>
+        <el-button @click="commentDialogVisible = false">取消</el-button>
+      </el-form-item>
+    </el-form>
+  </el-dialog>
 
 </template>
 

+ 5 - 14
src/router/index.ts

@@ -47,21 +47,12 @@ const router = createRouter({
                 }
             },
             {
-                path: '/customer/coupon/',
-                name: 'manageCoupon',
-                component: () => import('../views/customer/ManageCoupon.vue'),
+                path: '/allCoupon/',
+                name: 'allCoupon',
+                component: () => import('../views/coupon/AllCoupon.vue'),
                 meta: {
-                    title: '商品详情',
-                    permission: ['CUSTOMER']
-                }
-            },
-            {
-                path: '/staff/coupon/',
-                name: 'releaseCoupon',
-                component: () => import('../views/staff/AllCoupon.vue'),
-                meta: {
-                    title: '商品详情',
-                    permission: ['STAFF', 'MANAGER']
+                    title: '优惠券',
+                    permission: ['CUSTOMER', 'STAFF', 'MANAGER']
                 }
             },
             {

+ 0 - 4
src/views/Home.vue

@@ -1,15 +1,11 @@
 <script setup lang="ts">
 import Header from "../components/Header.vue"
-
 </script>
 
 <template>
-
   <Header/>
   <router-view />
-
 </template>
 
 <style scoped>
-
 </style>

+ 231 - 0
src/views/coupon/AllCoupon.vue

@@ -0,0 +1,231 @@
+<script setup lang="ts">
+import {ref} from "vue";
+import {createCoupons, getCouponGroups, getCoupons, receiveCouponGroup} from "../../api/coupon.ts";
+import {userInfo} from "../../api/user.ts";
+
+const role = sessionStorage.getItem("role")
+const myCouponList = ref()
+const receiveCouponList = ref()
+const type = ref()
+const satisfaction = ref()
+const minus = ref()
+const rest = ref()
+const storeName = ref()
+
+userInfo().then(res => {
+  storeName.value = res.result.storeName
+})
+
+let couponDialogVisible = ref(false)
+
+function toCreateCoupon() {
+  couponDialogVisible.value = true
+}
+
+function handleCreateCoupon() {
+  const payload = {
+    type: type.value,
+    satisfaction: satisfaction.value,
+    minus: minus.value,
+    rest: rest.value
+  }
+  couponDialogVisible.value = false
+  createCoupons(payload).then(res => {
+    if (res.code === '000') {
+      ElMessage({
+        message: '创建优惠券成功!',
+        type: 'success',
+        center: true,
+      })
+      getReceiveCouponList()
+      type.value = ''
+      satisfaction.value = null
+      minus.value = null
+      rest.value = null
+    } else if (res.code === '400') {
+      ElMessage({
+        message: res.msg,
+        type: 'error',
+        center: true,
+      })
+    }
+  })
+}
+
+getCoupons().then(res => {
+  myCouponList.value = res.result
+})
+
+
+getCouponGroups().then(res => {
+  receiveCouponList.value = res.result
+})
+
+function handleType(type) {
+  if (type === "FULL_REDUCTION") {
+    return "满减"
+  } else if (type === "SPECIAL") {
+    return "折扣"
+  }
+}
+
+function receiveCoupon(couponGroupId) {
+  receiveCouponGroup(couponGroupId).then(res => {
+    if (res.code === '000') {
+      ElMessage({
+        message: '获取优惠券成功!',
+        type: 'success',
+        center: true,
+      })
+      getMyCouponList()
+      getReceiveCouponList()
+    } else if (res.code === '400') {
+      ElMessage({
+        message: res.msg,
+        type: 'error',
+        center: true,
+      })
+    }
+  })
+}
+</script>
+
+<template>
+  <div>
+    <el-button @click="toCreateCoupon()" v-if="role === 'MANAGER' || role === 'STAFF'"
+               class="create-coupon-button" type="primary" plain>
+      新增优惠券
+    </el-button>
+
+    <el-dialog v-model="couponDialogVisible" title="创建优惠券">
+      <el-form label-width="100px" class="create-coupon-form">
+        <el-form-item label="应用范围:">
+          <span v-if="role === 'MANAGER'">全平台</span>
+          <span v-if="role === 'STAFF'">{{ storeName }}</span>
+        </el-form-item>
+
+        <el-form-item label="类型:" for="type">
+          <el-select id="identity"
+                     v-model="type"
+                     placeholder="请选择"
+          >
+            <el-option value="FULL_REDUCTION" label="满减"/>
+            <el-option value="SPECIAL" label="折扣"/>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="满:" for="satisfaction" v-if="type === 'FULL_REDUCTION'">
+          <el-input id="satisfaction" v-model="satisfaction"
+                    required placeholder="请输入金额" class="create-coupon-dialog-input">
+            <template #append>元</template>
+          </el-input>
+        </el-form-item>
+
+        <el-form-item label="减:" for="minus" v-if="type === 'FULL_REDUCTION'">
+          <el-input id="minus" v-model="minus" required placeholder="请输入金额"
+                    class="create-coupon-dialog-input">
+            <template #append>元</template>
+          </el-input>
+        </el-form-item>
+
+        <el-alert v-if="type === 'SPECIAL'"
+                  title="“蓝鲸券”使用规则:" type="success" :closable="false" class="special-alert">
+          * 0-100元区间打九五折;<br>
+          * 200-300元区间打八五折;<br>
+          * 300-400元区间打八折;<br>
+          * 400-500元区间打七五折;<br>
+          * 500元以上区间打七折。<br>
+        </el-alert>
+
+        <el-form-item label="数量:" for="rest">
+          <el-input id="rest" v-model="rest" required placeholder="请输入数量"
+                    class="create-coupon-dialog-input">
+            <template #append>张</template>
+          </el-input>
+        </el-form-item>
+
+        <el-button @click.prevent="handleCreateCoupon()"
+                   type="primary" plain>
+          创建
+        </el-button>
+
+      </el-form>
+    </el-dialog>
+
+    <div class="all-coupon-main">
+      <div v-if="role === 'CUSTOMER'">
+        <span class="this-title">我的优惠券</span>
+        <el-table :data="myCouponList" stripe class="coupon-table">
+          <el-table-column type="index" width="50"/>
+          <el-table-column prop="storeName" label="所属商店" width="180"/>
+          <el-table-column prop="type" label="类型" width="180">
+            <template #default="scope">
+              {{ handleType(scope.row.type) }}
+            </template>
+          </el-table-column>
+          <el-table-column prop="satisfaction" label="满(元)" width="180"/>
+          <el-table-column prop="minus" label="减(元)" width="180"/>
+          <el-table-column prop="used" label="状态" width="180">
+            <template #default="scope">
+              <el-tag v-if="scope.row.used === false" type="success">待使用</el-tag>
+              <el-tag v-if="scope.row.used === true" type="info">已使用</el-tag>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+
+      <div>
+        <span class="this-title" v-if="role === 'CUSTOMER'">可获取优惠券</span>
+        <span class="this-title" v-if="role === 'MANAGER'">全部优惠券</span>
+        <span class="this-title" v-if="role === 'STAFF'">门店下优惠券</span>
+        <el-table :data="receiveCouponList" stripe class="coupon-table">
+          <el-table-column type="index" width="50"/>
+          <el-table-column prop="storeName" label="所属商店" width="180"/>
+          <el-table-column prop="type" label="类型" width="180">
+            <template #default="scope">
+              {{ handleType(scope.row.type) }}
+            </template>
+          </el-table-column>
+          <el-table-column prop="satisfaction" label="满(元)" width="180"/>
+          <el-table-column prop="minus" label="减(元)" width="180"/>
+          <el-table-column prop="rest" label="剩余数量(张)" width="180"/>
+          <el-table-column label="操作" v-if="role === 'CUSTOMER'">
+            <template #default="scope">
+              <el-button @click="receiveCoupon(scope.row.id)" type="primary" plain>领取</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+    </div>
+  </div>
+</template>
+
+<style scoped>
+.create-coupon-button {
+  width: 100px;
+  margin-left: 20px;
+  margin-top: 30px;
+}
+
+.create-coupon-form {
+  width: 60%;
+}
+
+.special-alert {
+  margin-bottom: 15px;
+}
+
+.all-coupon-main {
+  margin-left: 20px;
+  margin-top: 20px;
+}
+
+.this-title {
+  font-size: large;
+  margin-bottom: 20px;
+}
+
+.coupon-table {
+  margin-bottom: 30px;
+}
+</style>

+ 0 - 112
src/views/customer/ManageCoupon.vue

@@ -1,112 +0,0 @@
-<script setup lang="ts">
-import {ref} from "vue";
-import {getCouponGroups, getCoupons, receiveCouponGroup} from "../../api/coupon.ts";
-
-const myCouponList = ref()
-const receiveCouponList = ref()
-const type = ref()
-const satisfaction = ref()
-const minus = ref()
-const rest = ref()
-
-getMyCouponList()
-getReceiveCouponList()
-
-function getMyCouponList() {
-  getCoupons().then(res => {
-    myCouponList.value = res.result
-  })
-}
-
-function getReceiveCouponList() {
-  getCouponGroups().then(res => {
-    receiveCouponList.value = res.result
-  })
-}
-
-function handleType(type) {
-  if (type === "FULL_REDUCTION") {
-    return "满减"
-  } else if (type === "SPECIAL") {
-    return "折扣"
-  }
-}
-
-function receiveCoupon(couponGroupId) {
-  receiveCouponGroup(couponGroupId).then(res => {
-    if (res.code === '000') {
-      ElMessage({
-        message: '获取优惠券成功!',
-        type: 'success',
-        center: true,
-      })
-      getMyCouponList()
-      getReceiveCouponList()
-    } else if (res.code === '400') {
-      ElMessage({
-        message: res.msg,
-        type: 'error',
-        center: true,
-      })
-    }
-  })
-}
-</script>
-
-<template>
-  <div class="all-coupon-main">
-    <span class="this-title">我的优惠券</span>
-    <el-table :data="myCouponList" stripe class="coupon-table">
-      <el-table-column type="index" width="50" />
-      <el-table-column prop="storeName" label="所属商店" width="180" />
-      <el-table-column prop="type" label="类型" width="180">
-        <template #default="scope">
-          {{ handleType(scope.row.type) }}
-        </template>
-      </el-table-column>
-      <el-table-column prop="satisfaction" label="满(元)" width="180" />
-      <el-table-column prop="minus" label="减(元)" width="180" />
-      <el-table-column prop="used" label="状态" width="180">
-        <template #default="scope">
-          <el-tag v-if="scope.row.used === false" type="success">待使用</el-tag>
-          <el-tag v-if="scope.row.used === true" type="info">已使用</el-tag>
-        </template>
-      </el-table-column>
-    </el-table>
-
-    <span class="this-title">获取优惠券</span>
-    <el-table :data="receiveCouponList" stripe class="coupon-table">
-      <el-table-column type="index" width="50" />
-      <el-table-column prop="storeName" label="所属商店" width="180" />
-      <el-table-column prop="type" label="类型" width="180">
-        <template #default="scope">
-          {{ handleType(scope.row.type) }}
-        </template>
-      </el-table-column>
-      <el-table-column prop="satisfaction" label="满(元)" width="180" />
-      <el-table-column prop="minus" label="减(元)" width="180" />
-      <el-table-column prop="rest" label="数量(张)" width="180" />
-      <el-table-column label="操作">
-        <template #default="scope">
-          <el-button @click="receiveCoupon(scope.row.id)" type="primary" plain>领取</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-  </div>
-</template>
-
-<style scoped>
-.all-coupon-main {
-  margin-left: 20px;
-  margin-top: 20px;
-}
-
-.this-title {
-  font-size: large;
-  margin-bottom: 20px;
-}
-
-.coupon-table {
-  margin-bottom: 30px;
-}
-</style>

+ 1 - 1
src/views/product/ProductDetail.vue

@@ -299,7 +299,7 @@ function toBackPage() {
                  @click="handleCreateOrder">创建订单
       </el-button>
 
-      <el-dialog v-model="orderDialogVisible">
+      <el-dialog v-model="orderDialogVisible" title="订单详情">
         <el-form>
           <el-form-item>
             <label for="amount">购买数量:</label>

+ 0 - 166
src/views/staff/AllCoupon.vue

@@ -1,166 +0,0 @@
-<script setup lang="ts">
-import {ref} from "vue";
-import {createCoupons, getCouponGroups, receiveCouponGroup} from "../../api/coupon.ts";
-
-const couponList = ref()
-const type = ref()
-const satisfaction = ref()
-const minus = ref()
-const rest = ref()
-
-
-getCouponList()
-
-function getCouponList() {
-  getCouponGroups().then(res => {
-    couponList.value = res.result
-  })
-}
-
-let couponDialogVisible = ref(false)
-
-function toCreateCoupon() {
-  couponDialogVisible.value = true
-}
-
-function handleCreateCoupon() {
-  const payload = {
-    type: type.value,
-    satisfaction: satisfaction.value,
-    minus: minus.value,
-    rest: rest.value
-  }
-  couponDialogVisible.value = false
-  createCoupons(payload).then(res => {
-    if (res.code === '000') {
-      ElMessage({
-        message: '创建优惠券成功!',
-        type: 'success',
-        center: true,
-      })
-      type.value = ''
-      satisfaction.value = null
-      minus.value = null
-      rest.value = null
-    } else if (res.code === '400') {
-      ElMessage({
-        message: res.msg,
-        type: 'error',
-        center: true,
-      })
-    }
-  })
-}
-
-function handleType(type) {
-  if (type === "FULL_REDUCTION") {
-    return "满减"
-  } else if (type === "SPECIAL") {
-    return "折扣"
-  }
-}
-
-function receiveCoupon(couponGroupId) {
-  receiveCouponGroup(couponGroupId).then(res => {
-    console.log(res)
-    if (res.code === '000') {
-      ElMessage({
-        message: '获取优惠券成功!',
-        type: 'success',
-        center: true,
-      })
-      getCouponList()
-    } else if (res.code === '400') {
-      ElMessage({
-        message: res.msg,
-        type: 'error',
-        center: true,
-      })
-    }
-  })
-}
-</script>
-
-<template>
-  <el-button class="create-coupon-button" type="primary" plain
-             @click="toCreateCoupon()">新增优惠券
-  </el-button>
-
-  <div class="all-coupon-main">
-    <el-table :data="couponList" style="width: 100%" stripe>
-      <el-table-column type="index" width="50" />
-      <el-table-column prop="type" label="类型" width="180">
-        <template #default="scope">
-          {{ handleType(scope.row.type) }}
-        </template>
-      </el-table-column>
-      <el-table-column prop="satisfaction" label="满(元)" width="180" />
-      <el-table-column prop="minus" label="减(元)" width="180" />
-      <el-table-column prop="rest" label="数量(张)" width="180" />
-      <el-table-column label="操作">
-        <template #default="scope">
-          <el-button @click="receiveCoupon(scope.row.id)" type="primary" plain>领取</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-  </div>
-
-  <el-dialog v-model="couponDialogVisible" title="创建优惠券">
-    <el-form>
-      <el-form-item>
-        <label for="type">类型:</label>
-        <el-select id="identity"
-                   v-model="type"
-                   placeholder="请选择"
-        >
-          <el-option value="FULL_REDUCTION" label="满减"/>
-          <el-option value="SPECIAL" label="折扣"/>
-        </el-select>
-      </el-form-item>
-      <el-form-item>
-        <label for="satisfaction">满:</label>
-        <el-input id="satisfaction" v-model="satisfaction" required placeholder="请输入金额"
-                  class="create-coupon-dialog-input">
-          <template #append>元</template>
-        </el-input>
-      </el-form-item>
-      <el-form-item>
-        <label for="minus">减:</label>
-        <el-input id="minus" v-model="minus" required placeholder="请输入金额"
-                  class="create-coupon-dialog-input">
-          <template #append>元</template>
-        </el-input>
-      </el-form-item>
-      <el-form-item>
-        <label for="rest">数量:</label>
-        <el-input id="rest" v-model="rest" required placeholder="请输入数量"
-                  class="create-coupon-dialog-input">
-          <template #append>张</template>
-        </el-input>
-      </el-form-item>
-
-      <el-form-item>
-        <button @click.prevent="handleCreateCoupon()">
-          添加
-        </button>
-      </el-form-item>
-    </el-form>
-  </el-dialog>
-</template>
-
-<style scoped>
-.create-coupon-button {
-  width: 100px;
-  margin-left: 20px;
-  margin-top: 30px;
-}
-
-.all-coupon-main {
-  margin-left: 20px;
-  margin-top: 20px;
-}
-
-.create-coupon-dialog-input {
-  width: 200px;
-}
-</style>

+ 6 - 0
src/views/user/Dashboard.vue

@@ -6,6 +6,7 @@ import {UserFilled} from "@element-plus/icons-vue";
 
 const role = sessionStorage.getItem("role")
 const name = ref('')
+const storeName = ref('')
 const tel = ref('')
 const address = ref('')
 const regTime = ref()
@@ -23,6 +24,7 @@ userInfo()
     .then(res => {
       name.value = res.result.name
       tel.value = res.result.phone
+      storeName.value = res.result.storeName
       address.value = res.result.address
       regTime.value = parseTime(res.result.createTime)
     })
@@ -147,6 +149,10 @@ function parseTime(time) {
           <el-tag>{{ parseRole() }}</el-tag>
         </el-descriptions-item>
 
+        <el-descriptions-item label="所属商店" v-if="role === 'STAFF'">
+          {{ storeName }}
+        </el-descriptions-item>
+
         <el-descriptions-item label="联系电话">
           {{ tel }}
         </el-descriptions-item>