UNPKG

6.47 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.Row = undefined;
7
8var _indexEvents = require('./indexEvents');
9
10var _rowData = require('./row-data');
11
12var _rowGetData = require('./row-getData');
13
14var _rowGetMeta = require('./row-getMeta');
15
16var _rowGetSimpleData = require('./row-getSimpleData');
17
18var _rowInit = require('./row-init');
19
20var _rowMeta = require('./row-meta');
21
22var _rowRef = require('./row-ref');
23
24var _rowRowSelect = require('./row-rowSelect');
25
26var _rowSimpleData = require('./row-simpleData');
27
28var _rowUtil = require('./row-util');
29
30function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
32function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
33
34function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
35 * Module : Kero webpack entry row index
36 * Author : liuyk(liuyuekai@yonyou.com)
37 * Date : 2016-08-09 15:24:46
38 */
39
40var Row = function (_Events) {
41 _inherits(Row, _Events);
42
43 function Row(options) {
44 _classCallCheck(this, Row);
45
46 var _this = _possibleConstructorReturn(this, (Row.__proto__ || Object.getPrototypeOf(Row)).call(this));
47
48 var self = _this;
49 _this.rowId = options['id'] || Row.getRandomRowId();
50 _this.status = Row.STATUS.NEW;
51 _this.parent = options['parent'];
52 _this.initValue = null;
53 _this.data = {};
54 _this.metaChange = {}; //ko.observable(1)
55 _this.valueChange = {};
56 _this.currentRowChange = ko.observable(1);
57 _this.selected = ko.pureComputed({
58 read: function read() {
59 var index = this.parent.getRowIndex(this);
60 var selectindices = this.parent.getSelectedIndices();
61 return selectindices.indexOf(index) != -1;
62 },
63 owner: _this
64
65 });
66 _this.focused = ko.pureComputed({
67 read: function read() {
68 var index = this.parent.getRowIndex(this);
69 var focusIndex = this.parent.getFocusIndex();
70 return focusIndex == index;
71 },
72 owner: _this
73
74 });
75
76 _this.init();
77 return _this;
78 }
79
80 return Row;
81}(_indexEvents.Events);
82
83//data
84
85
86Row.prototype.setValue = _rowData.setValue;
87Row.prototype.setChildValue = _rowData.setChildValue;
88Row.prototype.setChildSimpleDataByRowId = _rowData.setChildSimpleDataByRowId;
89Row.prototype.setData = _rowData.setData;
90Row.prototype.updateRow = _rowData.updateRow;
91
92//getData
93Row.prototype.getValue = _rowGetData.getValue;
94Row.prototype.getChildValue = _rowGetData.getChildValue;
95Row.prototype.getData = _rowGetData.getData;
96Row.prototype.getEmptyData = _rowGetData.getEmptyData;
97
98//getMeta
99Row.prototype.getMeta = _rowGetMeta.getMeta;
100
101//getSimpleData
102Row.prototype.formatValueFun = _rowGetSimpleData.formatValueFun;
103Row.prototype.getSimpleData = _rowGetSimpleData.getSimpleData;
104
105//init
106Row.prototype.init = _rowInit.init;
107
108//meta
109Row.prototype.setMeta = _rowMeta.setMeta;
110
111//ref
112Row.prototype.ref = _rowRef.ref;
113Row.prototype.refMeta = _rowRef.refMeta;
114Row.prototype.refCombo = _rowRef.refCombo;
115Row.prototype.refDate = _rowRef.refDate;
116Row.prototype.refEnum = _rowRef.refEnum;
117
118//rowSelect
119Row.prototype.toggleSelect = _rowRowSelect.toggleSelect;
120Row.prototype.singleSelect = _rowRowSelect.singleSelect;
121Row.prototype.multiSelect = _rowRowSelect.multiSelect;
122
123//simpleData
124Row.prototype.setSimpleData = _rowSimpleData.setSimpleData;
125
126//util
127Row.prototype.formatValue = _rowUtil.formatValue;
128
129Row.STATUS = {
130 NORMAL: 'nrm',
131 UPDATE: 'upd',
132 NEW: 'new',
133 DELETE: 'del',
134 FALSE_DELETE: 'fdel'
135};
136
137/*
138 * 生成随机行id
139 * @private
140 */
141Row.getRandomRowId = function () {
142 var _id = setTimeout(function () {});
143 return _id + '';
144};
145
146exports.Row = Row;
\No newline at end of file