@opentiny/vue-renderless 3.1.0-alpha.0 → 3.4.7

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 (177) hide show
  1. package/action-menu/index.js +10 -0
  2. package/action-menu/vue.js +26 -0
  3. package/amount/index.js +334 -0
  4. package/amount/vue.js +206 -0
  5. package/area/index.js +162 -0
  6. package/area/vue.js +68 -0
  7. package/autonavi-map/index.js +28 -0
  8. package/avatar/index.js +5 -1
  9. package/avatar/vue.js +2 -1
  10. package/baidu-map/index.js +28 -0
  11. package/breadcrumb/index.js +9 -0
  12. package/breadcrumb/vue.js +25 -3
  13. package/breadcrumb-item/index.js +26 -0
  14. package/breadcrumb-item/vue.js +20 -11
  15. package/bulletin-board/index.js +4 -1
  16. package/button-group/vue.js +1 -1
  17. package/calendar/index.js +14 -14
  18. package/card-template/index.js +1 -1
  19. package/cascader/index.js +21 -7
  20. package/cascader/vue.js +1 -2
  21. package/cascader-node/index.js +3 -1
  22. package/cascader-panel/index.js +12 -4
  23. package/cascader-panel/vue.js +1 -2
  24. package/chart-bar/index.js +533 -0
  25. package/chart-boxplot/index.js +270 -0
  26. package/chart-candle/index.js +428 -0
  27. package/chart-core/deps/constants.js +65 -0
  28. package/chart-core/deps/numerify.js +286 -0
  29. package/chart-core/deps/utils.js +205 -0
  30. package/chart-core/index.js +541 -0
  31. package/chart-core/modules/animation.js +10 -0
  32. package/chart-core/modules/extend.js +36 -0
  33. package/chart-core/modules/mark.js +7 -0
  34. package/chart-core/vue.js +128 -0
  35. package/chart-funnel/index.js +155 -0
  36. package/chart-gauge/index.js +153 -0
  37. package/chart-graph/index.js +38 -0
  38. package/chart-heatmap/index.js +407 -0
  39. package/chart-line/index.js +358 -0
  40. package/chart-liquidfill/index.js +119 -0
  41. package/chart-map/index.js +261 -0
  42. package/chart-pie/index.js +327 -0
  43. package/chart-radar/index.js +181 -0
  44. package/chart-sankey/index.js +166 -0
  45. package/chart-scatter/index.js +360 -0
  46. package/chart-sunburst/index.js +36 -0
  47. package/chart-tree/index.js +107 -0
  48. package/chart-waterfall/index.js +231 -0
  49. package/chart-wordcloud/index.js +109 -0
  50. package/checkbox/index.js +4 -4
  51. package/checkbox-button/index.js +3 -1
  52. package/common/bigInt.js +5 -2
  53. package/common/date.js +17 -17
  54. package/common/deps/date-util.js +15 -5
  55. package/common/deps/date.js +6 -6
  56. package/common/deps/dom.js +18 -6
  57. package/common/deps/eSpaceCtrl.js +286 -0
  58. package/common/deps/fullscreen/apis.js +22 -22
  59. package/common/deps/memorize.js +3 -3
  60. package/common/deps/modal-queue.js +2 -0
  61. package/common/deps/popper.js +12 -10
  62. package/common/deps/popup-manager.js +16 -5
  63. package/common/deps/resize-event.js +6 -2
  64. package/common/deps/scrollbar-width.js +6 -2
  65. package/common/deps/tree-model/node.js +30 -10
  66. package/common/deps/tree-model/tree-store.js +33 -21
  67. package/common/deps/tree-model/util.js +6 -2
  68. package/common/deps/upload-ajax.js +7 -1
  69. package/common/deps/vue-popper.js +2 -2
  70. package/common/string.js +1 -1
  71. package/company/index.js +56 -0
  72. package/company/vue.js +35 -0
  73. package/country/index.js +54 -0
  74. package/country/vue.js +35 -0
  75. package/credit-card-form/index.js +1 -0
  76. package/currency/index.js +78 -0
  77. package/currency/vue.js +39 -0
  78. package/date-panel/index.js +16 -6
  79. package/date-picker/index.js +9 -5
  80. package/date-range/index.js +28 -9
  81. package/date-table/index.js +3 -1
  82. package/dept/index.js +318 -0
  83. package/dept/vue.js +163 -0
  84. package/detail-page/index.js +4 -1
  85. package/dialog-box/index.js +14 -4
  86. package/dialog-box/vue.js +7 -3
  87. package/drop-roles/index.js +73 -0
  88. package/drop-roles/vue.js +38 -0
  89. package/dropdown/index.js +5 -4
  90. package/dropdown/vue.js +5 -3
  91. package/dropdown-item/index.js +15 -0
  92. package/dropdown-item/vue.js +27 -13
  93. package/espace/index.js +129 -0
  94. package/espace/vue.js +52 -0
  95. package/file-upload/index.js +336 -291
  96. package/form/index.js +3 -1
  97. package/form/vue.js +15 -0
  98. package/form-item/index.js +15 -5
  99. package/fullscreen/index.js +4 -4
  100. package/fullscreen/vue.js +3 -3
  101. package/grid/core/interceptor.js +4 -7
  102. package/grid/plugins/export.js +2 -2
  103. package/grid/plugins/exportExcel.js +28 -10
  104. package/grid/static/array/findTree.js +1 -1
  105. package/grid/static/base/helperCreateGetObjects.js +1 -1
  106. package/grid/static/base/helperEqualCompare.js +2 -2
  107. package/grid/static/base/helperGetHGSKeys.js +1 -1
  108. package/grid/static/base/uniqueId.js +1 -1
  109. package/grid/static/object/assign.js +3 -3
  110. package/grid/static/string/toString.js +3 -3
  111. package/hrapprover/index.js +118 -0
  112. package/hrapprover/vue.js +102 -0
  113. package/locales/index.js +116 -0
  114. package/locales/vue.js +46 -0
  115. package/logon-user/index.js +23 -0
  116. package/logon-user/vue.js +22 -0
  117. package/logout/index.js +118 -0
  118. package/logout/vue.js +22 -0
  119. package/milestone/index.js +2 -1
  120. package/mini-picker/index.js +1 -1
  121. package/mini-picker/vue.js +1 -1
  122. package/modal/index.js +4 -2
  123. package/month-table/index.js +2 -2
  124. package/nav-menu/index.js +2 -2
  125. package/numeric/index.js +4 -2
  126. package/package.json +33 -136
  127. package/pager-item/vue.js +6 -2
  128. package/picker/index.js +43 -17
  129. package/picker/timezone.js +2 -2
  130. package/picker-column/index.js +7 -3
  131. package/pop-upload/index.js +5 -3
  132. package/popeditor/index.js +15 -7
  133. package/popover/index.js +87 -54
  134. package/popover/vue.js +13 -9
  135. package/rate/index.js +2 -2
  136. package/rich-text/clipboard.js +77 -0
  137. package/rich-text/index.js +176 -0
  138. package/rich-text/module/file-upload.js +118 -0
  139. package/rich-text/module/image-drop.js +54 -0
  140. package/rich-text/module/image-upload.js +84 -0
  141. package/rich-text/options.js +187 -0
  142. package/rich-text/table-module.js +557 -0
  143. package/rich-text/vue.js +149 -0
  144. package/roles/index.js +87 -0
  145. package/roles/vue.js +39 -0
  146. package/search/index.js +32 -27
  147. package/search/vue.js +7 -2
  148. package/select/index.js +328 -304
  149. package/select/vue.js +19 -9
  150. package/select-dropdown/index.js +1 -1
  151. package/slider/index.js +9 -11
  152. package/slider/vue.js +3 -3
  153. package/split/vue.js +1 -1
  154. package/tab-nav/index.js +0 -6
  155. package/tab-nav/vue.js +0 -14
  156. package/table/index.js +1 -1
  157. package/text-popup/index.js +6 -4
  158. package/time/index.js +3 -1
  159. package/time-range/index.js +6 -2
  160. package/time-spinner/index.js +15 -5
  161. package/toggle-menu/index.js +11 -0
  162. package/toggle-menu/vue.js +2 -1
  163. package/tooltip/index.js +46 -35
  164. package/tooltip/vue.js +5 -1
  165. package/tree/index.js +57 -21
  166. package/tree-menu/index.js +3 -1
  167. package/tree-node/index.js +7 -3
  168. package/upload/index.js +14 -5
  169. package/user/index.js +634 -0
  170. package/user/vue.js +113 -0
  171. package/user-account/index.js +23 -0
  172. package/user-account/vue.js +25 -0
  173. package/user-contact/index.js +1 -4
  174. package/user-head/index.js +9 -11
  175. package/user-head/vue.js +2 -6
  176. package/user-link/index.js +43 -0
  177. package/user-link/vue.js +60 -0
package/form/index.js CHANGED
@@ -27,7 +27,9 @@ export var watchRules = function watchRules(_ref) {
27
27
  export var computedAutoLabelWidth = function computedAutoLabelWidth(_ref2) {
28
28
  var state = _ref2.state;
29
29
  return function () {
30
- if (!state.potentialLabelWidthArr.length) return 0;
30
+ if (!state.potentialLabelWidthArr.length) {
31
+ return 0;
32
+ }
31
33
  var max = Math.max.apply(Math, _toConsumableArray(state.potentialLabelWidthArr));
32
34
  return max ? "".concat(max, "px") : '';
33
35
  };
package/form/vue.js CHANGED
@@ -15,6 +15,21 @@ export var renderless = function renderless(props, _ref, _ref2) {
15
15
  potentialLabelWidthArr: [],
16
16
  autoLabelWidth: computed(function () {
17
17
  return api.computedAutoLabelWidth();
18
+ }),
19
+ hasRequired: computed(function () {
20
+ if (props.rules) {
21
+ return Object.values(props.rules).find(function (ruleOrRules) {
22
+ if (Array.isArray(ruleOrRules)) {
23
+ return ruleOrRules.some(function (r) {
24
+ return r.required;
25
+ });
26
+ } else {
27
+ return ruleOrRules.required;
28
+ }
29
+ });
30
+ } else {
31
+ return false;
32
+ }
18
33
  })
19
34
  });
20
35
  Object.assign(api, {
@@ -29,7 +29,9 @@ export var computedLabelStyle = function computedLabelStyle(_ref2) {
29
29
  state = _ref2.state;
30
30
  return function () {
31
31
  var result = {};
32
- if (state.form.labelPosition === POSITION.Top) return result;
32
+ if (state.form.labelPosition === POSITION.Top) {
33
+ return result;
34
+ }
33
35
  var labelWidth = props.labelWidth || state.form.labelWidth;
34
36
  if (labelWidth) {
35
37
  result.width = labelWidth;
@@ -43,8 +45,12 @@ export var computedContentStyle = function computedContentStyle(_ref3) {
43
45
  return function () {
44
46
  var result = {};
45
47
  var label = props.label;
46
- if (state.form.labelPosition === POSITION.Top || state.form.inline) return result;
47
- if (!label && !props.labelWidth && state.isNested) return result;
48
+ if (state.form.labelPosition === POSITION.Top || state.form.inline) {
49
+ return result;
50
+ }
51
+ if (!label && !props.labelWidth && state.isNested) {
52
+ return result;
53
+ }
48
54
  var labelWidth = props.labelWidth || state.form.labelWidth;
49
55
  if (labelWidth === 'auto') {
50
56
  if (props.labelWidth === 'auto') {
@@ -271,7 +277,9 @@ export var getFilteredRule = function getFilteredRule(api) {
271
277
  return function (trigger) {
272
278
  var rules = api.getRules();
273
279
  return rules.filter(function (rule) {
274
- if (!rule.trigger || trigger === '') return true;
280
+ if (!rule.trigger || trigger === '') {
281
+ return true;
282
+ }
275
283
  if (Array.isArray(rule.trigger)) {
276
284
  return rule.trigger.indexOf(trigger) > -1;
277
285
  }
@@ -344,7 +352,9 @@ export var getValueByPath = function getValueByPath(object, prop) {
344
352
  var result = null;
345
353
  for (var i = 0, len = paths.length; i < len; i++) {
346
354
  var path = paths[i];
347
- if (!current) break;
355
+ if (!current) {
356
+ break;
357
+ }
348
358
  if (i === len - 1) {
349
359
  result = current[path];
350
360
  break;
@@ -23,7 +23,7 @@ export var request = function request(_ref2) {
23
23
  return function () {
24
24
  if (state.isPageOnly) {
25
25
  state.isFullscreen = true;
26
- api.onChangeFullScreen();
26
+ api.onChangeFullscreen();
27
27
  off(document, 'keyup', api.keypressCallback);
28
28
  on(document, 'keyup', api.keypressCallback);
29
29
  } else {
@@ -52,7 +52,7 @@ export var exit = function exit(_ref3) {
52
52
  }
53
53
  if (state.isPageOnly) {
54
54
  state.isFullscreen = false;
55
- api.onChangeFullScreen();
55
+ api.onChangeFullscreen();
56
56
  off(document, 'keyup', api.keypressCallback);
57
57
  } else {
58
58
  sf.exit();
@@ -80,7 +80,7 @@ export var fullScreenCallback = function fullScreenCallback(_ref5) {
80
80
  sf.off('change', api.fullScreenCallback);
81
81
  }
82
82
  state.isFullscreen = sf.isFullscreen;
83
- api.onChangeFullScreen();
83
+ api.onChangeFullscreen();
84
84
  };
85
85
  };
86
86
  export var keypressCallback = function keypressCallback(api) {
@@ -90,7 +90,7 @@ export var keypressCallback = function keypressCallback(api) {
90
90
  }
91
91
  };
92
92
  };
93
- export var onChangeFullScreen = function onChangeFullScreen(_ref6) {
93
+ export var onChangeFullscreen = function onChangeFullscreen(_ref6) {
94
94
  var props = _ref6.props,
95
95
  state = _ref6.state,
96
96
  vm = _ref6.vm,
package/fullscreen/vue.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import sf from '@opentiny/vue-renderless/common/deps/fullscreen/screenfull';
2
- import { exit, enter, toggle, request, getState, shadeClick, keypressCallback, fullScreenCallback, onChangeFullScreen, computeWrapperStyle } from './index';
3
- export var api = ['state', 'exit', 'enter', 'toggle', 'request', 'getState', 'shadeClick', 'keypressCallback', 'fullScreenCallback', 'onChangeFullScreen'];
2
+ import { exit, enter, toggle, request, getState, shadeClick, keypressCallback, fullScreenCallback, onChangeFullscreen, computeWrapperStyle } from './index';
3
+ export var api = ['state', 'exit', 'enter', 'toggle', 'request', 'getState', 'shadeClick', 'keypressCallback', 'fullScreenCallback', 'onChangeFullscreen'];
4
4
  export var renderless = function renderless(props, _ref, _ref2) {
5
5
  var reactive = _ref.reactive,
6
6
  computed = _ref.computed,
@@ -56,7 +56,7 @@ export var renderless = function renderless(props, _ref, _ref2) {
56
56
  props: props,
57
57
  state: state
58
58
  }),
59
- onChangeFullScreen: onChangeFullScreen({
59
+ onChangeFullscreen: onChangeFullscreen({
60
60
  props: props,
61
61
  state: state,
62
62
  vm: vm,
@@ -15,13 +15,10 @@ var Interceptor = {
15
15
  return _storeMap[toType(type)] || [];
16
16
  },
17
17
  add: function add(type, callback) {
18
- type = toType(type);
19
- if (callback && ~eventTypes.indexOf(type)) {
20
- var eList = _storeMap[type];
21
- if (!eList) {
22
- eList = _storeMap[type] = [];
23
- }
24
- eList.push(callback);
18
+ var selfType = toType(type);
19
+ if (callback && ~eventTypes.indexOf(selfType)) {
20
+ _storeMap[selfType] = _storeMap[selfType] ? _storeMap[selfType] : [];
21
+ _storeMap[selfType].push(callback);
25
22
  }
26
23
  return Interceptor;
27
24
  },
@@ -9,7 +9,7 @@ import { exportExcel } from './exportExcel';
9
9
  var getCsvLabelData = function getCsvLabelData(columns, oData, tableElem) {
10
10
  var trElemList = tableElem.querySelectorAll('.tiny-grid__body-wrapper.body__wrapper .tiny-grid-body__row');
11
11
  var trData = [];
12
- var _loop = function _loop(i, len) {
12
+ var _loop = function _loop() {
13
13
  var item = {};
14
14
  var trElem = trElemList[i];
15
15
  columns.forEach(function (column) {
@@ -19,7 +19,7 @@ var getCsvLabelData = function getCsvLabelData(columns, oData, tableElem) {
19
19
  trData.push(item);
20
20
  };
21
21
  for (var i = 0, len = trElemList.length; i < len; i++) {
22
- _loop(i, len);
22
+ _loop();
23
23
  }
24
24
  return trData;
25
25
  };
@@ -29,8 +29,10 @@ function funcFromCodePoint() {
29
29
  var codeLength = 0;
30
30
  var resultStr = '';
31
31
  for (var i = 0, length = arguments.length; i !== length; ++i) {
32
- var cp = +arguments[i];
33
- if (!(cp < 0x10ffff && cp >>> 0 === cp)) throw new RangeError('Invalid code point: ' + cp);
32
+ var cp = Number(arguments[i]);
33
+ if (!(cp < 0x10ffff && cp >>> 0 === cp)) {
34
+ throw new RangeError('Invalid code point: ' + cp);
35
+ }
34
36
  if (cp <= 0xffff) {
35
37
  codeLength = codeUnitArr.push(cp);
36
38
  } else {
@@ -98,7 +100,9 @@ function initHeaderDatas(_ref5) {
98
100
  var childNodes = headerTrs[i].childNodes;
99
101
  var colSpanCount = 0;
100
102
  for (var j = 0; j < childNodes.length; j++) {
101
- if (~childNodes[j].className.split(/\s/).indexOf('col__gutter')) break;
103
+ if (~childNodes[j].className.split(/\s/).indexOf('col__gutter')) {
104
+ break;
105
+ }
102
106
  colSpanCount += childNodes[j].colSpan;
103
107
  }
104
108
  if (colSpanCount > maxColSpanCount[1]) {
@@ -132,7 +136,9 @@ function buildHeaderMerges(_ref6) {
132
136
  hpx: adjustHeight(rowHeight)
133
137
  });
134
138
  for (var j = 0; j < childNodes.length; j++) {
135
- if (~childNodes[j].className.split(/\s/).indexOf('col__gutter')) break;
139
+ if (~childNodes[j].className.split(/\s/).indexOf('col__gutter')) {
140
+ break;
141
+ }
136
142
  ths.push(childNodes[j]);
137
143
  var colSpan = childNodes[j].colSpan;
138
144
  var rowSpan = childNodes[j].rowSpan;
@@ -213,7 +219,9 @@ function buildHeader(_ref8) {
213
219
  headerTrs = _ref8.headerTrs,
214
220
  opts = _ref8.opts,
215
221
  ws = _ref8.ws;
216
- if (headerRowCount === 0) return;
222
+ if (headerRowCount === 0) {
223
+ return;
224
+ }
217
225
  var rowHeightMethod = opts.table.rowHeightMethod;
218
226
  var columnWidthMethod = opts.table.columnWidthMethod;
219
227
  var ths = [];
@@ -327,7 +335,9 @@ function buildBody(_ref11) {
327
335
  headerRowCount = _ref11.headerRowCount,
328
336
  opts = _ref11.opts,
329
337
  ws = _ref11.ws;
330
- if (bodyRowCount === 0) return;
338
+ if (bodyRowCount === 0) {
339
+ return;
340
+ }
331
341
  var rowHeightMethod = opts.table.rowHeightMethod;
332
342
  var offset = headerRowCount;
333
343
  for (var i = 0; i < bodyTrs.length; i++) {
@@ -458,7 +468,9 @@ function buildDatas(_ref14) {
458
468
  opts = _ref14.opts,
459
469
  $table = _ref14.$table,
460
470
  ws = _ref14.ws;
461
- if (datas.length === 0) return;
471
+ if (datas.length === 0) {
472
+ return;
473
+ }
462
474
  var styleMethod = opts.table.styleMethod;
463
475
  var formatMethod = opts.table.formatMethod;
464
476
  var fullColumn = $table.getTableColumn().fullColumn;
@@ -575,7 +587,9 @@ function buildColidsByVisibleColumn(_ref16) {
575
587
  colids = _ref16.colids,
576
588
  opts = _ref16.opts,
577
589
  ws = _ref16.ws;
578
- if (colids.length > 0 || bodyRowCount === 0) return;
590
+ if (colids.length > 0 || bodyRowCount === 0) {
591
+ return;
592
+ }
579
593
  var columnWidthMethod = opts.table.columnWidthMethod;
580
594
  var tds = [];
581
595
  for (var i = 0; i < bodyTrs.length; i++) {
@@ -612,7 +626,9 @@ function buildFooter(_ref17) {
612
626
  headerRowCount = _ref17.headerRowCount,
613
627
  opts = _ref17.opts,
614
628
  ws = _ref17.ws;
615
- if (footerRowCount === 0) return;
629
+ if (footerRowCount === 0) {
630
+ return;
631
+ }
616
632
  var rowHeightMethod = opts.table.rowHeightMethod;
617
633
  var offset = headerRowCount + bodyRowCount;
618
634
  for (var i = 0; i < footerTrs.length; i++) {
@@ -725,7 +741,9 @@ function createExcelFromDom($table, opts) {
725
741
  export function exportExcel($table, options) {
726
742
  var opts = extend(true, {}, options);
727
743
  opts.plugins = opts.plugins || {};
728
- if (!opts.plugins.XLSX || !opts.plugins.XLSXX || !opts.plugins.FileSaver) return;
744
+ if (!opts.plugins.XLSX || !opts.plugins.XLSXX || !opts.plugins.FileSaver) {
745
+ return;
746
+ }
729
747
  opts.table = opts.table || {};
730
748
  opts.table.sheetName = opts.table.sheetName || defaultOptions.table.sheetName;
731
749
  opts.table.formatMethod = opts.table.formatMethod || defaultOptions.table.formatMethod;
@@ -26,7 +26,7 @@ var findTreeItem = function findTreeItem(_ref) {
26
26
  if (parseChildren && item) {
27
27
  var newPath = paths.concat([parseChildren]);
28
28
  var match = findTreeItem({
29
- item: item,
29
+ parent: item,
30
30
  obj: item[parseChildren],
31
31
  iterate: iterate,
32
32
  context: context,
@@ -12,7 +12,7 @@ var helperCreateGetObjects = function helperCreateGetObjects(name, getIndex) {
12
12
  var eachCallback;
13
13
  if (getIndex > 1) {
14
14
  eachCallback = function eachCallback(key) {
15
- result.push(['' + key, obj[key]]);
15
+ result.push([String(key), obj[key]]);
16
16
  };
17
17
  } else {
18
18
  eachCallback = function eachCallback() {
@@ -19,10 +19,10 @@ var helperEqualCompare = function helperEqualCompare(_ref) {
19
19
  }
20
20
  if (val1 && val2 && !isNumber(val1) && !isNumber(val2) && !isString(val1) && !isString(val2)) {
21
21
  if (isRegExp(val1)) {
22
- return compare('' + val1, '' + val2, key, obj1, obj2);
22
+ return compare(String(val1), String(val2), key, obj1, obj2);
23
23
  }
24
24
  if (isDate(val1) || isBoolean(val1)) {
25
- return compare(+val1, +val2, key, obj1, obj2);
25
+ return compare(Number(val1), Number(val2), key, obj1, obj2);
26
26
  }
27
27
  return equalVal(val1, val2, func, key, compare);
28
28
  }
@@ -1,4 +1,4 @@
1
1
  var helperGetHGSKeys = function helperGetHGSKeys(property) {
2
- return property ? property.splice && property.join ? property : ('' + property).split('.') : [];
2
+ return property ? property.splice && property.join ? property : String(property).split('.') : [];
3
3
  };
4
4
  export default helperGetHGSKeys;
@@ -1,5 +1,5 @@
1
1
  var __uniqueId = 0;
2
2
  var uniqueId = function uniqueId(prefix) {
3
- return (prefix ? '' + prefix : 0) + ++__uniqueId;
3
+ return (prefix ? String(prefix) : 0) + ++__uniqueId;
4
4
  };
5
5
  export default uniqueId;
@@ -4,9 +4,9 @@ import clone from '../base/clone';
4
4
  var objectAssignFns = Object.assign;
5
5
  var handleAssign = function handleAssign(destination, args, isClone) {
6
6
  var len = args.length;
7
- var _loop = function _loop(_source, index) {
7
+ var _loop = function _loop(_source) {
8
8
  _source = args[index];
9
- var eachCallback = void 0;
9
+ var eachCallback;
10
10
  if (isClone) {
11
11
  eachCallback = function eachCallback(key) {
12
12
  destination[key] = clone(_source[key], isClone);
@@ -20,7 +20,7 @@ var handleAssign = function handleAssign(destination, args, isClone) {
20
20
  source = _source;
21
21
  };
22
22
  for (var source, index = 1; index < len; index++) {
23
- _loop(source, index);
23
+ _loop(source);
24
24
  }
25
25
  return destination;
26
26
  };
@@ -2,11 +2,11 @@ import eqNull from '../base/eqNull';
2
2
  import isNumber from '../base/isNumber';
3
3
  var toValString = function toValString(obj) {
4
4
  if (isNumber(obj)) {
5
- if (('' + obj).indexOf('e-') >= 0) {
5
+ if (String(obj).indexOf('e-') >= 0) {
6
6
  var isNegative = obj < 0;
7
- return (isNegative ? '-' : '') + '0' + ('' + ((isNegative ? Math.abs(obj) : obj) + 1)).substr(1);
7
+ return (isNegative ? '-' : '') + '0' + String((isNegative ? Math.abs(obj) : obj) + 1).substr(1);
8
8
  }
9
9
  }
10
- return '' + (eqNull(obj) ? '' : obj);
10
+ return String(eqNull(obj) ? '' : obj);
11
11
  };
12
12
  export default toValString;
@@ -0,0 +1,118 @@
1
+ import { extend } from '@opentiny/vue-renderless/common/object';
2
+ export var getHrList = function getHrList(_ref) {
3
+ var api = _ref.api,
4
+ props = _ref.props,
5
+ state = _ref.state;
6
+ return function (deptCode) {
7
+ state.loading = true;
8
+ var params = {
9
+ code: deptCode,
10
+ category: props.category
11
+ };
12
+ return api.fetchHrapprover(params).then(function (data) {
13
+ var hraInfo = [];
14
+ data.forEach(function (info) {
15
+ var person = info.approval_Person;
16
+ if (!person) {
17
+ return;
18
+ }
19
+ var persons = person.split('#');
20
+ persons.forEach(function (val) {
21
+ var newInfo = extend({}, info, {
22
+ 'approval_person': val
23
+ });
24
+ hraInfo.push(newInfo);
25
+ });
26
+ });
27
+ state.loading = false;
28
+ return hraInfo;
29
+ });
30
+ };
31
+ };
32
+ export var selectedDept = function selectedDept(_ref2) {
33
+ var api = _ref2.api,
34
+ state = _ref2.state;
35
+ return function (value) {
36
+ if (!value) {
37
+ state.hrList = [];
38
+ state.approvalPerson = '';
39
+ return;
40
+ }
41
+ api.getHrList(value).then(function (result) {
42
+ state.hrList = result;
43
+ var hasApproval = result.some(function (item) {
44
+ return item.approval_person === state.approvalPerson;
45
+ });
46
+ if (!hasApproval) {
47
+ state.approvalPerson = '';
48
+ }
49
+ })["catch"](function () {
50
+ state.hrList = [];
51
+ });
52
+ };
53
+ };
54
+ export var getDisplay = function getDisplay(_ref3) {
55
+ var api = _ref3.api,
56
+ state = _ref3.state;
57
+ return function (value) {
58
+ if (state.current === value) {
59
+ return;
60
+ }
61
+ state.current = value;
62
+ if (!value) {
63
+ state.hrList = [];
64
+ state.lastHrList = [];
65
+ state.approvalPerson = '';
66
+ return;
67
+ }
68
+ api.getHrList(value).then(function (result) {
69
+ state.hrList = result;
70
+ state.lastHrList = result;
71
+ var hasApproval = result.some(function (item) {
72
+ return item.approval_person === state.approvalPerson;
73
+ });
74
+ if (!hasApproval) {
75
+ state.approvalPerson = '';
76
+ }
77
+ })["catch"](function () {
78
+ state.hrList = [];
79
+ state.lastHrList = [];
80
+ state.approvalPerson = '';
81
+ });
82
+ };
83
+ };
84
+ export var resetPerson = function resetPerson(_ref4) {
85
+ var props = _ref4.props,
86
+ state = _ref4.state;
87
+ return function () {
88
+ state.approvalPerson = props.approvalPerson;
89
+ };
90
+ };
91
+ export var hrChange = function hrChange(_ref5) {
92
+ var emit = _ref5.emit,
93
+ state = _ref5.state;
94
+ return function (value) {
95
+ state.current = value;
96
+ emit('update:modelValue', value);
97
+ emit('update:approvalPerson', state.approvalPerson);
98
+ };
99
+ };
100
+ export var initService = function initService(_ref6) {
101
+ var props = _ref6.props,
102
+ service = _ref6.service;
103
+ var _ref7 = service || {},
104
+ fetchHrapprover = _ref7.fetchHrapprover;
105
+ var fetchHrapproverNoop = function fetchHrapproverNoop() {
106
+ return Promise.reject(new Error('[TINY Error][Hrapprover] Prop fetchHrapprover is not configured'));
107
+ };
108
+ return {
109
+ fetchHrapprover: props.fetchHrapprover || fetchHrapprover || fetchHrapproverNoop
110
+ };
111
+ };
112
+ export var cancel = function cancel(_ref8) {
113
+ var state = _ref8.state;
114
+ return function () {
115
+ state.approvalPerson = state.overdueData;
116
+ state.hrList = state.lastHrList;
117
+ };
118
+ };
@@ -0,0 +1,102 @@
1
+ import { getHrList, selectedDept, resetPerson, hrChange, initService, getDisplay, cancel } from './index';
2
+ export var api = ['state', 'hrChange', 'selectedDept', 'resetPerson', 'getDisplay', 'cancel'];
3
+ var initState = function initState(_ref) {
4
+ var reactive = _ref.reactive,
5
+ props = _ref.props;
6
+ var state = reactive({
7
+ hrList: [],
8
+ lastHrList: [],
9
+ dept: props.modelValue,
10
+ current: '',
11
+ approvalPerson: props.approvalPerson,
12
+ overdueData: '',
13
+ loading: false
14
+ });
15
+ return state;
16
+ };
17
+ var initApi = function initApi(_ref2) {
18
+ var api = _ref2.api,
19
+ state = _ref2.state,
20
+ emit = _ref2.emit,
21
+ props = _ref2.props,
22
+ $service = _ref2.$service;
23
+ Object.assign(api, {
24
+ state: state,
25
+ hrChange: hrChange({
26
+ emit: emit,
27
+ state: state
28
+ }),
29
+ resetPerson: resetPerson({
30
+ props: props,
31
+ state: state
32
+ }),
33
+ fetchHrapprover: $service.fetchHrapprover,
34
+ cancel: cancel({
35
+ state: state
36
+ }),
37
+ getHrList: getHrList({
38
+ api: api,
39
+ props: props,
40
+ state: state
41
+ }),
42
+ selectedDept: selectedDept({
43
+ api: api,
44
+ state: state
45
+ }),
46
+ getDisplay: getDisplay({
47
+ api: api,
48
+ state: state
49
+ })
50
+ });
51
+ };
52
+ var initWatch = function initWatch(_ref3) {
53
+ var watch = _ref3.watch,
54
+ state = _ref3.state,
55
+ api = _ref3.api,
56
+ props = _ref3.props;
57
+ watch(function () {
58
+ return props.modelValue;
59
+ }, function (value) {
60
+ state.dept = value;
61
+ api.getDisplay(value);
62
+ }, {
63
+ immediate: true
64
+ });
65
+ watch(function () {
66
+ return props.approvalPerson;
67
+ }, function (value) {
68
+ state.overdueData = value;
69
+ state.approvalPerson = value;
70
+ }, {
71
+ immediate: true
72
+ });
73
+ };
74
+ export var renderless = function renderless(props, _ref4, _ref5) {
75
+ var reactive = _ref4.reactive,
76
+ watch = _ref4.watch;
77
+ var service = _ref5.service,
78
+ emit = _ref5.emit;
79
+ var api = {};
80
+ var $service = initService({
81
+ props: props,
82
+ service: service
83
+ });
84
+ var state = initState({
85
+ reactive: reactive,
86
+ props: props
87
+ });
88
+ initApi({
89
+ api: api,
90
+ state: state,
91
+ emit: emit,
92
+ props: props,
93
+ $service: $service
94
+ });
95
+ initWatch({
96
+ watch: watch,
97
+ state: state,
98
+ api: api,
99
+ props: props
100
+ });
101
+ return api;
102
+ };