monkey 4 年前
父节点
当前提交
3b49fafe04

+ 12
- 6
src/components/NewCom/WkCheckbox/index.vue 查看文件

@@ -40,10 +40,9 @@
40 40
 </template>
41 41
 
42 42
 <script>
43
-import { isObject, isEmpty } from '@/utils/types'
43
+import { isObject, isEmpty, isArray } from '@/utils/types'
44 44
 import { valueEquals } from 'element-ui/lib/utils/util'
45 45
 import Emitter from 'element-ui/lib/mixins/emitter'
46
-
47 46
 export default {
48 47
   // 自定义字段库 多选
49 48
   name: 'WkCheckbox',
@@ -96,6 +95,12 @@ export default {
96 95
         this.validValue()
97 96
       },
98 97
       immediate: true
98
+    },
99
+    options: {
100
+      handler() {
101
+        this.validValue()
102
+      },
103
+      deep: true
99 104
     }
100 105
   },
101 106
 
@@ -118,18 +123,19 @@ export default {
118 123
         }
119 124
       } else {
120 125
         if (this.otherShowInput) {
121
-          const otherItem = this.value.filter((name) => !this.options.includes(name))
126
+          const value = isArray(this.value) ? this.value : []
127
+          const otherItem = value.filter((name) => !this.options.includes(name))
122 128
           if (otherItem.length > 0) {
123
-            const newValue = this.value.filter((name) => !otherItem.includes(name))
129
+            const newValue = value.filter((name) => !otherItem.includes(name))
124 130
             newValue.push('其他')
125 131
             this.dataValue = {
126 132
               select: newValue,
127 133
               otherValue: otherItem[otherItem.length - 1]
128 134
             }
129 135
           } else {
130
-            if (!valueEquals(this.value, this.dataValue.select)) {
136
+            if (!valueEquals(value, this.dataValue.select)) {
131 137
               this.dataValue = {
132
-                select: this.value,
138
+                select: value,
133 139
                 otherValue: ''
134 140
               }
135 141
             }

+ 23
- 2
src/components/NewCom/WkDepSelect/index.vue 查看文件

@@ -3,11 +3,12 @@
3 3
     v-elclickoutside="handleClose"
4 4
     ref="reference"
5 5
     :class="[disabled ? 'is_disabled' : 'is_valid', { 'is_focus': visible }]"
6
+    :style="{ height: `${height}px` }"
6 7
     wrap="wrap"
7 8
     class="wk-dep-select xh-form-border"
8 9
     @click="containerClick">
9 10
 
10
-    <div class="el-select__tags">
11
+    <div ref="tags" class="el-select__tags">
11 12
       <span
12 13
         v-for="(item, index) in showSelects"
13 14
         :key="index"
@@ -119,6 +120,7 @@ export default {
119 120
       visible: false,
120 121
       dataValue: [], // 校准传入值
121 122
       loading: false,
123
+      height: 34,
122 124
 
123 125
       optionsList: []
124 126
     }
@@ -175,6 +177,12 @@ export default {
175 177
           this.$emit('input', this.dataValue)
176 178
         }
177 179
       }
180
+    },
181
+    showSelects: {
182
+      handler() {
183
+        this.resetHeight()
184
+      },
185
+      immediate: true
178 186
     }
179 187
   },
180 188
 
@@ -183,6 +191,16 @@ export default {
183 191
   },
184 192
 
185 193
   methods: {
194
+    resetHeight() {
195
+      const tags = this.$refs.tags
196
+      if (tags) {
197
+        this.$nextTick(() => {
198
+          this.height = tags.clientHeight > 34 ? tags.clientHeight + 6 : 34
199
+        })
200
+      } else {
201
+        this.height = 34
202
+      }
203
+    },
186 204
 
187 205
     /**
188 206
      * 获取展示的数组
@@ -215,7 +233,7 @@ export default {
215 233
       }
216 234
 
217 235
       if (this.radio && (Array.isArray(this.value) || this.value === null || this.value === undefined)) {
218
-        this.$emit('input', '')
236
+        // this.$emit('input', '')
219 237
       }
220 238
 
221 239
       if (this.radio) {
@@ -318,8 +336,10 @@ export default {
318 336
       this.$nextTick(() => {
319 337
         if (this.radio) {
320 338
           this.dispatch('ElFormItem', 'el.form.change', this.dataValue && this.dataValue.length ? this.dataValue[0] : '')
339
+          this.$emit('input', this.dataValue && this.dataValue.length ? this.dataValue[0] : '')
321 340
         } else {
322 341
           this.dispatch('ElFormItem', 'el.form.change', this.dataValue)
342
+          this.$emit('input', this.dataValue)
323 343
         }
324 344
         this.$emit('change', this.dataValue, this.selects)
325 345
       })
@@ -358,6 +378,7 @@ export default {
358 378
     color: #ddd;
359 379
     line-height: 34px;
360 380
     cursor: pointer;
381
+    user-select: none;
361 382
   }
362 383
   .delete-icon {
363 384
     color: #999;

+ 10
- 10
src/components/NewCom/WkDetailTable/View.vue 查看文件

@@ -17,14 +17,14 @@
17 17
             <div
18 18
               v-if="getShowValue(item)"
19 19
               :key="index"
20
-              :class="[`is-${item.formType}`]"
20
+              :class="[`is-${item.form_type}`]"
21 21
               :label="item.name"
22 22
               :style="{width: item.stylePercent ? `${item.stylePercent}%` : 'auto'}"
23 23
               class="wk-form-item">
24 24
               <div class="wk-form-item__label">{{ item.name }}</div>
25 25
               <wk-field-view
26 26
                 :props="item"
27
-                :form-type="item.formType"
27
+                :form_type="item.form_type"
28 28
                 :value="fieldForm[sectionIndex][item.field]"
29 29
               >
30 30
                 <template slot-scope="{ data }">
@@ -50,11 +50,11 @@
50 50
           :key="index"
51 51
           :prop="item.field"
52 52
           :label="item.name"
53
-          :min-width="getMinWidth(item.formType)">
53
+          :min-width="getMinWidth(item.form_type)">
54 54
           <template slot-scope="{ row, column, $index }">
55 55
             <wk-field-view
56 56
               :props="item"
57
-              :form-type="item.formType"
57
+              :form_type="item.form_type"
58 58
               :value="row[item.field]"
59 59
             >
60 60
               <template slot-scope="{ data }">
@@ -115,12 +115,12 @@ export default {
115 115
   beforeDestroy() {},
116 116
 
117 117
   methods: {
118
-    getMinWidth(formType) {
119
-      if (formType === 'date_interval' ||
120
-      formType === 'dateRange' ||
121
-       formType === 'file' ||
122
-       formType === 'location' ||
123
-       formType === 'position') {
118
+    getMinWidth(form_type) {
119
+      if (form_type === 'date_interval' ||
120
+      form_type === 'dateRange' ||
121
+       form_type === 'file' ||
122
+       form_type === 'location' ||
123
+       form_type === 'position') {
124 124
         return 250
125 125
       }
126 126
       return 150

+ 127
- 12
src/components/NewCom/WkForm/GenerateRules.js 查看文件

@@ -8,7 +8,7 @@ import {
8 8
   regexIsCRMMobile,
9 9
   regexIsCRMEmail
10 10
 } from '@/utils'
11
-import { isEmpty } from '@/utils/types'
11
+import { isEmpty, isObject, isArray } from '@/utils/types'
12 12
 
13 13
 
14 14
 export default {
@@ -41,6 +41,32 @@ export default {
41 41
           message: item.name + '不能为空',
42 42
           trigger: ['blur', 'change']
43 43
         })
44
+        if (item.form_type == 'detail_table') {
45
+          tempList.push({
46
+            validator: ({ item }, value, callback) => {
47
+              if (this.getDetailTableIsEmpty(item.fieldExtendList, value)) {
48
+                callback(new Error(item.name + '不能为空'))
49
+              } else {
50
+                callback()
51
+              }
52
+            },
53
+            item: item,
54
+            trigger: ['blur', 'change']
55
+          })
56
+        } else if (item.form_type == 'checkbox') {
57
+          tempList.push({
58
+            validator: ({ item }, value, callback) => {
59
+              if (!isArray(value) || value.length === 0) {
60
+                callback(new Error(item.name + '不能为空'))
61
+              } else {
62
+                const emptyObj = value.find(valueItem => isEmpty(valueItem))
63
+                emptyObj === '' ? callback(new Error(item.name + '不能为空')) : callback()
64
+              }
65
+            },
66
+            item: item,
67
+            trigger: ['blur', 'change']
68
+          })
69
+        }
44 70
       }
45 71
 
46 72
       // 验证唯一
@@ -65,18 +91,22 @@ export default {
65 91
           validator: validateUnique,
66 92
           item: item,
67 93
           trigger:
68
-            item.formType == 'checkbox' || item.formType == 'select' || item.form_type == 'checkbox' || item.form_type == 'select'
94
+            item.form_type == 'checkbox' || item.form_type == 'select'
69 95
               ? ['change']
70 96
               : ['blur']
71 97
         })
72 98
       }
73 99
       // 特殊类型
74
-      if (item.formType === 'number' || item.form_type === 'number') {
100
+      if (item.form_type === 'number' || item.form_type === 'percent') {
75 101
         const validateCRMNumber = (rule, value, callback) => {
76
-          if (isEmpty(value) || regexIsCRMNumber(value)) {
77
-            callback()
102
+          if (item.hasOwnProperty('precisions')) {
103
+            this._getNumberRule(rule, value, callback)
78 104
           } else {
79
-            callback(new Error('数字的整数部分须少于15位,小数部分须少于4位'))
105
+            if (isEmpty(value) || regexIsCRMNumber(value)) {
106
+              callback()
107
+            } else {
108
+              callback(new Error('数字的整数部分须少于15位,小数部分须少于4位'))
109
+            }
80 110
           }
81 111
         }
82 112
         tempList.push({
@@ -84,12 +114,16 @@ export default {
84 114
           item: item,
85 115
           trigger: ['blur']
86 116
         })
87
-      } else if (item.formType === 'floatnumber' || item.form_type === 'floatnumber') {
117
+      } else if (item.form_type === 'floatnumber') {
88 118
         const validateCRMMoneyNumber = (rule, value, callback) => {
89
-          if (isEmpty(value) || regexIsCRMMoneyNumber(value)) {
90
-            callback()
119
+          if (item.hasOwnProperty('precisions')) {
120
+            this._getNumberRule(rule, value, callback)
91 121
           } else {
92
-            callback(new Error('货币的整数部分须少于15位,小数部分须少于2位'))
122
+            if (isEmpty(value) || regexIsCRMMoneyNumber(value)) {
123
+              callback()
124
+            } else {
125
+              callback(new Error('货币的整数部分须少于15位,小数部分须少于2位'))
126
+            }
93 127
           }
94 128
         }
95 129
         tempList.push({
@@ -97,7 +131,7 @@ export default {
97 131
           item: item,
98 132
           trigger: ['blur']
99 133
         })
100
-      } else if (item.formType === 'mobile' || item.form_type === 'mobile') {
134
+      } else if (item.form_type === 'mobile') {
101 135
         const validateCRMMobile = (rule, value, callback) => {
102 136
           if (isEmpty(value) || regexIsCRMMobile(value)) {
103 137
             callback()
@@ -110,7 +144,7 @@ export default {
110 144
           item: item,
111 145
           trigger: ['blur']
112 146
         })
113
-      } else if (item.formType === 'email' || item.form_type === 'email') {
147
+      } else if (item.form_type === 'email') {
114 148
         const validateCRMEmail = (rule, value, callback) => {
115 149
           if (isEmpty(value) || regexIsCRMEmail(value)) {
116 150
             callback()
@@ -123,9 +157,90 @@ export default {
123 157
           item: item,
124 158
           trigger: ['blur']
125 159
         })
160
+      } else if (item.form_type === 'location' && item.is_null == 1) {
161
+        const validateLocation = (rule, value, callback) => {
162
+          if (!isObject(value) || (
163
+            isObject(value) && isEmpty(value.lat) && isEmpty(value.lng) && isEmpty(value.address)
164
+          )) {
165
+            callback(new Error(item.name + '不能为空'))
166
+          } else {
167
+            callback()
168
+          }
169
+        }
170
+        tempList.push({
171
+          validator: validateLocation,
172
+          item: item,
173
+          trigger: ['change']
174
+        })
126 175
       }
127 176
 
128 177
       return tempList
178
+    },
179
+
180
+    /**
181
+     * 获取数值规则
182
+     */
183
+    _getNumberRule(rule, value, callback) {
184
+      const field = rule.item
185
+
186
+      const arr = String(value).split('.')
187
+
188
+      const len = String(value)
189
+        .replace('.', '')
190
+        .replace('-', '')
191
+        .length
192
+      const maxlength = field.form_type === 'percent' ? 10 : 15
193
+
194
+      const min = isEmpty(field.minNumRestrict) ? -Infinity : Number(field.minNumRestrict || -Infinity)
195
+      const max = isEmpty(field.maxNumRestrict) ? Infinity : Number(field.maxNumRestrict || Infinity)
196
+
197
+      if (len > maxlength) {
198
+        callback(new Error(`最多支持${maxlength}位数字(包含小数位)`))
199
+      } else if (isEmpty(field.precisions) && String(value).includes('.')) {
200
+        // null 不支持小数  0 不限制小数位
201
+        callback(new Error(`不支持小数`))
202
+      } else if (arr.length > 1 && arr[1].length > Number(field.precisions)) {
203
+        callback(new Error(`小数位不能大于${field.precisions}`))
204
+      } else if (value < min) {
205
+        callback(new Error(`不能小于${min}`))
206
+      } else if (value > max) {
207
+        callback(new Error(`不能大于${max}`))
208
+      } else {
209
+        callback()
210
+      }
211
+    },
212
+
213
+    /**
214
+     * 判断明细表格是否是空
215
+     * @param {*} fieldList
216
+     * @param {*} valueObj
217
+     */
218
+    getDetailTableIsEmpty(fieldList, valueObjs) {
219
+      for (let index = 0; index < valueObjs.length; index++) {
220
+        const valueObj = valueObjs[index]
221
+        if (this.judgeFormValueIsEmpty(fieldList, valueObj)) {
222
+          return true
223
+        }
224
+      }
225
+      return false
226
+    },
227
+
228
+    /**
229
+     * 判断对象值是否是空
230
+     */
231
+    judgeFormValueIsEmpty(fieldList, valueObj) {
232
+      for (let index = 0; index < fieldList.length; index++) {
233
+        const field = fieldList[index]
234
+        const value = valueObj[field.field]
235
+        if (field.form_type === 'location') {
236
+          if (isObject(value) && (!isEmpty(value.lat) || !isEmpty(value.lng) || !isEmpty(value.address))) {
237
+            return false
238
+          }
239
+        } else if (!isEmpty(value)) {
240
+          return false
241
+        }
242
+      }
243
+      return true
129 244
     }
130 245
   }
131 246
 }

+ 1
- 1
src/components/NewCom/WkForm/Mixin.js 查看文件

@@ -70,7 +70,7 @@ export default {
70 70
      * 获取提示语
71 71
      */
72 72
     getTips(data) {
73
-      const tips = data.tips || data.inputTips
73
+      const tips = data.tips || data.input_tips
74 74
       return tips ? `(${tips})` : ''
75 75
     },
76 76
     /**

+ 8
- 0
src/components/NewCom/WkForm/WkFormItem.vue 查看文件

@@ -127,4 +127,12 @@ export default {
127 127
   padding: 12px 12px 0;
128 128
   margin-bottom: 0;
129 129
 }
130
+.el-form-item.is-user {
131
+  display: flex ;
132
+  flex-direction: column ;
133
+}
134
+.el-form-item.is-structure {
135
+  display: flex;
136
+  flex-direction: column;
137
+}
130 138
 </style>

+ 5
- 1
src/components/NewCom/WkForm/utils.js 查看文件

@@ -42,7 +42,11 @@ export function getFormFieldShowName(form_type, value, placeholder = '--', item)
42 42
     if (isEmpty(newValue)) {
43 43
       return placeholder
44 44
     } else {
45
-      return newValue
45
+      if (isArray(newValue)) {
46
+        return newValue.join(',')
47
+      } else {
48
+        return newValue
49
+      }
46 50
     }
47 51
   } else if (form_type === 'structure') {
48 52
     if (isArray(value)) {

+ 1
- 16
src/components/XrUpgradeDialog.vue 查看文件

@@ -33,22 +33,7 @@ export default {
33 33
   },
34 34
   data() {
35 35
     return {
36
-      message: `新增:
37
-1、增加多种自定义字段类型,支持自定义字段占比配置及布局调整;
38
-2、客户管理:新增团队成员有效时间;优化团队成员权限;联系人和回款模块增加团队成员功能;增加相关团队字段,支持通过相关团队对团队成员进行筛选;
39
-3、新增日志点赞互动功能;
40
-4、新增发票模块自定义字段、发票导出功能;
41
-5、增加市场活动自定义表单
42
-6、跟进记录增加导入导出功能
43
-7、导入数据时,增加“负责人”字段
44
-8、角色权限:系统管理角色新增权限"角色权限查看",控制在新建员工选择角色和编辑员工角色时,可查看和选择角色的范围;
45
-
46
-优化:
47
-1、优化客户管理仪表盘,图表展示和统计数据等;
48
-2、优化导出,支持操作一万条以上数据;
49
-3、高级筛选判断符优化调整;时间筛选增加固定时间段(例如今日、本月、本年等);
50
-4、权限优化
51
-
36
+      message: `
52 37
 修复:
53 38
 1、修复其他已知bug。`
54 39
     }

+ 2
- 2
src/config.js 查看文件

@@ -3,8 +3,8 @@ const getLocationOrigin = () => {
3 3
 }
4 4
 
5 5
 const companyName = '悟空CRM'
6
-const version = 'V11.1.0'
7
-const baiduKey = 'lcuOQ71SCZhqpxsr1vL2mXoplWEoVctL'
6
+const version = 'V11.1.1'
7
+const baiduKey = '百度key'
8 8
 
9 9
 export default {
10 10
   version,

+ 19
- 23
src/mixins/CustomFields.js 查看文件

@@ -17,10 +17,10 @@ export default {
17 17
      */
18 18
     getItemValue(item, detail, type) {
19 19
       detail = detail || {}
20
-      if ((item.form_type || item.form_type) == 'contacts' ||
21
-          (item.form_type || item.form_type) == 'customer' ||
22
-          (item.form_type || item.form_type) == 'contract' ||
23
-          (item.form_type || item.form_type) == 'business'
20
+      if (item.form_type == 'contacts' ||
21
+          item.form_type == 'customer' ||
22
+          item.form_type == 'contract' ||
23
+          item.form_type == 'business'
24 24
       ) {
25 25
         // crm相关信息特殊处理
26 26
         if (type === 'update') {
@@ -55,12 +55,10 @@ export default {
55 55
             ? objDeepCopy(item.default_value.id)
56 56
             : ''
57 57
         }
58
-      } else if (item.form_type == 'user' ||
59
-            item.form_type == 'structure' ||
60
-            item.form_type == 'file' ||
61
-            item.form_type == 'user' ||
62
-            item.form_type == 'structure' ||
63
-            item.form_type == 'file'
58
+      } else if (
59
+        item.form_type == 'user' ||
60
+        item.form_type == 'structure' ||
61
+        item.form_type == 'file'
64 62
       ) {
65 63
         if (type === 'update') {
66 64
           return item.value ? objDeepCopy(item.value) : []
@@ -72,11 +70,8 @@ export default {
72 70
       } else {
73 71
         if (
74 72
           item.form_type == 'number' ||
75
-        item.form_type == 'floatnumber' ||
76
-        item.form_type == 'percent' ||
77
-        item.form_type == 'number' ||
78
-        item.form_type == 'floatnumber' ||
79
-        item.form_type == 'percent'
73
+          item.form_type == 'floatnumber' ||
74
+          item.form_type == 'percent'
80 75
         ) {
81 76
           if (type == 'update') {
82 77
             return isEmpty(item.value) ? undefined : item.value
@@ -453,9 +448,9 @@ export default {
453 448
         }
454 449
         return ''
455 450
       } else if (field.form_type == 'checkbox') {
456
-        if (isArray(dataValue)) {
457
-          return dataValue.join(',')
458
-        }
451
+        // if (isArray(dataValue)) {
452
+        //   return dataValue.join(',')
453
+        // }
459 454
         return dataValue
460 455
       } else if (field.form_type == 'date') {
461 456
         if (dataValue) {
@@ -506,11 +501,12 @@ export default {
506 501
       for (let index = 0; index < fieldList.length; index++) {
507 502
         const field = fieldList[index]
508 503
         const value = valueObj[field.field]
509
-        if (field.form_type === 'select' || field.form_type === 'checkbox') {
510
-          if (isObject(value) && !isEmpty(value.select)) {
511
-            return false
512
-          }
513
-        } else if (field.form_type === 'location') {
504
+        // if (field.form_type === 'select' || field.form_type === 'checkbox') {
505
+        //   if (isObject(value) && !isEmpty(value.select)) {
506
+        //     return false
507
+        //   }
508
+        // } else if (field.form_type === 'location') {
509
+        if (field.form_type === 'location') {
514 510
           if (isObject(value) && (!isEmpty(value.lat) || !isEmpty(value.lng) || !isEmpty(value.address))) {
515 511
             return false
516 512
           }

+ 26
- 5
src/views/admin/fields/components/FieldItem/FieldDetailTable.vue 查看文件

@@ -43,8 +43,10 @@
43 43
               :key="index"
44 44
               :prop="field.fieldName"
45 45
               :label="field.name">
46
-              <template slot-scope="scope">
47
-                <div class="input-box" />
46
+              <template slot-scope="{ row, column }">
47
+                <div class="input-box" >
48
+                  {{ row[column.property] }}
49
+                </div>
48 50
               </template>
49 51
             </el-table-column>
50 52
             <el-table-column label="操作" fixed="right">
@@ -115,9 +117,9 @@ export default {
115 117
         fallbackClass: 'draggingStyle',
116 118
         filter: '.empty-box'
117 119
       },
118
-      selectedPoint: [null, null],
120
+      selectedPoint: [null, null]
119 121
 
120
-      tableData: [{}]
122
+      // tableData: [{}]
121 123
     }
122 124
   },
123 125
   computed: {
@@ -129,9 +131,28 @@ export default {
129 131
     },
130 132
     list() {
131 133
       return this.isEmpty ? [] : this.field.fieldExtendList
134
+    },
135
+    tableData() {
136
+      const obj = {}
137
+      this.list.forEach(item => {
138
+        obj[item.fieldName] = this.formatterDefaultValue(item)
139
+      })
140
+      return [obj]
132 141
     }
133 142
   },
134 143
   methods: {
144
+    formatterDefaultValue(data) {
145
+      if (!data.default_value) return ''
146
+      if (data.form_type === 'boolean_value') {
147
+        return { '0': '不选中', '1': '选中' }[data.default_value] || '不选中'
148
+      } else if (data.form_type === 'datatime' || data.form_type === 'date_interval') {
149
+        return data.default_value.join('-')
150
+      } else if (data.form_type === 'checkbox') {
151
+        return data.default_value.join(',')
152
+      } else if (typeof data.default_value === 'string') {
153
+        return data.default_value
154
+      }
155
+    },
135 156
     dragListEnd(evt) {
136 157
       // console.log('table drag list end', evt)
137 158
     },
@@ -204,7 +225,7 @@ export default {
204 225
     width: 100%;
205 226
     height: 30px;
206 227
     border: 1px solid #dcdfe6;
207
-    padding: 3px 0;
228
+    padding: 3px 5px;
208 229
   }
209 230
 
210 231
   .table-field {

+ 57
- 56
src/views/admin/fields/components/SettingField/SettingDefault.vue 查看文件

@@ -86,7 +86,7 @@
86 86
 import WkDistpicker from '@/components/NewCom/WkDistpicker'
87 87
 
88 88
 import { isEmpty, isArray } from '@/utils/types'
89
-import { regexIsCRMMobile, regexIsCRMEmail, objDeepCopy } from '@/utils'
89
+import { objDeepCopy } from '@/utils'
90 90
 import { getFieldAuth } from '../../utils'
91 91
 
92 92
 export default {
@@ -217,64 +217,65 @@ export default {
217 217
   methods: {
218 218
     inputBlur() {
219 219
       // this.$emit('input', this.value)
220
-      if (!this.field.default_value) return
221
-      if (this.field.form_type === 'mobile') {
222
-        // 校验手机号
223
-        if (!regexIsCRMMobile(this.field.default_value)) {
224
-          this.$message.error('输入的手机格式有误')
225
-          this.field.default_value = ''
226
-        }
227
-      } else if (this.field.form_type === 'email') {
228
-        // 校验邮箱
229
-        if (!regexIsCRMEmail(this.field.default_value)) {
230
-          this.$message.error('输入的邮箱格式有误')
231
-          this.field.default_value = ''
232
-        }
233
-      } else if (this.type === 'number') {
234
-        // 校验数字类型
235
-        const num = Number(this.field.default_value) // 去0
236
-        if (isNaN(num)) {
237
-          this.field.default_value = null
238
-          return
239
-        }
240
-        this.field.default_value = String(num)
241
-        const arr = String(num).split('.')
220
+      // if (!this.field.default_value) return
221
+      // if (this.field.form_type === 'mobile') {
222
+      //   // 校验手机号
223
+      //   if (!regexIsCRMMobile(this.field.default_value)) {
224
+      //     this.$message.error('输入的手机格式有误')
225
+      //     this.field.default_value = ''
226
+      //   }
227
+      // } else if (this.field.form_type === 'email') {
228
+      //   // 校验邮箱
229
+      //   if (!regexIsCRMEmail(this.field.default_value)) {
230
+      //     this.$message.error('输入的邮箱格式有误')
231
+      //     this.field.default_value = ''
232
+      //   }
233
+      // } else if (this.type === 'number') {
234
+      //   console.log(111)
235
+      //   // 校验数字类型
236
+      //   const num = Number(this.field.default_value) // 去0
237
+      //   if (isNaN(num)) {
238
+      //     this.field.default_value = null
239
+      //     return
240
+      //   }
241
+      //   this.field.default_value = String(num)
242
+      //   const arr = String(num).split('.')
242 243
 
243
-        const len = String(num)
244
-          .replace('.', '')
245
-          .replace('-', '')
246
-          .length
247
-        const maxlength = this.field.form_type === 'percent' ? 10 : 15
248
-        if (len > maxlength) {
249
-          this.$message.error(`最多支持${maxlength}位数字(包含小数位)`)
250
-          this.field.default_value = null
251
-          return
252
-        }
244
+      //   const len = String(num)
245
+      //     .replace('.', '')
246
+      //     .replace('-', '')
247
+      //     .length
248
+      //   const maxlength = this.field.form_type === 'percent' ? 10 : 15
249
+      //   if (len > maxlength) {
250
+      //     this.$message.error(`最多支持${maxlength}位数字(包含小数位)`)
251
+      //     this.field.default_value = null
252
+      //     return
253
+      //   }
253 254
 
254
-        const min = isEmpty(this.field.minNumRestrict) ? -Infinity : Number(this.field.minNumRestrict || -Infinity)
255
-        const max = isEmpty(this.field.maxNumRestrict) ? Infinity : Number(this.field.maxNumRestrict || Infinity)
256
-        if (num < min) {
257
-          this.$message.error('默认值不能小于最小值')
258
-          this.field.default_value = null
259
-          return
260
-        }
261
-        if (num > max) {
262
-          this.$message.error('默认值不能大于最大值')
263
-          this.field.default_value = null
264
-          return
265
-        }
255
+      //   const min = isEmpty(this.field.minNumRestrict) ? -Infinity : Number(this.field.minNumRestrict || -Infinity)
256
+      //   const max = isEmpty(this.field.maxNumRestrict) ? Infinity : Number(this.field.maxNumRestrict || Infinity)
257
+      //   if (num < min) {
258
+      //     this.$message.error('默认值不能小于最小值')
259
+      //     this.field.default_value = null
260
+      //     return
261
+      //   }
262
+      //   if (num > max) {
263
+      //     this.$message.error('默认值不能大于最大值')
264
+      //     this.field.default_value = null
265
+      //     return
266
+      //   }
266 267
 
267
-        // null 不支持小数  0 不限制小数位
268
-        if (isEmpty(this.field.precisions)) {
269
-          this.field.default_value = arr[0]
270
-          return
271
-        }
272
-        if (this.field.precisions === 0) return
273
-        if (arr.length > 1 && arr[1].length > Number(this.field.precisions)) {
274
-          this.$message.error(`默认值的小数位不能大于${this.field.precisions}`)
275
-          this.field.default_value = null
276
-        }
277
-      }
268
+      //   // null 不支持小数  0 不限制小数位
269
+      //   if (isEmpty(this.field.precisions)) {
270
+      //     this.field.default_value = arr[0]
271
+      //     return
272
+      //   }
273
+      //   if (this.field.precisions === 0) return
274
+      //   if (arr.length > 1 && arr[1].length > Number(this.field.precisions)) {
275
+      //     this.$message.error(`默认值的小数位不能大于${this.field.precisions}`)
276
+      //     this.field.default_value = null
277
+      //   }
278
+      // }
278 279
     },
279 280
 
280 281
     /**

+ 1
- 1
src/views/admin/fields/components/SettingField/index.vue 查看文件

@@ -117,7 +117,7 @@
117 117
         </div>
118 118
 
119 119
         <div
120
-          v-if="fieldAuth.uniqueEdit"
120
+          v-if="fieldAuth.uniqueEdit && !['checkbox','file'].includes(field.form_type)"
121 121
           class="item-check-section">
122 122
           <el-checkbox
123 123
             v-model="field.is_unique"

+ 71
- 0
src/views/admin/fields/index.vue 查看文件

@@ -120,6 +120,7 @@ import Field from './field'
120 120
 import FieldTypeLib from './fieldTypeLib'
121 121
 import { objDeepCopy } from '@/utils/index'
122 122
 import { typeToComponent } from './utils'
123
+import { regexIsCRMMobile, regexIsCRMEmail } from '@/utils'
123 124
 
124 125
 export default {
125 126
   name: 'FieldsIndex',
@@ -504,6 +505,7 @@ export default {
504 505
       const copyField = objDeepCopy(field)
505 506
       delete copyField.field_id
506 507
       delete copyField.fieldName
508
+      delete copyField.field
507 509
       delete copyField.relevant
508 510
       copyField.field_type = 0
509 511
       copyField.operating = 255
@@ -734,6 +736,75 @@ export default {
734 736
         if (item.hasOwnProperty('optionsData')) {
735 737
           delete item.optionsData
736 738
         }
739
+
740
+        if (item.form_type === 'mobile' && item.default_value) {
741
+        // 校验手机号
742
+          if (!regexIsCRMMobile(item.default_value)) {
743
+            this.$message.error('输入的手机格式有误')
744
+            this.loading = false
745
+            return
746
+          }
747
+        }
748
+        if (item.form_type === 'email' && item.default_value) {
749
+        // 校验邮箱
750
+          if (!regexIsCRMEmail(item.default_value)) {
751
+            this.$message.error('输入的邮箱格式有误')
752
+
753
+            this.loading = false
754
+            return
755
+          }
756
+        }
757
+        if (item.form_type === 'number' && item.default_value) {
758
+          // 校验数字类型
759
+          const num = Number(item.default_value) // 去0
760
+          if (isNaN(num)) {
761
+            this.$message.error('数字输入错误')
762
+            this.loading = false
763
+            return
764
+          }
765
+          item.default_value = String(num)
766
+          const arr = String(num).split('.')
767
+
768
+          const len = String(num)
769
+            .replace('.', '')
770
+            .replace('-', '')
771
+            .length
772
+          const maxlength = item.form_type === 'percent' ? 10 : 15
773
+          if (len > maxlength) {
774
+            this.$message.error(`最多支持${maxlength}位数字(包含小数位)`)
775
+
776
+            this.loading = false
777
+            return
778
+          }
779
+
780
+          const min = isEmpty(item.minNumRestrict) ? -Infinity : Number(item.minNumRestrict || -Infinity)
781
+          const max = isEmpty(item.maxNumRestrict) ? Infinity : Number(item.maxNumRestrict || Infinity)
782
+          if (num < min) {
783
+            this.$message.error('默认值不能小于最小值')
784
+
785
+            this.loading = false
786
+            return
787
+          }
788
+          if (num > max) {
789
+            this.$message.error('默认值不能大于最大值')
790
+
791
+            this.loading = false
792
+            return
793
+          }
794
+
795
+          // null 不支持小数  0 不限制小数位
796
+          if (isEmpty(item.precisions)) {
797
+            this.loading = false
798
+            return
799
+          }
800
+          if (item.precisions === 0) return
801
+          if (arr.length > 1 && arr[1].length > Number(item.precisions)) {
802
+            this.$message.error(`默认值的小数位不能大于${item.precisions}`)
803
+
804
+            this.loading = false
805
+            return
806
+          }
807
+        }
737 808
       }
738 809
 
739 810
       // 请求参数

+ 2
- 2
src/views/crm/components/CRMEditBaseInfo.vue 查看文件

@@ -733,7 +733,7 @@ export default {
733 733
     editClick(item) {
734 734
       let dataValue = objDeepCopy(this.allForm[item.fieldName])
735 735
       // 明细表格是空时,需要填充一条空数据,展示时未处理。这里增加
736
-      if (item.formType === 'detail_table' && isEmpty(dataValue)) {
736
+      if (item.form_type === 'detail_table' && isEmpty(dataValue)) {
737 737
         dataValue = this.getItemValue(objDeepCopy(item), null, 'update')
738 738
       }
739 739
       this.$set(this.editForm, item.fieldName, dataValue)
@@ -784,7 +784,7 @@ export default {
784 784
       for (let index = 0; index < this.editFieldData.length; index++) {
785 785
         const field = this.editFieldData[index]
786 786
         // 获取当前编辑 和 隐藏的字段
787
-        if (field.formType !== 'desc_text' && (field.isEdit || !field.show)) {
787
+        if (field.form_type !== 'desc_text' && (field.isEdit || !field.show)) {
788 788
           list.push({
789 789
             fieldName: field.fieldName,
790 790
             field: field.field,

+ 18
- 0
src/views/crm/components/FilterForm/index.vue 查看文件

@@ -667,6 +667,24 @@ export default {
667 667
             // start: new Date(o.value[0]).getTime() / 1000,
668 668
             // end: new Date(o.value[1]).getTime() / 1000
669 669
           })
670
+        } else if (
671
+          o.form_type == 'number' ||
672
+          o.form_type == 'floatnumber' ||
673
+          o.form_type == 'percent'
674
+        ) {
675
+          let dataValues = []
676
+          if (o.type === 14) {
677
+            dataValues = [isEmpty(o.min) ? '' : o.min, isEmpty(o.max) ? '' : o.max]
678
+          } else {
679
+            dataValues = [o.value]
680
+          }
681
+          obj.push({
682
+            condition: o.condition,
683
+            form_type: o.form_type,
684
+            name: o.name,
685
+            type: o.field,
686
+            value: dataValues
687
+          })
670 688
         } else if (o.form_type == 'business_type') {
671 689
           obj.push({
672 690
             // condition: o.condition,