Blame view

pages/recommend/postRecommend/postRecommend.vue 9.89 KB
290144e9   易尊强   第一次
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  <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="baseForm" :modelValue="baseFormData" :rules="rules">
  				<view class="example-body">
  					<uni-file-picker limit="1" @select="select" title="头像"></uni-file-picker>
  				</view>
  				<uni-forms-item label="姓名" required name="name" style="margin-top: 10rpx;">
  					<uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
  				</uni-forms-item>
  				<uni-forms-item label="年龄" required name="age">
  					<uni-easyinput v-model="baseFormData.age" placeholder="请输入年龄" />
  				</uni-forms-item>
  				<uni-forms-item label="性别" required>
  					<uni-data-checkbox v-model="baseFormData.sex" :localdata="sexs" @change="change" />
  				</uni-forms-item>
  				<uni-forms-item label="政治面貌" required name="policy">
  					<uni-easyinput v-model="baseFormData.policy" placeholder="请输入政治面貌" />
  				</uni-forms-item>
  				<uni-forms-item label="民族" required name="nation">
  					<uni-easyinput v-model="baseFormData.nation" placeholder="请输入民族" />
  				</uni-forms-item>
  				<uni-forms-item label="电话号码" required name="phone">
  					<uni-easyinput v-model="baseFormData.phone" placeholder="请输入电话号码" />
  				</uni-forms-item>
  				<uni-forms-item label="学历" required name="education">
  					<uni-easyinput v-model="baseFormData.education" placeholder="请输入学历" />
  				</uni-forms-item>
  				<uni-forms-item label="毕业院校" required name="school">
  					<uni-easyinput v-model="baseFormData.school" placeholder="请输入毕业院校" />
  				</uni-forms-item>
  				<uni-forms-item label="工作经历">
  					<uni-easyinput type="textarea" v-model="baseFormData.introduction" placeholder="请输入工作经历" />
  				</uni-forms-item>
  			</uni-forms>
bd028579   易尊强   2/28
42
43
44
45
46
47
48
49
50
  			<view class="isNotice">
  				<view class="lef" style="margin-left: 30rpx;">
  					已选择<span>{{companysId.length}}</span>家企业
  				</view>
  				<view class="rig">
  					<button type="primary" @click="toTellInfo()" style="border-radius: 40rpx;">通知信息填写</button>
  				</view>
  			</view>
  		</view>		
290144e9   易尊强   第一次
51
52
53
54
55
56
57
58
59
60
61
  		<!-- 提交 -->
  		<view v-if="have" class="submit-btn" @click="postInfo('baseForm')">
  			<text>发布</text>
  		</view>
  		<view v-else class="submit-btn" @click="updateInfo('baseForm')">
  			<text>保存</text>
  		</view>
  	</view>
  </template>
  
  <script>
5bbfac44   易尊强   28号下午提交
62
  	import request from '@/utils/request.js'
290144e9   易尊强   第一次
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  	export default {
  		data() {
  			return {
  				// 基础表单数据
  				baseFormData: {
  					name: '',
  					age: '',
  					introduction: '',
  					sex: 2,
  					// 政治面貌
  					policy: '',
  					phone: '',
  					education: '',
  					school: '',
  					nation: '',
  					datetimesingle: 1627529992399,
  				},
  				sexValue: '',
  				filePath: [],
  				uploadPath: [],
bd028579   易尊强   2/28
83
84
85
  				// 需要通知的公司的id
  				companysId: [],
  				tellInfo:[],
290144e9   易尊强   第一次
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
  				// 单选数据源
  				sexs: [{
  					text: '男',
  					value: 0
  				}, {
  					text: '女',
  					value: 1
  				}, {
  					text: '保密',
  					value: 2
  				}],
  				// 校验规则
  				rules: {
  					name: {
  						rules: [{
  							required: true,
  							errorMessage: '姓名不能为空'
  						}]
  					},
  					age: {
  						rules: [{
  							required: true,
  							errorMessage: '年龄不能为空'
  						}, {
  							format: 'number',
  							errorMessage: '年龄只能输入数字'
  						}]
  					},
  					phone: {
  						rules: [{
  							required: true,
  							errorMessage: '电话号码不能为空'
  						}]
  					},
  					policy: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  					education: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  					school: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  					nation: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  				},
  				have:false,
  				isId:''
  			}
  		},
bd028579   易尊强   2/28
149
150
151
152
  		onUnload() {
  			uni.$off('idInfo')
  			uni.$off('tellInfo')
  		},
290144e9   易尊强   第一次
153
154
155
  		onLoad(options) {
  			console.log("options",options)
  			// console.log("options",JSON.stringify(options).data)
bd028579   易尊强   2/28
156
157
158
159
160
161
162
163
164
165
  			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
  			})
290144e9   易尊强   第一次
166
167
168
169
170
171
172
173
174
175
  			if(JSON.stringify(options) == "{}"){
  				this.have = true
  				console.log(this.have)
  			}else{
  				this.isId = JSON.parse(options.data)
  				console.log("Id",this.isId)
  				this.getDetail(this.isId)
  			}
  		},
  		methods: {
e6b161ae   易尊强   2/23
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
  			// 获取用户信息
  			getUser() {
  				if (uni.getStorageSync('user')) {
  					let userCode = uni.getStorageSync("user")
  					console.log(userCode)
  					if(userCode.userInfo.userId === 'admin'){
  						this.isAdmin = true
  					}
  					console.log('用户已登录!')
  				} 
  				else {
  					uni.showToast({
  						title: '请登录',
  						icon: 'none',
  						duration:1500
  					})
  					setTimeout(() => {
  						uni.reLaunch({
  							url: '/pages/login/index'
  						})
  					})
  				}
  			},
bd028579   易尊强   2/28
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
  			// 跳转到选择通知企业页面
  			toTellInfo() {
  				uni.navigateTo({
  					url: '/pages/tellInfo/tellInfo'
  				})
  			},
  			// 进行通知
  			tellNotice(id){
  				// 进行通知
  				request({
  					url:'/api/extend/demo/SendMessageByApp',
  					method:'post',
  					data:{
  						title:this.tellInfo[0],
  						companys:this.companysId,
  						desc:this.tellInfo[1],
  						reid:id,
5bbfac44   易尊强   28号下午提交
216
  						link:'/pages/recommend/recommendInfo/recommendInfo',
bd028579   易尊强   2/28
217
218
219
220
221
222
  						fangshi:'通知'
  					}
  				}).then(res=>{
  					console.log('通知结果',res)
  				})
  			},
290144e9   易尊强   第一次
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
  			// 获取上传状态
  			select(e) {
  				console.log('选择文件:', e)
  				this.filePath = e.tempFilePaths
  			},
  			change(e) {
  				console.log("e:", e.detail.value);
  				console.log("sex:", this.baseFormData.sex)
  			},
  			// 发布信息
  			postInfo(ref) {
  				let that = this
  				this.uploadPath = []
  				if (this.filePath.length == 0) {
  					uni.showToast({
  						icon: "error",
  						title: "请上传头像"
  					})
  					return
  				}
  				this.$refs[ref].validate().then(res => {
  					console.log(res)
  					this.sexValue = this.sexs[this.baseFormData.sex].text
  					console.log('xinbie', this.sexValue)
  					uni.uploadFile({
  						url: "http://deyanggaoxin.fengshiyun.com/api/file/Uploader/1",
  						filePath: this.filePath[0],
  						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)
  							// if (res.code == 200) {
  								
  							// }
  							console.log('进入')
  							let info = {
  								name: that.baseFormData.name,
  								headImg: that.uploadPath,
  								gender: that.sexValue,
  								age: that.baseFormData.age,
  								nation: that.baseFormData.nation,
  								phoneNumber: that.baseFormData.phone,
  								education:that.baseFormData.education,
  								graduationInstitution:that.baseFormData.school,
  								workExperience:that.baseFormData.introduction,
  								politicalOutlook:that.baseFormData.policy
  							}
  							that.API.postRecommend(info).then(res=>{
  								console.log("成功上传",res)
  								if(res.code === 200){
bd028579   易尊强   2/28
276
277
278
  									if(this.companysId.length > 0){
  										this.tellNotice(res.data.Id)
  									}
290144e9   易尊强   第一次
279
280
281
  									uni.showToast({
  										icon:"success",
  										title:"发布成功!"
e6b161ae   易尊强   2/23
282
283
284
285
  									}).then(()=>{
  										uni.navigateTo({
  											url:'/pages/recommend/recommend'
  										})
290144e9   易尊强   第一次
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
  									})
  								}
  							})
  						}
  					})
  				})
  			},
  			
  			// 修改信息
  			updateInfo(ref) {
  				let that = this
  				this.uploadPath = []
  				if (this.filePath.length == 0) {
  					uni.showToast({
  						icon: "error",
  						title: "请上传头像"
  					})
  					return
  				}
  				this.$refs[ref].validate().then(res => {
  					console.log(res)
  					this.sexValue = this.sexs[this.baseFormData.sex].text
  					console.log('xinbie', this.sexValue)
  					uni.uploadFile({
  						url: "http://deyanggaoxin.fengshiyun.com/api/file/Uploader/1",
  						filePath: this.filePath[0],
  						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)
  							// if (res.code == 200) {
  								
  							// }
  							console.log('进入')
  							let info = {
  								name: that.baseFormData.name,
  								headImg: that.uploadPath,
  								gender: that.sexValue,
  								age: that.baseFormData.age,
  								nation: that.baseFormData.nation,
  								phoneNumber: that.baseFormData.phone,
  								education:that.baseFormData.education,
  								graduationInstitution:that.baseFormData.school,
  								workExperience:that.baseFormData.introduction,
  								politicalOutlook:that.baseFormData.policy,
  								id:that.isId
  							}
  							that.API.updateRecommendInfo(info).then(res=>{
  								console.log("修改成功",res)
  								if(res.code === 200){
  									uni.showToast({
  										icon:"success",
  										title:"修改成功!"
  									})
  								}
  							})
  						}
  					})
  				})
  			},
  			
  			//获取详细信息
  			 getDetail(id){
  				 let that = this
  				 this.API.getRecommendInfo(id).then(res=>{
  					 console.log(res)
  					 if(res.code === 200){
  						 let detailData = res.data
  						 that.baseFormData.name = detailData.name
  						 that.baseFormData.age = detailData.age
  						 that.baseFormData.nation = detailData.nation
  						 that.baseFormData.phone = detailData.phoneNumber
  						 that.baseFormData.education = detailData.education
  						 that.baseFormData.school = detailData.graduationInstitution
  						 that.baseFormData.introduction = detailData.workExperience
  						 that.baseFormData.policy = detailData.politicalOutlook
  					 }
  				 })
  			 },
  		}
  	}
  </script>
  
  <style lang="scss" scoped>
  	@import 'Feedback.scss'
  </style>