eoss-ui 0.6.33 → 0.6.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/lib/button-group.js +36 -19
  2. package/lib/button.js +36 -19
  3. package/lib/checkbox-group.js +36 -19
  4. package/lib/data-table-form.js +36 -19
  5. package/lib/data-table.js +36 -19
  6. package/lib/date-picker.js +36 -19
  7. package/lib/dialog.js +36 -19
  8. package/lib/eoss-ui.common.js +97 -55
  9. package/lib/flow-group.js +36 -19
  10. package/lib/flow-list.js +36 -19
  11. package/lib/flow.js +36 -19
  12. package/lib/form.js +36 -19
  13. package/lib/handle-user.js +36 -19
  14. package/lib/handler.js +36 -19
  15. package/lib/icon.js +36 -19
  16. package/lib/icons.js +1 -1
  17. package/lib/index.js +1 -1
  18. package/lib/input-number.js +36 -19
  19. package/lib/input.js +36 -19
  20. package/lib/login.js +39 -22
  21. package/lib/main.js +82 -40
  22. package/lib/nav.js +36 -19
  23. package/lib/page.js +36 -19
  24. package/lib/pagination.js +36 -19
  25. package/lib/player.js +36 -19
  26. package/lib/qr-code.js +36 -19
  27. package/lib/radio-group.js +36 -19
  28. package/lib/retrial-auth.js +36 -19
  29. package/lib/select-ganged.js +36 -19
  30. package/lib/select.js +36 -19
  31. package/lib/selector-panel.js +36 -19
  32. package/lib/selector.js +36 -19
  33. package/lib/sizer.js +36 -19
  34. package/lib/steps.js +36 -19
  35. package/lib/switch.js +36 -19
  36. package/lib/table-form.js +36 -19
  37. package/lib/tabs.js +36 -19
  38. package/lib/theme-chalk/base.css +1 -1
  39. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  40. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  41. package/lib/theme-chalk/icon.css +1 -1
  42. package/lib/theme-chalk/index.css +1 -1
  43. package/lib/theme-chalk/main.css +1 -1
  44. package/lib/theme-chalk/menu.css +1 -1
  45. package/lib/theme-chalk/simplicity.css +1 -1
  46. package/lib/theme-chalk/sizer.css +1 -1
  47. package/lib/theme-chalk/upload.css +1 -1
  48. package/lib/tips.js +36 -19
  49. package/lib/tree-group.js +36 -19
  50. package/lib/tree.js +36 -19
  51. package/lib/upload.js +36 -19
  52. package/lib/utils/util.js +36 -19
  53. package/lib/wujie.js +36 -19
  54. package/lib/wxlogin.js +36 -19
  55. package/package.json +2 -2
  56. package/packages/.DS_Store +0 -0
  57. package/packages/data-table/.DS_Store +0 -0
  58. package/packages/icons/.DS_Store +0 -0
  59. package/packages/icons/src/icon.json +1 -1
  60. package/packages/login/src/main.vue +1 -1
  61. package/packages/main/.DS_Store +0 -0
  62. package/packages/main/src/default/index.vue +1 -1
  63. package/packages/main/src/main.vue +2 -2
  64. package/packages/main/src/simplicity/index.vue +32 -5
  65. package/packages/theme-chalk/lib/base.css +1 -1
  66. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  67. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  68. package/packages/theme-chalk/lib/icon.css +1 -1
  69. package/packages/theme-chalk/lib/index.css +1 -1
  70. package/packages/theme-chalk/lib/main.css +1 -1
  71. package/packages/theme-chalk/lib/menu.css +1 -1
  72. package/packages/theme-chalk/lib/simplicity.css +1 -1
  73. package/packages/theme-chalk/lib/sizer.css +1 -1
  74. package/packages/theme-chalk/lib/upload.css +1 -1
  75. package/packages/theme-chalk/src/.DS_Store +0 -0
  76. package/packages/theme-chalk/src/common/var.scss +2 -2
  77. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  78. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  79. package/packages/theme-chalk/src/handler.scss +1 -1
  80. package/packages/theme-chalk/src/icon.scss +7 -0
  81. package/packages/theme-chalk/src/login.scss +1 -1
  82. package/packages/theme-chalk/src/retrial-auth.scss +1 -1
  83. package/src/.DS_Store +0 -0
  84. package/src/index.js +1 -1
  85. package/src/utils/util.js +34 -22
package/lib/steps.js CHANGED
@@ -103,6 +103,10 @@ module.exports =
103
103
  /* harmony import */ var eoss_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(eoss_element__WEBPACK_IMPORTED_MODULE_5__);
104
104
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
105
105
 
106
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
107
+
108
+ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
109
+
106
110
  /**
107
111
  * 新封装公告方法规范:
108
112
  * 1.方法顺序按字母顺序排列
@@ -187,7 +191,8 @@ var ajax = function ajax(_ref) {
187
191
  publicKey = _ref.publicKey,
188
192
  secret = _ref.secret,
189
193
  encodes = _ref.encodes,
190
- oldmode = _ref.oldmode;
194
+ oldmode = _ref.oldmode,
195
+ configs = _objectWithoutProperties(_ref, ['headers', 'method', 'url', 'host', 'data', 'params', 'format', 'mix', 'defaults', 'loading', 'publicKey', 'secret', 'encodes', 'oldmode']);
191
196
 
192
197
  var header = headers || {};
193
198
  if (!method) {
@@ -491,13 +496,13 @@ var ajax = function ajax(_ref) {
491
496
  if (oldmode && !header['api-response-mode']) {
492
497
  header['api-response-mode'] = true;
493
498
  }
494
- return http({
499
+ return http(_extends({
495
500
  method: method,
496
501
  url: url,
497
502
  data: data,
498
503
  params: params,
499
504
  headers: header
500
- });
505
+ }, configs));
501
506
  };
502
507
 
503
508
  /**
@@ -1205,31 +1210,43 @@ var extend = function extend() {
1205
1210
  * @param {String} [fmt] - 格式
1206
1211
  **/
1207
1212
  var formatDate = function formatDate(date, fmt) {
1208
- var obj = void 0;
1209
- if (date) {
1210
- obj = new Date(date);
1211
- } else {
1212
- obj = new Date();
1213
- }
1213
+ // 1. 处理日期输入
1214
+ var obj = date ? new Date(date) : new Date();
1215
+ if (isNaN(obj.getTime())) throw new Error('Invalid date input');
1216
+
1217
+ // 2. 工具函数
1218
+ var pad = function pad(n) {
1219
+ return String(n).padStart(2, '0');
1220
+ };
1221
+ var monthNum = obj.getMonth(); // 数值月份 (0-11)
1222
+
1223
+ // 3. 定义格式化规则
1214
1224
  var quarter = ['一', '二', '三', '四'];
1225
+ var halfyear = ['上', '下'];
1215
1226
  var o = {
1216
- 'b+': Math.ceil((obj.getMonth() + 1) / 6), // 半年
1217
- 'M+': obj.getMonth() + 1, // 月份
1218
- 'd+': obj.getDate(), // 日
1219
- 'H+': obj.getHours(), // 小时
1220
- 'm+': obj.getMinutes(), //
1221
- 's+': obj.getSeconds(), // 秒
1222
- 'q+': quarter[Math.ceil((obj.getMonth() + 1) / 3) - 1], // 季度
1223
- S: obj.getMilliseconds() // 毫秒
1227
+ 'b+': halfyear[Math.floor(monthNum / 6)], // 1=上半年, 2=下半年
1228
+ 'M+': monthNum + 1, // 月份 (1-12)
1229
+ 'd+': obj.getDate(), // 日 (1-31)
1230
+ 'H+': obj.getHours(), // 小时 (0-23)
1231
+ 'm+': obj.getMinutes(), // 分钟 (0-59)
1232
+ 's+': obj.getSeconds(), // 秒 (0-59)
1233
+ 'q+': quarter[Math.floor(monthNum / 3)], // 季度 (一~四)
1234
+ 'S': obj.getMilliseconds() // 毫秒 (0-999)
1224
1235
  };
1236
+
1237
+ // 4. 处理年份
1225
1238
  if (/(y+)/.test(fmt)) {
1226
- fmt = fmt.replace(RegExp.$1, (obj.getFullYear() + '').substr(4 - RegExp.$1.length));
1239
+ fmt = fmt.replace(RegExp.$1, String(obj.getFullYear()).slice(-RegExp.$1.length));
1227
1240
  }
1241
+
1242
+ // 5. 处理其他字段
1228
1243
  for (var k in o) {
1229
1244
  if (new RegExp('(' + k + ')').test(fmt)) {
1230
- fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
1245
+ var val = k === 'q+' ? o[k] : pad(o[k]); // 季度不补零
1246
+ fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : val);
1231
1247
  }
1232
1248
  }
1249
+
1233
1250
  return fmt;
1234
1251
  };
1235
1252
 
package/lib/switch.js CHANGED
@@ -103,6 +103,10 @@ module.exports =
103
103
  /* harmony import */ var eoss_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(eoss_element__WEBPACK_IMPORTED_MODULE_5__);
104
104
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
105
105
 
106
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
107
+
108
+ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
109
+
106
110
  /**
107
111
  * 新封装公告方法规范:
108
112
  * 1.方法顺序按字母顺序排列
@@ -187,7 +191,8 @@ var ajax = function ajax(_ref) {
187
191
  publicKey = _ref.publicKey,
188
192
  secret = _ref.secret,
189
193
  encodes = _ref.encodes,
190
- oldmode = _ref.oldmode;
194
+ oldmode = _ref.oldmode,
195
+ configs = _objectWithoutProperties(_ref, ['headers', 'method', 'url', 'host', 'data', 'params', 'format', 'mix', 'defaults', 'loading', 'publicKey', 'secret', 'encodes', 'oldmode']);
191
196
 
192
197
  var header = headers || {};
193
198
  if (!method) {
@@ -491,13 +496,13 @@ var ajax = function ajax(_ref) {
491
496
  if (oldmode && !header['api-response-mode']) {
492
497
  header['api-response-mode'] = true;
493
498
  }
494
- return http({
499
+ return http(_extends({
495
500
  method: method,
496
501
  url: url,
497
502
  data: data,
498
503
  params: params,
499
504
  headers: header
500
- });
505
+ }, configs));
501
506
  };
502
507
 
503
508
  /**
@@ -1205,31 +1210,43 @@ var extend = function extend() {
1205
1210
  * @param {String} [fmt] - 格式
1206
1211
  **/
1207
1212
  var formatDate = function formatDate(date, fmt) {
1208
- var obj = void 0;
1209
- if (date) {
1210
- obj = new Date(date);
1211
- } else {
1212
- obj = new Date();
1213
- }
1213
+ // 1. 处理日期输入
1214
+ var obj = date ? new Date(date) : new Date();
1215
+ if (isNaN(obj.getTime())) throw new Error('Invalid date input');
1216
+
1217
+ // 2. 工具函数
1218
+ var pad = function pad(n) {
1219
+ return String(n).padStart(2, '0');
1220
+ };
1221
+ var monthNum = obj.getMonth(); // 数值月份 (0-11)
1222
+
1223
+ // 3. 定义格式化规则
1214
1224
  var quarter = ['一', '二', '三', '四'];
1225
+ var halfyear = ['上', '下'];
1215
1226
  var o = {
1216
- 'b+': Math.ceil((obj.getMonth() + 1) / 6), // 半年
1217
- 'M+': obj.getMonth() + 1, // 月份
1218
- 'd+': obj.getDate(), // 日
1219
- 'H+': obj.getHours(), // 小时
1220
- 'm+': obj.getMinutes(), //
1221
- 's+': obj.getSeconds(), // 秒
1222
- 'q+': quarter[Math.ceil((obj.getMonth() + 1) / 3) - 1], // 季度
1223
- S: obj.getMilliseconds() // 毫秒
1227
+ 'b+': halfyear[Math.floor(monthNum / 6)], // 1=上半年, 2=下半年
1228
+ 'M+': monthNum + 1, // 月份 (1-12)
1229
+ 'd+': obj.getDate(), // 日 (1-31)
1230
+ 'H+': obj.getHours(), // 小时 (0-23)
1231
+ 'm+': obj.getMinutes(), // 分钟 (0-59)
1232
+ 's+': obj.getSeconds(), // 秒 (0-59)
1233
+ 'q+': quarter[Math.floor(monthNum / 3)], // 季度 (一~四)
1234
+ 'S': obj.getMilliseconds() // 毫秒 (0-999)
1224
1235
  };
1236
+
1237
+ // 4. 处理年份
1225
1238
  if (/(y+)/.test(fmt)) {
1226
- fmt = fmt.replace(RegExp.$1, (obj.getFullYear() + '').substr(4 - RegExp.$1.length));
1239
+ fmt = fmt.replace(RegExp.$1, String(obj.getFullYear()).slice(-RegExp.$1.length));
1227
1240
  }
1241
+
1242
+ // 5. 处理其他字段
1228
1243
  for (var k in o) {
1229
1244
  if (new RegExp('(' + k + ')').test(fmt)) {
1230
- fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
1245
+ var val = k === 'q+' ? o[k] : pad(o[k]); // 季度不补零
1246
+ fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : val);
1231
1247
  }
1232
1248
  }
1249
+
1233
1250
  return fmt;
1234
1251
  };
1235
1252
 
package/lib/table-form.js CHANGED
@@ -103,6 +103,10 @@ module.exports =
103
103
  /* harmony import */ var eoss_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(eoss_element__WEBPACK_IMPORTED_MODULE_5__);
104
104
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
105
105
 
106
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
107
+
108
+ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
109
+
106
110
  /**
107
111
  * 新封装公告方法规范:
108
112
  * 1.方法顺序按字母顺序排列
@@ -187,7 +191,8 @@ var ajax = function ajax(_ref) {
187
191
  publicKey = _ref.publicKey,
188
192
  secret = _ref.secret,
189
193
  encodes = _ref.encodes,
190
- oldmode = _ref.oldmode;
194
+ oldmode = _ref.oldmode,
195
+ configs = _objectWithoutProperties(_ref, ['headers', 'method', 'url', 'host', 'data', 'params', 'format', 'mix', 'defaults', 'loading', 'publicKey', 'secret', 'encodes', 'oldmode']);
191
196
 
192
197
  var header = headers || {};
193
198
  if (!method) {
@@ -491,13 +496,13 @@ var ajax = function ajax(_ref) {
491
496
  if (oldmode && !header['api-response-mode']) {
492
497
  header['api-response-mode'] = true;
493
498
  }
494
- return http({
499
+ return http(_extends({
495
500
  method: method,
496
501
  url: url,
497
502
  data: data,
498
503
  params: params,
499
504
  headers: header
500
- });
505
+ }, configs));
501
506
  };
502
507
 
503
508
  /**
@@ -1205,31 +1210,43 @@ var extend = function extend() {
1205
1210
  * @param {String} [fmt] - 格式
1206
1211
  **/
1207
1212
  var formatDate = function formatDate(date, fmt) {
1208
- var obj = void 0;
1209
- if (date) {
1210
- obj = new Date(date);
1211
- } else {
1212
- obj = new Date();
1213
- }
1213
+ // 1. 处理日期输入
1214
+ var obj = date ? new Date(date) : new Date();
1215
+ if (isNaN(obj.getTime())) throw new Error('Invalid date input');
1216
+
1217
+ // 2. 工具函数
1218
+ var pad = function pad(n) {
1219
+ return String(n).padStart(2, '0');
1220
+ };
1221
+ var monthNum = obj.getMonth(); // 数值月份 (0-11)
1222
+
1223
+ // 3. 定义格式化规则
1214
1224
  var quarter = ['一', '二', '三', '四'];
1225
+ var halfyear = ['上', '下'];
1215
1226
  var o = {
1216
- 'b+': Math.ceil((obj.getMonth() + 1) / 6), // 半年
1217
- 'M+': obj.getMonth() + 1, // 月份
1218
- 'd+': obj.getDate(), // 日
1219
- 'H+': obj.getHours(), // 小时
1220
- 'm+': obj.getMinutes(), //
1221
- 's+': obj.getSeconds(), // 秒
1222
- 'q+': quarter[Math.ceil((obj.getMonth() + 1) / 3) - 1], // 季度
1223
- S: obj.getMilliseconds() // 毫秒
1227
+ 'b+': halfyear[Math.floor(monthNum / 6)], // 1=上半年, 2=下半年
1228
+ 'M+': monthNum + 1, // 月份 (1-12)
1229
+ 'd+': obj.getDate(), // 日 (1-31)
1230
+ 'H+': obj.getHours(), // 小时 (0-23)
1231
+ 'm+': obj.getMinutes(), // 分钟 (0-59)
1232
+ 's+': obj.getSeconds(), // 秒 (0-59)
1233
+ 'q+': quarter[Math.floor(monthNum / 3)], // 季度 (一~四)
1234
+ 'S': obj.getMilliseconds() // 毫秒 (0-999)
1224
1235
  };
1236
+
1237
+ // 4. 处理年份
1225
1238
  if (/(y+)/.test(fmt)) {
1226
- fmt = fmt.replace(RegExp.$1, (obj.getFullYear() + '').substr(4 - RegExp.$1.length));
1239
+ fmt = fmt.replace(RegExp.$1, String(obj.getFullYear()).slice(-RegExp.$1.length));
1227
1240
  }
1241
+
1242
+ // 5. 处理其他字段
1228
1243
  for (var k in o) {
1229
1244
  if (new RegExp('(' + k + ')').test(fmt)) {
1230
- fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
1245
+ var val = k === 'q+' ? o[k] : pad(o[k]); // 季度不补零
1246
+ fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : val);
1231
1247
  }
1232
1248
  }
1249
+
1233
1250
  return fmt;
1234
1251
  };
1235
1252
 
package/lib/tabs.js CHANGED
@@ -103,6 +103,10 @@ module.exports =
103
103
  /* harmony import */ var eoss_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(eoss_element__WEBPACK_IMPORTED_MODULE_5__);
104
104
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
105
105
 
106
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
107
+
108
+ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
109
+
106
110
  /**
107
111
  * 新封装公告方法规范:
108
112
  * 1.方法顺序按字母顺序排列
@@ -187,7 +191,8 @@ var ajax = function ajax(_ref) {
187
191
  publicKey = _ref.publicKey,
188
192
  secret = _ref.secret,
189
193
  encodes = _ref.encodes,
190
- oldmode = _ref.oldmode;
194
+ oldmode = _ref.oldmode,
195
+ configs = _objectWithoutProperties(_ref, ['headers', 'method', 'url', 'host', 'data', 'params', 'format', 'mix', 'defaults', 'loading', 'publicKey', 'secret', 'encodes', 'oldmode']);
191
196
 
192
197
  var header = headers || {};
193
198
  if (!method) {
@@ -491,13 +496,13 @@ var ajax = function ajax(_ref) {
491
496
  if (oldmode && !header['api-response-mode']) {
492
497
  header['api-response-mode'] = true;
493
498
  }
494
- return http({
499
+ return http(_extends({
495
500
  method: method,
496
501
  url: url,
497
502
  data: data,
498
503
  params: params,
499
504
  headers: header
500
- });
505
+ }, configs));
501
506
  };
502
507
 
503
508
  /**
@@ -1205,31 +1210,43 @@ var extend = function extend() {
1205
1210
  * @param {String} [fmt] - 格式
1206
1211
  **/
1207
1212
  var formatDate = function formatDate(date, fmt) {
1208
- var obj = void 0;
1209
- if (date) {
1210
- obj = new Date(date);
1211
- } else {
1212
- obj = new Date();
1213
- }
1213
+ // 1. 处理日期输入
1214
+ var obj = date ? new Date(date) : new Date();
1215
+ if (isNaN(obj.getTime())) throw new Error('Invalid date input');
1216
+
1217
+ // 2. 工具函数
1218
+ var pad = function pad(n) {
1219
+ return String(n).padStart(2, '0');
1220
+ };
1221
+ var monthNum = obj.getMonth(); // 数值月份 (0-11)
1222
+
1223
+ // 3. 定义格式化规则
1214
1224
  var quarter = ['一', '二', '三', '四'];
1225
+ var halfyear = ['上', '下'];
1215
1226
  var o = {
1216
- 'b+': Math.ceil((obj.getMonth() + 1) / 6), // 半年
1217
- 'M+': obj.getMonth() + 1, // 月份
1218
- 'd+': obj.getDate(), // 日
1219
- 'H+': obj.getHours(), // 小时
1220
- 'm+': obj.getMinutes(), //
1221
- 's+': obj.getSeconds(), // 秒
1222
- 'q+': quarter[Math.ceil((obj.getMonth() + 1) / 3) - 1], // 季度
1223
- S: obj.getMilliseconds() // 毫秒
1227
+ 'b+': halfyear[Math.floor(monthNum / 6)], // 1=上半年, 2=下半年
1228
+ 'M+': monthNum + 1, // 月份 (1-12)
1229
+ 'd+': obj.getDate(), // 日 (1-31)
1230
+ 'H+': obj.getHours(), // 小时 (0-23)
1231
+ 'm+': obj.getMinutes(), // 分钟 (0-59)
1232
+ 's+': obj.getSeconds(), // 秒 (0-59)
1233
+ 'q+': quarter[Math.floor(monthNum / 3)], // 季度 (一~四)
1234
+ 'S': obj.getMilliseconds() // 毫秒 (0-999)
1224
1235
  };
1236
+
1237
+ // 4. 处理年份
1225
1238
  if (/(y+)/.test(fmt)) {
1226
- fmt = fmt.replace(RegExp.$1, (obj.getFullYear() + '').substr(4 - RegExp.$1.length));
1239
+ fmt = fmt.replace(RegExp.$1, String(obj.getFullYear()).slice(-RegExp.$1.length));
1227
1240
  }
1241
+
1242
+ // 5. 处理其他字段
1228
1243
  for (var k in o) {
1229
1244
  if (new RegExp('(' + k + ')').test(fmt)) {
1230
- fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
1245
+ var val = k === 'q+' ? o[k] : pad(o[k]); // 季度不补零
1246
+ fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : val);
1231
1247
  }
1232
1248
  }
1249
+
1233
1250
  return fmt;
1234
1251
  };
1235
1252