Browse Source

Merge branch 'master' of http://git.qiniu1314.com/cmy/jztCashier

cmy 1 year ago
parent
commit
a3bbbd921c

+ 43 - 0
src/components/buuug7-simple-datetime-picker_0.7.0/changelog.md

@@ -0,0 +1,43 @@
+# CHANGELOG
+
+## 0.7.0(2023-07-11)
+- 增加`time-init`属性, 自定义初始时间, 默认为当前时间, 值为时间戳
+## 0.6.0(2023-07-11)
+
+- 增加对秒的选择
+- 增加`timeHidden`属性, 自定义年月日时分秒自由显示
+- 增加`timeLabel`属性, 自定义界面时间单位,默认为 `["年", "月", "日", "时", "分", "秒"]`
+- 修复微信小程序中无法定位到当前时间
+
+## 0.5.0(2021-08-17)
+
+- refactor
+
+## 0.4.1(2021-08-17)
+
+- update readme.md
+
+## 0.4.0(2021-08-17)
+
+- 移除组件 `color` 属性
+- update readme.md
+
+## 0.3.3(2021-08-15)
+
+- 修改插件基本信息
+
+## 0.3.2(2021-08-15)
+
+- 更新文档
+
+## 0.3.1(2021-08-15)
+
+- fix
+
+## 0.3.0(2019-07-22)
+
+- 增加 color 属性,可以更换按钮颜色
+
+## 0.0.4(2019-07-17)
+
+- 增加从 npm 安装方式

+ 342 - 0
src/components/buuug7-simple-datetime-picker_0.7.0/components/buuug7-simple-datetime-picker/buuug7-simple-datetime-picker.vue

@@ -0,0 +1,342 @@
+<template>
+  <div class="buuug7-simple-datetime-picker" v-if="done">
+    <div
+      class="mask"
+      :class="{ show: open }"
+      @touchmove.stop.prevent
+      catchtouchmove="true"
+    >
+    </div>
+    <div class="wrap" :class="{ show: open }">
+      <div class="picker-header" @touchmove.stop.prevent catchtouchmove="true">
+        <div class="btn-picker cancel" @click="open = false">取消</div>
+        <div class="btn-picker submit" @click="_onSubmit">确定</div>
+      </div>
+      <div class="picker-body">
+        <picker-div :value="value" @change="_onChange">
+          <picker-div-column v-if="timeHide[0]">
+            <div class="column-item" v-for="item in years" :key="item">
+              {{ item + timeLabel[0] }}
+            </div>
+          </picker-div-column>
+          <picker-div-column v-if="timeHide[1]">
+            <div class="column-item" v-for="item in months" :key="item">
+              {{ formatNum(item) + timeLabel[1] }}
+            </div>
+          </picker-div-column>
+          <picker-div-column v-if="timeHide[2]">
+            <div class="column-item" v-for="item in days" :key="item">
+              {{ formatNum(item) + timeLabel[2] }}
+            </div>
+          </picker-div-column>
+          <picker-div-column v-if="timeHide[3]">
+            <div class="column-item" v-for="item in hours" :key="item">
+              {{ formatNum(item) + timeLabel[3] }}
+            </div>
+          </picker-div-column>
+          <picker-div-column v-if="timeHide[4]">
+            <div class="column-item" v-for="item in minutes" :key="item">
+              {{ formatNum(item) + timeLabel[4] }}
+            </div>
+          </picker-div-column>
+          <picker-div-column v-if="timeHide[5]">
+            <div class="column-item" v-for="item in seconds" :key="item">
+              {{ formatNum(item) + timeLabel[5] }}
+            </div>
+          </picker-div-column>
+        </picker-div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "buuug7-simple-datetime-picker",
+  props: {
+    startYear: {
+      type: Number,
+      default: 2000,
+    },
+    endYear: {
+      type: Number,
+      default: 2099,
+    },
+    timeLabel: {
+      type: Array,
+      default: () => ["年", "月", "日", "时", "分", "秒"],
+    },
+    timeHide: {
+      type: Array,
+      default: () => [true, true, true, true, true, false],
+    },
+    timeInit: {
+      type: Number,
+      default: new Date().valueOf(),
+    },
+  },
+
+  data() {
+    return {
+      open: false,
+      years: [],
+      months: [],
+      days: [],
+      hours: [],
+      minutes: [],
+      seconds: [],
+      year: "",
+      month: "",
+      day: "",
+      hour: "",
+      minute: "",
+      second: "",
+      value: [0, 0, 0, 0, 0, 0],
+      done: false,
+    };
+  },
+
+  computed: {
+    currentDatetime() {
+      return new Date(this.timeInit);
+    },
+  },
+
+  mounted() {
+    this.init();
+  },
+
+  watch: {
+    month() {
+      this.initDays();
+    },
+  },
+
+  methods: {
+    init() {
+      this.initYears();
+      this.initMonths();
+      this.initDays();
+      this.initHours();
+      this.initMinutes();
+      this.initSeconds();
+      this.setSelectValue();
+      this.done = true;
+    },
+
+    initYears() {
+      const years = [];
+      for (let year = this.startYear; year <= this.endYear; year++) {
+        years.push(year);
+        if (this.currentDatetime.getFullYear() === year) {
+          this.$set(this.value, 0, year - this.startYear);
+        }
+      }
+      this.years = years;
+    },
+
+    initMonths() {
+      const months = [];
+      for (let month = 1; month <= 12; month++) {
+        months.push(month);
+        if (this.currentDatetime.getMonth() + 1 === month) {
+          this.$set(this.value, 1, month - 1);
+        }
+      }
+      this.months = months;
+    },
+
+    initDays() {
+      const value = this.value;
+      const selectedYear = this.years[value[0]];
+      const selectedMonth = this.months[value[1]];
+      const days = [];
+      const totalDays = new Date(selectedYear, selectedMonth, 0).getDate();
+      for (let day = 1; day <= totalDays; day++) {
+        days.push(day);
+        if (this.currentDatetime.getDate() === day) {
+          this.$set(value, 2, day - 1);
+        }
+      }
+      this.days = days;
+    },
+
+    initHours() {
+      const hours = [];
+      for (let hour = 0; hour <= 23; hour++) {
+        hours.push(hour);
+        if (this.currentDatetime.getHours() === hour) {
+          this.$set(this.value, 3, hour);
+        }
+      }
+      this.hours = hours;
+    },
+
+    initMinutes() {
+      const minutes = [];
+      for (let minute = 0; minute < 60; minute++) {
+        minutes.push(minute);
+        if (this.currentDatetime.getMinutes() === minute) {
+          this.$set(this.value, 4, minute);
+        }
+      }
+      this.minutes = minutes;
+    },
+
+    initSeconds() {
+      const seconds = [];
+      for (let second = 0; second < 60; second++) {
+        seconds.push(second);
+        if (this.currentDatetime.getSeconds() === second) {
+          this.$set(this.value, 5, second);
+        }
+      }
+      this.seconds = seconds;
+    },
+
+    show() {
+      this.open = true;
+    },
+
+    hide() {
+      this.open = false;
+    },
+
+    _onChange(e) {
+      this.value = e.detail.value;
+      this.setSelectValue();
+    },
+
+    setSelectValue() {
+      const v = this.value;
+
+      this.year = this.years[v[0]];
+      this.month = this.months[v[1]];
+      this.day = this.days[v[2]];
+      this.hour = this.hours[v[3]];
+      this.minute = this.minutes[v[4]];
+      this.second = this.seconds[v[5]];
+    },
+
+    _onSubmit() {
+      const {
+        year,
+        month,
+        day,
+        hour,
+        minute,
+        second,
+        formatNum,
+        timeHide,
+        timeLabel,
+      } = this;
+      const result = {
+        year: timeHide[0] ? formatNum(year) : "",
+        month: timeHide[1] ? formatNum(month) : "",
+        day: timeHide[2] ? formatNum(day) : "",
+        hour: timeHide[3] ? formatNum(hour) : "",
+        minute: timeHide[4] ? formatNum(minute) : "",
+        second: timeHide[5] ? formatNum(second) : "",
+      };
+		let yytime = `${result.year}-${result.month}-${result.day} ${result.hour}:${result.minute}`;
+		let newTime = new Date()
+		let date = new Date(yytime)
+		if(date.getTime() < newTime.getTime() ) {
+			this.$emit("err");				   
+		}else {
+			this.$emit("submit", result);
+			this.hide();
+		}
+     
+    },
+
+    formatNum(num) {
+      return num < 10 ? "0" + num : num + "";
+    },
+  },
+};
+</script>
+
+<style lang="stylus">
+// $transition: all 0.3s ease;
+// $primary: #488ee9;
+
+.buuug7-simple-datetime-picker {
+  position: relative;
+  z-index: 999;
+  picker-div {
+    height: 100%;
+  }
+  .mask {
+    position: fixed;
+    z-index: 1000;
+    top: 0;
+    right: 0;
+    bottom: 0;
+    left: 0;
+    background-color: rgba(0, 0, 0, 0.4);
+    visibility: hidden;
+    opacity: 0;
+    transition: all 0.3s ease;
+    &.show {
+      visibility: visible;
+      opacity: 1;
+    }
+  }
+  .wrap {
+    z-index: 1001;
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    width: 100%;
+    transition: all 0.3s ease;
+    transform: translateY(100%);
+    &.show {
+      transform: translateY(0);
+    }
+  }
+  .picker-header {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+    padding: 8px 8px;
+    background-color: darken(#fff, 2%);
+    background-color: #fff;
+  }
+  .picker-body {
+    width: 100%;
+    height: 420rpx;
+    overflow: hidden;
+    background-color: #fff;
+  }
+  .column-item {
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+  }
+  .btn-picker {
+    position: relative;
+    display: inline-block;
+    padding-left: 10px;
+    padding-right: 10px;
+    box-sizing: border-box;
+    text-align: center;
+    text-decoration: none;
+    line-height: 2;
+    -webkit-tap-highlight-color: transparent;
+    overflow: hidden;
+    background-color: #eee;
+    font-size: 14px;
+    border-radius: 3px;
+    color: #000;
+    cursor: pointer;
+  }
+  .btn-picker.submit {
+    background-color:#488ee9;
+    color: #fff;
+  }
+}
+</style>

+ 77 - 0
src/components/buuug7-simple-datetime-picker_0.7.0/package.json

@@ -0,0 +1,77 @@
+{
+  "id": "buuug7-simple-datetime-picker",
+  "displayName": "简单的日期时间选择器",
+  "version": "0.7.0",
+  "description": "uniApp 简单的日期时间选择器, 可选择年, 月, 日, 时, 分, 秒",
+  "keywords": [
+    "时间",
+    "日期",
+    "时间选择器",
+    "日期时间选择器",
+    "datetime"
+],
+  "repository": "",
+  "engines": {
+    "HBuilderX": "^3.6.1"
+  },
+"dcloudext": {
+    "sale": {
+      "regular": {
+        "price": "0.00"
+      },
+      "sourcecode": {
+        "price": "0.00"
+      }
+    },
+    "contact": {
+      "qq": "3190136675"
+    },
+    "declaration": {
+      "ads": "无",
+      "data": "无",
+      "permissions": "无"
+    },
+    "npmurl": "",
+    "type": "component-vue"
+  },
+  "uni_modules": {
+    "dependencies": [],
+    "encrypt": [],
+    "platforms": {
+      "cloud": {
+        "tcb": "y",
+        "aliyun": "y"
+      },
+      "client": {
+        "App": {
+          "app-vue": "y",
+          "app-nvue": "u"
+        },
+        "H5-mobile": {
+          "Safari": "y",
+          "Android Browser": "y",
+          "微信浏览器(Android)": "y",
+          "QQ浏览器(Android)": "y"
+        },
+        "H5-pc": {
+          "Chrome": "y",
+          "IE": "n",
+          "Edge": "y",
+          "Firefox": "y",
+          "Safari": "y"
+        },
+        "小程序": {
+          "微信": "y",
+          "阿里": "u",
+          "百度": "u",
+          "字节跳动": "u",
+          "QQ": "u"
+        },
+        "快应用": {
+          "华为": "u",
+          "联盟": "u"
+        }
+      }
+    }
+  }
+}

+ 97 - 0
src/components/buuug7-simple-datetime-picker_0.7.0/readme.md

@@ -0,0 +1,97 @@
+# uniApp 简单的日期时间选择器
+
+uniApp 日期时间选择器, 可选择年, 月, 日, 时, 分, 秒.
+
+## screenshot
+
+<p>
+  <img align=top src="https://img-cdn-aliyun.dcloud.net.cn/stream/plugin_screens/19363640-a869-11e9-a6c7-7fb99abe2bbf_0.png?1629144139" width="300px" height="auto">
+</p>
+
+## 安装
+
+推荐从[dcloud 插件市场](https://ext.dcloud.net.cn/plugin?id=592) 安装.
+
+## 用法
+
+在 template 中:
+
+```vue
+<template>
+  <view>
+    <button type="default" @click="openDatetimePicker">open picker</button>
+    <buuug7-simple-datetime-picker
+      ref="myPicker"
+      @submit="handleSubmit"
+      :start-year="2000"
+      :end-year="2099"
+      :time-init="1688860800000"
+      :time-hide="[true, true, true, true, true, false]"
+      :time-label="['年', '月', '日', '时', '分', '秒']"
+    />
+  </view>
+</template>
+```
+
+在 script 中:
+
+- 该插件遵循 easycom 规范, 不用显式导入就可以使用 `<buuug7-simple-datetime-picker />`
+- 如需显式导入可以使用`import SimpleDateTimePicker from "uni_modules/buuug7-simple-datetime-picker/components/buuug7-simple-datetime-picker/buuug7-simple-datetime-picker.vue";`
+
+```javascript
+export default {
+  data() {
+    return {
+      birthday: "",
+    };
+  },
+  methods: {
+    // 打开picker
+    openDatetimePicker() {
+      this.$refs.myPicker.show();
+    },
+
+    // 关闭picker
+    closeDatetimePicker() {
+      this.$refs.myPicker.hide();
+    },
+
+    handleSubmit(e) {
+      // console.log(e);
+      // {year: "2023", month: "07", day: "11", hour: "15", minute: "21", seconds: '55'}
+      this.birthday = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${seconds}`;
+    },
+  },
+};
+```
+
+> Note: 不要把组件放 swiper 里面或者 v-for 里面等, 最好放在页面根部. 通常情况下打开 picker 需要调用`this.$refs.refName.show()`, 在选择完毕后 picker 会自动隐藏,不需要调用`this.$refs.refName.hide()`来手动隐藏。
+
+## 属性说明
+
+#### start-year
+
+类型 `Number`,选择开始年份
+
+#### end-year
+
+类型 `Number`, 选择结束年份
+
+#### time-init
+
+类型`Number`, 自定义初始时间, 默认为当前时间, 值为时间戳
+
+#### time-hidden
+
+类型 `Array`, 自定义时间列显示,默认显示年月日日分 `[true, true, true, true, true, false]`
+
+- 只显示年月日, 则可以设置为`[true, true, true, false, false, false]`
+- 时分秒, 则可以设置为`[false, false, false, true, true, true]`
+
+#### time-label
+
+类型 `Array`, 自定义各个时间单位,默认为 `['年', '月', '日', '时', '分', '秒']`, 比如想切换成显示英文的年月日, 可以设置 `['year', 'month', 'day', 'hour', 'minute', 'second']`
+
+#### @submit
+
+类型 `function`, 监听选择事件, 回调函数的第一个参数包含了选择时间的完整信息

BIN
src/components/buuug7-simple-datetime-picker_0.7.0/screenshot_1.png


+ 50 - 5
src/pages/cashier/reservation.vue

@@ -62,6 +62,15 @@
 											</div>
 										</div>
 									</div>
+									<div class="title acea-row row-middle">
+										<div style="padding-right: 20px;">
+											预约时间:
+										</div>
+										<DatePicker type="date" placeholder="请选择预约日期" style="width: 150px"
+											v-model="chooseDay" />
+										<TimePicker format="HH:mm" placeholder="请选择预约时间" style="width: 100px"
+											v-model="chooseTime" />
+									</div>
 									<div class="count">
 										<div class="cart-sel">
 											已选购<span class="num">{{ cartSum }}</span>件
@@ -101,7 +110,7 @@
 													</div>
 													<div class="discount">
 														优惠:
-														¥{{ payInfo.total_price - (cartSum && payInfo.pay_price ? payInfo.pay_price : 0) || 0}}
+														¥{{( payInfo.total_price - (cartSum && payInfo.pay_price ? payInfo.pay_price : 0) || 0).toFixed(2) || 0}}
 													</div>
 													<div v-if="payInfo.list && payInfo.list.length > 0" class="detailed"
 														@click="discountCon">
@@ -242,6 +251,7 @@
 	import recharge from "@/components/recharge";
 	import userDetails from "@/components/userDetail/userDetails";
 	import settleDrawer from "@/components/settleDrawer";
+	import buuug7SimpleDatetimePicker from '@/components/buuug7-simple-datetime-picker_0.7.0/components/buuug7-simple-datetime-picker/buuug7-simple-datetime-picker.vue'
 	import "../../assets/js/core.js";
 	import {
 		cashierCate,
@@ -269,6 +279,7 @@
 	export default {
 		name: "index",
 		components: {
+			buuug7SimpleDatetimePicker,
 			userList,
 			staffList,
 			storeList,
@@ -278,6 +289,9 @@
 		},
 		data() {
 			return {
+				chooseTime: '',
+				chooseDay: '',
+				selectDay: '',
 				pptype: 1,
 				payInfo: {}, //订单计算结果
 				checkType: 1,
@@ -488,6 +502,11 @@
 			}
 		},
 		methods: {
+			handleSubmit() {
+
+			},
+
+			datetimePickerErr() {},
 			reloadList() {
 				this.reloading = true;
 				this.limitTemp = this.goodFrom.limit;
@@ -572,7 +591,7 @@
 						return
 					}
 					return
-				} 
+				}
 				if (this.pptype == 2) {
 					let that = this
 					let arr = that.invalidList.map(item => {
@@ -585,6 +604,7 @@
 						products: arr.join(','),
 						pay_type: that.payType,
 						userCode: payNum,
+						reservation_time: that.selectDay
 					}
 					this.cashBntLoading = true;
 					createServeItem(qdata).then(res => {
@@ -847,6 +867,8 @@
 					}).then(res => {
 						that.payInfo = res.data
 					})
+				} else {
+					that.payInfo = {}
 				}
 
 			},
@@ -1041,6 +1063,7 @@
 			keyboard() {
 				console.log("key11")
 				let that = this;
+
 				function delNums(item) {
 					that.collectionArray.pop();
 					that.collection = that.collectionArray.length ?
@@ -1107,15 +1130,34 @@
 					}
 				};
 			},
+			// 转换时间
+			changeDate(date) {
+				var year = date.getFullYear();
+				var month = (date.getMonth() + 1).toString();
+				var day = (date.getDate()).toString();
+				if (month.length == 1) {
+					month = "0" + month;
+				}
+				if (day.length == 1) {
+					day = "0" + day;
+				}
+				var dateTime = year + "-" + month + "-" + day;
+				return dateTime;
+			},
 			// 打开结算抽屉
 			openSettle() {
 				this.pptype = 2
 				if (!this.staffInfo.id) {
 					return this.$Message.error('请选择服务员工');
 				}
-				// if(!this.saleInfo.id) {
-				// 	return this.$Message.error('请选择销售员工');
-				// }
+				if (!this.chooseDay) {
+					return this.$Message.error('请选择预约日期');
+				}
+				if (!this.chooseTime) {
+					return this.$Message.error('请选择预约时间');
+				}
+				this.selectDay = this.changeDate(this.chooseDay) + ' ' + this.chooseTime
+				console.log(this.selectDay, 'this.selectDay ')
 				this.payList.forEach((value, index, arr) => {
 					value.status = true;
 					if (value.value === 'yue' && !this.userInfo.uid) {
@@ -1272,6 +1314,7 @@
 		display: flex;
 		flex-direction: column;
 	}
+
 	.goods {
 		flex: 1;
 		min-width: 0;
@@ -1412,6 +1455,7 @@
 						line-height: 14px;
 						color: #FFFFFF;
 					}
+
 					.picture {
 						width: 100%;
 						height: 130px;
@@ -1449,6 +1493,7 @@
 							right: 5px;
 							bottom: 5px;
 						}
+
 						.money {
 							font-weight: 500;
 							color: #F5222D;