fields.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * 表单 Fields 类
  3. * @class Fields
  4. */
  5. export default class Fields {
  6. constructor(obj) {
  7. this.name = obj.name // 字段名
  8. this.defaultValue = obj.defaultValue // 字段默认值
  9. this.fieldName = obj.fieldName // 字段
  10. this.formType = obj.formType // 字段类型
  11. this.inputTips = obj.inputTips || null // 输入提示
  12. this.isNull = obj.isNull || 0 // 非空 1 必填 0 非必填
  13. this.isUnique = obj.isUnique || 0 // 是否唯一 1 是 0 否
  14. this.setting = obj.setting || [] // 选项
  15. this.value = obj.value || '' // 字段值
  16. this.fieldType = obj.fieldType || 1
  17. this.disabled = obj.disabled || false
  18. this.precisions = obj.precisions || null // 精度
  19. if (obj.maxSelected) {
  20. this.maxSelected = obj.maxSelected
  21. }
  22. if (obj.maxlength) {
  23. this.maxlength = obj.maxlength
  24. }
  25. Object.keys(obj).forEach(key => {
  26. if (!this.hasOwnProperty(key)) {
  27. this[key] = obj[key]
  28. }
  29. })
  30. }
  31. }
  32. const constantTypes = {
  33. text: '单行文本',
  34. textarea: '多行文本',
  35. select: '下拉',
  36. radio: '单选',
  37. checkbox: '多选',
  38. number: '数字',
  39. floatnumber: '货币',
  40. mobile: '手机',
  41. email: '邮箱',
  42. date: '日期',
  43. datetime: '日期时间',
  44. file: '附件',
  45. }
  46. const asyncTypes = {
  47. address: '地址',
  48. user: '用户',
  49. structure: '部门',
  50. customer: '客户',
  51. contacts: '联系人',
  52. business: '商机',
  53. category: '产品类别',
  54. business_type: '商机状态组',
  55. business_status: '商机阶段',
  56. form: '表格',
  57. }
  58. const types = {
  59. text: '点击填写',
  60. email: '点击填写',
  61. mobile: '点击填写',
  62. phone: '点击填写',
  63. url: '点击填写',
  64. textarea: '点击填写',
  65. image: null,
  66. select: '点击选择',
  67. address: '点击选择',
  68. time: '点击选择',
  69. }