mm_os 1.5.9 → 1.6.1

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.
@@ -1,8 +1,6 @@
1
1
  const Item = require('mm_machine').Item;
2
2
  const Excel = require('mm_excel');
3
3
 
4
-
5
-
6
4
  /**
7
5
  * Sql操作驱动类
8
6
  * @extends {Item}
@@ -563,16 +561,17 @@ Drive.prototype.addOrSet = async function(db, query, body) {
563
561
  * @param {Array} fields 要获取的字段数组
564
562
  * @return {Array} 返回参数信息列表
565
563
  */
566
- Drive.prototype.get_params = async function(fields) {
564
+ Drive.prototype.get_params = async function(db, fields) {
567
565
  var cg = this.config;
568
566
  if (cg.params) {
569
567
  return cg.params;
570
568
  }
569
+
571
570
  var params;
572
571
  var name = cg.table;
573
- var db = $.pool.db['sys'];
574
- if (db) {
575
- var dt = db.get(name);
572
+ var pool = $.pool.db['sys'];
573
+ if (pool) {
574
+ var dt = pool.get(name);
576
575
  if (dt && dt.config) {
577
576
  var list = dt.config.fields;
578
577
  if (fields) {
@@ -592,6 +591,20 @@ Drive.prototype.get_params = async function(fields) {
592
591
  }
593
592
  }
594
593
  }
594
+ if (!params) {
595
+ db.table = this.config.table;
596
+ var list = await db.fields();
597
+ var lt = [];
598
+ for (var i = 0; i < list.length; i++) {
599
+ var o = list[i];
600
+ var note = o.note ? o.note.replace(":", ":") : o.name;
601
+ lt.push({
602
+ name: o.name,
603
+ title: note.left(":", true)
604
+ });
605
+ }
606
+ params = lt;
607
+ }
595
608
  if (!params) {
596
609
  var field = cg.field_default;
597
610
  var lt = [];
@@ -630,6 +643,7 @@ Drive.prototype.get_format = async function(db) {
630
643
  if (o.id !== o.key) {
631
644
  o.list.map((m) => {
632
645
  m[o.key] = m[o.id];
646
+ return m;
633
647
  });
634
648
  }
635
649
  }
@@ -645,7 +659,7 @@ Drive.prototype.get_format = async function(db) {
645
659
  * @return {Object} 返回导入结果
646
660
  */
647
661
  Drive.prototype.import_main = async function(db, file) {
648
- var params = await this.get_params();
662
+ var params = await this.get_params(db);
649
663
  var format = await this.get_format(db);
650
664
  file = file.replace(this.url_path, this.save_dir);
651
665
  var path;
@@ -772,7 +786,9 @@ Drive.prototype.export_main = async function(db, query, body) {
772
786
  if (!fields && query.field) {
773
787
  fields = query.field;
774
788
  }
775
- var params = await this.get_params(fields);
789
+ var params = await this.get_params(db, fields);
790
+
791
+ console.log("参数", params, fields);
776
792
  var format = await this.get_format(db);
777
793
 
778
794
  file = file.fullname(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "1.5.9",
3
+ "version": "1.6.1",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "koa-send": "^5.0.1",
36
36
  "koa-websocket": "^7.0.0",
37
37
  "mm_check": "^1.4.4",
38
- "mm_excel": "^1.0.8",
38
+ "mm_excel": "^1.0.9",
39
39
  "mm_expand": "^1.5.6",
40
40
  "mm_html": "^1.1.1",
41
41
  "mm_koa_proxy": "^1.0.0",