Blame view

pages/official/official.vue 12.3 KB
290144e9   易尊强   第一次
1
2
  <template>
  	<view class="page">
bd028579   易尊强   2/28
3
4
  		<!-- 管理员看到的 -->
  		<view class="test" v-if="isAdmin">
290144e9   易尊强   第一次
5
6
7
8
9
10
11
12
  			<!-- <uni-file-picker 
  				v-model="files" 
  				fileMediatype="all" 
  				@select="select" 
  				:limit="5"
  				style="border: 1px solid red;margin-bottom: 30px;"
  			/> -->
  			<!-- <up-load></up-load> -->
bd028579   易尊强   2/28
13
14
  			<view class="file_upload"
  				style="width: 90%;height: 60rpx; margin: 0 auto;display: flex;color: white; align-items: center; justify-content: space-around; background-color: gray;border-radius: 20rpx;">
290144e9   易尊强   第一次
15
16
17
18
19
  				<view class="file_name">
  					{{fileName}}
  				</view>
  				<view class="" @click="handleUploadClick" style="display: flex;align-items: center;">
  					<text>上传文件</text>
bd028579   易尊强   2/28
20
21
  					<image src="../../static/image/upload.png" style="width: 20rpx;height: 20rpx;margin-left: 20rpx;"
  						mode=""></image>
290144e9   易尊强   第一次
22
  				</view>
bd028579   易尊强   2/28
23
  
290144e9   易尊强   第一次
24
25
  			</view>
  			<xe-upload ref="XeUpload" :options="uploadOptions" @callback="handleUploadCallback"></xe-upload>
bd028579   易尊强   2/28
26
27
  			<wyh-tree-select :items="items" :activeIds="city_ids5" :selectAll="true" :isSearch="true"
  				@getTypeCompanyList="getTypeCompanyList" />
290144e9   易尊强   第一次
28
29
  			<view class="official">
  				<view>已选<text class="official-num">{{city_ids5.length}}</text>家企业</view>
bd028579   易尊强   2/28
30
31
  				<radio :checked="check" @click="change">是否通知</radio>
  				<view class="official-btn" @click="toGrouping">自定义分组</view>
290144e9   易尊强   第一次
32
33
34
  				<view class="official-btn" @click="send">确认发送</view>
  			</view>
  		</view>
bd028579   易尊强   2/28
35
36
  		<!-- 企业用户看到的 -->
  		<view class="test" v-else>
5bbfac44   易尊强   28号下午提交
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  			<view class="page1">
  				<view class="" style="width: 96%;margin: 0 auto;overflow: hidden;" v-show="!isNull">
  					<view class="" style="width: 140rpx; margin: 0 auto;margin-top: 300rpx;font-size: 30rpx;">
  						暂无信息
  					</view>
  				</view>
  				<view class="" style="width: 96%;margin: 0 auto;overflow: hidden;" v-show="isNull">
  					<view class="item" v-for="(it,index) in fileList" :key="index">
  						<view class="fileName" style="margin-left: 30rpx; ">
  							{{it.docmentName}}
  						</view>
  						<button @click="download(it.docmentUrl)">下载</button>
  					</view>
  				</view>
  			</view>
bd028579   易尊强   2/28
52
  		</view>
290144e9   易尊强   第一次
53
54
55
56
57
58
59
60
61
62
  	</view>
  </template>
  
  <script>
  	import request from '@/utils/request.js'
  	import upLoad from '@/components/ncc/ncc-upload/index.vue'
  	export default {
  		computed: {
  			city_name5() {
  				return this.getCityNames(this.city_ids5);
bd028579   易尊强   2/28
63
64
  			},
  
290144e9   易尊强   第一次
65
  		},
bd028579   易尊强   2/28
66
  		components: {
290144e9   易尊强   第一次
67
68
69
70
71
72
73
74
  			upLoad
  		},
  		data() {
  			return {
  				items: [],
  				city_ids5: [],
  				files: [],
  				// 上传的文件路径
bd028579   易尊强   2/28
75
  				fileUrl: '',
290144e9   易尊强   第一次
76
77
78
79
  				uploadOptions: {
  					url: 'http://deyanggaoxin.fengshiyun.com/api/file/Uploader/1', // 不传入上传地址则返回本地链接
  					// url: '', // 不传入上传地址则返回本地链接
  				},
044301aa   “wangming”   1
80
  				check: false,
290144e9   易尊强   第一次
81
  				// 文件名
bd028579   易尊强   2/28
82
  				fileName: '文件名',
290144e9   易尊强   第一次
83
  				// 当前用户ID:
bd028579   易尊强   2/28
84
  				userId: '',
5bbfac44   易尊强   28号下午提交
85
86
87
88
89
90
91
  				isAdmin:false,
  				// 用户公司ID
  				companyId: '',
  				// 公文列表
  				fileList: [],
  				isNull: false,
  				baseUrl: 'http://deyanggaoxin.fengshiyun.com'
290144e9   易尊强   第一次
92
93
94
95
  			}
  		},
  		onShow() {
  			this.getUser()
bd028579   易尊强   2/28
96
97
  			this.getTypeOfCompany()
  			this.getTypeCompanyList('365139048618001669')
5bbfac44   易尊强   28号下午提交
98
  			this.getFileList()
bd028579   易尊强   2/28
99
100
101
102
103
  			// this.getCompanyList()
  			// this.getTypeOfCompany()
  		},
  		watch: {
  
290144e9   易尊强   第一次
104
105
  		},
  		methods: {
044301aa   “wangming”   1
106
107
  			change() {
  				console.log('check', this.check)
bd028579   易尊强   2/28
108
  				this.check = !this.check
044301aa   “wangming”   1
109
  				console.log('check', this.check)
bd028579   易尊强   2/28
110
  			},
290144e9   易尊强   第一次
111
  			// 获取用户信息
bd028579   易尊强   2/28
112
  			getUser() {
290144e9   易尊强   第一次
113
114
115
116
117
118
119
  				if (uni.getStorageSync('user')) {
  					let userCode = uni.getStorageSync('user')
  					// console.log("用户的code", this.userCode)
  					this.userId = userCode.userInfo.userId
  					this.userName = userCode.userInfo.userAccount
  					this.userIcon = userCode.userInfo.headIcon
  					this.organizeName = userCode.userInfo.organizeName
044301aa   “wangming”   1
120
  					if (this.userId === 'admin') {
bd028579   易尊强   2/28
121
122
  						this.isAdmin = true
  					}
290144e9   易尊强   第一次
123
124
125
126
127
128
129
130
131
132
133
134
135
  					console.log(userCode)
  				} else {
  					uni.showToast({
  						title: '请登录',
  						icon: 'none'
  					})
  					setTimeout(() => {
  						uni.reLaunch({
  							url: '/pages/login/index'
  						})
  					})
  				}
  			},
bd028579   易尊强   2/28
136
137
  
  			// 跳转到自定义分组页面
044301aa   “wangming”   1
138
  			toGrouping() {
bd028579   易尊强   2/28
139
  				uni.navigateTo({
044301aa   “wangming”   1
140
  					url: '/pages/official/grouping/grouping'
bd028579   易尊强   2/28
141
142
143
144
  				})
  			},
  			// 获取企业分类
  			getTypeOfCompany() {
290144e9   易尊强   第一次
145
  				request({
bd028579   易尊强   2/28
146
147
148
149
150
  					url: '/api/system/DictionaryData/365138541614728453',
  					method: 'get',
  					data: {}
  				}).then(res => {
  					if (res.code == 200) {
290144e9   易尊强   第一次
151
  						console.log(res)
bd028579   易尊强   2/28
152
153
154
155
156
157
158
159
160
161
162
163
164
  						this.items = []
  						for (let i = 0; i < res.data.list.length; i++) {
  							this.items.push({
  								text: res.data.list[i].fullName,
  								id: res.data.list[i].id,
  								children: []
  							})
  						}
  						console.log(this.items)
  					} else if (res.code == 600) {
  						uni.showToast({
  							title: '请登录',
  							icon: 'none'
290144e9   易尊强   第一次
165
  						})
bd028579   易尊强   2/28
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
  					}
  				})
  			},
  			// 根据分类获取企业列表
  			getTypeCompanyList(id) {
  				request({
  					url: '/api/permission/organize/list',
  					method: 'get',
  					data: {
  						pageSize: 1000,
  						groupId: id
  					}
  				}).then(res => {
  					console.log(res)
  					if (res.code == 200) {
  						let result = this.items.findIndex(it => it.id === id)
  						this.items[result].children = []
  						console.log('下标', result)
  						let arr = res.data.list.map(it => {
290144e9   易尊强   第一次
185
186
  							return {
  								...it,
bd028579   易尊强   2/28
187
188
189
  								text: it.fullName,
  								id: it.id,
  								type: false,
290144e9   易尊强   第一次
190
191
  							}
  						})
bd028579   易尊强   2/28
192
  						this.items[result].children = arr
290144e9   易尊强   第一次
193
194
195
  					}
  				})
  			},
bd028579   易尊强   2/28
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
  			handleUploadClick() {
  				// 使用默认配置则不需要传入第二个参数
  				type: ['image', 'video', 'file'];
  				this.$refs.XeUpload.upload('file', {});
  				// this.$refs.XeUpload.upload('image', {
  				//  count: 6,
  				//  sizeType: ['original', 'compressed'],
  				//  sourceType: ['album'],
  				// });
  			},
  			handleUploadCallback(e) {
  				// e.type: ['choose', 'success', 'warning']
  				// choose 是options没有传入url,返回临时链接时触发
  				// success 是上传成功返回对应的数据时触发
  				// warning 上传或者选择文件失败触发
  				// ......
  				console.log(e)
  				this.fileUrl = e.data[0].response.data.url
  				this.fileName = e.data[0].name
  
  			},
  			// 获取机构列表
  			// getCompanyList(){
  			// 	request({
  			// 		url:'/api/permission/organize',
  			// 		methos:'get',
  			// 		data:{
  			// 			pageSize:500
  			// 		}
  			// 	}).then(res=>{
  			// 		if(res.code === 200){
  			// 			// console.log(res)
  			// 			let zhuangBei = res.data.list.filter(it=>{
  			// 				return it.stage === '装备制造'
  			// 			}).map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 			let yiYao = res.data.list.filter(it=>{
  			// 				return it.stage === '医药'
  			// 			}).map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 			let food = res.data.list.filter(it=>{
  			// 				return it.stage === '食品'
  			// 			}).map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 			let hangKong = res.data.list.filter(it=>{
  			// 				return it.stage === '通用航空'
  			// 			}).map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 			let caiLiao = res.data.list.filter(it=>{
  			// 				return it.stage === '先进材料'
  			// 			}).map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 			let another = res.data.list.filter(it=>{
  			// 				return it.stage === '其他' || it.stage === null
  			// 			}).map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 			// console.log('装备制造',zhuangBei)
  			// 			// console.log('医药',yiYao)
  			// 			// console.log('食品',food)
  			// 			// console.log('通用航空',hangKong)
  			// 			// console.log('先进材料',caiLiao)
  			// 			// console.log('其他',another)
  			// 			this.items = [
  			// 				{
  			// 					text:'全部',
  			// 					children:res.data.list.map(it=>{
  			// 				return {
  			// 					...it,
  			// 					text:it.fullName,
  			// 					id:it.id,
  			// 					type:false
  			// 				}
  			// 			})
  			// 				},
  			// 				{
  			// 					text:'装备制造',
  			// 					children:zhuangBei
  			// 				},
  			// 				{
  			// 					text:'医药',
  			// 					children:yiYao
  			// 				},
  			// 				{
  			// 					text:'食品',
  			// 					children:food
  			// 				},
  			// 				{
  			// 					text:'通用航空',
  			// 					children:hangKong
  			// 				},
  			// 				{
  			// 					text:'先进材料',
  			// 					children:caiLiao
  			// 				},
  			// 				{
  			// 					text:'其他',
  			// 					children:another
  			// 				},
  			// 			]
  			// 		}
  			// 	})
  			// },
290144e9   易尊强   第一次
334
335
336
337
338
339
340
341
342
343
  			onItem(res) {
  				console.log(res);
  			},
  			// select(e){
  			// 	console.log("上传文件",e)
  			// 	this.files = e.tempFiles
  			// 	// console.log(this.files)
  			// },
  			// success(e){
  			// 	console.log('success',this.files)
bd028579   易尊强   2/28
344
  
290144e9   易尊强   第一次
345
346
347
348
349
350
351
352
  			// },
  			// 发送文件
  			send() {
  				console.log("111")
  				let userInfo = uni.getStorageSync('user')
  				console.log(userInfo)
  				this.userId = userInfo.userInfo.userId
  				console.log(this.userId)
bd028579   易尊强   2/28
353
354
  				console.log('文件路径', this.fileUrl)
  				if (this.city_ids5.length === 0) {
290144e9   易尊强   第一次
355
  					uni.showToast({
bd028579   易尊强   2/28
356
  						title: "请选择企业"
290144e9   易尊强   第一次
357
358
359
  					})
  					return
  				}
bd028579   易尊强   2/28
360
  				for (let i = 0; i < this.city_ids5.length; i++) {
290144e9   易尊强   第一次
361
  					request({
bd028579   易尊强   2/28
362
363
364
365
366
367
368
  						url: '/api/Extend/basedocumenthandle',
  						method: 'post',
  						data: {
  							companyId: this.city_ids5[i],
  							creatorUserId: this.userId,
  							docmentUrl: this.fileUrl,
  							docmentName: this.fileName
290144e9   易尊强   第一次
369
  						},
bd028579   易尊强   2/28
370
  						header: {
290144e9   易尊强   第一次
371
372
  							"Content-Type": "application/json-patch+json"
  						}
bd028579   易尊强   2/28
373
  					}).then(res => {
290144e9   易尊强   第一次
374
  						console.log(res)
bd028579   易尊强   2/28
375
376
  						if (res.code === 200) {
  							if(this.check){
5bbfac44   易尊强   28号下午提交
377
  								this.tellNotice(res.data.Id,res.data.DocmentUrl)
bd028579   易尊强   2/28
378
  							}
290144e9   易尊强   第一次
379
  							uni.showToast({
bd028579   易尊强   2/28
380
381
  								icon: "success",
  								title: "发送成功"
290144e9   易尊强   第一次
382
  							})
bd028579   易尊强   2/28
383
  						} else {
290144e9   易尊强   第一次
384
  							uni.showToast({
bd028579   易尊强   2/28
385
386
  								icon: "error",
  								title: "发送失败,请重试"
290144e9   易尊强   第一次
387
388
389
390
391
  							})
  						}
  					})
  				}
  				console.log(this.city_ids5)
bd028579   易尊强   2/28
392
393
394
  
  			},
  			// 进行通知
5624065a   易尊强   28号下午
395
  			tellNotice(id,url){		
5bbfac44   易尊强   28号下午提交
396
  				console.log("进入通知")
bd028579   易尊强   2/28
397
398
399
400
401
  				request({
  					url:'/api/extend/demo/SendMessageByApp',
  					method:'post',
  					data:{
  						title:'公文消息',
5bbfac44   易尊强   28号下午提交
402
  						companys:this.city_ids5,
bd028579   易尊强   2/28
403
  						desc:this.noticeDesc,
5bbfac44   易尊强   28号下午提交
404
405
406
  						fangshi:'通知',
  						reid:id,
  						link:url
bd028579   易尊强   2/28
407
  					}
044301aa   “wangming”   1
408
409
  				}).then(res => {
  					console.log('通知结果', res)
bd028579   易尊强   2/28
410
  				})
290144e9   易尊强   第一次
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
  			},
  			getCityNames(ids) {
  				if (!ids) return;
  				if (ids.length == 0) {
  					return '';
  				}
  				let city_name = [];
  				this.items.map(function(item, index) {
  					item.children.map(function(city, ind) {
  						ids.map(function(id, i) {
  							if (id == city.id) {
  								city_name.push(city.text);
  							}
  						})
  					})
  				})
  				return city_name.join(',');
5bbfac44   易尊强   28号下午提交
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
  			},
  			// 获取当前用户的公文
  			getFileList() {
  				let userInfo = uni.getStorageSync('user')
  				request({
  					url: '/api/Extend/basedocumenthandle/GetListByCurrentUser',
  					method: 'get',
  					data: {}
  				}).then(res => {
  					console.log(res)
  					if (res.code === 200) {
  						this.fileList = res.data.list
  						if (this.fileList.length > 0) {
  							this.isNull = true
  						}
  					}
  				})
  			},
  			download(it) {
  				uni.downloadFile({
  						url: this.baseUrl + it,//下载地址接口返回
  						success: (data) => {
  							if (data.statusCode === 200) {
  								//文件保存到本地
  								uni.saveFile({
  									tempFilePath: data.tempFilePath, //临时路径
  									success: function(res) {
  										uni.showToast({
  											icon: 'none',
  											mask: true,
  											title: '文件已保存:' + res.savedFilePath, //保存路径
  											duration: 3000,
  										});
  										setTimeout(() => {
  											//打开文档查看
  											uni.openDocument({
  												filePath: res.savedFilePath,
  												success: function(res) {
  													// console.log('打开文档成功');
  												}
  											});
  										}, 3000)
  									}
  								});
  							}
  						},
  						fail: (err) => {
  							that.loadelshow = false
  							console.log(err);
  							uni.showToast({
  								icon: 'none',
  								mask: true,
  								title: '失败请重新下载',
  							});
  						},
  				});
  			},
290144e9   易尊强   第一次
485
  		},
290144e9   易尊强   第一次
486
487
488
489
490
491
  	}
  </script>
  
  <style scoped lang="scss">
  	@import 'official.scss';
  </style>