bri-components 1.2.35 → 1.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bri-components",
3
- "version": "1.2.35",
3
+ "version": "1.2.36",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -593,22 +593,7 @@
593
593
  // 是否显示 单元格校验提示文字
594
594
  getRuleResult (col, row, showRuleMessage = this.showRuleMessage) {
595
595
  if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || showRuleMessage) {
596
- const val = row[col._key];
597
- const ruleConfig = this.$getFieldRuleConfig(col);
598
- // 为空 校验必填;不为空 格式校验 (不是必填也要校验格式)
599
- return this.$isEmptyData(val)
600
- ? {
601
- bool: !col._required,
602
- message: `${col._name}为必填项`
603
- }
604
- : ruleConfig.regs && ruleConfig.regs.length
605
- ? {
606
- bool: ruleConfig.regs.every(regItem => regItem.test(val)),
607
- message: col._regMessage || `${col._name}格式不正确`
608
- }
609
- : {
610
- bool: true
611
- };
596
+ return this.$getFieldRuleResult(col, row);
612
597
  } else {
613
598
  return {
614
599
  bool: true
@@ -5,6 +5,7 @@
5
5
  :model="formData"
6
6
  :rules="showRules ? rules : {}"
7
7
  @submit.native.prevent
8
+ @on-validate="validateCb"
8
9
  >
9
10
  <Row>
10
11
  <template v-if="displayFormList.length">
@@ -21,7 +22,7 @@
21
22
  @click.native="clickControl(formItem)"
22
23
  >
23
24
  <dsh-form-unit
24
- ref="dshFormItem"
25
+ ref="dshFormUnit"
25
26
  :canEdit="canEdit"
26
27
  :formData="formData"
27
28
  :formItem="formItem"
@@ -99,11 +100,11 @@
99
100
  DshFormUnit
100
101
  },
101
102
  props: {
102
- // 启用该参数后,查看状态时,空值字段不显示
103
- notShowEmpty: {
104
- type: Boolean,
105
- default: false
106
- },
103
+ // // 启用该参数后,查看状态时,空值字段不显示
104
+ // notShowEmpty: {
105
+ // type: Boolean,
106
+ // default: false
107
+ // },
107
108
  canEdit: {
108
109
  type: Boolean,
109
110
  default: true
@@ -158,6 +159,10 @@
158
159
  data () {
159
160
  return {
160
161
  rules: {},
162
+ errorObj: {
163
+ errors: []
164
+ },
165
+
161
166
  forceValidateTypes: [
162
167
  "select", "cascader", "regions", "cascaders", "file", "coordinates", "editor",
163
168
  "users", "departments", "labels", "flatTable", "reference", "referenceBy"
@@ -205,26 +210,56 @@
205
210
  return this.$refs.form;
206
211
  },
207
212
  submit () {
208
- this.$nextTick(() => {
209
- this.$refs.form.validate((valid) => {
210
- if (valid && this.validate()) {
211
- console.log(valid);
213
+ this.errorObj = {
214
+ errors: []
215
+ };
216
+
217
+ this.$refs.form.validate(valid => {
218
+ // 此函数有时早于某些字段的validateCb,不稳定,所以加setTimeout目的确保最后执行
219
+ setTimeout(() => {
220
+ // if (!valid) {
221
+ // this.displayFormList.forEach(formItem => {
222
+ // const resultObj = this.$getFieldRuleResult(formItem, this.formData);
223
+ // if (resultObj.bool === false) {
224
+ // this.errorObj.errors.push(resultObj);
225
+ // }
226
+ // });
227
+ // }
228
+ const selfValid = this.selfValidate((valid, errorFormList) => {
229
+ if (valid === false) {
230
+ errorFormList.forEach(formItem => {
231
+ this.errorObj.errors.push({
232
+ bool: false,
233
+ message: `${formItem._name} 内部校验不正确!`
234
+ });
235
+ });
236
+ }
237
+ });
238
+
239
+ if (valid && selfValid) {
212
240
  this.rulesSuccess({});
213
241
  } else {
214
- this.rulesFailed({
215
- errors: []
216
- });
242
+ this.rulesFailed(this.errorObj);
217
243
  }
218
- });
244
+ }, 0);
219
245
  });
220
246
  },
221
- // 控件校验
222
- validate (callback) {
247
+ // iview的校验回调
248
+ validateCb (prop, status, error) {
249
+ if (status === false) {
250
+ this.errorObj.errors.push({
251
+ bool: false,
252
+ message: error
253
+ });
254
+ }
255
+ },
256
+ // 控件自己的校验
257
+ selfValidate (callback) {
223
258
  let bool = true;
224
259
  let errorRefs = [];
225
260
 
226
- if (this.$refs.dshFormItem) {
227
- errorRefs = this.$refs.dshFormItem.filter(refItem => !refItem.validate());
261
+ if (this.$refs.dshFormUnit) {
262
+ errorRefs = this.$refs.dshFormUnit.filter(refItem => !refItem.validate());
228
263
  bool = !errorRefs.length;
229
264
  } else {
230
265
  bool = true;
@@ -282,7 +317,7 @@
282
317
  // 格式校验 (不依赖必填)
283
318
  if (ruleConfig.regs.length) {
284
319
  rules.push({
285
- message: formItem._regMessage || `${formItem._name}格式不正确`,
320
+ message: formItem._regMessage || `${formItem._name} 格式不正确!`,
286
321
  trigger: "blur",
287
322
  transform: (val) => {
288
323
  if (this.$isEmptyData(val)) {
@@ -302,7 +337,7 @@
302
337
  fields: {
303
338
  lnglat: {
304
339
  required: true,
305
- message: `${formItem._name}为必填项`,
340
+ message: `${formItem._name} 为必填项!`,
306
341
  type: "array"
307
342
  }
308
343
  }
@@ -311,7 +346,7 @@
311
346
  fields: {
312
347
  list: {
313
348
  required: true,
314
- message: `${formItem._name}不能为空行!`,
349
+ message: `${formItem._name} 不能为空行!`,
315
350
  type: "array"
316
351
  }
317
352
  }
@@ -319,7 +354,7 @@
319
354
  referenceBy: {
320
355
  fields: {
321
356
  count: {
322
- message: `${formItem._name}必须关联数据!`,
357
+ message: `${formItem._name} 必须关联数据!`,
323
358
  type: "number",
324
359
  transform: (val) => {
325
360
  if (val && val > 0) {
@@ -335,7 +370,7 @@
335
370
 
336
371
  rules.push({
337
372
  required: true,
338
- message: `${formItem._name}为必填项!`,
373
+ message: `${formItem._name} 为必填项!`,
339
374
  trigger: "blur, change",
340
375
  type: "string",
341
376
  ...(subFieldsMap[formItem._type] || {}),
@@ -423,22 +423,7 @@
423
423
  // 是否显示 单元格校验提示文字
424
424
  getRuleResult (col, row, showRuleMessage = this.showRuleMessage) {
425
425
  if ((this.ruleRecordMap[`${row._id}dsh${col._key}`] || {}).showRuleMessage || showRuleMessage) {
426
- const val = row[col._key];
427
- const ruleConfig = this.$getFieldRuleConfig(col);
428
- // 为空 校验必填;不为空 格式校验 (不是必填也要校验格式)
429
- return this.$isEmptyData(val)
430
- ? {
431
- bool: !col._required,
432
- message: `${col._name}为必填项`
433
- }
434
- : ruleConfig.regs && ruleConfig.regs.length
435
- ? {
436
- bool: ruleConfig.regs.every(regItem => regItem.test(val)),
437
- message: col._regMessage || `${col._name}格式不正确`
438
- }
439
- : {
440
- bool: true
441
- };
426
+ return this.$getFieldRuleResult(col, row);
442
427
  } else {
443
428
  return {
444
429
  bool: true
@@ -2,6 +2,7 @@
2
2
  <Tabs
3
3
  :class="['DshTabs', `DshTabs-${mode}`]"
4
4
  v-model="curTabKey"
5
+ :animated="false"
5
6
  >
6
7
  <TabPane
7
8
  v-for="tabItem in list"
@@ -67,6 +68,7 @@
67
68
  return this.value;
68
69
  },
69
70
  set (tabKey) {
71
+ // iview的组件有问题,重复点击tab的某一项,set函数还是会触发!
70
72
  if (tabKey !== this.tmpTabKey) {
71
73
  this.init(tabKey);
72
74
 
@@ -96,7 +98,7 @@
96
98
  style: {
97
99
  padding: "0px 16px"
98
100
  }
99
- }, tabItem.name + tabItem._key);
101
+ }, tabItem.name);
100
102
  }
101
103
  : undefined;
102
104
  }
@@ -151,41 +153,23 @@
151
153
 
152
154
  &-bar {
153
155
  height: 100%;
154
- margin: 0;
155
- border-bottom: 0;
156
+ border-bottom: 0px!important;
157
+ margin-bottom: 0px!important;
156
158
 
157
159
  .ivu-tabs-nav-right {
158
- height: 100%;
160
+ margin-top: 8px;
161
+ margin-left: 40px;
159
162
  }
160
163
 
161
164
  .ivu-tabs-nav-container {
162
165
  height: 100%;
166
+ overflow: visible;
163
167
 
164
168
  .ivu-tabs-nav-wrap {
165
- .ivu-tabs-nav-scroll {
166
- .ivu-tabs-nav {
167
- .ivu-tabs-ink-bar {
168
- height: 0;
169
- background-color: #FFF;
170
- }
171
169
 
172
- .ivu-tabs-tab {
173
- padding: 12px 10px;
174
- margin: 0 10px;
175
- font-size: @textSize;
176
-
177
- &-active,
178
- &-focused {
179
- color: @themeColor;
180
- background-color: #FFF;
181
- }
182
- }
183
- }
184
- }
185
-
186
- &.ivu-tabs-nav-scrollable {
187
- .ivu-tabs-nav-prev,
188
- .ivu-tabs-nav-next {
170
+ .ivu-tabs-nav {
171
+ &-prev,
172
+ &-next {
189
173
  height: 100%;
190
174
  display: flex;
191
175
  flex-direction: row;
@@ -197,6 +181,38 @@
197
181
  font-size: @largeTitleSize;
198
182
  }
199
183
  }
184
+
185
+ &-scroll {
186
+ &-disabled {
187
+ display: none;
188
+ }
189
+
190
+ .ivu-tabs-nav {
191
+
192
+ .ivu-tabs-ink-bar {
193
+ height: 0;
194
+ background-color: #FFF;
195
+ }
196
+
197
+ .ivu-tabs-tab {
198
+ // display: inline-block;
199
+ // height: 44px;
200
+ padding: 0px!important;
201
+ margin-right: 1px!important;
202
+ // background-color: #E5E5E5;
203
+ text-align: center;
204
+ line-height: 44px;
205
+ font-size: @textSize;
206
+ color: @titleColor;
207
+
208
+ &-active,
209
+ &-focused {
210
+ color: @themeColor;
211
+ background-color: #FFF;
212
+ }
213
+ }
214
+ }
215
+ }
200
216
  }
201
217
  }
202
218
  }
@@ -209,6 +225,7 @@
209
225
  color: #ffffff;
210
226
 
211
227
  &-bar {
228
+
212
229
  .ivu-tabs-nav-right {
213
230
 
214
231
  }
@@ -216,23 +233,34 @@
216
233
  .ivu-tabs-nav-container {
217
234
 
218
235
  .ivu-tabs-nav-wrap {
219
- .ivu-tabs-nav-scroll {
220
- .ivu-tabs-nav {
221
- .ivu-tabs-ink-bar {
222
236
 
223
- }
237
+ .ivu-tabs-nav {
238
+ &-prev,
239
+ &-next {
240
+ color: #ffffff;
241
+ }
242
+
243
+ &-scroll {
244
+ .ivu-tabs-nav {
245
+
246
+ .ivu-tabs-ink-bar {
224
247
 
225
- .ivu-tabs-tab {
226
- &:hover {
227
- color: #ffffff;
228
248
  }
229
249
 
230
- &-active,
231
- &-focused {
232
- color: @theme-active;
250
+ .ivu-tabs-tab {
251
+ color: #ffffff;
233
252
 
234
253
  &:hover {
254
+ color: #ffffff;
255
+ }
256
+
257
+ &-active,
258
+ &-focused {
235
259
  color: @theme-active;
260
+
261
+ &:hover {
262
+ color: @theme-active;
263
+ }
236
264
  }
237
265
  }
238
266
  }
@@ -247,16 +275,17 @@
247
275
  // 页面编辑版
248
276
  &-page {
249
277
  .ivu-tabs {
278
+
250
279
  &-bar {
251
280
  border-bottom: 0px!important;
252
281
  margin-bottom: 0px!important;
253
- align-items: center;
254
-
255
- .ivu-tabs-nav-wrap {
256
282
 
283
+ .ivu-tabs-nav-right {
284
+ margin-left: 40px;
257
285
  }
258
286
 
259
287
  .ivu-tabs-nav-container {
288
+
260
289
  .ivu-tabs-nav-wrap {
261
290
 
262
291
  .ivu-tabs-nav {
@@ -275,15 +304,17 @@
275
304
  align-items: center;
276
305
 
277
306
  // tab切换下方下划线
278
- .ivu-tabs-ink-bar-animated {
307
+ .ivu-tabs-ink-bar {
279
308
  display: none;
309
+ &-animated {
310
+ display: none;
311
+ }
280
312
  }
281
313
 
282
314
  // tab切换标签
283
315
  .ivu-tabs-tab {
284
316
  display: inline-block;
285
317
  height: 40px;
286
- // width: fit-content;
287
318
  padding: 0px!important;
288
319
  margin-right: 1px!important;
289
320
  background-color: #E5E5E5;
@@ -4,40 +4,41 @@
4
4
  <dsh-draggable
5
5
  v-model="list"
6
6
  class="DshTabsSet-draggable"
7
- :style="{ minWidth: `${list.length * 110}px` }"
7
+ :style="{
8
+ minWidth: `${list.length * 110}px`
9
+ }"
8
10
  @change="$dispatchEvent(operationMap.drag, $event.moved.element, null, list)"
9
11
  >
10
12
  <span
11
13
  v-for="(item, index) in list"
12
14
  :key="item._id"
13
- :class="[
14
- 'DshTabsSet-item',
15
- { 'DshTabsSet-item-normal': item.screenType !== 'all' },
16
- { 'DshTabsSet-item-active': item.screenType !== 'all' && !!curItem && curItem._id === item._id },
17
- { 'DshTabsSet-item-isEdit': item.isEdit }
18
- ]"
15
+ :class="{
16
+ 'item': true,
17
+ 'item-active': !!curItem && curItem._id === item._id ,
18
+ 'item-edit': item.isEdit
19
+ }"
19
20
  @click="$dispatchEvent(operationMap.clickTab, item, index, list)"
20
21
  >
21
22
  <Input
22
23
  v-if="item.isEdit"
24
+ class="item-input"
23
25
  :ref="item._id"
24
- class="DshTabsSet-item-input"
25
26
  v-model="item.name"
26
27
  :placeholder="`输入${theme}名字……`"
27
28
  @on-blur="$dispatchEvent(operationMap.nameBlur, item, index, list)"
28
- @on-change="$dispatchEvent(operationMap.update, item, index, list)"
29
+ @on-change="$dispatchEvent(operationMap.changeVal, item, index, list)"
29
30
  @click.native.stop="0"
30
31
  />
31
32
  <span
32
33
  v-else
33
- class="DshTabsSet-item-name dsh-ellipsis"
34
+ class="item-name dsh-ellipsis"
34
35
  >{{ item.name }}</span>
35
36
 
36
37
  <template v-if="!item.isEdit && item.screenType !== 'all'">
37
38
  <Icon
38
- v-for="operationItem in $getOperationList(['delete', 'clickUpdate'])"
39
+ v-for="operationItem in $getOperationList(['delete', 'update'])"
39
40
  :key="operationItem.type"
40
- :class="[`DshTabsSet-item-${operationItem.type}`]"
41
+ :class="[`item-${operationItem.type}`]"
41
42
  :type="operationItem.icon"
42
43
  :color="operationItem.color"
43
44
  :size="operationItem.size || 18"
@@ -50,11 +51,11 @@
50
51
  --><span
51
52
  v-for="operationItem in $getOperationList(['create'])"
52
53
  :key="operationItem.type"
53
- class="DshTabsSet-item DshTabsSet-item-create"
54
+ class="item item-create"
54
55
  @click="$dispatchEvent(operationItem, null, null, list)"
55
56
  >
56
57
  <Icon
57
- class="DshTabsSet-create-icon"
58
+ class="item-create-icon"
58
59
  :type="operationItem.icon"
59
60
  :color="operationItem.color"
60
61
  :size="operationItem.size"
@@ -119,10 +120,10 @@
119
120
  color: "red",
120
121
  event: "delete"
121
122
  },
122
- update: {
123
+ changeVal: {
123
124
  name: "修改",
124
- type: "update",
125
- event: "update"
125
+ type: "changeVal",
126
+ event: "changeVal"
126
127
  },
127
128
  drag: {
128
129
  name: "拖动",
@@ -130,9 +131,9 @@
130
131
  event: "drag"
131
132
  },
132
133
 
133
- clickUpdate: {
134
+ update: {
134
135
  name: "点击修改",
135
- type: "clickUpdate",
136
+ type: "update",
136
137
  icon: "md-create",
137
138
  size: 12,
138
139
  color: "#1b9aee",
@@ -183,7 +184,7 @@
183
184
  }
184
185
  },
185
186
  // 修改
186
- update (operationItem, data, index, list) {
187
+ changeVal (operationItem, data, index, list) {
187
188
  this.change();
188
189
  },
189
190
  // 拖动
@@ -236,7 +237,7 @@
236
237
  display: flex;
237
238
  }
238
239
 
239
- &-item {
240
+ .item {
240
241
  display: inline-block;
241
242
  min-width: 110px;
242
243
  height: 100%;
@@ -248,22 +249,9 @@
248
249
  cursor: pointer;
249
250
  overflow: hidden;
250
251
  position: relative;
251
- &-normal:hover,
252
- &-isEdit,
253
- &-active {
254
- background-color: @bgColor;
255
- font-weight: 600;
256
- color: #515a6e;
257
- }
258
- &:hover {
259
- .DshTabsSet-item-delete,
260
- .DshTabsSet-item-clickUpdate {
261
- display: inline-block;
262
- }
263
- }
264
252
 
265
253
  &-delete,
266
- &-clickUpdate {
254
+ &-update {
267
255
  display: none;
268
256
  padding: 2px;
269
257
  position: absolute;
@@ -272,7 +260,7 @@
272
260
  &-delete {
273
261
  top: 2px;
274
262
  }
275
- &-clickUpdate {
263
+ &-update {
276
264
  bottom: 2px;
277
265
  }
278
266
  &-create {
@@ -282,30 +270,40 @@
282
270
  &-icon {}
283
271
  }
284
272
 
285
- &-name {}
286
- &-input {}
287
- }
288
- }
289
-
290
- .DshTabsSet {
291
- .ivu-input-wrapper {
292
- vertical-align: baseline;
293
- }
294
- &-item-input {
295
- .ivu-input {
296
- min-width: 150px;
297
- height: 18px;
298
- padding: 3px;
299
- border: none;
300
- border-radius: 0px;
273
+ &:hover,
274
+ &-active,
275
+ &-edit {
301
276
  background-color: @bgColor;
302
- line-height: 16px;
303
- font-size: 12px;
277
+ font-weight: 600;
304
278
  color: #515a6e;
305
- &:focus {
306
- box-shadow: none;
279
+ }
280
+ &:hover {
281
+ .item-delete,
282
+ .item-update {
283
+ display: inline-block;
307
284
  }
308
285
  }
286
+
287
+ &-input {
288
+ .ivu-input-wrapper {
289
+ vertical-align: baseline;
290
+ }
291
+ .ivu-input {
292
+ min-width: 150px;
293
+ height: 18px;
294
+ padding: 3px;
295
+ border: none;
296
+ border-radius: 0px;
297
+ background-color: @bgColor;
298
+ line-height: 16px;
299
+ font-size: 12px;
300
+ color: #515a6e;
301
+ &:focus {
302
+ box-shadow: none;
303
+ }
304
+ }
305
+ }
306
+ &-name {}
309
307
  }
310
308
  }
311
309
  </style>