@qqt-product/system 0.0.2 → 0.0.17

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 (179) hide show
  1. package/dist/index.es.js +53481 -10448
  2. package/dist/index.umd.js +94 -22
  3. package/dist/lib/components/QAccountList/src/QAccountCreate.vue.d.ts +2881 -0
  4. package/dist/lib/components/QAccountList/src/QAccountDetail.vue.d.ts +2874 -0
  5. package/dist/lib/components/QAccountList/src/QAccountEdit.vue.d.ts +2882 -0
  6. package/dist/lib/components/QAccountList/src/QAccountList.vue.d.ts +23 -4
  7. package/dist/lib/components/QBackgroundFileTaskList/src/QBackgroundFileTaskList.vue.d.ts +9 -4
  8. package/dist/lib/components/QElsEmailSendLogList/src/QElsEmailSendLogList.vue.d.ts +9 -4
  9. package/dist/lib/components/QElsMsgRecordList/src/QElsMsgRecordDetail.vue.d.ts +2867 -0
  10. package/dist/lib/components/QElsMsgRecordList/src/QElsMsgRecordList.vue.d.ts +2 -3
  11. package/dist/lib/components/QElsTenantPortalNewsList/src/QElsTenantPortalNewsDetail.vue.d.ts +2867 -0
  12. package/dist/lib/components/QElsTenantPortalNewsList/src/QElsTenantPortalNewsEdit.vue.d.ts +2879 -0
  13. package/dist/lib/components/QElsTenantPortalNewsList/src/QElsTenantPortalNewsList.vue.d.ts +38 -14
  14. package/dist/lib/components/QI18nList/src/QI18nList.vue.d.ts +2 -6
  15. package/dist/lib/components/QImChatGroupList/src/QImChatGroupList.vue.d.ts +5 -8
  16. package/dist/lib/components/QMqRecordList/src/QMqRecordList.vue.d.ts +9 -4
  17. package/dist/lib/components/QPermissionDataList/src/QPermissionDataAuth.vue.d.ts +387 -3
  18. package/dist/lib/components/QPermissionDataList/src/QPermissionDataEdit.vue.d.ts +2875 -0
  19. package/dist/lib/components/QPermissionDataList/src/QPermissionDataList.vue.d.ts +126 -0
  20. package/dist/lib/components/QPurchaseNoticeList/src/QPurchaseNoticeDetail.vue.d.ts +2867 -0
  21. package/dist/lib/components/QPurchaseNoticeList/src/QPurchaseNoticeEdit.vue.d.ts +2890 -0
  22. package/dist/lib/components/QPurchaseNoticeList/src/QPurchaseNoticeList.vue.d.ts +25 -5
  23. package/dist/lib/components/QPurchaseNoticeList/src/use-field-select-modal-hook.d.ts +7 -0
  24. package/dist/lib/components/QPurchaseNoticeTemplateList/src/QPurchaseNoticeTemplateList.vue.d.ts +222 -28
  25. package/dist/lib/components/QPurchaseNoticeTemplateList/src/QPurchaseNoticeTemplateModal.vue.d.ts +45 -0
  26. package/dist/lib/components/QQuartzJobList/src/QQuartzJobList.vue.d.ts +24 -5
  27. package/dist/lib/components/QRoleList/src/QRoleList.vue.d.ts +32 -7
  28. package/dist/lib/components/QRoleList/src/components/userAuthorization/index.d.ts +4 -4
  29. package/dist/lib/components/QRoleList/src/useConfigData.d.ts +1 -11
  30. package/dist/lib/components/QSupplierAccountList/src/QSupplierAccountList.vue.d.ts +25 -4
  31. package/dist/lib/components/QSupplierAccountList/src/useConfigData.d.ts +9 -0
  32. package/dist/lib/components/QUsageList/src/QUsageList.vue.d.ts +15 -35
  33. package/dist/lib/components/QUsageList/src/useConfigData.d.ts +111 -10
  34. package/dist/lib/components/QcustomConfigEdit/component/AddDictCodeModal.vue.d.ts +25 -0
  35. package/dist/lib/components/QcustomConfigEdit/component/regexComponent.d.ts +9 -10
  36. package/dist/lib/components/QcustomConfigEdit/src/QcustomConfigEdit.vue.d.ts +1208 -0
  37. package/dist/lib/components/QcustomConfigEdit/src/useConfigData.d.ts +1 -1
  38. package/dist/lib/components/QcustomConfigList/src/QcustomConfigList.vue.d.ts +8 -7
  39. package/dist/lib/components/QsysConfigList/src/QsysConfigList.vue.d.ts +2 -3
  40. package/dist/lib/components/index.d.ts +2 -2
  41. package/dist/lib/components/integratedNodesList/src/QIntegratedNodesDetail.vue.d.ts +2866 -0
  42. package/dist/lib/components/integratedNodesList/src/QIntegratedNodesEdit.vue.d.ts +2875 -0
  43. package/dist/lib/components/integratedNodesList/src/index.vue.d.ts +8 -11
  44. package/dist/lib/components/integratedReportSearchList/src/index.vue.d.ts +16 -10
  45. package/dist/lib/components/loginAbnormalLogList/src/index.vue.d.ts +2 -9
  46. package/dist/lib/components/loginLogList/src/index.vue.d.ts +2 -8
  47. package/dist/lib/components/loginSupplierLogList/src/index.vue.d.ts +2 -12
  48. package/dist/lib/components/operateLogList/src/index.vue.d.ts +2 -13
  49. package/dist/style.css +1 -1
  50. package/dist/vite-env.d.ts +13 -13
  51. package/package.json +24 -11
  52. package/.eslintignore +0 -4
  53. package/.eslintrc.cjs +0 -22
  54. package/.prettierignore +0 -4
  55. package/.prettierrc.cjs +0 -41
  56. package/.vscode/extensions.json +0 -3
  57. package/dist/lib/components/QCompanyermissionList/src/form.vue.d.ts +0 -80
  58. package/dist/lib/components/QCompanyermissionList/src/types.d.ts +0 -44
  59. package/dist/lib/components/integratedReportList/src/index.vue.d.ts +0 -70
  60. package/dist/vite.svg +0 -1
  61. package/index.html +0 -13
  62. package/public/vite.svg +0 -1
  63. package/src/App.vue +0 -8
  64. package/src/lib/components/QAccountList/index.ts +0 -6
  65. package/src/lib/components/QAccountList/src/QAccountDetail.vue +0 -191
  66. package/src/lib/components/QAccountList/src/QAccountEdit.vue +0 -241
  67. package/src/lib/components/QAccountList/src/QAccountList.vue +0 -530
  68. package/src/lib/components/QAccountList/src/useConfigData.ts +0 -53
  69. package/src/lib/components/QBackgroundFileTaskList/index.ts +0 -6
  70. package/src/lib/components/QBackgroundFileTaskList/src/QBackgroundFileTaskList.vue +0 -137
  71. package/src/lib/components/QBackgroundFileTaskList/src/useConfigData.ts +0 -20
  72. package/src/lib/components/QCompanyermissionList/src/editTree.vue +0 -291
  73. package/src/lib/components/QCompanyermissionList/src/form.vue +0 -238
  74. package/src/lib/components/QCompanyermissionList/src/index.vue +0 -309
  75. package/src/lib/components/QCompanyermissionList/src/types.ts +0 -44
  76. package/src/lib/components/QElsEmailSendLogList/index.ts +0 -6
  77. package/src/lib/components/QElsEmailSendLogList/src/QElsEmailSendLogList.vue +0 -166
  78. package/src/lib/components/QElsEmailSendLogList/src/useConfigData.ts +0 -19
  79. package/src/lib/components/QElsMsgRecordList/index.ts +0 -6
  80. package/src/lib/components/QElsMsgRecordList/src/QElsMsgRecordDetail.vue +0 -148
  81. package/src/lib/components/QElsMsgRecordList/src/QElsMsgRecordList.vue +0 -124
  82. package/src/lib/components/QElsMsgRecordList/src/useConfigData.ts +0 -22
  83. package/src/lib/components/QElsTenantPortalNewsList/index.ts +0 -6
  84. package/src/lib/components/QElsTenantPortalNewsList/src/QElsTenantPortalNewsDetail.vue +0 -139
  85. package/src/lib/components/QElsTenantPortalNewsList/src/QElsTenantPortalNewsEdit.vue +0 -196
  86. package/src/lib/components/QElsTenantPortalNewsList/src/QElsTenantPortalNewsList.vue +0 -122
  87. package/src/lib/components/QElsTenantPortalNewsList/src/useConfigData.ts +0 -20
  88. package/src/lib/components/QI18nList/index.ts +0 -6
  89. package/src/lib/components/QI18nList/src/QI18nForm.vue +0 -141
  90. package/src/lib/components/QI18nList/src/QI18nList.vue +0 -361
  91. package/src/lib/components/QI18nList/src/useConfigData.ts +0 -37
  92. package/src/lib/components/QImChatGroupList/index.ts +0 -6
  93. package/src/lib/components/QImChatGroupList/src/QImChatGroupList.vue +0 -94
  94. package/src/lib/components/QImChatGroupList/src/useConfigData.ts +0 -17
  95. package/src/lib/components/QMqRecordList/index.ts +0 -6
  96. package/src/lib/components/QMqRecordList/src/QMqRecordList.vue +0 -105
  97. package/src/lib/components/QMqRecordList/src/useConfigData.ts +0 -18
  98. package/src/lib/components/QPasswordSecurityPolicy/index.ts +0 -6
  99. package/src/lib/components/QPasswordSecurityPolicy/src/QPasswordSecurityPolicy.vue +0 -266
  100. package/src/lib/components/QPermissionDataList/index.ts +0 -6
  101. package/src/lib/components/QPermissionDataList/src/QPermissionDataAuth.vue +0 -3
  102. package/src/lib/components/QPermissionDataList/src/QPermissionDataEdit.vue +0 -221
  103. package/src/lib/components/QPermissionDataList/src/QPermissionDataList.vue +0 -117
  104. package/src/lib/components/QPermissionDataList/src/form.vue +0 -109
  105. package/src/lib/components/QPurchaseNoticeList/index.ts +0 -6
  106. package/src/lib/components/QPurchaseNoticeList/src/QPurchaseNoticeDetail.vue +0 -147
  107. package/src/lib/components/QPurchaseNoticeList/src/QPurchaseNoticeEdit.vue +0 -244
  108. package/src/lib/components/QPurchaseNoticeList/src/QPurchaseNoticeList.vue +0 -163
  109. package/src/lib/components/QPurchaseNoticeList/src/useConfigData.ts +0 -22
  110. package/src/lib/components/QPurchaseNoticeTemplateList/index.ts +0 -6
  111. package/src/lib/components/QPurchaseNoticeTemplateList/src/QPurchaseNoticeTemplateList.vue +0 -85
  112. package/src/lib/components/QPurchaseNoticeTemplateList/src/useConfigData.ts +0 -18
  113. package/src/lib/components/QQuartzJobList/index.ts +0 -6
  114. package/src/lib/components/QQuartzJobList/src/QQuartzJobList.vue +0 -263
  115. package/src/lib/components/QQuartzJobList/src/components/JCron.vue +0 -82
  116. package/src/lib/components/QQuartzJobList/src/components/JCronModal.vue +0 -985
  117. package/src/lib/components/QQuartzJobList/src/components/QuartzJobModal.vue +0 -176
  118. package/src/lib/components/QQuartzJobList/src/useConfigData.ts +0 -26
  119. package/src/lib/components/QRoleList/index.ts +0 -6
  120. package/src/lib/components/QRoleList/src/QRoleList.vue +0 -288
  121. package/src/lib/components/QRoleList/src/components/content-header/contentHeader.less +0 -31
  122. package/src/lib/components/QRoleList/src/components/content-header/index.tsx +0 -42
  123. package/src/lib/components/QRoleList/src/components/userAuthorization/index.tsx +0 -690
  124. package/src/lib/components/QRoleList/src/components/userAuthorization/userAuthorization.less +0 -97
  125. package/src/lib/components/QRoleList/src/useConfigData.ts +0 -33
  126. package/src/lib/components/QSupplierAccountList/index.ts +0 -6
  127. package/src/lib/components/QSupplierAccountList/src/QSupplierAccountForm.vue +0 -187
  128. package/src/lib/components/QSupplierAccountList/src/QSupplierAccountList.vue +0 -302
  129. package/src/lib/components/QSupplierAccountList/src/useConfigData.ts +0 -29
  130. package/src/lib/components/QUsageList/index.ts +0 -6
  131. package/src/lib/components/QUsageList/src/QUsageList.vue +0 -82
  132. package/src/lib/components/QUsageList/src/useConfigData.ts +0 -20
  133. package/src/lib/components/QcustomConfigEdit/component/AddDictCodeModal.vue +0 -140
  134. package/src/lib/components/QcustomConfigEdit/component/TempalePreviewModal.vue +0 -100
  135. package/src/lib/components/QcustomConfigEdit/component/dataFormatComponent.tsx +0 -100
  136. package/src/lib/components/QcustomConfigEdit/component/regexComponent.tsx +0 -71
  137. package/src/lib/components/QcustomConfigEdit/index.ts +0 -6
  138. package/src/lib/components/QcustomConfigEdit/src/QcustomConfigEdit.vue +0 -1807
  139. package/src/lib/components/QcustomConfigEdit/src/QcustomConfigRender.tsx +0 -242
  140. package/src/lib/components/QcustomConfigEdit/src/types.ts +0 -71
  141. package/src/lib/components/QcustomConfigEdit/src/useConfigComputed.ts +0 -75
  142. package/src/lib/components/QcustomConfigEdit/src/useConfigData.ts +0 -123
  143. package/src/lib/components/QcustomConfigEdit/src/useConfigMethods.ts +0 -117
  144. package/src/lib/components/QcustomConfigEdit/src/useConstant.ts +0 -301
  145. package/src/lib/components/QcustomConfigEdit/style/index.less +0 -41
  146. package/src/lib/components/QcustomConfigList/component/ImportJsonCustomConfig.vue +0 -135
  147. package/src/lib/components/QcustomConfigList/index.ts +0 -6
  148. package/src/lib/components/QcustomConfigList/src/QcustomConfigList.vue +0 -268
  149. package/src/lib/components/QcustomConfigList/src/types.ts +0 -1
  150. package/src/lib/components/QcustomConfigList/src/useConfigData.ts +0 -23
  151. package/src/lib/components/QcustomConfigList/src/useMethods.ts +0 -36
  152. package/src/lib/components/QcustomConfigList/style/index.less +0 -3
  153. package/src/lib/components/QsysConfigList/index.ts +0 -6
  154. package/src/lib/components/QsysConfigList/src/QsysConfigList.vue +0 -125
  155. package/src/lib/components/QsysConfigList/src/types.ts +0 -1
  156. package/src/lib/components/QsysConfigList/src/useConfigData.ts +0 -17
  157. package/src/lib/components/QsysConfigList/src/useMethods.ts +0 -11
  158. package/src/lib/components/QsysConfigList/style/index.less +0 -3
  159. package/src/lib/components/index.ts +0 -78
  160. package/src/lib/components/integratedNodesList/src/QIntegratedNodesDetail.vue +0 -49
  161. package/src/lib/components/integratedNodesList/src/QIntegratedNodesEdit.vue +0 -143
  162. package/src/lib/components/integratedNodesList/src/index.vue +0 -136
  163. package/src/lib/components/integratedReportList/src/index.vue +0 -86
  164. package/src/lib/components/integratedReportSearchList/src/index.vue +0 -66
  165. package/src/lib/components/loginAbnormalLogList/src/index.vue +0 -50
  166. package/src/lib/components/loginLogList/src/index.vue +0 -57
  167. package/src/lib/components/loginSupplierLogList/src/index.vue +0 -63
  168. package/src/lib/components/operateLogList/src/index.vue +0 -57
  169. package/src/lib/index.ts +0 -15
  170. package/src/lib/utils/constant.ts +0 -1
  171. package/src/lib/utils/global.hook.ts +0 -337
  172. package/src/lib/utils/global.types.ts +0 -49
  173. package/src/lib/utils/regexp.ts +0 -143
  174. package/src/main.ts +0 -11
  175. package/src/vite-env.d.ts +0 -13
  176. package/tsconfig.json +0 -24
  177. package/tsconfig.node.json +0 -9
  178. package/vite.config.ts +0 -61
  179. /package/dist/{index.es.d.ts → index.d.ts} +0 -0
@@ -1,690 +0,0 @@
1
- import { ref, defineComponent, PropType, ExtractPropTypes, computed, onMounted } from 'vue'
2
- import type { Ref, ComputedRef } from 'vue'
3
- import QContentHeader from '../content-header'
4
-
5
- import { BUTTON_CUSTOM, BUTTON_CUSTOM_PRIMARY } from '@qqt-product/ui'
6
- import type { GlobalPageLayoutTypes } from '@qqt-product/ui'
7
-
8
- import { message as Message } from '@qqt-product/ui'
9
-
10
- import qqtApi from '@qqt-product/api'
11
- import type { Map } from '@qqt-product/api'
12
-
13
- import qqtUtils from '@qqt-product/utils'
14
- const { debounce, cloneDeep } = qqtUtils
15
-
16
- import { QIcon } from '@qqt-product/icons'
17
- import { UpOutlined, DownOutlined, CaretRightOutlined, CaretDownOutlined } from '@ant-design/icons-vue'
18
-
19
- import './userAuthorization.less'
20
-
21
- const authProps = {
22
- rows: {
23
- type: Array as PropType<GlobalPageLayoutTypes.RecordStringNumber[]>,
24
- default() {
25
- return []
26
- },
27
- },
28
- /**
29
- |--------------------------------------------------
30
- | 目前为止该授权组件主要应用于三个页面
31
- | 租户管理 TenantList(默认)
32
- | 角色管理 RoleList
33
- | 供应商权限组 SupplierGroupList
34
- | 其中 租户管理 列表页面有批量、单选功能需要区分
35
- |--------------------------------------------------
36
- */
37
- parentPath: {
38
- type: String as PropType<'TenantList' | 'RoleList' | 'SupplierGroupList'>,
39
- default: 'TenantList',
40
- },
41
- }
42
-
43
- export type AuthProps = ExtractPropTypes<typeof authProps>
44
-
45
- // 定义树节点类型
46
- export interface TreeNode {
47
- __show?: boolean
48
- __checkall?: boolean
49
- __indeterminate?: boolean
50
- __checked?: boolean
51
- __has_children?: boolean
52
- __sibling_has_children?: boolean
53
- level: number
54
- isLeaf: boolean
55
- key: string
56
- menuType: number
57
- parentId: string
58
- slotTitle: string
59
- value: string
60
- children?: null | TreeNode[]
61
- }
62
-
63
- export default defineComponent({
64
- name: 'QUserAuthorization',
65
- components: {
66
- 'q-content-header': QContentHeader,
67
- 'q-icon': QIcon,
68
- 'up-outlined': UpOutlined,
69
- 'down-outlined': DownOutlined,
70
- 'caret-right-outlined': CaretRightOutlined,
71
- 'caret-down-outlined': CaretDownOutlined,
72
- },
73
- props: authProps,
74
- setup(props: AuthProps, ctx) {
75
- const Request: qqtApi.Request = qqtApi.useHttp()
76
-
77
- // 自定义属性常量设置
78
- const SHOW = '__show'
79
- const CHECKALL = '__checkall'
80
- const INDETERMINATE = '__indeterminate'
81
- const CHECKED = '__checked'
82
- const HAS_CHILDREN = '__has_children' // 有子级
83
- const SIBLING_HAS_CHILDREN = '__sibling_has_children' // 同级别有子级
84
-
85
- /**
86
- * @description:
87
- * 递归操作
88
- * 根据给定值 value 和节点 property 递归查找树的所有层级关系结果
89
- *
90
- * @param {*} array
91
- * @param {*} property
92
- * @param {*} value
93
- * @param {*} childrenName
94
- * @param {*} fn
95
- * @return {*}
96
- */
97
- const getNestedParentRelationItems = (array: TreeNode[], property = 'key', value = '', childrenName = 'children') => {
98
- /**
99
- * @description 递归查找所有符合条件依赖
100
- *
101
- * @param {*} arr
102
- * @returns
103
- */
104
- console.time('getRelation')
105
- function recursion(arr: TreeNode[]) {
106
- let result: TreeNode[] = []
107
- for (const v of arr) {
108
- const val: string = v[property]
109
- if (val === value) {
110
- result.push(v)
111
- break
112
- } else {
113
- const child = v[childrenName]
114
- if (child && child.length) {
115
- const sub = recursion(child)
116
- if (sub && sub.length) {
117
- result = [v].concat(sub)
118
- // 自定义格式化处理数据
119
- formatItem(v)
120
- }
121
- }
122
- }
123
- }
124
- if (result.length) {
125
- return result
126
- }
127
- }
128
-
129
- console.timeEnd('getRelation')
130
- return recursion(array)
131
- }
132
-
133
- /**
134
- * @description: 赋值全选或半勾选操作
135
- *
136
- * @param {*} item
137
- * @return {*}
138
- */
139
- function formatItem(item) {
140
- // if (item.key === '1394598965592260610') {
141
- // console.log('item :>> ', item)
142
- // }
143
- const children = item.children || []
144
- const checkAll = children.every((n) => n[CHECKED] || n[CHECKALL])
145
- const indeterminate = children.some((n) => {
146
- return n[CHECKED] || n[CHECKALL] || n[INDETERMINATE]
147
- })
148
- if (children && children.length) {
149
- if (item[CHECKALL] !== checkAll) {
150
- item[CHECKALL] = checkAll
151
- }
152
- const flag = !checkAll && indeterminate
153
- if (item[INDETERMINATE] !== flag) {
154
- item[INDETERMINATE] = flag
155
- }
156
- }
157
- }
158
-
159
- /**
160
- * @description:
161
- * 递归操作
162
- * 设置子级绑定值
163
- * @param {*} array
164
- * @param {*} bool
165
- * @param {*} childrenName
166
- * @return {*}
167
- */
168
- const arrayTreeSetBool = (array: TreeNode[], bool = false, childrenName = 'children') => {
169
- const recursion = (arr: TreeNode[]) => {
170
- arr.forEach((v) => {
171
- if (v[HAS_CHILDREN]) {
172
- if (v[CHECKALL] !== bool) {
173
- v[CHECKALL] = bool
174
- }
175
- if (v[INDETERMINATE]) {
176
- v[INDETERMINATE] = false
177
- }
178
- } else {
179
- if (v[CHECKED] !== bool) {
180
- v[CHECKED] = bool
181
- }
182
- }
183
-
184
- const child = v[childrenName]
185
- if (child && child.length) recursion(child)
186
- })
187
- }
188
- recursion(array)
189
- }
190
-
191
- /**
192
- * @description:
193
- * 递归操作
194
- * 树级列表各层级统一添加相同自定义属性值
195
- * @param {*} array
196
- * @param {*} levelName
197
- * @param {*} childrenName
198
- * @return {*}
199
- */
200
- const arrayTreeAddPropertys = (array: TreeNode[], levelName = 'level', childrenName = 'children') => {
201
- if (!Array.isArray(array)) return []
202
- const recursion = (array: TreeNode[], level = 0) => {
203
- level++
204
- const siblingHasChildren = array.some((v) => v.children)
205
- return array.map((v) => {
206
- v[levelName] = level
207
- const child = v[childrenName] as TreeNode[]
208
- const hasChildren = !!(child && child.length)
209
- // 展开/收起过滤切换绑定值
210
- v[SHOW] = false
211
- // checkbox 绑定值
212
- v[CHECKED] = false
213
-
214
- v[CHECKALL] = false
215
- v[INDETERMINATE] = false
216
- // 标识有没有子级
217
- v[HAS_CHILDREN] = hasChildren
218
- // 标识同级别其他 item 有没有子级, 用于布局排列控制
219
- v[SIBLING_HAS_CHILDREN] = siblingHasChildren
220
- if (hasChildren) recursion(child, level)
221
- return v
222
- })
223
- }
224
- return recursion(array)
225
- }
226
-
227
- /**
228
- * @description:
229
- * 递归操作
230
- * 格式化处理树级列表各层级半勾选绑定值
231
- * @param {*} array
232
- * @param {*} childrenName
233
- * @return {*}
234
- */
235
- const arrayTreeFormatItem = (array: TreeNode[], permissionIds: string[], property = 'key', childrenName = 'children') => {
236
- if (!Array.isArray(array)) return []
237
- let num = 0
238
-
239
- const recursion = (arr: TreeNode[]) => {
240
- arr.forEach((v) => {
241
- if (permissionIds.includes(v[property])) {
242
- // 有子级,绑定在 __checkAll 属性上面
243
- if (v[HAS_CHILDREN]) {
244
- v[CHECKALL] = true
245
- } else {
246
- v[CHECKED] = true
247
- }
248
- num++
249
- }
250
- const child = v[childrenName] as TreeNode[]
251
- if (child && child.length) recursion(child)
252
-
253
- // 格式化处理每一层级半勾选绑定值
254
- // 注,此处后序遍历处理才能确保把父级绑定半勾选状态值
255
- formatItem(v)
256
- })
257
- }
258
- recursion(array)
259
- console.log('num :>> ', num)
260
- }
261
-
262
- /**
263
- * 计算属性
264
- */
265
- // 是否单个权限配置
266
- const isSingle: ComputedRef<boolean> = computed(() => props.rows.length === 1)
267
-
268
- // 租户管理
269
- const isTenantList: ComputedRef<boolean> = computed(() => props.parentPath === 'TenantList')
270
-
271
- // 角色管理
272
- const isRoleList: ComputedRef<boolean> = computed(() => props.parentPath === 'RoleList')
273
-
274
- // 供应商权限组
275
- const isSupplierGroupList: ComputedRef<boolean> = computed(() => props.parentPath === 'SupplierGroupList')
276
-
277
- // 标题
278
- const title: ComputedRef<string> = computed(() => {
279
- return isTenantList.value ? '租户' : isRoleList.value ? '角色' : '供应商权限组'
280
- })
281
-
282
- // 副标题
283
- const computedSubTit: ComputedRef<string> = computed(() => {
284
- const names = props.rows.map((n) => {
285
- if (isTenantList.value) {
286
- return n.elsAccount ? `${n.elsAccount}_${n.companyName}` : ''
287
- } else {
288
- return n.roleCode ? `${n.roleCode}_${n.roleName}` : ''
289
- }
290
- })
291
- return names.join(',')
292
- })
293
-
294
- /**
295
- * 属性定义
296
- */
297
- // loading
298
- const spinning: Ref<boolean> = ref(false)
299
- const treeList: Ref<TreeNode[]> = ref([])
300
- // const ids: Ref<string[]> = ref([])
301
- const permissionIds: Ref<string[]> = ref([])
302
- const lastpermissionIds: Ref<string[]> = ref([])
303
-
304
- const toggleShow = debounce(function checkAllChange(event: Event, item: TreeNode) {
305
- console.log('item :>> ', item)
306
- item[SHOW] = !item[SHOW]
307
- }, 150)
308
-
309
- // 全选操作
310
- const handleCheckAllChange = debounce(function checkAllChange(event: Event, item: TreeNode) {
311
- console.log('item :>> ', item)
312
- if (!item.children) {
313
- return
314
- }
315
-
316
- item[CHECKALL] = !item[CHECKALL]
317
- item[INDETERMINATE] = false
318
- arrayTreeSetBool(item.children, item[CHECKALL])
319
-
320
- // 层级一后面子级勾选全部时,需要设置其父级半勾选状态
321
- if (item.level > 1) {
322
- getNestedParentRelationItems(treeList.value, 'key', item.key)
323
- }
324
- }, 150)
325
-
326
- // 最底层 checkbox 勾选
327
- // 需要递归查找其所有关联的父级checkbox 并设置半勾选状态
328
- const handleLastLevelCheckBoxChange = debounce(function lastLevelCheckBoxChange(event: Event, item: TreeNode) {
329
- console.log('item :>> ', item)
330
- item[CHECKED] = !item[CHECKED]
331
-
332
- if (item.level === 1) {
333
- return
334
- }
335
- getNestedParentRelationItems(treeList.value, 'key', item.key)
336
- }, 150)
337
-
338
- // 获取所有树级节点的key值
339
- const handleGetPermissionIds = (array: TreeNode[], property = 'key', childrenName = 'children') => {
340
- if (!Array.isArray(array)) return []
341
- const result: string[] = []
342
- const recursion = (arr: TreeNode[]) => {
343
- arr.forEach((v) => {
344
- // if (v.key === '1394598965592260610') {
345
- // console.log('v :>> ', v)
346
- // }
347
- const val = v[property]
348
- if (v[HAS_CHILDREN]) {
349
- if (v[CHECKALL] || v[INDETERMINATE]) {
350
- result.push(val)
351
- }
352
- } else {
353
- if (v[CHECKED]) {
354
- result.push(val)
355
- }
356
- }
357
-
358
- const child = v[childrenName]
359
- if (child && child.length) recursion(child)
360
- })
361
- }
362
- recursion(array)
363
-
364
- return result
365
- }
366
-
367
- const handleAuthSave = () => {
368
- const permissionIds = handleGetPermissionIds(treeList.value)
369
- console.log('permissionIds.length :>> ', permissionIds.length)
370
- spinning.value = true
371
- let params = {}
372
- let request: Promise<void | Map> = Promise.resolve()
373
-
374
- // 租户管理
375
- if (isTenantList.value) {
376
- // 单个租户
377
- if (isSingle.value) {
378
- const { elsAccount = '' } = props.rows[0] || {}
379
- params = {
380
- elsAccount,
381
- permissionIds: permissionIds.join(','),
382
- lastpermissionIds: lastpermissionIds.value.join(','),
383
- }
384
- request = Request.post({ url: '/account/permission/saveCompanyPermission', data: params })
385
- } else {
386
- // 多个租户
387
- const elsAccount = props.rows.map((n) => n.elsAccount as string)
388
- params = {
389
- elsAccountList: elsAccount,
390
- permissionIds: permissionIds.join(','),
391
- lastpermissionIds: '',
392
- }
393
- request = Request.post({ url: '/account/permission/saveCompanyPermissionList', data: params })
394
- }
395
- }
396
-
397
- // 角色管理
398
- if (isRoleList.value) {
399
- const { id = '' } = props.rows[0] || {}
400
- params = {
401
- roleId: id,
402
- permissionIds: permissionIds.join(','),
403
- lastpermissionIds: lastpermissionIds.value.join(','),
404
- }
405
- request = Request.post({ url: '/account/permission/saveRolePermission', data: params })
406
- }
407
-
408
- // 供应商权限组
409
- if (isSupplierGroupList.value) {
410
- const { id = '' } = props.rows[0] || {}
411
- params = {
412
- groupId: id,
413
- permissionIds: permissionIds.join(','),
414
- lastpermissionIds: lastpermissionIds.value.join(','),
415
- }
416
- request = Request.post({ url: '/account/supplierGroup/saveGroupPermission', data: params })
417
- }
418
-
419
- request
420
- .then((res) => {
421
- const response = res as GlobalPageLayoutTypes.ResponseType
422
-
423
- const type = response.success ? 'success' : 'error'
424
- Message[type](response.message)
425
- if (response.success) {
426
- ctx.emit('authCancel')
427
- }
428
- })
429
- .finally(() => {
430
- spinning.value = false
431
- })
432
- }
433
-
434
- // 获取树级节点数据
435
- const getTreeData = () => {
436
- const Map = {
437
- // 租户管理
438
- TenantList: {
439
- treeListApi: '/account/role/queryTreeList',
440
- permissionApi: '/account/permission/queryCompanyPermission',
441
- params: {},
442
- },
443
- // 角色管理
444
- RoleList: {
445
- treeListApi: '/account/role/queryTreeList',
446
- permissionApi: '/account/permission/queryRolePermission',
447
- params: {},
448
- },
449
- // 供应商权限组
450
- SupplierGroupList: {
451
- treeListApi: '/account/supplierGroup/queryTreeList',
452
- permissionApi: '/account/supplierGroup/queryGroupPermission',
453
- params: {},
454
- },
455
- }
456
- const { treeListApi, permissionApi } = Map[props.parentPath]
457
- let { params } = Map[props.parentPath]
458
- spinning.value = true
459
- Request.get({ url: treeListApi })
460
- .then((res) => {
461
- if (!res.success) {
462
- return
463
- }
464
- const response = res.result
465
-
466
- // 树级数据添加自定义属性
467
- treeList.value = arrayTreeAddPropertys(response.treeList)
468
- console.log('treeList.value :>> ', treeList.value)
469
-
470
- // ids.value = ids
471
-
472
- // 查询单个租户 或 单个角色 或 单个供应商 权限数据
473
- if (isSingle.value) {
474
- // 单个租户
475
- if (isTenantList.value) {
476
- const { elsAccount = '' } = props.rows[0] || {}
477
- params = { elsAccount }
478
- }
479
-
480
- // 单个角色
481
- if (isRoleList.value) {
482
- const { id = '' } = props.rows[0] || {}
483
- params = { roleId: id }
484
- }
485
-
486
- // 单个供应商
487
- if (isSupplierGroupList.value) {
488
- const { elsAccount = '', groupId = '' } = props.rows[0] || {}
489
- params = { elsAccount, groupId }
490
- }
491
-
492
- spinning.value = true
493
- Request.get({ url: permissionApi, params }).then((res) => {
494
- if (!res.success) {
495
- return
496
- }
497
- const result = res.result || []
498
- permissionIds.value = result
499
- lastpermissionIds.value = cloneDeep(result)
500
- console.time('time')
501
- arrayTreeFormatItem(treeList.value, permissionIds.value)
502
- console.timeEnd('time')
503
- })
504
- }
505
- })
506
- .finally(() => {
507
- spinning.value = false
508
- })
509
- }
510
-
511
- // 菜单图标
512
- // menuType, (0: 一级菜单,1: 子菜单, 2: 按钮)
513
- const renderIcon = (item: TreeNode) => {
514
- return item.menuType === 0 ? (
515
- <q-icon class="icon" type="icon-first-level-menu" size="16" color="#5570f1" style={{ marginRight: '4px' }} />
516
- ) : item.menuType === 1 ? (
517
- <q-icon class="icon" type="icon-secondary-menu" size="16" color="#454F59" style={{ marginRight: '4px' }} />
518
- ) : null
519
- }
520
-
521
- const renderMenuItem = (item: TreeNode) => {
522
- return (
523
- <a-col lg={8} xl={6} xxl={4}>
524
- <a-checkbox checked={item[CHECKED]} onChange={(e: Event) => handleLastLevelCheckBoxChange(e, item)}>
525
- {renderIcon(item)}
526
- {item.slotTitle}
527
- </a-checkbox>
528
- </a-col>
529
- )
530
- }
531
-
532
- const renderSubMenu = (item: TreeNode) => {
533
- // 根据层级分别渲染不同的结构布局
534
- const hasChildren = !!item[HAS_CHILDREN]
535
-
536
- let subArr
537
- if (hasChildren) {
538
- if (item.children) {
539
- subArr = item.children.map((sub) => renderItem(sub)) as JSX.Element[]
540
- }
541
- }
542
-
543
- // 根据子级的子级添加class类名
544
- const hasGrandchildren = item.children && item.children.some((sub) => sub.children)
545
-
546
- const subArrElem = hasGrandchildren ? <div class="children">{subArr}</div> : <a-row class="children">{subArr}</a-row>
547
-
548
- // 渲染层级一
549
- if (item.level === 1) {
550
- const toggleBtn = !hasChildren ? null : (
551
- <a-button type="link" onClick={(e) => toggleShow(e, item)}>
552
- <span>{item[SHOW] ? '收起' : '展开'}</span>
553
- {item[SHOW] ? <up-outlined /> : <down-outlined />}
554
- </a-button>
555
- )
556
-
557
- const childrenEl = !hasChildren ? null : (
558
- <q-collapse-transition>
559
- {!item[SHOW] ? null : <div class={['collapse', hasGrandchildren ? '' : 'noneGrandchildren']}>{hasGrandchildren ? subArr : <a-row class="children">{subArr}</a-row>}</div>}
560
- </q-collapse-transition>
561
- )
562
-
563
- return (
564
- <div class="item">
565
- <div class={['level', `level_${item.level}`, item[SHOW] ? '' : 'border']}>
566
- <div class="info">
567
- {!hasChildren ? (
568
- <a-checkbox checked={item[CHECKED]} onChange={(e: Event) => handleLastLevelCheckBoxChange(e, item)}>
569
- {renderIcon(item)}
570
- <strong>{item.slotTitle}</strong>
571
- </a-checkbox>
572
- ) : (
573
- <a-checkbox indeterminate={item[INDETERMINATE]} checked={item[CHECKALL]} onChange={(e: Event) => handleCheckAllChange(e, item)}>
574
- {renderIcon(item)}
575
- <strong>{item.slotTitle}</strong>
576
- </a-checkbox>
577
- )}
578
- <span class="tip">
579
- {'请耐心地完成您的'}
580
- {`${item.slotTitle}`}
581
- {'权限配置设置'}
582
- </span>
583
- </div>
584
- <div class="extra">{toggleBtn}</div>
585
- </div>
586
- {childrenEl}
587
- </div>
588
- )
589
- }
590
-
591
- // 渲染层级二
592
- if (item.level === 2) {
593
- return (
594
- <div class={['level', `level_${item.level}`]}>
595
- <div class="info">
596
- {!hasChildren ? (
597
- <a-checkbox checked={item[CHECKED]} onChange={(e: Event) => handleLastLevelCheckBoxChange(e, item)}>
598
- {renderIcon(item)}
599
- {item.slotTitle}
600
- </a-checkbox>
601
- ) : (
602
- <a-checkbox indeterminate={item[INDETERMINATE]} checked={item[CHECKALL]} onChange={(e: Event) => handleCheckAllChange(e, item)}>
603
- {renderIcon(item)}
604
- <strong>{item.slotTitle}</strong>
605
- </a-checkbox>
606
- )}
607
- </div>
608
- {subArrElem}
609
- </div>
610
- )
611
- }
612
-
613
- // 递归渲染缄层级三及后面层级
614
- return (
615
- <div class={['level', `level_${item.level}`]}>
616
- {!hasChildren ? null : (
617
- <span class={['triangle', item[SHOW] ? 'rotate90' : '']} onClick={(e: Event) => toggleShow(e, item)}>
618
- <caret-right-outlined style={item[SHOW] ? { color: '#5570f1', fontSize: '16px' } : { color: 'rgba(0, 0, 0, 0.45)', fontSize: '16px' }} />
619
- </span>
620
- )}
621
- {!hasChildren ? (
622
- <a-checkbox checked={item[CHECKED]} onChange={(e: Event) => handleLastLevelCheckBoxChange(e, item)}>
623
- {renderIcon(item)}
624
- {item.slotTitle}
625
- </a-checkbox>
626
- ) : (
627
- <a-checkbox indeterminate={item[INDETERMINATE]} checked={item[CHECKALL]} onChange={(e: Event) => handleCheckAllChange(e, item)}>
628
- {renderIcon(item)}
629
- {item.slotTitle}
630
- </a-checkbox>
631
- )}
632
- {!hasChildren ? null : <q-collapse-transition>{!item[SHOW] ? null : subArrElem}</q-collapse-transition>}
633
- </div>
634
- )
635
- }
636
-
637
- // 渲染结构
638
- const renderItem = (item: TreeNode) => {
639
- // 某部分三级菜单有多个相邻同级别菜单
640
- // 可能出现某几个没有子级,而其他有子级的情况
641
- // 如供应商管理--准入管理简化模式
642
- // 此处条件判断,如果相同层级某一个有子级就全部渲染成单行
643
- return item.level === 1 || item[HAS_CHILDREN] || item[SIBLING_HAS_CHILDREN] ? renderSubMenu(item) : renderMenuItem(item)
644
- }
645
-
646
- // init 初始化
647
- onMounted(() => getTreeData())
648
-
649
- const buttons: GlobalPageLayoutTypes.PageButton[] = [
650
- {
651
- ...BUTTON_CUSTOM_PRIMARY,
652
- title: '保存',
653
- emit: true,
654
- emitKey: 'authSave',
655
- },
656
- {
657
- ...BUTTON_CUSTOM,
658
- title: '取消',
659
- emit: true,
660
- emitKey: 'authCancel',
661
- },
662
- ]
663
-
664
- const headerProps = {
665
- buttons,
666
- onAuthSave: () => handleAuthSave(),
667
- ...ctx.attrs,
668
- }
669
-
670
- return () => {
671
- return (
672
- <div class="UserAuthorization">
673
- <a-spin spinning={spinning.value}>
674
- <q-content-header {...headerProps}></q-content-header>
675
- <div class="container">
676
- <div class="pageBox">
677
- <div class="title">
678
- <strong>{title.value}</strong>
679
- <strong>{props.rows.length > 1 ? '批量权限配置' : '权限配置'}</strong>
680
- <span>{computedSubTit.value}</span>
681
- </div>
682
- {treeList.value.map((n) => renderItem(n))}
683
- </div>
684
- </div>
685
- </a-spin>
686
- </div>
687
- )
688
- }
689
- },
690
- })