From cc06e1a6ff593b83595a9253b6201f8ed3ffd18c Mon Sep 17 00:00:00 2001 From: wangchen Date: Wed, 12 Jul 2023 18:06:16 +0800 Subject: [PATCH] 7.12 --- components/head-view/head-view.vue | 3 +- main.js | 3 +- pages.json | 6 + pages/index/instruct.vue | 454 +++- pages/index/instructDetails.vue | 277 +++ static/images/u176.png | Bin 0 -> 26975 bytes static/images/u86.png | Bin 0 -> 20902 bytes .../uni-datetime-picker/calendar-item.vue | 354 +-- .../uni-datetime-picker/calendar.vue | 1858 +++++++-------- .../uni-datetime-picker/i18n/en.json | 44 +- .../uni-datetime-picker/i18n/index.js | 14 +- .../uni-datetime-picker/time-picker.vue | 1868 +++++++-------- .../uni-datetime-picker.vue | 2064 ++++++++--------- .../components/uni-datetime-picker/util.js | 904 ++++---- uni_modules/uni-table/changelog.md | 27 + .../components/uni-table/uni-table.vue | 455 ++++ .../components/uni-tbody/uni-tbody.vue | 29 + .../uni-table/components/uni-td/uni-td.vue | 90 + .../components/uni-th/filter-dropdown.vue | 511 ++++ .../uni-table/components/uni-th/uni-th.vue | 285 +++ .../components/uni-thead/uni-thead.vue | 129 ++ .../components/uni-tr/table-checkbox.vue | 179 ++ .../uni-table/components/uni-tr/uni-tr.vue | 171 ++ uni_modules/uni-table/i18n/en.json | 9 + uni_modules/uni-table/i18n/es.json | 9 + uni_modules/uni-table/i18n/fr.json | 9 + uni_modules/uni-table/i18n/index.js | 12 + uni_modules/uni-table/i18n/zh-Hans.json | 9 + uni_modules/uni-table/i18n/zh-Hant.json | 9 + uni_modules/uni-table/package.json | 83 + uni_modules/uni-table/readme.md | 13 + 31 files changed, 6256 insertions(+), 3622 deletions(-) create mode 100644 pages/index/instructDetails.vue create mode 100644 static/images/u176.png create mode 100644 static/images/u86.png create mode 100644 uni_modules/uni-table/changelog.md create mode 100644 uni_modules/uni-table/components/uni-table/uni-table.vue create mode 100644 uni_modules/uni-table/components/uni-tbody/uni-tbody.vue create mode 100644 uni_modules/uni-table/components/uni-td/uni-td.vue create mode 100644 uni_modules/uni-table/components/uni-th/filter-dropdown.vue create mode 100644 uni_modules/uni-table/components/uni-th/uni-th.vue create mode 100644 uni_modules/uni-table/components/uni-thead/uni-thead.vue create mode 100644 uni_modules/uni-table/components/uni-tr/table-checkbox.vue create mode 100644 uni_modules/uni-table/components/uni-tr/uni-tr.vue create mode 100644 uni_modules/uni-table/i18n/en.json create mode 100644 uni_modules/uni-table/i18n/es.json create mode 100644 uni_modules/uni-table/i18n/fr.json create mode 100644 uni_modules/uni-table/i18n/index.js create mode 100644 uni_modules/uni-table/i18n/zh-Hans.json create mode 100644 uni_modules/uni-table/i18n/zh-Hant.json create mode 100644 uni_modules/uni-table/package.json create mode 100644 uni_modules/uni-table/readme.md diff --git a/components/head-view/head-view.vue b/components/head-view/head-view.vue index 72b652a..cf23a84 100644 --- a/components/head-view/head-view.vue +++ b/components/head-view/head-view.vue @@ -27,6 +27,7 @@ .headInfo { position: relative; background-color: #fff; + border-bottom: 1px solid #999999; height: 40px; line-height: 40px; font-size: 18px; @@ -39,4 +40,4 @@ } } - + \ No newline at end of file diff --git a/main.js b/main.js index d4424dd..7628154 100644 --- a/main.js +++ b/main.js @@ -33,7 +33,8 @@ import { Uploader, Field, Checkbox, - CheckboxGroup + CheckboxGroup, + Progress } from 'vant'; Vue.use(Radio); diff --git a/pages.json b/pages.json index 8db8ee7..4277e90 100644 --- a/pages.json +++ b/pages.json @@ -12,6 +12,12 @@ "navigationBarTitleText": "指令" } }, + { + "path": "pages/index/instructDetails", + "style": { + "navigationBarTitleText": "货物详情" + } + }, { "path": "pages/discharge/index", "style": { diff --git a/pages/index/instruct.vue b/pages/index/instruct.vue index 49c1710..e07b478 100644 --- a/pages/index/instruct.vue +++ b/pages/index/instruct.vue @@ -1,6 +1,7 @@ - - - - + + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue index 29b1b03..ec8e472 100644 --- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue @@ -1,929 +1,929 @@ - - - - - + + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json index 024f22f..56cd0a6 100644 --- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json @@ -1,22 +1,22 @@ -{ - "uni-datetime-picker.selectDate": "select date", - "uni-datetime-picker.selectTime": "select time", - "uni-datetime-picker.selectDateTime": "select date and time", - "uni-datetime-picker.startDate": "start date", - "uni-datetime-picker.endDate": "end date", - "uni-datetime-picker.startTime": "start time", - "uni-datetime-picker.endTime": "end time", - "uni-datetime-picker.ok": "ok", - "uni-datetime-picker.clear": "clear", - "uni-datetime-picker.cancel": "cancel", - "uni-datetime-picker.year": "-", - "uni-datetime-picker.month": "", - "uni-calender.MON": "MON", - "uni-calender.TUE": "TUE", - "uni-calender.WED": "WED", - "uni-calender.THU": "THU", - "uni-calender.FRI": "FRI", - "uni-calender.SAT": "SAT", - "uni-calender.SUN": "SUN", - "uni-calender.confirm": "confirm" -} +{ + "uni-datetime-picker.selectDate": "select date", + "uni-datetime-picker.selectTime": "select time", + "uni-datetime-picker.selectDateTime": "select date and time", + "uni-datetime-picker.startDate": "start date", + "uni-datetime-picker.endDate": "end date", + "uni-datetime-picker.startTime": "start time", + "uni-datetime-picker.endTime": "end time", + "uni-datetime-picker.ok": "ok", + "uni-datetime-picker.clear": "clear", + "uni-datetime-picker.cancel": "cancel", + "uni-datetime-picker.year": "-", + "uni-datetime-picker.month": "", + "uni-calender.MON": "MON", + "uni-calender.TUE": "TUE", + "uni-calender.WED": "WED", + "uni-calender.THU": "THU", + "uni-calender.FRI": "FRI", + "uni-calender.SAT": "SAT", + "uni-calender.SUN": "SUN", + "uni-calender.confirm": "confirm" +} diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js index de7509c..fa8f0f3 100644 --- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js @@ -1,8 +1,8 @@ -import en from './en.json' -import zhHans from './zh-Hans.json' -import zhHant from './zh-Hant.json' -export default { - en, - 'zh-Hans': zhHans, - 'zh-Hant': zhHant +import en from './en.json' +import zhHans from './zh-Hans.json' +import zhHant from './zh-Hant.json' +export default { + en, + 'zh-Hans': zhHans, + 'zh-Hant': zhHant } diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue index 81a042a..f03dff6 100644 --- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue @@ -1,934 +1,934 @@ - - - - - + + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue index 8769e83..7650d0f 100644 --- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue @@ -1,1032 +1,1032 @@ - - - - + + + + diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js index fc98623..3ea5bb1 100644 --- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js +++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js @@ -1,453 +1,453 @@ -class Calendar { - constructor({ - selected, - startDate, - endDate, - range, - } = {}) { - // 当前日期 - this.date = this.getDateObj(new Date()) // 当前初入日期 - // 打点信息 - this.selected = selected || []; - // 起始时间 - this.startDate = startDate - // 终止时间 - this.endDate = endDate - // 是否范围选择 - this.range = range - // 多选状态 - this.cleanMultipleStatus() - // 每周日期 - this.weeks = {} - this.lastHover = false - } - /** - * 设置日期 - * @param {Object} date - */ - setDate(date) { - const selectDate = this.getDateObj(date) - this.getWeeks(selectDate.fullDate) - } - - /** - * 清理多选状态 - */ - cleanMultipleStatus() { - this.multipleStatus = { - before: '', - after: '', - data: [] - } - } - - setStartDate(startDate) { - this.startDate = startDate - } - - setEndDate(endDate) { - this.endDate = endDate - } - - getPreMonthObj(date){ - date = fixIosDateFormat(date) - date = new Date(date) - - const oldMonth = date.getMonth() - date.setMonth(oldMonth - 1) - const newMonth = date.getMonth() - if(oldMonth !== 0 && newMonth - oldMonth === 0){ - date.setMonth(newMonth - 1) - } - return this.getDateObj(date) - } - getNextMonthObj(date){ - date = fixIosDateFormat(date) - date = new Date(date) - - const oldMonth = date.getMonth() - date.setMonth(oldMonth + 1) - const newMonth = date.getMonth() - if(newMonth - oldMonth > 1){ - date.setMonth(newMonth - 1) - } - return this.getDateObj(date) - } - - /** - * 获取指定格式Date对象 - */ - getDateObj(date) { - date = fixIosDateFormat(date) - date = new Date(date) - - return { - fullDate: getDate(date), - year: date.getFullYear(), - month: addZero(date.getMonth() + 1), - date: addZero(date.getDate()), - day: date.getDay() - } - } - - /** - * 获取上一个月日期集合 - */ - getPreMonthDays(amount, dateObj) { - const result = [] - for (let i = amount - 1; i >= 0; i--) { - const month = dateObj.month > 1 ? dateObj.month -1 : 12 - const year = month === 12 ? dateObj.year - 1 : dateObj.year - const date = new Date(year,month,-i).getDate() - const fullDate = `${year}-${addZero(month)}-${addZero(date)}` - let multiples = this.multipleStatus.data - let multiplesStatus = -1 - if (this.range && multiples) { - multiplesStatus = multiples.findIndex((item) => { - return this.dateEqual(item, fullDate) - }) - } - const checked = multiplesStatus !== -1 - // 获取打点信息 - const extraInfo = this.selected && this.selected.find((item) => { - if (this.dateEqual(fullDate, item.date)) { - return item - } - }) - result.push({ - fullDate, - year, - month, - date, - multiple: this.range ? checked : false, - beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), - afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), - disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), - isToday: fullDate === this.date.fullDate, - userChecked: false, - extraInfo - }) - } - return result - } - /** - * 获取本月日期集合 - */ - getCurrentMonthDays(amount, dateObj) { - const result = [] - const fullDate = this.date.fullDate - for (let i = 1; i <= amount; i++) { - const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}` - const isToday = fullDate === currentDate - // 获取打点信息 - const extraInfo = this.selected && this.selected.find((item) => { - if (this.dateEqual(currentDate, item.date)) { - return item - } - }) - - // 日期禁用 - let disableBefore = true - let disableAfter = true - if (this.startDate) { - disableBefore = dateCompare(this.startDate, currentDate) - } - - if (this.endDate) { - disableAfter = dateCompare(currentDate, this.endDate) - } - - let multiples = this.multipleStatus.data - let multiplesStatus = -1 - if (this.range && multiples) { - multiplesStatus = multiples.findIndex((item) => { - return this.dateEqual(item, currentDate) - }) - } - const checked = multiplesStatus !== -1 - - result.push({ - fullDate: currentDate, - year: dateObj.year, - month: dateObj.month, - date: i, - multiple: this.range ? checked : false, - beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after), - afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after), - disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)), - isToday, - userChecked: false, - extraInfo - }) - } - return result - } - /** - * 获取下一个月日期集合 - */ - _getNextMonthDays(amount, dateObj) { - const result = [] - const month = dateObj.month + 1 - for (let i = 1; i <= amount; i++) { - const month = dateObj.month === 12 ? 1 : dateObj.month*1 + 1 - const year = month === 1 ? dateObj.year + 1 : dateObj.year - const fullDate = `${year}-${addZero(month)}-${addZero(i)}` - let multiples = this.multipleStatus.data - let multiplesStatus = -1 - if (this.range && multiples) { - multiplesStatus = multiples.findIndex((item) => { - return this.dateEqual(item, fullDate) - }) - } - const checked = multiplesStatus !== -1 - // 获取打点信息 - const extraInfo = this.selected && this.selected.find((item) => { - if (this.dateEqual(fullDate, item.date)) { - return item - } - }) - result.push({ - fullDate, - year, - date: i, - month, - multiple: this.range ? checked : false, - beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), - afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), - disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), - isToday: fullDate === this.date.fullDate, - userChecked: false, - extraInfo - }) - } - return result - } - - /** - * 获取当前日期详情 - * @param {Object} date - */ - getInfo(date) { - if (!date) { - date = new Date() - } - - return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate) - } - - /** - * 比较时间是否相等 - */ - dateEqual(before, after) { - before = new Date(fixIosDateFormat(before)) - after = new Date(fixIosDateFormat(after)) - return before.valueOf() === after.valueOf() - } - - /** - * 比较真实起始日期 - */ - - isLogicBefore(currentDate, before, after) { - let logicBefore = before - if (before && after) { - logicBefore = dateCompare(before, after) ? before : after - } - return this.dateEqual(logicBefore, currentDate) - } - - isLogicAfter(currentDate, before, after) { - let logicAfter = after - if (before && after) { - logicAfter = dateCompare(before, after) ? after : before - } - return this.dateEqual(logicAfter, currentDate) - } - - /** - * 获取日期范围内所有日期 - * @param {Object} begin - * @param {Object} end - */ - geDateAll(begin, end) { - var arr = [] - var ab = begin.split('-') - var ae = end.split('-') - var db = new Date() - db.setFullYear(ab[0], ab[1] - 1, ab[2]) - var de = new Date() - de.setFullYear(ae[0], ae[1] - 1, ae[2]) - var unixDb = db.getTime() - 24 * 60 * 60 * 1000 - var unixDe = de.getTime() - 24 * 60 * 60 * 1000 - for (var k = unixDb; k <= unixDe;) { - k = k + 24 * 60 * 60 * 1000 - arr.push(this.getDateObj(new Date(parseInt(k))).fullDate) - } - return arr - } - - /** - * 获取多选状态 - */ - setMultiple(fullDate) { - if (!this.range) return - - let { - before, - after - } = this.multipleStatus - if (before && after) { - if (!this.lastHover) { - this.lastHover = true - return - } - this.multipleStatus.before = fullDate - this.multipleStatus.after = '' - this.multipleStatus.data = [] - this.multipleStatus.fulldate = '' - this.lastHover = false - } else { - if (!before) { - this.multipleStatus.before = fullDate - this.lastHover = false - } else { - this.multipleStatus.after = fullDate - if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { - this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus - .after); - } else { - this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus - .before); - } - this.lastHover = true - } - } - this.getWeeks(fullDate) - } - - /** - * 鼠标 hover 更新多选状态 - */ - setHoverMultiple(fullDate) { - if (!this.range || this.lastHover) return - - const { before } = this.multipleStatus - - if (!before) { - this.multipleStatus.before = fullDate - } else { - this.multipleStatus.after = fullDate - if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { - this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); - } else { - this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); - } - } - this.getWeeks(fullDate) - } - - /** - * 更新默认值多选状态 - */ - setDefaultMultiple(before, after) { - this.multipleStatus.before = before - this.multipleStatus.after = after - if (before && after) { - if (dateCompare(before, after)) { - this.multipleStatus.data = this.geDateAll(before, after); - this.getWeeks(after) - } else { - this.multipleStatus.data = this.geDateAll(after, before); - this.getWeeks(before) - } - } - } - - /** - * 获取每周数据 - * @param {Object} dateData - */ - getWeeks(dateData) { - const { - year, - month, - } = this.getDateObj(dateData) - - const preMonthDayAmount = new Date(year, month - 1, 1).getDay() - const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData)) - - const currentMonthDayAmount = new Date(year, month, 0).getDate() - const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData)) - - const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount - const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData)) - - const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays] - - const weeks = new Array(6) - for (let i = 0; i < calendarDays.length; i++) { - const index = Math.floor(i / 7) - if(!weeks[index]){ - weeks[index] = new Array(7) - } - weeks[index][i % 7] = calendarDays[i] - } - - this.calendar = calendarDays - this.weeks = weeks - } -} - -function getDateTime(date, hideSecond){ - return `${getDate(date)} ${getTime(date, hideSecond)}` -} - -function getDate(date) { - date = fixIosDateFormat(date) - date = new Date(date) - const year = date.getFullYear() - const month = date.getMonth()+1 - const day = date.getDate() - return `${year}-${addZero(month)}-${addZero(day)}` -} - -function getTime(date, hideSecond){ - date = fixIosDateFormat(date) - date = new Date(date) - const hour = date.getHours() - const minute = date.getMinutes() - const second = date.getSeconds() - return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}` -} - -function addZero(num) { - if(num < 10){ - num = `0${num}` - } - return num -} - -function getDefaultSecond(hideSecond) { - return hideSecond ? '00:00' : '00:00:00' -} - -function dateCompare(startDate, endDate) { - startDate = new Date(fixIosDateFormat(startDate)) - endDate = new Date(fixIosDateFormat(endDate)) - return startDate <= endDate -} - -function checkDate(date){ - const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g - return date.match(dateReg) -} - -const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9]:[0-5]?[0-9])?$/ -function fixIosDateFormat(value) { - if (typeof value === 'string' && dateTimeReg.test(value)) { - value = value.replace(/-/g, '/') - } - return value -} - +class Calendar { + constructor({ + selected, + startDate, + endDate, + range, + } = {}) { + // 当前日期 + this.date = this.getDateObj(new Date()) // 当前初入日期 + // 打点信息 + this.selected = selected || []; + // 起始时间 + this.startDate = startDate + // 终止时间 + this.endDate = endDate + // 是否范围选择 + this.range = range + // 多选状态 + this.cleanMultipleStatus() + // 每周日期 + this.weeks = {} + this.lastHover = false + } + /** + * 设置日期 + * @param {Object} date + */ + setDate(date) { + const selectDate = this.getDateObj(date) + this.getWeeks(selectDate.fullDate) + } + + /** + * 清理多选状态 + */ + cleanMultipleStatus() { + this.multipleStatus = { + before: '', + after: '', + data: [] + } + } + + setStartDate(startDate) { + this.startDate = startDate + } + + setEndDate(endDate) { + this.endDate = endDate + } + + getPreMonthObj(date){ + date = fixIosDateFormat(date) + date = new Date(date) + + const oldMonth = date.getMonth() + date.setMonth(oldMonth - 1) + const newMonth = date.getMonth() + if(oldMonth !== 0 && newMonth - oldMonth === 0){ + date.setMonth(newMonth - 1) + } + return this.getDateObj(date) + } + getNextMonthObj(date){ + date = fixIosDateFormat(date) + date = new Date(date) + + const oldMonth = date.getMonth() + date.setMonth(oldMonth + 1) + const newMonth = date.getMonth() + if(newMonth - oldMonth > 1){ + date.setMonth(newMonth - 1) + } + return this.getDateObj(date) + } + + /** + * 获取指定格式Date对象 + */ + getDateObj(date) { + date = fixIosDateFormat(date) + date = new Date(date) + + return { + fullDate: getDate(date), + year: date.getFullYear(), + month: addZero(date.getMonth() + 1), + date: addZero(date.getDate()), + day: date.getDay() + } + } + + /** + * 获取上一个月日期集合 + */ + getPreMonthDays(amount, dateObj) { + const result = [] + for (let i = amount - 1; i >= 0; i--) { + const month = dateObj.month > 1 ? dateObj.month -1 : 12 + const year = month === 12 ? dateObj.year - 1 : dateObj.year + const date = new Date(year,month,-i).getDate() + const fullDate = `${year}-${addZero(month)}-${addZero(date)}` + let multiples = this.multipleStatus.data + let multiplesStatus = -1 + if (this.range && multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, fullDate) + }) + } + const checked = multiplesStatus !== -1 + // 获取打点信息 + const extraInfo = this.selected && this.selected.find((item) => { + if (this.dateEqual(fullDate, item.date)) { + return item + } + }) + result.push({ + fullDate, + year, + month, + date, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), + disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), + isToday: fullDate === this.date.fullDate, + userChecked: false, + extraInfo + }) + } + return result + } + /** + * 获取本月日期集合 + */ + getCurrentMonthDays(amount, dateObj) { + const result = [] + const fullDate = this.date.fullDate + for (let i = 1; i <= amount; i++) { + const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}` + const isToday = fullDate === currentDate + // 获取打点信息 + const extraInfo = this.selected && this.selected.find((item) => { + if (this.dateEqual(currentDate, item.date)) { + return item + } + }) + + // 日期禁用 + let disableBefore = true + let disableAfter = true + if (this.startDate) { + disableBefore = dateCompare(this.startDate, currentDate) + } + + if (this.endDate) { + disableAfter = dateCompare(currentDate, this.endDate) + } + + let multiples = this.multipleStatus.data + let multiplesStatus = -1 + if (this.range && multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, currentDate) + }) + } + const checked = multiplesStatus !== -1 + + result.push({ + fullDate: currentDate, + year: dateObj.year, + month: dateObj.month, + date: i, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after), + disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare(currentDate,this.endDate)), + isToday, + userChecked: false, + extraInfo + }) + } + return result + } + /** + * 获取下一个月日期集合 + */ + _getNextMonthDays(amount, dateObj) { + const result = [] + const month = dateObj.month + 1 + for (let i = 1; i <= amount; i++) { + const month = dateObj.month === 12 ? 1 : dateObj.month*1 + 1 + const year = month === 1 ? dateObj.year + 1 : dateObj.year + const fullDate = `${year}-${addZero(month)}-${addZero(i)}` + let multiples = this.multipleStatus.data + let multiplesStatus = -1 + if (this.range && multiples) { + multiplesStatus = multiples.findIndex((item) => { + return this.dateEqual(item, fullDate) + }) + } + const checked = multiplesStatus !== -1 + // 获取打点信息 + const extraInfo = this.selected && this.selected.find((item) => { + if (this.dateEqual(fullDate, item.date)) { + return item + } + }) + result.push({ + fullDate, + year, + date: i, + month, + multiple: this.range ? checked : false, + beforeMultiple: this.isLogicBefore(fullDate, this.multipleStatus.before, this.multipleStatus.after), + afterMultiple: this.isLogicAfter(fullDate, this.multipleStatus.before, this.multipleStatus.after), + disable: (this.startDate && !dateCompare(this.startDate, fullDate)) || (this.endDate && !dateCompare(fullDate,this.endDate)), + isToday: fullDate === this.date.fullDate, + userChecked: false, + extraInfo + }) + } + return result + } + + /** + * 获取当前日期详情 + * @param {Object} date + */ + getInfo(date) { + if (!date) { + date = new Date() + } + + return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate) + } + + /** + * 比较时间是否相等 + */ + dateEqual(before, after) { + before = new Date(fixIosDateFormat(before)) + after = new Date(fixIosDateFormat(after)) + return before.valueOf() === after.valueOf() + } + + /** + * 比较真实起始日期 + */ + + isLogicBefore(currentDate, before, after) { + let logicBefore = before + if (before && after) { + logicBefore = dateCompare(before, after) ? before : after + } + return this.dateEqual(logicBefore, currentDate) + } + + isLogicAfter(currentDate, before, after) { + let logicAfter = after + if (before && after) { + logicAfter = dateCompare(before, after) ? after : before + } + return this.dateEqual(logicAfter, currentDate) + } + + /** + * 获取日期范围内所有日期 + * @param {Object} begin + * @param {Object} end + */ + geDateAll(begin, end) { + var arr = [] + var ab = begin.split('-') + var ae = end.split('-') + var db = new Date() + db.setFullYear(ab[0], ab[1] - 1, ab[2]) + var de = new Date() + de.setFullYear(ae[0], ae[1] - 1, ae[2]) + var unixDb = db.getTime() - 24 * 60 * 60 * 1000 + var unixDe = de.getTime() - 24 * 60 * 60 * 1000 + for (var k = unixDb; k <= unixDe;) { + k = k + 24 * 60 * 60 * 1000 + arr.push(this.getDateObj(new Date(parseInt(k))).fullDate) + } + return arr + } + + /** + * 获取多选状态 + */ + setMultiple(fullDate) { + if (!this.range) return + + let { + before, + after + } = this.multipleStatus + if (before && after) { + if (!this.lastHover) { + this.lastHover = true + return + } + this.multipleStatus.before = fullDate + this.multipleStatus.after = '' + this.multipleStatus.data = [] + this.multipleStatus.fulldate = '' + this.lastHover = false + } else { + if (!before) { + this.multipleStatus.before = fullDate + this.lastHover = false + } else { + this.multipleStatus.after = fullDate + if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus + .after); + } else { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus + .before); + } + this.lastHover = true + } + } + this.getWeeks(fullDate) + } + + /** + * 鼠标 hover 更新多选状态 + */ + setHoverMultiple(fullDate) { + if (!this.range || this.lastHover) return + + const { before } = this.multipleStatus + + if (!before) { + this.multipleStatus.before = fullDate + } else { + this.multipleStatus.after = fullDate + if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); + } else { + this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); + } + } + this.getWeeks(fullDate) + } + + /** + * 更新默认值多选状态 + */ + setDefaultMultiple(before, after) { + this.multipleStatus.before = before + this.multipleStatus.after = after + if (before && after) { + if (dateCompare(before, after)) { + this.multipleStatus.data = this.geDateAll(before, after); + this.getWeeks(after) + } else { + this.multipleStatus.data = this.geDateAll(after, before); + this.getWeeks(before) + } + } + } + + /** + * 获取每周数据 + * @param {Object} dateData + */ + getWeeks(dateData) { + const { + year, + month, + } = this.getDateObj(dateData) + + const preMonthDayAmount = new Date(year, month - 1, 1).getDay() + const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData)) + + const currentMonthDayAmount = new Date(year, month, 0).getDate() + const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData)) + + const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount + const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData)) + + const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays] + + const weeks = new Array(6) + for (let i = 0; i < calendarDays.length; i++) { + const index = Math.floor(i / 7) + if(!weeks[index]){ + weeks[index] = new Array(7) + } + weeks[index][i % 7] = calendarDays[i] + } + + this.calendar = calendarDays + this.weeks = weeks + } +} + +function getDateTime(date, hideSecond){ + return `${getDate(date)} ${getTime(date, hideSecond)}` +} + +function getDate(date) { + date = fixIosDateFormat(date) + date = new Date(date) + const year = date.getFullYear() + const month = date.getMonth()+1 + const day = date.getDate() + return `${year}-${addZero(month)}-${addZero(day)}` +} + +function getTime(date, hideSecond){ + date = fixIosDateFormat(date) + date = new Date(date) + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}` +} + +function addZero(num) { + if(num < 10){ + num = `0${num}` + } + return num +} + +function getDefaultSecond(hideSecond) { + return hideSecond ? '00:00' : '00:00:00' +} + +function dateCompare(startDate, endDate) { + startDate = new Date(fixIosDateFormat(startDate)) + endDate = new Date(fixIosDateFormat(endDate)) + return startDate <= endDate +} + +function checkDate(date){ + const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g + return date.match(dateReg) +} + +const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9]:[0-5]?[0-9])?$/ +function fixIosDateFormat(value) { + if (typeof value === 'string' && dateTimeReg.test(value)) { + value = value.replace(/-/g, '/') + } + return value +} + export {Calendar, getDateTime, getDate, getTime, addZero, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat} \ No newline at end of file diff --git a/uni_modules/uni-table/changelog.md b/uni_modules/uni-table/changelog.md new file mode 100644 index 0000000..cacf2a6 --- /dev/null +++ b/uni_modules/uni-table/changelog.md @@ -0,0 +1,27 @@ +## 1.2.3(2023-03-28) +- 修复 在vue3模式下可能会出现错误的问题 +## 1.2.2(2022-11-29) +- 优化 主题样式 +## 1.2.1(2022-06-06) +- 修复 微信小程序存在无使用组件的问题 +## 1.2.0(2021-11-19) +- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource) +- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-table](https://uniapp.dcloud.io/component/uniui/uni-table) +## 1.1.0(2021-07-30) +- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834) +## 1.0.7(2021-07-08) +- 新增 uni-th 支持 date 日期筛选范围 +## 1.0.6(2021-07-05) +- 新增 uni-th 支持 range 筛选范围 +## 1.0.5(2021-06-28) +- 新增 uni-th 筛选功能 +## 1.0.4(2021-05-12) +- 新增 示例地址 +- 修复 示例项目缺少组件的Bug +## 1.0.3(2021-04-16) +- 新增 sortable 属性,是否开启单列排序 +- 优化 表格多选逻辑 +## 1.0.2(2021-03-22) +- uni-tr 添加 disabled 属性,用于 type=selection 时,设置某行是否可由全选按钮控制 +## 1.0.1(2021-02-05) +- 调整为uni_modules目录规范 diff --git a/uni_modules/uni-table/components/uni-table/uni-table.vue b/uni_modules/uni-table/components/uni-table/uni-table.vue new file mode 100644 index 0000000..9fe681d --- /dev/null +++ b/uni_modules/uni-table/components/uni-table/uni-table.vue @@ -0,0 +1,455 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-tbody/uni-tbody.vue b/uni_modules/uni-table/components/uni-tbody/uni-tbody.vue new file mode 100644 index 0000000..1d808b3 --- /dev/null +++ b/uni_modules/uni-table/components/uni-tbody/uni-tbody.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-td/uni-td.vue b/uni_modules/uni-table/components/uni-td/uni-td.vue new file mode 100644 index 0000000..e0d743b --- /dev/null +++ b/uni_modules/uni-table/components/uni-td/uni-td.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-th/filter-dropdown.vue b/uni_modules/uni-table/components/uni-th/filter-dropdown.vue new file mode 100644 index 0000000..add1098 --- /dev/null +++ b/uni_modules/uni-table/components/uni-th/filter-dropdown.vue @@ -0,0 +1,511 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-th/uni-th.vue b/uni_modules/uni-table/components/uni-th/uni-th.vue new file mode 100644 index 0000000..75fa42a --- /dev/null +++ b/uni_modules/uni-table/components/uni-th/uni-th.vue @@ -0,0 +1,285 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-thead/uni-thead.vue b/uni_modules/uni-table/components/uni-thead/uni-thead.vue new file mode 100644 index 0000000..a12078a --- /dev/null +++ b/uni_modules/uni-table/components/uni-thead/uni-thead.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-tr/table-checkbox.vue b/uni_modules/uni-table/components/uni-tr/table-checkbox.vue new file mode 100644 index 0000000..f22936b --- /dev/null +++ b/uni_modules/uni-table/components/uni-tr/table-checkbox.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/uni_modules/uni-table/components/uni-tr/uni-tr.vue b/uni_modules/uni-table/components/uni-tr/uni-tr.vue new file mode 100644 index 0000000..d5cdee6 --- /dev/null +++ b/uni_modules/uni-table/components/uni-tr/uni-tr.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/uni_modules/uni-table/i18n/en.json b/uni_modules/uni-table/i18n/en.json new file mode 100644 index 0000000..cc9c4a3 --- /dev/null +++ b/uni_modules/uni-table/i18n/en.json @@ -0,0 +1,9 @@ +{ + "filter-dropdown.reset": "Reset", + "filter-dropdown.search": "Search", + "filter-dropdown.submit": "Submit", + "filter-dropdown.filter": "Filter", + "filter-dropdown.gt": "Greater or equal to", + "filter-dropdown.lt": "Less than or equal to", + "filter-dropdown.date": "Date" +} diff --git a/uni_modules/uni-table/i18n/es.json b/uni_modules/uni-table/i18n/es.json new file mode 100644 index 0000000..9c4705c --- /dev/null +++ b/uni_modules/uni-table/i18n/es.json @@ -0,0 +1,9 @@ +{ + "filter-dropdown.reset": "Reiniciar", + "filter-dropdown.search": "Búsqueda", + "filter-dropdown.submit": "Entregar", + "filter-dropdown.filter": "Filtrar", + "filter-dropdown.gt": "Mayor o igual a", + "filter-dropdown.lt": "Menos que o igual a", + "filter-dropdown.date": "Fecha" +} diff --git a/uni_modules/uni-table/i18n/fr.json b/uni_modules/uni-table/i18n/fr.json new file mode 100644 index 0000000..389a9ae --- /dev/null +++ b/uni_modules/uni-table/i18n/fr.json @@ -0,0 +1,9 @@ +{ + "filter-dropdown.reset": "Réinitialiser", + "filter-dropdown.search": "Chercher", + "filter-dropdown.submit": "Soumettre", + "filter-dropdown.filter": "Filtre", + "filter-dropdown.gt": "Supérieur ou égal à", + "filter-dropdown.lt": "Inférieur ou égal à", + "filter-dropdown.date": "Date" +} diff --git a/uni_modules/uni-table/i18n/index.js b/uni_modules/uni-table/i18n/index.js new file mode 100644 index 0000000..2293b0d --- /dev/null +++ b/uni_modules/uni-table/i18n/index.js @@ -0,0 +1,12 @@ +import en from './en.json' +import es from './es.json' +import fr from './fr.json' +import zhHans from './zh-Hans.json' +import zhHant from './zh-Hant.json' +export default { + en, + es, + fr, + 'zh-Hans': zhHans, + 'zh-Hant': zhHant +} diff --git a/uni_modules/uni-table/i18n/zh-Hans.json b/uni_modules/uni-table/i18n/zh-Hans.json new file mode 100644 index 0000000..0b1afab --- /dev/null +++ b/uni_modules/uni-table/i18n/zh-Hans.json @@ -0,0 +1,9 @@ +{ + "filter-dropdown.reset": "重置", + "filter-dropdown.search": "搜索", + "filter-dropdown.submit": "确定", + "filter-dropdown.filter": "筛选", + "filter-dropdown.gt": "大于等于", + "filter-dropdown.lt": "小于等于", + "filter-dropdown.date": "日期范围" +} diff --git a/uni_modules/uni-table/i18n/zh-Hant.json b/uni_modules/uni-table/i18n/zh-Hant.json new file mode 100644 index 0000000..d633f2d --- /dev/null +++ b/uni_modules/uni-table/i18n/zh-Hant.json @@ -0,0 +1,9 @@ +{ + "filter-dropdown.reset": "重置", + "filter-dropdown.search": "搜索", + "filter-dropdown.submit": "確定", + "filter-dropdown.filter": "篩選", + "filter-dropdown.gt": "大於等於", + "filter-dropdown.lt": "小於等於", + "filter-dropdown.date": "日期範圍" +} diff --git a/uni_modules/uni-table/package.json b/uni_modules/uni-table/package.json new file mode 100644 index 0000000..16cbb53 --- /dev/null +++ b/uni_modules/uni-table/package.json @@ -0,0 +1,83 @@ +{ + "id": "uni-table", + "displayName": "uni-table 表格", + "version": "1.2.3", + "description": "表格组件,多用于展示多条结构类似的数据,如", + "keywords": [ + "uni-ui", + "uniui", + "table", + "表格" +], + "repository": "https://github.com/dcloudio/uni-ui", + "engines": { + "HBuilderX": "" + }, + "directories": { + "example": "../../temps/example_temps" + }, +"dcloudext": { + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "无", + "data": "无", + "permissions": "无" + }, + "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", + "type": "component-vue" + }, + "uni_modules": { + "dependencies": ["uni-scss","uni-datetime-picker"], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "y", + "aliyun": "y" + }, + "client": { + "App": { + "app-vue": "y", + "app-nvue": "n" + }, + "H5-mobile": { + "Safari": "y", + "Android Browser": "y", + "微信浏览器(Android)": "y", + "QQ浏览器(Android)": "y" + }, + "H5-pc": { + "Chrome": "y", + "IE": "y", + "Edge": "y", + "Firefox": "y", + "Safari": "y" + }, + "小程序": { + "微信": "y", + "阿里": "y", + "百度": "y", + "字节跳动": "n", + "QQ": "y" + }, + "快应用": { + "华为": "n", + "联盟": "n" + }, + "Vue": { + "vue2": "y", + "vue3": "y" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-table/readme.md b/uni_modules/uni-table/readme.md new file mode 100644 index 0000000..a0f93cf --- /dev/null +++ b/uni_modules/uni-table/readme.md @@ -0,0 +1,13 @@ + + +## Table 表单 +> 组件名:``uni-table``,代码块: `uTable`。 + +用于展示多条结构类似的数据 + +### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-table) +#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839 + + + +