xiaohaizhao 2 месяцев назад
Родитель
Сommit
a7afa840c7

+ 22 - 22
CRM/customer/modules/orderCreate/create.js

@@ -288,30 +288,30 @@ onTabChange(e) {
   });
 },
 // 打开添加商品面板
-addProduct() {
-  // 直接跳转到产品选择页面
-  wx.navigateTo({
-    url: `/select/product1/index?params=${JSON.stringify({
-      "id": "2026031312441901",
-      "content": {
-        "pageNumber": 1,
-        "pageSize": 20,
-        "where": {
-          "tablefilter": {
-            "itemname": null,
-            "itemno": null,
-            "model": null,
-            "guid_price": null,
-            "guid_price_cus": null,
-            "packageqty": null
+  addProduct() {
+    // 直接跳转到产品选择页面
+    wx.navigateTo({
+      url: `/CRM/customer/modules/orderCreate/productSelect/index?params=${JSON.stringify({
+        "id": "2026031312441901",
+        "content": {
+          "pageNumber": 1,
+          "pageSize": 20,
+          "where": {
+            "tablefilter": {
+              "itemname": null,
+              "itemno": null,
+              "model": null,
+              "guid_price": null,
+              "guid_price_cus": null,
+              "packageqty": null
+            }
           }
         }
-      }
-    })}&butText=添加商品`
-  });
-  // 设置全局回调函数
-  getApp().globalData.handleSelect = this.handleSelect.bind(this);
-},
+      })}&butText=添加商品`
+    });
+    // 设置全局回调函数
+    getApp().globalData.handleSelect = this.handleSelect.bind(this);
+  },
   // 处理选择商品回调
   handleSelect(detail) {
     if (detail && detail.list) {

+ 123 - 0
CRM/customer/modules/orderCreate/productSelect/index.js

@@ -0,0 +1,123 @@
+const _Http = getApp().globalData.http;
+
+Page({
+	data: {
+		loading: true,
+		params: {}, //请求体
+		result: [], //返回结果
+		radio: false, //是否为单选
+		idname: "sys_enterprise_itemid", //idkey
+		showName: "itemname",
+		privacyFieldC: []
+	},
+	onLoad(options) {
+		if (options.params) {
+			let params = JSON.parse(options.params);
+			if (!params.content.pageNumber || !params.content.pageTotal) {
+				params.content.pageNumber = 1;
+				params.content.pageTotal = 1;
+			}
+			this.setData({
+				params
+			});
+		};
+		this.setData({
+			radio: options.radio ? true : false,
+			idname: options.idname || this.data.idname,
+			showName: options.showName || this.data.showName
+		});
+		try {
+      let privacyFieldC = wx.getStorageSync('auth').writeOff.forms.list.formcols.map(v => v.title);
+      this.setData({
+        privacyFieldC
+      })
+      console.log("privacyFieldC", privacyFieldC)
+    } catch (error) {
+      console.error(error)
+    }
+		this.getList();
+	},
+	getList(init = false) {
+		//init 用于初始化分页
+		if (init.detail != undefined) init = init.detail;
+		let params = this.data.params;
+		if (init) params.content.pageNumber = 1
+		if (params.content.pageNumber > params.content.pageTotal) return;
+		_Http.basic(params).then(res => {
+			console.log("选择产品列表", res)
+			this.selectComponent('#ListBox').RefreshToComplete();
+			if (res.msg != '成功') return wx.showToast({
+				title: res.msg,
+				icon: "none"
+			})
+			this.setData({
+				'params.content.pageNumber': res.pageNumber + 1,
+				'params.content.pageTotal': res.pageTotal,
+				'params.content.total': res.total,
+				list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+				loading: false
+			})
+		})
+	},
+	/* 选中 */
+	changeResult(e) {
+		let {
+			id,
+			item
+		} = e.currentTarget.dataset, result = this.data.result;
+		if (this.data.radio) {
+			result = [id];
+		} else {
+			let isAdd = result.some(v => v == id);
+			if (!isAdd) {
+				result.push(id)
+			} else {
+				result = result.filter(v => v != id)
+			}
+		}
+		this.setData({
+			result
+		});
+		if (this.data.radio) this.submit();
+	},
+	/* 提交 */
+	submit() {
+		let result = this.data.result,
+			obj = this.data.radio ? {
+				id: result,
+				item: this.data.list.find(value => value[this.data.idname] == result),
+				value: [this.data.list.find(value => value[this.data.idname] == result)[this.data.showName], result]
+			} : {
+				result,
+				list: result.map(v => this.data.list.find(value => value[this.data.idname] == v)),
+				value: [result.map(v => {
+					let data = this.data.list.find(value => value[this.data.idname] == v);
+					return data ? data[this.data.showName] : ""
+				}), result]
+			}
+		getApp().globalData.handleSelect && getApp().globalData.handleSelect(obj)
+	},
+	/* 开始搜索 */
+	startSearch({
+		detail
+	}) {
+		let condition = this.data.content ? this.data.content.where.tablefilter.itemname : this.data.params.content.where.tablefilter.itemname;
+		if (detail == condition) return;
+		this.setData({
+			'content.where.tablefilter.itemname': detail,
+			'params.content.where.tablefilter.itemname': detail
+		});
+		this.getList(true);
+	},
+	/* 取消搜索 */
+	onClear() {
+		this.setData({
+			'content.where.tablefilter.itemname': "",
+			'params.content.where.tablefilter.itemname': ""
+		});
+		this.getList(true);
+	},
+	onUnload() {
+		getApp().globalData.handleSelect = null;
+	}
+})

+ 9 - 0
CRM/customer/modules/orderCreate/productSelect/index.json

@@ -0,0 +1,9 @@
+{
+  "usingComponents": {
+    "van-search": "@vant/weapp/search/index",
+    "van-checkbox": "@vant/weapp/checkbox/index",
+    "van-button": "@vant/weapp/button/index",
+    "Yl_ListBox": "/components/Yl_ListBox/index",
+    "Yl_Empty": "/components/Yl_Empty/index"
+  }
+}

+ 84 - 0
CRM/customer/modules/orderCreate/productSelect/index.scss

@@ -0,0 +1,84 @@
+.search {
+  background-color: #f5f5f5;
+}
+
+.total {
+  padding: 10rpx 20rpx;
+  font-size: 24rpx;
+  color: #999;
+  background-color: #f5f5f5;
+  border-bottom: 1rpx solid #e8e8e8;
+}
+
+.setclient-list-item {
+  background-color: #fff;
+  margin-bottom: 10rpx;
+}
+
+.mian {
+  display: flex;
+  padding: 20rpx;
+  position: relative;
+}
+
+.checkbox {
+  margin-right: 20rpx;
+  display: flex;
+  align-items: center;
+}
+
+.dec {
+  flex: 1;
+}
+
+.title {
+  font-size: 32rpx;
+  font-weight: bold;
+  color: #333;
+  margin-bottom: 10rpx;
+}
+
+.subfield {
+  font-size: 24rpx;
+  color: #666;
+  margin-bottom: 8rpx;
+}
+
+.line-1 {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.text-red {
+  color: #ff4d4f;
+}
+
+.footer {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  padding: 20rpx;
+  background-color: #fff;
+  border-top: 1rpx solid #e8e8e8;
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+}
+
+.count {
+  font-size: 28rpx;
+  color: #333;
+}
+
+.but {
+  width: 180rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  border-radius: 8rpx !important;
+  font-size: 32rpx;
+  background-color: #3874F6;
+  color: #fff;
+}

+ 59 - 0
CRM/customer/modules/orderCreate/productSelect/index.wxml

@@ -0,0 +1,59 @@
+<van-search class="search" value="{{ params.content.where.tablefilter.itemname }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<view class="total">共{{params.content.total}}个</view>
+<Yl_ListBox id='ListBox' bind:getlist='getList'>
+    <view class="setclient-list-item" wx:for="{{list}}" wx:key="itemno">
+        <navigator url="#" class="mian" data-id="{{item.sys_enterprise_itemid}}" data-item="{{item}}" bindtap="changeResult">
+            <view class="checkbox">
+                <van-checkbox wx:if="{{!radio}}" value="{{ handle.isCheck(item.sys_enterprise_itemid,result) }}" shape="square" icon-size='28rpx' />
+            </view>
+            <view class="dec">
+                <view class="title line-1">
+                    {{item.itemname}}
+                </view>
+                <view class="subfield line-1">
+                    品号:{{item.itemno}}
+                </view>
+                <view class="subfield">
+                    型号:{{item.model||' --'}}
+                </view>
+                <view class="subfield">
+                    指导价格:{{item.guid_price || ' --'}}
+                </view>
+                <view class="subfield">
+                    自定义指导价格:{{item.guid_price_cus || ' --'}}
+                </view>
+                <view class="subfield">
+                    包装数量:{{item.packing_qty || ' --'}}
+                </view>
+                <view class="subfield">
+                    是否上架:<text class="{{item.isonsale == 0 ? 'text-red' : ''}}">{{item.isonsale == 1 ? '是' : '否'}}</text>
+                </view>
+                <view class="subfield">
+                    商品类型:{{item.prodtype == 1 ? '配件' : '其他'}}
+                </view>
+            </view>
+        </navigator>
+    </view>
+    <view wx:if="{{!radio}}" style="height: 130rpx;" />
+    <Yl_Empty wx:if="{{list.length==0}}" />
+</Yl_ListBox>
+
+<block wx:if="{{!radio}}">
+    <view class="footer">
+        <view class="count">
+            已选:{{result.length}}
+        </view>
+        <van-button custom-class='but' color='#3874F6' disabled='{{result.length==0}}' bind:click="submit">确定</van-button>
+    </view>
+    <wxs module="handle">
+        module.exports = {
+            isCheck: function (id, list) {
+                return list.some(function (v) {
+                    return v == id
+                });
+            },
+        }
+    </wxs>
+</block>
+
+<wxs src="/utils/hidePrice.wxs" module="handleHide" />

+ 2 - 1
app.json

@@ -125,7 +125,8 @@
         "lead/detail",
         "customer/modules/order/details",
         "customer/modules/followRecord/create",
-        "customer/modules/orderCreate/create"
+        "customer/modules/orderCreate/create",
+        "customer/modules/orderCreate/productSelect/index"
       ]
     }
   ],