فهرست منبع

新增产品类别

zhaoxiaohai 3 سال پیش
والد
کامیت
bdd30a69ed

+ 65 - 0
packageA/contract/modules/discount/type/add/index.js

@@ -0,0 +1,65 @@
+const _Http = getApp().globalData.http;
+Page({
+    data: {
+        result: [],
+        "content": {
+            "sa_contractid": 1,
+            "pageNumber": 1,
+            "pageSize": 20,
+            "where": {
+                "condition": ""
+            }
+        },
+    },
+    onLoad(options) {
+        this.setData({
+            "content.sa_contractid": options.sa_contractid
+        })
+        this.getList();
+    },
+    toggle(e) {
+        const {
+            itemclassid
+        } = e.currentTarget.dataset.item;
+        let result = this.data.result;
+        let index = result.findIndex(v => v == itemclassid);
+        index == -1 ? result.push(itemclassid + "") : result.splice(index, 1);
+        this.setData({
+            result
+        })
+    },
+    getList(init = false) {
+        let content = this.data.content;
+        if (init) content.pageNumber = 1;
+        if (content.pageNumber > content.pageTotal) return;
+        _Http.basic({
+            "id": 20221124140102,
+            content
+        }).then(res => {
+            console.log("可添加类别", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                "paging.pageNumber": res.pageNumber + 1,
+                "paging.pageTotal": res.pageTotal,
+                "paging.total": res.total,
+            })
+        })
+    },
+    submit() {
+        let page = getCurrentPages().find(v => v.__route__ == 'packageA/contract/detail');
+        if (page) page.selectComponent("#PiscountType").handleAdd(this.data.result.map(v => {
+            return {
+                "sa_contract_itemsaleclassid": 0,
+                "itemclassid": v,
+                "discountrate": 1
+            }
+        }))
+    },
+    onReachBottom() {
+        this.getList();
+    },
+})

+ 4 - 0
packageA/contract/modules/discount/type/add/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "选择类别"
+}

+ 27 - 0
packageA/contract/modules/discount/type/add/index.scss

@@ -0,0 +1,27 @@
+.value-class {
+    flex: none !important;
+}
+
+.new-footer {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+    position: fixed;
+    width: 100vw;
+    height: 130rpx;
+    background: #FFFFFF;
+    box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+    bottom: 0;
+
+    .new-submit {
+        width: 156rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 8rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+        margin-right: 30rpx;
+    }
+}

+ 13 - 0
packageA/contract/modules/discount/type/add/index.wxml

@@ -0,0 +1,13 @@
+<van-checkbox-group value="{{ result }}" bind:change="onChange">
+    <van-cell-group>
+        <van-cell wx:for="{{ list }}" wx:key="item.itemclassid" title="{{ item.itemclassname }}" label="{{item.brandname?'品牌:'+item.brandname:''}}" value-class="value-class" clickable data-item="{{ item }}" bind:click="toggle">
+            <van-checkbox name="{{ item.itemclassid }}" />
+        </van-cell>
+    </van-cell-group>
+</van-checkbox-group>
+
+<My_empty wx:if="{{list.length==0}}" />
+<view style="height: 130rpx;" />
+<view class="new-footer">
+    <van-button custom-class='new-submit' disabled='{{!result.length}}' bindclick='submit'>提交</van-button>
+</view>

+ 5 - 28
packageA/contract/modules/discount/type/index.js

@@ -52,46 +52,23 @@ Component({
                 })
             })
         },
-        /* 去选择产品 */
-        addProduct() {
-            let params = {
-                "id": 20221124093602,
-                modle: "#PiscountProduct",
-                "version": 1,
-                "content": {
-                    nocache: true,
-                    sa_contractid: this.data.sa_contractid,
-                    pageNumber: 1,
-                    pageTotal: 1,
-                    total: null,
-                    where: {
-                        condition: "",
-                    }
-                }
-            };
-            console.log("添加产品", params)
-            wx.navigateTo({
-                url: '/packageA/select/product/select?params=' + JSON.stringify(params)
-            })
-        },
-        /* 处理选择产品 */
-        handleSelectProduct(items) {
-            console.log(this.data.sa_contractid)
+        /* 处理新增 */
+        handleAdd(items) {
             let that = this;
             wx.showModal({
                 title: '提示',
-                content: '是否确认添加产品?',
+                content: '是否确认添加产品类别?',
                 complete: ({
                     confirm
                 }) => {
                     if (confirm) _Http.basic({
-                        "id": 20221123164402,
+                        "id": 20221124110202,
                         "content": {
                             "sa_contractid": that.data.sa_contractid,
                             items
                         }
                     }).then(res => {
-                        console.log("产品明细添加产品", res);
+                        console.log("添加产品类别", res);
                         wx.showToast({
                             title: res.msg != '成功' ? res.msg : '添加成功!',
                             icon: "none"

+ 1 - 1
packageA/contract/modules/discount/type/index.wxml

@@ -4,7 +4,7 @@
         <!-- <navigator url="#" class="but">
             <van-icon name="search" />
         </navigator> -->
-        <navigator wx:if="{{!disabled}}" url="#" class="but" bindtap="addProduct">
+        <navigator wx:if="{{!disabled}}" url="/packageA/contract/modules/discount/type/add/index?sa_contractid={{sa_contractid}}" class="but">
             <van-icon name="plus" />
         </navigator>
     </view>