agilebuilder-ui 1.0.18 → 1.0.19-beta2

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.
@@ -0,0 +1,6 @@
1
+ import FsUploadNew from './src/fs-upload-new.vue'
2
+ FsUploadNew.install = function (Vue) {
3
+ window.$vueApp.component(FsUploadNew.name, FsUploadNew)
4
+ }
5
+
6
+ export default FsUploadNew
@@ -0,0 +1,129 @@
1
+ <template>
2
+ <el-upload
3
+ class="upload-demo"
4
+ :accept="accept"
5
+ :limit="limit"
6
+ :show-file-list="false"
7
+ auto-upload
8
+ :headers="headers"
9
+ :action="defaultAction"
10
+ :multiple="multiple"
11
+ :before-upload="handleBeforeUpload"
12
+ :before-remove="beforeRemove"
13
+ :on-success="onSuccess"
14
+ >
15
+ <el-button type="primary">{{ placeholder }}</el-button>
16
+ <template #tip>
17
+ <div class="el-upload__tip">jpg/png files with a size less than 500kb</div>
18
+ </template>
19
+ </el-upload>
20
+ <template v-if="fileList && fileList.length > 0">
21
+ <fs-preview-new :disabled="disabled" :file-list="fileList" :system-code="systemCode" />
22
+ </template>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { ref, defineProps } from 'vue'
27
+ import { getSystemFrontendUrl, isPlateSys } from '../../../src/utils/common-util'
28
+ import { getToken } from '../../../src/utils/auth'
29
+ import type { UploadFile, UploadFiles } from 'element-plus'
30
+ import fsPreviewNew from './fs-preview-new.vue'
31
+ const props = defineProps({
32
+ systemCode: {
33
+ type: String,
34
+ default: ''
35
+ },
36
+ disabled: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ accept: {
41
+ type: String,
42
+ default: ''
43
+ },
44
+ multiple: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ limit: {
49
+ type: Number,
50
+ default: 1
51
+ },
52
+ limitFileSize: {
53
+ type: Number,
54
+ default: 30
55
+ },
56
+ placeholder: {
57
+ type: String,
58
+ default: '拖拽文件 或 点击上传'
59
+ },
60
+ action: {
61
+ type: String,
62
+ default: ''
63
+ },
64
+ headers: {
65
+ type: Object,
66
+ default: () => ({ Authorization: null })
67
+ },
68
+ fileList: {
69
+ type: Array<{ showName: string; serverPath: string }>,
70
+ default: () => []
71
+ },
72
+ handleBeforeUpload: {
73
+ type: Function,
74
+ default: () => {}
75
+ },
76
+ onSuccess: {
77
+ type: Function,
78
+ default: () => {}
79
+ },
80
+ beforeRemove: {
81
+ type: Function,
82
+ default: () => {}
83
+ },
84
+ onRemove: {
85
+ type: Function,
86
+ default: () => {}
87
+ },
88
+ beforeDownload: {
89
+ type: Function,
90
+ default: () => {}
91
+ },
92
+ pageContext: {
93
+ type: Object,
94
+ default: () => ({})
95
+ },
96
+ configure: {
97
+ type: Object,
98
+ default: () => ({})
99
+ }
100
+ })
101
+ const baseURL = window.$vueApp.config.globalProperties.baseURL
102
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI
103
+ const defaultAction = ref<string>('')
104
+
105
+ if (props.action) {
106
+ defaultAction.value = props.action
107
+ } else {
108
+ let tempAction = baseURL + '/common/fs-upload'
109
+ if (!isPlateSys(props.systemCode)) {
110
+ tempAction = baseAPI + '/component/super-form/uploads'
111
+ }
112
+ defaultAction.value = tempAction
113
+ }
114
+ if (!props.headers || !props.headers['Authorization']) {
115
+ // eslint-disable-next-line vue/no-mutating-props
116
+ props.headers.Authorization = getToken()
117
+ }
118
+ const handleBeforeUpload = (file: File) => {
119
+ return props.handleBeforeUpload(file)
120
+ }
121
+ const onSuccess = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
122
+ // eslint-disable-next-line vue/no-mutating-props
123
+ props.fileList.push({
124
+ showName: response.name,
125
+ serverPath: response.serverPath
126
+ })
127
+ props.onSuccess(response, uploadFile, uploadFiles)
128
+ }
129
+ </script>
@@ -0,0 +1,132 @@
1
+ <template>
2
+ <el-upload
3
+ class="upload-demo"
4
+ :accept="accept"
5
+ :limit="limit"
6
+ :show-file-list="false"
7
+ drag
8
+ auto-upload
9
+ :headers="headers"
10
+ :action="defaultAction"
11
+ :multiple="multiple"
12
+ :before-upload="handleBeforeUpload"
13
+ :before-remove="beforeRemove"
14
+ :on-success="onSuccess"
15
+ >
16
+ <el-icon class="el-icon--upload"><upload-filled /></el-icon>
17
+ <div class="el-upload__text">{{ placeholder }}</div>
18
+ <template #tip>
19
+ <div class="el-upload__tip">jpg/png files with a size less than 500kb</div>
20
+ </template>
21
+ </el-upload>
22
+ <template v-if="fileList && fileList.length > 0">
23
+ <fs-preview-new :disabled="disabled" :file-list="fileList" :system-code="systemCode" />
24
+ </template>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { UploadFilled } from '@element-plus/icons-vue'
29
+ import { ref, defineProps } from 'vue'
30
+ import { getSystemFrontendUrl, isPlateSys } from '../../../src/utils/common-util'
31
+ import { getToken } from '../../../src/utils/auth'
32
+ import type { UploadFile, UploadFiles } from 'element-plus'
33
+ import fsPreviewNew from './fs-preview-new.vue'
34
+ const props = defineProps({
35
+ systemCode: {
36
+ type: String,
37
+ default: ''
38
+ },
39
+ disabled: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ accept: {
44
+ type: String,
45
+ default: ''
46
+ },
47
+ multiple: {
48
+ type: Boolean,
49
+ default: false
50
+ },
51
+ limit: {
52
+ type: Number,
53
+ default: 1
54
+ },
55
+ limitFileSize: {
56
+ type: Number,
57
+ default: 30
58
+ },
59
+ placeholder: {
60
+ type: String,
61
+ default: '拖拽文件 或 点击上传'
62
+ },
63
+ action: {
64
+ type: String,
65
+ default: ''
66
+ },
67
+ headers: {
68
+ type: Object,
69
+ default: () => ({ Authorization: null })
70
+ },
71
+ fileList: {
72
+ type: Array<{ showName: string; serverPath: string }>,
73
+ default: () => []
74
+ },
75
+ handleBeforeUpload: {
76
+ type: Function,
77
+ default: () => {}
78
+ },
79
+ onSuccess: {
80
+ type: Function,
81
+ default: () => {}
82
+ },
83
+ beforeRemove: {
84
+ type: Function,
85
+ default: () => {}
86
+ },
87
+ onRemove: {
88
+ type: Function,
89
+ default: () => {}
90
+ },
91
+ beforeDownload: {
92
+ type: Function,
93
+ default: () => {}
94
+ },
95
+ pageContext: {
96
+ type: Object,
97
+ default: () => ({})
98
+ },
99
+ configure: {
100
+ type: Object,
101
+ default: () => ({})
102
+ }
103
+ })
104
+ const baseURL = window.$vueApp.config.globalProperties.baseURL
105
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI
106
+ const defaultAction = ref<string>('')
107
+
108
+ if (props.action) {
109
+ defaultAction.value = props.action
110
+ } else {
111
+ let tempAction = baseURL + '/common/fs-upload'
112
+ if (!isPlateSys(props.systemCode)) {
113
+ tempAction = baseAPI + '/component/super-form/uploads'
114
+ }
115
+ defaultAction.value = tempAction
116
+ }
117
+ if (!props.headers || !props.headers['Authorization']) {
118
+ // eslint-disable-next-line vue/no-mutating-props
119
+ props.headers.Authorization = getToken()
120
+ }
121
+ const handleBeforeUpload = (file: File) => {
122
+ return props.handleBeforeUpload(file)
123
+ }
124
+ const onSuccess = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
125
+ // eslint-disable-next-line vue/no-mutating-props
126
+ props.fileList.push({
127
+ showName: response.name,
128
+ serverPath: response.serverPath
129
+ })
130
+ props.onSuccess(response, uploadFile, uploadFiles)
131
+ }
132
+ </script>
@@ -0,0 +1,199 @@
1
+ <template>
2
+ <div v-for="(file, index) in fileList" :key="index" style="width: 100%">
3
+ <el-tag>
4
+ <el-tooltip content="预览" placement="top">
5
+ <span style="cursor: pointer" @click="preview(file.showName, file.serverPath)">
6
+ <el-icon><Paperclip /></el-icon>
7
+ <span style="margin-left: 6.5px">{{ file.showName }}</span>
8
+ </span>
9
+ </el-tooltip>
10
+ <el-tooltip content="下载" placement="top">
11
+ <el-icon style="cursor: pointer; padding-left: 15px" @click="handleDownload(file)">
12
+ <Download />
13
+ </el-icon>
14
+ </el-tooltip>
15
+ <el-tooltip content="移除" placement="top">
16
+ <el-icon @click="handleOnRemove(file)"><Close /></el-icon>
17
+ </el-tooltip>
18
+ </el-tag>
19
+ <el-dialog v-model="dialogVisible" title="预览" width="500">
20
+ <el-image :preview-src-list="previewSrcList" :src="previewImageInfo.src" />
21
+ </el-dialog>
22
+ </div>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import { Close, Paperclip, Download } from '@element-plus/icons-vue'
27
+ import { ref, defineProps } from 'vue'
28
+ import { getSystemFrontendUrl, isPlateSys } from '../../../src/utils/common-util'
29
+ import { getToken } from '../../../src/utils/auth'
30
+ const props = defineProps({
31
+ systemCode: {
32
+ type: String,
33
+ default: ''
34
+ },
35
+ disabled: {
36
+ type: Boolean,
37
+ default: false
38
+ },
39
+ fileList: {
40
+ type: Array<{ showName: string; serverPath: string }>,
41
+ default: () => []
42
+ },
43
+ pageContext: {
44
+ type: Object,
45
+ default: () => ({})
46
+ },
47
+ configure: {
48
+ type: Object,
49
+ default: () => ({})
50
+ },
51
+ beforeRemove: {
52
+ type: Function,
53
+ default: () => {}
54
+ },
55
+ onRemove: {
56
+ type: Function,
57
+ default: () => {}
58
+ },
59
+ beforeDownload: {
60
+ type: Function,
61
+ default: () => {}
62
+ }
63
+ })
64
+ const baseURL = window.$vueApp.config.globalProperties.baseURL
65
+ const baseAPI = window.$vueApp.config.globalProperties.baseAPI
66
+
67
+ const dialogVisible = ref<boolean>(false)
68
+ const previewImageInfo = ref<any>({})
69
+ const previewSrcList = ref<string[]>([])
70
+
71
+ const handleDownload = (file: any) => {
72
+ if (isPromise(props.beforeDownload)) {
73
+ props.beforeDownload(props.pageContext, props.configure, file).then((res: any) => {
74
+ if (res === false) {
75
+ console.log('beforeDownload=false')
76
+ } else {
77
+ download(file)
78
+ }
79
+ })
80
+ } else {
81
+ if (props.beforeDownload(props.pageContext, props.configure, file) === false) {
82
+ console.log('beforeDownload=false')
83
+ } else {
84
+ download(file)
85
+ }
86
+ }
87
+ }
88
+ const download = (file: any) => {
89
+ const token = getToken()
90
+ const showName = file.showName.replace('#', '~~').replace('?', '~$').replace('&', '$')
91
+ let url =
92
+ baseURL +
93
+ '/common/super-form/downloads?showName=' +
94
+ encodeURI(showName) +
95
+ '&serverPath=' +
96
+ file.serverPath +
97
+ '&jwt=' +
98
+ token
99
+ if (!isPlateSys(props.systemCode)) {
100
+ url =
101
+ baseAPI +
102
+ '/component/super-form/downloads?showName=' +
103
+ encodeURI(showName) +
104
+ '&serverPath=' +
105
+ file.serverPath +
106
+ '&jwt=' +
107
+ token
108
+ }
109
+ window.location.href = url
110
+ }
111
+ const handleOnRemove = (file: any) => {
112
+ props.beforeRemove(props.pageContext, props.configure, file)
113
+ const idnex = props.fileList.findIndex((item: any) => item.serverPath === file.uuid)
114
+ // eslint-disable-next-line vue/no-mutating-props
115
+ props.fileList.splice(idnex, 1)
116
+ props.onRemove(file)
117
+ }
118
+
119
+ const isPromise = (p: any) => {
120
+ return p && Object.prototype.toString.call(p) === '[object Promise]'
121
+ }
122
+ const preview = (showName: string, serverPath: string) => {
123
+ console.log('preview')
124
+
125
+ let isImage = false
126
+ if (showName && /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(showName)) {
127
+ isImage = true
128
+ }
129
+ if (isImage) {
130
+ previewImageInfo.value.src = getPreviewSrc(showName, serverPath)
131
+ const srcList: string[] = []
132
+ props.fileList.forEach((item: any) => {
133
+ srcList.push(getPreviewSrc(item.showName, item.serverPath))
134
+ })
135
+ previewSrcList.value = srcList
136
+ dialogVisible.value = true
137
+ } else {
138
+ previweDoc(showName, serverPath)
139
+ }
140
+ }
141
+
142
+ const previweDoc = (showName: string, serverPath: string) => {
143
+ const token = getToken()
144
+ showName = showName = formatName(showName)
145
+ if (window.$vueApp.config.globalProperties.customPreviewUrl) {
146
+ window.open(
147
+ getSystemFrontendUrl(window.$vueApp.config.globalProperties.portalUrl) +
148
+ '/#/file-service/preview?serverPath=' +
149
+ serverPath +
150
+ '&showName=' +
151
+ encodeURI(showName),
152
+ showName
153
+ )
154
+ } else {
155
+ let baseUrl = window.$vueApp.config.globalProperties.baseURL
156
+ if (isPlateSys(window.$vueApp.config.globalProperties.systemCode)) {
157
+ baseUrl = window.$vueApp.config.globalProperties.baseAPI
158
+ }
159
+ let previewUrl
160
+ if (window.$vueApp.config.globalProperties.kkFileViewUrl) {
161
+ const originUrl =
162
+ baseUrl +
163
+ '/common/super-form/downloads?jwt=' +
164
+ token +
165
+ '&showName=' +
166
+ encodeURI(showName) +
167
+ '&serverPath=' +
168
+ serverPath
169
+ //要预览文件的访问地址
170
+ const myPreviewUrl = originUrl + '&fullfilename=' + showName
171
+ console.log('myPreviewUrl====', myPreviewUrl)
172
+ // http://127.0.0.1:8012/onlinePreview
173
+ previewUrl = window.$vueApp.config.globalProperties.kkFileViewUrl + '?url=' + 1
174
+ // encodeURIComponent(Base64.encode(myPreviewUrl))
175
+ console.log('previewUrl====', previewUrl)
176
+ } else {
177
+ previewUrl = baseUrl + '/common/fs-upload/preview?jwt=' + token
178
+ previewUrl = previewUrl + '&showName=' + encodeURI(showName) + '&serverPath=' + serverPath
179
+ }
180
+ window.open(previewUrl, showName)
181
+ }
182
+ }
183
+ function getPreviewSrc(showName: string, serverPath: string) {
184
+ showName = formatName(showName)
185
+ const token = getToken()
186
+ let url = baseURL + '/common/super-form/downloads?jwt=' + token
187
+ if (!isPlateSys(props.systemCode)) {
188
+ url = baseAPI + '/component/super-form/downloads?jwt=' + token
189
+ }
190
+ return url + '&showName=' + encodeURI(showName) + '&serverPath=' + serverPath
191
+ }
192
+
193
+ const formatName = (showName: string) => {
194
+ if (showName) {
195
+ showName = showName.replace('#', '~~').replace('?', '~$').replace('&', '$')
196
+ }
197
+ return showName
198
+ }
199
+ </script>
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <FsUploadList
3
+ v-if="displayType === 'input'"
4
+ :value="listFileLabel"
5
+ :row="entity"
6
+ :disabled="disabled"
7
+ :fileInfo="fileInfo"
8
+ :fileSetObj="{ accept: accept, multiple: multiple, limitFileSize: limitFileSize }"
9
+ @upload-success="onListUploadSuccess"
10
+ />
11
+ <fs-button-upload
12
+ v-else-if="displayType === 'button'"
13
+ :disabled="disabled"
14
+ :fileInfo="fileInfo"
15
+ :systemCode="systemCode"
16
+ :accept="accept"
17
+ :multiple="multiple"
18
+ :limit="limit"
19
+ :limitFileSize="limitFileSize"
20
+ :placeholder="placeholder"
21
+ :action="action"
22
+ :headers="headers"
23
+ :file-list="fileList"
24
+ :handleBeforeUpload="handleBeforeUpload"
25
+ :onSuccess="onSuccess"
26
+ :beforeRemove="beforeRemove"
27
+ :onRemove="onRemove"
28
+ :beforeDownload="beforeDownload"
29
+ :pageContext="pageContext"
30
+ :configure="configure"
31
+ />
32
+ <fs-drag-upload
33
+ v-else-if="displayType === 'drag'"
34
+ :disabled="disabled"
35
+ :fileInfo="fileInfo"
36
+ :systemCode="systemCode"
37
+ :accept="accept"
38
+ :multiple="multiple"
39
+ :limit="limit"
40
+ :limitFileSize="limitFileSize"
41
+ :placeholder="placeholder"
42
+ :action="action"
43
+ :headers="headers"
44
+ :file-list="fileList"
45
+ :handleBeforeUpload="handleBeforeUpload"
46
+ :onSuccess="onSuccess"
47
+ :beforeRemove="beforeRemove"
48
+ :onRemove="onRemove"
49
+ :beforeDownload="beforeDownload"
50
+ :pageContext="pageContext"
51
+ :configure="configure"
52
+ />
53
+ </template>
54
+ <script setup lang="ts">
55
+ import FsDragUpload from './fs-drag-upload.vue'
56
+ import FsButtonUpload from './fs-button-upload.vue'
57
+ import { ref, defineProps } from 'vue'
58
+ const props = defineProps({
59
+ entity: {
60
+ type: Object,
61
+ default: () => {
62
+ return null
63
+ }
64
+ },
65
+ fileInfo: {
66
+ type: Object,
67
+ default: () => ({})
68
+ },
69
+ systemCode: {
70
+ type: String,
71
+ default: ''
72
+ },
73
+ displayType: {
74
+ type: String,
75
+ default: 'input'
76
+ },
77
+ disabled: {
78
+ type: Boolean,
79
+ default: false
80
+ },
81
+ accept: {
82
+ type: String,
83
+ default: ''
84
+ },
85
+ multiple: {
86
+ type: Boolean,
87
+ default: false
88
+ },
89
+ limit: {
90
+ type: Number,
91
+ default: 1
92
+ },
93
+ limitFileSize: {
94
+ type: Number,
95
+ default: 30
96
+ },
97
+ placeholder: {
98
+ type: String,
99
+ default: '拖拽文件 或 点击上传'
100
+ },
101
+ action: {
102
+ type: String,
103
+ default: ''
104
+ },
105
+ headers: {
106
+ type: Object,
107
+ default: () => ({ Authorization: null })
108
+ },
109
+ fileList: {
110
+ type: Array<{ showName: string; serverPath: string }>,
111
+ default: () => []
112
+ },
113
+ handleBeforeUpload: {
114
+ type: Function,
115
+ default: () => {}
116
+ },
117
+ onSuccess: {
118
+ type: Function,
119
+ default: () => {}
120
+ },
121
+ beforeRemove: {
122
+ type: Function,
123
+ default: () => {}
124
+ },
125
+ onRemove: {
126
+ type: Function,
127
+ default: () => {}
128
+ },
129
+ beforeDownload: {
130
+ type: Function,
131
+ default: () => {}
132
+ },
133
+ pageContext: {
134
+ type: Object,
135
+ default: () => ({})
136
+ },
137
+ configure: {
138
+ type: Object,
139
+ default: () => ({})
140
+ }
141
+ })
142
+ const listFileLabel = ref<string>('')
143
+ if (props.displayType === 'input') {
144
+ listFileLabel.value = props.fileInfo.showName || ''
145
+ }
146
+ const onListUploadSuccess = (res: any) => {
147
+ listFileLabel.value = res.showName
148
+ }
149
+ </script>
package/packages/index.js CHANGED
@@ -36,6 +36,7 @@ import IntervalSelection from './IntervalSelection'
36
36
  import DepartmentTreeMobile from './department-tree-mobile'
37
37
  import DepartmentUserTreeMobile from './department-user-tree-mobile'
38
38
  import SuperIcon from './super-icon'
39
+ import FsUploadNew from './fs-upload-new'
39
40
  import * as ElementPlusIconsVue from "@element-plus/icons-vue"
40
41
  // 将所有组件都存储起来,方便后续统一注册
41
42
  const components = [
@@ -71,7 +72,8 @@ const components = [
71
72
  IntervalSelection,
72
73
  DepartmentTreeMobile,
73
74
  DepartmentUserTreeMobile,
74
- SuperIcon
75
+ SuperIcon,
76
+ FsUploadNew
75
77
  ]
76
78
 
77
79
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
@@ -128,7 +130,8 @@ export {
128
130
  SecretInfo,
129
131
  DepartmentTreeMobile,
130
132
  DepartmentUserTreeMobile,
131
- SuperIcon
133
+ SuperIcon,
134
+ FsUploadNew
132
135
  }
133
136
 
134
137
  export default {