于继渤 1 سال پیش
والد
کامیت
56f4bf23ae

+ 145 - 114
package-base-select/pages/select-goods/select-goods.js

@@ -19,13 +19,13 @@ Page({
   data: {
     firstFlag: true,
     orderBy: [{
-        "text": "可售量升序",
-        "value": 1
-      },
-      {
-        "text": "可售量降序",
-        "value": 2
-      }
+      "text": "可售量升序",
+      "value": 1
+    },
+    {
+      "text": "可售量降序",
+      "value": 2
+    }
     ],
     routeObjName: 'goodsSku',
     dataItem: null,
@@ -38,30 +38,30 @@ Page({
     catId: null,
     active: 0,
     popContent: [{
-        code: 'itemQty',
-        type: 'step',
-        title: '数量',
-        required: true
-      },
-      {
-        code: 'whId',
-        name: 'whName',
-        title: '仓库',
-        type: 'choose',
-        urlKey: 'chooseWh'
-      },
-      {
-        code: 'skuSpec',
-        title: '规格',
-        type: 'str',
-        readonly: true,
-        dropType: ''
-      },
-      {
-        code: 'nonStdCode',
-        title: '商品批次',
-        type: 'str',
-      },
+      code: 'itemQty',
+      type: 'step',
+      title: '数量',
+      required: true
+    },
+    {
+      code: 'whId',
+      name: 'whName',
+      title: '仓库',
+      type: 'choose',
+      urlKey: 'chooseWh'
+    },
+    {
+      code: 'skuSpec',
+      title: '规格',
+      type: 'str',
+      readonly: true,
+      dropType: ''
+    },
+    {
+      code: 'nonStdCode',
+      title: '商品批次',
+      type: 'str',
+    },
     ],
     popupTopObj: [{
       leftTitle: '库存量',
@@ -125,35 +125,35 @@ Page({
     if (this.data.item == Constants.billType.sale) {
       this.setData({
         popContent: [{
-            code: 'itemQty',
-            type: 'step',
-            title: mixins.$t("count"),
-            required: true
-          },
-          {
-            code: 'priceSale',
-            type: 'number',
-            title: mixins.$t("priceSale"),
-            required: true,
-            center: 'right'
-          },
-          {
-            code: 'whId',
-            name: 'whName',
-            title: mixins.$t("warehouseId"),
-            type: 'choose',
-            urlKey: 'openingInventory',
-          },
-          {
-            code: 'nonStdCode',
-            title: mixins.$t("goodsBatch"),
-            type: 'str',
-          },
-          {
-            code: 'flgGift',
-            title: mixins.$t("flgGift"),
-            type: 'checkbox',
-          },
+          code: 'itemQty',
+          type: 'step',
+          title: mixins.$t("count"),
+          required: true
+        },
+        {
+          code: 'priceSale',
+          type: 'number',
+          title: mixins.$t("priceSale"),
+          required: true,
+          center: 'right'
+        },
+        {
+          code: 'whId',
+          name: 'whName',
+          title: mixins.$t("warehouseId"),
+          type: 'choose',
+          urlKey: 'openingInventory',
+        },
+        {
+          code: 'nonStdCode',
+          title: mixins.$t("goodsBatch"),
+          type: 'str',
+        },
+        {
+          code: 'flgGift',
+          title: mixins.$t("flgGift"),
+          type: 'checkbox',
+        },
         ]
       })
     }
@@ -162,64 +162,64 @@ Page({
     if (this.data.item == Constants.billType.saleOut || this.data.item == Constants.billType.saleOutReturn) {
       this.setData({
         popContent: [{
-            code: 'itemQty',
-            type: 'step',
-            title: mixins.$t("count"),
-            required: true
-          },
-          {
-            code: 'priceOut',
-            type: 'number',
-            title: mixins.$t("priceSale"),
-            required: true,
-            readonly: false,
-            center: 'right'
-          },
-          {
-            code: 'whId',
-            name: 'whName',
-            choosePopupType: 'inventorySku',
-            title: mixins.$t("warehouseId"),
-            type: 'choose',
-            urlKey: 'selectInventorySku',
-          },
-          {
-            code: 'nonStdCode',
-            title: mixins.$t("goodsBatch"),
-            type: 'str',
-          },
+          code: 'itemQty',
+          type: 'step',
+          title: mixins.$t("count"),
+          required: true
+        },
+        {
+          code: 'priceOut',
+          type: 'number',
+          title: mixins.$t("priceSale"),
+          required: true,
+          readonly: false,
+          center: 'right'
+        },
+        {
+          code: 'whId',
+          name: 'whName',
+          choosePopupType: 'inventorySku',
+          title: mixins.$t("warehouseId"),
+          type: 'choose',
+          urlKey: 'selectInventorySku',
+        },
+        {
+          code: 'nonStdCode',
+          title: mixins.$t("goodsBatch"),
+          type: 'str',
+        },
         ]
       })
     }
     if (this.data.item == Constants.billType.purReturn) {
       this.setData({
         popContent: [{
-            code: 'itemQty',
-            type: 'step',
-            title: mixins.$t("count"),
-            required: true
-          },
-          {
-            code: 'priceStandard',
-            type: 'number',
-            title: mixins.$t("pricePur"),
-            required: true,
-            readonly: true,
-            center: 'right'
-          },
-          {
-            code: 'whId',
-            name: 'whName',
-            choosePopupType: 'inventorySku',
-            title: mixins.$t("warehouseId"),
-            type: 'choose',
-            urlKey: 'selectInventorySku',
-          },
-          {
-            code: 'nonStdCode',
-            title: mixins.$t("goodsBatch"),
-            type: 'str',
-          },
+          code: 'itemQty',
+          type: 'step',
+          title: mixins.$t("count"),
+          required: true
+        },
+        {
+          code: 'priceStandard',
+          type: 'number',
+          title: mixins.$t("pricePur"),
+          required: true,
+          readonly: true,
+          center: 'right'
+        },
+        {
+          code: 'whId',
+          name: 'whName',
+          choosePopupType: 'inventorySku',
+          title: mixins.$t("warehouseId"),
+          type: 'choose',
+          urlKey: 'selectInventorySku',
+        },
+        {
+          code: 'nonStdCode',
+          title: mixins.$t("goodsBatch"),
+          type: 'str',
+        },
         ]
       })
     }
@@ -325,6 +325,19 @@ Page({
         tableData: tableData
       })
     }
+    //处理图片
+    if (tableData && tableData.length > 0) {
+      tableData.forEach(item => {
+        if (item.skuImages && item.skuImages.value) {
+          item.skuImages.value = JSON.parse(item.skuImages.value)
+          console.log('item.skuImages.value', item.skuImages.value[0].url)
+          item['imagesUrl'] = item.skuImages.value.length > 0 ? item.skuImages.value[0].url : null
+        }
+      })
+      this.setData({
+        tableData: tableData
+      })
+    }
 
     if (this.data.controlFlags && this.data.controlFlags.sourcePage == "inventory-adjustment") { //库存调整 设置
       let popContent = this.data.popContent
@@ -349,7 +362,7 @@ Page({
         })
       }
       if (tableData && tableData.length > 0) {
-        tableData.forEach(element => { 
+        tableData.forEach(element => {
           if (element.skuImages && element.skuImages.length > 0) {
             element.skuImages.forEach(item => {
               item.url = config.image_url + item.path
@@ -374,6 +387,24 @@ Page({
     }
   },
   /**
+   * @desc : 删除已选
+   * @date : 2024/2/1 15:49
+   * @author : 于继渤
+   */
+  delChoosedGoodsItem(e) {
+    console.log('delChoosedGoodsItem', e)
+    let index = e.currentTarget.dataset.index
+    let choosedGoodsList = this.data.choosedGoodsList
+    choosedGoodsList.splice(index, 1)
+    this.setData({
+      choosedGoodsList: choosedGoodsList
+    })
+  },
+
+
+
+
+  /**
    * @desc : 获取种类
    * @date : 2024/2/1 15:49
    * @author : 于继渤
@@ -484,7 +515,7 @@ Page({
         url: chooseRoute,
         events: {
           // 回调后
-          bindData: function (data) {}
+          bindData: function (data) { }
         },
         success: function (res) {
           let data = {

+ 17 - 22
package-base-select/pages/select-goods/select-goods.wxml

@@ -1,19 +1,12 @@
 <wxs module="m1">
   var displayPrice = function (item) {
     var numberFormat = require("/utils/numberFormat.wxs");
-    // 如果有促销显示标准售价,如果正常品显示标价
-    // if (item.promotionType == 0) {
-    //优先显示促销价
+
     if (item.pricePromotion) {
       return '¥' + numberFormat.toThousandCents(item.pricePromotion)
     } else {
       return '¥' + numberFormat.toThousandCents(item.priceStandard)
     }
-
-    // } else {
-    //   return '¥' + numberFormat.toThousandCents(item.pricePromotion)
-    // }
-    // return ''
   }
   module.exports.displayPrice = displayPrice
 </wxs>
@@ -43,8 +36,14 @@
       商品列表
     </view>
 
-    <view bind:tap="selectedProduct" data-active="{{1}}" class="{{ active == 0 ? 'selected-product selected-product-color-02' : 'selected-product selected-product-color-01'}}">
-      已选商品
+    <view bind:tap="selectedProduct" data-active="{{1}}" class="{{ active == 0 ? 'selected-product selected-product-color-02' : 'selected-product selected-product-color-01'}}" style="position: relative;" >
+
+        <view>已选商品</view>
+     
+  
+      <view wx:if="{{choosedGoodsList.length > 0}}" style="position: absolute;top:16rpx;right: 40rpx;">
+        <view class="icon">{{choosedGoodsList.length}}</view>
+      </view>
     </view>
   </view>
 </van-sticky>
@@ -59,16 +58,15 @@
       <view wx:for="{{tableData}}" wx:key="index" border="{{ false }}" class="goods-cell-class" data-item="{{item}}" bind:tap="openAddItemInfo">
         <view class="goods-item-class">
           <view> 
-            <van-image radius="15rpx" custom-class="goods-item-image" fit="fill" src="{{item.skuImages? item.skuImages[0].url : '' }}" />
+            <van-image radius="15rpx" custom-class="goods-item-image" fit="fill" src="{{item.imagesUrl}}" />
           </view>
           <view style="margin-left: 26rpx;width: 100%; ">
             <!-- 标题 -->
             <view>
-              <dk-text fontSize="24rpx" value="{{item.skuCode}}"></dk-text>
-              <!-- <dk-title fontSize="28rpx" titleTag="{{item.brandName}}" title="{{item.skuCode}}"></dk-title> -->
+              <dk-title  titleTag="{{item.brandName}}" title="{{item.skuModel}}"></dk-title>
             </view>
             <!-- 描述 -->
-            <view style="display: flex; ">
+            <view style="display: flex;padding-top: 10rpx;">
               <dk-text fontSize="24rpx" value="{{item.skuName}}"></dk-text>
             </view>
             <view style="display: flex;align-items: flex-end;margin-top:20rpx;">
@@ -208,13 +206,13 @@
         <van-swipe-cell right-width="{{ 65 }}" data-index="{{index}}" async-close bind:close="delChoosedGoodsItem">
           <view class="goods-item-class">
             <view>
-              <van-image radius="15rpx" custom-class="goods-item-image" fit="fill" src="{{item.skuImages? item.skuImages.path : '' }}" />
+              <van-image radius="15rpx" custom-class="goods-item-image" fit="fill" src="{{item.imagesUrl }}" />
             </view>
             <view style="margin-left: 26rpx;width: 100%;">
               <view data-item="{{item}}" data-index="{{index}}" bind:tap="openChoosedItemInfo">
                 <!-- 标题 -->
                 <view style="display: flex;">
-                  <dk-title titleTag="{{item.brandName}}" title="{{item.skuCode}}"></dk-title>
+                  <dk-title titleTag="{{item.brandName}}" title="{{item.skuModel}}"></dk-title>
                 </view>
                 <!-- 描述 -->
                 <view style="display: flex; ">
@@ -287,20 +285,17 @@
 
 
 
-<dk-popup wx:if="{{ billType != 'sale' && billType != 'saleOut' }}" type="sale"   descCol="skuName" titleTagCol="shortName" titleCol="skuModel" priceCol="pricePromotion" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjName}}" priceTitle="参考价:"  priceCol="pricePurchase" contentObj="{{popContent}}" bind:commit="editItems">
+<dk-popup wx:if="{{ billType != 'sale' && billType != 'saleOut' }}" type="sale"   descCol="skuName" titleTagCol="brandName" titleCol="skuModel" priceCol="pricePromotion" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjName}}" priceTitle="参考价:"  priceCol="pricePurchase" contentObj="{{popContent}}" bind:commit="editItems">
 </dk-popup>
 
 
 
-<dk-popup wx:if="{{ billType == 'sale' }}" type="sale" titleTagCol="shortName" subCol="skuCode" descCol="skuName" titleCol="skuModel" priceTitle="标价:" priceCol="priceStandard" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjName}}" contentObj="{{popContent}}" bind:commit="editItems">
+<dk-popup wx:if="{{ billType == 'sale' }}" type="sale" titleTagCol="brandName" subCol="skuCode" descCol="skuName" titleCol="skuModel" priceTitle="标价:" priceCol="priceStandard" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjName}}" contentObj="{{popContent}}" bind:commit="editItems">
 </dk-popup>
 
-<dk-popup wx:if="{{ billType == 'saleOut'}}" type="sale" titleTagCol="brandName" subCol="skuCode" descCol="skuModel" titleCol="skuName" priceTitle="标价:" priceCol="priceStandard" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjName}}" contentObj="{{popContent}}" bind:commit="editItems" popupTopObj="{{popupTopObj}}">
+<dk-popup wx:if="{{ billType == 'saleOut'}}" type="sale" titleTagCol="brandName" subCol="skuCode" descCol="skuName" titleCol="skuModel" priceTitle="标价:" priceCol="priceStandard" value="{{dataItem}}" show="{{showPop}}" routeObjName="{{routeObjName}}" contentObj="{{popContent}}" bind:commit="editItems" popupTopObj="{{popupTopObj}}">
 </dk-popup>
 
-
-<!-- <dk-save-button cssType="{{ (billType == 'sale' || billType == 'saleOut' )? 'shopping':''}}" model:value="{{btnFormData}}" btnAutoWidthFlag="{{false}}" btnRightFlag="{{true}}" buttonList="{{buttonList}}" contentList="{{contentList}}" bind:open="submit"></dk-save-button> -->
-
 <dk-save-button  cssType="sale" model:value="{{btnFormData}}" btnAutoWidthFlag="{{false}}" btnRightFlag="{{true}}" buttonList="{{buttonList}}" contentList="{{contentList}}" bind:open="submit"></dk-save-button>
 
 <!-- 仓库 -->

+ 9 - 0
package-base-select/pages/select-goods/select-goods.wxss

@@ -31,6 +31,15 @@ page {
   border-color: #3E69F6 !important;
 }
 
+.icon {
+  width: 40rpx;
+  height: 40rpx;
+  background-color: red;
+  border-radius: 50%;
+  box-sizing: border-box;
+  color: white;
+}
+
 .van-empty {
   border-bottom: 0px solid #ffffff !important;
 }

+ 14 - 1
pages/shopping/shopping.js

@@ -45,7 +45,20 @@ Page({
       { type: 'count', code: 'count', quantity: 0 }
     ]
   },
-
+  /**
+   * @desc : 删除已选
+   * @date : 2024/2/1 15:49
+   * @author : 于继渤
+   */
+  delChoosedGoodsItem(e) {
+    console.log('delChoosedGoodsItem', e)
+    let index = e.currentTarget.dataset.index
+    let choosedGoodsList = this.data.choosedGoodsList
+    choosedGoodsList.splice(index, 1)
+    this.setData({
+      choosedGoodsList: choosedGoodsList
+    })
+  },
 
   /**
    * @desc : 左侧分类切换

+ 3 - 0
pages/shopping/shopping.wxss

@@ -45,6 +45,9 @@ page{
   font-weight: 600 !important;
 }
 
+.van-sidebar-item--selected {
+  border-color: #3E69F6 !important;
+}
 .sidebar-item {
   padding: 30rpx 25rpx 20rpx 35rpx !important;
   font-size: 13px !important;

+ 28 - 29
utils/numberFormat.wxs

@@ -37,49 +37,48 @@ function toIntFixed(value) {
 }
 //千分符
 function toThousandCents(num) {
-  if(num == undefined){
+  if (num == undefined) {
     return 0;
   }
   var num = num + '';
-    var d = '';
-    if (num.slice(0, 1) == '-'){
-      d = num.slice(0, 1);
-      num = num.slice(1);
-    }
-    var len = num.length;
-    var index = num.indexOf('.');
-    if (index == -1) {
-      num = num + '.00';
-    } else if ((index + 2) == len) {
-      num = num + '0';
-    }
-    var index = num.indexOf('.'); // 字符出现的位置
-    var num2 = num.slice(-3);
-    num = num.slice(0,index)
-    var result = '';
-    while (num.length > 3) {
-      result = ',' + num.slice(-3) + result;
-      num = num.slice(0, num.length - 3);
-    }
-    if (num) {
-      result = num + result;
-    }
-    return d + (result + num2)
+  var d = '';
+  if (num.slice(0, 1) == '-') {
+    d = num.slice(0, 1);
+    num = num.slice(1);
+  }
+  var len = num.length;
+  var index = num.indexOf('.');
+  if (index == -1) {
+    num = num + '.00';
+  } else if ((index + 2) == len) {
+    num = num + '0';
+  }
+  var index = num.indexOf('.'); // 字符出现的位置
+  var num2 = num.slice(-3);
+  num = num.slice(0, index)
+  var result = '';
+  while (num.length > 3) {
+    result = ',' + num.slice(-3) + result;
+    num = num.slice(0, num.length - 3);
+  }
+  if (num) {
+    result = num + result;
+  }
+  return d + (result + num2)
 }
 
-function toPercent(point){
-  var percent = parseFloat(point*100).toFixed(2);
+function toPercent(point) {
+  var percent = parseFloat(point * 100).toFixed(2);
   return percent;
 }
 
 function toThousandCents2(num) {
-  if(num == undefined){
+  if (num == undefined) {
     num = 0
   }
   num.toLocaleString()
 }
 
-
 /**
  * //暴露接口调用
  */