|
|
@@ -2,7 +2,7 @@
|
|
|
import {useRouter} from "vue-router";
|
|
|
import {ref, onMounted} from "vue";
|
|
|
import {addStock, getProductById} from "../../api/product.ts";
|
|
|
-import {Back} from "@element-plus/icons-vue";
|
|
|
+import {Back, RefreshRight} from "@element-plus/icons-vue";
|
|
|
import {ElTable} from "element-plus";
|
|
|
import {createOrder, payOrder} from "../../api/order.ts";
|
|
|
import {getAvailableCouponsByStoreId} from "../../api/coupon.ts";
|
|
|
@@ -128,11 +128,13 @@ function handleCreateOrder() {
|
|
|
}
|
|
|
|
|
|
const showForm = ref(false);
|
|
|
+const isLoading = ref(false)
|
|
|
+const refreshButtonVisible = ref(false)
|
|
|
|
|
|
function handleConfirmOrder() {
|
|
|
- console.log(couponId.value)
|
|
|
+ isLoading.value = true
|
|
|
+ refreshButtonVisible.value = true
|
|
|
payOrder(orderId.value, couponId.value).then(res => {
|
|
|
- console.log(res)
|
|
|
const paymentWindow = window.open('', '_blank');
|
|
|
paymentWindow.document.write(res);
|
|
|
paymentWindow.document.forms[0].submit(); // 提交表单
|
|
|
@@ -147,6 +149,9 @@ function handleConfirmOrder() {
|
|
|
amount.value = 1
|
|
|
type.value = ''
|
|
|
totalPrice.value = price.value
|
|
|
+ couponId.value = 0
|
|
|
+ isLoading.value = false
|
|
|
+ refreshButtonVisible.value = false
|
|
|
} else if (res.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.msg,
|
|
|
@@ -157,6 +162,17 @@ function handleConfirmOrder() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+function refreshPage() {
|
|
|
+ location.reload();
|
|
|
+}
|
|
|
+
|
|
|
+function handlePayDialogClose() {
|
|
|
+ orderDialogVisible.value = false
|
|
|
+ couponId.value = 0
|
|
|
+ isLoading.value = false
|
|
|
+ refreshButtonVisible.value = false
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
showForm.value = true; // 组件加载后显示表单
|
|
|
});
|
|
|
@@ -261,7 +277,7 @@ function toBackPage() {
|
|
|
</el-descriptions>
|
|
|
|
|
|
<el-input class="add-stock-number-input" v-if="role === 'STAFF'"
|
|
|
- v-model="addStockNumber" placeholder="请输入添加库存数" />
|
|
|
+ v-model="addStockNumber" placeholder="请输入添加库存数"/>
|
|
|
<el-button class="add-stock-button" @click="AddStock" v-if="role === 'STAFF'"
|
|
|
type="primary" plain>
|
|
|
新增库存
|
|
|
@@ -299,43 +315,58 @@ function toBackPage() {
|
|
|
@click="handleCreateOrder">创建订单
|
|
|
</el-button>
|
|
|
|
|
|
- <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">
|
|
|
- {{ 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" type="primary" plain>确认支付</el-button>
|
|
|
- </el-dialog>
|
|
|
+ <el-dialog v-model="orderDialogVisible" :before-close="handlePayDialogClose">
|
|
|
+ <el-row>
|
|
|
+ <span class="pay-dialog-title">订单支付</span>
|
|
|
+ <el-button v-if="refreshButtonVisible" @click="refreshPage()"
|
|
|
+ type="primary" plain class="pay-dialog-refresh-button">
|
|
|
+ 已完成支付,刷新界面
|
|
|
+ <el-icon>
|
|
|
+ <RefreshRight/>
|
|
|
+ </el-icon>
|
|
|
+ </el-button>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <div v-loading="isLoading">
|
|
|
+ <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">
|
|
|
+ {{ 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" type="primary" plain>确认支付</el-button>
|
|
|
+ </div>
|
|
|
|
|
|
+ </el-dialog>
|
|
|
</el-main>
|
|
|
</el-container>
|
|
|
</template>
|
|
|
@@ -391,4 +422,14 @@ function toBackPage() {
|
|
|
.buy-button {
|
|
|
margin-left: 30px;
|
|
|
}
|
|
|
+
|
|
|
+.pay-dialog-title {
|
|
|
+ font-size: 30px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.pay-dialog-refresh-button {
|
|
|
+ margin-left: 15px;
|
|
|
+ margin-top: 5px;
|
|
|
+}
|
|
|
</style>
|