123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 客户
- const Client = {
- name: {
- type: String,
- required: true,
- maxLength: 200,
- field: { label: '企业名称', filter: true, required: true },
- },
- legal: {
- type: String,
- required: true,
- maxLength: 200,
- field: { label: '联系人', filter: true, required: true },
- },
- mobile: {
- type: String,
- required: true,
- maxLength: 200,
- field: { label: '联系电话', filter: true, required: true },
- },
- address: {
- type: String,
- maxLength: 200,
- field: { label: '地址' },
- }, // 存储内容
- account_bank: {
- type: String,
- maxLength: 200,
- field: { label: '开户行' },
- },
- account: { type: String, maxLength: 200, field: { label: '银行账号' } },
- taxes_no: { type: String, maxLength: 200, field: { label: '税号' } },
- type: {
- type: String,
- maxLength: 200,
- field: {
- label: '类型',
- notable: true,
- noform: true,
- list: [
- { label: '客户', value: '客户' },
- { label: '供应商', value: '供应商' },
- ],
- },
- },
- 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(Client, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ name: 1 });
- schema.index({ legal: 1 });
- schema.index({ mobile: 1 });
- schema.index({ type: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Client', schema, 'client');
- };
|