vue2-client 1.6.28 → 1.6.29

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,9 @@
5
5
  - 修复下拉框搜索异常问题
6
6
  - 依赖更新
7
7
 
8
+ **1.6.28 - 1.6.29 -2023-04-21 @江超**
9
+ - 修改文件上传组件的超时时间
10
+
8
11
  **1.6.26 - 1.6.27 -2023-04-16 @江超**
9
12
  - 修复单页面iframe对http前缀的兼容处理
10
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.6.28",
3
+ "version": "1.6.29",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -1,168 +1,168 @@
1
- <template>
2
- <div>
3
- <a-upload-dragger
4
- v-if="model.type === 'file'"
5
- :accept="model.accept.join('')"
6
- :customRequest="uploadFiles"
7
- :file-list="uploadedFileList"
8
- :multiple="true"
9
- :remove="deleteFileItem"
10
- name="file">
11
- <p class="ant-upload-drag-icon">
12
- <a-icon type="inbox"/>
13
- </p>
14
- <p class="ant-upload-text">
15
- 点击或拖动文件到该区域上传
16
- </p>
17
- <p class="ant-upload-hint">
18
- 支持单个或多个文件
19
- </p>
20
- </a-upload-dragger>
21
- <a-upload
22
- v-if=" model.type === 'image'"
23
- :accept="model.accept.join('')"
24
- :customRequest="uploadFiles"
25
- :file-list="uploadedFileList"
26
- :remove="deleteFileItem"
27
- list-type="picture-card">
28
- <a-icon type="plus"/>
29
- <div class="ant-upload-text">
30
- Upload
31
- </div>
32
- </a-upload>
33
- </div>
34
- </template>
35
-
36
- <script>
37
-
38
- import { post } from '@vue2-client/services/api'
39
- import { mapState } from 'vuex'
40
- import { upload } from '@vue2-client/services/api/common'
41
-
42
- export default {
43
- name: 'uploads',
44
- data () {
45
- return {
46
- uploadedFileList: [],
47
- }
48
- },
49
- props: {
50
- // 表单属性
51
- model: {
52
- type: Object,
53
- default: () => {
54
- return {}
55
- }
56
- },
57
- files: {
58
- type: Array,
59
- default: () => {
60
- return []
61
- }
62
- },
63
- images: {
64
- type: Array,
65
- default: () => {
66
- return []
67
- }
68
- },
69
- serviceName: {
70
- type: String,
71
- default: 'af-system'
72
- }
73
- },
74
- computed: {
75
- ...mapState('account', { currUser: 'user' })
76
- },
77
- created () {
78
- const list = this.model.type === 'file' ? [...this.files] : [...this.images]
79
- if (this.model.useType) {
80
- this.uploadedFileList = list.filter(item => item.f_use_type === this.model.useType)
81
- } else {
82
- this.uploadedFileList = list
83
- }
84
- this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
85
- },
86
- methods: {
87
- uploadFiles (info) {
88
- if (this.uploadedFileList.length >= this.model.acceptCount) {
89
- this.$message.error(`当前表单限制仅可上传 ${this.model.acceptCount} 个文件`)
90
- return
91
- }
92
- // 初始化文件信息
93
- const fileInfo = {
94
- uid: info.file.uid,
95
- name: info.file.name,
96
- status: 'uploading',
97
- response: '',
98
- url: '',
99
- }
100
- // 放入上传列表中,以便于显示上传进度
101
- this.uploadedFileList.push(fileInfo)
102
- // 组装上传数据
103
- const headers = {
104
- 'Content-Type': 'multipart/form-data',
105
- }
106
- const formData = new FormData()
107
- formData.append('avatar', info.file)
108
- formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
109
- if (this.model.pathKey) {
110
- formData.append('pathKey', this.model.pathKey ?? 'Default')
111
- }
112
- // formData.append('stockAlias', this.model.stockAlias)
113
- formData.append('formType', this.model.type)
114
- formData.append('useType', this.model.useType ?? 'Default')
115
- formData.append('resUploadStock', this.model.resUploadStock)
116
- formData.append('filename', info.file.name)
117
- formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
118
- formData.append('f_operator', this.currUser ? this.currUser.username : '')
119
-
120
- // const url = '/api/af-system/resource'
121
- // if (process.env.NODE_ENV === 'production') {
122
- // url = `/${this.model.stockAlias}/af-system/resource`
123
- // }
124
- upload(formData, this.serviceName, { headers, timeout: 60 * 1000 }).then(res => {
125
- // 根据服务端返回的结果判断成功与否,设置文件条目的状态
126
- if (res.success) {
127
- fileInfo.status = 'done'
128
- let dataObj
129
- if (typeof res.data === 'string') {
130
- dataObj = JSON.parse(res.data)
131
- } else {
132
- dataObj = res.data
133
- }
134
- fileInfo.response = dataObj
135
- fileInfo.id = dataObj.id
136
- fileInfo.url = dataObj.f_downloadpath
137
- this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
138
- this.$message.success('上传成功!')
139
- } else {
140
- fileInfo.status = 'error'
141
- fileInfo.response = res.data
142
- this.$message.error('上传失败!')
143
- }
144
- }).catch((e) => {
145
- fileInfo.status = 'error'
146
- fileInfo.response = e
147
- this.$message.error(`请求失败!${e}`)
148
- })
149
- },
150
- // 删除文件
151
- deleteFileItem (file) {
152
- if (file.id) {
153
- post('/api/' + this.serviceName + '/entity/t_files', { id: file.id, f_state: '删除' }).then(res => {
154
- }).catch(e => { })
155
- }
156
- // 找到当前文件所在列表的索引
157
- const index = this.uploadedFileList.indexOf(file)
158
- // 从列表中移除该文件
159
- this.uploadedFileList.splice(index, 1)
160
- this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
161
- return true
162
- }
163
- }
164
- }
165
- </script>
166
- <style lang="less" scoped>
167
-
168
- </style>
1
+ <template>
2
+ <div>
3
+ <a-upload-dragger
4
+ v-if="model.type === 'file'"
5
+ :accept="model.accept.join('')"
6
+ :customRequest="uploadFiles"
7
+ :file-list="uploadedFileList"
8
+ :multiple="true"
9
+ :remove="deleteFileItem"
10
+ name="file">
11
+ <p class="ant-upload-drag-icon">
12
+ <a-icon type="inbox"/>
13
+ </p>
14
+ <p class="ant-upload-text">
15
+ 点击或拖动文件到该区域上传
16
+ </p>
17
+ <p class="ant-upload-hint">
18
+ 支持单个或多个文件
19
+ </p>
20
+ </a-upload-dragger>
21
+ <a-upload
22
+ v-if=" model.type === 'image'"
23
+ :accept="model.accept.join('')"
24
+ :customRequest="uploadFiles"
25
+ :file-list="uploadedFileList"
26
+ :remove="deleteFileItem"
27
+ list-type="picture-card">
28
+ <a-icon type="plus"/>
29
+ <div class="ant-upload-text">
30
+ Upload
31
+ </div>
32
+ </a-upload>
33
+ </div>
34
+ </template>
35
+
36
+ <script>
37
+
38
+ import { post } from '@vue2-client/services/api'
39
+ import { mapState } from 'vuex'
40
+ import { upload } from '@vue2-client/services/api/common'
41
+
42
+ export default {
43
+ name: 'uploads',
44
+ data () {
45
+ return {
46
+ uploadedFileList: [],
47
+ }
48
+ },
49
+ props: {
50
+ // 表单属性
51
+ model: {
52
+ type: Object,
53
+ default: () => {
54
+ return {}
55
+ }
56
+ },
57
+ files: {
58
+ type: Array,
59
+ default: () => {
60
+ return []
61
+ }
62
+ },
63
+ images: {
64
+ type: Array,
65
+ default: () => {
66
+ return []
67
+ }
68
+ },
69
+ serviceName: {
70
+ type: String,
71
+ default: 'af-system'
72
+ }
73
+ },
74
+ computed: {
75
+ ...mapState('account', { currUser: 'user' })
76
+ },
77
+ created () {
78
+ const list = this.model.type === 'file' ? [...this.files] : [...this.images]
79
+ if (this.model.useType) {
80
+ this.uploadedFileList = list.filter(item => item.f_use_type === this.model.useType)
81
+ } else {
82
+ this.uploadedFileList = list
83
+ }
84
+ this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
85
+ },
86
+ methods: {
87
+ uploadFiles (info) {
88
+ if (this.uploadedFileList.length >= this.model.acceptCount) {
89
+ this.$message.error(`当前表单限制仅可上传 ${this.model.acceptCount} 个文件`)
90
+ return
91
+ }
92
+ // 初始化文件信息
93
+ const fileInfo = {
94
+ uid: info.file.uid,
95
+ name: info.file.name,
96
+ status: 'uploading',
97
+ response: '',
98
+ url: '',
99
+ }
100
+ // 放入上传列表中,以便于显示上传进度
101
+ this.uploadedFileList.push(fileInfo)
102
+ // 组装上传数据
103
+ const headers = {
104
+ 'Content-Type': 'multipart/form-data',
105
+ }
106
+ const formData = new FormData()
107
+ formData.append('avatar', info.file)
108
+ formData.append('resUploadMode', this.model.resUploadMode ?? 'server')
109
+ if (this.model.pathKey) {
110
+ formData.append('pathKey', this.model.pathKey ?? 'Default')
111
+ }
112
+ // formData.append('stockAlias', this.model.stockAlias)
113
+ formData.append('formType', this.model.type)
114
+ formData.append('useType', this.model.useType ?? 'Default')
115
+ formData.append('resUploadStock', this.model.resUploadStock)
116
+ formData.append('filename', info.file.name)
117
+ formData.append('filesize', (info.file.size / 1024 / 1024).toFixed(4))
118
+ formData.append('f_operator', this.currUser ? this.currUser.username : '')
119
+
120
+ // const url = '/api/af-system/resource'
121
+ // if (process.env.NODE_ENV === 'production') {
122
+ // url = `/${this.model.stockAlias}/af-system/resource`
123
+ // }
124
+ upload(formData, this.serviceName, { headers, timeout: 600 * 1000 }).then(res => {
125
+ // 根据服务端返回的结果判断成功与否,设置文件条目的状态
126
+ if (res.success) {
127
+ fileInfo.status = 'done'
128
+ let dataObj
129
+ if (typeof res.data === 'string') {
130
+ dataObj = JSON.parse(res.data)
131
+ } else {
132
+ dataObj = res.data
133
+ }
134
+ fileInfo.response = dataObj
135
+ fileInfo.id = dataObj.id
136
+ fileInfo.url = dataObj.f_downloadpath
137
+ this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
138
+ this.$message.success('上传成功!')
139
+ } else {
140
+ fileInfo.status = 'error'
141
+ fileInfo.response = res.data
142
+ this.$message.error('上传失败!')
143
+ }
144
+ }).catch((e) => {
145
+ fileInfo.status = 'error'
146
+ fileInfo.response = e
147
+ this.$message.error(`请求失败!${e}`)
148
+ })
149
+ },
150
+ // 删除文件
151
+ deleteFileItem (file) {
152
+ if (file.id) {
153
+ post('/api/' + this.serviceName + '/entity/t_files', { id: file.id, f_state: '删除' }).then(res => {
154
+ }).catch(e => { })
155
+ }
156
+ // 找到当前文件所在列表的索引
157
+ const index = this.uploadedFileList.indexOf(file)
158
+ // 从列表中移除该文件
159
+ this.uploadedFileList.splice(index, 1)
160
+ this.$emit('setFiles', this.uploadedFileList.filter(item => item.status === 'done').map(item => item.id))
161
+ return true
162
+ }
163
+ }
164
+ }
165
+ </script>
166
+ <style lang="less" scoped>
167
+
168
+ </style>