hqchart 1.1.12733 → 1.1.12741
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.
- package/package.json +1 -1
- package/src/jscommon/jschinamapdata.js +3 -0
- package/src/jscommon/umychart.NetworkFilterTest.js +48803 -0
- package/src/jscommon/umychart.aliYunnetwork.js +47 -0
- package/src/jscommon/umychart.complier.js +25402 -0
- package/src/jscommon/umychart.console.js +12 -0
- package/src/jscommon/umychart.deal.js +1452 -0
- package/src/jscommon/umychart.dragdiv.js +48 -0
- package/src/jscommon/umychart.index.data.js +4132 -0
- package/src/jscommon/umychart.js +90801 -0
- package/src/jscommon/umychart.keyboard.js +1659 -0
- package/src/jscommon/umychart.listctrl.js +690 -0
- package/src/jscommon/umychart.mind.js +2203 -0
- package/src/jscommon/umychart.network.js +44 -0
- package/src/jscommon/umychart.news.js +823 -0
- package/src/jscommon/umychart.regressiontest.js +400 -0
- package/src/jscommon/umychart.report.js +5803 -0
- package/src/jscommon/umychart.scrollbar.js +1345 -0
- package/src/jscommon/umychart.stock.js +4218 -0
- package/src/jscommon/umychart.style.js +625 -0
- package/src/jscommon/umychart.testdata.js +150 -0
- package/src/jscommon/umychart.uniapp.h5/umychart.uniapp.h5.js +237 -35
- package/src/jscommon/umychart.user.js +137 -0
- package/src/jscommon/umychart.version.js +30 -0
- package/src/jscommon/umychart.vue/umychart.vue.js +237 -35
- package/src/jscommon/umychart.worker.js +114 -0
- package/src/jscommon/umychart.ws.stock.js +110 -0
- package/src/jscommon/vendor.js +2 -0
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2018 jones
|
|
3
|
+
|
|
4
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
|
|
6
|
+
开源项目 https://github.com/jones2000/HQChart
|
|
7
|
+
|
|
8
|
+
jones_2000@163.com
|
|
9
|
+
|
|
10
|
+
股票列表 (H5版本)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
//单元个类型
|
|
14
|
+
var CELL_TYPE_ID=
|
|
15
|
+
{
|
|
16
|
+
CELL_NONE_ID:0,
|
|
17
|
+
CELL_INTEGER_ID:1, //整型
|
|
18
|
+
CELL_STRING_ID:2,
|
|
19
|
+
CELL_STOCK_NAME_ID:3, //股票名称
|
|
20
|
+
CELL_STOCK_CODE_ID:4, //股票代码
|
|
21
|
+
CELL_STOCK_PRICE_ID:5, //价格字段
|
|
22
|
+
CELL_PERCENTAGE_ID:6, //百分比
|
|
23
|
+
CELL_BIG_NUMBER_ID:7, //大数值数据
|
|
24
|
+
CELL_DOUBLE_ID:8, //浮点型
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//表头单元类型
|
|
28
|
+
var HEAD_CELL_TYPE_ID=
|
|
29
|
+
{
|
|
30
|
+
CELL_STRING_ID:2, //字符串
|
|
31
|
+
CELL_SELECT_ID:5 //下拉选择框
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
//行数据
|
|
36
|
+
function JsCellItem()
|
|
37
|
+
{
|
|
38
|
+
this.Type=CELL_TYPE_ID.CELL_STRING_ID; //0=数值 1=字符串
|
|
39
|
+
this.Value=null; //原始数值
|
|
40
|
+
this.Text=''; //显示文本
|
|
41
|
+
this.CSS; //对应css样式的名字
|
|
42
|
+
this.Element; //td
|
|
43
|
+
this.UpdateStatus={ Value:false, CSS:false }; //是否需要更新
|
|
44
|
+
this.Index;
|
|
45
|
+
|
|
46
|
+
this.Build=function(index, trElement)
|
|
47
|
+
{
|
|
48
|
+
this.Index=index;
|
|
49
|
+
if (index<trElement.cells.length)
|
|
50
|
+
{
|
|
51
|
+
if (this.Element!=trElement.cells[index])
|
|
52
|
+
{
|
|
53
|
+
this.Element=trElement.cells[index];
|
|
54
|
+
this.UpdateStatus={ Value:true, CSS:true };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
{
|
|
59
|
+
this.Element=trElement.insertCell(index);
|
|
60
|
+
this.UpdateStatus={ Value:true, CSS:true };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.Update();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.Update=function()
|
|
67
|
+
{
|
|
68
|
+
if (!this.Element) return;
|
|
69
|
+
|
|
70
|
+
if (this.UpdateStatus.Value==true) this.Element.innerHTML=this.Text;
|
|
71
|
+
if (this.UpdateStatus.CSS==true) this.Element.className=this.CSS;
|
|
72
|
+
|
|
73
|
+
this.UpdateStatus.Value=false;
|
|
74
|
+
this.UpdateStatus.CSS=false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
this.SetValue=function(value, option) //option: { Type:单元个类型}
|
|
79
|
+
{
|
|
80
|
+
if (!option || !option.Type) this.SetStringValue(value.toString());
|
|
81
|
+
|
|
82
|
+
switch(option.Type)
|
|
83
|
+
{
|
|
84
|
+
case CELL_TYPE_ID.CELL_STOCK_NAME_ID:
|
|
85
|
+
case CELL_TYPE_ID.CELL_STOCK_CODE_ID:
|
|
86
|
+
this.SetStringValue(value,option);
|
|
87
|
+
break;
|
|
88
|
+
case CELL_TYPE_ID.CELL_STOCK_PRICE_ID:
|
|
89
|
+
this.SetPriceValue(value,option);
|
|
90
|
+
break;
|
|
91
|
+
case CELL_TYPE_ID.CELL_PERCENTAGE_ID:
|
|
92
|
+
this.SetPercentageValue(value,option);
|
|
93
|
+
break;
|
|
94
|
+
case CELL_TYPE_ID.CELL_BIG_NUMBER_ID:
|
|
95
|
+
this.SetBigNumberValue(value,option);
|
|
96
|
+
break;
|
|
97
|
+
case CELL_TYPE_ID.CELL_NONE_ID:
|
|
98
|
+
this.SetNoneValue(value,option);
|
|
99
|
+
break;
|
|
100
|
+
case CELL_TYPE_ID.CELL_DOUBLE_ID:
|
|
101
|
+
this.SetDoubleValue(value,option)
|
|
102
|
+
break;
|
|
103
|
+
case CELL_TYPE_ID.CELL_INTEGER_ID:
|
|
104
|
+
this.SetIntegerValue(value,option);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.ChangeType=function(option)
|
|
110
|
+
{
|
|
111
|
+
if (!opton) return;
|
|
112
|
+
|
|
113
|
+
var value=this.Value; //先读取值
|
|
114
|
+
this.SetValue(value,option);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.SetPercentageValue=function(value, option)
|
|
118
|
+
{
|
|
119
|
+
this.Value=value;
|
|
120
|
+
if (JSTableHelper.IsNumber(value)) this.SetText(value.toFixed(option.Dec)+'%');
|
|
121
|
+
else this.SetText(option.NullText);
|
|
122
|
+
|
|
123
|
+
if (value>option.CompareValue) this.SetCSS(option.CSS[0]);
|
|
124
|
+
else if (value<option.CompareValue) this.SetCSS(option.CSS[1]);
|
|
125
|
+
else this.SetCSS(option.CSS[2]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.SetPriceValue=function(value, option)
|
|
129
|
+
{
|
|
130
|
+
if (value==this.Value) return;
|
|
131
|
+
|
|
132
|
+
this.Value=value;
|
|
133
|
+
if (!JSTableHelper.IsNumber(value)) this.SetText(option.NullText);
|
|
134
|
+
else this.SetText(value.toFixed(option.Dec));
|
|
135
|
+
|
|
136
|
+
if (value>option.CompareValue) this.SetCSS(option.CSS[0]);
|
|
137
|
+
else if (value<option.CompareValue) this.SetCSS(option.CSS[1]);
|
|
138
|
+
else this.SetCSS(option.CSS[2]);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.SetBigNumberValue=function(value, option)
|
|
142
|
+
{
|
|
143
|
+
this.Value=value;
|
|
144
|
+
this.SetText(JSTableHelper.FormatValueString(value,option.Dec[0],option.Dec[1]));
|
|
145
|
+
this.UpdateStatus.Value=true;
|
|
146
|
+
|
|
147
|
+
this.SetOption(option);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this.SetDoubleValue=function(value, option)
|
|
151
|
+
{
|
|
152
|
+
this.Type=CELL_TYPE_ID.CELL_DOUBLE_ID;
|
|
153
|
+
this.Value=value;
|
|
154
|
+
if (JSTableHelper.IsNumber(value)) this.SetText(value.toFixed(opton.Dec)); //TO:格式化类
|
|
155
|
+
else this.SetText(option.NullText);
|
|
156
|
+
this.UpdateStatus.Value=true;
|
|
157
|
+
|
|
158
|
+
this.SetOption(option);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.SetIntegerValue=function(value,option)
|
|
162
|
+
{
|
|
163
|
+
this.Type=CELL_TYPE_ID.CELL_INTEGER_ID;
|
|
164
|
+
this.Value=value;
|
|
165
|
+
if (JSTableHelper.IsNumber(value)) this.SetText(parseInt(value).toString()); //TO:格式化类
|
|
166
|
+
else this.SetText(option.NullText);
|
|
167
|
+
|
|
168
|
+
this.SetOption(option);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.SetNoneValue=function(value,option)
|
|
172
|
+
{
|
|
173
|
+
this.Type=CELL_TYPE_ID.CELL_NONE_ID;
|
|
174
|
+
this.Value=value;
|
|
175
|
+
this.SetText(opton.NullText);
|
|
176
|
+
|
|
177
|
+
this.SetOption(option);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.SetStringValue=function(value, option)
|
|
181
|
+
{
|
|
182
|
+
this.Type=CELL_TYPE_ID.CELL_STRING_ID;
|
|
183
|
+
this.Value=value;
|
|
184
|
+
this.SetText(value);
|
|
185
|
+
|
|
186
|
+
this.SetOption(option);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
this.SetCSS=function(css)
|
|
191
|
+
{
|
|
192
|
+
if (!css) return;
|
|
193
|
+
|
|
194
|
+
if (css!=this.CSS)
|
|
195
|
+
{
|
|
196
|
+
this.CSS=css;
|
|
197
|
+
this.UpdateStatus.CSS=true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
this.SetType=function(type)
|
|
202
|
+
{
|
|
203
|
+
if (JSTableHelper.IsNumber(type)) this.Type=type;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this.SetText=function(text)
|
|
207
|
+
{
|
|
208
|
+
if (this.Text!=text)
|
|
209
|
+
{
|
|
210
|
+
this.Text=text;
|
|
211
|
+
this.UpdateStatus.Value=true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
this.SetOption=function(option)
|
|
216
|
+
{
|
|
217
|
+
if (!option) return;
|
|
218
|
+
|
|
219
|
+
this.SetCSS(option.CSS);
|
|
220
|
+
this.SetType(option.Type);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
JsCellItem.GetCellRule=function(type)
|
|
225
|
+
{
|
|
226
|
+
const CELL_RULE_MAP=new Map
|
|
227
|
+
([
|
|
228
|
+
[CELL_TYPE_ID.CELL_STOCK_NAME_ID, {Type:CELL_TYPE_ID.CELL_STOCK_NAME_ID, CSS:'jscell-stock-name'} ],
|
|
229
|
+
[CELL_TYPE_ID.CELL_STOCK_CODE_ID, {Type:CELL_TYPE_ID.CELL_STOCK_CODE_ID, CSS:'jscell-stock-code'} ],
|
|
230
|
+
[CELL_TYPE_ID.CELL_NONE_ID, {Type:CELL_TYPE_ID.CELL_NONE_ID, CSS:'jscell-none', NullText:''}],
|
|
231
|
+
|
|
232
|
+
[CELL_TYPE_ID.CELL_PERCENTAGE_ID,
|
|
233
|
+
{
|
|
234
|
+
Type:CELL_TYPE_ID.CELL_PERCENTAGE_ID,
|
|
235
|
+
CSS:["jscell-value-up","jscell-value-down","jscell-value-unchanged"],
|
|
236
|
+
CompareValue:0, //对比值
|
|
237
|
+
Dec:2, //小数位数
|
|
238
|
+
NullText:'--'
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
|
|
242
|
+
[CELL_TYPE_ID.CELL_STOCK_PRICE_ID,
|
|
243
|
+
{
|
|
244
|
+
Type:CELL_TYPE_ID.CELL_PERCENTAGE_ID,
|
|
245
|
+
CSS:["jscell-value-up","jscell-value-down","jscell-value-unchanged"],
|
|
246
|
+
CompareValue:0, //填前收盘价
|
|
247
|
+
Dec:2, //小数位数,
|
|
248
|
+
NullText:'--'
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
|
|
252
|
+
[CELL_TYPE_ID.CELL_BIG_NUMBER_ID, { Type:CELL_TYPE_ID.CELL_BIG_NUMBER_ID, CSS:'jscell-big-number', Dec:[2,2] }],
|
|
253
|
+
[CELL_TYPE_ID.CELL_INTEGER_ID, { Type:CELL_TYPE_ID.CELL_INTEGER_ID, CSS:'jscell-number', NullText:'--' }],
|
|
254
|
+
[CELL_TYPE_ID.CELL_DOUBLE_ID, { Type:CELL_TYPE_ID.CELL_DOUBLE_ID, CSS:'jscell-number', NullText:'--' }]
|
|
255
|
+
]);
|
|
256
|
+
|
|
257
|
+
if (CELL_RULE_MAP.has(type)) return CELL_RULE_MAP.get(type);
|
|
258
|
+
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function JsRowItem()
|
|
263
|
+
{
|
|
264
|
+
this.Cells=[];
|
|
265
|
+
this.Index;
|
|
266
|
+
this.Element; //tr
|
|
267
|
+
this.Key; //主键 修改使用
|
|
268
|
+
|
|
269
|
+
this.SetCell=function(index, value, option)
|
|
270
|
+
{
|
|
271
|
+
var cell=new JsCellItem();
|
|
272
|
+
cell.SetValue(value, option);
|
|
273
|
+
this.Cells[index]=cell;
|
|
274
|
+
return cell;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
this.InsertCell=function(index, value, option)
|
|
278
|
+
{
|
|
279
|
+
var cell=new JsCellItem();
|
|
280
|
+
cell.SetValue(value, option);
|
|
281
|
+
this.Cells.splice(index,0,cell);
|
|
282
|
+
return cell;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.RemoveCell=function(index)
|
|
286
|
+
{
|
|
287
|
+
var cell=this.Cells.splice(index,1);
|
|
288
|
+
return cell;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
this.Build=function(index, bodyElement)
|
|
292
|
+
{
|
|
293
|
+
this.Index=index;
|
|
294
|
+
if (index<bodyElement.rows.length)
|
|
295
|
+
this.Element=bodyElement.rows[index];
|
|
296
|
+
else
|
|
297
|
+
this.Element=bodyElement.insertRow(index);
|
|
298
|
+
|
|
299
|
+
for(var i in this.Cells)
|
|
300
|
+
{
|
|
301
|
+
var cellItem=this.Cells[i];
|
|
302
|
+
cellItem.Build(i, this.Element);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
var cellCount=this.Cells.length;
|
|
306
|
+
while(cellCount<this.Element.cells.length)
|
|
307
|
+
{
|
|
308
|
+
this.Element.deleteCell(-1);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
this.Update=function()
|
|
313
|
+
{
|
|
314
|
+
if (!this.Element) return;
|
|
315
|
+
|
|
316
|
+
for(var i in this.Cells)
|
|
317
|
+
{
|
|
318
|
+
var cellItem=this.Cells[i];
|
|
319
|
+
cellItem.Update();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function JsHeadCellItem()
|
|
325
|
+
{
|
|
326
|
+
this.CSS; //对应css样式的名字
|
|
327
|
+
this.Element;
|
|
328
|
+
this.Text;
|
|
329
|
+
this.Index;
|
|
330
|
+
this.Text;
|
|
331
|
+
this.RowSpan;
|
|
332
|
+
this.ColSpan;
|
|
333
|
+
this.UpdateStatus={ Value:false, CSS:false, RowSpan:false, ColSpan:false }; //是否需要更新
|
|
334
|
+
this.CreateElement; //自定义创建元素
|
|
335
|
+
this.Identfiy=JSTableHelper.CreateGuid();
|
|
336
|
+
|
|
337
|
+
this.Children=[];
|
|
338
|
+
|
|
339
|
+
this.Build=function(index, trElement)
|
|
340
|
+
{
|
|
341
|
+
this.Index=index;
|
|
342
|
+
if (index<trElement.cells.length)
|
|
343
|
+
this.Element=trElement.cells[index];
|
|
344
|
+
else
|
|
345
|
+
this.Element=trElement.insertCell(index);
|
|
346
|
+
|
|
347
|
+
this.Update();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.Update=function()
|
|
351
|
+
{
|
|
352
|
+
if (!this.Element) return;
|
|
353
|
+
|
|
354
|
+
if (this.CreateElement)
|
|
355
|
+
{
|
|
356
|
+
this.CreateElement(this, this.ID);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (this.UpdateStatus.Value==true) this.Element.innerHTML=this.Text;
|
|
361
|
+
if (this.UpdateStatus.CSS==true) this.Element.className=this.CSS;
|
|
362
|
+
if (this.UpdateStatus.RowSpan==true) this.Element.rowSpan=this.RowSpan;
|
|
363
|
+
if (this.UpdateStatus.ColSpan==true) this.Element.colSpan=this.ColSpan;
|
|
364
|
+
|
|
365
|
+
this.UpdateStatus.Value=false;
|
|
366
|
+
this.UpdateStatus.CSS=false;
|
|
367
|
+
this.UpdateStatus.RowSpan=false;
|
|
368
|
+
this.UpdateStatus.ColSpan=false;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
this.SetText=function(text,option)
|
|
372
|
+
{
|
|
373
|
+
if (text!=this.Text)
|
|
374
|
+
{
|
|
375
|
+
this.Text=text;
|
|
376
|
+
this.UpdateStatus.Value=true;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (option)
|
|
380
|
+
{
|
|
381
|
+
if (option.CSS)
|
|
382
|
+
{
|
|
383
|
+
if (this.CSS!=option.CSS)
|
|
384
|
+
{
|
|
385
|
+
this.CSS=option.CSS;
|
|
386
|
+
this.UpdateStatus.CSS=true;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (option.RowSpan && option.RowSpan!=this.RowSpan)
|
|
391
|
+
{
|
|
392
|
+
this.RowSpan=option.RowSpan;
|
|
393
|
+
this.UpdateStatus.RowSpan=true;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (option.ColSpan && option.ColSpan!=this.ColSpan)
|
|
397
|
+
{
|
|
398
|
+
this.ColSpan=option.ColSpan;
|
|
399
|
+
this.UpdateStatus.ColSpan=true;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (option.ID) this.Identfiy=option.ID;
|
|
403
|
+
if (option.CreateElement) this.CreateElement=option.CreateElement;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
JsHeadCellItem.GetCellRule=function(type)
|
|
409
|
+
{
|
|
410
|
+
const CELL_RULE_MAP=new Map
|
|
411
|
+
([
|
|
412
|
+
[HEAD_CELL_TYPE_ID.CELL_STRING_ID, {Type:HEAD_CELL_TYPE_ID.CELL_STRING_ID, CSS:'jshcell-string'} ]
|
|
413
|
+
]);
|
|
414
|
+
|
|
415
|
+
if (CELL_RULE_MAP.has(type)) return CELL_RULE_MAP.get(type);
|
|
416
|
+
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function JsHeadRowItem()
|
|
421
|
+
{
|
|
422
|
+
this.CSS; //对应css样式的名字
|
|
423
|
+
this.Element; //<tr>
|
|
424
|
+
this.Index;
|
|
425
|
+
this.Cells=[];
|
|
426
|
+
|
|
427
|
+
this.Build=function(index,headElement)
|
|
428
|
+
{
|
|
429
|
+
this.Index=index;
|
|
430
|
+
if (index<headElement.rows.length)
|
|
431
|
+
this.Element=headElement.rows[index];
|
|
432
|
+
else
|
|
433
|
+
this.Element=headElement.insertRow(index);
|
|
434
|
+
|
|
435
|
+
for(var i in this.Cells)
|
|
436
|
+
{
|
|
437
|
+
var item=this.Cells[i];
|
|
438
|
+
item.Build(i, this.Element);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.InsertCell=function(index, text, option)
|
|
443
|
+
{
|
|
444
|
+
var cell=new JsHeadCellItem();
|
|
445
|
+
cell.SetText(text, option);
|
|
446
|
+
this.Cells.splice(index,0,cell);
|
|
447
|
+
return cell;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function JsTableHead()
|
|
452
|
+
{
|
|
453
|
+
this.Element; //<thead>
|
|
454
|
+
this.Rows=[]; // JsHeadRowItem
|
|
455
|
+
|
|
456
|
+
this.Build=function()
|
|
457
|
+
{
|
|
458
|
+
for(var i in this.Rows)
|
|
459
|
+
{
|
|
460
|
+
var rowItem=this.Rows[i];
|
|
461
|
+
rowItem.Build(i,this.Element);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
this.InsertRow=function(index)
|
|
466
|
+
{
|
|
467
|
+
var row=new JsHeadRowItem();
|
|
468
|
+
this.Rows[index]=row;
|
|
469
|
+
|
|
470
|
+
return row;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
this.RowCount=function()
|
|
474
|
+
{
|
|
475
|
+
return this.Rows.length;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
this.GetRow=function(rowIndex, rowColunm) //获取表头单元格数据
|
|
479
|
+
{
|
|
480
|
+
return this.Rows[rowIndex].Cells[rowColunm];
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function JSTable(divElement,option)
|
|
485
|
+
{
|
|
486
|
+
this.DivElement=divElement;
|
|
487
|
+
this.Rows=[]; //行
|
|
488
|
+
this.Head=new JsTableHead();
|
|
489
|
+
|
|
490
|
+
this.TableElement=document.createElement("table");
|
|
491
|
+
if (option && option.CSS) this.TableElement.className=option.CSS;
|
|
492
|
+
else this.TableElement.className='jstable jstable-metrics jstable-bordered ';
|
|
493
|
+
this.TableElement.id=JSTableHelper.CreateGuid();
|
|
494
|
+
divElement.appendChild(this.TableElement);
|
|
495
|
+
|
|
496
|
+
//表头
|
|
497
|
+
this.Head.Element=document.createElement("thead");
|
|
498
|
+
this.TableElement.appendChild(this.Head.Element);
|
|
499
|
+
|
|
500
|
+
//标题
|
|
501
|
+
this.BodyElement=document.createElement("tbody");
|
|
502
|
+
this.TableElement.appendChild(this.BodyElement);
|
|
503
|
+
|
|
504
|
+
//更新数据及行列
|
|
505
|
+
this.Build=function()
|
|
506
|
+
{
|
|
507
|
+
this.Head.Build();
|
|
508
|
+
|
|
509
|
+
for(var i in this.Rows)
|
|
510
|
+
{
|
|
511
|
+
var rowItem=this.Rows[i];
|
|
512
|
+
rowItem.Build(i,this.BodyElement);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
//删除多余的行
|
|
516
|
+
var rowCount=this.Rows.length;
|
|
517
|
+
while(rowCount<this.BodyElement.rows.length)
|
|
518
|
+
{
|
|
519
|
+
this.BodyElement.deleteRow(-1);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
//更新数据 行列不发生变化调用
|
|
524
|
+
this.Update=function()
|
|
525
|
+
{
|
|
526
|
+
for(var i in this.Rows)
|
|
527
|
+
{
|
|
528
|
+
var rowItem=this.Rows[i];
|
|
529
|
+
rowItem.Update();
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
this.InsertRow=function(index, row)
|
|
534
|
+
{
|
|
535
|
+
this.Rows.splice(index, 0, row);
|
|
536
|
+
return row;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
this.RemoveRow=function(index) //删除行
|
|
540
|
+
{
|
|
541
|
+
var row=this.Rows.splice(index, 1);
|
|
542
|
+
return row;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
this.RemoveColumn=function(index) //删除列
|
|
546
|
+
{
|
|
547
|
+
for(var i in this.Rows)
|
|
548
|
+
{
|
|
549
|
+
var item=this.Rows[i];
|
|
550
|
+
item.RemoveCell(index);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
this.ClearRows=function()
|
|
555
|
+
{
|
|
556
|
+
this.Rows=[];
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
this.InsertColumn=function(index, data) //添加列 data:{ Value:, Option }
|
|
560
|
+
{
|
|
561
|
+
if (Array.isArray(data))
|
|
562
|
+
{
|
|
563
|
+
for(var i in this.Rows)
|
|
564
|
+
{
|
|
565
|
+
var item=this.Rows[i];
|
|
566
|
+
if (i<data.length)
|
|
567
|
+
{
|
|
568
|
+
const dataItem=data[i];
|
|
569
|
+
item.InsertCell(index,dataItem.Value, dataItem.Option);
|
|
570
|
+
}
|
|
571
|
+
else
|
|
572
|
+
{
|
|
573
|
+
item.InsertCell(index,null,JsCellItem.GetCellRule(CELL_TYPE_ID.CELL_NONE_ID));
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else
|
|
578
|
+
{
|
|
579
|
+
for(var i in this.Rows)
|
|
580
|
+
{
|
|
581
|
+
var item=this.Rows[i];
|
|
582
|
+
item.InsertCell(index,data.Value, data.Option);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
//设置单元格数据
|
|
588
|
+
this.SetCellValue=function(rowIndex, colIndex, value, option)
|
|
589
|
+
{
|
|
590
|
+
if (rowIndex>=this.Rows.length) return;
|
|
591
|
+
var row=this.Rows[rowIndex];
|
|
592
|
+
if (colIndex>=row.Cells.length) return;
|
|
593
|
+
|
|
594
|
+
row.Cells[colIndex].SetValue(value,option);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
this.GetRowCount=function()
|
|
598
|
+
{
|
|
599
|
+
return this.Rows.length;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//排序
|
|
603
|
+
this.Sort=function(orderID, colIndex) //0=不排序 1=升序 2=降序
|
|
604
|
+
{
|
|
605
|
+
if (orderID==1)
|
|
606
|
+
{
|
|
607
|
+
this.Rows.sort((a,b)=>
|
|
608
|
+
{
|
|
609
|
+
return a.Cells[colIndex].Value-b.Cells[colIndex].Value;
|
|
610
|
+
})
|
|
611
|
+
}
|
|
612
|
+
else if (orderID==2)
|
|
613
|
+
{
|
|
614
|
+
this.Rows.sort((a,b)=>
|
|
615
|
+
{
|
|
616
|
+
return b.Cells[colIndex].Value-a.Cells[colIndex].Value;
|
|
617
|
+
})
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
625
|
+
// 公共方法
|
|
626
|
+
//
|
|
627
|
+
//
|
|
628
|
+
//
|
|
629
|
+
|
|
630
|
+
function JSTableHelper()
|
|
631
|
+
{
|
|
632
|
+
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
JSTableHelper.CreateGuid=function()
|
|
636
|
+
{
|
|
637
|
+
function S4()
|
|
638
|
+
{
|
|
639
|
+
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
|
640
|
+
}
|
|
641
|
+
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
//是否是数值
|
|
645
|
+
JSTableHelper.IsNumber=function(value)
|
|
646
|
+
{
|
|
647
|
+
if (value==null) return false;
|
|
648
|
+
if (isNaN(value)) return false;
|
|
649
|
+
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
//是否是整形
|
|
654
|
+
JSTableHelper.IsInteger=function(x)
|
|
655
|
+
{
|
|
656
|
+
return (typeof x === 'number') && (x % 1 === 0);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
//数据输出格式化 floatPrecision=原始小数位数 changedfloatPrecision=转换以后的小数位数
|
|
660
|
+
JSTableHelper.FormatValueString=function(value, floatPrecision, changedfloatPrecision, languageID)
|
|
661
|
+
{
|
|
662
|
+
if (!JSTableHelper.IsNumber(value))
|
|
663
|
+
{
|
|
664
|
+
if (floatPrecision>0)
|
|
665
|
+
{
|
|
666
|
+
var nullText='-.';
|
|
667
|
+
for(var i=0;i<floatPrecision;++i)
|
|
668
|
+
nullText+='-';
|
|
669
|
+
return nullText;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return '--';
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (value<0.00000000001 && value>-0.00000000001)
|
|
676
|
+
{
|
|
677
|
+
return "0";
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
var absValue = Math.abs(value);
|
|
681
|
+
if (absValue < 10000)
|
|
682
|
+
return value.toFixed(floatPrecision);
|
|
683
|
+
else if (absValue < 100000000)
|
|
684
|
+
return (value/10000).toFixed(changedfloatPrecision)+"万";
|
|
685
|
+
else if (absValue < 1000000000000)
|
|
686
|
+
return (value/100000000).toFixed(changedfloatPrecision)+"亿";
|
|
687
|
+
else
|
|
688
|
+
return (value/1000000000000).toFixed(changedfloatPrecision)+"万亿";
|
|
689
|
+
}
|
|
690
|
+
|