datetime-picker.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <template>
  2. <view class="datatime">
  3. <picker mode="multiSelector" :range="range" range-key="text" @change="change" @columnchange="columnchange" :value="value" :disabled="disabled">
  4. <view class="dis-fix">
  5. <view class="content" :class="{ placeholder: !dateStr }">
  6. <text>{{ dateStr ? dateStr : placeholder }}</text>
  7. </view>
  8. <slot></slot>
  9. </view>
  10. </picker>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. /**
  16. * 数据
  17. */
  18. props: {
  19. // 是否禁用
  20. disabled: {
  21. type: Boolean,
  22. default: false
  23. },
  24. // 占位符
  25. placeholder: {
  26. type: String,
  27. default: '请选择日期时间'
  28. },
  29. // 表示有效日期时间范围的开始,
  30. // 字符串格式为 "YYYY-MM-DD hh:mm"
  31. start: {
  32. type: String,
  33. default: '1970-1-1 00:00'
  34. },
  35. // 表示有效日期时间范围的结束
  36. // 字符串格式为 "YYYY-MM-DD hh:mm"
  37. end: {
  38. type: String,
  39. default: '2300-1-1 00:00'
  40. },
  41. // 表示选择器的粒度,有效值:year | month | day | hour | minute
  42. fields: {
  43. type: String,
  44. default: 'minute'
  45. },
  46. // 默认值
  47. // 字符串格式为 "YYYY-MM-DD hh:mm"
  48. defaultValue: {
  49. type: String,
  50. default: ''
  51. }
  52. },
  53. /**
  54. * 数据
  55. */
  56. data() {
  57. return {
  58. range: [],
  59. value: [],
  60. dateStr: '', // 最终显示的字符串
  61. dtStart: null, // 有效范围开始
  62. dtEnd: null, // 有效范围结束
  63. };
  64. },
  65. /**
  66. * 监听数据
  67. */
  68. watch: {
  69. // 默认值
  70. defaultValue() {
  71. // 设置默认值
  72. this.setDefaultValue();
  73. }
  74. },
  75. /**
  76. * 组件初次加载完成
  77. */
  78. mounted() {
  79. // 有效日期开始和结束
  80. let start = this.start;
  81. let end = this.end;
  82. // 验证是否是有效的开始和结束日期
  83. if(!this.isString(this.start)) {
  84. console.log('开始日期需为String类型,格式为 "YYYY-MM-DD hh:mm"');
  85. start = '1970-1-1 00:00';
  86. }
  87. if(!this.isString(this.start)) {
  88. console.log('结束日期需为String类型,格式为 "YYYY-MM-DD hh:mm"');
  89. start = '2300-1-1 00:00';
  90. }
  91. // 将开始日期和结束日期转为 Date
  92. let dtStart = this.formatDate(start).dt;
  93. let dtEnd = this.formatDate(end).dt;
  94. // 判断有效日期结束是否大于有效日期开始,如果不是,则将有效日期结束修改为有效日期开始往后300年
  95. if (dtEnd <= dtStart) {
  96. dtEnd = this.formatDate(start).dt;
  97. dtEnd.setFullYear(dtStart.getFullYear() + 300);
  98. dtEnd.setDate(dtEnd.getDate() - 1);
  99. }
  100. // 更新开始日期和结束日期
  101. this.dtStart = dtStart;
  102. this.dtEnd = dtEnd;
  103. // 设置默认值
  104. this.setDefaultValue();
  105. },
  106. /**
  107. * 方法
  108. */
  109. methods: {
  110. /**
  111. * 确认选择
  112. */
  113. change(event) {
  114. let year, month, day, hour, minute;
  115. if(this.fields == 'year') {
  116. year = this.range[0][this.value[0]].number; // 年
  117. let dtStr = `${year}`;
  118. this.setDateStr(dtStr);
  119. this.$emit('change', this.formatDate(dtStr));
  120. return;
  121. }
  122. else if(this.fields == 'month') {
  123. year = this.range[0][this.value[0]].number; // 年
  124. month = this.range[1][this.value[1]].number; // 月
  125. let dtStr = `${year}-${month}`;
  126. this.setDateStr(dtStr);
  127. this.$emit('change', this.formatDate(dtStr));
  128. return;
  129. }
  130. else if(this.fields == 'day') {
  131. year = this.range[0][this.value[0]].number; // 年
  132. month = this.range[1][this.value[1]].number; // 月
  133. day = this.range[2][this.value[2]].number; // 日
  134. let dtStr = `${year}-${month}-${day}`;
  135. this.setDateStr(dtStr);
  136. this.$emit('change', this.formatDate(dtStr));
  137. return;
  138. }
  139. else if(this.fields == 'hour') {
  140. year = this.range[0][this.value[0]].number; // 年
  141. month = this.range[1][this.value[1]].number; // 月
  142. day = this.range[2][this.value[2]].number; // 日
  143. hour = this.range[3][this.value[3]].number; // 时
  144. day = this.range[2][this.value[2]].number; // 日
  145. let dtStr = `${year}-${month}-${day} ${hour}`;
  146. this.setDateStr(dtStr);
  147. this.$emit('change', this.formatDate(dtStr));
  148. return;
  149. }
  150. else if(this.fields == 'minute') {
  151. year = this.range[0][this.value[0]].number; // 年
  152. month = this.range[1][this.value[1]].number; // 月
  153. day = this.range[2][this.value[2]].number; // 日
  154. hour = this.range[3][this.value[3]].number; // 时
  155. minute = this.range[4][this.value[4]].number; // 分
  156. let dtStr = `${year}-${month}-${day} ${hour}:${minute}`;
  157. this.setDateStr(dtStr);
  158. this.$emit('change', this.formatDate(dtStr));
  159. return;
  160. }
  161. },
  162. /**
  163. * 设置显示的值
  164. * @param {Date|String} date 日期字符串或日期对象
  165. */
  166. setDateStr(date) {
  167. let dt = this.formatDate(date);
  168. if(this.fields == 'year') {
  169. this.dateStr = `${dt.YYYY}年`;
  170. return;
  171. }
  172. if(this.fields == 'month') {
  173. this.dateStr = `${dt.YYYY}年${dt.M}月`;
  174. return;
  175. }
  176. if(this.fields == 'day') {
  177. this.dateStr = `${dt.YYYY}年${dt.M}月${dt.D}日`;
  178. return;
  179. }
  180. if(this.fields == 'hour') {
  181. this.dateStr = `${dt.YYYY}年${dt.M}月${dt.D}日 ${dt.h}时`;
  182. return;
  183. }
  184. this.dateStr = `${dt.YYYY}-${dt.M}-${dt.D} ${dt.h}:${dt.m}`;
  185. },
  186. /**
  187. * 设置年数据
  188. */
  189. setYearData() {
  190. // 有效日期
  191. let yearStart = this.dtStart.getFullYear();
  192. let yearEnd = this.dtEnd.getFullYear();
  193. // 年
  194. let years = [];
  195. for (let year = yearStart; year <= yearEnd; year++) {
  196. let item = {
  197. number: year,
  198. text: `${year}年`,
  199. };
  200. years.push(item);
  201. }
  202. this.range.splice(0, 1, years);
  203. },
  204. /**
  205. * 设置月数据
  206. * @param {Number} year 年
  207. */
  208. setMonthData(year) {
  209. // 有效日期
  210. let yearStart = this.dtStart.getFullYear();
  211. let monthStart = this.dtStart.getMonth() + 1;
  212. let yearEnd = this.dtEnd.getFullYear();
  213. let monthEnd = this.dtEnd.getMonth() + 1;
  214. // 月
  215. let months = [];
  216. let monthStartIndex = year == yearStart ? monthStart : 1;
  217. let monthEndIndex = year == yearEnd ? monthEnd : 12;
  218. for (let month = monthStartIndex; month <= monthEndIndex; month++) {
  219. let item = {
  220. number: month,
  221. text: `${month}月`,
  222. };
  223. months.push(item);
  224. }
  225. this.range.splice(1, 1, months);
  226. },
  227. /**
  228. * 设置日数据
  229. * @param {Number} year 年
  230. * @param {Number} month 月
  231. */
  232. setDayData(year, month) {
  233. // 有效日期
  234. let yearStart = this.dtStart.getFullYear();
  235. let monthStart = this.dtStart.getMonth() + 1;
  236. let dayStart = this.dtStart.getDate();
  237. let yearEnd = this.dtEnd.getFullYear();
  238. let monthEnd = this.dtEnd.getMonth() + 1;
  239. let dayEnd = this.dtEnd.getDate();
  240. // 日
  241. let days = [];
  242. let dayStartIndex = year == yearStart && month == monthStart ? dayStart : 1;
  243. let dayEndIndex;
  244. if(year == yearEnd && month == monthEnd) {
  245. dayEndIndex = dayEnd;
  246. } else {
  247. // 本月1号
  248. let dtThisMonth = new Date();
  249. dtThisMonth.setFullYear(year);
  250. dtThisMonth.setMonth(month - 1);
  251. dtThisMonth.setDate(1);
  252. dtThisMonth.setHours(0);
  253. dtThisMonth.setMinutes(0);
  254. dtThisMonth.setSeconds(0);
  255. dtThisMonth.setMilliseconds(0);
  256. // 下月1号
  257. let dtNextMonth = new Date();
  258. dtNextMonth.setFullYear(year);
  259. dtNextMonth.setMonth(month);
  260. dtNextMonth.setDate(1);
  261. dtNextMonth.setHours(0);
  262. dtNextMonth.setMinutes(0);
  263. dtNextMonth.setSeconds(0);
  264. dtNextMonth.setMilliseconds(0);
  265. // 计算出本月的总天数
  266. dayEndIndex = parseInt((dtNextMonth - dtThisMonth) / (86400000));
  267. }
  268. for (let day = dayStartIndex; day <= dayEndIndex; day++) {
  269. let item = {
  270. number: day,
  271. text: `${day}日`,
  272. };
  273. days.push(item);
  274. }
  275. this.range.splice(2, 1, days);
  276. },
  277. /**
  278. * 设置时数据
  279. * @param {Number} year 年
  280. * @param {Number} month 月
  281. * @param {Number} day 日
  282. */
  283. setHourData(year, month, day) {
  284. // 有效日期
  285. let yearStart = this.dtStart.getFullYear();
  286. let monthStart = this.dtStart.getMonth() + 1;
  287. let dayStart = this.dtStart.getDate();
  288. let hourStart = this.dtStart.getHours();
  289. let yearEnd = this.dtEnd.getFullYear();
  290. let monthEnd = this.dtEnd.getMonth() + 1;
  291. let dayEnd = this.dtEnd.getDate();
  292. let hourEnd = this.dtEnd.getHours();
  293. // 时
  294. let hours = [];
  295. let hourStartIndex = year == yearStart && month == monthStart && day == dayStart ? hourStart : 0;
  296. let hourEndIndex = year == yearEnd && month == monthEnd && day == dayEnd ? hourEnd : 23;
  297. for (let hour = hourStartIndex; hour <= hourEndIndex; hour++) {
  298. let item = {
  299. number: hour,
  300. text: `${hour}时`,
  301. };
  302. hours.push(item);
  303. }
  304. this.range.splice(3, 1, hours);
  305. },
  306. /**
  307. * 设置分数据
  308. * @param {Number} year 年
  309. * @param {Number} month 月
  310. * @param {Number} day 日
  311. * @param {Number} hour 时
  312. */
  313. setMinuteData(year, month, day, hour) {
  314. // 有效日期
  315. let yearStart = this.dtStart.getFullYear();
  316. let monthStart = this.dtStart.getMonth() + 1;
  317. let dayStart = this.dtStart.getDate();
  318. let hourStart = this.dtStart.getHours();
  319. let minuteStart = this.dtStart.getMinutes();
  320. let yearEnd = this.dtEnd.getFullYear();
  321. let monthEnd = this.dtEnd.getMonth() + 1;
  322. let dayEnd = this.dtEnd.getDate();
  323. let hourEnd = this.dtEnd.getHours();
  324. let minuteEnd = this.dtEnd.getMinutes();
  325. // 分
  326. let minutes = [];
  327. let minuteStartIndex = year == yearStart && month == monthStart && day == dayStart && hour == hourStart ? minuteStart : 0;
  328. let minuteEndIndex = year == yearEnd && month == monthEnd && day == dayEnd && hour == hourEnd ? minuteEnd : 59;
  329. for(let minute = minuteStartIndex; minute <= minuteEndIndex; minute++) {
  330. let item = {
  331. number: minute,
  332. text: `${minute}分`,
  333. }
  334. minutes.push(item);
  335. }
  336. this.range.splice(4, 1, minutes);
  337. },
  338. /**
  339. * 设置默认值
  340. */
  341. setDefaultValue() {
  342. // 默认日期
  343. let dtDefault;
  344. // 开始日期和结束日期
  345. let dtStart = this.dtStart;
  346. let dtEnd = this.dtEnd;
  347. // 判断是否传了默认日期
  348. // 传了默认日期,格式化默认日期为日期对象
  349. if(this.defaultValue) {
  350. dtDefault = this.formatDate(this.defaultValue).dt;
  351. }
  352. // 如果没有传默认日期,将默认日期设置为当前日期
  353. else {
  354. dtDefault = new Date();
  355. }
  356. // 如果默认日期不在有效日期范围内,设置默认日期为有效日期开始值
  357. if (dtDefault < dtStart || dtDefault > dtEnd) {
  358. dtDefault = dtStart;
  359. }
  360. // 更新 dateStr
  361. if(this.defaultValue) this.setDateStr(dtDefault);
  362. // 默认值相关数据
  363. let dfYear = dtDefault.getFullYear();
  364. let dfMonth = dtDefault.getMonth() + 1;
  365. let dfDay = dtDefault.getDate();
  366. let dfHour = dtDefault.getHours();
  367. let dfMinute = dtDefault.getMinutes();
  368. // 设置年数据
  369. this.setYearData();
  370. // 设置 Year 这一列的 value 值
  371. let yearIndex = this.range[0].findIndex(year => {
  372. return dfYear == year.number;
  373. });
  374. this.value.splice(0, 1, yearIndex >= 0 ? yearIndex : 0);
  375. // 设置月数据
  376. if(this.fields == 'year') return;
  377. this.setMonthData(dfYear);
  378. // 设置 Month 这一列的 value 值
  379. let monthIndex = this.range[1].findIndex(month => {
  380. return dfMonth == month.number;
  381. });
  382. this.value.splice(1, 1, monthIndex >=0 ? monthIndex : 0);
  383. // 设置日数据
  384. if(this.fields == 'month') return;
  385. this.setDayData(dfYear, dfMonth);
  386. // 设置 Day 这一列的 value 值
  387. let dayIndex = this.range[2].findIndex(day => {
  388. return dfDay == day.number;
  389. });
  390. this.value.splice(2, 1, dayIndex >=0 ? dayIndex : 0);
  391. // 设置时数据
  392. if(this.fields == 'day') return;
  393. this.setHourData(dfYear, dfMonth, dfDay);
  394. // 设置 Hour 这一列的 value 值
  395. let hourIndex = this.range[3].findIndex(hour => {
  396. return dfHour == hour.number;
  397. });
  398. this.value.splice(3, 1, hourIndex >=0 ? hourIndex : 0);
  399. // 设置分数据
  400. if(this.fields == 'hour') return;
  401. this.setMinuteData(dfYear, dfMonth, dfDay, dfHour);
  402. // 设置 Minute 这一列的 value 值
  403. let minuteIndex = this.range[4].findIndex(minute => {
  404. return dfMinute == minute.number;
  405. });
  406. this.value.splice(4, 1, minuteIndex >=0 ? minuteIndex : 0);
  407. },
  408. /**
  409. * 某一列的值改变时触发
  410. * @param {Number} event.detail.column 表示改变了第几列(下标从0开始)
  411. * @param {Number} event.detail.value 表示变更值的下标
  412. */
  413. columnchange(event) {
  414. let columnIndex = event.detail.column; // 改变的列的下标
  415. let valueIndex = event.detail.value; // 变更值的下标
  416. // 更新改变列的 value
  417. this.value.splice(columnIndex, 1, valueIndex);
  418. // 改变年要更新月数据
  419. if(this.fields == 'year') return;
  420. if (columnIndex == 0) {
  421. // 当前选择的月
  422. let monthBeforeUpdate = this.range[1][this.value[1]];
  423. // 更新月数据
  424. this.setMonthData(this.range[0][this.value[0]].number);
  425. // 更新 Month Value
  426. let monthIndex = this.range[1].findIndex(month => {
  427. return month.number == monthBeforeUpdate.number;
  428. });
  429. this.value.splice(1, 1, monthIndex >= 0 ? monthIndex : 0);
  430. }
  431. // 改变年、月都要更新日数据
  432. if(this.fields == 'month') return;
  433. if (columnIndex == 0 || columnIndex == 1) {
  434. // 当前选择的日
  435. let dayBeforeUpdate = this.range[2][this.value[2]];
  436. // 更新日数据
  437. this.setDayData(this.range[0][this.value[0]].number, this.range[1][this.value[1]].number);
  438. // 更新 Day Value
  439. let dayIndex = this.range[2].findIndex(day => {
  440. return day.number == dayBeforeUpdate.number;
  441. });
  442. this.value.splice(2, 1, dayIndex >= 0 ? dayIndex : 0);
  443. }
  444. // 改变年、月、日都要更新时数据
  445. if(this.fields == 'day') return;
  446. if (columnIndex == 0 || columnIndex == 1 || columnIndex == 2) {
  447. // 当前选择的时
  448. let hourBeforeUpdate = this.range[3][this.value[3]];
  449. // 更新时数据
  450. this.setHourData(this.range[0][this.value[0]].number, this.range[1][this.value[1]].number, this.range[2][this.value[2]].number);
  451. // 更新 Hour Value
  452. let hourIndex = this.range[3].findIndex(hour => {
  453. return hour.number == hourBeforeUpdate.number;
  454. });
  455. this.value.splice(3, 1, hourIndex >= 0 ? hourIndex : 0);
  456. }
  457. // 当前选择的分
  458. if(this.fields == 'hour') return;
  459. let minuteBeforeUpdate = this.range[4][this.value[4]];
  460. // 更新分数据
  461. this.setMinuteData(this.range[0][this.value[0]].number, this.range[1][this.value[1]].number, this.range[2][this.value[2]].number, this.range[3][this.value[3]].number);
  462. // 更新 Minute Value
  463. let minuteIndex = this.range[4].findIndex(minute => {
  464. return minute.number == minuteBeforeUpdate.number;
  465. });
  466. this.value.splice(4, 1, minuteIndex >= 0 ? minuteIndex : 0);
  467. },
  468. /**
  469. * 判断数据是否是 String 类型
  470. * @param {Any} val 要判断的数据
  471. * @returns {Boolean} true:是;false:不是;
  472. */
  473. isString(val) {
  474. return Object.prototype.toString.call(val) === '[object String]';
  475. },
  476. /**
  477. * 精确判断数据是否是 Date 类型
  478. * @param {Any} val 要判断的数据
  479. * @returns {Boolean} true:是;false:不是;
  480. */
  481. isDate(val) {
  482. return Object.prototype.toString.call(val) === '[object Date]';
  483. },
  484. /**
  485. * 格式化日期
  486. * @param {Date|String} date 日期或日期字符串
  487. */
  488. formatDate(date) {
  489. let YYYY = null;
  490. let M = null;
  491. let MM = null;
  492. let D = null;
  493. let DD = null;
  494. let h = null;
  495. let hh = null;
  496. let m = null;
  497. let mm = null;
  498. let s = null;
  499. let ss = null;
  500. let ms = null;
  501. let ms2 = null;
  502. let ms3 = null;
  503. let ms4 = null;
  504. let dt = null;
  505. // 如果 date 是 String 类型
  506. if (date && this.isString(date)) {
  507. // 当前日期
  508. let dt = new Date();
  509. // 真机运行时,如果直接用 new Date('YYYY-MM-DD hh:mm:ss') 会报 Invalid Date 错误,所以采用下面的方式创建日期
  510. let dtArr = date.replace(/\//g, '.').replace(/-/g, '.').replace(/:/g, '.').replace(/T/g, ' ').replace(' ', '.').replace(
  511. 'Z', '').split('.');
  512. // 年
  513. if (dtArr.length > 0 && !isNaN(dtArr[0])) {
  514. dt.setFullYear(parseInt(dtArr[0]));
  515. }
  516. // 月
  517. if (dtArr.length > 1 && !isNaN(dtArr[1])) {
  518. dt.setMonth(parseInt(dtArr[1]) - 1);
  519. }
  520. // 日
  521. if (dtArr.length > 2 && !isNaN(dtArr[2])) {
  522. dt.setDate(parseInt(dtArr[2]));
  523. }
  524. // 时
  525. if (dtArr.length > 3 && !isNaN(dtArr[3])) {
  526. dt.setHours(parseInt(dtArr[3]));
  527. } else {
  528. dt.setHours(0);
  529. }
  530. // 分
  531. if (dtArr.length > 4 && !isNaN(dtArr[4])) {
  532. dt.setMinutes(parseInt(dtArr[4]));
  533. } else {
  534. dt.setMinutes(0);
  535. }
  536. // 秒
  537. if (dtArr.length > 5 && !isNaN(dtArr[5])) {
  538. dt.setSeconds(parseInt(dtArr[5]));
  539. } else {
  540. dt.setSeconds(0);
  541. }
  542. // 毫秒
  543. if (dtArr.length > 6 && !isNaN(dtArr[6])) {
  544. dt.setMilliseconds(parseInt(dtArr[6]));
  545. } else {
  546. dt.setMilliseconds(0);
  547. }
  548. date = dt;
  549. }
  550. // 如果 date 是 Date 类型
  551. if (date && this.isDate(date)) {
  552. YYYY = date.getFullYear();
  553. M = date.getMonth() + 1;
  554. MM = M >= 10 ? M : '0' + M;
  555. D = date.getDate();
  556. DD = D >= 10 ? D : '0' + D;
  557. h = date.getHours();
  558. hh = h >= 10 ? h : '0' + h;
  559. m = date.getMinutes();
  560. mm = m >= 10 ? m : '0' + m;
  561. s = date.getSeconds();
  562. ss = s >= 10 ? s : '0' + s;
  563. ms = date.getMilliseconds();
  564. ms2 = ms;
  565. ms3 = ms;
  566. ms4 = ms;
  567. if (ms < 10) {
  568. ms2 = '0' + ms;
  569. ms3 = '00' + ms;
  570. ms4 = '000' + ms;
  571. } else if (ms < 100) {
  572. ms3 = '0' + ms;
  573. ms4 = '00' + ms;
  574. } else {
  575. ms4 = '0' + ms;
  576. }
  577. }
  578. // 返回的数据对象
  579. let result = {
  580. YYYY: YYYY,
  581. MM: MM,
  582. M: M,
  583. DD: DD,
  584. D: D,
  585. hh: hh,
  586. h: h,
  587. mm: mm,
  588. m: m,
  589. ss: ss,
  590. s: s,
  591. ms: ms,
  592. ms2: ms2,
  593. ms3: ms3,
  594. ms4: ms4,
  595. dt: date,
  596. fmt1: `${YYYY}-${MM}-${DD}`,
  597. fmt2: `${YYYY}年${M}月${D}日`,
  598. fmt3: `${YYYY}-${M}-${D} ${hh}:${mm}`,
  599. fmt4: `${h}:${m}:${s}`,
  600. fmt5: `${MM}-${DD}`,
  601. fmt6: `${YYYY}-${MM}`,
  602. fmt7: `${YYYY}年${M}月`,
  603. fmt8: `${h}:${m}`,
  604. fmt9: `${M}月${D}日`,
  605. notes: 'YYYY(年),MM(月,补0),M(月,不补0),DD(日,补0),D(日,不补0),hh(时,补0),h(时,不补0),mm(分,补0),m(分,不补0),ss(秒,补0),s(秒,不补0),ms(毫秒,不补0),ms2(毫秒,补0到2位),ms3(毫秒,补0到3位),ms4(毫秒,补0到4位),其余的fmt1,fmt2,... 看格式就知道了!'
  606. };
  607. return result;
  608. }
  609. }
  610. };
  611. </script>
  612. <style lang="scss" scoped>
  613. .content {
  614. text-align: left;
  615. flex: 1;
  616. color: #101010;
  617. }
  618. .content.placeholder{
  619. color: #aeaeae;
  620. }
  621. .dis-fix{
  622. display: flex;
  623. justify-content: space-around;
  624. }
  625. </style>