kero
Version:
<img src="http://tinper.org/assets/images/kero.png" width="120" style="max-width:100%;"/>
128 lines (105 loc) • 3.74 kB
JavaScript
/**
* Module : Kero webpack entry row index
* Author : liuyk(liuyuekai@yonyou.com)
* Date : 2016-08-09 15:24:46
*/
import { Events } from './indexEvents';
import { rowDataFunObj } from './row-data';
import { rowGetDataFunObj } from './row-getData';
import { rowGetMetaFunObj } from './row-getMeta';
import { rowGetSimpleDataFunObj } from './row-getSimpleData';
import { rowInitFunObj } from './row-init';
import { rowMetaFunObj } from './row-meta';
import { rowRefFunObj } from './row-ref';
import { rowRowSelectFunObj } from './row-rowSelect';
import { rowSimpleDataFunObj } from './row-simpleData';
import { rowUtilFunObj } from './row-util';
/**
* Row
* @namespace
* @description 前端数据模型行对象
*/
var Row = function (_Events) {
babelHelpers.inherits(Row, _Events);
function Row(options) {
babelHelpers.classCallCheck(this, Row);
var _this = babelHelpers.possibleConstructorReturn(this, (Row.__proto__ || Object.getPrototypeOf(Row)).call(this));
var self = _this;
/**
* 当前行的唯一标识
* @type {string}
*/
_this.rowId = options['id'] || Row.getRandomRowId();
/**
* 当前行的状态
* Row.STATUS.NORMAL('nrm') :前后端都存在并且保持一致
* Row.STATUS.UPDATE('upd') :前后端都存在并且前端进行了修改
* Row.STATUS.NEW('new') :后端不存在,前端存在的数据
* Row.STATUS.DELETE('del') :后端请求返回的状态,前端判断为此状态则将数据删除
* Row.STATUS.FALSE_DELETE('fdel') :后端存在,前端不存在的数据
* @type {string}
* @default Row.STATUS.NEW
*/
_this.status = Row.STATUS.NEW;
/**
* 当前行对应的DataTable对象
* @type {u.DataTable}
*/
_this.parent = options['parent'];
// 当前行的数据信息
_this.data = {};
// 存储meta改变信息
_this.metaChange = {}; //ko.observable(1)
// 存储valuecahnge改变信息
_this.valueChange = {};
// 监听当前行改变
_this.currentRowChange = ko.observable(1);
// 监听当前行是否选中
_this.selected = ko.pureComputed({
read: function read() {
var index = this.parent.getRowIndex(this);
var selectindices = this.parent.getSelectedIndices();
return selectindices.indexOf(index) != -1;
},
owner: _this
});
// 监听当前行是否为focus
_this.focused = ko.pureComputed({
read: function read() {
var index = this.parent.getRowIndex(this);
var focusIndex = this.parent.getFocusIndex();
return focusIndex == index;
},
owner: _this
});
_this.init();
return _this;
}
return Row;
}(Events);
var RowProto = Row.prototype;
Object.assign(RowProto, rowDataFunObj);
Object.assign(RowProto, rowGetDataFunObj);
Object.assign(RowProto, rowGetMetaFunObj);
Object.assign(RowProto, rowGetSimpleDataFunObj);
Object.assign(RowProto, rowInitFunObj);
Object.assign(RowProto, rowMetaFunObj);
Object.assign(RowProto, rowRefFunObj);
Object.assign(RowProto, rowRowSelectFunObj);
Object.assign(RowProto, rowSimpleDataFunObj);
Object.assign(RowProto, rowUtilFunObj);
Row.STATUS = {
NORMAL: 'nrm',
UPDATE: 'upd',
NEW: 'new',
DELETE: 'del',
FALSE_DELETE: 'fdel'
/*
* 生成随机行id
* @private
*/
};Row.getRandomRowId = function () {
var _id = setTimeout(function () {});
return _id + '';
};
export { Row };