wui-date.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. angular.module('wui.date',[]).directive('wuiDate', function() {
  2. return {
  3. // Restrict to elements and attributes
  4. restrict: 'EA',
  5. // Assign the angular link function
  6. compile: fieldCompile,
  7. // Assign the angular directive template HTML
  8. template: fieldTemplate,
  9. // templateUrl: "pageTemplate.html",
  10. // Assign the angular scope attribute formatting
  11. scope: {
  12. id: '@?', // 时间插件主键 默认scope.$id
  13. name: '@?', // 绑定表单验证input的name属性
  14. format: '@?', // 定义时间格式 默认yyyy-mm-dd
  15. interval: '@?', // 定义time时间间隔 默认30minutes
  16. placeholder: '@?', // 选择框提示语 默认 '选择时间'
  17. position: '@?', // 定义选择框浮动位置 默认left
  18. ngModel: '=', // 父scope绑定的时间的属性
  19. btns: '@', // 按钮信息 空则不显示任何按钮
  20. dateClass: '@?', // 自定义样式
  21. width: '@?', // 输入框宽度 支持px及百分比
  22. size: '@?' // 插件大小 默认为迷你型 large、L、l表示大型窗
  23. }
  24. };
  25. function fieldCompile(scope, element, attr) {
  26. return {
  27. pre: function(scope, element, attr) {
  28. scope.id = scope.id || 'date' + scope.$id; // 生成插件唯一id
  29. var position = scope.position || 'left', // 面板浮动
  30. iptWidth = parseInt(scope.width); // 输入框宽度
  31. iptWidthU = scope.width?scope.width.search('%') == -1 ? 'px' : '%':null,
  32. size = scope.size != 'large' && scope.size != 'l' && scope.size != 'L' ? 'small' : null;
  33. angular.element(element).find('.wui-date').addClass('wui-date-' + scope.id);
  34. if(scope.name != '' && typeof scope.name != 'undefined') {
  35. angular.element(element).find('.wui-date input').attr('name', scope.name);
  36. }
  37. if(size) {
  38. angular.element(element).find('.wui-date').addClass(size); // 大小
  39. }
  40. angular.element(element).find('.wui-date .wui-date-picker').addClass(position); // 面板添加浮动
  41. scope.dateClass ? angular.element(element).find('.wui-date').addClass(scope.dateClass) : null; // 插件外部样式
  42. iptWidth ? angular.element(element).find('.wui-date').css('width', iptWidth + iptWidthU) : null; // 输入框宽度
  43. },
  44. post: function(scope, element, attr) {
  45. fieldLink(scope, element, attr);
  46. }
  47. }
  48. }
  49. function fieldLink(scope, element, attr) {
  50. // 初始化
  51. var GMTDate, // GMT格式时间
  52. format = (scope.format || 'yyyy-mm-dd').toLowerCase(), // 时间格式
  53. interval = parseInt(scope.interval) || 30, // time间隔
  54. interval = (60 % interval === 0 || interval % 60 === 0) && interval <= 12 * 60 ? interval : 30,
  55. placeholder = scope.placeholder || "选择时间",
  56. maxYear = parseInt(new Date().getFullYear()) + 100, // 插件最大year
  57. minYear = 1900, // 插件最小year
  58. SPECIAL_DATE_RULES = ['至今'], // 特殊字符串规则
  59. DATE_RULES = ['yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:mm', 'yyyy-mm-dd', 'yyyy-mm']; // 内置的日期格式
  60. // angular对象初始化
  61. scope.date = {
  62. year: '0000',
  63. month: '00',
  64. date: '00',
  65. hours: '00',
  66. minutes: '00',
  67. seconds: '00',
  68. dateList: [],
  69. timeList: [],
  70. yearList: {},
  71. showPicker: false,
  72. showTimePicker: false,
  73. showTimeList: true,
  74. showClearIcon: false,
  75. selector: 1,
  76. btns: scope.btns ? JSON.parse(scope.btns.replace(/'/g, '"')) : {}, // btns字符串转对象
  77. showBtn: false,
  78. };
  79. // 初始化GMT时间
  80. function GMTDateInit(date) {
  81. date = dateFormat(date);
  82. if(date) {
  83. if(!SPECIAL_DATE_RULES.includes(date)) {
  84. GMTDate = StrDateToGMT(date);
  85. } else {
  86. GMTDate = new Date();
  87. }
  88. } else {
  89. GMTDate = new Date();
  90. }
  91. }
  92. // 加载dom
  93. function domBootstrap(format) {
  94. if(Object.keys(scope.date.btns).length) {
  95. scope.date.showBtn = true;
  96. }
  97. switch(format) {
  98. case 'yyyy-mm-dd hh:mm:ss':
  99. case 'yyyy-mm-dd hh:mm':
  100. scope.date.showTimePicker = true; //
  101. scope.date.selector = 1;
  102. angular.element(element).find('.wui-date .wui-date-picker').removeClass('no_timer');
  103. break;
  104. case 'yyyy-mm-dd':
  105. scope.date.showTimePicker = false;
  106. angular.element(element).find('.wui-date .wui-date-picker').addClass('no_timer');
  107. scope.date.selector = 1;
  108. break;
  109. case 'yyyy-mm':
  110. scope.date.showTimePicker = false;
  111. scope.date.selector = 2;
  112. angular.element(element).find('.wui-date .wui-date-picker').addClass('no_timer');
  113. break;
  114. default:
  115. break;
  116. }
  117. }
  118. // 时间格式化
  119. function dateFormat(date) {
  120. if(!date) {
  121. return null;
  122. }
  123. if(SPECIAL_DATE_RULES.includes(date)) { // 特殊字符串
  124. return date;
  125. }
  126. date = date.toString().replace(/[\D]/g, ""); // 清除时间除数字外字符
  127. var len = format.replace(/\W/g, "").length; // 默认格式长度
  128. var str = date.length >= len ? date.slice(0, len) : '';
  129. if(date && str) {
  130. switch(format) {
  131. case 'yyyy-mm-dd hh:mm:ss':
  132. date = str.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/, "$1-$2-$3 $4:$5:$6");
  133. break;
  134. case 'yyyy-mm-dd hh:mm':
  135. date = str.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/, "$1-$2-$3 $4:$5");
  136. break;
  137. case 'yyyy-mm-dd':
  138. date = str.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
  139. break;
  140. case 'yyyy-mm':
  141. date = str.replace(/(\d{4})(\d{2})/, "$1-$2");
  142. break;
  143. default:
  144. break;
  145. }
  146. return str !== date ? date : null; // 正则替换失败后返回原字符串 替换成功则 str != date
  147. }
  148. return null;
  149. }
  150. // 字符串时间格式化为标准时间
  151. function StrDateToGMT(date) {
  152. if(date && new Date(date) != 'Invalid Date') {
  153. return new Date(date);
  154. }
  155. return null;
  156. }
  157. // 标准时间格式化为字符串时间
  158. function GMTToStrDate(date) {
  159. date = new Date(date);
  160. if(date && toString.call(date) == '[object Date]') {
  161. return date.getFullYear() + '/' + getDoubleDigit(date.getMonth() + 1) + '/' + getDoubleDigit(date.getDate()) + ' ' + getDoubleDigit(date.getHours()) + ':' + getDoubleDigit(date.getMinutes()) + ':' + getDoubleDigit(date.getSeconds());
  162. }
  163. return null;
  164. }
  165. // 生成两位月、日
  166. function getDoubleDigit(num) {
  167. num = '0' + num;
  168. return num.slice(-2);
  169. }
  170. // 显示的年月日时分秒数据
  171. function getAllDate() {
  172. scope.date.year = GMTDate.getFullYear(); // 初始化年份
  173. scope.date.month = getDoubleDigit(GMTDate.getMonth() + 1); // 两位月份
  174. scope.date.day = getDoubleDigit(GMTDate.getDate()); // 两位日期
  175. scope.date.hours = getDoubleDigit(GMTDate.getHours()); // 两位时
  176. scope.date.minutes = getDoubleDigit(GMTDate.getMinutes()); // 两位分
  177. scope.date.seconds = getDoubleDigit(GMTDate.getSeconds()); // 两位秒
  178. }
  179. // 生成日期数据
  180. function getDateList(date) {
  181. date = date || new Date();
  182. if(date.getFullYear() <= maxYear && date.getFullYear() >= minYear) { // 判断年份上下限
  183. // 初始化数据
  184. var dateList = [], // 属性type:1 表示上月的日期 2表示当月日期 3表示下月日期, 属性date:当天是几号
  185. weekOfFirstDay, // 当月第一天是周几
  186. endDayOfMonth, // 当前月份最后一天
  187. endDayOfLastMonth, // 上月最后一天
  188. modelDate = StrDateToGMT(scope.ngModel);
  189. getAllDate();
  190. weekOfFirstDay = new Date(scope.date.year, scope.date.month - 1, 1).getDay();
  191. endDayOfMonth = new Date(scope.date.year, scope.date.month, 0).getDate();
  192. endDayOfLastMonth = new Date(scope.date.year, scope.date.month - 1, 0).getDate();
  193. // 当月日期列表
  194. for(var i = 1; i <= endDayOfMonth; i++) {
  195. // 面板显示日期与输入框日期相同返回 true
  196. if(modelDate) {
  197. var condition1 = modelDate.getFullYear() == scope.date.year && (modelDate.getMonth() + 1) == scope.date.month && modelDate.getDate() == i;
  198. }
  199. // 面板日期为系统当天日期返回 true
  200. var condition2 = new Date().getFullYear() == GMTDate.getFullYear() && new Date().getMonth() == GMTDate.getMonth() && new Date().getDate() == i;
  201. var dateObj = {
  202. 'type': 2,
  203. 'date': i
  204. };
  205. if(condition1) {
  206. dateObj.current = true; // currently picked
  207. }
  208. if(condition2) {
  209. dateObj.today = true; // today
  210. }
  211. dateList.push(dateObj);
  212. }
  213. // 根据week生成填充上月日期
  214. var prevLen = 0; // the length of prev month day
  215. prevLen = weekOfFirstDay || 7;
  216. for(var j = 0; j < prevLen; j++) {
  217. dateList.unshift({
  218. 'type': 1,
  219. 'date': endDayOfLastMonth--
  220. });
  221. }
  222. // 每个面板最多显示42天 计算剩余下月显示的天数
  223. var nextLen = 42 - prevLen - endDayOfMonth;
  224. for(var k = 1; k <= nextLen; k++) {
  225. dateList.push({
  226. 'type': 3,
  227. 'date': k
  228. });
  229. }
  230. // 按每行显示7天分割数组
  231. var count = 0,
  232. arr = [],
  233. resList = [];
  234. for(var l = 0; l < dateList.length; l++) {
  235. count++;
  236. arr.push(dateList[l]);
  237. if(count >= 7) {
  238. resList.push(arr);
  239. count = 0;
  240. arr = [];
  241. }
  242. }
  243. return resList;
  244. }
  245. }
  246. // 生成时间选择列表数据
  247. function createTimeList() {
  248. var h = 8,
  249. m = 0,
  250. resList = [{
  251. 'time': '08:00'
  252. }];
  253. // fill time list
  254. for(var i = 1; i < 24 * 60 / interval; i++) {
  255. m = m + interval;
  256. if(m >= 60) {
  257. h = h + (m / 60);
  258. m = 0;
  259. }
  260. if(h >= 24) {
  261. h = h - 24;
  262. }
  263. var timeObj = {
  264. 'time': getDoubleDigit(h) + ":" + getDoubleDigit(m)
  265. };
  266. resList.push(timeObj);
  267. }
  268. return resList;
  269. }
  270. // 生成年份选择列表数据
  271. function createYearList(year) {
  272. year = parseInt(year) || GMTDate.getFullYear();
  273. if(year) {
  274. var yearList = {};
  275. yearList.startYear = year;
  276. yearList.endYear = yearList.startYear + 10;
  277. yearList.y1 = [];
  278. yearList.y2 = [];
  279. yearList.y3 = [];
  280. for(var i = 0; i < 4; i++) {
  281. yearList.y1.push(year + i);
  282. yearList.y2.push(year + i + 4);
  283. if(yearList.y3.length <= 2) {
  284. yearList.y3.push(year + i + 8);
  285. }
  286. }
  287. return yearList;
  288. }
  289. return null;
  290. }
  291. // 输出时间
  292. function outputDate() {
  293. scope.ngModel = dateFormat(GMTToStrDate(GMTDate));
  294. }
  295. // 点击某天关闭弹窗的规则
  296. var DATE_PICK_CLOSE = (format == DATE_RULES[2]);
  297. // Pick Date
  298. scope.pickDate = function(item, e) {
  299. if(item.type == 2) {
  300. GMTDate.setDate(item.date);
  301. if(DATE_PICK_CLOSE) {
  302. scope.date.showPicker = false;
  303. }
  304. } else if(item.type == 1) {
  305. GMTDate.setDate(item.date);
  306. GMTDate.setMonth(scope.date.month - 2);
  307. } else if(item.type == 3) {
  308. GMTDate.setDate(item.date);
  309. GMTDate.setMonth(scope.date.month);
  310. }
  311. outputDate();
  312. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  313. }
  314. // Pick Time
  315. scope.pickTime = function(time) {
  316. GMTDate.setHours(time.slice(0, 2));
  317. GMTDate.setMinutes(time.slice(3, 5));
  318. outputDate();
  319. getAllDate();
  320. }
  321. // Prev Year
  322. scope.prevYear = function() {
  323. var y = scope.date.year - 1;
  324. if(y >= minYear) {
  325. GMTDate.setFullYear(y);
  326. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  327. }
  328. }
  329. // Next Year
  330. scope.nextYear = function() {
  331. var y = scope.date.year + 1;
  332. if(y <= maxYear) {
  333. GMTDate.setFullYear(y);
  334. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  335. }
  336. }
  337. // Prev Year
  338. scope.prevYearByMonth = function() {
  339. var y = scope.date.year - 1;
  340. if(y >= minYear) {
  341. GMTDate.setFullYear(y);
  342. getAllDate();
  343. }
  344. }
  345. // Next Year
  346. scope.nextYearByMonth = function() {
  347. var y = scope.date.year + 1;
  348. if(y <= maxYear) {
  349. GMTDate.setFullYear(y);
  350. getAllDate();
  351. }
  352. }
  353. // Prev Month
  354. scope.prevMonth = function() {
  355. var m = scope.date.month - 2;
  356. GMTDate.setMonth(m);
  357. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  358. }
  359. // Next Month
  360. scope.nextMonth = function() {
  361. var m = scope.date.month;
  362. GMTDate.setMonth(m);
  363. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  364. }
  365. // 打开年份选择列表
  366. scope.openYearPicker = function(year) {
  367. scope.date.selector = 3;
  368. scope.date.yearList = createYearList(year);
  369. }
  370. // Pick Year
  371. scope.selectYear = function(year) {
  372. GMTDate.setFullYear(year);
  373. scope.date.selector = 2;
  374. getAllDate();
  375. outputDate();
  376. }
  377. scope.pickPrevYear = function() {
  378. var year = scope.date.yearList.startYear - 11;
  379. if(year >= minYear) {
  380. scope.openYearPicker(year);
  381. }
  382. }
  383. scope.pickNextYear = function() {
  384. var year = scope.date.yearList.startYear + 11;
  385. if(year <= maxYear) {
  386. scope.openYearPicker(year);
  387. }
  388. }
  389. // 打开月份选择列表
  390. scope.openMonthPicker = function() {
  391. scope.date.selector = 2;
  392. }
  393. // 点击某月关闭弹窗的规则
  394. var MONTH_PICK_CLOSE = (format == DATE_RULES[3]);
  395. // Select Month
  396. scope.selectMonth = function(m) {
  397. GMTDate.setMonth(m - 1);
  398. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  399. scope.date.selector = 1;
  400. outputDate();
  401. if(MONTH_PICK_CLOSE) {
  402. scope.date.showPicker = false;
  403. }
  404. }
  405. // 选择至今
  406. scope.hitherto = function() {
  407. scope.ngModel = '至今';
  408. scope.date.showPicker = false;
  409. }
  410. // Picker open
  411. scope.openPicker = function() {
  412. domBootstrap(format); // 打开日期面板更新样式
  413. angular.element(".wui-date .wui-date-picker").hide();
  414. angular.element(".wui-date-" + scope.id + " .wui-date-picker").show();
  415. GMTDateInit(scope.ngModel);
  416. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  417. scope.date.showPicker = true;
  418. }
  419. // 确定按钮
  420. scope.confirm = function() {
  421. outputDate();
  422. scope.date.showPicker = false;
  423. }
  424. // 此刻按钮
  425. scope.moment = function() {
  426. GMTDate = new Date();
  427. outputDate();
  428. scope.date.showPicker = false;
  429. }
  430. // 格式化input的date
  431. scope.checkDateFormat = function() {
  432. scope.ngModel = dateFormat(scope.ngModel);
  433. }
  434. // date init
  435. scope.dateInit = function() {
  436. domBootstrap(format);
  437. GMTDateInit(scope.ngModel);
  438. scope.date.dateList = getDateList(GMTDate); // 生成年月日数据
  439. scope.date.timeList = createTimeList();
  440. }
  441. scope.$watch('date.showPicker', function() {
  442. if(scope.date.showPicker) {
  443. scope.dateInit();
  444. }
  445. });
  446. // Close by click blank
  447. element.on('click', function(e) {
  448. //阻止底层冒泡
  449. e.stopPropagation();
  450. });
  451. angular.element('body').on('click', ':not(.wui-date)', function() {
  452. angular.element(element).find('.wui-date-picker').hide();
  453. });
  454. }
  455. function fieldTemplate(scope, element, attr) {
  456. return(
  457. '<div class="wui-date wui-date" ng-app="wui.date">' +
  458. '<div class="wui-date-editor" ng-click="openPicker()">' +
  459. '<input class="wui-input wui-input-block wui-date-input" type="text" placeholder="{{placeholder}}" ng-model="ngModel" autocomplete="off" ng-blur=checkDateFormat()>' +
  460. '<i class="iconfont icon1">&#xe807;</i>' +
  461. '</div>' +
  462. '<br/>' +
  463. '<div class="wui-date-picker" ng-show="date.showPicker">' +
  464. '<div class="wui-date-picker_body">' +
  465. '<div class="wui-date-picker_panel" ng-show="date.selector == 1">' +
  466. '<div class="wui-date-panel_header">' +
  467. '<i class="iconfont" ng-click="prevYear()">&#xe809;</i>' +
  468. '<i class="iconfont" ng-click="prevMonth()">&#xe808;</i>' +
  469. '<span class="title">' +
  470. '<span class="txt" ng-click="openYearPicker()"><span>{{date.year}}</span> 年 </span>' +
  471. '<span class="txt" ng-click="openMonthPicker()"><span>{{date.month}}</span> 月</span>' +
  472. '</span>' +
  473. '<i class="iconfont" ng-click="nextMonth()">&#xe886;</i>' +
  474. '<i class="iconfont" ng-click="nextYear()">&#xe640;</i>' +
  475. '</div>' +
  476. '<div class="wui-date-picker_content">' +
  477. '<table class="wui-data-table">' +
  478. '<tr>' +
  479. '<th>日</th>' +
  480. '<th>一</th>' +
  481. '<th>二</th>' +
  482. '<th>三</th>' +
  483. '<th>四</th>' +
  484. '<th>五</th>' +
  485. '<th>六</th>' +
  486. '</tr>' +
  487. '<tr ng-repeat="item in date.dateList track by $index">' +
  488. '<td ng-repeat="subItem in date.dateList[$index]"><div ng-class="{&apos;prev-date&apos;:subItem.type==1,&apos;date&apos;:subItem.type==2,&apos;next-date&apos;:subItem.type==3}"><span ng-click="pickDate(subItem,$event)" ng-class="{&apos;today&apos;:subItem.today,&apos;current&apos;:subItem.current}">{{subItem.date}}</span></div></td>' +
  489. '</tr>' +
  490. '</table>' +
  491. '</div>' +
  492. '</div>' +
  493. '<div class="wui-date-picker_panel month_panel" ng-show="date.selector == 2">' +
  494. '<div class="wui-date-panel_header">' +
  495. '<i class="iconfont" ng-click="prevYearByMonth()">&#xe809;</i>' +
  496. '<span class="title">' +
  497. '<span class="txt" ng-click="openYearPicker()"><span>{{date.year}}</span> 年</span>' +
  498. '</span>' +
  499. '<i class="iconfont" ng-click="nextYearByMonth()">&#xe640;</i>' +
  500. '</div> ' +
  501. '<div class="wui-date-picker_content">' +
  502. '<table class="wui-data-table">' +
  503. '<tr>' +
  504. '<td>' +
  505. '<a class="cell" ng-click="selectMonth(1)">一月</a>' +
  506. '</td>' +
  507. '<td>' +
  508. '<a class="cell" ng-click="selectMonth(2)">二月</a>' +
  509. '</td>' +
  510. '<td>' +
  511. '<a class="cell" ng-click="selectMonth(3)">三月</a>' +
  512. '</td>' +
  513. '<td>' +
  514. '<a class="cell" ng-click="selectMonth(4)">四月</a>' +
  515. '</td>' +
  516. '</tr>' +
  517. '<tr>' +
  518. '<td>' +
  519. '<a class="cell" ng-click="selectMonth(5)">五月</a>' +
  520. '</td>' +
  521. '<td>' +
  522. '<a class="cell" ng-click="selectMonth(6)">六月</a>' +
  523. '</td>' +
  524. '<td>' +
  525. '<a class="cell" ng-click="selectMonth(7)">七月</a>' +
  526. '</td>' +
  527. '<td>' +
  528. '<a class="cell" ng-click="selectMonth(8)">八月</a>' +
  529. '</td>' +
  530. '</tr>' +
  531. '<tr>' +
  532. '<td>' +
  533. '<a class="cell" ng-click="selectMonth(9)">九月</a>' +
  534. '</td>' +
  535. '<td>' +
  536. '<a class="cell" ng-click="selectMonth(10)">十月</a>' +
  537. '</td>' +
  538. '<td>' +
  539. '<a class="cell" ng-click="selectMonth(11)">十一月</a>' +
  540. '</td>' +
  541. '<td>' +
  542. '<a class="cell" ng-click="selectMonth(12)">十二月</a>' +
  543. '</td>' +
  544. '</tr>' +
  545. '</table>' +
  546. '</div> ' +
  547. '</div>' +
  548. '<div class="wui-date-picker_panel year_panel" ng-show="date.selector == 3 ">' +
  549. '<div class="wui-date-panel_header">' +
  550. '<i class="iconfont" ng-click="pickPrevYear()">&#xe809;</i>' +
  551. '<span class="title">' +
  552. '<span class="txt"><span>{{date.yearList.startYear}}</span> 年 - <span>{{date.yearList.endYear}}</span> 年</span>' +
  553. '</span>' +
  554. '<i class="iconfont" ng-click="pickNextYear()">&#xe640;</i>' +
  555. '</div>' +
  556. '<div class="wui-date-picker_content">' +
  557. '<table class="wui-data-table">' +
  558. '<tr>' +
  559. '<td ng-repeat="item in date.yearList.y1 track by $index">' +
  560. '<a class="cell" ng-click="selectYear(item)">{{item}}</a>' +
  561. '</td>' +
  562. '</tr>' +
  563. '<tr>' +
  564. '<td ng-repeat="item in date.yearList.y2 track by $index">' +
  565. '<a class="cell" ng-click="selectYear(item)">{{item}}</a>' +
  566. '</td>' +
  567. '</tr>' +
  568. '<tr>' +
  569. '<td ng-repeat="item in date.yearList.y3 track by $index">' +
  570. '<a class="cell" ng-click="selectYear(item)">{{item}}</a>' +
  571. '</td>' +
  572. '</tr>' +
  573. '</table>' +
  574. '</div>' +
  575. '</div>' +
  576. '<div class="wui-date-picker_aside" ng-show="date.showTimePicker">' +
  577. '<div class="wui-date-aside_header">' +
  578. '<div class="wui-select wui-select-block time-select" id="time">' +
  579. '<div class="wui-select-selection time-selection">' +
  580. '<input type="hidden" name="" value="" >' +
  581. '<span class="wui-select-icon iconfont time-icon">&#xe887;</span>' +
  582. '<span class="wui-select-placeholder placeholder">{{date.hours}}:{{date.minutes}}</span>' +
  583. '<span class="wui-select-selected-value value"></span>' +
  584. '</div>' +
  585. '<div class="wui-select-menu time-menu" ng-show="date.showTimeList">' +
  586. '<ul>' +
  587. '<li class="wui-select-item time-menu-item" ng-repeat="item in date.timeList" ng-click="pickTime(item.time)">{{item.time}}</li>' +
  588. '</ul>' +
  589. '</div>' +
  590. '</div>' +
  591. '</div>' +
  592. '</div>' +
  593. '</div>' +
  594. '<div class="wui-date-picker_footer" ng-show="date.showBtn">' +
  595. '<button type="button" class="wui-btn wui-btn-white wui-btn-xsmall" ng-click="moment()" ng-if="date.btns.now">{{date.btns.now}}</button>' +
  596. '<button type="button" class="wui-btn wui-btn-primary wui-btn-xsmall" ng-click="confirm()" ng-if="date.btns.ok">{{date.btns.ok}}</button>' +
  597. '<button type="button" class="wui-btn wui-btn-white wui-btn-xsmall" ng-click="hitherto()" ng-if="date.btns.hitherto">至今</button>' +
  598. '</div>' +
  599. '</div>' +
  600. '</div>'
  601. );
  602. }
  603. });