mm_os 1.6.0 → 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 = [];
@@ -646,7 +659,7 @@ Drive.prototype.get_format = async function(db) {
646
659
  * @return {Object} 返回导入结果
647
660
  */
648
661
  Drive.prototype.import_main = async function(db, file) {
649
- var params = await this.get_params();
662
+ var params = await this.get_params(db);
650
663
  var format = await this.get_format(db);
651
664
  file = file.replace(this.url_path, this.save_dir);
652
665
  var path;
@@ -773,7 +786,9 @@ Drive.prototype.export_main = async function(db, query, body) {
773
786
  if (!fields && query.field) {
774
787
  fields = query.field;
775
788
  }
776
- var params = await this.get_params(fields);
789
+ var params = await this.get_params(db, fields);
790
+
791
+ console.log("参数", params, fields);
777
792
  var format = await this.get_format(db);
778
793
 
779
794
  file = file.fullname(path);
@@ -1041,4 +1056,5 @@ Drive.prototype.count = async function(db, query, body) {
1041
1056
  return await this.count_main(db, pm);
1042
1057
  };
1043
1058
 
1059
+
1044
1060
  module.exports = Drive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {