Blame view

pages/postPolicy/postPolicy.vue 10.7 KB
290144e9   易尊强   第一次
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  <template>
  	<view class="page">
  		<!-- 反馈内容 -->
  		<view class="feedback-data">
  			<view class="titleall-box">
  				<view class="titleall-left">
  					<view class="titleall-left-line"></view>填写政策法规信息
  				</view>
  			</view>
  			<uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData" style="width: 96%;margin: 0 auto;">
  				<uni-forms-item label="标题" required name="title">
  					<uni-easyinput v-model="valiFormData.title" placeholder="请输入" />
  				</uni-forms-item>
  				<uni-forms-item label="摘要" required name="subTitle">
  					<uni-easyinput v-model="valiFormData.subTitle" placeholder="请输入" />
  				</uni-forms-item>
6c679290   易尊强   3/6a上午
17
  				<uni-forms-item label="详细内容">
290144e9   易尊强   第一次
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  					<uni-easyinput type="textarea" v-model="valiFormData.bodyContent" placeholder="请输入" />
  				</uni-forms-item>
  			</uni-forms>
  			<view class="example-body">
  				<uni-file-picker limit="9" @select="select" title="图片"></uni-file-picker>
  			</view>
  			<!-- 选择反馈类型 -->
  			<view class="feedback-type">
  				<view class="feedback-type-left">隶属类别</view>
  				<view class="feedback-type-right">
  					<view class="title">
  						<text>{{TypeArray[TypeIndex]}}</text>
  					</view>
  					<view class="picker">
  						<picker @change="FeedbackTypeCh" :value="TypeIndex" :range="TypeArray">
9b1c150c   “wangming”   1
33
  							<view class="uni-input">{{TypeArray[TypeIndex]}}</view>
290144e9   易尊强   第一次
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  						</picker>
  					</view>
  					<view class="more">
  						<image src="../../static/down1.png"></image>
  					</view>
  				</view>
  			</view>
  			<!-- 选择级别 -->
  			<view class="feedback-type">
  				<view class="feedback-type-left">级别类别</view>
  				<view class="feedback-type-right">
  					<view class="title">
  						<text>{{SecTypeArray[SecTypeIndex]}}</text>
  					</view>
  					<view class="picker">
  						<picker @change="FeedbackSecTypeCh" :value="SecTypeIndex" :range="SecTypeArray">
9b1c150c   “wangming”   1
50
  							<view class="uni-input">{{SecTypeArray[SecTypeIndex]}}</view>
290144e9   易尊强   第一次
51
52
53
54
55
56
57
  						</picker>
  					</view>
  					<view class="more">
  						<image src="../../static/down1.png"></image>
  					</view>
  				</view>
  			</view>
9b1c150c   “wangming”   1
58
59
  			<view class="isNotice"
  				style="display: flex; align-items: center; margin-top: 20rpx;justify-content: space-between;">
bd028579   易尊强   2/28
60
61
62
  				<view class="lef" style="margin-left: 30rpx;">
  					已选择<span>{{companysId.length}}</span>家企业
  				</view>
6c679290   易尊强   3/6a上午
63
64
65
66
67
68
69
  				<view class="rig" @click="toTellInfo()" style="display: flex;align-items: center;">
  					<text>选择企业</text>
  					<view class="more-content">
  						<view class="more-content-img">
  							<image src="../../static/right2.png"></image>
  						</view>
  					</view>
bd028579   易尊强   2/28
70
71
  				</view>
  			</view>
290144e9   易尊强   第一次
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  		</view>
  
  		<!-- 提交 -->
  		<view v-if="have" class="submit-btn" @click="submitContent('valiForm')">
  			<text>发布</text>
  		</view>
  		<view v-else class="submit-btn" @click="updateEvent('valiForm')">
  			<text>保存</text>
  		</view>
  	</view>
  </template>
  
  <script>
  	import {
  		data
  	} from '../../uview-ui/libs/mixin/mixin';
  	import request from '@/utils/request.js'
9b1c150c   “wangming”   1
89
  	import utils from '../../service/utils';
290144e9   易尊强   第一次
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  	export default {
  		data() {
  			return {
  				userCode: {},
  				// 选择图片路径
  				filePath: [],
  				uploadPath: [],
  				type: "",
  				lastModifyUserId: '',
  				// 校验表单数据
  				valiFormData: {
  					title: '',
  					bodyContent: '',
  					subTitle: '',
  				},
bd028579   易尊强   2/28
105
  				// 需要通知的公司的id
9b1c150c   “wangming”   1
106
  				companysId: [],
290144e9   易尊强   第一次
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  				creater: '',
  				rules: {
  					title: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  					subTitle: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  				},
9b1c150c   “wangming”   1
122
  				baseUrl: "https://www.dygxq-es.cn",
290144e9   易尊强   第一次
123
  				// 判断是否传了id
9b1c150c   “wangming”   1
124
125
126
127
128
  				isId: '',
  				have: false,
  				detailData: [],
  				categoryId: '360234017372505349',
  				TypeArray: ['人才', '企业', '金融', '法律法规', '其他'],
290144e9   易尊强   第一次
129
130
131
  				SecTypeArray: ['国家级', '省级', '市级', '本地'],
  				TypeIndex: 0,
  				SecTypeIndex: 0,
9b1c150c   “wangming”   1
132
133
  				tellInfo: [],
  			}
290144e9   易尊强   第一次
134
135
136
137
  		},
  		// onShow() {
  		// 	this.getType()
  		// },
bd028579   易尊强   2/28
138
139
140
141
  		onUnload() {
  			uni.$off('idInfo')
  			uni.$off('tellInfo')
  		},
9b1c150c   “wangming”   1
142
143
144
145
146
147
  		onShow() {
  			let data = uni.getStorageSync('idInfo')
  			// console.log('公司ID数据',uni.getStorageSync('idInfo'))
  			console.log('datain公司ID数据', data)
  			this.companysId = data
  		},
290144e9   易尊强   第一次
148
  		onLoad(options) {
9b1c150c   “wangming”   1
149
150
151
152
153
154
155
156
157
158
159
160
  			console.log("options", options)
  			// uni.$on('idInfo', res => {
  			// 	console.log("选择公司页面返回的公司ID", res)
  			// 	if (res.length > 0)
  			// 		this.companysId = res
  			// })
  			uni.$on('tellInfo', res => {
  				console.log("tell信息", res)
  				if (res.length > 0)
  					this.tellInfo = res
  			})
  			if (JSON.stringify(options) == "{}") {
290144e9   易尊强   第一次
161
  				this.have = true
9b1c150c   “wangming”   1
162
  			} else {
290144e9   易尊强   第一次
163
  				this.isId = JSON.parse(options.data)
9b1c150c   “wangming”   1
164
  				console.log("Id", this.isId)
290144e9   易尊强   第一次
165
166
167
168
169
170
171
172
173
174
175
176
  				this.getConDetail(this.isId)
  			}
  			this.getUser()
  			let user = uni.getStorageSync('user')
  			this.lastModifyUserId = user.userInfo.userId
  
  		},
  		methods: {
  			/**
  			 * 反馈类型
  			 * @param {Object} val
  			 */
9b1c150c   “wangming”   1
177
  			FeedbackTypeCh(val) {
290144e9   易尊强   第一次
178
179
180
181
182
183
184
  				console.log(val);
  				this.TypeIndex = val.detail.value;
  			},
  			/**
  			 * 反馈类型
  			 * @param {Object} val
  			 */
9b1c150c   “wangming”   1
185
  			FeedbackSecTypeCh(val) {
290144e9   易尊强   第一次
186
187
188
189
190
191
192
193
194
195
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
  				console.log(val);
  				this.SecTypeIndex = val.detail.value;
  			},
  			// 获取上传状态
  			select(e) {
  				console.log('选择文件:', e)
  				this.filePath = e.tempFilePaths
  			},
  			// 获取用户信息
  			getUser() {
  				if (uni.getStorageSync('user')) {
  					this.userCode = uni.getStorageSync('user').userInfo
  					// this.userInfo = this.userCode.userAccount
  					// this.userInfo = '123456'
  					console.log('用户已登录!', this.userCode)
  				} else {
  					uni.showToast({
  						title: '请登录',
  						icon: 'none'
  					})
  					setTimeout(() => {
  						uni.reLaunch({
  							url: '/pages/login/index'
  						})
  					})
  				}
  			},
  			// 提交内容
  			submitContent(ref) {
  				let that = this
  				this.$refs[ref].validate().then(res => {
  					console.log('success', res);
  					uni.showToast({
  						title: `校验通过`
  					})
  
  					this.uploadPath = []
  					for (let i = 0; i < this.filePath.length; i++) {
  						uni.uploadFile({
9b1c150c   “wangming”   1
225
  							url: "https://www.dygxq-es.cn/api/file/Uploader/1",
290144e9   易尊强   第一次
226
227
228
229
230
231
232
233
234
235
236
  							filePath: this.filePath[i],
  							name: 'file',
  							success: (res) => {
  								console.log(JSON.parse(res.data))
  								let data = JSON.parse(res.data).data
  								console.log(data)
  								this.uploadPath.push(data)
  							}
  						})
  					}
  					console.log('需要', this.uploadPath)
9b1c150c   “wangming”   1
237
  					setTimeout(function() {
290144e9   易尊强   第一次
238
  						that.postAll()
9b1c150c   “wangming”   1
239
  					}, 1500)
290144e9   易尊强   第一次
240
241
242
243
244
245
246
247
248
249
250
251
252
  				})
  			},
  
  			// 上传所有
  			postAll() {
  				console.log("进入POST")
  				let that = this
  				let isType = this.TypeArray[this.TypeIndex]
  				let isType2 = this.SecTypeArray[this.SecTypeIndex]
  				if (that.uploadPath) {
  					console.log('jinru')
  					// console.log(uni.getStorageSync('token'))
  					var info = {
9b1c150c   “wangming”   1
253
254
255
256
257
258
259
260
  						title: that.valiFormData.title,
  						bodyContent: that.valiFormData.bodyContent,
  						categoryId: '396213073565713669',
  						creatorUserId: that.userCode.userId,
  						subTitle: that.valiFormData.subTitle,
  						isType: isType,
  						isType2: isType2,
  						imgUrl: that.uploadPath,
290144e9   易尊强   第一次
261
262
  					}
  					console.log(info)
9b1c150c   “wangming”   1
263
264
265
  					this.API.postPolicy(info).then(res => {
  						console.log("1111", res);
  						console.log("res", res);
290144e9   易尊强   第一次
266
267
  						if (res.code == 200) {
  							console.log("上传后的值", res)
9b1c150c   “wangming”   1
268
  							if (this.companysId.length > 0) {
bd028579   易尊强   2/28
269
270
  								this.tellNotice(res.data.Id)
  							}
290144e9   易尊强   第一次
271
272
273
  							uni.showToast({
  								icon: "success",
  								title: "发布成功!"
9b1c150c   “wangming”   1
274
  							}).then(() => {
290144e9   易尊强   第一次
275
  								uni.navigateTo({
9b1c150c   “wangming”   1
276
  									url: '/pages/policy/policy'
290144e9   易尊强   第一次
277
278
279
  								})
  							})
  						}
9b1c150c   “wangming”   1
280
  					}).catch((err) => {
290144e9   易尊强   第一次
281
282
  						console.log(err)
  					})
290144e9   易尊强   第一次
283
284
285
286
287
288
289
290
291
292
  				}
  			},
  			// /**
  			//  * 反馈类型
  			//  * @param {Object} 
  			//  */
  			// FeedbackTypeCh(val) {
  			// 	console.log(val);
  			// 	this.TypeIndex = val.detail.value;
  			// }
bd028579   易尊强   2/28
293
294
295
296
297
298
299
300
301
302
303
304
305
  			// 跳转到选择通知企业页面
  			// 跳转到选择通知企业页面
  			toTellInfo() {
  				uni.navigateTo({
  					url: '/pages/tellInfo/tellInfo'
  				})
  			},
  			toChooseCom() {
  				uni.navigateTo({
  					url: '/pages/chooseCom/chooseCom'
  				})
  			},
  			// 进行通知
9b1c150c   “wangming”   1
306
  			tellNotice(id) {
bd028579   易尊强   2/28
307
308
  				// 进行通知
  				request({
9b1c150c   “wangming”   1
309
310
311
312
313
314
315
316
317
318
  					url: '/api/extend/demo/SendMessageByApp',
  					method: 'post',
  					data: {
  						title: this.tellInfo[0],
  						companys: this.companysId,
  						desc: this.tellInfo[1],
  						reid: id,
  						link: '/pages/policyDetail/policyDetail',
  						fangshi: '通知',
  						type: '政策法规通知'
bd028579   易尊强   2/28
319
  					}
9b1c150c   “wangming”   1
320
321
  				}).then(res => {
  					console.log('通知结果', res)
bd028579   易尊强   2/28
322
323
  				})
  			},
290144e9   易尊强   第一次
324
  			// 获取信息
9b1c150c   “wangming”   1
325
  			getConDetail(id) {
290144e9   易尊强   第一次
326
327
328
  				let that = this
  				let currentId = id
  				console.log(currentId)
9b1c150c   “wangming”   1
329
  				that.API.getConstructDetail(currentId).then(res => {
290144e9   易尊强   第一次
330
331
332
333
334
335
336
337
338
339
  					console.log(res)
  					let createTime = utils.formatTime(res.data.creatorTime)
  					res.data.creatorTime = createTime
  					that.detailData = res.data
  					console.log(that.detailData)
  					this.valiFormData.title = that.detailData.tItle
  					this.valiFormData.subTitle = that.detailData.summary
  					this.valiFormData.bodyContent = that.detailData.content
  				})
  			},
9b1c150c   “wangming”   1
340
  
290144e9   易尊强   第一次
341
  			// 信息更新
9b1c150c   “wangming”   1
342
  			updateEvent(ref) {
290144e9   易尊强   第一次
343
344
345
346
347
348
  				let that = this
  				this.$refs[ref].validate().then(res => {
  					console.log('success', res);
  					uni.showToast({
  						title: `校验通过`
  					})
9b1c150c   “wangming”   1
349
  
290144e9   易尊强   第一次
350
351
352
  					this.uploadPath = []
  					for (let i = 0; i < this.filePath.length; i++) {
  						uni.uploadFile({
9b1c150c   “wangming”   1
353
  							url: "https://www.dygxq-es.cn/api/file/Uploader/1",
290144e9   易尊强   第一次
354
355
356
357
358
359
360
361
362
363
364
  							filePath: this.filePath[i],
  							name: 'file',
  							success: (res) => {
  								console.log(JSON.parse(res.data))
  								let data = JSON.parse(res.data).data
  								console.log(data)
  								this.uploadPath.push(data)
  							}
  						})
  					}
  					console.log('需要', this.uploadPath)
9b1c150c   “wangming”   1
365
  					setTimeout(function() {
290144e9   易尊强   第一次
366
  						that.updateData()
9b1c150c   “wangming”   1
367
  					}, 1500)
290144e9   易尊强   第一次
368
369
370
  				})
  			},
  			// 更新接口
9b1c150c   “wangming”   1
371
  			updateData() {
290144e9   易尊强   第一次
372
373
374
375
376
  				let that = this
  				if (that.uploadPath) {
  					console.log('jinru')
  					// console.log(uni.getStorageSync('token'))
  					var info = {
9b1c150c   “wangming”   1
377
378
379
380
381
382
  						tItle: that.valiFormData.title,
  						content: that.valiFormData.bodyContent,
  						creatorUserId: that.userCode.userId,
  						summary: that.valiFormData.subTitle,
  						image: that.uploadPath,
  						id: this.isId
290144e9   易尊强   第一次
383
384
  					}
  					console.log(info)
9b1c150c   “wangming”   1
385
386
387
  					this.API.modifyCon(info).then(res => {
  						console.log("1111", res);
  						console.log("res", res);
290144e9   易尊强   第一次
388
389
390
391
392
393
394
  						if (res.code == 200) {
  							console.log("上传后的值", res)
  							uni.showToast({
  								icon: "success",
  								title: "更新成功!"
  							})
  						}
9b1c150c   “wangming”   1
395
  					}).catch((err) => {
290144e9   易尊强   第一次
396
397
  						console.log(err)
  					})
9b1c150c   “wangming”   1
398
  				}
290144e9   易尊强   第一次
399
400
  			}
  		}
290144e9   易尊强   第一次
401
402
403
404
405
  	}
  </script>
  
  <style scoped lang="scss">
  	@import 'Feedback.scss';
9b1c150c   “wangming”   1
406
407
  
  	.more-content {
6c679290   易尊强   3/6a上午
408
409
  		display: flex;
  		align-items: center;
9b1c150c   “wangming”   1
410
411
  
  		image {
6c679290   易尊强   3/6a上午
412
413
414
415
  			width: 100rpx;
  			height: 100rpx;
  			border-radius: 100%;
  		}
9b1c150c   “wangming”   1
416
  
6c679290   易尊强   3/6a上午
417
418
419
420
421
422
423
  		.more-content-img {
  			image {
  				width: 24rpx;
  				height: 24rpx;
  			}
  		}
  	}
290144e9   易尊强   第一次
424
  </style>