index.js 5.75 KB
Newer Older
田翔's avatar
田翔 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
// 常量集合
/**
 *  @Description: 新增形态 【时间】相关内容
 *  @Date: 2021/11/30
 *  @Edit: ChenLong
 * */
import moment from 'moment';

const dateDescribe = {
  默认为空: {
    initTime: '',
    endTime: '',
    readOnly: false,
  },
  默认为当前时间: {
    initTime: moment(new Date()),
    endTime: '',
    readOnly: false,
  },
  锁定为当前时间: {
    initTime: moment(new Date()),
    endTime: '',
    readOnly: true,
  },
  不超过当前时间: {
    initTime: '',
    endTime: moment(),
    readOnly: false,
  },
30
}
田翔's avatar
田翔 committed
31 32 33 34 35 36 37 38
const dateType = {
  日期时间: 'date',
  时间: 'time',
  日期: 'date',
  日期年份: 'year',
  日期月份: 'month',
  日期周: 'week',
  时分秒: 'time',
39
}
田翔's avatar
田翔 committed
40 41 42 43 44 45 46 47
const dateFormat = {
  日期时间: 'YYYY-MM-DD HH:mm:ss',
  时间: 'YYYY-MM-DD HH:mm:ss',
  日期: 'YYYY-MM-DD',
  日期年份: 'YYYY',
  日期月份: 'YYYY-MM',
  日期周: 'YYYY-MM-DD',
  时分秒: 'HH:mm:ss',
48
}
田翔's avatar
田翔 committed
49 50 51 52 53 54 55
const RegExpObject = {
  number: '^(\\-|\\+)?((0\\.\\d+)|([0-9])|([1-9]\\d+(\\.\\d+)?))$',// 数字,支持正、负、浮点数
  digits: '^(\\-|\\+)?(\\d|[1-9]\\d+)$', // 整数
  email: '^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$', // 邮箱
  identity: '(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)',
  mobile: '^1(3|4|5|6|7|8|9)\\d{9}$',
  bankAccount: '^(\\d{16}|\\d{19})$',
56 57 58 59
}
const dateArray = { timeControl: ['时间', '仅时间', '日期', '日期月份', '日期年份', '时分秒'] }
const doNotDisplayInEditModelShape = ['编码']

田翔's avatar
田翔 committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
const colors = [
  // '#ffccc7', '#ffe7ba', '#fffb8f', '#d9f7be', '#b5f5ec',
  // '#bae7ff', '#d6e4ff', '#efdbff', '#ffd6e7', '#e8e8e8',
  // '#ff4d4f', '#ffa940', '#fbce00', '#73d13d', '#36cfc9',
  // '#40a9ff', '#597ef7', '#9254de', '#f759ab', '#8c8c8c',
  'rgb(255, 77, 79)',
  'rgb(255, 169, 64)',
  'rgb(251, 206, 0)',
  'rgba(115, 209, 61)',
  'rgba(54, 207, 201)',
  'rgba(64, 169, 255)',
  'rgba(89, 126, 247)',
  'rgba(146, 84, 222)',
  'rgba(247, 89, 171)',
  'rgba(140, 140, 140)',
  // 'rgba(255, 204, 199)',
  // 'rgba(255, 231, 186)',
  // 'rgba(255, 251, 143)',
  // 'rgba(217, 247, 190)',
  // 'rgba(181, 245, 236)',
  // 'rgba(186, 231, 255)',
  // 'rgba(214, 228, 255)',
  // 'rgba(239, 219, 255)',
  // 'rgba(255, 214, 231)',
  // 'rgba(232, 232, 232)',
]

87
const widgetData = {
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
  'TextInput': {
    name: '文本',
    type: '文本控件',
  },
  'TextArea': {
    name: '多行文本',
    type: '文本控件',
  },
  'NumberInput': {
    name: '数值',
    type: '文本控件',
  },
  'RichText': {
    name: '富文本',
    type: '文本控件',
  },
  'Coding': {
    name: '编码',
    type: '文本控件',
  },
田翔's avatar
田翔 committed
108 109 110 111
  'SearchLocation': {
    name: '地址位置',
    type: '文本控件',
  },
田翔's avatar
田翔 committed
112 113 114 115
  'TextHTML': {
    name: '描述控件',
    type: '文本控件',
  },
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
  'ComboBox': {
    name: '下拉框',
    type: '选择器控件',
  },
  'RadioButton': {
    name: '单选框',
    type: '选择器控件',
  },
  'CheckBox': {
    name: '复选框',
    type: '选择器控件',
  },
  'SwitchSelector': {
    name: '开关按钮',
    type: '选择器控件',
  },
  'RelevanceSelect': {
    name: '关联选择',
    type: '选择器控件'
  },
  'CascadeSelector': {
    name: '联级选择',
    type: '选择器控件',
  },
  'PersonSelector': {
    name: '人员选择',
    type: '业务控件',
  },
  'DeptSelector': {
    name: '部门选择',
    type: '业务控件',
  },
  'AccountSelector': {
    name: '台账选择',
    type: '业务控件',
  },
  'DateTime': {
    name: '日期选择',
    type: '时间控件',
  },
  'Time': {
    name: '时间选择',
    type: '时间控件',
  },
  'FileUpload': {
    name: '附件',
    type: '附件控件',
  },
  'Coordinate': {
165 166 167 168 169 170 171 172 173
    name: '地图坐标',
    type: 'GIS控件',
  },
  'DrawPath': {
    name: '路径控件',
    type: 'GIS控件',
  },
  'DrawArea': {
    name: '区域控件',
174 175 176 177 178 179 180 181 182 183 184 185 186 187
    type: 'GIS控件',
  },
  'Device': {
    name: '设备选择',
    type: 'GIS控件',
  },
  'RelationForm': {
    name: '关联表单',
    type: '高级控件',
  },
  'AutoCalculate': {
    name: '自动计算',
    type: '高级控件',
  },
田翔's avatar
田翔 committed
188 189 190 191
  'Signature': {
    name: '手写签名',
    type: '高级控件',
  },
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
}

const getStyles = (type) => {
  switch (type) {
    case '文本控件': return { background: '#DEFED9', color: '#48BC2E' }
    case '选择器控件': return { background: '#E1EDFE', color: '#0765F3' }
    case '业务控件': return { background: '#FCE2FA', color: '#DD3CC4' }
    case '时间控件': return { background: '#E1EDFE', color: '#0765F3' }
    case '附件控件': return { background: '#FCF2E0', color: '#F59E06' }
    case 'GIS控件': return { background: '#D1F5EB', color: '#0A9C71' }
    case '高级控件': return { background: '#D6F1FE', color: '#0195D4' }
    default: return {}
  }
}

207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
const accepts = {
  '全部': [],
  '图片': ['.bmp', '.gif', '.jpeg', 'tiff', '.png', '.svg', '.jpg'],
  '文档': ['.docx', '.xlsx', '.pdf'],
  '视频': ['.mp4'],
  '音频': ['.mp3'],
}

const getFileType = (fileName) => {
  if (fileName) {
    //图片
    if (fileName.includes('jpg')) {
      return 'jpg'
    }
    if (fileName.includes('png')) {
      return 'png'
    }
    if (fileName.includes('svg')) {
      return 'svg'
    }
    if (fileName.includes('jpeg')) {
      return 'jpeg'
    }
    //文档
    if (fileName.includes('docx')) {
      return 'docx'
    }
    if (fileName.includes('xlsx')) {
      return 'xlsx'
    }
    if (fileName.includes('pdf')) {
      return 'pdf'
    }
    //音频
    if (fileName.includes('mp3')) {
      return 'mp3'
    }
    //视频
    if (fileName.includes('mp4')) {
      return 'mp4'
    }
  }
  return null
}

252 253 254 255 256 257 258
export {
  dateDescribe,
  dateType,
  dateFormat,
  RegExpObject,
  dateArray,
  doNotDisplayInEditModelShape,
田翔's avatar
田翔 committed
259
  colors,
260 261
  widgetData,
  getStyles,
262 263
  accepts,
  getFileType
264
}