From 9354604265d3a5fd05b8bb528749bdbab424cc79 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期三, 18 六月 2025 23:03:21 +0800
Subject: [PATCH] 上下架,库存调整
---
pages/goods-manager/updateSkus/updateSkus.vue | 114 ++++++++++++++++++++++
pages.json | 15 +++
pages/goods-manager/goodsList/goodsList.vue | 125 +++++++++++++++++++-----
api/goods.js | 36 +++++++
4 files changed, 264 insertions(+), 26 deletions(-)
diff --git a/api/goods.js b/api/goods.js
index 260a32d..16a6fd8 100644
--- a/api/goods.js
+++ b/api/goods.js
@@ -316,3 +316,39 @@
})
}
+export function upGoods(params) {
+ return http.request({
+ url: api.store + `/goods/goods/up`,
+ needToken: true,
+ method: Method.PUT,
+ params: params
+ })
+}
+export function lowGoods(params) {
+ return http.request({
+ url: api.store + `/goods/goods/under`,
+ needToken: true,
+ method: Method.PUT,
+ params: params
+ })
+}
+export function getGoodsSkuData(params) {
+ return http.request({
+ url: api.store + '/goods/goods/sku/list',
+ needToken: true,
+ method: Method.GET,
+ params: params
+ })
+}
+
+
+export function updateStocks(params) {
+ return http.request({
+ url: api.store + `/goods/goods/update/stocks`,
+ needToken: true,
+ method: Method.PUT,
+ header: { "content-type": "application/json" },
+ data: params
+ })
+}
+
diff --git a/pages.json b/pages.json
index 5931aad..ba01ce6 100644
--- a/pages.json
+++ b/pages.json
@@ -254,6 +254,21 @@
}
},
{
+ "path": "pages/goods-manager/updateSkus/updateSkus",
+ "style": {
+ "enablePullDownRefresh": true,
+ "navigationBarTitleText": "璋冩暣搴撳瓨",
+ "componentPlaceholder": {
+ "u-icon": "view",
+ "u-button": "view",
+ "u-form": "view",
+ "u-form-item": "view",
+ "u-input": "view",
+ "u-popup": "view"
+ }
+ }
+ },
+ {
"path": "pages/userPermissions/userPermissions",
"style": {
"navigationBarTitleText": "鐢ㄦ埛鏉冮檺",
diff --git a/pages/goods-manager/goodsList/goodsList.vue b/pages/goods-manager/goodsList/goodsList.vue
index e77a8be..d186625 100644
--- a/pages/goods-manager/goodsList/goodsList.vue
+++ b/pages/goods-manager/goodsList/goodsList.vue
@@ -5,7 +5,7 @@
<!-- 閫氳繃 uni-list--waterfall 绫诲喅瀹氶〉闈㈠竷灞�鏂瑰悜 -->
<!-- to 灞炴�ф惡甯﹀弬鏁拌烦杞鎯呴〉闈紝褰撳墠鍙负鍙傝�� -->
<view :border="!formData.waterfall" class="uni-list-item--waterfall" title="鑷畾涔夊晢鍝佸垪琛�"
- v-for="item in data" :key="item.id" @click="addGoods(item.id)">
+ v-for="item in data" :key="item.id" @click="toggle(item)">
<!-- 閫氳繃header鎻掓Ы瀹氫箟鍒楄〃宸︿晶鍥剧墖 -->
<view class="uni-thumb shop-picture" :class="{ 'shop-picture-column': formData.waterfall }">
@@ -32,9 +32,10 @@
item.buyCount || 0 }}
</view>
<view class="uni-note ellipsis">
- <text class="uni-link">涓婃灦</text>
+ <text :class="item.marketEnable == 'DOWN' ? 'market-down' : 'market-up'">{{
+ item.marketEnable == 'DOWN' ? "宸蹭笅鏋�" : "宸蹭笂鏋�" }}</text>
- <text class="uni-link" style="color:red;">鍒犻櫎</text>
+ <!--<text class="uni-link" style="color:red;">鍒犻櫎</text> -->
</view>
</view>
</view>
@@ -43,6 +44,7 @@
</view>
</view>
+ <view style="height: 80px;"></view>
</view>
<button type="default" class="btn" @click="addGoods('')">
@@ -51,6 +53,18 @@
</button>
<!-- 閫氳繃 loadMore 缁勪欢瀹炵幇涓婃媺鍔犺浇鏁堟灉锛屽闇�鑷畾涔夋樉绀哄唴瀹癸紝鍙弬鑰冿細https://ext.dcloud.net.cn/plugin?id=29 -->
<uni-load-more v-if="loading || formData.status === 'noMore'" :status="formData.status" />
+ <view>
+ <!-- 鏅�氬脊绐� -->
+ <uni-popup ref="popup" background-color="#fff">
+ <view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
+
+ <button type="default" @click="underOrup">{{ selectGoods.marketEnable == 'DOWN' ? '涓婃灦' : "涓嬫灦"
+ }}</button>
+
+ <button type="default" @click="stocks">璋冩暣搴撳瓨</button>
+ </view>
+ </uni-popup>
+ </view>
</view>
</template>
@@ -73,31 +87,11 @@
pageNumber: 1,
pageSize: 10,
},
- data: [
- {
- "id": 122,
- "goods_thumb": "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/83df593e6ba448ddbe6685d928e6fa65.jpg",
- "name": "銆愮垎娆俱�慉pple iPhone 11 (A2223) 64GB 娣辩┖鐏拌壊 绉诲姩鑱旈�氱數淇�4G鎵嬫満",
- "goods_price": "699.00",
- "goods_tip": "鐑崠涓�",
- "tag": [
- "鐑崠涓�",
- ]
- },
- {
- "id": 123,
- "goods_thumb": "https://lilishop-oss.oss-cn-beijing.aliyuncs.com/83df593e6ba448ddbe6685d928e6fa65.jpg",
- "name": "銆愮垎娆俱�慉pple iPhone 11 (A2223) 64GB 娣辩┖鐏拌壊 绉诲姩鑱旈�氱數淇�4G鎵嬫満",
- "goods_price": "699.00",
- "goods_tip": "鐑崠涓�",
- "tag": [
- "鐑崠涓�",
- ]
- }
- ],
+ data: [],
formData: {
status: 'loading', // 鍔犺浇鐘舵��
},
+ selectGoods: {},
tipShow: false // 鏄惁鏄剧ず椤堕儴鎻愮ず妗�
};
},
@@ -109,6 +103,48 @@
}
},
methods: {
+ underOrup() {
+ let params = {
+ goodsId: this.selectGoods.id,
+ };
+ this.$refs.popup.close()
+ if (this.selectGoods.marketEnable == 'DOWN') {
+ API_GOODS.upGoods(params).then((res) => {
+ uni.showLoading({
+ title: '涓婃灦鎴愬姛'
+ });
+
+ setTimeout(function () {
+ uni.hideLoading();
+ }, 2000);
+ this.getGoodsList();
+ })
+ }
+ else {
+ API_GOODS.lowGoods(params).then((res) => {
+ uni.showLoading({
+ title: '涓嬫灦鎴愬姛'
+ });
+
+ setTimeout(function () {
+ uni.hideLoading();
+ }, 2000);
+ this.getGoodsList();
+ })
+ }
+ },
+ stocks() {
+
+ this.$refs.popup.close()
+ var goodsId = this.selectGoods.id
+ uni.navigateTo({
+ url: `/pages/goods-manager/updateSkus/updateSkus${"?goodsId=" + goodsId}`,
+ });
+ },
+ toggle(item) {
+ this.$refs.popup.open('bottom')
+ this.selectGoods = item;
+ },
getGoodsList() {
uni.showLoading();
@@ -256,7 +292,6 @@
// 灏忕▼搴� 缂栬瘧鍚庝細澶氫竴灞傛爣绛撅紝鑰屽叾浠栧钩鍙版病鏈夛紝鎵�浠ラ渶瑕佺壒娈婂鐞嗕竴涓�
/deep/ .uni-list {
/* #endif */
- height: calc(100vh - 100px - 80px - 60px);
display: flex;
flex-direction: row;
flex-wrap: wrap;
@@ -303,4 +338,42 @@
margin-right: 10rpx;
}
}
+
+@mixin flex {
+ /* #ifndef APP-NVUE */
+ display: flex;
+ /* #endif */
+ flex-direction: row;
+}
+
+@mixin height {
+ /* #ifndef APP-NVUE */
+ height: 100%;
+ /* #endif */
+ /* #ifdef APP-NVUE */
+ flex: 1;
+ /* #endif */
+}
+
+.popup-content {
+ @include flex;
+ align-items: center;
+ justify-content: center;
+ padding: 15px;
+ height: 150px;
+ background-color: #fff;
+}
+
+.popup-height {
+ @include height;
+ width: 200px;
+}
+
+.market-down {
+ color: red;
+}
+
+.market-up {
+ color: green;
+}
</style>
\ No newline at end of file
diff --git a/pages/goods-manager/updateSkus/updateSkus.vue b/pages/goods-manager/updateSkus/updateSkus.vue
new file mode 100644
index 0000000..f781929
--- /dev/null
+++ b/pages/goods-manager/updateSkus/updateSkus.vue
@@ -0,0 +1,114 @@
+<template>
+ <view>
+ <view class="container">
+ <view class="item" v-for="item in skuList" :key="item.id">
+ <text class="label">{{ item.simpleSpecs }}</text>
+ <input class="input" placeholder="璇疯緭鍏ュ簱瀛樻暟閲�" value="{{item.quantity}}" @input="onInput"
+ data-id="{{item.id}}" />
+ </view>
+ </view>
+ <button type="default" class="btn" @click="updateSkus()">
+ <u-icon name="plus-circle"></u-icon>
+ 鏇存柊
+ </button>
+ </view>
+</template>
+<script>
+
+import * as API_GOODS from "@/api/goods.js";
+export default {
+ data() {
+ return {
+ routerVal: {},
+ skuParams: [],
+ skuList: []
+ }
+ },
+ onShow() {
+ var goodsId = this.routerVal.goodsId
+ let params = {
+ goodsId: goodsId,
+ pageSize: 100
+ };
+ API_GOODS.getGoodsSkuData(params).then((res) => {
+ this.skuList = res.data.result.records
+ res.data.result.records.forEach(item => {
+ this.skuParams.push({ skuId: item.id, quantity: item.quantity })
+ });
+ })
+ },
+ onLoad(option) {
+ uni.showLoading({
+ title: "鍔犺浇涓�",
+ });
+ this.routerVal = option;
+
+ uni.hideLoading();
+ },
+ methods: {
+ onInput(e) {
+ var id = e.currentTarget.dataset.id
+ for (let index = 0; index < this.skuParams.length; index++) {
+ if (this.skuParams[index].skuId == id)
+ this.skuParams[index].quantity = e.detail.value
+ }
+ },
+ updateSkus() {
+ API_GOODS.updateStocks(this.skuParams).then((res) => {
+ if (res.data.code == 200) {
+ uni.showToast({
+ title: "鏇存柊鎴愬姛",
+ icon: "success",
+ duration: 2000,
+ });
+ setTimeout(() => {
+ uni.navigateBack({
+ delta: 1,
+ });
+ })
+ }
+ })
+ }
+ }
+}
+</script>
+<style lang="scss" scoped>
+/* WXSS 鏂囦欢 */
+.container {
+ padding: 20px;
+}
+
+.item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 20px;
+}
+
+.label {
+ width: 80px;
+ text-align: right;
+ margin-right: 15px;
+}
+
+.input {
+ flex: 1;
+ border: 1px solid #ddd;
+ padding: 10px;
+ border-radius: 4px;
+}
+
+.btn {
+ background: $light-color;
+ position: fixed;
+ width: 690rpx;
+ bottom: 60rpx;
+ height: 80rpx;
+ left: 30rpx;
+ font-size: 30rpx;
+ line-height: 80rpx;
+
+ .u-icon {
+ margin-right: 10rpx;
+ }
+}
+</style>
\ No newline at end of file
--
Gitblit v1.8.0