sbd-npm 1.4.4 → 1.4.6

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/status.js +84 -0
  3. package/util.js +12 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -33,6 +33,9 @@ $(function () {
33
33
  case "environment":
34
34
  Status.handle_environment();
35
35
  break;
36
+ case "task":
37
+ Status.handle_task();
38
+ break;
36
39
  case "tool":
37
40
  Status.handle_tool();
38
41
  break;
@@ -385,6 +388,87 @@ $(function () {
385
388
  });
386
389
  },
387
390
 
391
+ handle_task: function () {
392
+ if (!document.getElementById("task_content")) {
393
+ let ht_html =[];
394
+ ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
395
+ ht_html.push('<div class="form-inline">');
396
+ ht_html.push('<div class="form-group">');
397
+ ht_html.push('<input data-toggle="tooltip" data-placement="top" title="要执行的任务内容" placeholder="要执行的任务内容" value="" type="text" class="form-control" id="task_content" autocomplete="off" style="width: 300px;"/>');
398
+ ht_html.push('</div>&nbsp;');
399
+ ht_html.push('<button class="btn btn-default" id="task_add">添加任务</button>');
400
+ ht_html.push('<span id="task_tips"></span>');
401
+ ht_html.push('</div>');
402
+ ht_html.push('<form class="form-horizontal" style="margin-top: 10px;">');
403
+ ht_html.push('<div class="form-group" id="task_result_zone"></div>');
404
+ ht_html.push('</form>');
405
+ ht_html.push('</div>');
406
+ $("#task_div").html(ht_html.join(""));
407
+ $("#task_add").click(function() {
408
+ let task_content = $("#task_content").val();
409
+ if (task_content) {
410
+ $("#task_content").prop('disabled', true);
411
+ $("#task_add").prop('disabled', true);
412
+ Util.show_loading();
413
+ $("#task_tips").html("");
414
+ Util.post(location.pathname, {active_div: "task_add", "task_content": task_content}, function (j) {
415
+ if (j["code"] && j["code"] === 1) {
416
+ $("#task_add").html('任务处理中...');
417
+ if (!document.getElementById("task_result")) {
418
+ $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
419
+ }
420
+ $("#task_result").val("任务 `" + task_content + "` 处理中...");
421
+ } else {
422
+ if (j["code"] && j["code"] === 2) {
423
+ $("#task_tips").html("<b class='text-danger'>已添加新任务在处理中!</b>");
424
+ } else if (j["code"] && j["code"] === 3) {
425
+ $("#task_tips").html("<b class='text-danger'>有任务在执行中!</b>");
426
+ } else {
427
+ $("#task_tips").html("<b class='text-danger'>参数异常!</b>");
428
+ }
429
+ $("#task_content").prop('disabled', false);
430
+ $("#task_add").prop('disabled', false);
431
+ }
432
+ Util.hide_tips();
433
+ });
434
+ } else {
435
+ $("#task_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
436
+ }
437
+ return false;
438
+ });
439
+ }
440
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
441
+ if (j["code"] && j["code"] > 1 && j["content"]) {
442
+ let ta_obj = $("#task_add");
443
+ let tc_obj = $("#task_content");
444
+ tc_obj.val(j["content"]);
445
+ if (j["code"] === 4) {
446
+ ta_obj.html('添加任务');
447
+ ta_obj.prop('disabled', false);
448
+ tc_obj.prop('disabled', false);
449
+ $("#task_tips").html("<b class='text-success'>任务 `" + j["content"] + "` 已经完成!</b>");
450
+ } else {
451
+ ta_obj.html('任务处理中...');
452
+ ta_obj.prop('disabled', true);
453
+ tc_obj.prop('disabled', true);
454
+ }
455
+ if (!document.getElementById("task_result")) {
456
+ $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
457
+ }
458
+ let tr_obj = $("#task_result");
459
+ if (j["result"]) {
460
+ tr_obj.val(j["result"]);
461
+ tr_obj.scrollTop(tr_obj[0].scrollHeight);
462
+ } else {
463
+ if (j["code"] !== 4) {
464
+ tr_obj.val("任务 `" + j["content"] + "` 处理中...");
465
+ }
466
+ }
467
+ }
468
+ Util.hide_tips();
469
+ });
470
+ },
471
+
388
472
  handle_tool: function () {
389
473
  let t_obj = $("#timestamp");
390
474
  let t_val = t_obj.val();
package/util.js CHANGED
@@ -1261,7 +1261,7 @@ const Util = {
1261
1261
  {"name": "当时股价", "table_sort": 1, "title": "当季最后一个交易日的收盘价"},
1262
1262
  {"name": "持股总数", "table_sort": 1},
1263
1263
  {"name": "持仓基金数", "table_sort": 1},
1264
- {"name": "持股进前10的基金数", "table_sort": 1, "title": "基金数以持股数占比进前10内的股票来统计"},
1264
+ {"name": "持股进前10的基金数", "table_sort": 1, "title": "基金数以持股数占比进前十内的股票来统计"},
1265
1265
  {"name": "持仓市值", "table_sort": 1, "title": "当时股价 * 持股总数"},
1266
1266
  ]
1267
1267
  });
@@ -1273,7 +1273,7 @@ const Util = {
1273
1273
  }
1274
1274
  Util.post("/stock/" + code, {action: "public_fund_change"}, function (j) {
1275
1275
  Util["pfc_stock_chart"].hideLoading();
1276
- let date_data = [], fund_num_data = [], stock_num_data = [], price_data = [], _html = [], is_fund10_num = 0;
1276
+ let date_data = [], fund_num_data = [], stock_num_data = [], value_data = [], price_data = [], _html = [], is_fund10_num = 0;
1277
1277
  if ($("#is_fund10_num").length > 0) {
1278
1278
  is_fund10_num = $("#is_fund10_num").prop("checked") ? 1 : 0;
1279
1279
  }
@@ -1286,6 +1286,8 @@ const Util = {
1286
1286
  fund_num_data.push(item["fund_num"]);
1287
1287
  }
1288
1288
  stock_num_data.push(item["stock_num"]);
1289
+ let hold_value = Util.to_hundred_million(item["hold_value"], 3);
1290
+ value_data.push(hold_value);
1289
1291
  price_data.push(item["price"]);
1290
1292
  _html.push("<tr>");
1291
1293
  _html.push("<td>", Util.pack_html_link("https://data.eastmoney.com/zlsj/detail/" + date_format + "-1-" + code + ".html", date_format), "</td>");
@@ -1309,15 +1311,17 @@ const Util = {
1309
1311
  fund_rank_num_rate = "(" + Util.year_price_rate(item["fund_rank_num"], item["pre_fund_rank_num"], 1) + ")";
1310
1312
  }
1311
1313
  _html.push("<td data-val='", item["fund_rank_num"], "'>", item["fund_rank_num"], fund_rank_num_rate, "</td>");
1312
- _html.push("<td data-val='", item["hold_value"], "' title='", item["hold_value"], "'>", Util.to_unit(item["hold_value"], 3), "</td>");
1314
+ _html.push("<td data-val='", item["hold_value"], "' title='", item["hold_value"], "'>", hold_value, "亿</td>");
1313
1315
  _html.push("</tr>");
1314
1316
  });
1315
1317
  date_data = date_data.reverse();
1316
1318
  fund_num_data = fund_num_data.reverse();
1317
1319
  stock_num_data = stock_num_data.reverse();
1320
+ value_data = value_data.reverse();
1318
1321
  price_data = price_data.reverse();
1319
1322
  Util["pfc_stock_chart"] = Util.multi_axis_line(Util["pfc_stock_chart"], "pfc_stock_line_canvas", date_data, '总持股数', stock_num_data, '股价', price_data);
1320
1323
  Util["pfc_fund_chart"] = Util.multi_axis_line(Util["pfc_fund_chart"], "pfc_fund_line_canvas", date_data, '持仓家数', fund_num_data, '股价', price_data);
1324
+ Util["pfc_value_chart"] = Util.multi_axis_line(Util["pfc_value_chart"], "pfc_value_line_canvas", date_data, '持仓市值', value_data, '股价', price_data);
1321
1325
  if (j["data"].length > 1) {
1322
1326
  let cur_stock_num = j["data"][0]["stock_num"];
1323
1327
  let pre_stock_num = j["data"][1]["stock_num"];
@@ -1329,6 +1333,11 @@ const Util = {
1329
1333
  if (cur_fund_num > 0 && pre_fund_num > 0) {
1330
1334
  $("#pfc_fund_tips").html("(当前基金数: <b class='text-info'>" + cur_fund_num + "</b>, 环比: " + Util.year_price_rate(cur_fund_num, pre_fund_num) + ")");
1331
1335
  }
1336
+ let cur_value_num = j["data"][0]["hold_value"];
1337
+ let pre_value_num = j["data"][1]["hold_value"];
1338
+ if (cur_value_num > 0 && pre_value_num > 0) {
1339
+ $("#pfc_value_tips").html("(当前持仓市值: <b class='text-info'>" + Util.to_unit(cur_value_num) + "</b>, 环比: " + Util.year_price_rate(cur_value_num, pre_value_num) + ")");
1340
+ }
1332
1341
  }
1333
1342
  Util.render_table_html("pfc_fund_table_body", _html);
1334
1343
  Util.hide_tips();