eoss-ui 0.4.10 → 0.4.15

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 (67) hide show
  1. package/lib/button-group.js +110 -15
  2. package/lib/button.js +112 -17
  3. package/lib/ca-login.js +326 -0
  4. package/lib/card.js +2 -2
  5. package/lib/cascader.js +2 -2
  6. package/lib/checkbox-group.js +110 -15
  7. package/lib/clients.js +2 -2
  8. package/lib/data-table-form.js +110 -15
  9. package/lib/data-table.js +148 -35
  10. package/lib/date-picker.js +112 -17
  11. package/lib/dialog.js +113 -17
  12. package/lib/enterprise.js +2 -2
  13. package/lib/eoss-ui.common.js +289 -53
  14. package/lib/error-page.js +2 -2
  15. package/lib/flow-group.js +112 -17
  16. package/lib/flow-list.js +110 -15
  17. package/lib/flow.js +110 -15
  18. package/lib/form.js +124 -26
  19. package/lib/handle-user.js +112 -17
  20. package/lib/handler.js +112 -17
  21. package/lib/index.js +1 -1
  22. package/lib/input-number.js +112 -17
  23. package/lib/input.js +112 -17
  24. package/lib/label.js +2 -2
  25. package/lib/login.js +110 -15
  26. package/lib/main.js +110 -15
  27. package/lib/mainComp.js +110 -15
  28. package/lib/menu.js +2 -2
  29. package/lib/nav.js +112 -17
  30. package/lib/notify.js +2 -2
  31. package/lib/page.js +112 -17
  32. package/lib/pagination.js +2 -2
  33. package/lib/player.js +112 -17
  34. package/lib/qr-code.js +119 -24
  35. package/lib/radio-group.js +112 -17
  36. package/lib/select-ganged.js +112 -17
  37. package/lib/select.js +119 -24
  38. package/lib/selector-panel.js +110 -15
  39. package/lib/selector.js +112 -17
  40. package/lib/sizer.js +112 -17
  41. package/lib/steps.js +112 -17
  42. package/lib/switch.js +112 -17
  43. package/lib/table-form.js +119 -24
  44. package/lib/tabs-panel.js +2 -2
  45. package/lib/tabs.js +112 -17
  46. package/lib/theme-chalk/ca-login.css +1 -0
  47. package/lib/theme-chalk/index.css +1 -1
  48. package/lib/tips.js +112 -17
  49. package/lib/toolbar.js +2 -2
  50. package/lib/tree-group.js +112 -17
  51. package/lib/tree.js +112 -17
  52. package/lib/upload.js +110 -15
  53. package/lib/utils/util.js +110 -15
  54. package/lib/wujie.js +112 -17
  55. package/lib/wxlogin.js +112 -17
  56. package/package.json +4 -4
  57. package/packages/ca-login/index.js +5 -0
  58. package/packages/ca-login/src/main.vue +62 -0
  59. package/packages/data-table/src/column.vue +20 -7
  60. package/packages/data-table/src/main.vue +2 -1
  61. package/packages/form/src/main.vue +17 -7
  62. package/packages/theme-chalk/lib/ca-login.css +1 -0
  63. package/packages/theme-chalk/lib/index.css +1 -1
  64. package/packages/theme-chalk/src/ca-login.scss +4 -0
  65. package/packages/theme-chalk/src/index.scss +1 -0
  66. package/src/index.js +4 -1
  67. package/src/utils/util.js +122 -37
@@ -0,0 +1,4 @@
1
+ @import './common/var.scss';
2
+ .es-ca-login {
3
+ cursor: pointer;
4
+ }
@@ -2,6 +2,7 @@
2
2
  @import "./button.scss";
3
3
  @import "./button-group.scss";
4
4
  @import "./checkbox-group.scss";
5
+ @import "./ca-login.scss";
5
6
  @import "./card.scss";
6
7
  @import "./cascader.scss";
7
8
  @import "./clients.scss";
package/src/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import Button from '../packages/button/index.js';
4
4
  import ButtonGroup from '../packages/button-group/index.js';
5
5
  import CheckboxGroup from '../packages/checkbox-group/index.js';
6
+ import CaLogin from '../packages/ca-login/index.js';
6
7
  import Card from '../packages/card/index.js';
7
8
  import Cascader from '../packages/cascader/index.js';
8
9
  import Clients from '../packages/clients/index.js';
@@ -54,6 +55,7 @@ const components = [
54
55
  Button,
55
56
  ButtonGroup,
56
57
  CheckboxGroup,
58
+ CaLogin,
57
59
  Card,
58
60
  Cascader,
59
61
  Clients,
@@ -113,11 +115,12 @@ if (typeof window !== 'undefined' && window.Vue) {
113
115
  }
114
116
 
115
117
  export default {
116
- version: '0.4.10',
118
+ version: '0.4.15',
117
119
  install,
118
120
  Button,
119
121
  ButtonGroup,
120
122
  CheckboxGroup,
123
+ CaLogin,
121
124
  Card,
122
125
  Cascader,
123
126
  Clients,
package/src/utils/util.js CHANGED
@@ -326,7 +326,7 @@ const ajax = function ({
326
326
  * @param {String} [key] - 对象子元素的属性名
327
327
  **/
328
328
  const arrUnique = function (data, key) {
329
- var newArr = [];
329
+ let newArr = [];
330
330
  if (key === undefined) {
331
331
  data.sort();
332
332
  newArr = [data[0]];
@@ -336,7 +336,7 @@ const arrUnique = function (data, key) {
336
336
  }
337
337
  }
338
338
  } else {
339
- var obj = {};
339
+ let obj = {};
340
340
  for (let i = 0; i < data.length; i++) {
341
341
  if (!obj[data[i][key]]) {
342
342
  newArr.push(data[i]);
@@ -474,8 +474,8 @@ const esEncode = function (value) {
474
474
  * @param {string} [key] - 私钥
475
475
  **/
476
476
  const esDecode = function (value) {
477
- var kleng = publicKey.length;
478
- var result;
477
+ let kleng = publicKey.length;
478
+ let result;
479
479
  let cat1;
480
480
  let cat2;
481
481
  let cat3;
@@ -483,7 +483,7 @@ const esDecode = function (value) {
483
483
  let arr;
484
484
  arr = new Array(Math.floor(value.length / 3));
485
485
  result = arr.length;
486
- for (var i = 0; i < result; i++) {
486
+ for (let i = 0; i < result; i++) {
487
487
  cat1 = publicKey.indexOf(value.charAt(num));
488
488
  num++;
489
489
  cat2 = publicKey.indexOf(value.charAt(num));
@@ -562,10 +562,11 @@ const exclAttribute = ({ attrs = 'value', data }) => {
562
562
  * @param {name} [string] - 导出文件名
563
563
  * @param {numbers} [boolean] - 序号
564
564
  **/
565
- const exportXls = function ({ thead = [], data = [], name, numbers }) {
565
+ const exportXls = function ({ thead = [], data = [], name, numbers, option }) {
566
566
  let tbody = '';
567
567
  let aligns = [];
568
568
  let fields = [];
569
+ let keys = {};
569
570
  let others = {};
570
571
  let alink = document.createElement('a');
571
572
  for (let i = 0; i < thead.length; i++) {
@@ -573,14 +574,17 @@ const exportXls = function ({ thead = [], data = [], name, numbers }) {
573
574
  if (numbers) {
574
575
  tbody += '<th rowspan="' + thead.length + '"></th>';
575
576
  }
576
- const tr = thead[i];
577
+ let tr = thead[i];
577
578
  let col = 0;
578
579
  for (let x = 0; x < tr.length; x++) {
579
- const td = tr[x];
580
+ let td = tr[x];
580
581
  if (td.property) {
581
582
  if (col === x) {
582
583
  fields.push(td.property);
583
584
  aligns.push(td.align);
585
+ if (td.labelKey && td.valueKey) {
586
+ keys[td.property] = {labelKey: td.labelKey, valueKey: td.valueKey, multiple: !!(td.valueToString || td['value-to-string'])};
587
+ }
584
588
  } else {
585
589
  others[String(col)] = [td.property, td.align];
586
590
  }
@@ -601,16 +605,66 @@ const exportXls = function ({ thead = [], data = [], name, numbers }) {
601
605
  }
602
606
  for (let i = 0; i < data.length; i++) {
603
607
  tbody += '<tr>';
604
- for (var x in fields) {
605
- tbody += '<td align="' + aligns[x] + '">' + data[i][fields[x]] + '</td>';
608
+ for (let x in fields) {
609
+ let field = '';
610
+ let valueKey = keys[fields[x]] && keys[fields[x]].valueKey ? keys[fields[x]].valueKey : 'value';
611
+ let labelKey = keys[fields[x]] && keys[fields[x]].labelKey ? keys[fields[x]].labelKey : 'name';
612
+ if (option[fields[x]]) {
613
+ if (Array.isArray(data[i][fields[x]])) {
614
+ field = [];
615
+ data[i][fields[x]].forEach(ele => {
616
+ option[fields[x]].forEach(item => {
617
+ // eslint-disable-next-line eqeqeq
618
+ if (item[valueKey] == ele) {
619
+ field.push(item[labelKey]);
620
+ return;
621
+ }
622
+ });
623
+ });
624
+ field = field.join(' ');
625
+ } else if (typeof data[i][fields[x]] === 'string' && keys[fields[x]] && keys[fields[x]].multiple) {
626
+ field = [];
627
+ data[i][fields[x]].split(',').forEach(ele => {
628
+ option[fields[x]].forEach(item => {
629
+ // eslint-disable-next-line eqeqeq
630
+ if (item[valueKey] == ele) {
631
+ field.push(item[labelKey]);
632
+ return;
633
+ }
634
+ });
635
+ });
636
+ field = field.join(' ');
637
+ } else {
638
+ option[fields[x]].forEach(item => {
639
+ // eslint-disable-next-line eqeqeq
640
+ if (item[valueKey] == data[i][fields[x]]) {
641
+ field = item[labelKey];
642
+ return;
643
+ }
644
+ });
645
+ }
646
+ } else if (typeof data[i][fields[x]] === 'object' && keys[fields[x]]) {
647
+ if (Array.isArray(data[i][fields[x]])) {
648
+ data[i][fields[x]].forEach(item => {
649
+ field = [];
650
+ field.push({}.toString.call(item) === '[object Object]' ? item[labelKey] : item);
651
+ });
652
+ field = field.join(' ');
653
+ } else {
654
+ field = data[i][fields[x]][labelKey];
655
+ }
656
+ } else {
657
+ field = data[i][fields[x]];
658
+ }
659
+ tbody += '<td align="' + aligns[x] + '">' + field + '</td>';
606
660
  }
607
661
  tbody += '</tr>';
608
662
  }
609
663
  if (!name) {
610
664
  name = 'table_' + new Date().getTime();
611
665
  }
612
- var uri = 'data:application/vnd.ms-excel;base64,';
613
- var template =
666
+ let uri = 'data:application/vnd.ms-excel;base64,';
667
+ let template =
614
668
  '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table style="vnd.ms-excel.numberformat:@">' +
615
669
  tbody +
616
670
  '</table></body></html>';
@@ -948,7 +1002,7 @@ const getSaturation = function ($s, $i, $isLight) {
948
1002
  const getScript = function (url, callback) {
949
1003
  // eslint-disable-next-line no-undef
950
1004
  return new Promise((resolve, reject) => {
951
- var xmlHttp = null;
1005
+ let xmlHttp = null;
952
1006
  if (win.XMLHttpRequest) {
953
1007
  xmlHttp = new XMLHttpRequest();
954
1008
  } else if (win.ActiveXObject) {
@@ -1170,15 +1224,15 @@ const getValues = function (obj, flag) {
1170
1224
  **/
1171
1225
 
1172
1226
  const handlerUrl = function (url, before) {
1173
- var arry = url.split('?');
1227
+ let arry = url.split('?');
1174
1228
  if (arry.length > 2) {
1175
1229
  let ary = arry.splice(1, arry.length);
1176
1230
  arry.push(ary.join('?'));
1177
1231
  }
1178
1232
  if (arry.length > 1) {
1179
1233
  if (arry[1].indexOf('_tt') > -1) {
1180
- var search = arry[1].split('&');
1181
- for (var i in search) {
1234
+ let search = arry[1].split('&');
1235
+ for (let i in search) {
1182
1236
  if (search[i].indexOf('_tt') > -1) {
1183
1237
  search[i] = '_tt=' + new Date().getTime();
1184
1238
  }
@@ -1303,7 +1357,7 @@ const identical = function ({
1303
1357
  * @param {String} [key] - 目标对象的属性名
1304
1358
  **/
1305
1359
  const indexOfObj = function (arry, target, key) {
1306
- for (var i = 0; i < arry.length; i++) {
1360
+ for (let i = 0; i < arry.length; i++) {
1307
1361
  if (key) {
1308
1362
  if (typeof target === 'string' && arry[i][key] === target) {
1309
1363
  return i;
@@ -1372,10 +1426,23 @@ const isLogged = function ({
1372
1426
  } else {
1373
1427
  const token = getStorage('token') || getStorage('Authorization');
1374
1428
  if (
1375
- Object.prototype.hasOwnProperty.call(to.query, 'serverId') &&
1429
+ !token && Object.prototype.hasOwnProperty.call(to.query, 'serverId') &&
1376
1430
  Object.prototype.hasOwnProperty.call(to.query, 'authType')
1377
1431
  ) {
1378
- const url = win.top.location.href;
1432
+ let url = win.top.location.href;
1433
+ if (to.query.openType) {
1434
+ switch (to.query.openType) {
1435
+ case 'self':
1436
+ url = win.location.href;
1437
+ break;
1438
+ case 'blank':
1439
+ url = win.location.href;
1440
+ break;
1441
+ case 'parent':
1442
+ url = win.parent.location.href;
1443
+ break;
1444
+ }
1445
+ }
1379
1446
  ajax({
1380
1447
  method: 'post',
1381
1448
  url: authCenter,
@@ -1405,10 +1472,27 @@ const isLogged = function ({
1405
1472
  '{redirectUri}',
1406
1473
  encodeURIComponent(url)
1407
1474
  );
1408
- if (open) {
1409
- win.open(href);
1475
+ if (to.query.openType) {
1476
+ switch (to.query.openType) {
1477
+ case 'self':
1478
+ win.location.href = href;
1479
+ break;
1480
+ case 'blank':
1481
+ win.open(href);
1482
+ break;
1483
+ case 'top':
1484
+ win.top.location.href = href;
1485
+ break;
1486
+ case 'parent':
1487
+ win.parent.location.href = href;
1488
+ break;
1489
+ }
1410
1490
  } else {
1411
- win.top.location.href = href;
1491
+ if (open) {
1492
+ win.open(href);
1493
+ } else {
1494
+ win.top.location.href = href;
1495
+ }
1412
1496
  }
1413
1497
  break;
1414
1498
  }
@@ -1423,12 +1507,13 @@ const isLogged = function ({
1423
1507
  } else if (
1424
1508
  token ||
1425
1509
  to.path === '/' ||
1426
- to.path === '/login' ||
1427
1510
  to.path === '/404' ||
1428
- exclude.indexOf(to.path) > -1 || exclude.indexOf(to.name) > -1
1511
+ exclude.indexOf(to.path) > -1 || exclude.indexOf(to.name) > -1 ||
1512
+ to.path === '/login' ||
1513
+ (token && to.path === '/main')
1429
1514
  ) {
1430
- if (redirect && to.name && (to.name === 'login' || to.name === 'main')) {
1431
- window.location.replace(urlJoinParams({ url: `./${to.name}.html`, param: to.query }));
1515
+ if (redirect && (to.path === '/main' || to.path === '/login')) {
1516
+ window.location.replace(urlJoinParams({ url: `.${to.path}.html`, param: to.query }));
1432
1517
  } else {
1433
1518
  next();
1434
1519
  }
@@ -1593,7 +1678,7 @@ const mixColor = function ($color1, $color2, $n) {
1593
1678
  **/
1594
1679
  const overbrim = function (el) {
1595
1680
  let w = el.offsetWidth;
1596
- var s = el.scrollWidth;
1681
+ let s = el.scrollWidth;
1597
1682
  if (s > w) {
1598
1683
  return true;
1599
1684
  } else {
@@ -1749,7 +1834,7 @@ const sendMessage = function ({ data = {}, url }) {
1749
1834
  * @param {String} [url] - 图标地址
1750
1835
  **/
1751
1836
  const setFavicon = function (url) {
1752
- var link = document.querySelector("link[rel*='icon']");
1837
+ let link = document.querySelector("link[rel*='icon']");
1753
1838
  if (link) {
1754
1839
  link.href = url;
1755
1840
  } else {
@@ -1842,13 +1927,13 @@ const startWith = function (value, reg, or = false) {
1842
1927
  * @param {Number} [wait] - 延迟毫秒数
1843
1928
  **/
1844
1929
  const throttle = function (fn, wait) {
1845
- var timer = null;
1846
- var startTime = Date.now();
1930
+ let timer = null;
1931
+ let startTime = Date.now();
1847
1932
  return function () {
1848
- var curTime = Date.now();
1849
- var remaining = wait - (curTime - startTime);
1850
- var context = this;
1851
- var args = arguments;
1933
+ let curTime = Date.now();
1934
+ let remaining = wait - (curTime - startTime);
1935
+ let context = this;
1936
+ let args = arguments;
1852
1937
  clearTimeout(timer);
1853
1938
  if (remaining <= 0) {
1854
1939
  fn.apply(context, args);
@@ -2037,9 +2122,9 @@ const watermark = function (option) {
2037
2122
  let { rows, cols, html, angle, color, height, lineHeight, opacity, fontSize, fontWeight, fontFamily, textAlign, zIndex } = options;
2038
2123
 
2039
2124
  wrap.style.cssText = 'display: flex;align-items: center;justify-content: flex-start;flex-wrap: wrap;align-content: space-between;position: fixed;left: 50%;top: 50%;transform: translate(-50%, -50%);height: 100vh;width: 100vw;pointer-events: none;overflow: hidden;background: transparent;z-index: ' + zIndex + ';';
2040
- var num = rows * cols;
2041
- for (var i = 0; i < num; i++) {
2042
- var item = document.createElement('div');
2125
+ let num = rows * cols;
2126
+ for (let i = 0; i < num; i++) {
2127
+ let item = document.createElement('div');
2043
2128
  item.innerHTML = html;
2044
2129
  item.style.cssText = 'flex-grow: 1;flex-shrink: 0;color: ' + color + ';text-align: ' + textAlign + ';width: ' + (100 / cols) + '%;height: ' + height + 'px;line-height: ' + lineHeight + 'px;font-size:' + fontSize + 'px;font-weight: ' + fontWeight + ';font-family: ' + fontFamily + ';text-align: ' + textAlign + ';transform: rotate(' + angle + 'deg);opacity: ' + opacity + ';';
2045
2130
  docFrag.appendChild(item);