agilebuilder-ui 1.1.37 → 1.1.38

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.
@@ -210,7 +210,8 @@ import {
210
210
  isEditOptionFunction,
211
211
  isHasEditOption,
212
212
  isHasOptionFunction,
213
- isObjectValueEqual
213
+ isObjectValueEqual,
214
+ rowBeforeValidate
214
215
  } from './utils'
215
216
  import Sortable from 'sortablejs'
216
217
  import store from './store'
@@ -2775,10 +2776,28 @@ export default {
2775
2776
  gridData = this.subTableData
2776
2777
  }
2777
2778
  if (gridData && gridData.length > 0) {
2779
+ const gridParams = store.get(this.code)
2780
+ const customRules = gridParams.options.customRules
2778
2781
  const pageSize = this.pagination && this.pagination.pageSize
2779
2782
  const validateRules = formValidatorService.getValidator(this.code)
2780
2783
  for (let i = 0; i < gridData.length; i++) {
2781
2784
  const row = gridData[i]
2785
+ let rules = validateRules
2786
+ if (customRules) {
2787
+ const propNames = Object.keys(customRules)
2788
+ if (propNames.length > 0) {
2789
+ // 遍历customRules,判断customRules的规则是否有beforeValidate
2790
+ for (const propName of propNames) {
2791
+ if (customRules[propName].beforeValidate) {
2792
+ const result = rowBeforeValidate(customRules[propName], gridParams, row)
2793
+ if (result === false && rules[propName]) {
2794
+ rules = JSON.parse(JSON.stringify(validateRules))
2795
+ rules[propName] = []
2796
+ }
2797
+ }
2798
+ }
2799
+ }
2800
+ }
2782
2801
  // 取消最后一个编辑行的状态
2783
2802
  if (row.$editing !== undefined && row.$editing === true) {
2784
2803
  setEntityFieldValue(row, '$editing', false)
@@ -2788,7 +2807,7 @@ export default {
2788
2807
  let needValidate = true
2789
2808
  if (isHasEditOption('isEnableValidate', this.code)) {
2790
2809
  // 表示配置了是否启用必填验证
2791
- needValidate = this.gridParams.options.lineEditOptions['isEnableValidate']
2810
+ needValidate = gridParams.options.lineEditOptions['isEnableValidate']
2792
2811
  }
2793
2812
  let validateResult = true
2794
2813
  if (needValidate === true) {
@@ -2803,7 +2822,7 @@ export default {
2803
2822
  row,
2804
2823
  this.code,
2805
2824
  i,
2806
- validateRules,
2825
+ rules,
2807
2826
  this.isSubTableShowPage,
2808
2827
  pageNum,
2809
2828
  pageRowIndex
@@ -205,7 +205,7 @@ function getEntityId(row) {
205
205
  }
206
206
 
207
207
  // 行编辑时,是否有权限编辑某字段
208
- export function isDisableEdit(prop, listCode, row) {
208
+ export function isDisableEdit(prop, listCode, row, rowIndex) {
209
209
  if (!listCode) {
210
210
  listCode = store.get('_list_code')
211
211
  }
@@ -271,7 +271,11 @@ export function isDisableEdit(prop, listCode, row) {
271
271
  const columnRules = gridParams.options.customRules[prop]
272
272
  ? gridParams.options.customRules[prop]
273
273
  : gridParams.options.customRules['_all_fields']
274
- if (columnRules && columnRules.disabled) {
274
+ let beforeValidateResult = true
275
+ // if (columnRules.beforeValidate) {
276
+ // beforeValidateResult = rowBeforeValidate(columnRules, gridParams, row, rowIndex)
277
+ // }
278
+ if (columnRules && columnRules.disabled && beforeValidateResult !== false) {
275
279
  isDiabled = true
276
280
  }
277
281
  }
@@ -280,6 +284,16 @@ export function isDisableEdit(prop, listCode, row) {
280
284
  return isDiabled
281
285
  }
282
286
 
287
+ export function rowBeforeValidate(columnRules, gridParams, row) {
288
+ const params = {
289
+ parent: gridParams.options.extraParam.entityMap,
290
+ row: row,
291
+ pageContext: gridParams.options.pageContext,
292
+ configure: gridParams.options.configureObj
293
+ }
294
+ return columnRules.beforeValidate(params)
295
+ }
296
+
283
297
  // 行编辑时,是否必填某字段, 如果是流程表单子表, 需要将列表管理里配置的必填字段去掉,使用流程内的子表编辑权限控制
284
298
  export function isRequiredEdit(column, listCode) {
285
299
  const prop = column.prop
@@ -17,7 +17,7 @@ function packageEnumAndBeanColumnValueSetsWhenPlate(columns, listCode) {
17
17
  return new Promise((resolve, reject) => {
18
18
  const valueSetColumnsInfo = {
19
19
  listCode: listCode,
20
- valueSetMetas: [],
20
+ valueSetMetas: []
21
21
  }
22
22
  const valueSetColumnIndexs = []
23
23
  for (let i = 0; i < columns.length; i++) {
@@ -27,13 +27,11 @@ function packageEnumAndBeanColumnValueSetsWhenPlate(columns, listCode) {
27
27
  let titleValueSet = null
28
28
  const titleValueSetJson = column.titleValueSet
29
29
  if (titleValueSetJson) {
30
- titleValueSet = packageEnumAndBeanColumnValueSet(
31
- JSON.parse(titleValueSetJson)
32
- )
30
+ titleValueSet = packageEnumAndBeanColumnValueSet(JSON.parse(titleValueSetJson))
33
31
  }
34
32
  if (columnValueSet || titleValueSet) {
35
33
  const valueSetMeta = {
36
- prop: prop,
34
+ prop: prop
37
35
  }
38
36
  if (columnValueSet) {
39
37
  // 字段的值设置
@@ -48,17 +46,11 @@ function packageEnumAndBeanColumnValueSetsWhenPlate(columns, listCode) {
48
46
  }
49
47
  if (valueSetColumnsInfo.valueSetMetas.length > 0) {
50
48
  window.$vueApp.config.globalProperties.$http
51
- .post(
52
- window.$vueApp.config.globalProperties.baseURL +
53
- '/common/super-grids/value-sets',
54
- valueSetColumnsInfo
55
- )
49
+ .post(window.$vueApp.config.globalProperties.baseURL + '/common/super-grids/value-sets', valueSetColumnsInfo)
56
50
  .then((columnValueSets) => {
57
51
  valueSetColumnIndexs.forEach((columnIndex) => {
58
52
  let valueSetMap
59
- const prop = columns[columnIndex].prop
60
- ? columns[columnIndex].prop
61
- : columns[columnIndex].label
53
+ const prop = columns[columnIndex].prop ? columns[columnIndex].prop : columns[columnIndex].label
62
54
  for (const prop1 in columnValueSets) {
63
55
  if (prop === prop1) {
64
56
  valueSetMap = columnValueSets[prop]
@@ -70,8 +62,7 @@ function packageEnumAndBeanColumnValueSetsWhenPlate(columns, listCode) {
70
62
  columns[columnIndex].valueSet = valueSetMap.valueSet
71
63
  }
72
64
  if (valueSetMap.titleValueSet) {
73
- columns[columnIndex].titleValueSetValue =
74
- valueSetMap.titleValueSet
65
+ columns[columnIndex].titleValueSetValue = valueSetMap.titleValueSet
75
66
  }
76
67
  }
77
68
  })
@@ -111,7 +102,7 @@ function packageEnumAndBeanColumnValueSet(valueSetInfo) {
111
102
  * 封装值设置为枚举 或 bean方式时的值为'key-value'键值对信息
112
103
  */
113
104
  function packageEnumAndBeanColumnValueSetsWhenOtherSys(columns, listCode, additionalParamMap, entity, systemCode) {
114
- return new Promise((resolve, reject) => {
105
+ return new Promise((resolve, reject) => {
115
106
  const dataSourceList = getDataSourceConfigList(columns)
116
107
  const valueSetColumnIndexs = dataSourceList.valueSetColumnIndexs
117
108
  const param = {
@@ -129,7 +120,7 @@ function packageEnumAndBeanColumnValueSetsWhenOtherSys(columns, listCode, additi
129
120
  .then((result) => {
130
121
  const columnValueSet = result.columnValueSet
131
122
  const columnTitleValueSet = result.columnTitleValueSet
132
- for(let prop in valueSetColumnIndexs){
123
+ for (let prop in valueSetColumnIndexs) {
133
124
  const columnIndex = valueSetColumnIndexs[prop]
134
125
  const valueSet = columnValueSet[prop]
135
126
  if (valueSet) {
@@ -175,7 +166,7 @@ function getDataSourceConfigList(columns) {
175
166
  valueSetColumnIndexs[prop] = i
176
167
  }
177
168
  }
178
- return {dataSourceConfigList, dataSourceConfigListTitle, valueSetColumnIndexs}
169
+ return { dataSourceConfigList, dataSourceConfigListTitle, valueSetColumnIndexs }
179
170
  }
180
171
 
181
172
  function getConfigWithValueSet(valueSetInfo, prop, column) {
@@ -203,41 +194,42 @@ function getConfigWithValueSet(valueSetInfo, prop, column) {
203
194
  }
204
195
  }
205
196
  } else if (beanName && beanName !== '') {
206
- infoObj.type = 'beanName'
207
- infoObj.props = {
208
- prop: prop,
209
- valueSet: BEAN_NAME_PREFIX + beanName
210
- }
211
- }else if(column && column.valueSetOptions) {
212
- // 动态数据源、数据表/视图、服务
197
+ infoObj.type = 'beanName'
198
+ infoObj.props = {
199
+ prop: prop,
200
+ valueSet: BEAN_NAME_PREFIX + beanName
201
+ }
202
+ } else if (column && column.valueSetOptions) {
203
+ // 动态数据源(select开启value-label自动转换或者)、数据表/视图、服务
213
204
  const valueSetOptionsObj = JSON.parse(column.valueSetOptions)
214
- if((valueSetOptionsObj.type || valueSetOptionsObj.dynamicDataSourceCode) && valueSetOptionsObj.valueLabelSwitch){
205
+ if (
206
+ (valueSetOptionsObj.type || valueSetOptionsObj.dynamicDataSourceCode) &&
207
+ (column.componentType === 'radio' || column.componentType === 'checkbox' || valueSetOptionsObj.valueLabelSwitch)
208
+ ) {
215
209
  // 表示是动态数据源等值设置信息
216
210
  // const isShouldInitSearch = (valueSetOptionsObj.filterType === undefined || valueSetOptionsObj.filterType != 'remote')
217
- if(!valueSetOptionsObj.type || valueSetOptionsObj.type !== 'optionGroup'){
211
+ if (!valueSetOptionsObj.type || valueSetOptionsObj.type !== 'optionGroup') {
218
212
  // 选项组时不需要在此处获得
219
213
  Object.assign(infoObj, valueSetOptionsObj)
220
214
  // 更新uuid为字段名
221
215
  infoObj.uuid = prop
222
- if(!infoObj.props){
216
+ if (!infoObj.props) {
223
217
  infoObj.props = {}
224
218
  }
225
219
  infoObj.props.prop = prop
226
220
  }
227
- if(valueSetOptionsObj.dynamicDataSourceCode){
221
+ if (valueSetOptionsObj.dynamicDataSourceCode) {
228
222
  infoObj.type = 'dynamicData'
229
- if(!infoObj.props){
223
+ if (!infoObj.props) {
230
224
  infoObj.props = {}
231
225
  }
232
226
  infoObj.props.code = valueSetOptionsObj.dynamicDataSourceCode
233
227
  }
234
228
  }
235
229
  }
236
- if(infoObj.type){
230
+ if (infoObj.type) {
237
231
  // 表示是有效的值设置
238
232
  return infoObj
239
233
  }
240
234
  return null
241
235
  }
242
-
243
-
@@ -243,6 +243,7 @@ export function getServerConfigUtil(http) {
243
243
  window.$vueApp.config.globalProperties.baseAPI
244
244
  )
245
245
  localStorage.setItem('_baseAPI_', window.$vueApp.config.globalProperties.baseAPI)
246
+ localStorage.setItem('_amb_projectModel_', window.$vueApp.config.globalProperties.projectModel)
246
247
  if (config.fontIconAddress && window.insertCssFile) {
247
248
  window.insertCssFile(`${config.fontIconAddress}/iconfont.css`)
248
249
  }
@@ -588,7 +589,7 @@ export function loadCSS() {
588
589
  console.error('皮肤主题为空!')
589
590
  return
590
591
  }
591
- const baseAPI = localStorage.getItem('_baseAPI_')
592
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI?window.$vueApp.config.globalProperties.baseAPI:localStorage.getItem('_baseAPI_')
592
593
  if (baseAPI) {
593
594
  const href = replacePrefix(baseAPI) + '/component/theme/load-theme?theme=' + theme + '&_t_=' + new Date().getTime()
594
595
  let isHasLink = true