|
|
@@ -1,210 +0,0 @@
|
|
|
-<script setup lang="ts">
|
|
|
-import {ref, computed} from "vue"
|
|
|
-import {router} from '../../router'
|
|
|
-import {Back} from "@element-plus/icons-vue"
|
|
|
-import {addStock, getProductById} from "../../api/product.ts"
|
|
|
-
|
|
|
-const role = sessionStorage.getItem("role")
|
|
|
-
|
|
|
-const productId = router.currentRoute.value.params.productId
|
|
|
-const productVO = ref()
|
|
|
-const storeId = ref(0)
|
|
|
-const name = ref('')
|
|
|
-const photoUrlList = ref([])
|
|
|
-const rating = ref(0)
|
|
|
-const number = ref(0)
|
|
|
-const salesAmount = ref(0)
|
|
|
-const stock = ref(0)
|
|
|
-const category = ref('')
|
|
|
-const price = ref(0)
|
|
|
-
|
|
|
-const addStockNumber = ref('')
|
|
|
-
|
|
|
-const hasAddStockInput = computed(() => addStockNumber.value != '')
|
|
|
-const addStockDisabled = computed(() => {
|
|
|
- return !(hasAddStockInput.value)
|
|
|
-})
|
|
|
-
|
|
|
-getProductDetail()
|
|
|
-
|
|
|
-function getProductDetail() {
|
|
|
- getProductById(productId).then(res => {
|
|
|
- productVO.value = res.result
|
|
|
- storeId.value = productVO.value.storeId
|
|
|
- name.value = productVO.value.name
|
|
|
- photoUrlList.value = productVO.value.photoUrlList
|
|
|
- rating.value = productVO.value.rating
|
|
|
- number.value = productVO.value.number
|
|
|
- salesAmount.value = productVO.value.salesAmount
|
|
|
- stock.value = productVO.value.stock
|
|
|
- category.value = productVO.value.category
|
|
|
- price.value = productVO.value.price
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-// 添加库存按钮
|
|
|
-function AddStock() {
|
|
|
- addStock(productId, addStockNumber.value).then(res => {
|
|
|
- if (res.code === '000') {
|
|
|
- ElMessage({
|
|
|
- message: '添加库存成功!',
|
|
|
- type: 'success',
|
|
|
- center: true,
|
|
|
- })
|
|
|
- addStockNumber.value = null
|
|
|
- getProductDetail()
|
|
|
- } else if (res.code === '400') {
|
|
|
- ElMessage({
|
|
|
- message: res.msg,
|
|
|
- type: 'error',
|
|
|
- center: true,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-function parseCategory(category) {
|
|
|
- if (category === 'FOOD') {
|
|
|
- return "食品"
|
|
|
- } else if (category === 'CLOTHES') {
|
|
|
- return "服饰"
|
|
|
- } else if (category === 'FURNITURE') {
|
|
|
- return "家具"
|
|
|
- } else if (category === 'ELECTRONICS') {
|
|
|
- return "电子产品"
|
|
|
- } else if (category === 'ENTERTAINMENT') {
|
|
|
- return "娱乐"
|
|
|
- } else if (category === 'SPORTS') {
|
|
|
- return "体育产品"
|
|
|
- } else if (category === 'LUXURY') {
|
|
|
- return "奢侈品"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function toBackPage() {
|
|
|
- router.push("/storeDetail/" + storeId.value)
|
|
|
-}
|
|
|
-</script>
|
|
|
-
|
|
|
-
|
|
|
-<template>
|
|
|
- <el-container>
|
|
|
- <el-aside width="25%" class="page-aside">
|
|
|
- <div class="product-detail-aside">
|
|
|
- <el-button @click="toBackPage()"
|
|
|
- type="primary" circle plain class="back-button">
|
|
|
- <el-icon>
|
|
|
- <Back/>
|
|
|
- </el-icon>
|
|
|
- </el-button>
|
|
|
-
|
|
|
- <el-carousel trigger="click" arrow="always" indicator-position="outside">
|
|
|
- <el-carousel-item v-for="item in photoUrlList" :key="item">
|
|
|
- <el-image class="logo-image" :src="item" />
|
|
|
- </el-carousel-item>
|
|
|
- </el-carousel>
|
|
|
-
|
|
|
- <span class="product-title">{{ name }}</span>
|
|
|
-
|
|
|
- <el-descriptions :column="1">
|
|
|
- <el-descriptions-item style="font-size: 10px" label="品类">
|
|
|
- {{ parseCategory(category) }}
|
|
|
- </el-descriptions-item>
|
|
|
-
|
|
|
- <el-descriptions-item style="font-size: 10px" label="价格">
|
|
|
- {{ price }} 元
|
|
|
- </el-descriptions-item>
|
|
|
-
|
|
|
- <el-descriptions-item style="font-size: 10px" label="评分">
|
|
|
- <el-rate
|
|
|
- v-model="rating"
|
|
|
- disabled
|
|
|
- show-score
|
|
|
- text-color="#ff9900"
|
|
|
- score-template="{value} 分"
|
|
|
- size="small"
|
|
|
- />
|
|
|
- (共 {{ number }} 人打分)
|
|
|
- </el-descriptions-item>
|
|
|
-
|
|
|
- <el-descriptions-item style="font-size: 10px" label="销量">
|
|
|
- {{ salesAmount }} 件
|
|
|
- </el-descriptions-item>
|
|
|
-
|
|
|
- <el-descriptions-item style="font-size: 10px" label="库存">
|
|
|
- {{ stock }} 件
|
|
|
- </el-descriptions-item>
|
|
|
- </el-descriptions>
|
|
|
- </div>
|
|
|
- </el-aside>
|
|
|
-
|
|
|
- <el-main>
|
|
|
- <div v-if="role === 'STAFF'">
|
|
|
- <div>
|
|
|
- <span class="main-title">添加库存</span>
|
|
|
- </div>
|
|
|
- <div class="add-stock-main">
|
|
|
- <el-input class="add-stock-number-input"
|
|
|
- v-model="addStockNumber" placeholder="请输入添加库存数">
|
|
|
- <template #append>件</template>
|
|
|
- </el-input>
|
|
|
- <br>
|
|
|
- <el-button @click="AddStock" :disabled="addStockDisabled"
|
|
|
- class="add-stock-button" type="primary" plain>
|
|
|
- 新增库存
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </el-main>
|
|
|
- </el-container>
|
|
|
-</template>
|
|
|
-
|
|
|
-
|
|
|
-<style scoped>
|
|
|
-.page-aside {
|
|
|
- border-right: lightgrey solid 1px;
|
|
|
-}
|
|
|
-
|
|
|
-.back-button {
|
|
|
- margin-top: 20px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.product-title {
|
|
|
- font-size: 30px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.product-detail-aside {
|
|
|
- width: 80%;
|
|
|
- margin-left: 10%;
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- justify-content: start;
|
|
|
-}
|
|
|
-
|
|
|
-.logo-image {
|
|
|
- width: 100%;
|
|
|
-}
|
|
|
-
|
|
|
-.add-stock-number-input {
|
|
|
- width: 300px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.add-stock-button {
|
|
|
- margin-bottom: 40px;
|
|
|
-}
|
|
|
-
|
|
|
-.main-title {
|
|
|
- font-size: 30px;
|
|
|
- margin-top: 20px;
|
|
|
- margin-bottom: 20px;
|
|
|
- margin-left: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.add-stock-main {
|
|
|
- margin-top: 20px;
|
|
|
- margin-left: 30px;
|
|
|
-}
|
|
|
-</style>
|