fix: 预售商品时间问题
This commit is contained in:
		
							parent
							
								
									ee68f341a1
								
							
						
					
					
						commit
						adb0cb4f2c
					
				| 
						 | 
				
			
			@ -54,7 +54,7 @@
 | 
			
		|||
            ></el-col>
 | 
			
		||||
          </el-row>
 | 
			
		||||
          <el-form-item
 | 
			
		||||
            label="预计发货时间:"
 | 
			
		||||
            label="可预约发货时间:"
 | 
			
		||||
            prop="estimatedStartDeliveryTime"
 | 
			
		||||
          >
 | 
			
		||||
            <el-date-picker
 | 
			
		||||
| 
						 | 
				
			
			@ -67,9 +67,10 @@
 | 
			
		|||
              range-separator="至"
 | 
			
		||||
              start-placeholder="开始日期"
 | 
			
		||||
              end-placeholder="结束日期"
 | 
			
		||||
              :picker-options="pickerOptions"
 | 
			
		||||
              :picker-options="pickerOptions3"
 | 
			
		||||
            >
 | 
			
		||||
            </el-date-picker>
 | 
			
		||||
            <div style="color: red;">顾客支付定金时、可对此区间的日期进行预约,卖家须在顾客已选预约日进行发货</div>
 | 
			
		||||
          </el-form-item>
 | 
			
		||||
          <el-form-item label="定金可退:" prop="isRefundEarnestMoney">
 | 
			
		||||
            <el-radio v-model="ruleForm.isRefundEarnestMoney" :label="1"
 | 
			
		||||
| 
						 | 
				
			
			@ -378,6 +379,7 @@
 | 
			
		|||
<script>
 | 
			
		||||
import commodity from './commodity.vue'
 | 
			
		||||
import { debounce, cloneDeep } from 'lodash'
 | 
			
		||||
import dayjs from 'dayjs'
 | 
			
		||||
export default {
 | 
			
		||||
  components: { commodity },
 | 
			
		||||
  props: {
 | 
			
		||||
| 
						 | 
				
			
			@ -408,7 +410,7 @@ export default {
 | 
			
		|||
      },
 | 
			
		||||
      pickerOptions: {
 | 
			
		||||
        disabledDate(time) {
 | 
			
		||||
          return time.getTime() < Date.now()
 | 
			
		||||
          return time.getTime() <= dayjs().subtract(1, 'day').valueOf()
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      orderTime: [], //订单支付时间
 | 
			
		||||
| 
						 | 
				
			
			@ -420,7 +422,17 @@ export default {
 | 
			
		|||
            console.log(that.ruleForm.startTime)
 | 
			
		||||
            date = new Date(that.ruleForm.startTime).getTime()
 | 
			
		||||
          }
 | 
			
		||||
          return time.getTime() < date
 | 
			
		||||
          return time.getTime() <= dayjs(date).subtract(1, 'day').valueOf()
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      pickerOptions3: {
 | 
			
		||||
        disabledDate(time) {
 | 
			
		||||
          let date = Date.now()
 | 
			
		||||
          if (that.ruleForm && that.ruleForm.balancePaymentEndTime) {
 | 
			
		||||
            console.log(that.ruleForm.balancePaymentEndTime)
 | 
			
		||||
            date = new Date(that.ruleForm.balancePaymentEndTime).getTime()
 | 
			
		||||
          }
 | 
			
		||||
          return time.getTime() <= dayjs(date).valueOf()
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      delivery: [], //发货时间
 | 
			
		||||
| 
						 | 
				
			
			@ -630,6 +642,10 @@ export default {
 | 
			
		|||
              this.$refs.ruleForm.validate(valid => {
 | 
			
		||||
                if (valid) {
 | 
			
		||||
                  console.log(valid)
 | 
			
		||||
                  if (dayjs(this.ruleForm.startTime).isAfter(dayjs(this.ruleForm.balancePaymentStartTime))) {
 | 
			
		||||
                    this.$message.error('付尾款开始时间必须大于等于定金开始时间')
 | 
			
		||||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  if (
 | 
			
		||||
                    this.ruleForm.productList &&
 | 
			
		||||
                    this.ruleForm.productList.length === 0
 | 
			
		||||
| 
						 | 
				
			
			@ -638,6 +654,7 @@ export default {
 | 
			
		|||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  let pass = true
 | 
			
		||||
                  let moneyPass = true
 | 
			
		||||
                  let count = 0
 | 
			
		||||
                  this.ruleForm.productList.forEach(product => {
 | 
			
		||||
                    if (
 | 
			
		||||
| 
						 | 
				
			
			@ -660,6 +677,9 @@ export default {
 | 
			
		|||
                          if (!spec.advanceSellStockNum) {
 | 
			
		||||
                            pass = false
 | 
			
		||||
                          }
 | 
			
		||||
                          if (spec.presalePrice >= spec.earnestMoney) {
 | 
			
		||||
                            moneyPass = false
 | 
			
		||||
                          }
 | 
			
		||||
                        }
 | 
			
		||||
                      })
 | 
			
		||||
                    }
 | 
			
		||||
| 
						 | 
				
			
			@ -672,6 +692,10 @@ export default {
 | 
			
		|||
                    this.$message.error('请填写预售价、定金、预售库存')
 | 
			
		||||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  if (!moneyPass) {
 | 
			
		||||
                    this.$message.error('定金必须小于预售价')
 | 
			
		||||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  this.$api.preSale
 | 
			
		||||
                    .addPreSaleProducts(this.ruleForm)
 | 
			
		||||
                    .then(res => {
 | 
			
		||||
| 
						 | 
				
			
			@ -683,6 +707,10 @@ export default {
 | 
			
		|||
            } else {
 | 
			
		||||
              this.$refs.ruleForm.validate(valid => {
 | 
			
		||||
                if (valid) {
 | 
			
		||||
                  if (dayjs(this.ruleForm.startTime).isAfter(dayjs(this.ruleForm.balancePaymentStartTime))) {
 | 
			
		||||
                    this.$message.error('付尾款开始时间必须大于等于定金开始时间')
 | 
			
		||||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  console.log(valid)
 | 
			
		||||
                  if (
 | 
			
		||||
                    this.ruleForm.productSpecificationList &&
 | 
			
		||||
| 
						 | 
				
			
			@ -692,6 +720,7 @@ export default {
 | 
			
		|||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  let pass = true
 | 
			
		||||
                  let moneyPass = true
 | 
			
		||||
                  let count = this.ruleForm.productSpecificationList.filter(
 | 
			
		||||
                    spec => spec.isAdvanceSell
 | 
			
		||||
                  ).length
 | 
			
		||||
| 
						 | 
				
			
			@ -706,6 +735,9 @@ export default {
 | 
			
		|||
                      if (!spec.advanceSellStockNum) {
 | 
			
		||||
                        pass = false
 | 
			
		||||
                      }
 | 
			
		||||
                      if (spec.presalePrice >= spec.earnestMoney) {
 | 
			
		||||
                        moneyPass = false
 | 
			
		||||
                      }
 | 
			
		||||
                    }
 | 
			
		||||
                  })
 | 
			
		||||
                  if (!count) {
 | 
			
		||||
| 
						 | 
				
			
			@ -716,6 +748,10 @@ export default {
 | 
			
		|||
                    this.$message.error('请填写预售价、定金、预售库存')
 | 
			
		||||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  if (!moneyPass) {
 | 
			
		||||
                    this.$message.error('定金必须小于预售价')
 | 
			
		||||
                    return
 | 
			
		||||
                  }
 | 
			
		||||
                  this.$api.preSale
 | 
			
		||||
                    .updatePreSaleProducts(this.ruleForm)
 | 
			
		||||
                    .then(res => {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue