@jari-ace/element-plus-component 0.3.2 → 0.3.3

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.
Files changed (148) hide show
  1. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts +956 -1179
  2. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts.map +1 -1
  3. package/dist/components/button/JaButton.vue.d.ts +114 -450
  4. package/dist/components/button/JaButton.vue.d.ts.map +1 -1
  5. package/dist/components/checkbox/JaCheckbox.vue.d.ts +228 -150
  6. package/dist/components/checkbox/JaCheckbox.vue.d.ts.map +1 -1
  7. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts +215 -137
  8. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts.map +1 -1
  9. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts +700 -1596
  10. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts.map +1 -1
  11. package/dist/components/form/JaForm.vue.d.ts +1 -1
  12. package/dist/components/formItem/JaFormItem.vue.d.ts +83 -293
  13. package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
  14. package/dist/components/input/JaInput.vue.d.ts +244 -609
  15. package/dist/components/input/JaInput.vue.d.ts.map +1 -1
  16. package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts +1 -1
  17. package/dist/components/inputI18n/I18nBundleEditor.vue.d.ts.map +1 -1
  18. package/dist/components/inputI18n/I18nBundleEditor.vue.js +1 -1
  19. package/dist/components/inputI18n/I18nBundleEditor.vue.js.map +1 -1
  20. package/dist/components/inputI18n/InputI18n.vue.d.ts.map +1 -1
  21. package/dist/components/inputI18n/InputI18n.vue.js +14 -5
  22. package/dist/components/inputI18n/InputI18n.vue.js.map +1 -1
  23. package/dist/components/inputNumber/JaInputNumber.vue.d.ts +117 -471
  24. package/dist/components/inputNumber/JaInputNumber.vue.d.ts.map +1 -1
  25. package/dist/components/inputNumber/JaInputNumber.vue.js +4 -1
  26. package/dist/components/inputNumber/JaInputNumber.vue.js.map +1 -1
  27. package/dist/components/properyPicker/PropertyPicker.vue.d.ts.map +1 -1
  28. package/dist/components/properyPicker/PropertyPicker.vue.js +4 -8
  29. package/dist/components/properyPicker/PropertyPicker.vue.js.map +1 -1
  30. package/dist/components/radioGroup/JaRadioGroup.vue.d.ts +96 -287
  31. package/dist/components/radioGroup/JaRadioGroup.vue.d.ts.map +1 -1
  32. package/dist/components/rolePicker/RoleCategorySelector.vue.d.ts +14 -0
  33. package/dist/components/rolePicker/RoleCategorySelector.vue.d.ts.map +1 -0
  34. package/dist/components/rolePicker/RoleCategorySelector.vue.js +410 -0
  35. package/dist/components/rolePicker/RoleCategorySelector.vue.js.map +1 -0
  36. package/dist/components/rolePicker/RoleEditor.vue.d.ts +1 -0
  37. package/dist/components/rolePicker/RoleEditor.vue.d.ts.map +1 -1
  38. package/dist/components/rolePicker/RoleEditor.vue.js +64 -31
  39. package/dist/components/rolePicker/RoleEditor.vue.js.map +1 -1
  40. package/dist/components/rolePicker/baseRolePicker.vue.d.ts.map +1 -1
  41. package/dist/components/rolePicker/baseRolePicker.vue.js +7 -9
  42. package/dist/components/rolePicker/baseRolePicker.vue.js.map +1 -1
  43. package/dist/components/rolePicker/index.d.ts +2 -0
  44. package/dist/components/rolePicker/index.d.ts.map +1 -1
  45. package/dist/components/rolePicker/index.js +2 -0
  46. package/dist/components/rolePicker/index.js.map +1 -1
  47. package/dist/components/scrollbar/Scrollbar.vue.d.ts +110 -378
  48. package/dist/components/scrollbar/Scrollbar.vue.d.ts.map +1 -1
  49. package/dist/components/switch/JaSwitch.vue.d.ts +96 -431
  50. package/dist/components/switch/JaSwitch.vue.d.ts.map +1 -1
  51. package/dist/components/upload/JaUploader.vue.d.ts +50 -6
  52. package/dist/components/upload/JaUploader.vue.d.ts.map +1 -1
  53. package/dist/components/upload/index.d.ts +76 -9
  54. package/dist/components/upload/index.d.ts.map +1 -1
  55. package/dist/components/upload/index.js +1 -0
  56. package/dist/components/upload/index.js.map +1 -1
  57. package/dist/components/upload/types.d.ts +3 -0
  58. package/dist/components/upload/types.d.ts.map +1 -0
  59. package/dist/components/upload/types.js +2 -0
  60. package/dist/components/upload/types.js.map +1 -0
  61. package/dist/components/upload/uploader.vue.d.ts +26 -3
  62. package/dist/components/upload/uploader.vue.d.ts.map +1 -1
  63. package/dist/components/upload/uploader.vue.js +28 -11
  64. package/dist/components/upload/uploader.vue.js.map +1 -1
  65. package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts +1808 -0
  66. package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts.map +1 -0
  67. package/dist/components/userGroupTree/src/userGroupTree.vue.js +23 -14
  68. package/dist/components/userGroupTree/src/userGroupTree.vue.js.map +1 -1
  69. package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts.map +1 -1
  70. package/dist/components/userSelectDialog/src/userSelectDialog.vue.js +2 -0
  71. package/dist/components/userSelectDialog/src/userSelectDialog.vue.js.map +1 -1
  72. package/dist/hooks/useAppInstances.d.ts +17 -4
  73. package/dist/hooks/useAppInstances.d.ts.map +1 -1
  74. package/dist/hooks/useAppInstances.js +109 -24
  75. package/dist/hooks/useAppInstances.js.map +1 -1
  76. package/dist/hooks/useClassificationLevels.d.ts.map +1 -1
  77. package/dist/hooks/useClassificationLevels.js +30 -7
  78. package/dist/hooks/useClassificationLevels.js.map +1 -1
  79. package/dist/hooks/useConstraintProviders.d.ts +5 -0
  80. package/dist/hooks/useConstraintProviders.d.ts.map +1 -0
  81. package/dist/hooks/useConstraintProviders.js +31 -0
  82. package/dist/hooks/useConstraintProviders.js.map +1 -0
  83. package/dist/hooks/useEntities.d.ts +9 -0
  84. package/dist/hooks/useEntities.d.ts.map +1 -0
  85. package/dist/hooks/useEntities.js +40 -0
  86. package/dist/hooks/useEntities.js.map +1 -0
  87. package/dist/hooks/useEntityPropDataTypes.d.ts +5 -0
  88. package/dist/hooks/useEntityPropDataTypes.d.ts.map +1 -0
  89. package/dist/hooks/useEntityPropDataTypes.js +31 -0
  90. package/dist/hooks/useEntityPropDataTypes.js.map +1 -0
  91. package/dist/hooks/useFileConfigurations.d.ts +6 -0
  92. package/dist/hooks/useFileConfigurations.d.ts.map +1 -0
  93. package/dist/hooks/useFileConfigurations.js +37 -0
  94. package/dist/hooks/useFileConfigurations.js.map +1 -0
  95. package/dist/hooks/useGroups.d.ts +7 -0
  96. package/dist/hooks/useGroups.d.ts.map +1 -0
  97. package/dist/hooks/useGroups.js +75 -0
  98. package/dist/hooks/useGroups.js.map +1 -0
  99. package/dist/hooks/useNumberTemplates.d.ts +6 -0
  100. package/dist/hooks/useNumberTemplates.d.ts.map +1 -0
  101. package/dist/hooks/useNumberTemplates.js +37 -0
  102. package/dist/hooks/useNumberTemplates.js.map +1 -0
  103. package/dist/hooks/useProperties.d.ts +9 -0
  104. package/dist/hooks/useProperties.d.ts.map +1 -0
  105. package/dist/hooks/useProperties.js +40 -0
  106. package/dist/hooks/useProperties.js.map +1 -0
  107. package/dist/hooks/useRoleCategories.d.ts +6 -0
  108. package/dist/hooks/useRoleCategories.d.ts.map +1 -0
  109. package/dist/hooks/useRoleCategories.js +37 -0
  110. package/dist/hooks/useRoleCategories.js.map +1 -0
  111. package/dist/hooks/useRoles.d.ts +6 -0
  112. package/dist/hooks/useRoles.d.ts.map +1 -0
  113. package/dist/hooks/useRoles.js +38 -0
  114. package/dist/hooks/useRoles.js.map +1 -0
  115. package/dist/index.d.ts +9 -0
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +9 -0
  118. package/dist/index.js.map +1 -1
  119. package/lib/index.css +1 -1
  120. package/lib/index.js +9264 -8794
  121. package/lib/index.umd.cjs +34 -34
  122. package/package.json +7 -7
  123. package/packages/components/input/JaInput.vue +1 -1
  124. package/packages/components/inputI18n/I18nBundleEditor.vue +2 -2
  125. package/packages/components/inputI18n/InputI18n.vue +33 -25
  126. package/packages/components/inputNumber/JaInputNumber.vue +6 -5
  127. package/packages/components/properyPicker/PropertyPicker.vue +4 -8
  128. package/packages/components/rolePicker/RoleCategorySelector.vue +154 -0
  129. package/packages/components/rolePicker/RoleEditor.vue +16 -7
  130. package/packages/components/rolePicker/baseRolePicker.vue +6 -13
  131. package/packages/components/rolePicker/index.ts +3 -0
  132. package/packages/components/upload/index.ts +1 -0
  133. package/packages/components/upload/types.ts +4 -0
  134. package/packages/components/upload/uploader.vue +456 -381
  135. package/packages/components/userGroupTree/src/userGroupTree.vue +54 -17
  136. package/packages/components/userSelectDialog/src/userSelectDialog.vue +1 -1
  137. package/packages/hooks/useAppInstances.ts +121 -25
  138. package/packages/hooks/useClassificationLevels.ts +31 -7
  139. package/packages/hooks/useConstraintProviders.ts +36 -0
  140. package/packages/hooks/useEntities.ts +44 -0
  141. package/packages/hooks/useEntityPropDataTypes.ts +37 -0
  142. package/packages/hooks/useFileConfigurations.ts +41 -0
  143. package/packages/hooks/useGroups.ts +81 -0
  144. package/packages/hooks/useNumberTemplates.ts +43 -0
  145. package/packages/hooks/useProperties.ts +44 -0
  146. package/packages/hooks/useRoleCategories.ts +42 -0
  147. package/packages/hooks/useRoles.ts +44 -0
  148. package/packages/index.ts +9 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jari-ace/element-plus-component",
3
3
  "private": false,
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "main": "lib/index.umd.cjs",
6
6
  "module": "lib/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "animate.css": "^4.1.1",
26
26
  "pretty-bytes": "^7.1.0",
27
27
  "vue-pdf-embed": "^2.1.3",
28
- "@jari-ace/app-bolts": "0.5.10"
28
+ "@jari-ace/app-bolts": "0.5.11"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/lodash-es": "^4.17.12",
@@ -33,7 +33,7 @@
33
33
  "@vitejs/plugin-vue-jsx": "^4.1.1",
34
34
  "@vue/tsconfig": "^0.5.1",
35
35
  "@vueuse/core": "^11.1.0",
36
- "element-plus": "2.10.3",
36
+ "element-plus": "2.11.7",
37
37
  "gulp": "^4.0.2",
38
38
  "gulp-autoprefixer": "^8.0.0",
39
39
  "gulp-clean-css": "^4.3.0",
@@ -46,18 +46,18 @@
46
46
  "sass": "^1.77.6",
47
47
  "typescript": "~5.4.5",
48
48
  "vite": "^6.3.5",
49
- "vue": "^3.5.13",
49
+ "vue": "^3.5.24",
50
50
  "vue-i18n": "^9.13.1",
51
- "vue-tsc": "^2.0.21"
51
+ "vue-tsc": "^2.2.12"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@vueuse/core": "^11.1.0",
58
- "element-plus": "^2.8.4",
58
+ "element-plus": "^2.11.7",
59
59
  "lodash-es": "^4.17.21",
60
- "vue": "^3.5.11",
60
+ "vue": "^3.5.24",
61
61
  "vue-i18n": "^9.13.1"
62
62
  },
63
63
  "scripts": {
@@ -21,7 +21,7 @@ const props = withDefaults(defineProps<{
21
21
  suffixIcon?: string | Component
22
22
  rows?: number
23
23
  autosize?: boolean | object
24
- autocomplete?: string
24
+ autocomplete?: AutoFill
25
25
  name?: string
26
26
  readonly?: boolean,
27
27
  max?: any
@@ -13,7 +13,7 @@ const visible = defineModel<boolean>({
13
13
  required: true
14
14
  });
15
15
  const props = defineProps<{
16
- appId: string,
16
+ appId?: string,
17
17
  preKey?: string
18
18
  }>();
19
19
  const axios = createAxiosWithoutCache();
@@ -22,7 +22,7 @@ const app = ref<AppInstance>();
22
22
  const key = ref("");
23
23
  const messages = ref<Record<string, string>>({})
24
24
  const emits = defineEmits(["success"])
25
- const appInstances = await useAppInstances();
25
+ const appInstances = useAppInstances();
26
26
 
27
27
  function onOpen() {
28
28
  loadApp();
@@ -32,7 +32,7 @@ const focused = ref(false)
32
32
  const editorVisible = ref(false)
33
33
  const select = ref<InstanceType<typeof ElSelect>>()
34
34
  const appName = ref("");
35
- const appInstances = await useAppInstances();
35
+ const appInstances = useAppInstances();
36
36
  const filterKey = ref("")
37
37
  const i18nTxt = ref("")
38
38
  const selectI18n = ref<InstanceType<typeof ElSelect>>();
@@ -43,13 +43,13 @@ let timeoutHandle: number | undefined = undefined;
43
43
  async function loadMessage(val?: string) {
44
44
  if (!val) val = model.value;
45
45
  if (!props.appId) return
46
+ i18nTxt.value = val
46
47
  const app = await appInstances.getById(props.appId)
47
48
  appName.value = app.name
48
- if (!val || !appName.value) {
49
+ if (!val || val.length === 0 || !appName.value) {
49
50
  i18nTxt.value = "";
50
51
  return;
51
52
  }
52
- i18nTxt.value = val
53
53
  let key = val;
54
54
  if (val && val.length > 0) {
55
55
  key = trim(key);
@@ -62,6 +62,7 @@ async function loadMessage(val?: string) {
62
62
  });
63
63
  const message = messages.find(m => m.locale === locale)
64
64
  if (message) {
65
+ await nextTick()
65
66
  i18nTxt.value = message.message
66
67
  }
67
68
  }
@@ -95,10 +96,13 @@ onUnmounted(() => {
95
96
  watch(model, () => {
96
97
  debounceLoadMessage();
97
98
  }, {
98
- deep: true,
99
- immediate: true
99
+ deep: true
100
100
  })
101
101
 
102
+ if (!i18nTxt.value) {
103
+ debounceLoadMessage()
104
+ }
105
+
102
106
  function onChange(value: string) {
103
107
  emits('change', value)
104
108
  }
@@ -120,27 +124,31 @@ defineExpose({
120
124
  </script>
121
125
 
122
126
  <template>
123
- <el-input ref="selectI18n" @focus="onFocus" v-show="!focused" v-model="i18nTxt" :size="size"
124
- :disabled="disabled"
125
- :type="textarea ? 'textarea': undefined">
126
- </el-input>
127
- <el-select ref="select" filterable remote :remote-method="filterMessages" v-show="focused"
128
- :disabled="disabled" default-first-option
129
- remote-show-suffix @change="onChange" :size="size" allow-create clearable
130
- @blur="onBlur" v-model="model">
131
- <el-option v-for="k in messageKeys" :key="k" :value="'{' + k +'}'"
132
- :label="'{' + k +'}'"></el-option>
133
- <template #footer>
134
- <ja-button link :style="{width: '100%'}" type="primary" @click="editorVisible=true"
135
- shortcut="Alt+I">
136
- 新建国际化文本(Alt+I)
137
- </ja-button>
138
- </template>
139
- </el-select>
140
- <message-editor :app-id="appId" :pre-key="filterKey" v-model="editorVisible"
141
- @success="onNewI18nCreated"></message-editor>
127
+ <div class="ja-input-i18n">
128
+ <el-input ref="selectI18n" @focus="onFocus" v-show="!focused" v-model="i18nTxt" :size="size"
129
+ :disabled="disabled"
130
+ :type="textarea ? 'textarea': undefined">
131
+ </el-input>
132
+ <el-select ref="select" filterable remote :remote-method="filterMessages" v-show="focused"
133
+ :disabled="disabled" default-first-option reserve-keyword
134
+ remote-show-suffix @change="onChange" :size="size" allow-create clearable
135
+ @blur="onBlur" v-model="model">
136
+ <el-option v-for="k in messageKeys" :key="k" :value="'{' + k +'}'"
137
+ :label="'{' + k +'}'"></el-option>
138
+ <template #footer>
139
+ <ja-button link :style="{width: '100%'}" type="primary" @click="editorVisible=true"
140
+ shortcut="Alt+I">
141
+ 新建国际化文本(Alt+I)
142
+ </ja-button>
143
+ </template>
144
+ </el-select>
145
+ <message-editor :app-id="appId" :pre-key="filterKey" v-model="editorVisible"
146
+ @success="onNewI18nCreated"></message-editor>
147
+ </div>
142
148
  </template>
143
149
 
144
150
  <style scoped lang="scss">
145
-
151
+ .ja-input-i18n {
152
+ flex: auto;
153
+ }
146
154
  </style>
@@ -4,6 +4,7 @@ import {ElInputNumber} from 'element-plus'
4
4
  import type {ValidationInstance} from '../../hooks/useBackendValidations'
5
5
  import {getValue, setValue} from "../../utils/objectUtils";
6
6
 
7
+ type ModelType = number | null | undefined;
7
8
  const props = withDefaults(defineProps<{
8
9
  min?: number
9
10
  max?: number
@@ -43,11 +44,10 @@ const input = ref<typeof ElInputNumber>()
43
44
  const emit = defineEmits<{
44
45
  blur: [evt: Event]
45
46
  focus: [evt: Event]
46
- change: [value?: number]
47
+ change: [value?: ModelType]
47
48
  }>()
48
- type ModelType = number;
49
49
 
50
- function onChange(value?: number) {
50
+ function onChange(value?: ModelType) {
51
51
  validator.removeFieldError(prop)
52
52
  setValue(model.formData, prop, mv.value)
53
53
  emit('change', value)
@@ -55,7 +55,8 @@ function onChange(value?: number) {
55
55
 
56
56
  const mv = ref(getValue(model.formData, prop) as ModelType);
57
57
  watch(() => model.formData, () => {
58
- mv.value = getValue(model.formData, prop) as ModelType
58
+ const value = getValue(model.formData, prop)
59
+ mv.value = value as ModelType
59
60
  }, {
60
61
  deep: true
61
62
  })
@@ -79,7 +80,7 @@ defineExpose({
79
80
  :aria-label="ariaLabel"
80
81
  :controls="controls"
81
82
  :controls-position="controlsPosition"
82
- v-model="mv"
83
+ v-model.number="mv"
83
84
  :name="name"
84
85
  :placeholder="placeholder"
85
86
  :precision="precision"
@@ -2,11 +2,12 @@
2
2
  import {
3
3
  createAxiosWithoutCache,
4
4
  type ProjectedPropertyDefinition,
5
- useEntityApi, useLoading
5
+ useLoading
6
6
  } from "@jari-ace/app-bolts";
7
7
  import {computed, nextTick, ref, watch} from "vue";
8
8
  import {ElDropdown, ElScrollbar, ElTag, ElIcon, ElEmpty, vLoading} from "element-plus";
9
9
  import {ArrowDown, ArrowUp} from "@element-plus/icons-vue";
10
+ import { useProperties } from "../../hooks/useProperties";
10
11
 
11
12
  const props = defineProps<{
12
13
  entityId?: string
@@ -17,7 +18,7 @@ const model = defineModel<string | undefined>({
17
18
  });
18
19
  const selectedProp = ref<string[]>([]);
19
20
  const axios = createAxiosWithoutCache();
20
- const api = useEntityApi(axios);
21
+ const {getProperties} = useProperties();
21
22
  const properties = ref<ProjectedPropertyDefinition[]>();
22
23
  const propsCache: Record<number, ProjectedPropertyDefinition[]> = {};
23
24
  const activeIndex = ref(0);
@@ -34,12 +35,7 @@ async function loadProperties() {
34
35
  currentEntityId = props.entityId
35
36
  }
36
37
  if (currentEntityId) {
37
- let p = propsCache[currentEntityId];
38
- if (!p) {
39
- p = await api.getProperties(currentEntityId);
40
- propsCache[currentEntityId] = p;
41
- }
42
- properties.value = p;
38
+ properties.value = await getProperties(currentEntityId);
43
39
  } else {
44
40
  properties.value = [];
45
41
  }
@@ -0,0 +1,154 @@
1
+ <script setup lang="ts">
2
+ import {createAxiosWithoutCache, type RoleCategory, useRoleCategoryApi} from "@jari-ace/app-bolts";
3
+ import {ref, watch} from "vue";
4
+ import {Check, Delete, Edit, InfoFilled, Plus} from "@element-plus/icons-vue";
5
+ import {useRoleCategories} from "../../hooks/useRoleCategories";
6
+ import {ElMessage, ElSelect, ElOption, ElInput, ElText, ElTooltip, ElIcon} from "element-plus";
7
+ import JaButton from "../button/JaButton.vue";
8
+ import vFocus from '../../directives/autofocus'
9
+
10
+ const props = defineProps<{
11
+ appId?: string,
12
+ allowEdit?: boolean
13
+ }>()
14
+ const axios = createAxiosWithoutCache()
15
+ const api = useRoleCategoryApi(axios)
16
+ const model = defineModel<string>({required: false})
17
+ const {getRoleCategories, refreshRoleCategoryCache} = useRoleCategories();
18
+ const categories = ref<RoleCategory[]>([])
19
+ const editingCategory = ref<RoleCategory>()
20
+
21
+ async function loadCategories() {
22
+ if (!props.appId) return;
23
+ categories.value = await getRoleCategories(props.appId)
24
+ if (categories.value.length > 0) model.value = categories.value[0].name
25
+ console.log(`Loading categories for ${props.appId}`, categories.value)
26
+ }
27
+
28
+ async function onAddClicked() {
29
+ if (!props.appId) {
30
+ throw new Error('appId 参数不能为空')
31
+ }
32
+ if (!!editingCategory.value) {
33
+ const r = await submit();
34
+ if (!r) return;
35
+ }
36
+ editingCategory.value = {
37
+ id: "0",
38
+ name: "",
39
+ app: {
40
+ id: props.appId
41
+ },
42
+ dataVersion: 0
43
+ }
44
+ categories.value.push(editingCategory.value)
45
+ }
46
+
47
+ async function onEditClicked(c: RoleCategory) {
48
+ if (!!editingCategory.value) {
49
+ if (!(await submit())) return;
50
+ }
51
+ editingCategory.value = c;
52
+ }
53
+
54
+ async function onSubmitClicked() {
55
+ if (!!editingCategory.value) {
56
+ if (!(await submit())) return;
57
+ }
58
+ editingCategory.value = undefined;
59
+ }
60
+
61
+ async function onDeleteClicked(c: RoleCategory) {
62
+ if (!!editingCategory.value) {
63
+ if (!(await submit())) return;
64
+ editingCategory.value = undefined;
65
+ }
66
+ await api.delete({
67
+ id: c.id,
68
+ dataVersion: c.dataVersion
69
+ })
70
+ refreshRoleCategoryCache(props.appId)
71
+ categories.value.splice(categories.value.indexOf(c), 1);
72
+ }
73
+
74
+ function onOptionClicked(e: Event, category: RoleCategory) {
75
+ if (category === editingCategory.value) {
76
+ e.preventDefault();
77
+ e.stopPropagation();
78
+ }
79
+ }
80
+
81
+ async function submit() {
82
+ if (!editingCategory.value) return true;
83
+ if (!editingCategory.value.name || editingCategory.value.name.length < 1) {
84
+ ElMessage.error("类别名称不能为空");
85
+ return false;
86
+ }
87
+ try {
88
+ let r: RoleCategory;
89
+ if (editingCategory.value.id == "0") {
90
+ r = await api.create({
91
+ name: editingCategory.value.name,
92
+ app: editingCategory.value.app
93
+ }, {
94
+ popValidationErrorNotification: true
95
+ })
96
+ } else {
97
+ r = await api.update({
98
+ ...editingCategory.value
99
+ }, {
100
+ popValidationErrorNotification: true
101
+ })
102
+ }
103
+ refreshRoleCategoryCache(props.appId)
104
+ editingCategory.value.id = r.id;
105
+ editingCategory.value.dataVersion = r.dataVersion;
106
+ return true;
107
+ } catch {
108
+ return false;
109
+ }
110
+ }
111
+
112
+ watch(() => props.appId, loadCategories, {immediate: true})
113
+ </script>
114
+
115
+ <template>
116
+ <el-select v-model="model" placeholder="[未分类]">
117
+ <el-option label="[未分类]" value=""/>
118
+ <el-option v-for="c in categories" :key="c.id" :label="c.name" :value="c.name">
119
+ <div style="display: flex; margin: 0 -32px 0 -20px; padding: 0 32px 0 20px"
120
+ @click="onOptionClicked($event, c)">
121
+ <div style="flex: 1;">
122
+ <el-text v-if="c !== editingCategory"> {{ c.name }}</el-text>
123
+ <el-input v-focus @click.prevent.stop v-if="c === editingCategory" size="small"
124
+ v-model="editingCategory.name" maxlength="255" @keydown.enter="onSubmitClicked"></el-input>
125
+ </div>
126
+ <div>
127
+ <ja-button v-if="c !== editingCategory && allowEdit" size="small" type="primary" :icon="Edit"
128
+ link @click.stop.prevent="onEditClicked(c)" tooltip="修改"></ja-button>
129
+ <ja-button v-if="c !== editingCategory && allowEdit" size="small" type="danger" :icon="Delete"
130
+ link @click.stop.prevent="onDeleteClicked(c)" tooltip="删除"></ja-button>
131
+ <ja-button v-if="c === editingCategory && allowEdit" size="small" type="primary"
132
+ :icon="Check" link @click.stop.prevent="onSubmitClicked" tooltip="提交"></ja-button>
133
+ </div>
134
+ </div>
135
+ </el-option>
136
+ <template #header>
137
+ <div style="display: flex; padding: 0 20px 0 10px">
138
+ <div style="flex: 1;">
139
+ <el-text><b>业务分类</b>
140
+ <el-tooltip content="业务分类限制角色只能授予同分类的用户组"><el-icon><info-filled/></el-icon></el-tooltip>
141
+ </el-text>
142
+ </div>
143
+ <div style="flex: 1; text-align: right;" v-if="allowEdit">
144
+ <ja-button size="small" type="primary" plain :icon="Plus" shortcut="Alt+A"
145
+ link tooltip="添加" @click.prevent.stop="onAddClicked"></ja-button>
146
+ </div>
147
+ </div>
148
+ </template>
149
+ </el-select>
150
+ </template>
151
+
152
+ <style scoped lang="scss">
153
+
154
+ </style>
@@ -11,17 +11,21 @@ import {JaButton} from "../button";
11
11
  import {JaInput} from "../input";
12
12
  import {JaFormItem} from "../formItem";
13
13
  import {JaBaseRolePicker} from "./index";
14
+ import {JaInputI18nRaw} from "../inputI18n";
14
15
  import {useBackendValidations} from "../../hooks/useBackendValidations";
15
16
  import type {JaForm} from "../form";
16
17
  import {ElDrawer, ElButton} from "element-plus";
17
18
  import vFocus from "../../directives/autofocus"
18
19
  import {useAppInstances} from "../../hooks/useAppInstances";
20
+ import {useRoles} from "../../hooks/useRoles";
21
+ import RoleCategorySelector from "./RoleCategorySelector.vue";
19
22
 
20
23
  const visible = defineModel<boolean>({
21
24
  default: false
22
25
  });
23
26
  const props = defineProps<{
24
- appName?: string
27
+ appName?: string,
28
+ category?: string
25
29
  }>();
26
30
  const emits = defineEmits<{
27
31
  (e: "success", g: Role): void
@@ -38,7 +42,8 @@ const initData: Role = {
38
42
  dataVersion: 0,
39
43
  description: "",
40
44
  id: "0",
41
- name: ""
45
+ name: "",
46
+ category: props.category
42
47
  }
43
48
 
44
49
  const state = ref<{
@@ -53,15 +58,14 @@ const api = useRoleApi(axios);
53
58
  const formRef = ref<typeof JaForm>()
54
59
  const rolePicker = ref<InstanceType<typeof JaBaseRolePicker>>();
55
60
  const app = ref<AppInstance>()
56
-
61
+ const apps = useAppInstances()
62
+ const {refreshRolesCache} = useRoles()
57
63
  async function init() {
58
64
  state.value.formData = {...initData};
59
65
  if (!props.appName) {
60
66
  throw new Error('rolePicker组件的appName属性不能为空')
61
67
  }
62
- app.value = await (
63
- await useAppInstances()
64
- ).getByName(props.appName);
68
+ app.value = await apps.getByName(props.appName);
65
69
  }
66
70
 
67
71
  async function submit() {
@@ -81,8 +85,10 @@ async function submit() {
81
85
  },
82
86
  description: role.description,
83
87
  name: role.name,
84
- caption: role.caption
88
+ caption: role.caption,
89
+ category: role.category
85
90
  }).then(g => {
91
+ refreshRolesCache(app.value!.id)
86
92
  emits('success', g);
87
93
  visible.value = false;
88
94
  }))
@@ -111,6 +117,9 @@ async function submit() {
111
117
  <ja-input-i18n-raw :app-id="app?.id" size="small"
112
118
  v-model="state.formData.caption"></ja-input-i18n-raw>
113
119
  </ja-form-item>
120
+ <ja-form-item label="业务分类" prop="category">
121
+ <role-category-selector :app-id="app?.id" v-model="state.formData.category"></role-category-selector>
122
+ </ja-form-item>
114
123
  <ja-form-item label="角色说明" prop="description">
115
124
  <ja-input type="textarea"/>
116
125
  </ja-form-item>
@@ -1,32 +1,25 @@
1
1
  <script setup lang="ts">
2
2
  import {
3
3
  type AppInstance,
4
- createAxiosWithoutCache,
5
- useAppApi,
6
- useRoleApi,
7
4
  type ProjectedRole,
8
5
  } from "@jari-ace/app-bolts";
9
6
  import {ref, watch} from "vue";
10
7
  import type {TreeNodeData} from "element-plus/es/components/tree/src/tree.type";
11
8
  import {ElTreeSelect} from "element-plus";
9
+ import {useAppInstances} from "../../hooks/useAppInstances";
10
+ import {useRoles} from "../../hooks/useRoles";
12
11
 
13
- const axios = createAxiosWithoutCache();
14
- const api = useRoleApi(axios);
15
- const appApi = useAppApi(axios);
12
+ const {getRoles} = useRoles()
16
13
  const props = defineProps<{
17
14
  appName?: string
18
15
  }>();
19
16
  const currentApp = ref<AppInstance>();
20
17
  const roles = ref<ProjectedRole[]>([]);
18
+ const apps = useAppInstances()
21
19
  const loadData = async () => {
22
20
  if (!props.appName) return;
23
- currentApp.value = await appApi.getByName(props.appName);
24
- roles.value = (
25
- await api.getAllRole(currentApp.value.id)
26
- ).map(r => {
27
- r.name = r.appName + "." + r.name
28
- return r
29
- });
21
+ currentApp.value = await apps.getByName(props.appName);
22
+ roles.value = await getRoles(currentApp.value.id);
30
23
  if (selectedRoleName.value) {
31
24
  currentRole.value = findRole(selectedRoleName.value, roles.value);
32
25
  } else {
@@ -2,9 +2,12 @@ import {type SFCWithInstall, withInstall} from "../../utils/install";
2
2
  import BaseRolePicker from "./baseRolePicker.vue";
3
3
  import RolePicker from "./RolePicker.vue";
4
4
  import RolePickerRaw from "./RolePickerRaw.vue";
5
+ import RoleCategorySelector from "./RoleCategorySelector.vue"
5
6
 
6
7
  export const JaBaseRolePicker: SFCWithInstall<typeof BaseRolePicker> = withInstall(BaseRolePicker);
7
8
 
8
9
  export const JaRolePicker: SFCWithInstall<typeof RolePicker> = withInstall(RolePicker);
9
10
 
10
11
  export const JaRolePickerRaw: SFCWithInstall<typeof RolePickerRaw> = withInstall(RolePickerRaw);
12
+
13
+ export const JaRoleCategorySelector: SFCWithInstall<typeof RoleCategorySelector> = withInstall(RoleCategorySelector);
@@ -3,3 +3,4 @@ import Upload from './uploader.vue'
3
3
  import _JaUploader from './JaUploader.vue'
4
4
  export const JaUploader = withInstall(_JaUploader);
5
5
  export const JaUploaderRaw = withInstall(Upload);
6
+ export * from './types'
@@ -0,0 +1,4 @@
1
+ import type {Meta, UppyFile} from "@uppy/core";
2
+
3
+ export type AceFile = UppyFile<Meta, Record<string, never>>;
4
+