@kyfe/fms-vue2-components 0.0.2-beta.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 (62) hide show
  1. package/dist/assets/css/fms-ks-decrypt.css +1 -0
  2. package/dist/fms-copy-box/index.js +69 -0
  3. package/dist/fms-copy-box/style.css +1 -0
  4. package/dist/fms-empty/index.js +42 -0
  5. package/dist/fms-empty/style.css +1 -0
  6. package/dist/fms-ks-decrypt/index.js +9 -0
  7. package/dist/fms-ks-decrypt.bcc12f44.js +335 -0
  8. package/dist/fms-ks-file-upload/index.js +148 -0
  9. package/dist/fms-ks-file-upload/style.css +1 -0
  10. package/dist/fms-ks-file-view/index.js +286 -0
  11. package/dist/fms-ks-file-view/style.css +1 -0
  12. package/dist/fms-scroll-list/index.js +241 -0
  13. package/dist/fms-scroll-list/style.css +1 -0
  14. package/dist/index.js +37 -0
  15. package/dist/plugin-vue2_normalizer.ed7092a9.js +30 -0
  16. package/package.json +31 -0
  17. package/src/assets/images/code.png +0 -0
  18. package/src/assets/images/copy-icon.png +0 -0
  19. package/src/assets/images/tag-gkbk.png +0 -0
  20. package/src/assets/style/common.less +62 -0
  21. package/src/components/fms-copy-box/fms-copy-box.vue +97 -0
  22. package/src/components/fms-copy-box/index.js +7 -0
  23. package/src/components/fms-copy-box//345/244/215/345/210/266.md +0 -0
  24. package/src/components/fms-empty/assets/default.png +0 -0
  25. package/src/components/fms-empty/assets/search.png +0 -0
  26. package/src/components/fms-empty/fms-empty.vue +57 -0
  27. package/src/components/fms-empty/index.js +7 -0
  28. package/src/components/fms-ks-decrypt/component/call/index.vue +283 -0
  29. package/src/components/fms-ks-decrypt/component/call/mixin.less +50 -0
  30. package/src/components/fms-ks-decrypt/component/custom-call/index.vue +50 -0
  31. package/src/components/fms-ks-decrypt/fms-ks-decrypt.vue +257 -0
  32. package/src/components/fms-ks-decrypt/index.js +7 -0
  33. package/src/components/fms-ks-decrypt/phone.svg +24 -0
  34. package/src/components/fms-ks-decrypt//346/225/217/346/204/237/347/233/221/346/216/247/347/273/204/344/273/266.md +140 -0
  35. package/src/components/fms-ks-file-upload/assets/icon_close.png +0 -0
  36. package/src/components/fms-ks-file-upload/fms-ks-file-upload.vue +254 -0
  37. package/src/components/fms-ks-file-upload/index.js +7 -0
  38. package/src/components/fms-ks-file-upload//344/270/212/344/274/240/347/273/204/344/273/266.md +0 -0
  39. package/src/components/fms-ks-file-view/assets/icon_default.svg +23 -0
  40. package/src/components/fms-ks-file-view/assets/icon_default_new.png +0 -0
  41. package/src/components/fms-ks-file-view/assets/icon_excel.svg +20 -0
  42. package/src/components/fms-ks-file-view/assets/icon_excel_new.png +0 -0
  43. package/src/components/fms-ks-file-view/assets/icon_file.png +0 -0
  44. package/src/components/fms-ks-file-view/assets/icon_pdf_new.png +0 -0
  45. package/src/components/fms-ks-file-view/assets/icon_ppt.svg +20 -0
  46. package/src/components/fms-ks-file-view/assets/icon_ppt_new.png +0 -0
  47. package/src/components/fms-ks-file-view/assets/icon_preview_file.png +0 -0
  48. package/src/components/fms-ks-file-view/assets/icon_txt.png +0 -0
  49. package/src/components/fms-ks-file-view/assets/icon_word.svg +19 -0
  50. package/src/components/fms-ks-file-view/assets/icon_word_new.png +0 -0
  51. package/src/components/fms-ks-file-view/assets/icon_xmind.png +0 -0
  52. package/src/components/fms-ks-file-view/components/attachment.vue +343 -0
  53. package/src/components/fms-ks-file-view/fms-ks-file-view.vue +165 -0
  54. package/src/components/fms-ks-file-view/index.js +7 -0
  55. package/src/components/fms-ks-file-view/utils/index.js +27 -0
  56. package/src/components/fms-ks-file-view//346/226/207/344/273/266/351/242/204/350/247/210.md +23 -0
  57. package/src/components/fms-scroll-list/Waterfall.js +91 -0
  58. package/src/components/fms-scroll-list/fms-scroll-list.vue +294 -0
  59. package/src/components/fms-scroll-list/index.js +7 -0
  60. package/src/components/fms-scroll-list//346/273/232/345/212/250.md +0 -0
  61. package/src/index.js +37 -0
  62. package/vite.config.js +82 -0
@@ -0,0 +1,294 @@
1
+ <!--
2
+ * @Description: 滚动列表组件
3
+ -->
4
+ <template>
5
+ <div class="ky-scroll-list" ref="refScroll">
6
+ <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
7
+ <van-list v-model="loading" :finished="finished" :immediate-check="false" @load="getData">
8
+ <div :style="scrollContentStyle" ref="scrollListContentRef" class="ky-scroll-list__content" :class="{isGrid: isEnabledMultiCol && isGrid}">
9
+ <slot :scrollData="list" :params="setParams"></slot>
10
+ </div>
11
+ <template #finished>
12
+ <div v-if="list.length > 0">{{ setConfig.finishedTips }}</div>
13
+ </template>
14
+ </van-list>
15
+ <fms-empty v-if="(finished || isInitEmpty) && !loading && list.length === 0" :image="emptyType" />
16
+ </van-pull-refresh>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ const initParams = {
22
+ page: 1,
23
+ pageSize: 20
24
+ }
25
+ import FmsEmpty from '../fms-empty'
26
+ import { MaxDecrypt } from '@kyfe/decrypt'
27
+ import { WaterFall } from "./Waterfall";
28
+ const MENU = {
29
+ id: '151349933249281652',
30
+ title: 'OA申请'
31
+ }
32
+ export default {
33
+ name: 'FmsScrollList',
34
+ props: {
35
+ config: Object,
36
+ params: Object,
37
+ onRefreshBefore: Function,
38
+ isEnabledMultiCol: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ gap: {
43
+ type: Array,
44
+ /** 大屏两列布局的上下以及左右间距, arr[0]上下, arr[1]左右 */
45
+ default: () => ([12, 12])
46
+ },
47
+ /** 大屏两列布局用grid布局还是waterfall, waterfall用于item不等高的情况,grid用于等高的情况 */
48
+ isGrid: {
49
+ type: Boolean,
50
+ default: false
51
+ },
52
+ finishedTips: {
53
+ type: String,
54
+ default: '已无更多数据'
55
+ },
56
+ emptyType: {
57
+ type: String,
58
+ default: 'default'
59
+ },
60
+ // 是否初始化的时候需要展示缺省图
61
+ isInitEmpty: {
62
+ type: Boolean,
63
+ default: false
64
+ },
65
+ // 列表层样式
66
+ connStyle: {
67
+ type: Object,
68
+ default () {
69
+ return {}
70
+ }
71
+ },
72
+ // 是否展开折叠
73
+ isBigScreen: {
74
+ type: Boolean,
75
+ default: false
76
+ },
77
+ },
78
+ components: {
79
+ FmsEmpty
80
+ },
81
+ data () {
82
+ return {
83
+ maxDecrypt: null,
84
+ setConfig: {
85
+ refresher: true, //是否开启下拉刷新
86
+ finishedTips: this.finishedTips,
87
+ autoInit: true, //是否自动加载第一次页面数据
88
+ api: '',
89
+ },
90
+ // 默认请求参数
91
+ setParams: {
92
+ ...initParams
93
+ },
94
+ loading: false,
95
+ refreshing: false, //是否下拉中
96
+ finished: false, //是否所有数据加载完成
97
+ list: [], //列表数据
98
+ }
99
+ },
100
+ computed: {
101
+ scrollContentStyle() {
102
+ const styles = {
103
+ ...this.connStyle
104
+ }
105
+ const {gap} = this
106
+ if (this.isGrid && this.isBigScreen) {
107
+ styles.gap = `${gap[0]}px ${gap[1]}px`
108
+ }
109
+ return styles
110
+ }
111
+ },
112
+ watch: {
113
+ isBigScreen: {
114
+ immediate: true,
115
+ handler(v) {
116
+ if (this.isGrid || !this.isEnabledMultiCol) {
117
+ return
118
+ }
119
+ this.$nextTick(() => {
120
+ if (!v) {
121
+ this.destroyObserver()
122
+ return
123
+ }
124
+ this.initObserver()
125
+ })
126
+ }
127
+ }
128
+ },
129
+ created () {
130
+ this.updatedConfig()
131
+ this.updatedParams()
132
+ if (this.setConfig.autoInit) this.initData()
133
+ },
134
+ beforeDestroy() {
135
+ this.destroyObserver()
136
+ },
137
+ methods: {
138
+ initObserver() {
139
+ this.waterFall = new WaterFall({
140
+ gap: this.gap
141
+ })
142
+ this.waterFall.observe(this.$refs.refScroll, this.$refs.scrollListContentRef)
143
+ },
144
+ destroyObserver() {
145
+ if (!this.waterFall) {
146
+ return
147
+ }
148
+ this.waterFall.dispose()
149
+ this.waterFall = null
150
+ },
151
+ // 更新配置参数
152
+ updatedConfig (paramsConfig) {
153
+ const { setConfig, config } = this
154
+ this.setConfig = { ...setConfig, ...config, ...paramsConfig }
155
+ // console.log('this.setConfig', this.setConfig)
156
+ },
157
+ // 重置页面初始入参
158
+ reSetParams () {
159
+ const { params } = this
160
+ this.setParams = { ...initParams, ...params }
161
+ },
162
+ // 更新请求参数,可以也直接直接在getData方法里面增加
163
+ updatedParams (paramsConfig) {
164
+ const { setParams, params } = this
165
+ this.setParams = { ...setParams, ...params, ...paramsConfig }
166
+ // console.log('this.setParams', this.setParams)
167
+ },
168
+ onRefresh () {
169
+ this.onRefreshBefore && this.onRefreshBefore()
170
+ this.initData()
171
+ },
172
+ //初始化
173
+ async initData (params, options = {}) {
174
+ const { isLoading = true } = options
175
+ if (isLoading) {
176
+ this.$toast.loading({
177
+ forbidClick: true,
178
+ duration: 0
179
+ })
180
+ }
181
+ if (params) {
182
+ this.updatedParams(params)
183
+ }
184
+ this.setParams.page = 1
185
+ const _initData = await this.getData(options, true)
186
+ this.$emit('initData', _initData)
187
+ return _initData
188
+ },
189
+ async getData (options = {}, isInit = false) {
190
+ const { isLoading = true } = options
191
+ // if (['noData', 'noMore', 'loading'].includes(this.setParams.loadingType)) return
192
+ if (!this.setConfig.api) this.$toast('API不能为空')
193
+ // console.log(this.setParams)
194
+ try {
195
+ const data = await this.$http(this.setConfig.api, '55668', this.setParams)
196
+ const { pageTotal, rows, rowTotal } = data
197
+ const { page } = this.setParams
198
+ if (page === 1 || isInit) {
199
+ this.setParams.page = 1
200
+ this.list = this.initMaxDecrypt(rows)
201
+ } else {
202
+ this.maxDecrypt.addData(rows)
203
+ this.list = this.maxDecrypt.getData()
204
+ }
205
+ console.log('this.list', this.list)
206
+ this.setParams.page = page + 1
207
+ this.loading = false
208
+ this.refreshing = false
209
+ this.finished = page >= +pageTotal
210
+ if (isLoading) this.$toast.clear()
211
+ const _res = { list: this.list, params: this.setParams, rowTotal, pageTotal, currentRows: rows }
212
+ this.$emit('getData', _res)
213
+ return _res
214
+ } catch (error) {
215
+ this.loading = false
216
+ this.refreshing = false
217
+ this.finished = true
218
+ this.list = []
219
+ this.$emit('getData', { list: [], params: this.setParams })
220
+ // 弱网
221
+ this.$bus.$emit('EXECUTE_NET_ERROR')
222
+ console.log(error)
223
+ }
224
+ },
225
+ initMaxDecrypt (data) {
226
+ let _data = []
227
+ try {
228
+ this.maxDecrypt = new MaxDecrypt({
229
+ // 对数据做代理
230
+ data,
231
+ // 当前数据源的请求code
232
+ apiCode: this.setConfig.api,
233
+ // 当前menuId为测试id
234
+ menuId: MENU.id,
235
+ // // 数据被解密回调
236
+ change (...arg) {
237
+ console.log('数据被解密', ...arg)
238
+ },
239
+ // 超过最大解密回调,表示要进行恢复密文
240
+ maxChange (...arg) {
241
+ console.log('超过最大解密次数', ...arg)
242
+ }
243
+ })
244
+ // 返回代理后的数据
245
+ _data = this.maxDecrypt.getData()
246
+ } catch (error) {
247
+ console.log('initMaxDecrypt', error)
248
+ _data = data
249
+ }
250
+ if (!_data) {
251
+ _data = data
252
+ }
253
+ return _data
254
+ },
255
+ },
256
+ }
257
+ </script>
258
+
259
+ <style lang="less" scoped>
260
+ .ky-scroll-list {
261
+ /deep/ .van-list__finished-text {
262
+ font-size: 14px;
263
+ line-height: 40px;
264
+ }
265
+
266
+ /deep/ .van-loading__text {
267
+ font-size: 14px;
268
+ }
269
+
270
+ /deep/ .van-pull-refresh__head {
271
+ font-size: 14px;
272
+ }
273
+ .two-columns-layout() {
274
+ .ky-scroll-list__content.isGrid {
275
+ &.isGrid {
276
+ display: grid;
277
+ grid-template-columns: repeat(2, 1fr);
278
+ grid-auto-flow: row;
279
+ }
280
+ }
281
+ }
282
+ .ky-scroll-list__content {
283
+ position: relative;
284
+ min-height: 10px;
285
+ }
286
+
287
+ @media (min-width: 600px) {
288
+ .two-columns-layout();
289
+ }
290
+ @media (horizontal-viewport-segments: 2) {
291
+ .two-columns-layout();
292
+ }
293
+ }
294
+ </style>
@@ -0,0 +1,7 @@
1
+ import FmsScrollList from './fms-scroll-list.vue'
2
+
3
+ FmsScrollList.install = function(Vue) {
4
+ Vue.component(FmsScrollList.name, FmsScrollList)
5
+ }
6
+
7
+ export default FmsScrollList
package/src/index.js ADDED
@@ -0,0 +1,37 @@
1
+
2
+ import FmsCopyBox from './components/fms-copy-box/index'
3
+ import FmsEmpty from './components/fms-empty/index'
4
+ import FmsKsDecrypt from './components/fms-ks-decrypt/index'
5
+ import FmsKsFileUpload from './components/fms-ks-file-upload/index'
6
+ import FmsKsFileView from './components/fms-ks-file-view/index'
7
+ import FmsScrollList from './components/fms-scroll-list/index'
8
+
9
+ const components = [
10
+ FmsCopyBox,
11
+ FmsEmpty,
12
+ FmsKsDecrypt,
13
+ FmsKsFileUpload,
14
+ FmsKsFileView,
15
+ FmsScrollList
16
+ ]
17
+
18
+ const install = function(Vue) {
19
+ components.forEach(component => {
20
+ Vue.component(component.name, component)
21
+ })
22
+ }
23
+
24
+ // 按需导出
25
+ export {
26
+ FmsCopyBox,
27
+ FmsEmpty,
28
+ FmsKsDecrypt,
29
+ FmsKsFileUpload,
30
+ FmsKsFileView,
31
+ FmsScrollList
32
+ }
33
+ // 全量导出
34
+ export default {
35
+ install,
36
+ }
37
+
package/vite.config.js ADDED
@@ -0,0 +1,82 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue2'
3
+ import vueJsx from '@vitejs/plugin-vue2-jsx'
4
+ import path from 'path'
5
+ import fs from 'fs'
6
+ import libcss from 'vite-plugin-libcss'
7
+ import { libInjectCss } from 'vite-plugin-lib-inject-css';
8
+ // 获取组件入口
9
+ const getComponentEntries = () => {
10
+ const entries = {}
11
+ const componentsDir = path.resolve(__dirname, 'src/components')
12
+
13
+ fs.readdirSync(componentsDir).forEach(dir => {
14
+ const componentDir = path.join(componentsDir, dir)
15
+ if (fs.statSync(componentDir).isDirectory()) {
16
+ const indexPath = path.join(componentDir, 'index.js')
17
+ if (fs.existsSync(indexPath)) {
18
+ entries[dir] = indexPath
19
+ }
20
+ }
21
+ })
22
+
23
+ return entries
24
+ }
25
+
26
+ export default defineConfig({
27
+ plugins: [
28
+ vueJsx(),
29
+ vue(),
30
+ libcss(),
31
+ libInjectCss()
32
+ ],
33
+ resolve: {
34
+ alias: {
35
+ '@': './src',
36
+ }
37
+ },
38
+ build: {
39
+ lib: {
40
+ entry: {
41
+ index: path.resolve(__dirname, 'src/index.js'), // 全量导出入口
42
+ ...getComponentEntries() // 按需导出入口
43
+ },
44
+ formats: ['es'],
45
+ name: 'MyComponentLib',
46
+ // 修复全量 JS 文件位置
47
+ fileName: (format, entryName) => {
48
+ return entryName === 'index'
49
+ ? 'index.js'
50
+ : `${entryName}/index.js`
51
+ }
52
+ },
53
+ rollupOptions: {
54
+ external: ['lodash', 'vue', 'dayjs', '@kyfe/decrypt'],
55
+ output: {
56
+ assetFileNames: (assetInfo) => {
57
+ // 非CSS资源输出到顶级assets目录
58
+ if (!assetInfo.name.endsWith('.css')) {
59
+ // 获取原始目录的最后一级 (e.g. 'images' from 'src/assets/images')
60
+ const dir = path.dirname(assetInfo.name).split('/').pop();
61
+ return `assets/${dir}/[name].[hash].[ext]`;
62
+ }
63
+ // CSS 文件
64
+ const match = assetInfo.name.match(/components\/([^/]+)\//);
65
+ // 如果找到匹配项则使用匹配结果,否则使用默认路径
66
+ if (match && match[1]) {
67
+ return `${match[1]}/style.css`;
68
+ }
69
+ // 降级方案:不符合路径格式的 CSS 文件
70
+ return 'assets/css/[name].[ext]';
71
+ },
72
+ // 确保全量入口生成正确的文件
73
+ entryFileNames: (chunkInfo) => {
74
+ return chunkInfo.name === 'index'
75
+ ? 'index.js'
76
+ : '[name]/index.js'
77
+ }
78
+ }
79
+ },
80
+ cssCodeSplit: true
81
+ }
82
+ })