|
|
@@ -6,6 +6,8 @@ import {Back, RefreshRight} from "@element-plus/icons-vue";
|
|
|
import {ElTable} from "element-plus";
|
|
|
import {calculateOrder, createOrder, payOrder} from "../../api/order.ts";
|
|
|
import {getAvailableCouponsByStoreId} from "../../api/coupon.ts";
|
|
|
+import {getCommentsById} from "../../api/comment.ts";
|
|
|
+import OrderItem from "../../components/OrderItem.vue";
|
|
|
|
|
|
const router = useRouter();
|
|
|
const role = sessionStorage.getItem("role")
|
|
|
@@ -31,33 +33,50 @@ const handleChange = () => {
|
|
|
totalPrice.value = amount.value * price.value
|
|
|
}
|
|
|
const type = ref()
|
|
|
-let orderDialogVisible = ref(false)
|
|
|
+const orderDialogVisible = ref(false)
|
|
|
const orderId = ref()
|
|
|
const couponId = ref(0)
|
|
|
+const addStockNumber = ref('')
|
|
|
|
|
|
-const hasTypeInput = computed(() => type.value != '')
|
|
|
-const typeLegal = hasTypeInput
|
|
|
+const hasTypeInput = computed(() => type.value != null)
|
|
|
+const hasAddStockInput = computed(() => addStockNumber.value != '')
|
|
|
|
|
|
-const createDisabled = computed(() => {
|
|
|
- return !(nameLegal.value && locationLegal.value && imageFileList.value);
|
|
|
+const amountLegal = computed(() => amount.value <= stock.value)
|
|
|
+
|
|
|
+const createOrderDisabled = computed(() => {
|
|
|
+ return !(amountLegal.value && hasTypeInput.value);
|
|
|
+})
|
|
|
+
|
|
|
+const addStockDisabled = computed(() => {
|
|
|
+ return !(hasAddStockInput.value);
|
|
|
})
|
|
|
|
|
|
-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
|
|
|
-
|
|
|
- photoUrl.value = photoUrlList.value[0]
|
|
|
- totalPrice.value = price.value
|
|
|
+const commentList = ref([])
|
|
|
+
|
|
|
+getCommentsById(productId).then(res => {
|
|
|
+ commentList.value = res.result
|
|
|
})
|
|
|
|
|
|
+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
|
|
|
+
|
|
|
+ photoUrl.value = photoUrlList.value[0]
|
|
|
+ totalPrice.value = price.value
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
function parseCategory(category) {
|
|
|
if (category === 'FOOD') {
|
|
|
return "食品"
|
|
|
@@ -76,17 +95,7 @@ function parseCategory(category) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const addStockNumber = ref(null)
|
|
|
-
|
|
|
function AddStock() {
|
|
|
- if (addStockNumber.value === null) {
|
|
|
- ElMessage({
|
|
|
- message: "请输入添加库存数!",
|
|
|
- type: 'error',
|
|
|
- center: true,
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
addStock(productId, addStockNumber.value).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
ElMessage({
|
|
|
@@ -184,7 +193,7 @@ function parseOrderType(type) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function handleCouponType(type) {
|
|
|
+function parseCouponType(type) {
|
|
|
if (type === "FULL_REDUCTION") {
|
|
|
return "满减"
|
|
|
} else if (type === "SPECIAL") {
|
|
|
@@ -192,6 +201,14 @@ function handleCouponType(type) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function parseNull(value) {
|
|
|
+ if (value === null) {
|
|
|
+ return "/"
|
|
|
+ } else {
|
|
|
+ return value
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 处理优惠券
|
|
|
interface Coupon {
|
|
|
id: number
|
|
|
@@ -230,7 +247,6 @@ const handleCurrentChange = (val: Coupon | undefined) => {
|
|
|
function toBackPage() {
|
|
|
router.push("/storeDetail/" + storeId.value)
|
|
|
}
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -304,7 +320,7 @@ function toBackPage() {
|
|
|
{{ totalPrice }} 元
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <el-button @click="handleCreateOrder" :disabled="createDisabled"
|
|
|
+ <el-button @click="handleCreateOrder" :disabled="createOrderDisabled"
|
|
|
class="buy-button" type="primary" plain>创建订单
|
|
|
</el-button>
|
|
|
</el-main>
|
|
|
@@ -319,13 +335,18 @@ function toBackPage() {
|
|
|
<template #append>件</template>
|
|
|
</el-input>
|
|
|
<br>
|
|
|
- <el-button @click="AddStock"
|
|
|
+ <el-button @click="AddStock" :disabled="addStockDisabled"
|
|
|
class="add-stock-button" type="primary" plain>
|
|
|
新增库存
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</el-main>
|
|
|
|
|
|
+<!-- <div class="comment-item-list">-->
|
|
|
+<!-- <CommentItem-->
|
|
|
+<!-- v-for="commentVO in commentList"/>-->
|
|
|
+<!-- </div>-->
|
|
|
+
|
|
|
<el-dialog v-model="orderDialogVisible" :before-close="handlePayDialogClose">
|
|
|
<el-row>
|
|
|
<span class="pay-dialog-title">订单支付</span>
|
|
|
@@ -365,11 +386,19 @@ function toBackPage() {
|
|
|
<el-table-column type="index" width="50"/>
|
|
|
<el-table-column prop="type" label="类型" width="180">
|
|
|
<template #default="scope">
|
|
|
- {{ handleCouponType(scope.row.type) }}
|
|
|
+ {{ parseCouponType(scope.row.type) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="satisfaction" label="满(元)" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ parseNull(scope.row.satisfaction) }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="minus" label="减(元)" width="180">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ parseNull(scope.row.minus) }}
|
|
|
</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>
|
|
|
|