Pārlūkot izejas kodu

添加产品之前查询是否重复商品

xiaohaizhao 1 gadu atpakaļ
vecāks
revīzija
4f779a35fc

+ 2 - 2
packageA/activity/selectProduct/index.wxml

@@ -4,9 +4,9 @@
 	<navigator url="#" wx:for="{{list}}" wx:key="itemid" class="item-box">
 		<view class="top" bindtap="changeResults" data-id="{{item[idname]}}" data-item="{{item}}" bindtap="{{item.groupqty!=0 && item.maxQty<=0?'':'changeResult'}}">
 			<view class="image">
-				<van-image width="100%" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover}}" use-loading-slot use-error-slot lazy-load>
+				<van-image width="100%" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover||123123}}" use-loading-slot use-error-slot lazy-load>
 					<van-loading slot="loading" type="spinner" size="20" vertical />
-					<text slot="error">加载失败</text>
+					<text slot="error">暂无图片</text>
 				</van-image>
 			</view>
 			<view class="content">

+ 64 - 31
packageA/orderForm/modules/product/index.js

@@ -190,40 +190,73 @@ Component({
         /* 处理新增产品 */
         handleSelect(detail) {
             let that = this;
-            wx.showModal({
-                title: '提示',
-                content: `是否确认添加${detail.result.length}件商品?`,
-                complete: (res) => {
-                    if (res.confirm) _Http.basic({
-                        "id": 20221109093602,
-                        "content": {
-                            ...that.data.base,
-                            "items": detail.list.map(v => {
-                                return {
-                                    sa_orderitemsid: 0,
-                                    "itemid": v.itemid, //商品ID
-                                    "qty": v.qty, //数量
-                                    "width": v.width || 0,
-                                    "length": v.length || 0,
-                                    price: this.data.type == '工具订单' ? v.marketprice : v.contractprice,
-                                    sa_promotion_itemsid: v.sa_promotion_itemsid || 0
-                                }
-                            })
+
+            _Http.basic({
+                "id": 2024020201095102,
+                "content": {
+                    ...that.data.base,
+                    "items": detail.list
+                },
+            }).then(res => {
+                console.log("查询重复产品", res)
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.msg,
+                    icon: "none"
+                });
+                if (res.data.items.length) {
+                    wx.showModal({
+                        title: '提示',
+                        content: `本单已存在【${res.data.items[0].itemname}】商品,确认继续添加吗?`,
+                        complete: (res) => {
+                            if (res.cancel) {
+
+                            }
+
+                            if (res.confirm) handle()
                         }
-                    }).then(s => {
-                        console.log('新增产品', s)
-                        wx.showToast({
-                            title: s.msg == '成功' ? '添加成功' : s.msg,
-                            icon: "none"
-                        });
-                        if (s.msg == '成功') setTimeout(() => {
-                            that.getList(sa_orderid, true);
-                            wx.navigateBack();
-                            that.updateThePrice();
-                        }, 300)
                     })
+                } else {
+                    handle()
                 }
-            });
+            })
+            function handle() {
+                wx.showModal({
+                    title: '提示',
+                    content: `是否确认添加${detail.result.length}件商品?`,
+                    complete: (res) => {
+                        if (res.confirm) _Http.basic({
+                            "id": 20221109093602,
+                            content: {
+                                ...that.data.base,
+                                "items": detail.list.map(v => {
+                                    return {
+                                        sa_orderitemsid: 0,
+                                        "itemid": v.itemid, //商品ID
+                                        "qty": v.qty, //数量
+                                        "width": v.width || 0,
+                                        "length": v.length || 0,
+                                        price: that.data.type == '工具订单' ? v.marketprice : v.contractprice,
+                                        sa_promotion_itemsid: v.sa_promotion_itemsid || 0
+                                    }
+                                })
+                            }
+                        }).then(s => {
+                            console.log('新增产品', s)
+                            wx.showToast({
+                                title: s.msg == '成功' ? '添加成功' : s.msg,
+                                icon: "none"
+                            });
+                            if (s.msg == '成功') setTimeout(() => {
+                                that.getList(sa_orderid, true);
+                                wx.navigateBack();
+                                that.updateThePrice();
+                            }, 300)
+                        })
+                    }
+                });
+            }
+
+
         },
         /* 使用接口更新总价 */
         updateThePrice() {