lrf402788946 4 years ago
parent
commit
19b619d82b
8 changed files with 405 additions and 165 deletions
  1. 0 103
      app/controller/.zhwlcar.js
  2. 101 0
      app/controller/car/.car.js
  3. 4 4
      app/controller/zhwlcar.js
  4. 284 0
      app/model/car.js
  5. 0 48
      app/model/zhwlcar.js
  6. 1 6
      app/router.js
  7. 11 0
      app/router/car.js
  8. 4 4
      app/service/zhwlcar.js

+ 0 - 103
app/controller/.zhwlcar.js

@@ -1,103 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: [
-      "car_onwer",
-      "it",
-      "it_member",
-      "ro",
-      "r_time",
-      "car_no",
-      "car_type",
-      "cc_no",
-      "cc_weight",
-      "cc_scrap_time",
-      "cc_examine_time",
-      "rc_no",
-      "rc_examine_time",
-      "bcc_no",
-      "fi_name",
-      "fi_tel",
-      "fi_no",
-      "fi_cost",
-      "fi_start_time",
-      "fi_end_time",
-      "fi_dw",
-      "fi_vt",
-      "fi_sign_time",
-      "bi_name",
-      "bi_tel",
-      "bi_no",
-      "bi_cost",
-      "bi_start_time",
-      "bi_end_time",
-      "bi_dw",
-      "bi_sign_time",
-      "remark",
-      "last_place",
-    ],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: [
-      "car_onwer",
-      "it",
-      "it_member",
-      "ro",
-      "r_time",
-      "car_no",
-      "car_type",
-      "cc_no",
-      "cc_weight",
-      "cc_scrap_time",
-      "cc_examine_time",
-      "rc_no",
-      "rc_examine_time",
-      "bcc_no",
-      "fi_name",
-      "fi_tel",
-      "fi_no",
-      "fi_cost",
-      "fi_start_time",
-      "fi_end_time",
-      "fi_dw",
-      "fi_vt",
-      "fi_sign_time",
-      "bi_name",
-      "bi_tel",
-      "bi_no",
-      "bi_cost",
-      "bi_start_time",
-      "bi_end_time",
-      "bi_dw",
-      "bi_sign_time",
-      "remark",
-      "last_place",
-    ],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        car_onwer: "car_onwer",
-        it: "it",
-        it_member: "it_member",
-      },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};

+ 101 - 0
app/controller/car/.car.js

@@ -0,0 +1,101 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "!onwer",
+      "car_no",
+      "id_number",
+      "id_name",
+      "organ",
+      "r_date",
+      "c_type",
+      "c_doc_no",
+      "c_weight",
+      "c_scrap_date",
+      "c_examine_date",
+      "r_tran_no",
+      "r_examine_date",
+      "buy_car_taxes_no",
+      "f_company",
+      "f_tel",
+      "f_no",
+      "f_cost",
+      "f_start_date",
+      "f_end_date",
+      "f_solve",
+      "f_car_taxes",
+      "f_sign_date",
+      "b_company",
+      "b_tel",
+      "b_no",
+      "b_cost",
+      "b_start_date",
+      "b_end_date",
+      "b_solve",
+      "b_sign_date",
+      "remark",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "!onwer",
+      "car_no",
+      "id_number",
+      "id_name",
+      "organ",
+      "r_date",
+      "c_type",
+      "c_doc_no",
+      "c_weight",
+      "c_scrap_date",
+      "c_examine_date",
+      "r_tran_no",
+      "r_examine_date",
+      "buy_car_taxes_no",
+      "f_company",
+      "f_tel",
+      "f_no",
+      "f_cost",
+      "f_start_date",
+      "f_end_date",
+      "f_solve",
+      "f_car_taxes",
+      "f_sign_date",
+      "b_company",
+      "b_tel",
+      "b_no",
+      "b_cost",
+      "b_start_date",
+      "b_end_date",
+      "b_solve",
+      "b_sign_date",
+      "remark",
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        onwer: "%onwer%",
+        car_no: "%car_no%",
+        id_number: "%id_number%",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 4 - 4
app/controller/zhwlcar.js

@@ -1,16 +1,16 @@
 'use strict';
 
 // const _ = require('lodash');
-const meta = require('./.zhwlcar.js');
+const meta = require('./.car.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose/lib/controller');
 
 // 车辆表
-class ZhwlcarController extends Controller {
+class CarController extends Controller {
   constructor(ctx) {
     super(ctx);
-    this.service = this.ctx.service.zhwlcar;
+    this.service = this.ctx.service.car.car;
   }
 }
 
-module.exports = CrudController(ZhwlcarController, meta);
+module.exports = CrudController(CarController, meta);

+ 284 - 0
app/model/car.js

@@ -0,0 +1,284 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 车辆表
+const car = {
+  onwer: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车所有人', filter: true, required: true },
+    row: 1,
+  }, // 机动车所有人
+  car_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车登记编号', required: true, notable: true },
+    row: 2,
+  }, // 机动车登记编号
+  id_number: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '身份证明代码', required: true },
+    row: 3,
+  }, // 身份证明代码
+  id_name: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '身份证名称', required: true, notable: true },
+    row: 4,
+  }, // 身份证明名称
+  organ: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '登记机关', required: true, notable: true },
+    row: 5,
+  }, // 登记机关
+  r_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '登记日期', required: true, notable: true, type: 'date' },
+    row: 6,
+  }, // 登记日期
+  c_type: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车类别', required: true, notable: true },
+    row: 7,
+  }, // 机动车类别
+  c_doc_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车档案编号', required: true, notable: true },
+    row: 8,
+  }, // 机动车档案编号
+  c_weight: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '机动车整备质量(自重)', required: true, notable: true },
+    row: 9,
+  }, // 机动车整备质量(自重)
+  c_scrap_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '机动车强制报废日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 10,
+  }, // 机动车强制报废日期
+  c_examine_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '机动车检验有效期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 11,
+  }, // 机动车检验有效期
+  r_tran_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '道路运输证编号', required: true, notable: true },
+    row: 12,
+  }, // 道路运输证编号
+  r_examine_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '道路检验有效期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 13,
+  }, // 道路检验有效期
+  buy_car_taxes_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '车辆购置税完税证明编号', required: true, notable: true },
+    row: 14,
+  }, // 车辆购置税完税证明编号
+  f_company: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险责任公司', required: true, notable: true },
+    row: 15,
+  }, // 强制险责任公司
+  f_tel: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险责任公司服务电话', required: true, notable: true },
+    row: 16,
+  }, // 强制险责任公司服务电话
+  f_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险保险单号', required: true, notable: true },
+    row: 17,
+  }, // 强制险保险单号
+  f_cost: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险费用合计', required: true, notable: true },
+    row: 18,
+  }, // 强制险费用合计
+  f_start_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险起始时间', required: true, notable: true },
+    row: 19,
+  }, // 强制险起始时间
+  f_end_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险截止时间', required: true, notable: true },
+    row: 20,
+  }, // 强制险截止时间
+  f_solve: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险合同争议解决方式', required: true, notable: true },
+    row: 21,
+  }, // 强制险合同争议解决方式
+  f_car_taxes: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险代收车船使用税', required: true, notable: true },
+    row: 22,
+  }, // 强制险代收车船使用税
+  f_sign_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '强制险签单日期', required: true, notable: true },
+    row: 23,
+  }, // 强制险签单日期
+  b_company: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险责任公司名称', required: true, notable: true },
+    row: 24,
+  }, // 商业险责任公司名称
+  b_tel: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险责任公司电话', required: true, notable: true },
+    row: 25,
+  }, // 商业险责任公司电话
+  b_no: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险保险单号', required: true, notable: true },
+    row: 26,
+  }, // 商业险保险单号
+  b_cost: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险费用合计', required: true, notable: true },
+    row: 27,
+  }, // 商业险费用合计
+  b_start_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '商业险起始日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 28,
+  }, // 商业险起始日期
+  b_end_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '商业险截止日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 29,
+  }, // 商业险截止日期
+  b_solve: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '商业险合同争议解决方式', required: true, notable: true },
+    row: 30,
+  }, // 商业险合同争议解决方式
+  b_sign_date: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: {
+      label: '商业险签约日期',
+      required: true,
+      notable: true,
+      type: 'date',
+    },
+    row: 31,
+  }, // 商业险签约日期
+  remark: {
+    type: String,
+    required: false,
+    maxLength: 200,
+    field: { label: '备注', required: true },
+    row: 32,
+  }, // 备注
+  status: {
+    type: String,
+    maxLength: 200,
+    default: '0',
+    field: {
+      label: '状态',
+      filter: 'select',
+      type: 'select',
+      format: (i => (i === '0' ? '使用' : '禁用')).toString(),
+      list: [
+        { label: '使用', value: '0' },
+        { label: '禁用', value: '1' },
+      ],
+    },
+  }, // 状态:0=>使用;1禁用
+};
+
+const schema = new Schema(car, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Car', schema, 'car');
+};

+ 0 - 48
app/model/zhwlcar.js

@@ -1,48 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 车辆表
-const ZhwlcarSchema = {
-  car_onwer: { type: String, required: false, maxLength: 200 }, // 机动车所有人
-  it: { type: String, required: false, maxLength: 200 }, // 身份证明名称
-  it_member: { type: String, required: false, maxLength: 200 }, // 身份证明代码
-  ro: { type: String, required: false, maxLength: 200 }, // 登记机关
-  r_time: { type: String, required: false, maxLength: 200 }, // 登记日期
-  car_no: { type: String, required: false, maxLength: 200 }, // 机动车登记编号
-  car_type: { type: String, required: false, maxLength: 200 }, // 机动车类别
-  cc_no: { type: String, required: false, maxLength: 200 }, // 机动车档案编号
-  cc_weight: { type: String, required: false, maxLength: 200 }, // 机动车整备质量(自重)
-  cc_scrap_time: { type: String, required: false, maxLength: 200 }, // 机动车强制报废日期
-  cc_examine_time: { type: String, required: false, maxLength: 200 }, // 机动车检验有效期
-  rc_no: { type: String, required: false, maxLength: 200 }, // 道路运输证编号
-  rc_examine_time: { type: String, required: false, maxLength: 200 }, // 道路检验有效期
-  bcc_no: { type: String, required: false, maxLength: 200 }, // 车辆购置税完税证明编号
-  fi_name: { type: String, required: false, maxLength: 200 }, // 强制险责任公司
-  fi_tel: { type: String, required: false, maxLength: 200 }, // 强制险责任公司服务电话
-  fi_no: { type: String, required: false, maxLength: 200 }, // 强制险保险单号
-  fi_cost: { type: String, required: false, maxLength: 200 }, // 强制险费用合计
-  fi_start_time: { type: String, required: false, maxLength: 200 }, // 强制险起始时间
-  fi_end_time: { type: String, required: false, maxLength: 200 }, // 强制险截止时间
-  fi_dw: { type: String, required: false, maxLength: 200 }, // 强制险合同争议解决方式
-  fi_vt: { type: String, required: false, maxLength: 200 }, // 强制险代收车船使用税
-  fi_sign_time: { type: String, required: false, maxLength: 200 }, // 强制险签单日期
-  bi_name: { type: String, required: false, maxLength: 200 }, // 商业险责任公司名称
-  bi_tel: { type: String, required: false, maxLength: 200 }, // 商业险责任公司电话
-  bi_no: { type: String, required: false, maxLength: 200 }, // 商业险保险单号
-  bi_cost: { type: String, required: false, maxLength: 200 }, // 商业险费用合计
-  bi_start_time: { type: String, required: false, maxLength: 200 }, // 商业险起始日期
-  bi_end_time: { type: String, required: false, maxLength: 200 }, // 商业险截止日期
-  bi_dw: { type: String, required: false, maxLength: 200 }, // 商业险合同争议解决方式
-  bi_sign_time: { type: String, required: false, maxLength: 200 }, // 商业险签约日期
-  remark: { type: String, required: false, maxLength: 200 }, // 备注
-  last_place: { type: String, required: false, maxLength: 200 }, // 最后地点
-};
-
-const schema = new Schema(ZhwlcarSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Zhwlcar', schema, 'zhwlcar');
-};

+ 1 - 6
app/router.js

@@ -11,15 +11,10 @@ module.exports = app => {
   // 測試
   router.resources('test', '/api/servicezhwl/test', controller.test); // index、create、show、destroy
   router.post('test', '/api/servicezhwl/test/update/:id', controller.test.update);
-
-
-  // 车辆表
-  router.resources('zhwlcar', '/api/servicezhwl/zhwlcar', controller.zhwlcar); // index、create、show、destroy
-  router.post('zhwlcar', '/api/servicezhwl/zhwlcar/update/:id', controller.zhwlcar.update);
-
   // 系统设置路由
   require('./router/system')(app); // 系统设置
   require('./router/personnel')(app); // 人员设置
   require('./router/client')(app); // 客户/供应商相关
+  require('./router/car')(app); // 车辆相关
 
 };

+ 11 - 0
app/router/car.js

@@ -0,0 +1,11 @@
+'use strict';
+/**
+ * @param {Egg.Application} app - egg application
+ */
+module.exports = app => {
+  const prefix = '/api/servicezhwl';
+  const index = 'car';
+  const { router, controller } = app;
+  router.resources('car', `${prefix}/car`, controller[index].car); // index、create、show、destroy
+  router.post('car', `${prefix}/car/update/:id`, controller[index].car.update);
+};

+ 4 - 4
app/service/zhwlcar.js

@@ -6,11 +6,11 @@ const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { ZhwlcarError, ErrorCode } = require('naf-core').Error;
 
-class ZhwlcarService extends CrudService {
+class CarService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'zhwlcar');
-    this.model = this.ctx.model.Zhwlcar;
+    super(ctx, 'car');
+    this.model = this.ctx.model.Car;
   }
 }
 
-module.exports = ZhwlcarService;
+module.exports = CarService;