@yxhl/specter-pui-vtk 1.0.0

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 (49) hide show
  1. package/README.md +122 -0
  2. package/dist/specter-pui-vtk.css +1 -0
  3. package/dist/specter-pui.es.js +3289 -0
  4. package/dist/specter-pui.es.js.map +1 -0
  5. package/dist/specter-pui.umd.js +2 -0
  6. package/dist/specter-pui.umd.js.map +1 -0
  7. package/package.json +65 -0
  8. package/src/assets/css/globals.scss +250 -0
  9. package/src/assets/css/index.scss +271 -0
  10. package/src/assets/css/settings.scss +10 -0
  11. package/src/assets/css/variables.scss +0 -0
  12. package/src/assets/icon/logo.svg +9 -0
  13. package/src/assets/img/background.png +0 -0
  14. package/src/assets/img/dtx.png +0 -0
  15. package/src/commons/filters/dictionary.js +75 -0
  16. package/src/commons/filters/format.js +112 -0
  17. package/src/commons/filters/mask.js +25 -0
  18. package/src/commons/index.js +17 -0
  19. package/src/commons/request.js +89 -0
  20. package/src/commons/storage.js +41 -0
  21. package/src/commons/themes.js +153 -0
  22. package/src/commons/validation.js +72 -0
  23. package/src/components/README.md +35 -0
  24. package/src/components/assembly/VtkArea.vue +259 -0
  25. package/src/components/assembly/VtkCheckbox.vue +168 -0
  26. package/src/components/assembly/VtkCount.vue +403 -0
  27. package/src/components/assembly/VtkDatePicker.vue +326 -0
  28. package/src/components/assembly/VtkEmpty.vue +107 -0
  29. package/src/components/assembly/VtkFab.vue +78 -0
  30. package/src/components/assembly/VtkFormItem.vue +166 -0
  31. package/src/components/assembly/VtkImg.vue +372 -0
  32. package/src/components/assembly/VtkPage.vue +156 -0
  33. package/src/components/assembly/VtkPdf.vue +424 -0
  34. package/src/components/assembly/VtkProj.vue +539 -0
  35. package/src/components/assembly/VtkRadio.vue +82 -0
  36. package/src/components/assembly/VtkSearch.vue +145 -0
  37. package/src/components/assembly/VtkSelect.vue +104 -0
  38. package/src/components/assembly/VtkStepper.vue +160 -0
  39. package/src/components/message/alert.vue +31 -0
  40. package/src/components/message/confirm.vue +44 -0
  41. package/src/components/message/index.js +55 -0
  42. package/src/components/message/loading.vue +33 -0
  43. package/src/components/message/prompt.vue +57 -0
  44. package/src/components/message/toast.vue +45 -0
  45. package/src/components/message/vtkMessage.vue +27 -0
  46. package/src/composables/useMixins.js +2 -0
  47. package/src/composables/usePage.js +311 -0
  48. package/src/index.js +109 -0
  49. package/src/stores/message.js +79 -0
@@ -0,0 +1,2 @@
1
+ // 从 usePage.js 中导出 useMixins
2
+ export { useMixins } from './usePage.js'
@@ -0,0 +1,311 @@
1
+ // composables/useMixins.js
2
+ import { ref, reactive } from 'vue'
3
+ import Request from '../commons/request.js'
4
+ import Message from '../components/message/index.js'
5
+ import storage from '../commons/storage.js'
6
+
7
+ /**
8
+ * 通用 mixins composable
9
+ * @param {Object} urlConfig - URL 配置对象
10
+ * @returns {Object} 包含所有状态和方法的对象
11
+ */
12
+ export function useMixins(urlConfig = {}) {
13
+ // 响应式数据
14
+ const queryParam = reactive({})
15
+ const desserts = ref([])
16
+ const loading = ref(false)
17
+ const superQueryParams = ref('')
18
+ const page = reactive({
19
+ pageno: 1,
20
+ limit: 10
21
+ })
22
+ const pageData = ref({})
23
+ const sumup = ref({})
24
+ const pageDataCopy = ref([])
25
+ const overlay = ref(false)
26
+ const user = ref({})
27
+
28
+ // URL 配置
29
+ const url = reactive(urlConfig)
30
+
31
+ /**
32
+ * 获取查询参数
33
+ * @returns {Object} 查询参数对象
34
+ */
35
+ const getQueryParams = () => {
36
+ user.value = storage.get('user')
37
+ if (!queryParam.areaCode) {
38
+ queryParam.areaCode = user.value?.areacode
39
+ }
40
+ const codex = Object.assign({}, queryParam)
41
+ const params = {
42
+ pageno: page.pageno,
43
+ limit: page.limit,
44
+ codex: codex
45
+ }
46
+ return params
47
+ }
48
+
49
+ /**
50
+ * 加载页面数据
51
+ */
52
+ const loadPage = () => {
53
+ if (!url.list) {
54
+ Message.toast('请先设置url.list属性', { color: 'warning' })
55
+ return
56
+ }
57
+ const params = getQueryParams()
58
+ loading.value = true
59
+
60
+ // 兼容处理 vtk 对象
61
+ if (window.$vtk?.message?.loading) {
62
+ window.$vtk.message.loading.show()
63
+ }
64
+
65
+ Request.postJson(url.list, params)
66
+ .then((res) => {
67
+ if (window.$vtk?.message?.loading) {
68
+ window.$vtk.message.loading.hide()
69
+ }
70
+
71
+ if (res.meta.success || res.data) {
72
+ desserts.value = res.data?.rows || []
73
+ pageData.value = res.data
74
+ sumup.value = res.data.sumup ? res.data.sumup : {}
75
+ pageDataCopy.value = res.data
76
+ }
77
+ loading.value = false
78
+ })
79
+ .catch((error) => {
80
+ console.error('加载页面数据失败:', error)
81
+ loading.value = false
82
+ if (window.$vtk?.message?.loading) {
83
+ window.$vtk.message.loading.hide()
84
+ }
85
+ })
86
+ }
87
+
88
+ /**
89
+ * 搜索查询
90
+ */
91
+ const searchQuery = () => {
92
+ page.pageno = 1
93
+ page.limit ??= 10
94
+ loadPage()
95
+ }
96
+
97
+ /**
98
+ * 分页变化处理
99
+ * @param {Object} pageInfo - 分页信息
100
+ */
101
+ const getListPage = (pageInfo) => {
102
+ page.pageno = pageInfo.pageno
103
+ page.limit = pageInfo.limit
104
+ loadPage()
105
+ }
106
+
107
+ /**
108
+ * 删除项
109
+ * @param {string|number} id - 要删除的项ID
110
+ * @param {string} text - 确认提示文本
111
+ */
112
+ const deleteItem = (id, text) => {
113
+ if (!url.delete) {
114
+ Message.toast('请设置url.delete属性!', { color: 'warning' })
115
+ return
116
+ }
117
+
118
+ Message.confirm(
119
+ { title: '确认删除', text: text ? text : '是否删除?' },
120
+ (result) => {
121
+ if (result) {
122
+ Request.getForm(url.delete, { id: id })
123
+ .then((res) => {
124
+ if (res.meta.success) {
125
+ Message.toast('删除成功', { color: 'success' })
126
+ loadPage()
127
+ } else {
128
+ Message.toast('删除失败', { color: 'warning' })
129
+ }
130
+ })
131
+ .catch((error) => {
132
+ console.error('删除失败:', error)
133
+ Message.toast('删除失败', { color: 'warning' })
134
+ })
135
+ }
136
+ }
137
+ )
138
+ }
139
+
140
+ /**
141
+ * 复制项
142
+ * @param {string|number} id - 要复制的项ID
143
+ * @param {string} text - 确认提示文本
144
+ */
145
+ const copyItem = (id, text) => {
146
+ if (!url.copy) {
147
+ Message.toast('请设置url.copy!', { color: 'warning' })
148
+ return
149
+ }
150
+
151
+ Message.confirm(
152
+ { title: '拷贝', text: text ? text : '是否确认拷贝当前数据?' },
153
+ (result) => {
154
+ if (result) {
155
+ Request.getForm(url.copy, { id: id })
156
+ .then((res) => {
157
+ if (res.meta.success) {
158
+ Message.toast('拷贝成功', { color: 'success' })
159
+ loadPage()
160
+ } else {
161
+ Message.toast('拷贝失败', { color: 'warning' })
162
+ }
163
+ })
164
+ .catch((error) => {
165
+ console.error('拷贝失败:', error)
166
+ Message.toast('拷贝失败', { color: 'warning' })
167
+ })
168
+ }
169
+ }
170
+ )
171
+ }
172
+
173
+ /**
174
+ * 编辑项
175
+ * @param {Object} record - 要编辑的记录
176
+ * @param {Object} modalFormRef - 模态框引用
177
+ */
178
+ const edit = (record, modalFormRef) => {
179
+ if (modalFormRef?.value) {
180
+ modalFormRef.value.edit(record)
181
+ }
182
+ }
183
+
184
+ /**
185
+ * 添加新项
186
+ * @param {Object} modalFormRef - 模态框引用
187
+ */
188
+ const add = (modalFormRef) => {
189
+ if (modalFormRef?.value) {
190
+ modalFormRef.value.add()
191
+ }
192
+ }
193
+
194
+ /**
195
+ * 模态框确认回调
196
+ */
197
+ const modalFormOk = () => {
198
+ loadPage()
199
+ }
200
+
201
+ /**
202
+ * 导出数据
203
+ */
204
+ const expData = () => {
205
+ overlay.value = true
206
+
207
+ if (window.$vtk?.message?.loading) {
208
+ window.$vtk.message.loading.show()
209
+ }
210
+
211
+ const params = getQueryParams()
212
+ Request.exp(url.exp, params)
213
+ .then((res) => {
214
+ if (window.$vtk?.message?.loading) {
215
+ window.$vtk.message.loading.hide()
216
+ }
217
+
218
+ if (res) {
219
+ const disposition = res.headers['content-disposition']
220
+ const filename = decodeURI(
221
+ disposition.substring(
222
+ disposition.indexOf('filename=') + 9,
223
+ disposition.length
224
+ )
225
+ )
226
+ const blob = new Blob([res.data], {
227
+ type: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
228
+ })
229
+
230
+ if (window.navigator.msSaveOrOpenBlob) {
231
+ navigator.msSaveBlob(blob)
232
+ } else {
233
+ const link = document.createElement('a')
234
+ link.style.display = 'none'
235
+ link.href = URL.createObjectURL(blob)
236
+ link.download = filename
237
+ document.body.appendChild(link)
238
+ link.click()
239
+ document.body.removeChild(link)
240
+ }
241
+ }
242
+ overlay.value = false
243
+ })
244
+ .catch((error) => {
245
+ console.error('导出数据失败:', error)
246
+ overlay.value = false
247
+ if (window.$vtk?.message?.loading) {
248
+ window.$vtk.message.loading.hide()
249
+ }
250
+ })
251
+ }
252
+
253
+ /**
254
+ * 重置查询参数
255
+ */
256
+ const resetQueryParams = () => {
257
+ Object.keys(queryParam).forEach(key => {
258
+ delete queryParam[key]
259
+ })
260
+ }
261
+
262
+ /**
263
+ * 重置分页
264
+ */
265
+ const resetPage = () => {
266
+ page.pageno = 1
267
+ page.limit = 10
268
+ }
269
+
270
+ /**
271
+ * 更新 URL 配置
272
+ * @param {Object} newUrlConfig - 新的 URL 配置
273
+ */
274
+ const updateUrlConfig = (newUrlConfig) => {
275
+ Object.assign(url, newUrlConfig)
276
+ }
277
+
278
+ // 返回所有状态和方法
279
+ return {
280
+ // 响应式数据
281
+ queryParam,
282
+ desserts,
283
+ loading,
284
+ superQueryParams,
285
+ page,
286
+ pageData,
287
+ sumup,
288
+ pageDataCopy,
289
+ overlay,
290
+ user,
291
+ url,
292
+
293
+ // 方法
294
+ getQueryParams,
295
+ loadPage,
296
+ searchQuery,
297
+ getListPage,
298
+ deleteItem,
299
+ copyItem,
300
+ edit,
301
+ add,
302
+ modalFormOk,
303
+ expData,
304
+ resetQueryParams,
305
+ resetPage,
306
+ updateUrlConfig
307
+ }
308
+ }
309
+
310
+ // 默认导出保持向后兼容
311
+ export default useMixins
package/src/index.js ADDED
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Specter PUI - Vue 3 组件库
3
+ * 基于 Vuetify 3 的智能组件库
4
+ */
5
+
6
+ // 组件导出
7
+ export { default as VtkArea } from './components/assembly/VtkArea.vue'
8
+ export { default as VtkCheckbox } from './components/assembly/VtkCheckbox.vue'
9
+ export { default as VtkCount } from './components/assembly/VtkCount.vue'
10
+ export { default as VtkDatePicker } from './components/assembly/VtkDatePicker.vue'
11
+ export { default as VtkEmpty } from './components/assembly/VtkEmpty.vue'
12
+ export { default as VtkFab } from './components/assembly/VtkFab.vue'
13
+ export { default as VtkFormItem } from './components/assembly/VtkFormItem.vue'
14
+ export { default as VtkImg } from './components/assembly/VtkImg.vue'
15
+ export { default as VtkPage } from './components/assembly/VtkPage.vue'
16
+ export { default as VtkPdf } from './components/assembly/VtkPdf.vue'
17
+ export { default as VtkProj } from './components/assembly/VtkProj.vue'
18
+ export { default as VtkRadio } from './components/assembly/VtkRadio.vue'
19
+ export { default as VtkSearch } from './components/assembly/VtkSearch.vue'
20
+ export { default as VtkSelect } from './components/assembly/VtkSelect.vue'
21
+ export { default as VtkStepper } from './components/assembly/VtkStepper.vue'
22
+
23
+ // 工具函数导出
24
+ export * from './commons/filters/dictionary.js'
25
+ export * from './commons/filters/format.js'
26
+ export * from './commons/filters/mask.js'
27
+ export { default as request } from './commons/request.js'
28
+ export { default as storage } from './commons/storage.js'
29
+ export { default as themes } from './commons/themes.js'
30
+ export * from './commons/validation.js'
31
+
32
+ // Composables 导出
33
+ export { useMixins } from './composables/usePage.js'
34
+
35
+ // 消息组件导出
36
+ export { default as vtkMessage } from './components/message/index.js'
37
+
38
+ // 插件安装函数
39
+ import vtkMessage from './components/message/index.js'
40
+ import storage from './commons/storage.js'
41
+ import themes from './commons/themes.js'
42
+ import request from './commons/request.js'
43
+ import * as dictionary from './commons/filters/dictionary.js'
44
+ import * as mask from './commons/filters/mask.js'
45
+ import * as format from './commons/filters/format.js'
46
+
47
+ // 导入所有组件
48
+ import VtkArea from './components/assembly/VtkArea.vue'
49
+ import VtkCheckbox from './components/assembly/VtkCheckbox.vue'
50
+ import VtkCount from './components/assembly/VtkCount.vue'
51
+ import VtkDatePicker from './components/assembly/VtkDatePicker.vue'
52
+ import VtkEmpty from './components/assembly/VtkEmpty.vue'
53
+ import VtkFab from './components/assembly/VtkFab.vue'
54
+ import VtkFormItem from './components/assembly/VtkFormItem.vue'
55
+ import VtkImg from './components/assembly/VtkImg.vue'
56
+ import VtkPage from './components/assembly/VtkPage.vue'
57
+ import VtkPdf from './components/assembly/VtkPdf.vue'
58
+ import VtkProj from './components/assembly/VtkProj.vue'
59
+ import VtkRadio from './components/assembly/VtkRadio.vue'
60
+ import VtkSearch from './components/assembly/VtkSearch.vue'
61
+ import VtkSelect from './components/assembly/VtkSelect.vue'
62
+ import VtkStepper from './components/assembly/VtkStepper.vue'
63
+
64
+ export function install(app, options = {}) {
65
+ // 注册全局组件
66
+ const components = {
67
+ VtkArea,
68
+ VtkCheckbox,
69
+ VtkCount,
70
+ VtkDatePicker,
71
+ VtkEmpty,
72
+ VtkFab,
73
+ VtkFormItem,
74
+ VtkImg,
75
+ VtkPage,
76
+ VtkPdf,
77
+ VtkProj,
78
+ VtkRadio,
79
+ VtkSearch,
80
+ VtkSelect,
81
+ VtkStepper
82
+ }
83
+
84
+ // 注册组件
85
+ Object.keys(components).forEach(name => {
86
+ app.component(name, components[name])
87
+ })
88
+
89
+ // 挂载全局对象
90
+ app.config.globalProperties.$vtk = {
91
+ message: vtkMessage,
92
+ request,
93
+ storage,
94
+ themes,
95
+ filters: {
96
+ ...dictionary, // 字典过滤方法: dict, analyType, analyLevel
97
+ ...mask, // 脱敏方法: mobile, idcard
98
+ ...format // 格式化方法: date, num, age, txt, abs
99
+ },
100
+ ...options
101
+ }
102
+
103
+ return app
104
+ }
105
+
106
+ // 默认导出
107
+ export default {
108
+ install
109
+ }
@@ -0,0 +1,79 @@
1
+ // stores/message.js
2
+ import { defineStore } from 'pinia'
3
+
4
+ export const useMessageStore = defineStore('message', {
5
+ state: () => ({
6
+ alert: {
7
+ isActive: false,
8
+ options: {
9
+ title: '',
10
+ text: '',
11
+ color: '',
12
+ width: 500
13
+ }
14
+ },
15
+ confirm: {
16
+ isActive: false,
17
+ options: {
18
+ title: '',
19
+ text: '',
20
+ color: '',
21
+ width: 500,
22
+ cancelText: '取消',
23
+ confirmText: '确定'
24
+ }
25
+ },
26
+ loading: {
27
+ isActive: false,
28
+ options: {
29
+ title: '',
30
+ text: '',
31
+ color: '',
32
+ width: 300,
33
+ indeterminate: true,
34
+ value: 0,
35
+ progressColor: 'primary'
36
+ }
37
+ },
38
+ prompt: {
39
+ isActive: false,
40
+ options: {
41
+ title: '',
42
+ text: '',
43
+ color: '',
44
+ width: 500,
45
+ label: '',
46
+ placeholder: '',
47
+ inputType: 'text',
48
+ cancelText: '取消',
49
+ confirmText: '确定'
50
+ }
51
+ },
52
+ toast: {
53
+ isActive: false,
54
+ options: {
55
+ text: '',
56
+ color: '',
57
+ timeout: 3000,
58
+ position: 'top'
59
+ }
60
+ }
61
+ }),
62
+
63
+ actions: {
64
+ hide(type) {
65
+ if (this[type]) {
66
+ this[type].isActive = false
67
+ }
68
+ },
69
+
70
+ show(type, options) {
71
+ if (this[type]) {
72
+ this[type] = {
73
+ isActive: true,
74
+ options: options
75
+ }
76
+ }
77
+ }
78
+ }
79
+ })