lrf402788946 4 năm trước cách đây
mục cha
commit
52e3e066d3
3 tập tin đã thay đổi với 50 bổ sung23 xóa
  1. 0 2
      app/controller/order/.order.js
  2. 8 21
      app/model/order.js
  3. 42 0
      app/service/util.js

+ 0 - 2
app/controller/order/.order.js

@@ -15,7 +15,6 @@ module.exports = {
       "pre_money",
       "goods",
       "split",
-      "goods_bill",
       "in_bill",
       "out_bill",
       "is_js",
@@ -45,7 +44,6 @@ module.exports = {
       "pre_money",
       "goods",
       "split",
-      "goods_bill",
       "in_bill",
       "out_bill",
       "is_js",

+ 8 - 21
app/model/order.js

@@ -30,7 +30,14 @@ const goods = new Schema({
   number: { type: Number, maxLength: 200 }, // 数量
   weight: { type: Number, maxLength: 200 }, // 重量
   volume: { type: Number, maxLength: 200 }, // 体积
-  transport_type: { type: String, maxLength: 200, default: '直达' }, // 该货物的运输类型: 直达;转运
+  // 收入部分
+  mode: { type: String, maxlength: 200 }, // 计费方式
+  price: { type: Number, maxLength: 200 }, // 单价
+  taxes: { type: String, maxLength: 200 }, // 税率
+  sq_ys: { type: Number, maxLength: 200 }, // 税前应收
+  sq_ss: { type: Number, maxLength: 200 }, // 税前实收
+  sh_ys: { type: Number, maxLength: 200 }, // 税后应收
+  sh_ss: { type: Number, maxLength: 200 }, // 税后实收
   remark: { type: String, maxLength: 200 },
 });
 
@@ -57,21 +64,6 @@ const recordList = new Schema({
   time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') }, // 操作时间
 });
 
-// 货物收入
-const goods_bill = new Schema({
-  name: { type: String, maxlength: 200 }, // 货物名称
-  mode: { type: String, maxlength: 200 }, // 计费方式
-  number: { type: Number, maxLength: 200 }, // 数量
-  weight: { type: Number, maxLength: 200 }, // 重量
-  volume: { type: Number, maxLength: 200 }, // 体积
-  price: { type: Number, maxLength: 200 }, // 单价
-  taxes: { type: String, maxLength: 200 }, // 税率
-  sq_ys: { type: Number, maxLength: 200 }, // 税前应收
-  sq_ss: { type: Number, maxLength: 200 }, // 税前实收
-  sh_ys: { type: Number, maxLength: 200 }, // 税后应收
-  sh_ss: { type: Number, maxLength: 200 }, // 税后实收
-});
-
 // 收入/支出项
 const cost_bill = new Schema({
   item: { type: String, maxlength: 200 }, // 支出项
@@ -165,11 +157,6 @@ const order = {
       remark: '货物录入后,同时进入这里,这里的货物供拆分使用',
     },
   },
-  goods_bill: {
-    type: [ goods_bill ],
-    maxLength: 200,
-    field: { label: '货物收入单据' },
-  },
   in_bill: {
     type: [ cost_bill ],
     maxLength: 200,

+ 42 - 0
app/service/util.js

@@ -10,7 +10,28 @@ class UtilService extends CrudService {
     super(ctx);
     this.mq = this.ctx.mq;
   }
+
+  /**
+   * 获取字段前置函数
+   * @param {String} param0 {model字段名
+   */
   async findModel({ model }) {
+    if (model !== 'all') return await this.getModel(model);
+    const modelList = this.ctx.model;
+    const keys = Object.keys(modelList);
+    const arr = [];
+    for (const key of keys) {
+      if (key !== 'Test') { arr.push({ zh: this.modelToZh(key), table: key, value: await this.getModel(key) }); }
+    }
+    return arr;
+
+  }
+
+  /**
+   * 获取字段
+   * @param {String} model 表名
+   */
+  async getModel(model) {
     const _model = _.capitalize(model);
     const data = this.ctx.model[_model].prototype.schema.obj;
     const keys = Object.keys(data);
@@ -26,6 +47,27 @@ class UtilService extends CrudService {
     return res;
   }
 
+  /**
+   * 表名换成中文
+   * @param {String} model 表名
+   */
+  modelToZh(model) {
+    const obj = {
+      car: '车辆表',
+      client: '客户/供应商表',
+      daily: '车辆日常维修表',
+      dictionary: '字典表',
+      driver: '司机表',
+      item: '项目表',
+      mode: '计费方式表',
+      order: '订单表',
+      route: '路线表',
+      transport: '运输表',
+      treaty: '合同表',
+    };
+    return obj[_.lowerCase(model)];
+  }
+
   async utilMethod(query, body) {
   }
 }