@oinone/kunlun-vue-admin-base 6.2.7 → 6.2.8

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": "@oinone/kunlun-vue-admin-base",
3
- "version": "6.2.7",
3
+ "version": "6.2.8",
4
4
  "main": "index.ts",
5
5
  "scripts": {
6
6
  "prebuild": "rimraf dist",
@@ -14,13 +14,13 @@
14
14
  "doc": "typedoc --out docs src/index.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@oinone/kunlun-vue-admin-layout": "6.2.7",
18
- "@oinone/kunlun-vue-router": "6.2.7",
19
- "@oinone/kunlun-vue-ui": "6.2.7",
20
- "@oinone/kunlun-vue-ui-antd": "6.2.7",
21
- "@oinone/kunlun-vue-ui-common": "6.2.7",
22
- "@oinone/kunlun-vue-ui-el": "6.2.7",
23
- "@oinone/kunlun-vue-widget": "6.2.7",
17
+ "@oinone/kunlun-vue-admin-layout": "6.2.8",
18
+ "@oinone/kunlun-vue-router": "6.2.8",
19
+ "@oinone/kunlun-vue-ui": "6.2.8",
20
+ "@oinone/kunlun-vue-ui-antd": "6.2.8",
21
+ "@oinone/kunlun-vue-ui-common": "6.2.8",
22
+ "@oinone/kunlun-vue-ui-el": "6.2.8",
23
+ "@oinone/kunlun-vue-widget": "6.2.8",
24
24
  "@wangeditor/editor": "5.1.23",
25
25
  "@wangeditor/editor-for-vue": "5.1.11",
26
26
  "@wangeditor/plugin-upload-attachment": "1.1.0",
@@ -20,17 +20,17 @@ import {
20
20
  SubmitValue,
21
21
  translateValueByKey
22
22
  } from '@oinone/kunlun-engine';
23
- import { ActionContextType, Entity, ModelFieldType, ViewMode, ViewType } from '@oinone/kunlun-meta';
24
- import { Condition, DefaultComparisonOperator } from '@oinone/kunlun-request';
23
+ import { ActionContextType, Entity, ViewMode, ViewType } from '@oinone/kunlun-meta';
24
+ import { Condition } from '@oinone/kunlun-request';
25
25
  import { DEFAULT_LIST_TRUE_CONDITION, DEFAULT_TRUE_CONDITION, EDirection, ISort } from '@oinone/kunlun-service';
26
26
  import {
27
27
  BooleanHelper,
28
28
  CallChaining,
29
- CastHelper,
30
29
  debugConsole,
31
30
  NumberHelper,
32
31
  ObjectUtils,
33
32
  Optional,
33
+ RSQLField,
34
34
  RSQLHelper,
35
35
  RSQLNodeInfo,
36
36
  SortDirection,
@@ -41,7 +41,7 @@ import {
41
41
  import { CheckedChangeEvent, RadioChangeEvent } from '@oinone/kunlun-vue-ui';
42
42
  import { ListPaginationStyle, ListSelectMode, PageSizeEnum } from '@oinone/kunlun-vue-ui-antd';
43
43
  import { Widget } from '@oinone/kunlun-vue-widget';
44
- import { ceil, get as getValue, isEmpty, isNil, isString, toInteger, toString } from 'lodash-es';
44
+ import { ceil, isEmpty, isNil, isString, toInteger, toString } from 'lodash-es';
45
45
  import { VxeTablePropTypes } from 'vxe-table';
46
46
  import { fetchPageSize } from '../../typing';
47
47
  import { FetchUtil } from '../../util';
@@ -123,7 +123,7 @@ export abstract class BaseElementListViewWidget<
123
123
  if (this.usingSearchCondition || !this.isDataSourceProvider) {
124
124
  // 前端搜索
125
125
  if (searchCondition) {
126
- dataSource = RsqlFilterExecutor.filter(dataSource, searchCondition);
126
+ dataSource = dataSource.filter((v) => RSQLHelper.compute(searchCondition, v));
127
127
  }
128
128
  }
129
129
  if (!this.isDataSourceProvider) {
@@ -374,7 +374,7 @@ export abstract class BaseElementListViewWidget<
374
374
  }
375
375
  if (record) {
376
376
  if (searchCondition) {
377
- if (RsqlFilterExecutor.filter([record], searchCondition).length) {
377
+ if (RSQLHelper.compute(searchCondition, record)) {
378
378
  dataSource.push(record);
379
379
  } else {
380
380
  filterSize++;
@@ -688,13 +688,10 @@ export abstract class BaseElementListViewWidget<
688
688
  if (!rsql || rsql === DEFAULT_LIST_TRUE_CONDITION) {
689
689
  return undefined;
690
690
  }
691
- const searchCondition = RSQLHelper.parse(
692
- {
693
- model: this.model.model,
694
- fields: CastHelper.cast(this.seekSearchRuntimeContext()?.model.modelFields)
695
- },
696
- rsql
697
- );
691
+ const searchCondition = RSQLHelper.parseRSQL(rsql, {
692
+ model: this.model.model,
693
+ fields: (this.seekSearchRuntimeContext()?.model.modelFields || []) as unknown as RSQLField[]
694
+ });
698
695
  if (!searchCondition) {
699
696
  return undefined;
700
697
  }
@@ -973,229 +970,3 @@ export abstract class BaseElementListViewWidget<
973
970
  await this.refreshProcess(condition);
974
971
  }
975
972
  }
976
-
977
- type RsqlToObjectItem = {
978
- value: Array<string | number | boolean>;
979
- operator: DefaultComparisonOperator;
980
- ttype: ModelFieldType;
981
- };
982
-
983
- interface IRsqlToObject {
984
- [key: string]: RsqlToObjectItem | RsqlToObjectItem[];
985
- }
986
-
987
- class RsqlFilterExecutor {
988
- public static filter<T extends Record<string, unknown> = Record<string, unknown>>(
989
- list: T[],
990
- root: TreeNode<RSQLNodeInfo>
991
- ): T[] {
992
- return this.rsqlNodeToCondition(list, root);
993
- }
994
-
995
- private static rsqlNodeToCondition<T extends Record<string, unknown>>(list: T[], root: TreeNode<RSQLNodeInfo>): T[] {
996
- const { children } = root;
997
-
998
- const realChildren = children.filter((child) => (child.children && child.children.length) || child.value?.field);
999
-
1000
- /**
1001
- * 将rsql node tree 转换成正确的数据格式,格式如下。
1002
- *
1003
- * [
1004
- * {
1005
- * code: {
1006
- * value: '110',
1007
- * ttype: 'STRING'
1008
- * operator: '=like='
1009
- * },
1010
- * },
1011
- * {
1012
- * writeDate: {
1013
- * value: '2023-02-28 10:51:04',
1014
- * ttype: 'DATETIME'
1015
- * operator: '=lt='
1016
- * }
1017
- * },
1018
- * {
1019
- * writeDate: {
1020
- * value: '2023-02-28 09:51:04',
1021
- * ttype: 'DATETIME'
1022
- * operator: '=gt='
1023
- * }
1024
- * }
1025
- * ]
1026
- */
1027
-
1028
- const arr: IRsqlToObject[] = [];
1029
-
1030
- realChildren.forEach((child) => {
1031
- if (child.children.length === 0) {
1032
- const { selector, operator, field, args } = child.value!;
1033
-
1034
- /**
1035
- * {value: xxx, operator: 'xxx', ttype: xxx}
1036
- */
1037
- const result = this.buildRsqlToObjectItem({
1038
- value: args![0],
1039
- operator: operator!.symbol! as any,
1040
- ttype: field ? field.ttype : null
1041
- });
1042
-
1043
- arr.push({
1044
- [selector as string]: result
1045
- });
1046
- } else if (child.value?.type === 1) {
1047
- // 如果 type === 1 , 那么是 `or` 的查询条件
1048
- const selector = child.children[0].value?.selector as string;
1049
-
1050
- /**
1051
- * [{value: xxx, operator: 'xxx', ttype: xxx}, {value: xxx, operator: 'xxx', ttype: xxx}]
1052
- */
1053
- const list = child.children.map((c) => {
1054
- const { operator, field, args } = c.value!;
1055
- return this.buildRsqlToObjectItem({
1056
- value: args![0],
1057
- operator: operator!.symbol! as any,
1058
- ttype: field ? field.ttype : null
1059
- });
1060
- });
1061
-
1062
- arr.push({
1063
- [selector as string]: list
1064
- });
1065
- }
1066
- });
1067
-
1068
- return this.getFilterResultWithConditionArr(list, arr) as T[];
1069
- }
1070
-
1071
- private static buildRsqlToObjectItem({ value, operator, ttype }) {
1072
- return {
1073
- value: this.getValueByTType(value, ttype),
1074
- operator,
1075
- ttype
1076
- };
1077
- }
1078
-
1079
- private static getFilterResultWithConditionArr(list, arr: IRsqlToObject[]) {
1080
- const filterArr: ((val: any) => boolean)[] = [];
1081
-
1082
- arr.forEach((obj) => {
1083
- Object.keys(obj).forEach((key) => {
1084
- filterArr.push((dataSourceItem) => {
1085
- const conditionObject = obj[key];
1086
-
1087
- /**
1088
- * 如果当前条件是数组,那么是 `or` 查询
1089
- */
1090
- if (Array.isArray(conditionObject)) {
1091
- const [k, relationK] = key.split('.');
1092
- const itemValue = getValue<any[]>(dataSourceItem, k, []).map((v) => v[relationK]);
1093
- return itemValue === null ? false : conditionObject.some((v) => this.executeOperator(v, itemValue));
1094
- }
1095
-
1096
- let itemValue: null | any[] | Record<string, any> = null;
1097
- if ([ModelFieldType.ManyToMany, ModelFieldType.OneToMany].includes(conditionObject.ttype)) {
1098
- const [k, relationK] = key.split('.');
1099
- itemValue = getValue<any[]>(dataSourceItem, k, []).map((v) => v[relationK]);
1100
- } else {
1101
- itemValue = getValue(dataSourceItem, key, null);
1102
- }
1103
-
1104
- return this.executeOperator(conditionObject, itemValue);
1105
- });
1106
- });
1107
- });
1108
-
1109
- return filterArr.reduce((pre, next) => {
1110
- return pre?.filter(next);
1111
- }, list);
1112
- }
1113
-
1114
- /**
1115
- * 通过 `条件` + `table每一行`,执行对应的操作
1116
- */
1117
- private static executeOperator(obj: RsqlToObjectItem, dataSourceItem) {
1118
- if (dataSourceItem === null) {
1119
- return false;
1120
- }
1121
-
1122
- const realValue = this.getValueByTType(dataSourceItem, obj.ttype);
1123
-
1124
- if (obj.operator === DefaultComparisonOperator.GREATER_THAN) {
1125
- return realValue > obj.value;
1126
- }
1127
-
1128
- if (obj.operator === DefaultComparisonOperator.GREATER_THAN_OR_EQUAL) {
1129
- return realValue >= obj.value;
1130
- }
1131
-
1132
- if (obj.operator === DefaultComparisonOperator.LESS_THAN) {
1133
- return realValue < obj.value;
1134
- }
1135
-
1136
- if (obj.operator === DefaultComparisonOperator.LESS_THAN_OR_EQUAL) {
1137
- return realValue < obj.value;
1138
- }
1139
-
1140
- if ([ModelFieldType.ManyToMany, ModelFieldType.OneToMany].includes(obj.ttype)) {
1141
- return realValue.includes(obj.value);
1142
- }
1143
-
1144
- if (obj.operator === DefaultComparisonOperator.LIKE) {
1145
- return realValue.indexOf(obj.value) > -1;
1146
- }
1147
-
1148
- if (obj.operator === DefaultComparisonOperator.NOT_LIKE) {
1149
- return realValue.indexOf(obj.value) === -1;
1150
- }
1151
-
1152
- if (obj.operator === DefaultComparisonOperator.STARTS) {
1153
- return realValue.startsWith(obj.value);
1154
- }
1155
-
1156
- if (obj.operator === DefaultComparisonOperator.NOT_STARTS) {
1157
- return !realValue.startsWith(obj.value);
1158
- }
1159
-
1160
- if (obj.operator === DefaultComparisonOperator.ENDS) {
1161
- return realValue.endsWith(obj.value);
1162
- }
1163
-
1164
- if (obj.operator === DefaultComparisonOperator.NOT_ENDS) {
1165
- return !realValue.endsWith(obj.value);
1166
- }
1167
-
1168
- if (obj.operator === DefaultComparisonOperator.IS_NULL) {
1169
- return realValue === null;
1170
- }
1171
-
1172
- if (obj.operator === DefaultComparisonOperator.NOT_NULL) {
1173
- return realValue !== null;
1174
- }
1175
-
1176
- if (obj.operator === DefaultComparisonOperator.EQUAL) {
1177
- return realValue === obj.value;
1178
- }
1179
-
1180
- if (obj.operator === DefaultComparisonOperator.NOT_EQUAL) {
1181
- return realValue !== obj.value;
1182
- }
1183
-
1184
- throw new TypeError(`搜索失败,不支持${obj.operator}搜索`);
1185
- }
1186
-
1187
- /**
1188
- * 根据 ttype,将value变成正确的值
1189
- * 时间类型,就要转成时间戳
1190
- */
1191
- private static getValueByTType(value, ttype: ModelFieldType) {
1192
- switch (ttype) {
1193
- case ModelFieldType.Date:
1194
- case ModelFieldType.DateTime:
1195
- return new Date(value).getTime();
1196
-
1197
- default:
1198
- return value;
1199
- }
1200
- }
1201
- }
@@ -134,8 +134,8 @@ export class AppsGalleryWidget extends BaseElementListViewWidget {
134
134
  return {
135
135
  hasCreateAppAction: !!CreateAppAction && !this.executeInvisibleExpress(CreateAppAction.invisible),
136
136
  hasUpdateAppAction: !!UpdateAppAction && !this.executeInvisibleExpress(UpdateAppAction.invisible),
137
- hasUninstallAction: !!UninstallAction && !this.executeInvisibleExpress(UninstallAction.invisible),
138
- hasInstallAction: !!InstallAction && !this.executeInvisibleExpress(InstallAction.invisible),
137
+ hasUninstallAction: !!UninstallAction,
138
+ hasInstallAction: !!InstallAction,
139
139
  hasBindHomepageAction: !!BindHomepageAction && !this.executeInvisibleExpress(BindHomepageAction.invisible),
140
140
  hasDetailAction: !!DetailAction && !this.executeInvisibleExpress(DetailAction.invisible),
141
141
 
@@ -75,7 +75,13 @@
75
75
  <div v-if="record.state === AppState.INSTALLED" class="state">
76
76
  {{ translateValueByKey('已安装') }}
77
77
  </div>
78
- <div v-else-if="!record.state || record.state === AppState.UNINSTALLED" class="install-action">
78
+ <div
79
+ v-else-if="
80
+ (!record.state || record.state === AppState.UNINSTALLED) &&
81
+ actionPermission.hasCreateAppAction
82
+ "
83
+ class="install-action"
84
+ >
79
85
  <span class="install-action-font" @click="installApp(record)">{{
80
86
  translateValueByKey('安装')
81
87
  }}</span>