Преглед изворни кода

商品管理添加剩余库存查看

ltx529596 пре 4 година
родитељ
комит
afcb0e7c9a
3 измењених фајлова са 89 додато и 30 уклоњено
  1. 11 8
      src/pages/index/index.vue
  2. 78 22
      src/pages/shop/shopdetail.vue
  3. BIN
      src/static/images/ref.png

+ 11 - 8
src/pages/index/index.vue

@@ -98,7 +98,7 @@
 									订单总量
 								</view>
 								<view class="num">
-									{{orderSun.num *100}}
+									{{parseInt(orderSun.num *100)}}
 								</view>
 								<view class="ratio">
 									<view class="detail">
@@ -341,7 +341,8 @@ export default {
 
       orderMessage: {},
 
-      today: moment().format('YYYY-MM-DD HH:mm:ss'),
+      todayforday: moment().format('YYYY-MM-DD HH:mm:ss'),
+      today: moment().format('YYYY-MM-DD'),
       this_day: moment().format('YYYY.MM.DD'),
 
       // 数据还可以优化
@@ -397,6 +398,7 @@ export default {
     },
   },
   onShow() {
+    this.todayforday = moment().format('YYYY-MM-DD HH:mm:ss')
     _self = this;
     this.cWidth = uni.upx2px(690); // upx2px 转换为px
     this.cHeight = uni.upx2px(300);
@@ -407,6 +409,7 @@ export default {
     this.loading = false;
 
     getDataBuyTime = setInterval(() => {
+      this.todayforday = moment().format('YYYY-MM-DD HH:mm:ss')
       this.loading = false;
       this.getShopList();
       this.$mHelper.toast(`自动更新数据${moment().format('h:mm:ss')}`);
@@ -507,7 +510,7 @@ export default {
       }
       await this.$http
         .get('/homePage/gjzs', {
-          date: this.today,
+          date: this.todayforday,
           shopId: this.shopID,
         })
         .then(async (res) => {
@@ -592,7 +595,7 @@ export default {
       }
       await this.$http
         .get('/homePage/pendingTransaction', {
-          date: this.today,
+          date: this.todayforday,
           shopId: this.shopID,
         })
         .then(async (res) => {
@@ -614,7 +617,7 @@ export default {
       }
       await this.$http
         .get('/homePage/getData2', {
-          date: this.today,
+          date: this.todayforday,
           shopId: this.shopID,
         })
         .then(async (res) => {
@@ -735,7 +738,7 @@ export default {
       }
       await this.$http
         .get('/homePage/getData3', {
-          date: this.today,
+          date: this.todayforday,
           shopId: this.shopID,
         })
         .then(async (res) => {
@@ -855,7 +858,7 @@ export default {
       }
       await this.$http
         .get('/homePage/getData0', {
-          date: this.today,
+          date: this.todayforday,
           shopId: this.shopID,
         })
         .then(async (res) => {
@@ -958,7 +961,7 @@ export default {
       this.loadingMore4 = true;
       await this.$http
         .get('/homePage/getData1', {
-          date: this.today,
+          date: this.todayforday,
           shopId: this.shopID,
         })
         .then(async (res) => {

+ 78 - 22
src/pages/shop/shopdetail.vue

@@ -95,7 +95,7 @@
           <view class="txt" @tap="toClassify">管理分类</view>
         </view>
       </view>
-      <!-- 西线推荐 -->
+      <!-- 分类 -->
       <view class="xiline detail-list">
         <view class="menu">
           <view class="uni-list-cell">
@@ -217,10 +217,7 @@
                     <view class="txt">
                       <text class="txt1"> {{ item.name }}</text>
                       <text> {{ item.know }}</text>
-                      <view
-                        class="inventory"
-                        v-if="item.name === '限日库存模式'"
-                      >
+                      <view class="inventory"  v-if="item.name === '限日库存模式'">
                         <text class="name">日库存数:</text>
                         <input
                           class="dateInventory"
@@ -229,6 +226,12 @@
                           v-model="dateInventory"
                         />
                       </view>
+
+                      <view class="ref" v-if="item.name === '限日库存模式'">
+                        <text class="residue">今日剩余库存:<text class="residuenum"> {{ todayResidue }}</text></text>
+                        <image class="reficon" src="../../static/images/ref.png" @tap="refToday"></image>
+                      </view>
+
                       <view
                         class="inventory"
                         v-if="item.name === '限总库存模式'"
@@ -241,6 +244,11 @@
                           v-model="sunInventory"
                         />
                       </view>
+
+                      <view class="ref" v-if="item.name === '限总库存模式'">
+                        <text class="residue">当前剩余总库存:<text class="residuenum"> {{ sunResidue }}</text></text>
+                        <image class="reficon" src="../../static/images/ref.png" @tap="refSun"></image>
+                      </view>
                     </view>
                   </label>
                 </radio-group>
@@ -374,6 +382,7 @@ export default {
       scenicId: uni.getStorageSync('scenicId'),
       title: '商品详情',
       showoperat: false,
+      salerule: '',
 
       placeholderContent: '请输入内容...',
       mastKnow: '',
@@ -448,6 +457,9 @@ export default {
       sunInventory: 0,
       inventory: '',
 
+      todayResidue: 0,
+      sunResidue: 0,
+
       bookingnum: '',
 
       bookingList: [
@@ -475,9 +487,6 @@ export default {
       },
     };
   },
-  onUnload () {
-    uni.removeStorageSync('Id');
-  },
   onShow () {
     if (this.storeId != '') {
       this.getLine(this.storeId)
@@ -523,6 +532,7 @@ export default {
           });
         }
         let rule = JSON.parse(this.shopData.saleRuleJson);
+
         if (rule) {
           this.astrictDate.data.saleDay = rule.data.saleDay
             ? rule.data.saleDay
@@ -531,10 +541,11 @@ export default {
             ? rule.data.saleNum
             : 1;
           // 有效期模式
-          this.astrictDate.dateSetting = rule.data.dateSetting;
+          this.astrictDate.data.dateSetting = rule.data.dateSetting;
           this.patterIndex = +rule.data.dateSetting;
           // 库存模式
-          this.astrictDate.goodsStockFlag = rule.data.goodsStockFlag;
+          this.astrictDate.data.goodsStockFlag = rule.data.goodsStockFlag;
+          this.getResidue()
           this.shopNumIndex = +rule.data.goodsStockFlag;
 
           if (this.shopNumIndex === 1) {
@@ -544,6 +555,7 @@ export default {
           }
           // 预订数量
           this.astrictDate.data.bookRule = rule.data.bookRule;
+
           // 实名制
           if (rule.data.isRealName === '0') {
             this.trueNme = true;
@@ -551,9 +563,10 @@ export default {
             this.trueNme = false;
           }
           this.astrictDate.data.isRealName = rule.data.isRealName;
+
           // 可退规则
           this.bookingIndex = +rule.data.usubscribeRule;
-          this.astrictDate.usubscribeRule = rule.data.usubscribeRule;
+          this.astrictDate.data.usubscribeRule = rule.data.usubscribeRule;
           // 二维码
           if (rule.data.isShowQrcode === '0') {
             this.codeShow = true;
@@ -565,8 +578,10 @@ export default {
         // 限制购票回显
         if (this.shopData.saleRule === '1') {
           this.showoperat = true;
+          this.salerule = '1'
         } else {
           this.showoperat = false;
+          this.salerule = '0'
         }
         this.loading = false;
       });
@@ -621,6 +636,31 @@ export default {
       }
 
       this.astrictDate.data.goodsStockFlag = e.detail.value;
+      this.getResidue()
+    },
+    // 剩余库存
+    async getResidue () {
+      console.log(this.astrictDate.data.goodsStockFlag);
+      await this.$http.get('/goods/getInventory',{
+        id:this.SHOPID,
+        goodsStockFlag: this.astrictDate.data.goodsStockFlag
+      }).then( res =>{
+        if (res.code === 200 && res.msg ==='OK') {
+          if (+this.astrictDate.data.goodsStockFlag === 1) {
+            this.todayResidue = res.data.now_inventory
+          } else if (+this.astrictDate.data.goodsStockFlag === 2) {
+            this.sunResidue = res.data.now_inventory
+          }
+        }
+      })
+    },
+    refToday () {
+      this.todayResidue = '...'
+      this.getResidue()
+    },
+    refSun () {
+      this.sunResidue = '...'
+      this.getResidue()
     },
     // 可退模式
     bookingChange (e) {
@@ -952,13 +992,13 @@ export default {
         return
       }
 
-      // 判断是否限制账号购买
+      // 判断是否限制账号购买 
       if (this.showoperat) {
-        this.showoperat = '1';
+        this.salerule = '1'
       } else {
-        this.showoperat = '0';
-        this.astrictDate.data.saleDay = 0;
-        this.astrictDate.data.saleNum = 0;
+        this.salerule = '0'
+        this.astrictDate.data.saleDay = '';
+        this.astrictDate.data.saleNum = '';
       }
       let name = '';
       if (this.typeProperty === 1) {
@@ -1037,17 +1077,14 @@ export default {
           imges: JSON.stringify(this.Imglist) || '',
           del: this.shopData.del || '',
           upDown: this.shopData.upDown || '',
-          saleRule: this.showoperat, // 限制购票
+          saleRule: this.salerule, // 限制购票
           saleRuleJson: JSON.stringify(this.astrictDate),
           //  自营
           name: name,
           salePrice: this.price * 100 || null,
           price: this.rateprice * 100 || null,
-          expiredTime:
-            this.expirationDate === '请选择商品过期日期'
-              ? ''
-              : this.expirationDate,
-          inventory: this.inventory,
+          expiredTime:this.expirationDate === '请选择商品过期日期'? '': this.expirationDate,
+          inventory: this.inventory
         })
         .then((res) => {
           if (res.code === 200 && res.msg === 'OK') {
@@ -1330,6 +1367,25 @@ export default {
             }
             .dateInventory {
               flex: 1;
+              color: #232828;
+            }
+          }
+          .ref {
+            display: flex;
+            align-items: center;
+            .residue {
+              color:  #232828;
+            }
+            .residuenum{
+              margin-left: 15upx;
+              color: firebrick;
+              font-weight: 700;
+            }
+            .reficon{
+              margin-left: 30upx;
+              width: 30upx;
+              height: 30upx;
+              z-index: 10;
             }
           }
         }

BIN
src/static/images/ref.png