@zscreate/zhxy-app-component 1.0.320-test.4 → 1.0.321

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/README.md CHANGED
@@ -6,4 +6,6 @@
6
6
 
7
7
  浙江工贸辅导员值班 zjgm_241105_test
8
8
 
9
- 浙江安防会议室 zjaf_meeting_20241203
9
+ 浙江安防会议室 zjaf_meeting_20241203
10
+
11
+ 浙江安防文件上传预览 zjaf_file_20241216
@@ -465,7 +465,7 @@
465
465
  <view class="evan-form-item-container__main" :style="mContentStyle" @click="handleSeclet(widget.options.multiple)">
466
466
  <view class="form-input" style="display: flex;align-items: center;">
467
467
  <view class="option-font-size">{{ dataModelShow ? dataModelShow : widget.options.placeholder }}</view>
468
- <uni-icons style="margin-left: auto; margin-right: 20rpx;margin-top: 8rpx;" @click.native.stop="handleClear" v-if="!widget.options.disabled && dataModelShow" type="clear" color="#e1e1e1" size="14"></uni-icons>
468
+ <uni-icons style="margin-left: auto; margin-right: 20rpx;margin-top: 8rpx;" @click.native.stop="handleClear(widget.options.multiple)" v-if="!widget.options.disabled && dataModelShow" type="clear" color="#e1e1e1" size="14"></uni-icons>
469
469
  </view>
470
470
  </view>
471
471
  <!-- <icon type="clear" size="14" v-if="widget.options.canView" />-->
@@ -1018,8 +1018,8 @@ export default {
1018
1018
  clearValidate() {
1019
1019
  this.showFalse = false
1020
1020
  },
1021
- handleClear() {
1022
- this.dataModel = []
1021
+ handleClear(isMultiple=true) {
1022
+ this.dataModel = isMultiple?[]:''
1023
1023
  this.dataModelShow = ''
1024
1024
  if(this.zjfmFormDesign && this.widget.model == 'thr') {
1025
1025
  this.models.thxq = ''
@@ -55,7 +55,6 @@
55
55
  @click="showTableRow(item.model, tableCIndex)">
56
56
  </view>
57
57
  </view>
58
- {{tableRowsShow[item.model][tableCIndex]}}
59
58
  <view class="view-port" v-show="tableRowsShow[item.model][tableCIndex]">
60
59
  <view v-for="(tableItem, tableItemIndex) in table.columns" :key="tableItemIndex">
61
60
  <evan-form-item v-show="tableItem.options.canView"
@@ -1,147 +1,155 @@
1
1
  <template>
2
- <view style="width: 100%;">
3
- <view class="file_conten" style="width: 100%;">
4
- <view class="file_upload option-font-size" @click="chooseMessageFile"
5
- v-if="isShow">
6
- {{ widget.options.placeholder || '点击上传'}}
7
- </view>
8
- <view style="width: 100%">
9
- <view class="file_item" v-for="(item,idx) in defaultFile" :key="idx">
10
- <view @click="downLoadFile(item.url,item.name, item)" style="max-width: 640rpx;color: rgb(0, 122, 255); overflow: hidden" :style="{maxWidth: disabled ? '100%': '640rpx'}">{{item.name}}</view>
11
- <icon type="clear" size="16" @click="handleDelete(idx)" v-if="!disabled" />
12
- </view>
13
- </view>
14
- </view>
15
- <!-- <view class="name" v-show="!show">{{name}}</view>
2
+ <view style="width: 100%;">
3
+ <view class="file_conten" style="width: 100%;">
4
+ <view class="file_upload option-font-size" @click="chooseMessageFile" v-if="isShow">
5
+ {{ widget.options.placeholder || '点击上传' }}
6
+ </view>
7
+ <view style="width: 100%">
8
+ <view class="file_item" v-for="(item, idx) in defaultFile" :key="idx">
9
+ <view @click="downLoadFile(item.url, item.name, item)"
10
+ style="max-width: 580rpx;color: rgb(0, 122, 255); overflow: hidden"
11
+ :style="{ maxWidth: disabled ? '100%' : '580rpx' }">{{ item.name }}</view>
12
+ <view style="display: flex;align-items: center;">
13
+ <!-- #ifdef ZJAF_DESIGN -->
14
+ <!-- ZJAF_DESIGN浙江安防环境变量,有该变量才会有文件上传的预览功能 -->
15
+ <view v-if="['doc', 'docx', 'xls', 'xlsx', 'jpg', 'jpeg', 'png', 'gif', 'pdf'].includes(getFileExt(item.name))" @click="handlePreview(item)" style="color: rgb(0, 122, 255);margin-top: 0;margin-right: 20rpx;">预览
16
+ </view>
17
+ <!-- #endif -->
18
+ <icon type="clear" size="16" @click="handleDelete(idx)" v-if="!disabled" />
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </view>
23
+ <!-- <view class="name" v-show="!show">{{name}}</view>
16
24
  <view class="name SXcolor" v-if="fileName" @click="downLoadFile(defaultFile[0]['url'])">{{fileName}}</view>
17
25
  </view>
18
26
  <view v-if="fileName" class="tips option-font-size">更多文件详情请于电脑端查看</view> -->
19
- <view v-if="!disabled && percent > 0" >
20
- <progress :percent="percent" stroke-width="5" activeColor="#007AFF" backgroundColor="#FFFFFF"
21
- style="width: 200upx;" v-show="show"></progress>
22
- </view>
23
- </view>
27
+ <view v-if="!disabled && percent > 0">
28
+ <progress :percent="percent" stroke-width="5" activeColor="#007AFF" backgroundColor="#FFFFFF"
29
+ style="width: 200upx;" v-show="show"></progress>
30
+ </view>
31
+ </view>
24
32
  </template>
25
33
 
26
34
  <script>
27
- import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../../utils/util";
35
+ import { downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait } from "../../utils/util";
28
36
 
29
- export default {
30
- props: {
31
- widget: {
32
- type: Object,
33
- default: {}
34
- },
35
- url: {
36
- type: String,
37
- default: ''
38
- },
39
- disabled: {
40
- type: Boolean,
41
- default: false
42
- },
43
- defaultFile: {
44
- type: Array,
45
- default: () => []
46
- }
47
- },
48
- data() {
49
- return {
50
- name: "",
51
- percent: 0,
52
- show: true,
53
- uploadIng: false,
54
- openId: undefined,
55
- header: {
56
- 'X-Access-Token': uni.getStorageSync('token') || this.$store.state.token || this.$store.getters.token
57
- },
58
- isShow:true,//是否展示点击上传
59
- }
60
- },
61
- watch:{
62
- //当上传的数量超过了设置的数量 就不让上传
63
- defaultFile(val){
64
- this.getShow(val)
65
- }
66
- },
67
- async mounted() {
68
- const { uploadEncrypt, downloadVerifyToken} = this.widget.options
69
- if (uploadEncrypt && !downloadVerifyToken) {
70
- this.openId = await getOpenId()
71
- this.openId = this.openId.replaceAll("+", "%2B").replaceAll("=", "%3D")
37
+ export default {
38
+ props: {
39
+ widget: {
40
+ type: Object,
41
+ default: {}
42
+ },
43
+ url: {
44
+ type: String,
45
+ default: ''
46
+ },
47
+ disabled: {
48
+ type: Boolean,
49
+ default: false
50
+ },
51
+ defaultFile: {
52
+ type: Array,
53
+ default: () => []
54
+ }
55
+ },
56
+ data() {
57
+ return {
58
+ name: "",
59
+ percent: 0,
60
+ show: true,
61
+ uploadIng: false,
62
+ openId: undefined,
63
+ header: {
64
+ 'X-Access-Token': uni.getStorageSync('token') || this.$store.state.token || this.$store.getters.token
65
+ },
66
+ isShow: true,//是否展示点击上传
67
+ }
68
+ },
69
+ watch: {
70
+ //当上传的数量超过了设置的数量 就不让上传
71
+ defaultFile(val) {
72
+ this.getShow(val)
73
+ }
74
+ },
75
+ async mounted() {
76
+ const { uploadEncrypt, downloadVerifyToken } = this.widget.options
77
+ if (uploadEncrypt && !downloadVerifyToken) {
78
+ this.openId = await getOpenId()
79
+ this.openId = this.openId.replaceAll("+", "%2B").replaceAll("=", "%3D")
80
+ }
81
+ if (this.disabled) {
82
+ this.isShow = !this.disabled
83
+ }
84
+ else {
85
+ this.getShow(this.defaultFile)
86
+ }
87
+ },
88
+ methods: {
89
+ getShow(val) {
90
+ if (val && val.length >= this.widget.options.length) {
91
+ this.isShow = false
72
92
  }
73
- if(this.disabled){
74
- this.isShow =!this.disabled
75
- }
76
- else{
77
- this.getShow(this.defaultFile)
78
- }
79
- },
80
- methods: {
81
- getShow(val){
82
- if(val && val.length>=this.widget.options.length){
83
- this.isShow = false
84
- }
85
- else{
86
- this.isShow = true
87
- }
88
- },
89
- //删除文件
90
- handleDelete(idx) {
91
- this.$emit('fileDelete', idx)
92
- },
93
- async downLoadFile(path, name, item) {
94
- let baseUrl = this.downLoadUrl
95
- const { uploadEncrypt, downloadVerifyToken} = this.widget.options
96
- if (uploadEncrypt) {
97
- const [err, res = {} ] = await toAwait(this.$u.get('/sys/common/checkDownloadZip', {fileId: item.fileId}))
98
- if (err || !res.success) {
99
- return uni.showToast({title: res.message || '文件检查状态失败', icon: 'none'})
100
- }
101
- path = `/sys/common/downloadZip?fileId=${item.fileId}&openId=${this.openId}&token=${ this.header['X-Access-Token'] }`
102
- baseUrl = this.uniEnv.BASE_API || this.uniEnv.apiUrl
103
- }
104
- // #ifdef H5
105
- const { h5_preview, h5_preview_type } = this.widget.options
106
- if (h5_preview) {
107
- return h5PreviewFile(baseUrl + path, h5_preview_type)
93
+ else {
94
+ this.isShow = true
95
+ }
96
+ },
97
+ //删除文件
98
+ handleDelete(idx) {
99
+ this.$emit('fileDelete', idx)
100
+ },
101
+ async downLoadFile(path, name, item) {
102
+ let baseUrl = this.downLoadUrl
103
+ const { uploadEncrypt, downloadVerifyToken } = this.widget.options
104
+ if (uploadEncrypt) {
105
+ const [err, res = {}] = await toAwait(this.$u.get('/sys/common/checkDownloadZip', { fileId: item.fileId }))
106
+ if (err || !res.success) {
107
+ return uni.showToast({ title: res.message || '文件检查状态失败', icon: 'none' })
108
108
  }
109
- // #endif
110
- downloadFile(baseUrl, { path, name })
111
- },
112
- chooseMessageFile: function(e) {
113
- console.log(this.widget, )
114
- const { options } = this.widget
109
+ path = `/sys/common/downloadZip?fileId=${item.fileId}&openId=${this.openId}&token=${this.header['X-Access-Token']}`
110
+ baseUrl = this.uniEnv.BASE_API || this.uniEnv.apiUrl
111
+ }
112
+ // #ifdef H5
113
+ const { h5_preview, h5_preview_type } = this.widget.options
114
+ if (h5_preview) {
115
+ return h5PreviewFile(baseUrl + path, h5_preview_type)
116
+ }
117
+ // #endif
118
+ downloadFile(baseUrl, { path, name })
119
+ },
120
+ chooseMessageFile: function (e) {
121
+ console.log(this.widget,)
122
+ const { options } = this.widget
115
123
 
116
- if (this.disabled || (this.defaultFile.length && this.defaultFile.length >= options.length)) {
117
- this.uploadIng = false
118
- return false;
119
- }
124
+ if (this.disabled || (this.defaultFile.length && this.defaultFile.length >= options.length)) {
125
+ this.uploadIng = false
126
+ return false;
127
+ }
120
128
 
121
- if (this.uploadIng) {
122
- uni.showToast({
123
- title: `文件上传中`,
124
- icon: 'none'
125
- })
126
- return
127
- }
128
- var that = this;
129
- //#ifdef H5
130
- uni.chooseFile
131
- //#endif
132
- // #ifdef MP-WEIXIN
133
- wx.chooseMessageFile
129
+ if (this.uploadIng) {
130
+ uni.showToast({
131
+ title: `文件上传中`,
132
+ icon: 'none'
133
+ })
134
+ return
135
+ }
136
+ var that = this;
137
+ //#ifdef H5
138
+ uni.chooseFile
139
+ //#endif
140
+ // #ifdef MP-WEIXIN
141
+ wx.chooseMessageFile
134
142
  // #endif
135
143
  ({
136
- count: 1,
137
- type: 'all',
138
- success: (res) => {
144
+ count: 1,
145
+ type: 'all',
146
+ success: (res) => {
139
147
  this.uploadIng = true
140
- console.log(res.tempFiles)
141
- const path = res.tempFiles
142
- const { ext = '' , options } = this.widget
143
- const { fileSize } = options
144
- that.name = res.tempFiles[0].name
148
+ console.log(res.tempFiles)
149
+ const path = res.tempFiles
150
+ const { ext = '', options } = this.widget
151
+ const { fileSize } = options
152
+ that.name = res.tempFiles[0].name
145
153
 
146
154
  console.log(ext, that.name.split('.').pop())
147
155
  if (!ext.includes(that.name.split('.').pop())) {
@@ -160,16 +168,16 @@ import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../.
160
168
  }
161
169
 
162
170
  this.uploadIng = true
163
- const uploadTask = uni.uploadFile({
164
- url: that.url,
165
- filePath: path[0].path,
166
- name: 'file',
171
+ const uploadTask = uni.uploadFile({
172
+ url: that.url,
173
+ filePath: path[0].path,
174
+ name: 'file',
167
175
  formData: {
168
176
  fileName: that.name,
169
177
  },
170
178
  // header['X-Access-Token'] = uni.getStorageSync('token') || vm.$store.state.token
171
179
  header: this.header,
172
- success: function(res) {
180
+ success: function (res) {
173
181
  try {
174
182
  res = JSON.parse(res.data)
175
183
  if (!res.success) {
@@ -193,7 +201,7 @@ import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../.
193
201
  } catch (e) {
194
202
 
195
203
  }
196
- let uid = String(Math.random()).substr(2) - 0
204
+ let uid = String(Math.random()).substr(2) - 0
197
205
  let imgObj = {
198
206
  uid,
199
207
  key: uid,
@@ -205,80 +213,117 @@ import {downloadFile, getDictInfo, getOpenId, h5PreviewFile, toAwait} from "../.
205
213
  imgObj['fileId'] = res.result.fileId
206
214
  imgObj['name'] = imgObj['name'] || res.result.fileName
207
215
  }
208
- that.$emit('filePost', imgObj)
209
- },
216
+ that.$emit('filePost', imgObj)
217
+ },
210
218
  fail() {
211
- uni.showToast({title: '文件上传失败', icon: 'none'})
219
+ uni.showToast({ title: '文件上传失败', icon: 'none' })
212
220
  },
213
221
  complete() {
214
222
  that.show = false
215
223
  that.percent = 0
216
224
  that.uploadIng = false
217
225
  }
218
- });
226
+ });
219
227
 
220
228
  that.show = true
221
- uploadTask.onProgressUpdate(function(res) {
222
- that.percent = res.progress;
223
- if (Number(res.progress) == 100) {
224
- that.show = false
225
- }
226
- });
227
- },
229
+ uploadTask.onProgressUpdate(function (res) {
230
+ that.percent = res.progress;
231
+ if (Number(res.progress) == 100) {
232
+ that.show = false
233
+ }
234
+ });
235
+ },
228
236
 
229
- error: function(e) {
237
+ error: function (e) {
230
238
  that.uploadIng = false
231
- console.log(e);
232
- },
239
+ console.log(e);
240
+ },
233
241
 
234
242
  complete: (res) => {
235
243
  // if (res.errMsg.includes('cancel')) return that.uploadIng = false
236
244
  }
237
- });
238
- }
239
- }
240
- }
245
+ });
246
+ },
247
+ handlePreview(file) {
248
+ debugger
249
+ let ext = this.getFileExt(file.name)
250
+
251
+ if(['doc', 'docx', 'xls', 'xlsx'].includes(ext)) {
252
+ let preViewPdf = file.url
253
+ this.$u.get('/sys/common/preViewPdf', {preViewPdf}).then((res) => {
254
+ if(res.success) {
255
+ debugger
256
+ window.open( process.uniEnv.imgUrl+ res.message + '?download=0')
257
+ } else {
258
+ uni.showToast({
259
+ title: '当前状态不支持文件预览',
260
+ icon: "none",
261
+ duration: 1500,
262
+ })
263
+ }
264
+
265
+ })
266
+ return
267
+ }
268
+ window.open(process.uniEnv.imgUrl + file.url + '?download=0')
269
+ },
270
+ getFileExt(filename) {
271
+ try {
272
+ filename = decodeURIComponent(filename)
273
+ } catch (e) {
274
+
275
+ }
276
+ if (!filename || typeof filename != 'string') {
277
+ return false
278
+ };
279
+ let a = filename.split('').reverse().join('');
280
+ let b = a.substring(0, a.search(/\./)).split('').reverse().join('');
281
+ return b
282
+ }
283
+ }
284
+ }
241
285
  </script>
242
286
 
243
287
  <style scoped lang="scss">
244
- .file_conten {
245
- // display: flex;
246
- // flex-direction: row;
247
- // align-items: center;
248
- // justify-content: flex-start;
249
- }
288
+ .file_conten {
289
+ // display: flex;
290
+ // flex-direction: row;
291
+ // align-items: center;
292
+ // justify-content: flex-start;
293
+ }
294
+
295
+ .file_upload {
296
+ color: #666;
297
+ margin-right: 20rpx;
250
298
 
251
- .file_upload {
252
- color: #666;
253
- margin-right: 20rpx;
299
+ }
254
300
 
255
- }
301
+ .option-font-size {
302
+ font-size: $uni-form-content-font-size;
303
+ }
256
304
 
257
- .option-font-size {
258
- font-size: $uni-form-content-font-size;
259
- }
305
+ .name {
306
+ padding-top: 4upx;
307
+ font-size: 22upx;
308
+ }
260
309
 
261
- .name {
262
- padding-top: 4upx;
263
- font-size: 22upx;
264
- }
310
+ .SXcolor {
311
+ color: #539DFA;
312
+ }
265
313
 
266
- .SXcolor {
267
- color: #539DFA;
268
- }
314
+ .tips {
315
+ color: #999;
316
+ font-size: 22upx;
317
+ }
269
318
 
270
- .tips {
271
- color: #999;
272
- font-size: 22upx;
273
- }
319
+ .file_item {
320
+ width: calc(100% - 10px);
321
+ display: flex;
322
+ justify-content: space-between;
323
+ align-items: center;
274
324
 
275
- .file_item {
276
- width: calc(100% - 10px);
277
- display: flex;
278
- justify-content: space-between;
279
- align-items: center;
280
- view {
281
- margin-top: 10upx;
282
- }
283
- }
325
+ view {
326
+ margin-top: 10upx;
327
+ }
328
+ }
284
329
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zscreate/zhxy-app-component",
3
- "version": "1.0.320-test.4",
3
+ "version": "1.0.321",
4
4
  "private": false,
5
5
  "description": "zhxy-app-component",
6
6
  "main": "index.js",