1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import {
|
8 | Events
|
9 | } from './indexEvents';
|
10 |
|
11 |
|
12 | import {
|
13 | setValue,
|
14 | setChildValue,
|
15 | setChildSimpleDataByRowId,
|
16 | setData,
|
17 | updateRow
|
18 | } from './row-data';
|
19 |
|
20 | import {
|
21 | getValue,
|
22 | getChildValue,
|
23 | getData,
|
24 | getEmptyData
|
25 | } from './row-getData';
|
26 |
|
27 | import {
|
28 | getMeta
|
29 | } from './row-getMeta';
|
30 |
|
31 | import {
|
32 | formatValueFun,
|
33 | getSimpleData
|
34 | } from './row-getSimpleData';
|
35 |
|
36 | import {
|
37 | init
|
38 | } from './row-init';
|
39 |
|
40 | import {
|
41 | setMeta
|
42 | } from './row-meta';
|
43 |
|
44 | import {
|
45 | ref,
|
46 | refMeta,
|
47 | refCombo,
|
48 | refDate,
|
49 | refEnum
|
50 | } from './row-ref';
|
51 |
|
52 | import{
|
53 | toggleSelect,
|
54 | singleSelect,
|
55 | multiSelect
|
56 | } from './row-rowSelect';
|
57 |
|
58 | import {
|
59 | setSimpleData
|
60 | } from './row-simpleData';
|
61 |
|
62 | import {
|
63 | formatValue,
|
64 | } from './row-util';
|
65 |
|
66 |
|
67 | class Row extends Events{
|
68 | constructor(options){
|
69 | super();
|
70 | var self = this;
|
71 | this.rowId = options['id'] || Row.getRandomRowId()
|
72 | this.status = Row.STATUS.NEW
|
73 | this.parent = options['parent']
|
74 | this.initValue = null
|
75 | this.data = {}
|
76 | this.metaChange = {}
|
77 | this.valueChange = {};
|
78 | this.currentRowChange = ko.observable(1);
|
79 | this.selected = ko.pureComputed({
|
80 | read: function () {
|
81 | var index = this.parent.getRowIndex(this);
|
82 | var selectindices = this.parent.getSelectedIndices();
|
83 | return selectindices.indexOf(index) != -1;
|
84 | },
|
85 | owner: this
|
86 |
|
87 | })
|
88 | this.focused = ko.pureComputed({
|
89 | read: function () {
|
90 | var index = this.parent.getRowIndex(this);
|
91 | var focusIndex = this.parent.getFocusIndex()
|
92 | return focusIndex == index;
|
93 | },
|
94 | owner: this
|
95 |
|
96 | })
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | this.init();
|
103 | }
|
104 | }
|
105 |
|
106 |
|
107 | Row.prototype.setValue= setValue;
|
108 | Row.prototype.setChildValue= setChildValue;
|
109 | Row.prototype.setChildSimpleDataByRowId= setChildSimpleDataByRowId;
|
110 | Row.prototype.setData= setData;
|
111 | Row.prototype.updateRow= updateRow;
|
112 |
|
113 |
|
114 | Row.prototype.getValue= getValue;
|
115 | Row.prototype.getChildValue= getChildValue;
|
116 | Row.prototype.getData= getData;
|
117 | Row.prototype.getEmptyData= getEmptyData;
|
118 |
|
119 |
|
120 | Row.prototype.getMeta= getMeta;
|
121 |
|
122 |
|
123 | Row.prototype.formatValueFun= formatValueFun;
|
124 | Row.prototype.getSimpleData= getSimpleData;
|
125 |
|
126 |
|
127 | Row.prototype.init= init;
|
128 |
|
129 |
|
130 | Row.prototype.setMeta= setMeta;
|
131 |
|
132 |
|
133 | Row.prototype.ref= ref;
|
134 | Row.prototype.refMeta= refMeta;
|
135 | Row.prototype.refCombo= refCombo;
|
136 | Row.prototype.refDate= refDate;
|
137 | Row.prototype.refEnum= refEnum;
|
138 |
|
139 |
|
140 | Row.prototype.toggleSelect= toggleSelect;
|
141 | Row.prototype.singleSelect= singleSelect;
|
142 | Row.prototype.multiSelect= multiSelect;
|
143 |
|
144 |
|
145 | Row.prototype.setSimpleData= setSimpleData;
|
146 |
|
147 |
|
148 | Row.prototype.formatValue= formatValue;
|
149 |
|
150 |
|
151 |
|
152 | Row.STATUS = {
|
153 | NORMAL: 'nrm',
|
154 | UPDATE: 'upd',
|
155 | NEW: 'new',
|
156 | DELETE: 'del',
|
157 | FALSE_DELETE: 'fdel'
|
158 | }
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | Row.getRandomRowId = function () {
|
165 | var _id = setTimeout(function () {})
|
166 | return _id + '';
|
167 | };
|
168 |
|
169 |
|
170 |
|
171 | export {
|
172 | Row
|
173 | }
|