efront 4.0.51 → 4.0.54

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.
@@ -371,28 +371,23 @@ var getTdsOfSameRow = function (td) {
371
371
  return tds;
372
372
  };
373
373
  function setContextMenu(thead) {
374
- var fields = this.fields.slice();
375
- var scope = this;
376
- var menuItems = fields.map(f => {
377
- return {
378
- name: f.name || " ",
379
- checked: !f.hidden,
380
- width: f.width,
381
- do() {
382
- this.checked = !this.checked;
383
- f.hidden = !this.checked;
384
- scope.fields = fields.filter(f => !f.hidden);
385
- var width = thead.scrollWidth / scope.fields.length;
386
- if (!width || width < 200) width = 200;
387
- forEachRow(thead, function (tr) {
388
- for (var td of tr.children) {
389
- if (td.offsetWidth > width) css(td, { width });
390
- }
391
- });
392
- setLazyFixedColumn.call(thead.parentNode, true)
374
+ var fields = this.originFields.slice();
375
+ var _do = function () {
376
+ this.checked = !this.checked;
377
+ var f = fields[this.index];
378
+ f.hidden = !this.checked;
379
+ scope.fields = fields.filter(f => !f.hidden);
380
+ var width = thead.scrollWidth / scope.fields.length;
381
+ if (!width || width < 200) width = 200;
382
+ forEachRow(thead, function (tr) {
383
+ for (var td of tr.children) {
384
+ if (td.offsetWidth > width) css(td, { width });
393
385
  }
394
- }
395
- });
386
+ });
387
+ setLazyFixedColumn.call(thead.parentNode, true)
388
+ };
389
+ var menuItems = fields.map((f, i) => ({ name: f.name || "&nbsp", index: i, width: f.width, key: f.key, checked: !f.hidden, do: _do }));
390
+ var scope = this;
396
391
  contextmenu(thead, menuItems);
397
392
  }
398
393
  function table(elem) {
@@ -468,11 +463,19 @@ function table(elem) {
468
463
  };
469
464
  vbox(table, 'x');
470
465
  };
471
- care(table, async function ([fields, data]) {
466
+ care(table, async function (src) {
467
+ if (src instanceof Table) {
468
+ data = src;
469
+ fields = data.fields;
470
+ }
471
+ else if (src instanceof Array) {
472
+ var [fields, data] = src;
473
+ }
474
+ else throw new Error("table组件源数据错误!");
472
475
  if (_vbox) _vbox(), _vbox = null;
473
476
  watch(table, {
474
477
  find(text) {
475
- if ($scope.data.constructor === Table){
478
+ if ($scope.data.constructor === Table) {
476
479
  $scope.data.searchText = text;
477
480
  $scope.data.update();
478
481
  }
@@ -485,7 +488,8 @@ function table(elem) {
485
488
  markedRows = false;
486
489
  this.style.display = 'block';
487
490
  var $scope = {
488
- fields,
491
+ originFields: fields,
492
+ fields: fields.filter(f => !f.hidden),
489
493
  isEmpty,
490
494
  hasFoot: true,
491
495
  setContextMenu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.0.51",
3
+ "version": "4.0.54",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {