@zscreate/zhxy-app-component 1.0.4 → 1.0.7

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.
@@ -117,8 +117,8 @@
117
117
  {{widget.name}}
118
118
  </view>
119
119
  <view class="evan-form-item-container__main" :style="mContentStyle">
120
- <switch :checked="dataModel" @change="switch1Change" color="#007AFF" style="transform: scale(0.8,0.8)"
121
- :disabled="widget.options.disabled" />
120
+ <form-switch :checked="dataModel" @change="switch1Change" color="#007AFF" style="transform: scale(0.8,0.8)"
121
+ :disabled="widget.options.disabled" />
122
122
  </view>
123
123
  </view>
124
124
 
@@ -388,9 +388,9 @@
388
388
  </view>
389
389
  <view class="evan-form-item-container__main" :style="mContentStyle"
390
390
  @click="handleSeclet(widget.options.multiple)">
391
- <div class="option-font-size">{{dataModelShow ? dataModelShow : widget.options.placeholder}}</div>
391
+ <div class="option-font-size">{{dataModelShow ? dataModelShow : widget.options.placeholder }}</div>
392
392
  </view>
393
- <icon type="clear" size="14" v-if="item.options.canView" />
393
+ <!-- <icon type="clear" size="14" v-if="widget.options.canView" />-->
394
394
  </view>
395
395
 
396
396
  <!-- userSelector -->
@@ -469,9 +469,11 @@
469
469
  import {
470
470
  getMode
471
471
  } from './utilForForm'
472
+ import FormSwitch from "../form-switch/form-switch";
472
473
  export default {
473
474
  mixins: [computedMixin, validateFormMixin, pubSubMixin, valueChangeMixin],
474
475
  components: {
476
+ FormSwitch,
475
477
  UniRate,
476
478
  tColorPicker,
477
479
  unploadFile,
@@ -0,0 +1,32 @@
1
+ <template>
2
+ <switch :checked="dataModel" @change="change" v-bind="$attrs"
3
+ :disabled="disabled" />
4
+ </template>
5
+
6
+ <script>
7
+ export default {
8
+ name: "form-switch",
9
+ props: {
10
+ checked: Boolean,
11
+ disabled: Boolean,
12
+ defaultValue: Boolean,
13
+ },
14
+ data() {
15
+ return {
16
+ dataModel: false
17
+ }
18
+ },
19
+ created() {
20
+ this.dataModel = this.defaultValue
21
+ },
22
+ methods: {
23
+ change(e) {
24
+ this.$emit('change', e)
25
+ }
26
+ }
27
+ }
28
+ </script>
29
+
30
+ <style scoped>
31
+
32
+ </style>
@@ -1,267 +1,273 @@
1
- <template>
2
- <view>
3
- <view class="file_conten">
4
- <view class="file_upload option-font-size" @click="chooseMessageFile"
5
- v-if="isShow">
6
- 点击上传
7
- </view>
8
- <view>
9
- <view class="file_item" v-for="(item,idx) in defaultFile" :key="idx">
10
- <view @click="downLoadFile(item.url,item.name)">{{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>
16
- <view class="name SXcolor" v-if="fileName" @click="downLoadFile(defaultFile[0]['url'])">{{fileName}}</view>
17
- </view>
18
- <view v-if="fileName" class="tips option-font-size">更多文件详情请于电脑端查看</view> -->
19
- <view v-if="!disabled">
20
- <progress :percent="percent" stroke-width="5" activeColor="#007AFF" backgroundColor="#FFFFFF"
21
- style="width: 200upx;" v-show="show"></progress>
22
- </view>
23
- </view>
24
- </template>
25
-
26
- <script>
27
- export default {
28
- props: {
29
- widget: {
30
- type: Object,
31
- default: {}
32
- },
33
- url: {
34
- type: String,
35
- default: ''
36
- },
37
- disabled: {
38
- type: Boolean,
39
- default: false
40
- },
41
- defaultFile: {
42
- type: Array,
43
- default: () => []
44
- }
45
- },
46
- data() {
47
- return {
48
- name: "",
49
- percent: 0,
50
- show: true,
51
- imgViewUrl: this.LFileBaseUrl,
52
- isShow:true,//是否展示点击上传
53
- }
54
- },
55
- watch:{
56
- //当上传的数量超过了设置的数量 就不让上传
57
- defaultFile(val){
58
- this.getShow(val)
59
- }
60
- },
61
- mounted() {
62
- if(this.disabled){
63
- this.isShow =!this.disabled
64
- }
65
- else{
66
- this.getShow(this.defaultFile)
67
- }
68
- },
69
- methods: {
70
- getShow(val){
71
- if(val && val.length>=this.widget.length){
72
- this.isShow = false
73
- }
74
- else{
75
- this.isShow = true
76
- }
77
- },
78
- //删除文件
79
- handleDelete(idx) {
80
- this.$emit('fileDelete', idx)
81
- },
82
- downLoadFile(path, name) {
83
- //#ifdef H5
84
- const a = document.createElement("a")
85
- a.href = this.downLoadUrl + path
86
- a.target = '_blank'
87
- a.click()
88
- return
89
- //#endif
90
- // if (path.includes('.pdf')) {
91
- // uni.navigateTo({
92
- // url: '/pages/home/Singlepoint?url=' + this.downLoadUrl + path + "&download=true"
93
- // })
94
- // return false;
95
- // }
96
- let type = '';
97
- let fileType = '';
98
- let fileTypesIndex = -1;
99
- const fileTypes = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx'];
100
- if (path) {
101
- let str = path.split('.');
102
- type = str[str.length - 1]
103
- }
104
-
105
- if (type) {
106
- fileTypesIndex = fileTypes.indexOf(type);
107
- console.log(fileTypesIndex)
108
- }
109
-
110
- if (fileTypesIndex != -1) {
111
- fileType = fileTypes[fileTypesIndex]
112
- }
113
- // #ifdef H5
114
- window.open(this.uniEnv.imgUrl + path)
115
- return
116
- // #endif
117
- uni.downloadFile({
118
- url: this.uniEnv.imgUrl + path, //下载地址接口返回
119
- filePath: wx.env.USER_DATA_PATH + "/" + name,
120
- success: (data) => {
121
- console.log(data)
122
- if (data.statusCode === 200) {
123
- uni.openDocument({
124
- filePath: data.filePath,
125
- showMenu: true,
126
- fileType: fileType,
127
- success: function(res) {
128
- // console.log('打开文档成功');
129
- },
130
- fail(res) {
131
- console.log(res)
132
- uni.showToast({
133
- icon: 'none',
134
- mask: true,
135
- title: '下载失败',
136
- duration: 3000,
137
- });
138
- },
139
- });
140
- }
141
- },
142
- })
143
- // uni.downloadFile({
144
- // url: this.downLoadUrl + path, //下载地址接口返回
145
- // success: (data) => {
146
- // if (data.statusCode === 200) {
147
- // //文件保存到本地
148
- // uni.saveFile({
149
- // tempFilePath: data.tempFilePath, //临时路径
150
- // success: function(res) {
151
- // uni.showToast({
152
- // icon: 'none',
153
- // mask: true,
154
- // title: '文件已保存:' + res.savedFilePath, //保存路径
155
- // duration: 3000,
156
- // });
157
- // setTimeout(() => {
158
- // // escape(res.savedFilePath)
159
- // //打开文档查看
160
- // uni.openDocument({
161
- // filePath: res.savedFilePath,
162
- // fileType: fileType,
163
- // success: function(res) {
164
- // // console.log('打开文档成功');
165
- // },
166
- // fail(res) {
167
- // console.log(res)
168
- // uni.showToast({
169
- // icon: 'none',
170
- // mask: true,
171
- // title: '文件打开失败!', //保存路径
172
- // duration: 3000,
173
- // });
174
- // },
175
- // });
176
- // }, 3000)
177
- // }
178
- // });
179
- // }
180
- // }
181
- // })
182
- },
183
- chooseMessageFile: function(e) {
184
- console.log(this.widget, )
185
- if (this.disabled || (this.defaultFile.length && this.defaultFile.length >= this.widget.length)) return false;
186
- var that = this;
187
- wx.chooseMessageFile({
188
- count: 1,
189
- type: 'all',
190
- success(res) {
191
- console.log(res.tempFiles)
192
- const path = res.tempFiles
193
- that.name = res.tempFiles[0].name
194
- const uploadTask = uni.uploadFile({
195
- url: that.url,
196
- filePath: path[0].path,
197
- name: 'file',
198
- formData: {},
199
- success: function(res) {
200
- let imgObj = {
201
- key: String(Math.random()).substr(2) - 0,
202
- name: that.name,
203
- status: "success",
204
- url: JSON.parse(res.data).message
205
- }
206
- that.$emit('filePost', imgObj)
207
- }
208
- });
209
-
210
- uploadTask.onProgressUpdate(function(res) {
211
- that.percent = res.progress;
212
- if (Number(res.progress) == 100) {
213
- that.show = false
214
- }
215
- });
216
- },
217
- error: function(e) {
218
- console.log(e);
219
- }
220
- });
221
- }
222
- }
223
- }
224
- </script>
225
-
226
- <style scoped lang="scss">
227
- .file_conten {
228
- // display: flex;
229
- // flex-direction: row;
230
- // align-items: center;
231
- // justify-content: flex-start;
232
- }
233
-
234
- .file_upload {
235
- color: #666;
236
- margin-right: 20rpx;
237
-
238
- }
239
-
240
- .option-font-size {
241
- font-size: $uni-form-content-font-size;
242
- }
243
-
244
- .name {
245
- padding-top: 4upx;
246
- font-size: 22upx;
247
- }
248
-
249
- .SXcolor {
250
- color: #539DFA;
251
- }
252
-
253
- .tips {
254
- color: #999;
255
- font-size: 22upx;
256
- }
257
-
258
- .file_item {
259
- width: 700upx;
260
- display: flex;
261
- justify-content: space-between;
262
- align-items: center;
263
- view{
264
- margin-top: 10upx;
265
- }
266
- }
267
- </style>
1
+ <template>
2
+ <view>
3
+ <view class="file_conten">
4
+ <view class="file_upload option-font-size" @click="chooseMessageFile"
5
+ v-if="isShow">
6
+ 点击上传
7
+ </view>
8
+ <view>
9
+ <view class="file_item" v-for="(item,idx) in defaultFile" :key="idx">
10
+ <view @click="downLoadFile(item.url,item.name)">{{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>
16
+ <view class="name SXcolor" v-if="fileName" @click="downLoadFile(defaultFile[0]['url'])">{{fileName}}</view>
17
+ </view>
18
+ <view v-if="fileName" class="tips option-font-size">更多文件详情请于电脑端查看</view> -->
19
+ <view v-if="!disabled">
20
+ <progress :percent="percent" stroke-width="5" activeColor="#007AFF" backgroundColor="#FFFFFF"
21
+ style="width: 200upx;" v-show="show"></progress>
22
+ </view>
23
+ </view>
24
+ </template>
25
+
26
+ <script>
27
+ export default {
28
+ props: {
29
+ widget: {
30
+ type: Object,
31
+ default: {}
32
+ },
33
+ url: {
34
+ type: String,
35
+ default: ''
36
+ },
37
+ disabled: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ defaultFile: {
42
+ type: Array,
43
+ default: () => []
44
+ }
45
+ },
46
+ data() {
47
+ return {
48
+ name: "",
49
+ percent: 0,
50
+ show: true,
51
+ imgViewUrl: this.LFileBaseUrl,
52
+ isShow:true,//是否展示点击上传
53
+ }
54
+ },
55
+ watch:{
56
+ //当上传的数量超过了设置的数量 就不让上传
57
+ defaultFile(val){
58
+ this.getShow(val)
59
+ }
60
+ },
61
+ mounted() {
62
+ if(this.disabled){
63
+ this.isShow =!this.disabled
64
+ }
65
+ else{
66
+ this.getShow(this.defaultFile)
67
+ }
68
+ },
69
+ methods: {
70
+ getShow(val){
71
+ if(val && val.length>=this.widget.length){
72
+ this.isShow = false
73
+ }
74
+ else{
75
+ this.isShow = true
76
+ }
77
+ },
78
+ //删除文件
79
+ handleDelete(idx) {
80
+ this.$emit('fileDelete', idx)
81
+ },
82
+ downLoadFile(path, name) {
83
+ //#ifdef H5
84
+ const a = document.createElement("a")
85
+ a.href = this.downLoadUrl + path
86
+ a.target = '_blank'
87
+ a.click()
88
+ return
89
+ //#endif
90
+ // if (path.includes('.pdf')) {
91
+ // uni.navigateTo({
92
+ // url: '/pages/home/Singlepoint?url=' + this.downLoadUrl + path + "&download=true"
93
+ // })
94
+ // return false;
95
+ // }
96
+ let type = '';
97
+ let fileType = '';
98
+ let fileTypesIndex = -1;
99
+ const fileTypes = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx'];
100
+ if (path) {
101
+ let str = path.split('.');
102
+ type = str[str.length - 1]
103
+ }
104
+
105
+ if (type) {
106
+ fileTypesIndex = fileTypes.indexOf(type);
107
+ console.log(fileTypesIndex)
108
+ }
109
+
110
+ if (fileTypesIndex != -1) {
111
+ fileType = fileTypes[fileTypesIndex]
112
+ }
113
+ // #ifdef H5
114
+ window.open(this.uniEnv.imgUrl + path)
115
+ return
116
+ // #endif
117
+ uni.downloadFile({
118
+ url: this.uniEnv.imgUrl + path, //下载地址接口返回
119
+ filePath: wx.env.USER_DATA_PATH + "/" + name,
120
+ success: (data) => {
121
+ console.log(data)
122
+ if (data.statusCode === 200) {
123
+ uni.openDocument({
124
+ filePath: data.filePath,
125
+ showMenu: true,
126
+ fileType: fileType,
127
+ success: function(res) {
128
+ // console.log('打开文档成功');
129
+ },
130
+ fail(res) {
131
+ console.log(res)
132
+ uni.showToast({
133
+ icon: 'none',
134
+ mask: true,
135
+ title: '下载失败',
136
+ duration: 3000,
137
+ });
138
+ },
139
+ });
140
+ }
141
+ },
142
+ })
143
+ // uni.downloadFile({
144
+ // url: this.downLoadUrl + path, //下载地址接口返回
145
+ // success: (data) => {
146
+ // if (data.statusCode === 200) {
147
+ // //文件保存到本地
148
+ // uni.saveFile({
149
+ // tempFilePath: data.tempFilePath, //临时路径
150
+ // success: function(res) {
151
+ // uni.showToast({
152
+ // icon: 'none',
153
+ // mask: true,
154
+ // title: '文件已保存:' + res.savedFilePath, //保存路径
155
+ // duration: 3000,
156
+ // });
157
+ // setTimeout(() => {
158
+ // // escape(res.savedFilePath)
159
+ // //打开文档查看
160
+ // uni.openDocument({
161
+ // filePath: res.savedFilePath,
162
+ // fileType: fileType,
163
+ // success: function(res) {
164
+ // // console.log('打开文档成功');
165
+ // },
166
+ // fail(res) {
167
+ // console.log(res)
168
+ // uni.showToast({
169
+ // icon: 'none',
170
+ // mask: true,
171
+ // title: '文件打开失败!', //保存路径
172
+ // duration: 3000,
173
+ // });
174
+ // },
175
+ // });
176
+ // }, 3000)
177
+ // }
178
+ // });
179
+ // }
180
+ // }
181
+ // })
182
+ },
183
+ chooseMessageFile: function(e) {
184
+ console.log(this.widget, )
185
+ if (this.disabled || (this.defaultFile.length && this.defaultFile.length >= this.widget.length)) return false;
186
+ var that = this;
187
+ //#ifdef H5
188
+ uni.chooseFile
189
+ //#endif
190
+ // #ifdef MP-WEIXIN
191
+ wx.chooseMessageFile
192
+ // #endif
193
+ ({
194
+ count: 1,
195
+ type: 'all',
196
+ success(res) {
197
+ console.log(res.tempFiles)
198
+ const path = res.tempFiles
199
+ that.name = res.tempFiles[0].name
200
+ const uploadTask = uni.uploadFile({
201
+ url: that.url,
202
+ filePath: path[0].path,
203
+ name: 'file',
204
+ formData: {},
205
+ success: function(res) {
206
+ let imgObj = {
207
+ key: String(Math.random()).substr(2) - 0,
208
+ name: that.name,
209
+ status: "success",
210
+ url: JSON.parse(res.data).message
211
+ }
212
+ that.$emit('filePost', imgObj)
213
+ }
214
+ });
215
+
216
+ uploadTask.onProgressUpdate(function(res) {
217
+ that.percent = res.progress;
218
+ if (Number(res.progress) == 100) {
219
+ that.show = false
220
+ }
221
+ });
222
+ },
223
+ error: function(e) {
224
+ console.log(e);
225
+ }
226
+ });
227
+ }
228
+ }
229
+ }
230
+ </script>
231
+
232
+ <style scoped lang="scss">
233
+ .file_conten {
234
+ // display: flex;
235
+ // flex-direction: row;
236
+ // align-items: center;
237
+ // justify-content: flex-start;
238
+ }
239
+
240
+ .file_upload {
241
+ color: #666;
242
+ margin-right: 20rpx;
243
+
244
+ }
245
+
246
+ .option-font-size {
247
+ font-size: $uni-form-content-font-size;
248
+ }
249
+
250
+ .name {
251
+ padding-top: 4upx;
252
+ font-size: 22upx;
253
+ }
254
+
255
+ .SXcolor {
256
+ color: #539DFA;
257
+ }
258
+
259
+ .tips {
260
+ color: #999;
261
+ font-size: 22upx;
262
+ }
263
+
264
+ .file_item {
265
+ width: 700upx;
266
+ display: flex;
267
+ justify-content: space-between;
268
+ align-items: center;
269
+ view{
270
+ margin-top: 10upx;
271
+ }
272
+ }
273
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zscreate/zhxy-app-component",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "private": false,
5
5
  "description": "zhxy-app-component",
6
6
  "main": "index.js",