mooho-base-admin-plus 2.10.60 → 2.10.62

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,7 +1,7 @@
1
1
  {
2
2
  "name": "mooho-base-admin-plus",
3
3
  "description": "MOOHO basic framework for admin by Vue3",
4
- "version": "2.10.60",
4
+ "version": "2.10.62",
5
5
  "author": "jinyifan <jinyifan@mooho.com.cn>",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -108,15 +108,31 @@ export default {
108
108
  let data = {};
109
109
  this.columns.forEach(item => {
110
110
  if (item.defaultValue) {
111
- if (item.defaultValue == '{today}') {
111
+ if (item.defaultValue.startsWith('{today}')) {
112
112
  // 当前日期
113
113
  let date = new Date();
114
+
115
+ if (item.defaultValue.indexOf('+') != -1) {
116
+ date.setDate(date.getDate() + parseInt(item.defaultValue.split('+')[1]));
117
+ } else if (item.defaultValue.indexOf('-') != -1) {
118
+ date.setDate(date.getDate() - parseInt(item.defaultValue.split('-')[1]));
119
+ }
120
+
114
121
  let value = date.toISOString().replace(/T.*/, '');
115
122
  setData(data, item, new Date(value));
116
- } else if (item.defaultValue.startsWith('{today(') && item.defaultValue.endsWith(')}')) {
117
- // 当前时间转字符串
118
- let format = item.defaultValue.substr(7, item.defaultValue.length - 9);
119
- setData(data, item, dateFormat(new Date(), format));
123
+ } else if (item.defaultValue.startsWith('{today(')) {
124
+ // 当前日期
125
+ let date = new Date();
126
+
127
+ if (item.defaultValue.indexOf('+') != -1) {
128
+ date.setDate(date.getDate() + parseInt(item.defaultValue.split('+')[1]));
129
+ } else if (item.defaultValue.indexOf('-') != -1) {
130
+ date.setDate(date.getDate() - parseInt(item.defaultValue.split('-')[1]));
131
+ }
132
+
133
+ let format = item.defaultValue.substr(7, item.defaultValue.indexOf(')}') - 7);
134
+
135
+ setData(data, item, dateFormat(date, format));
120
136
  } else if (item.defaultValue == '{currentUserID}') {
121
137
  // 当前用户编号
122
138
  setData(data, item, this.info.id);
@@ -102,14 +102,17 @@
102
102
  this.$refs.table.hotInstance.addHook('beforeOnCellMouseUp', (event, coords) => {
103
103
  this.coords = coords;
104
104
  if (event.detail === 2 && coords.row >= 0 && !this.readonly) {
105
- // 双击弹出窗口
106
- let column = this.hotSetting.columns[coords.col];
107
- let data = this.$refs.table.hotInstance.getSourceData();
108
-
109
- if (column.controlType === 'DialogSelect' && !column.readonly) {
110
- this.$refs.dialogTable.init(column.source, () => {
111
- this.$refs.dialogTable.open(this.getParam(data[coords.row], column, this.parentData));
112
- });
105
+ let isReadonly = this.$refs.table.hotInstance.getCellMeta(coords.row, coords.col).readOnly;
106
+ if (!isReadonly) {
107
+ // 双击弹出窗口
108
+ let column = this.hotSetting.columns[coords.col];
109
+ //let data = this.$refs.table.hotInstance.getSourceData();
110
+
111
+ if (column.controlType === 'DialogSelect' && !column.readonly) {
112
+ this.$refs.dialogTable.init(column.source, () => {
113
+ this.$refs.dialogTable.open(this.getParam(this.staticData[coords.row], column, this.parentData));
114
+ });
115
+ }
113
116
  }
114
117
  }
115
118
  });
@@ -267,132 +270,122 @@
267
270
  if (!this.readonly) {
268
271
  if (item.controlType === 'Label' || item.isReadonly == true) {
269
272
  column.readOnly = true;
270
- } else if (item.controlType === 'TextInput') {
271
- column.type = 'text';
272
-
273
- if (column.isRequired) {
274
- column.validator = 'text-required';
275
- }
276
- } else if (item.controlType === 'NumberInput') {
277
- column.type = 'numeric';
278
- if (column.isRequired) {
279
- column.validator = 'numeric-required';
280
- }
281
- // column.validator = 'numeric';
282
- } else if (item.controlType === 'Check') {
283
- column.type = 'checkbox';
284
- } else if (item.controlType === 'Select') {
285
- column.editor = 'select';
286
- if (column.isRequired) {
287
- column.validator = 'select-required';
288
- }
289
-
290
- let dataSource = [];
291
-
292
- if (column.isStaticItem) {
293
- if (!!(column.itemData || '').trim()) {
294
- column.itemData.split(/[\n]/).forEach(item => {
295
- if (!!(item || '').trim()) {
296
- if (item.split(':').length > 1) {
297
- let key = item.split(':')[0];
298
- let value = item.split(':')[1];
299
-
300
- if (column.dataType == 'Integer' || column.dataType == 'BigInteger') {
301
- dataSource.push({
302
- id: parseInt(key),
303
- name: value
304
- });
305
- } else if (column.dataType == 'Decimal' || column.dataType == 'Float' || column.dataType == 'Double') {
306
- dataSource.push({
307
- id: parseFloat(key),
308
- name: value
309
- });
310
- } else if (column.dataType == 'Boolean') {
311
- dataSource.push({
312
- id: key.toUpperCase() == 'TRUE',
313
- name: value
314
- });
315
- } else {
316
- dataSource.push({
317
- id: key,
318
- name: value
319
- });
320
- }
321
- } else {
322
- if (column.dataType == 'Integer' || column.dataType == 'BigInteger') {
323
- dataSource.push({
324
- id: parseInt(item),
325
- name: item
326
- });
327
- } else if (column.dataType == 'Decimal' || column.dataType == 'Float' || column.dataType == 'Double') {
328
- dataSource.push({
329
- id: parseFloat(item),
330
- name: item
331
- });
332
- } else if (column.dataType == 'Boolean') {
333
- dataSource.push({
334
- id: item.toUpperCase() == 'TRUE',
335
- name: item
336
- });
273
+ } else {
274
+ column.validator = this.getValidator(column);
275
+
276
+ if (item.controlType === 'TextInput') {
277
+ column.type = 'text';
278
+ } else if (item.controlType === 'NumberInput') {
279
+ column.type = 'numeric';
280
+ } else if (item.controlType === 'Check') {
281
+ column.type = 'checkbox';
282
+ } else if (item.controlType === 'Select') {
283
+ column.editor = 'select';
284
+
285
+ let dataSource = [];
286
+
287
+ if (column.isStaticItem) {
288
+ if (!!(column.itemData || '').trim()) {
289
+ column.itemData.split(/[\n]/).forEach(item => {
290
+ if (!!(item || '').trim()) {
291
+ if (item.split(':').length > 1) {
292
+ let key = item.split(':')[0];
293
+ let value = item.split(':')[1];
294
+
295
+ if (column.dataType == 'Integer' || column.dataType == 'BigInteger') {
296
+ dataSource.push({
297
+ id: parseInt(key),
298
+ name: value
299
+ });
300
+ } else if (column.dataType == 'Decimal' || column.dataType == 'Float' || column.dataType == 'Double') {
301
+ dataSource.push({
302
+ id: parseFloat(key),
303
+ name: value
304
+ });
305
+ } else if (column.dataType == 'Boolean') {
306
+ dataSource.push({
307
+ id: key.toUpperCase() == 'TRUE',
308
+ name: value
309
+ });
310
+ } else {
311
+ dataSource.push({
312
+ id: key,
313
+ name: value
314
+ });
315
+ }
337
316
  } else {
338
- dataSource.push({
339
- id: item,
340
- name: item
341
- });
317
+ if (column.dataType == 'Integer' || column.dataType == 'BigInteger') {
318
+ dataSource.push({
319
+ id: parseInt(item),
320
+ name: item
321
+ });
322
+ } else if (column.dataType == 'Decimal' || column.dataType == 'Float' || column.dataType == 'Double') {
323
+ dataSource.push({
324
+ id: parseFloat(item),
325
+ name: item
326
+ });
327
+ } else if (column.dataType == 'Boolean') {
328
+ dataSource.push({
329
+ id: item.toUpperCase() == 'TRUE',
330
+ name: item
331
+ });
332
+ } else {
333
+ dataSource.push({
334
+ id: item,
335
+ name: item
336
+ });
337
+ }
342
338
  }
343
339
  }
340
+ });
341
+ }
342
+ } else {
343
+ if (column.dataType.startsWith('Enum:')) {
344
+ // 枚举
345
+ dataSource = this.getEnumList(column.dataType.split(':')[1]);
346
+ } else if (!!(column.source || '').trim()) {
347
+ let param = this.getParam(null, column, this.parentData);
348
+
349
+ // 选择框、单选框组
350
+ this.disableLoader();
351
+ let res;
352
+ if (column.isSourceCustom) {
353
+ res = await customModelApi.query(column.source, param); //, [column.sourceDataCode, column.sourceDisplayCode]);
354
+ } else {
355
+ res = await modelApi.query(column.source, param); //, [column.sourceDataCode, column.sourceDisplayCode]);
344
356
  }
345
- });
346
- }
347
- } else {
348
- if (column.dataType.startsWith('Enum:')) {
349
- // 枚举
350
- dataSource = this.getEnumList(column.dataType.split(':')[1]);
351
- } else if (!!(column.source || '').trim()) {
352
- let param = this.getParam(null, column, this.parentData);
353
-
354
- // 选择框、单选框组
355
- this.disableLoader();
356
- let res;
357
- if (column.isSourceCustom) {
358
- res = await customModelApi.query(column.source, param); //, [column.sourceDataCode, column.sourceDisplayCode]);
359
- } else {
360
- res = await modelApi.query(column.source, param); //, [column.sourceDataCode, column.sourceDisplayCode]);
357
+ this.enableLoader();
358
+
359
+ dataSource = res.data.map(item => {
360
+ return {
361
+ id: !(column.sourceDataCode || '').trim() ? item.id : this.parseData(item, column.sourceDataCode),
362
+ name: this.parseData(item, column.sourceDisplayCode)
363
+ };
364
+ });
361
365
  }
362
- this.enableLoader();
363
-
364
- dataSource = res.data.map(item => {
365
- return {
366
- id: !(column.sourceDataCode || '').trim() ? item.id : this.parseData(item, column.sourceDataCode),
367
- name: this.parseData(item, column.sourceDisplayCode)
368
- };
369
- });
370
366
  }
371
- }
372
367
 
373
- column.selectOptions = dataSource.map(option => {
374
- return option.id;
375
- });
376
- } else if (item.controlType === 'Date') {
377
- column.type = 'date';
378
- if (column.isRequired) {
379
- column.validator = 'date-required';
368
+ column.selectOptions = dataSource.map(option => {
369
+ return option.id;
370
+ });
371
+ } else if (item.controlType === 'Date') {
372
+ column.type = 'date';
373
+ column.dateFormat = 'YYYY-MM-DD';
374
+ column.correctFormat = true;
375
+ // column.renderer = function (instance, td, row, col, prop, value, cellProperties) {
376
+ // if (value) {
377
+ // td.innerHTML = dateFormat(new Date(value), 'yyyy-MM-dd');
378
+ // console.log(instance);
379
+ // console.log(td);
380
+ // console.log(row);
381
+ // console.log(col);
382
+ // console.log(prop);
383
+ // console.log(value);
384
+ // console.log(cellProperties);
385
+ // }
386
+ // return td;
387
+ // };
380
388
  }
381
- column.dateFormat = 'YYYY-MM-DD';
382
- column.correctFormat = true;
383
- // column.renderer = function (instance, td, row, col, prop, value, cellProperties) {
384
- // if (value) {
385
- // td.innerHTML = dateFormat(new Date(value), 'yyyy-MM-dd');
386
- // console.log(instance);
387
- // console.log(td);
388
- // console.log(row);
389
- // console.log(col);
390
- // console.log(prop);
391
- // console.log(value);
392
- // console.log(cellProperties);
393
- // }
394
- // return td;
395
- // };
396
389
  }
397
390
  }
398
391
 
@@ -662,6 +655,28 @@
662
655
  }
663
656
  });
664
657
  },
658
+ // 获取验证器
659
+ getValidator(column) {
660
+ if (column.controlType === 'TextInput' || column.controlType === 'Select' || column.controlType === 'DialogSelect') {
661
+ if (column.isRequired) {
662
+ return 'text-required';
663
+ } else {
664
+ return 'text';
665
+ }
666
+ } else if (column.controlType === 'NumberInput') {
667
+ if (column.isRequired) {
668
+ return 'numeric-required';
669
+ } else {
670
+ return 'numeric';
671
+ }
672
+ } else if (column.controlType === 'Date') {
673
+ if (column.isRequired) {
674
+ return 'date-required';
675
+ } else {
676
+ return 'date';
677
+ }
678
+ }
679
+ },
665
680
  /**
666
681
  * 加载数据
667
682
  *
@@ -851,16 +866,32 @@
851
866
  cells: (row, col, prop) => {
852
867
  let column = this.columns.find(item => item.code == prop);
853
868
 
869
+ let isShow = column.isShow;
870
+ let isReadonly = column.isReadonly;
871
+
854
872
  // 判断是否只读
855
873
  if (!!(column.readonlyJson || '').trim()) {
856
874
  let setting = JSON.parse(column.readonlyJson);
857
875
 
858
876
  if (setting.type == 'Condition' || setting.type == 'Expression') {
859
- let readOnly = this.judgeCondition(setting, this.staticData[row]);
877
+ isReadonly = this.judgeCondition(setting, this.staticData[row]);
878
+ }
879
+ }
880
+
881
+ // 判断是否显示
882
+ if (!!(column.showJson || '').trim()) {
883
+ let setting = JSON.parse(column.showJson);
860
884
 
861
- return { readOnly };
885
+ if (setting.type == 'Condition' || setting.type == 'Expression') {
886
+ isShow = this.judgeCondition(setting, this.staticData[row]);
862
887
  }
863
888
  }
889
+
890
+ if (!isShow) {
891
+ this.setData(this.staticData[row], prop, null);
892
+ }
893
+
894
+ return { readOnly: !isShow || isReadonly, validator: !isShow ? null : this.getValidator(column) };
864
895
  }
865
896
  });
866
897
  },