Sfoglia il codice sorgente

添加标品列表增加分页;
创建商品修改校验

lishanshan 8 mesi fa
parent
commit
1c791516d2
3 ha cambiato i file con 117 aggiunte e 82 eliminazioni
  1. 1 1
      pages/product/creatProduct.vue
  2. 112 77
      pages/product/creatStandard.vue
  3. 4 4
      pages/product/usable.vue

+ 1 - 1
pages/product/creatProduct.vue

@@ -1200,7 +1200,7 @@ export default {
 				});
 				return
 			}
-			if (!this.form.availableEndDate && !this.form.expirationDays) {
+			if (!this.form.useType) {
 				uni.showToast({
 					title: '请选择可用时间',
 					icon: 'none'

+ 112 - 77
pages/product/creatStandard.vue

@@ -21,31 +21,42 @@
 			</view>
 		</view>
 		<view class="list">
-			<view class="product_item" v-for="(item, index) in productList" :key="index">
-				<view class="details">
-					<view class="img">
-						<image :src="item.productImage" mode=""></image>
-					</view>
-					<view class="data">
-						<span>{{ item.productName }}</span>
-						<!-- <span>售卖时间:{{item.time}}</span> -->
-						<!-- <view class="repertory">售卖时间:{{ item.saleStartDate }} - {{ item.saleEndDate }}</view> -->
-						<view class="price">
-							<span style="font-size: 22rpx;margin: 0px;">¥</span>{{ item.soldPrice }}
-							<span style="color:#999 ;font-size: 22rpx; text-decoration: line-through;">¥{{ item.price }}</span>
-						</view>
-					</view>
-					<view class="ticket" v-if="item.isRights == 1">
-						<image src="/static/product/ticket.png" mode=""></image>
-					</view>
-					<view class="tag" @click.stop="select(item)">
-						<!-- <span>组合套餐</span>
-						<span class="frame"></span> -->
-						<image src="/static/product/select.png" mode="" v-if="item.select"></image>
-						<image src="/static/product/round.png" mode="" v-else></image>
-					</view>
-				</view>
-			</view>
+		  <ListScrollView 
+		    ref="listScroll"
+		    :api="api"
+		    :init="initParams"
+		    :pageSize="10"
+		    :keyName="'records'"
+		    @afterFetch="afterFetch"
+		  >
+		    <template v-slot:list="{ data }">
+		      <view class="product_item" v-for="(item, index) in data" :key="index">
+		        <view class="details">
+		          <view class="img">
+		            <image :src="item.productImage" mode=""></image>
+		          </view>
+		          <view class="data">
+		            <span>{{ item.productName }}</span>
+								<!-- <span>售卖时间:{{item.time}}</span> -->
+								<!-- <view class="repertory">售卖时间:{{ item.saleStartDate }} - {{ item.saleEndDate }}</view> -->
+		            <view class="price">
+		              <span style="font-size: 22rpx;margin: 0px;">¥</span>{{ item.soldPrice }}
+		              <span style="color:#999 ;font-size: 22rpx; text-decoration: line-through;">¥{{ item.price }}</span>
+		            </view>
+		          </view>
+		          <view class="ticket" v-if="item.isRights == 1">
+		            <image src="/static/product/ticket.png" mode=""></image>
+		          </view>
+							<view class="tag" @click.stop="select(item)">
+								<!-- <span>组合套餐</span>
+								<span class="frame"></span> -->
+								<image src="/static/product/select.png" mode="" v-if="item.select"></image>
+								<image src="/static/product/round.png" mode="" v-else></image>
+							</view>
+		        </view>
+		      </view>
+		    </template>
+		  </ListScrollView>
 		</view>
 		<view class="creat">
 			<view class="operate">
@@ -63,7 +74,11 @@
 
 <script>
 	import configService from '../../common/service/config.service'
+	import ListScrollView from '@/components/list-scroll-view/index.vue';
 	export default {
+		components: {
+			ListScrollView
+		},
 		data() {
 			return {
 				isManage: false,
@@ -74,7 +89,11 @@
 				productName: '',
 				productList: [],
 				merchantId: '',
-				tabIndex: 1
+				api: {
+        	url: '/app/product/purveyor/list',
+        	method: 'GET'
+      	},
+      	initParams: {},
 			}
 		},
 		methods: {
@@ -98,64 +117,76 @@
 
 			},
 			add() {
-				if (this.productList.filter(e => e.select).map(e => e.productId).length > 0) {
-					let ids = this.productList.filter(e => e.select).map(e => e.productId).join(',')
-
-					this.$http.get("/app/product/addPurveyorProduct?ids=" + ids + '&merchantId=' + this.merchantId)
-						.then(res => {
-							if (res.data.code == 200) {
-								this.$tip.success(res.data.message || '添加成功');
-								this.back()
-							} else {
-								uni.showToast({
-									icon:'error',
-									title:'不能重复添加'
-								})
-								// this.$tip.error(res.data.message);
-								
-							}
-						})
-				} else {
-					this.$tip.alert('请选择品牌标品');
-
-				}
+			  const dataList = this.$refs.listScroll?.dataList || [];
+			  const selectedProducts = dataList.filter(e => e.select);
+			
+			  if (selectedProducts.length > 0) {
+			    let ids = selectedProducts.map(e => e.productId).join(',');
+				
+			    this.$http.get("/app/product/addPurveyorProduct?ids=" + ids + '&merchantId=' + this.merchantId)
+			      .then(res => {
+			        if (res.data.code == 200) {
+			          this.$tip.success(res.data.message || '添加成功');
+			          this.back()
+			        } else {
+			          uni.showToast({
+			            icon:'error',
+			            title:'不能重复添加'
+			          })
+			        }
+			      })
+			  } else {
+			    this.$tip.alert('请选择品牌标品');
+			  }
 			},
 			select(item) {
 				item.select = !item.select
 			},
-			//全选
+			// 全选
 			allSelect() {
-				if (this.isAll) {
-					this.isAll = false
-					this.productList.forEach(item => {
-						item.select = false
-					})
-				} else {
-					this.isAll = true
-					this.productList.forEach(item => {
-						item.select = true
-					})
-				}
+			  if (this.isAll) {
+			    this.isAll = false;
+			    // 更新ListScrollView组件内部的数据列表
+			    if (this.$refs.listScroll && this.$refs.listScroll.dataList) {
+			      this.$refs.listScroll.dataList.forEach(item => {
+			        item.select = false;
+			      });
+			    }
+			  } else {
+			    this.isAll = true;
+			    // 更新ListScrollView组件内部的数据列表
+			    if (this.$refs.listScroll && this.$refs.listScroll.dataList) {
+			      this.$refs.listScroll.dataList.forEach(item => {
+			        item.select = true;
+			      });
+			    }
+			  }
 			},
 			getProductList() {
-				this.$http.get("/app/product/purveyor/list?merchantId=" + this.merchantId + "&productStatus=" + this
-						.productStatus +
-						'&productName=' + this.productName, )
-					.then(res => {
-						if (res.data.code == 200) {
-							res.data.result.records.forEach((item) => {
-								item.select = false;
-								// item.saleEndDate = item.saleEndDate.includes('00:00:00') ? item.saleEndDate.slice(0, 10) : item
-								// 	.saleEndDate
-								// item.saleStartDate = item.saleStartDate.includes('00:00:00') ? item.saleStartDate.slice(0, 10) :
-								// 	item.saleStartDate
-								// item.productImage = configService.apiUrl + '/' + item.productImage
-							})
-							this.productList = res.data.result.records
-						}
-					})
+				// 更新初始化参数
+      	this.initParams = {
+      	  merchantId: this.merchantId,
+      	  productStatus: this.productStatus,
+      	  productName: this.productName
+      	};
+      	// 重置列表
+      	if (this.$refs.listScroll) {
+      	  this.$refs.listScroll.reloadList(this.initParams);
+      	}
 			},
-
+			// 数据加载完成后的回调
+    	afterFetch(result) {
+  			if (result && result.records && Array.isArray(result.records)) {
+  			  result.records.forEach((item) => {
+						item.select = false;
+						// item.saleEndDate = item.saleEndDate.includes('00:00:00') ? item.saleEndDate.slice(0, 10) : item
+						// 	.saleEndDate
+						// item.saleStartDate = item.saleStartDate.includes('00:00:00') ? item.saleStartDate.slice(0, 10) :
+						// 	item.saleStartDate
+						// item.productImage = configService.apiUrl + '/' + item.productImage
+  			  });
+  			}
+    	},
 		},
 		onShow() {
 			
@@ -174,7 +205,11 @@
 				key: 'group',
 			});
 
-		}
+		},
+		onLoad() {
+  	  // 初始化列表
+  	  this.getProductList();
+  	}
 		// async onShow() {
 		// 	let that = this
 		// 	uni.getStorage({

+ 4 - 4
pages/product/usable.vue

@@ -32,8 +32,8 @@
 					<view class="title now">
 						固定时间段
 						<view class="picker">
-							<u-input placeholder="去设置" v-model="showDate" @click="selectDate" />
-							<u-icon name="arrow-right" style="margin-left: 17rpx;"></u-icon>
+							<u-input placeholder="去设置" v-model="showDate"/>
+							<u-icon name="arrow-right" style="margin-left: 17rpx;" @click="selectDate" ></u-icon>
 						</view>
 					</view>
 				</u-radio>
@@ -91,9 +91,9 @@ export default {
 		},
 		selectDate() {
 			// this.isSelectDate = true
-			if (this.value == 'date') {
+			// if (this.value == 'date') {
 				this.$refs.rangTime.open()
-			}
+			// }
 		},
 		save() {
 			console.log(this.value)