@zscreate/zhxy-app-component 1.0.85 → 1.0.87

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.
@@ -532,6 +532,7 @@ import {
532
532
  getMode
533
533
  } from './utilForForm'
534
534
  import UserSelectByRole from "../userSelectByRole/userSelectByRole";
535
+ import {downloadFile} from "../../utils/util";
535
536
 
536
537
  export default {
537
538
  mixins: [computedMixin, validateFormMixin, pubSubMixin, valueChangeMixin],
@@ -884,63 +885,8 @@ export default {
884
885
  // console.log('this.checkboxAndRadioOptions', this.checkboxAndRadioOptions)
885
886
  },
886
887
 
887
- downLoadFile(path) {
888
- // console.log(process.uniEnv.uploadUrl)
889
- // console.log(path)
890
- // #ifdef H5
891
- window.open(this.uniEnv.imgUrl + path.url)
892
- return
893
- // #endif
894
- uni.downloadFile({
895
- // url: this.downLoadUrl + path, //下载地址接口返回
896
- url: this.uniEnv.imgUrl + path.url,
897
- filePath: wx.env.USER_DATA_PATH + "/" + path.name,
898
- success: (data) => {
899
- if (data.statusCode === 200) {
900
- //文件保存到本地
901
- uni.openDocument({
902
- filePath: data.filePath,
903
- showMenu: true,
904
- success: function (res) {
905
- // console.log('打开文档成功');
906
- },
907
- fail(res) {
908
- console.log(res)
909
- uni.showToast({
910
- icon: 'none',
911
- mask: true,
912
- title: '下载失败',
913
- duration: 3000,
914
- });
915
- },
916
- });
917
- // uni.saveFile({
918
- // tempFilePath: data.tempFilePath, //临时路径
919
- // success: function(res) {
920
- // uni.showToast({
921
- // icon: 'none',
922
- // mask: true,
923
- // title: '文件已保存:' + res.savedFilePath, //保存路径
924
- // duration: 3000,
925
- // });
926
- // setTimeout(() => {
927
- // //打开文档查看
928
- // uni.openDocument({
929
- // filePath: res.savedFilePath,
930
- // success: function(res) {
931
- // // console.log('打开文档成功');
932
- // },
933
- // complete: function(res) {}
934
- // });
935
- // }, 3000)
936
- // }
937
- // });
938
- }
939
- },
940
- complete: function (res) {
941
- // console.log(res)
942
- }
943
- })
888
+ downLoadFile(item) {
889
+ downloadFile(this.downloadUrl, { path: item.url, name: item.name })
944
890
  },
945
891
 
946
892
  /**纠错**/
@@ -24,7 +24,9 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
- export default {
27
+ import {downloadFile} from "../../utils/util";
28
+
29
+ export default {
28
30
  props: {
29
31
  widget: {
30
32
  type: Object,
@@ -48,7 +50,6 @@
48
50
  name: "",
49
51
  percent: 0,
50
52
  show: true,
51
- imgViewUrl: this.LFileBaseUrl,
52
53
  isShow:true,//是否展示点击上传
53
54
  }
54
55
  },
@@ -80,82 +81,7 @@
80
81
  this.$emit('fileDelete', idx)
81
82
  },
82
83
  downLoadFile(path, name) {
83
- //#ifdef H5
84
- const a = document.createElement("a")
85
- a.href = this.downLoadUrl + path
86
- a.target = '_blank'
87
- a.download = name
88
- a.click()
89
- return
90
- //#endif
91
-
92
- let type = '';
93
- const fileTypes = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx'];
94
- const imageTypes = ['png', 'jpeg', 'jpg', 'gif']
95
- if (path) {
96
- let str = path.split('.');
97
- type = str[str.length - 1]
98
- type = type.toString().toLowerCase()
99
- }
100
- if (imageTypes.includes(type)) {
101
- uni.previewImage({
102
- count: 1,
103
- urls: [ this.downLoadUrl + path ],
104
- fail() {
105
- uni.showToast({
106
- icon: 'none',
107
- mask: true,
108
- title: '图片打开失败!',
109
- duration: 3000,
110
- });
111
- }
112
- })
113
- return
114
- }
115
-
116
- wx.downloadFile({
117
- url: this.downLoadUrl + path,
118
- filePath: wx.env.USER_DATA_PATH + "/" + name,
119
- success: function (res) {
120
- console.log(res)
121
- if (fileTypes.includes(type)) {
122
- uni.openDocument({
123
- filePath: res.filePath,
124
- showMenu: true,
125
- fileType: type,
126
- fail(res) {
127
- console.log(res)
128
- uni.showToast({
129
- icon: 'none',
130
- mask: true,
131
- title: '文件打开失败!',
132
- duration: 3000,
133
- });
134
- },
135
- });
136
- } else {
137
- wx.shareFileMessage({
138
- filePath: res.filePath,
139
- success: function(res) {
140
- console.log("下载成功" + res.savedFilePath)
141
- console.log(JSON.stringify(res))
142
- },
143
- fail: (err) => {
144
- console.log("save error: " + err)
145
- }
146
- })
147
- }
148
- },
149
- fail(res) {
150
- console.log(res)
151
- uni.showToast({
152
- icon: 'none',
153
- mask: true,
154
- title: '下载失败',
155
- duration: 3000,
156
- });
157
- },
158
- })
84
+ downloadFile(this.downloadUrl, { path, name })
159
85
  },
160
86
  chooseMessageFile: function(e) {
161
87
  console.log(this.widget, )
@@ -23,8 +23,9 @@
23
23
  <u-checkbox :value="isAllCheck" @change="roleCheckAll">
24
24
  </u-checkbox>
25
25
  </view>
26
+ <view v-else>选择</view>
26
27
  </u-th>
27
- <u-th>姓名</u-th>
28
+ <u-th >姓名</u-th>
28
29
  <u-th>所属部门</u-th>
29
30
  </u-tr>
30
31
  <u-tr v-for="user in roleUserList" :key="user.id">
@@ -34,8 +35,8 @@
34
35
  </u-checkbox>
35
36
  </view>
36
37
  </u-td>
37
- <u-td><view>{{ user.realname }}</view></u-td>
38
- <u-td style="word-break: break-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"><view>{{ user.departName }}</view></u-td>
38
+ <u-td style="flex: 1"><view>{{ user.realname }}</view></u-td>
39
+ <u-td style="flex: 1; word-break: break-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"><view>{{ user.departName }}</view></u-td>
39
40
  </u-tr>
40
41
  </u-table>
41
42
 
@@ -48,6 +49,7 @@
48
49
  </view>
49
50
 
50
51
 
52
+ <t-loading :isLoading="isLoading"/>
51
53
  </u-popup>
52
54
  </template>
53
55
 
@@ -69,6 +71,7 @@ export default {
69
71
  multiple: false,
70
72
  depId: '',
71
73
  roleChecked: '',
74
+ isLoading: true,
72
75
  }
73
76
  },
74
77
  computed: {
@@ -83,7 +86,7 @@ export default {
83
86
  methods: {
84
87
  init(widget, value) {
85
88
  this.roleSelectShow = true
86
-
89
+ this.isLoading = true
87
90
  if (widget.options.departRelation) {
88
91
  const userInfo = uni.getStorageSync('userinfo')
89
92
  console.log("userInfo: ", userInfo)
@@ -91,7 +94,7 @@ export default {
91
94
  }
92
95
  this.role = widget.options.role
93
96
  this.multiple = widget.options.multiple
94
- this.currValue = value || []
97
+ this.currValue = cloneObj(value || [])
95
98
  this.$u.get('/sys/role/list', {
96
99
  pageNo: 1,
97
100
  pageSize: 100000,
@@ -99,8 +102,9 @@ export default {
99
102
  this.rolesList = res.result.records.filter((item) => {
100
103
  return this.role.includes(item.id);
101
104
  });
105
+ }).finally(() => {
106
+ this.isLoading = false
102
107
  })
103
- this.currValue = cloneObj(value)
104
108
  },
105
109
  removeClick(val) {
106
110
  this.currValue = this.currValue.filter(item => item.id !== val.id)
@@ -168,6 +172,7 @@ export default {
168
172
  }
169
173
  },
170
174
  roleChange(roleId) {
175
+ this.isLoading = true
171
176
  this.$u.get('/formApi/listFormUserByRole', {
172
177
  pageNo: 1,
173
178
  pageSize: 100000,
@@ -178,6 +183,10 @@ export default {
178
183
  item.checked = this.checkIds.includes(item.id)
179
184
  return item
180
185
  })
186
+ }).finally( () => {
187
+ this.$nextTick(() => {
188
+ this.isLoading = false
189
+ })
181
190
  })
182
191
 
183
192
  },
@@ -186,5 +195,10 @@ export default {
186
195
  </script>
187
196
 
188
197
  <style scoped>
189
-
198
+ /deep/ u-th:nth-child(1) {
199
+ flex: 0 0 40px;
200
+ }
201
+ /deep/ u-th {
202
+ flex: 1;
203
+ }
190
204
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zscreate/zhxy-app-component",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "private": false,
5
5
  "description": "zhxy-app-component",
6
6
  "main": "index.js",
package/utils/util.js CHANGED
@@ -66,41 +66,121 @@ var dateUtils = {
66
66
  }
67
67
  };
68
68
 
69
- function _debounce(fn, delay) {
70
- var delay = delay || 1000;
71
- var timer;
72
- return function () {
73
- var th = this;
74
- var args = arguments;
75
- if (timer) {
76
- clearTimeout(timer);
77
- }
78
- timer = setTimeout(function () {
79
- timer = null;
80
- fn.apply(th, args);
81
- }, delay);
82
- };
69
+ function _debounce(fn, delay) {
70
+ var delay = delay || 1000;
71
+ var timer;
72
+ return function () {
73
+ var th = this;
74
+ var args = arguments;
75
+ if (timer) {
76
+ clearTimeout(timer);
77
+ }
78
+ timer = setTimeout(function () {
79
+ timer = null;
80
+ fn.apply(th, args);
81
+ }, delay);
82
+ };
83
83
  }
84
84
 
85
- function cloneObj (obj) {
86
- if(obj === undefined || obj === null){
87
- return obj;
88
- }
89
- var newobj = obj.constructor === Array ? [] : {};
90
- if(typeof obj !== 'object'){
91
- return obj;
92
- } else {//如果不支持以上方法
93
- for(var i in obj){
94
- newobj[i] = typeof obj[i] === 'object' ? cloneObj(obj[i]) : obj[i];
95
- }
96
- }
97
- return newobj;
98
- }
85
+ function cloneObj (obj) {
86
+ if(obj === undefined || obj === null){
87
+ return obj;
88
+ }
89
+ var newobj = obj.constructor === Array ? [] : {};
90
+ if(typeof obj !== 'object'){
91
+ return obj;
92
+ } else {//如果不支持以上方法
93
+ for(var i in obj){
94
+ newobj[i] = typeof obj[i] === 'object' ? cloneObj(obj[i]) : obj[i];
95
+ }
96
+ }
97
+ return newobj;
98
+ }
99
+
100
+ function downloadFile(downLoadUrl, { path, name }) {
101
+ //#ifdef H5
102
+ const a = document.createElement("a")
103
+ a.href = downLoadUrl + path
104
+ a.target = '_blank'
105
+ name && (a.download = name)
106
+ a.click()
107
+ return
108
+ //#endif
109
+
110
+ let type = '';
111
+ const fileTypes = ['doc', 'docx', 'pdf', 'xls', 'xlsx', 'ppt', 'pptx'];
112
+ const imageTypes = ['png', 'jpeg', 'jpg', 'gif']
113
+ if (path) {
114
+ let str = path.split('.');
115
+ type = str[str.length - 1]
116
+ type = type.toString().toLowerCase()
117
+ }
118
+ if (imageTypes.includes(type)) {
119
+ uni.previewImage({
120
+ count: 1,
121
+ urls: [ downLoadUrl + path ],
122
+ fail() {
123
+ uni.showToast({
124
+ icon: 'none',
125
+ mask: true,
126
+ title: '图片打开失败!',
127
+ duration: 3000,
128
+ });
129
+ }
130
+ })
131
+ return
132
+ }
133
+
134
+ wx.downloadFile({
135
+ url: downLoadUrl + path,
136
+ filePath: wx.env.USER_DATA_PATH + "/" + name,
137
+ success: function (res) {
138
+ console.log(res)
139
+ if (fileTypes.includes(type)) {
140
+ uni.openDocument({
141
+ filePath: res.filePath,
142
+ showMenu: true,
143
+ fileType: type,
144
+ fail(res) {
145
+ console.log(res)
146
+ uni.showToast({
147
+ icon: 'none',
148
+ mask: true,
149
+ title: '文件打开失败!',
150
+ duration: 3000,
151
+ });
152
+ },
153
+ });
154
+ } else {
155
+ wx.shareFileMessage({
156
+ filePath: res.filePath,
157
+ success: function(res) {
158
+ console.log("下载成功" + res.savedFilePath)
159
+ console.log(JSON.stringify(res))
160
+ },
161
+ fail: (err) => {
162
+ console.log("save error: " + err)
163
+ }
164
+ })
165
+ }
166
+ },
167
+ fail(res) {
168
+ console.log(res)
169
+ uni.showToast({
170
+ icon: 'none',
171
+ mask: true,
172
+ title: '下载失败',
173
+ duration: 3000,
174
+ });
175
+ },
176
+ })
177
+ }
99
178
 
100
179
  module.exports = {
101
180
  formatTime: formatTime,
102
181
  formatLocation: formatLocation,
103
182
  dateUtils: dateUtils,
104
183
  cloneObj: cloneObj,
105
- _debounce:_debounce
106
- }
184
+ _debounce:_debounce,
185
+ downloadFile
186
+ }