agilebuilder-ui 1.0.90-tmp182 → 1.0.90-tmp183

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": "agilebuilder-ui",
3
- "version": "1.0.90-tmp182",
3
+ "version": "1.0.90-tmp183",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./lib/super-ui.js",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div>
2
+ <span>
3
3
  <template v-if="!disabled">
4
4
  <template v-if="!isMobile">
5
5
  <el-input
@@ -120,7 +120,7 @@
120
120
  <template v-else>
121
121
  <fs-preview :entity="row" :file-set-obj="fileSetObj" :is-sql="isSql" :label="value" />
122
122
  </template>
123
- </div>
123
+ </span>
124
124
  </template>
125
125
 
126
126
  <script>
@@ -1267,6 +1267,85 @@ const apis = {
1267
1267
  const gridParams = store.get(listCode)
1268
1268
  gridParams.options['subTableData'] = null
1269
1269
  this.fetchListData()
1270
+ },
1271
+ /**
1272
+ * v10 行编辑时动态控制字段的编辑权限
1273
+ * @param pageContext 页面解析的上下文对象
1274
+ * @param customRules 格式如下:
1275
+ * [
1276
+ {
1277
+ name: '_all_fields', // _all_fields 表示所有字段
1278
+ disabled: true,
1279
+ required: true,
1280
+ rules: [
1281
+ {
1282
+ required: true,
1283
+ trigger: 'blur'
1284
+ },
1285
+ {
1286
+ type: 'email',
1287
+ trigger: ['blur', 'change']
1288
+ }
1289
+ ]
1290
+ },
1291
+ {
1292
+ name: 'xxxx',
1293
+ disabled: true,
1294
+ required: true,
1295
+ rules: [
1296
+ {
1297
+ required: true,
1298
+ message: 'Please input email address',
1299
+ trigger: 'blur'
1300
+ },
1301
+ {
1302
+ type: 'email',
1303
+ message: 'Please input correct email address',
1304
+ trigger: ['blur', 'change']
1305
+ }
1306
+ ]
1307
+ }
1308
+ ]
1309
+ */
1310
+ dynamicControlTableEdit(pageContext, customRules, listCode){
1311
+ const gridParams = store.get(listCode)
1312
+ // console.log('dynamicControlTableEdit----customRules-----', customRules, gridParams.options.customRules)
1313
+ if(!customRules){
1314
+ return
1315
+ }
1316
+ let gridCustomRules = {}
1317
+ if(gridParams.options.customRules){
1318
+ gridCustomRules = JSON.parse(JSON.stringify(gridParams.options.customRules))
1319
+ }
1320
+ customRules.forEach(item=>{
1321
+ const copyItem = JSON.parse(JSON.stringify(item))
1322
+ const prop = item.name
1323
+ // 当前列新的自定义规则集合
1324
+ let columnRules
1325
+ if(!gridCustomRules[prop]){
1326
+ gridCustomRules[prop] = {}
1327
+ }
1328
+ // console.log('dynamicControlTableEdit----gridCustomRules111-----', gridCustomRules)
1329
+ // 获得当前列已有的自定义规则集合
1330
+ columnRules = gridCustomRules[prop].rules
1331
+
1332
+ if(copyItem.rules){
1333
+ if(!columnRules){
1334
+ columnRules = []
1335
+ }
1336
+ // 将当前列自定义规则集合拼接到已有的自定义规则集合中
1337
+ columnRules = columnRules.concat(copyItem.rules)
1338
+ }
1339
+ // 当前列总的自定义规则更新
1340
+ copyItem.rules = columnRules
1341
+ // this.options.customRules[prop] = copyItem
1342
+ if(!gridParams.options.customRules){
1343
+ gridParams.options.customRules = {}
1344
+ }
1345
+ // console.log('dynamicControlTableEdit----gridParams.options.customRules222-----', gridParams.options.customRules)
1346
+ gridParams.options.customRules[prop] = copyItem
1347
+ })
1348
+ // console.log('dynamicControlTableEdit----gridParams.options.customRules333-----', gridParams.options.customRules)
1270
1349
  }
1271
1350
  }
1272
1351
  export default apis
@@ -441,7 +441,6 @@ import { $emit } from '../../utils/gogocodeTransfer'
441
441
  import eventBus from './eventBus'
442
442
  import { isMobileBrowser } from '../../../src/utils/common-util'
443
443
  import { analysisScanValue, setScanAnalysisValue } from './scan-util.ts'
444
-
445
444
  export default {
446
445
  name: 'DynamicInput',
447
446
  components: {
@@ -465,6 +464,7 @@ export default {
465
464
  type: Object,
466
465
  default: null
467
466
  },
467
+ // 下拉选选项集合
468
468
  options: {
469
469
  type: Array,
470
470
  default: null
@@ -498,6 +498,11 @@ export default {
498
498
  disabled: {
499
499
  type: Boolean,
500
500
  default: false
501
+ },
502
+ // 列表配置信息
503
+ gridOptions: {
504
+ type: Object,
505
+ default: null
501
506
  }
502
507
  },
503
508
  data() {
@@ -737,6 +742,25 @@ export default {
737
742
  }
738
743
  }
739
744
  this.getDateAllowTime()
745
+ if(!this.gridOptions.customRules){
746
+ this.gridOptions.customRules = {}
747
+ }
748
+ this.$watch('gridOptions.customRules.'+this.column.prop,
749
+ (newVal, oldVal)=> {
750
+ this.packageCustomRules(newVal)
751
+ },
752
+ {
753
+ immediate: true,
754
+ deep: true,
755
+ })
756
+ this.$watch('gridOptions.customRules._all_fields',
757
+ (newVal, oldVal)=> {
758
+ this.packageCustomRules(newVal)
759
+ },
760
+ {
761
+ immediate: true,
762
+ deep: true,
763
+ })
740
764
  },
741
765
  mounted() {
742
766
  // 去掉该监听,否则导致焦点总是跳到第一个编辑框
@@ -1797,6 +1821,18 @@ export default {
1797
1821
  this.isShowBrowserScan = false
1798
1822
  this.innerValue = value
1799
1823
  this.blurEvent()
1824
+ },
1825
+ packageCustomRules(columnRule) {
1826
+ console.log('packageCustomRules---columnRule=', columnRule)
1827
+ if(!columnRule){
1828
+ return
1829
+ }
1830
+ if(columnRule.disabled !== undefined){
1831
+ this.$emit('change-disabled', columnRule.disabled)
1832
+ }
1833
+ if(columnRule.required !== undefined){
1834
+ this.$emit('change-required', columnRule.required)
1835
+ }
1800
1836
  }
1801
1837
  }
1802
1838
  }
@@ -87,41 +87,100 @@ function getValidator(listCode) {
87
87
  }
88
88
  const gridParams = store.get(listCode)
89
89
  const editFieldInfos = gridParams.columns
90
+ const customRules = gridParams.options.customRules
90
91
  const rules = {}
91
92
  if (editFieldInfos) {
92
93
  editFieldInfos.forEach((editField) => {
93
- setRules(rules, editField, listCode)
94
+ setRules(rules, editField, listCode, customRules)
94
95
  })
95
96
  }
96
97
  // console.log('rules', rules)
97
98
  return rules
98
99
  }
99
100
 
100
- function setRules(rules, editField, listCode) {
101
+ function setRules(rules, editField, listCode, customRules) {
101
102
  const prop = editField.prop
102
103
  if (editField.groupHeader && editField.children && editField.children.length > 0) {
103
104
  // 组合表头时或者动态列,递归设置规则,
104
105
  editField.children.forEach((child) => {
105
- setRules(rules, child, listCode)
106
+ setRules(rules, child, listCode, customRules)
106
107
  })
107
108
  } else {
108
- if (prop && editField.validations && !isDisableEdit(prop, listCode)) {
109
- const validations = JSON.parse(editField.validations)
110
- validations.forEach((item) => {
111
- if (item.pattern) {
112
- // 后台传递的是正则字符串,不能直接使用
113
- item.pattern = new RegExp(item.pattern)
109
+ if(prop) {
110
+ // 获得当前列的自定义校验规则
111
+ const columnCustomRules = getColumnCustomRules(editField, customRules)
112
+ if ((columnCustomRules || editField.validations) && !isDisableEdit(prop, listCode)) {
113
+ let validations = editField.validations? JSON.parse(editField.validations): []
114
+ validations.forEach((item) => {
115
+ if (item.pattern) {
116
+ // 后台传递的是正则字符串,不能直接使用
117
+ item.pattern = new RegExp(item.pattern)
118
+ }
119
+ })
120
+ validations = validations.concat(columnCustomRules)
121
+ if (prop.indexOf('.') > 0) {
122
+ setObjectPropRule(editField, rules, validations)
123
+ } else {
124
+ if (validations && validations.length > 0) {
125
+ rules[prop] = [...validations]
126
+ }
114
127
  }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ /**
133
+ * 获得当前列的自定义校验规则
134
+ * @param {*} editField
135
+ * @param {*} customRules
136
+ * @returns
137
+ */
138
+ function getColumnCustomRules(editField, customRules) {
139
+ const prop = editField.prop
140
+ let columnCustomRules = []
141
+ let requiredRule
142
+ const allFieldsName = '_all_fields'
143
+ let columnRule
144
+ if(customRules){
145
+ columnRule = customRules[prop]? customRules[prop]: customRules[allFieldsName]
146
+ }
147
+ if(columnRule && (columnRule.required || columnRule.rules)) {
148
+ // 表示配置的必填或其它验证规则时
149
+ const mustFillMsg = getI18n().t('imatrixUIMessage.mustFill', {
150
+ label: editField.label
151
+ })
152
+ columnCustomRules = columnRule.rules? JSON.parse(JSON.stringify(columnRule.rules)): null
153
+ if(columnCustomRules && columnCustomRules.length > 0){
154
+ // 获得必填验证规则
155
+ const requiredRules = columnCustomRules.filter(item=>item.required)
156
+ if(requiredRules && requiredRules.length > 0){
157
+ requiredRule = requiredRules[0]
158
+ }
159
+ }
160
+ if(columnRule.name === allFieldsName && columnCustomRules){
161
+ // 所有字段_all_fields的验证的message更新,补充“label”
162
+ columnCustomRules.forEach(item=>{
163
+ item.message = editField.label + item.message
115
164
  })
116
- if (prop.indexOf('.') > 0) {
117
- setObjectPropRule(editField, rules, validations)
118
- } else {
119
- if (validations && validations.length > 0) {
120
- rules[prop] = [...validations]
121
- }
165
+ }
166
+ if(!requiredRule && columnRule.required) {
167
+ // 当rules中没有配置必填验证,但是有required为true时,则封装必填验证规则,到集合中
168
+ if(!columnCustomRules){
169
+ columnCustomRules = []
122
170
  }
171
+ requiredRule = {
172
+ required: true,
173
+ message: mustFillMsg,
174
+ trigger: 'blur'
175
+ }
176
+ columnCustomRules.push(requiredRule)
177
+ }
178
+ if(requiredRule && !requiredRule.message) {
179
+ // 如果必填验证规则中message为空时,封装默认的必填验证规则,'_all_fields'可能会为空
180
+ requiredRule.message = mustFillMsg
123
181
  }
124
182
  }
183
+ return columnCustomRules
125
184
  }
126
185
  /**
127
186
  * 验证实体
@@ -4,13 +4,14 @@
4
4
  <dynamic-input
5
5
  v-if="(lineEdit.editable && isEditable && row.$editing) || isShowForm"
6
6
  v-model:value="row[column.prop]"
7
- :class="isRequired(row.$editing) ? 'm-requried' : ''"
7
+ :class="requiredClass"
8
8
  :column="column"
9
9
  :is-sql="isSql"
10
10
  :line-edit="lineEdit"
11
11
  :list-code="listCode"
12
12
  :list-toolbar-form-data="listToolbarFormData"
13
13
  :options="column.valueSet"
14
+ :grid-options="options"
14
15
  :position="{
15
16
  row: rowIndex,
16
17
  prop: column.prop
@@ -28,6 +29,7 @@
28
29
  @refresPortData="refresPortData"
29
30
  @refresPortsData="refresPortsData"
30
31
  @change-disabled="changeDisabled"
32
+ @change-required="changeRequired"
31
33
  />
32
34
  <span v-else>
33
35
  <span v-if="column.operations" class="grid-operation-buttons">
@@ -117,6 +119,7 @@
117
119
  :value="getCellValue(row)"
118
120
  :additional-param-map="additionalParamMap"
119
121
  :additional-settings="additionalSettings"
122
+ :pageContext="options.pageContext"
120
123
  />
121
124
  </span>
122
125
  <!-- 自定义格式的时候 -->
@@ -153,6 +156,7 @@
153
156
  :listCode="listCode"
154
157
  :component-id="componentId"
155
158
  :additional-settings="additionalSettings"
159
+ :pageContext="options.pageContext"
156
160
  @prohibitToEdit="prohibitToEdit"
157
161
  @refresh-list="refreshList"
158
162
  /></span>
@@ -460,6 +464,7 @@ export default {
460
464
  data() {
461
465
  let parentFormData
462
466
  const gridParams = store.get(this.listCode)
467
+ const options = gridParams.options
463
468
  if (gridParams.options.extraParam && gridParams.options.extraParam.entityMap) {
464
469
  parentFormData = gridParams.options.extraParam.entityMap
465
470
  }
@@ -474,6 +479,10 @@ export default {
474
479
  scanEnable = true
475
480
  }
476
481
  const componentId = this.listCode + '_' + this.column.prop
482
+ let lineEdit
483
+ if (gridParams.lineEdit !== null && gridParams.lineEdit !== undefined) {
484
+ lineEdit = gridParams.lineEdit
485
+ }
477
486
  return {
478
487
  selectRow: null,
479
488
  that: this,
@@ -502,80 +511,25 @@ export default {
502
511
  scanEnable,
503
512
  componentId,
504
513
  controlConfig,
505
- rowLinkConfigMapping: {}
514
+ rowLinkConfigMapping: {},
515
+ requiredClass: '',
516
+ lineEdit,
517
+ options
506
518
  }
507
519
  },
508
520
  computed: {
509
- filters() {
510
- if (this.column.filterable) {
511
- const gridParams = store.get(this.listCode)
512
- const values = getColumnValues(gridParams.gridData, this.column.prop)
513
- const filters = []
514
- for (const value of values) {
515
- filters.push({
516
- text: value,
517
- value
518
- })
519
- }
520
- return filters
521
- } else {
522
- return null
523
- }
524
- },
525
- filterMethod() {
526
- if (this.column.filterable) {
527
- return this.filterHandler
528
- } else {
529
- return null
530
- }
531
- },
532
- fixed() {
533
- if (
534
- (this.column.fixed && this.column.fixed === 'false') ||
535
- this.column.fixed === undefined ||
536
- this.column.fixed === ''
537
- ) {
538
- return false
539
- }
540
- if (this.column.prop === 'operation' && this.column.fixed && this.column.fixed === 'left') {
541
- // 操作列居右固定
542
- return 'right'
543
- }
544
- return this.column.fixed
545
- },
546
- sortable() {
547
- const gridParams = store.get(this.listCode)
548
- if (
549
- gridParams &&
550
- gridParams.options &&
551
- gridParams.options.isFormSubTable &&
552
- gridParams.options.showOperationButton
553
- ) {
554
- return false
555
- }
556
- if (this.column.sortable === 'false' || this.column.sortable === false || this.column.sortable === '') {
557
- return false
558
- } else if (this.column.sortable === 'true' || this.column.sortable === true) {
559
- return 'custom'
560
- }
561
- if (this.column.sortable) {
562
- return 'custom'
563
- } else {
564
- return false
565
- }
566
- },
567
- lineEdit() {
568
- let isLineEdit = false
569
- if (this.listCode) {
570
- const gridParams = store.get(this.listCode)
571
- if (gridParams.lineEdit !== null && gridParams.lineEdit !== undefined) {
572
- isLineEdit = gridParams.lineEdit
573
- } else {
574
- isLineEdit = false
575
- }
576
- }
577
- return isLineEdit
578
- },
521
+ // lineEdit() {
522
+ // let isLineEdit = false
523
+ // if (this.listCode) {
524
+ // const gridParams = store.get(this.listCode)
525
+ // if (gridParams.lineEdit !== null && gridParams.lineEdit !== undefined) {
526
+ // isLineEdit = gridParams.lineEdit
527
+ // } else {
528
+ // isLineEdit = false
529
+ // }
530
+ // }
531
+ // return isLineEdit
532
+ // },
579
533
 
580
534
  ...mapGetters(['preventReclick'])
581
535
  },
@@ -661,6 +615,7 @@ export default {
661
615
  }
662
616
  }
663
617
  this.setScanRuleSets()
618
+ this.requiredClass = this.isRequired(this.row.$editing) ? 'm-requried' : ''
664
619
  },
665
620
  mounted() {
666
621
  // 监听保存时点击按钮事件线触发
@@ -926,6 +881,7 @@ export default {
926
881
  tableName,
927
882
  this.listCode
928
883
  )
884
+ debugger
929
885
  if (hyperLinkResult.jumpPageSetting && rowIndex !== undefined) {
930
886
  this.rowLinkConfigMapping[rowIndex] = hyperLinkResult.jumpPageSetting
931
887
  }
@@ -1019,7 +975,15 @@ export default {
1019
975
  }
1020
976
  },
1021
977
  isRequired(editing) {
1022
- if (!this.isFormSubTable && this.lineEdit.editable && this.isEditable && editing && this.column.validations) {
978
+ console.log('isRequired---this.lineEdit=', this.lineEdit)
979
+ if (
980
+ !this.isFormSubTable &&
981
+ this.lineEdit &&
982
+ this.lineEdit.editable &&
983
+ this.isEditable &&
984
+ editing &&
985
+ this.column.validations
986
+ ) {
1023
987
  if (this.column.validations.indexOf('"required":true') > 0) {
1024
988
  return true
1025
989
  }
@@ -1071,6 +1035,9 @@ export default {
1071
1035
  this.column._scanRuleSets = res
1072
1036
  })
1073
1037
  }
1038
+ },
1039
+ changeRequired(required) {
1040
+ this.requiredClass = required ? 'm-requried' : ''
1074
1041
  }
1075
1042
  },
1076
1043
  emits: ['refresData', 'refresPortData', 'refresPortsData', 'refresMainTableFields', 'prohibitToEdit']
@@ -1087,7 +1054,7 @@ export default {
1087
1054
  .m-requried {
1088
1055
  float: left;
1089
1056
  white-space: nowrap;
1090
- width: 100%;
1057
+ width: 96%;
1091
1058
  }
1092
1059
 
1093
1060
  .m-requried::after {
@@ -336,6 +336,10 @@ export default {
336
336
  return this.column.width ? this.column.width + '' : '130'
337
337
  },
338
338
  // 设置字段禁止编辑
339
+ fnProhibitToEdit(isEditable) {
340
+ this.$refs[this.column.prop].fnProhibitToEdit(isEditable)
341
+ },
342
+ // 设置字段禁止编辑
339
343
  prohibitToEdit(entity) {
340
344
  $emit(this, 'prohibitToEdit', entity)
341
345
  },
@@ -355,20 +359,4 @@ export default {
355
359
  </script>
356
360
 
357
361
  <style lang="scss" scoped>
358
- .annex-cell {
359
- padding-right: 5px;
360
- cursor: pointer;
361
- color: #409eff;
362
- }
363
-
364
- .m-requried {
365
- float: left;
366
- white-space: nowrap;
367
- width: 100%;
368
- }
369
-
370
- .m-requried::after {
371
- content: '*';
372
- color: #f56c6c;
373
- }
374
362
  </style>
@@ -3156,7 +3156,10 @@ export default {
3156
3156
  openFold(isOpen) {
3157
3157
  this.resizeTableHeight()
3158
3158
  },
3159
- // 设置字段禁止编辑
3159
+ /**
3160
+ * 设置字段禁止编辑。只能控制禁止编辑。不能控制必填
3161
+ * @param entity 格式如:{'NAME':false,"DYM_COLUMN":true}。表示NAME字段不可编辑,DYM_COLUMN可以被编辑
3162
+ */
3160
3163
  fnProhibitToEdit(entity) {
3161
3164
  if (entity) {
3162
3165
  if (entity.isForceUpdate) {
@@ -3174,7 +3177,10 @@ export default {
3174
3177
  }
3175
3178
  }
3176
3179
  },
3177
- // 设置字段禁止编辑
3180
+ /**
3181
+ * 设置字段禁止编辑。只能控制禁止编辑。不能控制必填
3182
+ * @param entity 格式如:{'NAME':false,"DYM_COLUMN":true}。表示NAME字段不可编辑,DYM_COLUMN可以被编辑
3183
+ */
3178
3184
  prohibitToEdit(entity) {
3179
3185
  this.fnProhibitToEdit(entity)
3180
3186
  },
@@ -3340,8 +3346,7 @@ export default {
3340
3346
  'un-edit',
3341
3347
  'refresMainTableFields',
3342
3348
  'refresh',
3343
- 'cancel-search',
3344
- ,
3349
+ 'cancel-search'
3345
3350
  ],
3346
3351
  }
3347
3352
  </script>
@@ -262,6 +262,15 @@ export function isDisableEdit(prop, listCode, row) {
262
262
  isDiabled = true
263
263
  }
264
264
  }
265
+ if (isDiabled === false) {
266
+ // 表示不是禁止编辑的,继续校验自定义规则中是否是禁止编辑的
267
+ if(gridParams.options.customRules && (gridParams.options.customRules[prop] || gridParams.options.customRules['_all_fields'])){
268
+ const columnRules = gridParams.options.customRules[prop]? gridParams.options.customRules[prop]: gridParams.options.customRules['_all_fields']
269
+ if(columnRules && columnRules.disabled){
270
+ isDiabled = true
271
+ }
272
+ }
273
+ }
265
274
  }
266
275
  return isDiabled
267
276
  }
@@ -83,7 +83,8 @@ const cn = {
83
83
  forbiddenExceptionLinkUrl: '请点击进行权限申请',
84
84
  forbiddenExceptionLinkUser: '如有疑问请联系',
85
85
  uploadFileTip: '上传的文件不超过{fileSize}M',
86
- asyncExportJumpMsg: '或点击我跳转到下载页面'
86
+ asyncExportJumpMsg: '或点击我跳转到下载页面',
87
+ mustFill: '{label} 必须填写'
87
88
  },
88
89
  // 列表组件
89
90
  superGrid: {
@@ -85,7 +85,8 @@ const en = {
85
85
  forbiddenExceptionLinkUrl: 'please click to apply',
86
86
  forbiddenExceptionLinkUser: 'if you have any questions,please contact',
87
87
  uploadFileTip: 'The file size should lower {fileSize}M',
88
- asyncExportJumpMsg: 'Or click me to jump to download page.'
88
+ asyncExportJumpMsg: 'Or click me to jump to download page.',
89
+ mustFill: '{label} must fill'
89
90
  },
90
91
  superGrid: {
91
92
  columnConfig: 'Column Config',