Skip to content

Commit

Permalink
编译打包
Browse files Browse the repository at this point in the history
  • Loading branch information
黄书伟 committed Oct 24, 2017
1 parent 59a1f01 commit d50cab3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
28 changes: 19 additions & 9 deletions libs/v-table/src/cell-edit-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,39 @@ exports.default = {
editInputLen = void 0,
_actionFun = void 0,
textAlign = void 0,
formatterVal = '';
childTarget = void 0;

while (target.className && target.className.indexOf('v-table-body-cell') === -1 || !target.className) {
target = target.parentNode;
}

childTarget = target.children[0];

childTarget.style.display = 'none';

if ((0, _dom.hasClass)(target, 'cell-editing')) {
return false;
}

(0, _dom.addClass)(target, 'cell-editing');

oldVal = target.innerText;
oldVal = childTarget.innerText.trim();

if (target.style.textAlign) {

textAlign = target.style.textAlign;
}

target.innerHTML = '<input type=\'text\' value="' + oldVal + '" class=\'cell-edit-input\' style=\'width:100%;height: 100%;text-align: ' + textAlign + ';\'>';
editInput = document.createElement('input');
editInput.value = oldVal;
editInput.className = 'cell-edit-input';
editInput.style.textAlign = textAlign;
editInput.style.width = '100%';
editInput.style.height = '100%';


target.appendChild(editInput);

editInput = target.querySelector('.cell-edit-input');
editInput.focus();

editInputLen = editInput.value.length;
Expand All @@ -69,29 +80,28 @@ exports.default = {
return false;
}

formatterVal = self.cellEditFormatter && self.cellEditFormatter(editInput.value, oldVal, rowIndex, rowData, field);

target.innerHTML = formatterVal && formatterVal.length > 0 ? formatterVal : editInput.value;
childTarget.style.display = '';

callback(editInput.value, oldVal);

_utils2.default.unbind(editInput, 'blur', _actionFun);
_utils2.default.unbind(editInput, 'keydown', _actionFun);

target.removeChild(editInput);
}
};

_utils2.default.bind(editInput, 'blur', _actionFun);
_utils2.default.bind(editInput, 'keydown', _actionFun);
},
cellEditClick: function cellEditClick(e, isEdit, rowData, field, rowIndex) {

if (isEdit) {

var self = this;

var onCellEditCallBack = function onCellEditCallBack(newValue, oldVal) {

self.cellEditDone(newValue, oldVal, rowIndex, rowData, field);
self.cellEditDone && self.cellEditDone(newValue, oldVal, rowIndex, rowData, field);
};

this.cellEdit(e, onCellEditCallBack, rowIndex, rowData, field);
Expand Down
8 changes: 6 additions & 2 deletions libs/v-table/src/drag-width-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ var _utils = require('../../src/utils/utils.js');

var _utils2 = _interopRequireDefault(_utils);

var _dom = require('../../src/utils/dom.js');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = {
Expand Down Expand Up @@ -47,7 +49,7 @@ exports.default = {

target = event.target;

while (target && (target.className && target.className.indexOf('v-table-title-cell') === -1 || !target.className)) {
while (target && (target.className && !(0, _dom.hasClass)(target, 'v-table-title-cell') || !target.className)) {
target = target.parentNode;
}

Expand Down Expand Up @@ -149,14 +151,16 @@ exports.default = {
if (this.totalColumnsWidth < this.internalWidth) {

rightViewBody.style.overflowX = 'hidden';

(0, _dom.removeClass)(rightViewBody, 'v-table-rightview-special-border');
rightViewBody.classList.remove('v-table-rightview-special-border');
} else {

rightViewBody.style.overflowX = 'scroll';

if (!this.hasFrozenColumn) {

rightViewBody.classList.add('v-table-rightview-special-border');
(0, _dom.addClass)(rightViewBody, 'v-table-rightview-special-border');
}
}

Expand Down
27 changes: 15 additions & 12 deletions libs/v-table/src/table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,6 @@
rowMouseLeave: Function,
// 单元格编辑完成回调
cellEditDone: Function,
// 单元格编辑格式化
cellEditFormatter: Function,
// 单元格合并
cellMerge: Function,
// select all
Expand Down Expand Up @@ -809,24 +807,29 @@
this.initColumns();
},
'tableData': function (newVal) {
// deep watch
'tableData': {
this.internalTableData = this.initInternalTableData(newVal);
handler:function (newVal) {
this.updateCheckboxGroupModel();
this.internalTableData = this.initInternalTableData(newVal);
this.tableEmpty();
this.updateCheckboxGroupModel();
if (Array.isArray(newVal) && newVal.length > 0) {
this.tableEmpty();
this.initView();
if (Array.isArray(newVal) && newVal.length > 0) {
if (!this.hasBindScrollEvent) {
this.scrollControl();
this.initView();
if (!this.hasBindScrollEvent) {
this.scrollControl();
}
}
}
this.resize();
this.resize();
},
deep: true
}
}
}
Expand Down

0 comments on commit d50cab3

Please sign in to comment.