sbd-npm 1.2.43 → 1.2.45

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/constant.js +3 -2
  2. package/package.json +1 -1
  3. package/util.js +52 -23
package/constant.js CHANGED
@@ -212,8 +212,8 @@ const MenuList = [
212
212
  {'key': 'rank_profit', 'name': '净利润/营业收入', 'url': '/90ee0f9bcf37d965d0f894c6bd6be788'},
213
213
  {'key': 'rank_roe', 'name': 'ROE(净资产收益率)', 'url': '/575707ea27d7de73d5467660b9181606'},
214
214
  {'key': 'rank_dividend', 'name': '股息', 'url': '/83070c336bee9b99bd4f9ad54963f9ef'},
215
- {'key': 'rank_circulation_stock', 'name': '流通股比例', 'url': '/212721244ee3f9bab3ea2275f6f25272'},
216
- {'key': 'rank_holder', 'name': '股东比', 'url': '/5f09520c907774de4e1dfcf78e7f45b8'},
215
+ {'key': 'rank_circulation_stock', 'name': '流通股份', 'url': '/212721244ee3f9bab3ea2275f6f25272'},
216
+ {'key': 'rank_holder', 'name': '股东户数', 'url': '/5f09520c907774de4e1dfcf78e7f45b8'},
217
217
  {'key': 'rank_goodwill', 'name': '商誉占比', 'url': '/81e1e604b6fd26be1ab3f496e5edd742'},
218
218
  ]
219
219
  },
@@ -264,6 +264,7 @@ const IndexList = [
264
264
  {'code': 'SH000906', 'name': '中证800', 'is_industry': 1, 'is_key': 1},
265
265
  {'code': 'SH000852', 'name': '中证1000', 'is_industry': 1, 'is_key': 1},
266
266
  {'code': 'SZ399303', 'name': '国证2000', 'is_industry': 0, 'is_key': 1},
267
+ {'code': 'SZ399959', 'name': '军工指数', 'is_industry': 0, 'is_key': 0},
267
268
  {'code': 'SH000985', 'name': '中证全指', 'is_industry': 0, 'is_key': 0},
268
269
  {'code': 'SH000922', 'name': '中证红利', 'is_industry': 0, 'is_key': 0},
269
270
  {'code': 'SH000003', 'name': 'B股指数', 'is_industry': 0, 'is_key': 0},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.43",
3
+ "version": "1.2.45",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -253,12 +253,20 @@ const Util = {
253
253
  let symbol = Util.is_alpha(item["code"]) ? item["code"].toUpperCase() : item["code"];
254
254
  let name = symbol;
255
255
  if (item["cname"]) {
256
- name = item["cname"];
256
+ if (Util.is_us(item["code"])) {
257
+ name = item["cname"].replace("公司", "").replace("•", "").replace("•", "");
258
+ } else {
259
+ name = item["cname"];
260
+ }
257
261
  } else if (item["name"]) {
258
262
  name = item["name"];
259
- if (Util.is_us(item["code"]) && name.indexOf(' ') !== -1) {
260
- let name_arr = name.split(' ');
261
- name = name_arr[0] ? name_arr[0] : name;
263
+ if (Util.is_us(item["code"])) {
264
+ if (name.indexOf(' ') !== -1) {
265
+ let name_arr = name.split(' ');
266
+ name = name_arr[0] ? name_arr[0] : name;
267
+ } else {
268
+ name = name.replace("公司", "").replace("•", "").replace("•", "");
269
+ }
262
270
  }
263
271
  name = name.substr(0, 10);
264
272
  }
@@ -500,7 +508,7 @@ const Util = {
500
508
  us_logo_html: function (code) {
501
509
  code = code.toUpperCase();
502
510
  let logo_url = "https://storage.googleapis.com/iex/api/logos/" + code + ".png";
503
- return '<a rel="noopener noreferrer nofollow" href="' + logo_url + '" target="_blank"><img alt="' + code + '" width="20px" src="' + logo_url + '"/><a>';
511
+ return '<a rel="noopener noreferrer nofollow" href="' + logo_url + '" target="_blank"><img alt="' + code + '" width="20px" src="' + logo_url + '"/></a>';
504
512
  },
505
513
 
506
514
  /**
@@ -1334,6 +1342,23 @@ const Util = {
1334
1342
  $("#" + component_id).html(html.join(""));
1335
1343
  },
1336
1344
 
1345
+ /**
1346
+ * 初始 select 组件
1347
+ * @param component_id
1348
+ * @param data
1349
+ */
1350
+ init_select_component: function (component_id, data) {
1351
+ let element_id = component_id.replace("_div", "");
1352
+ let html = [];
1353
+ html.push('<label for="', element_id, '"></label>');
1354
+ html.push('<select id="', element_id, '" class="form-control">');
1355
+ data.forEach(function (item) {
1356
+ html.push('<option value="', item["val"], '">', item["name"], '</option>');
1357
+ });
1358
+ html.push('</select>');
1359
+ $("#" + component_id).html(html.join(""));
1360
+ }
1361
+
1337
1362
  /**
1338
1363
  * 当前时间戳
1339
1364
  * @returns {number}
@@ -2461,23 +2486,6 @@ const Util = {
2461
2486
  }
2462
2487
  },
2463
2488
 
2464
- /**
2465
- * 获取股东数据
2466
- * @param element_id
2467
- */
2468
- fetch_holder_num: function (element_id) {
2469
- let code_list = Util.get_code_list(element_id);
2470
- if (code_list.length > 0) {
2471
- Util.post("/action", {action: "holder_num", code_list: code_list.join("-")}, function (j) {
2472
- $.each(j, function (code, item) {
2473
- $(".holder_" + code).each(function () {
2474
- $(this).html(Util.pack_holder_num(item));
2475
- });
2476
- });
2477
- });
2478
- }
2479
- },
2480
-
2481
2489
  /**
2482
2490
  * 设置 option 的第 nth 项为默认项
2483
2491
  * @param obj
@@ -2722,7 +2730,10 @@ const Util = {
2722
2730
  } else if (digit >= 10000 || digit <= -10000) {
2723
2731
  return "<span title='" + digit + "'>" + Util.to_float(digit / 10000, fraction) + "万</span>";
2724
2732
  }
2725
- return Util.to_float(digit, fraction);
2733
+ if (Util.is_float(digit)) {
2734
+ return Util.to_float(digit, fraction);
2735
+ }
2736
+ return digit;
2726
2737
  },
2727
2738
 
2728
2739
  /**
@@ -2750,6 +2761,24 @@ const Util = {
2750
2761
  return 0;
2751
2762
  },
2752
2763
 
2764
+ /**
2765
+ * 是否浮点数
2766
+ * @param n
2767
+ * @returns {boolean}
2768
+ */
2769
+ is_float: function (n) {
2770
+ return Number(n) === n && n % 1 !== 0;
2771
+ },
2772
+
2773
+ /**
2774
+ * 是否整数
2775
+ * @param n
2776
+ * @returns {boolean}
2777
+ */
2778
+ is_int: function (n) {
2779
+ return Number(n) === n && n % 1 === 0;
2780
+ },
2781
+
2753
2782
  /**
2754
2783
  * 触发事件的对象的引用
2755
2784
  * https://developer.mozilla.org/zh-CN/docs/Web/API/Event/target