添加页面
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<!--
|
||||
* @Date: 2024-10-08 14:29:36
|
||||
* @LastEditors: shirlwang
|
||||
* @LastEditTime: 2025-11-04 13:53:56
|
||||
* @LastEditTime: 2025-11-04 16:30:05
|
||||
-->
|
||||
<template>
|
||||
<view class="container">
|
||||
<scroll-view scroll-y="true" >
|
||||
<scroll-view scroll-y="true" :style="{height: edit?'calc(100vh - 380rpx)':'calc(100vh - 194rpx)'}">
|
||||
<view class="inner">
|
||||
<view class="part-title" style="display: flex;justify-content: space-between;">求职需求信息
|
||||
<view v-if="!edit&&formData.id&&formData.currentStatus!=3" class="btn"
|
||||
@@ -160,6 +160,8 @@
|
||||
<!-- 工种选择器弹窗 -->
|
||||
|
||||
|
||||
<choose-person ref="personChooser" @confirm="personNameConfirm" />
|
||||
<PlacePicker ref="placePicker" @selected="handleSelected" />
|
||||
</scroll-view>
|
||||
<view class="button-area" v-if="edit">
|
||||
<view class="btn" @click="cancelPage">取消</view>
|
||||
@@ -171,26 +173,24 @@
|
||||
<script>
|
||||
import {
|
||||
getPersonBase
|
||||
} from "@/packageRc/api/personinfo/index";
|
||||
} from "@/apiRc/person";
|
||||
import {
|
||||
addPersonDemand,
|
||||
updatePersonDemand,
|
||||
getPersonDemand
|
||||
} from "@/packageRc/api/needs/personDemand";
|
||||
} from "@/apiRc/needs/personDemand";
|
||||
import {
|
||||
listJobType
|
||||
} from "@/packageRc/api/jobType/index";
|
||||
import ImageUpload from './ImageUpload'
|
||||
import ChoosePerson from './choosePerson';
|
||||
} from "@/apiRc/jobType/index";
|
||||
import ImageUpload from '/packageRc/components/ImageUpload'
|
||||
import ChoosePerson from '/packageRc/pages/needs/components/choosePerson';
|
||||
import PlacePicker from "/packageRc/components/placePicker";
|
||||
|
||||
//import uPopup from 'uview-ui/components/u-popup/u-popup.vue'
|
||||
export default {
|
||||
components: {
|
||||
ChoosePerson,
|
||||
ImageUpload,
|
||||
PlacePicker,
|
||||
// uPopup
|
||||
},
|
||||
props: {
|
||||
needId: {
|
||||
@@ -209,8 +209,6 @@
|
||||
dates: {},
|
||||
currentCommunityId: '',
|
||||
showPickerPicker: false,
|
||||
canChoosePerson: true,
|
||||
canChoosePerson: true,
|
||||
formData: {
|
||||
demandType:"1",
|
||||
personName: '',
|
||||
@@ -228,7 +226,6 @@
|
||||
jobDescription: '',
|
||||
// fileUrl: []
|
||||
},
|
||||
bfnrzd:[],
|
||||
rules: {
|
||||
personName: [{
|
||||
required: true,
|
||||
@@ -253,11 +250,11 @@
|
||||
message: '请选择最低薪酬',
|
||||
trigger: ['blur', 'change'],
|
||||
}, ],
|
||||
jobDescription: [{
|
||||
required: true,
|
||||
message: '请填写求职说明',
|
||||
trigger: ['blur', 'change'],
|
||||
}, ]
|
||||
jobDescription: [{
|
||||
required: true,
|
||||
message: '请填写求职说明',
|
||||
trigger: ['blur', 'change'],
|
||||
}, ]
|
||||
// employmentType: [{
|
||||
// required: true,
|
||||
// message: '请选择用工形式',
|
||||
@@ -300,14 +297,10 @@
|
||||
workTypeIndexes: [0, 0, 0],
|
||||
}
|
||||
},
|
||||
// 移除uView表单验证相关代码
|
||||
onReady() {
|
||||
this.$refs.uForm.setRules(this.rules)
|
||||
},
|
||||
created() {
|
||||
this.workTypeRemoteMethod('');
|
||||
console.log('qcjy_fwnr' );
|
||||
this.$getDict('qcjy_fwnr').then(res => {
|
||||
this.bfnrzd = res.data;
|
||||
});
|
||||
this.setName()
|
||||
this.loading = true;
|
||||
let arr = [{
|
||||
key: 'qcjy_gznx',
|
||||
@@ -338,7 +331,7 @@
|
||||
prop: 'employmentWillingness'
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
// 使用 Promise.all 确保所有字典数据加载完成
|
||||
Promise.all(arr.map(ele => this.getDicts(ele.key)))
|
||||
.then(responses => {
|
||||
@@ -356,14 +349,18 @@
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
this.workTypeRemoteMethod('');
|
||||
},
|
||||
methods: {
|
||||
// 获取字典数据
|
||||
getDicts(dictType) {
|
||||
return this.$getDict(dictType)
|
||||
// .then(res => {
|
||||
// this.dict[dictType] = res.data;
|
||||
// });
|
||||
return new Promise((resolve, reject) => {
|
||||
// 这里应该调用实际的API,暂时返回空数组
|
||||
// 如果需要真实的API调用,请替换下面的代码
|
||||
setTimeout(() => {
|
||||
resolve({ data: [] });
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
|
||||
cancelPage() {
|
||||
@@ -380,15 +377,12 @@
|
||||
}
|
||||
},
|
||||
setName(){
|
||||
// 只有在name有值时才设置人员信息,避免覆盖已有数据
|
||||
if(this.name) {
|
||||
this.formData.personName = this.name
|
||||
this.formData.personId = this.needId
|
||||
this.formData.userId = this.needId
|
||||
}
|
||||
this.formData.personName = this.name
|
||||
this.formData.personId = this.needId
|
||||
this.formData.userId = this.needId
|
||||
},
|
||||
personNameConfirm(event) {
|
||||
// this.formData.personName = event.name
|
||||
this.formData.personName = event.name
|
||||
this.formData.personId = event.id
|
||||
this.formData.userId = event.userId
|
||||
|
||||
@@ -460,7 +454,7 @@
|
||||
cancelPicker(type) {
|
||||
this.show[type] = false
|
||||
},
|
||||
getCityOptis(data) {
|
||||
getCityOptions(data) {
|
||||
if (data && data[0] && data[0].children) {
|
||||
return [data].concat(this.getCityOptions(data[0].children))
|
||||
} else {
|
||||
@@ -493,7 +487,7 @@
|
||||
if (this.edit) {
|
||||
if(type === 'workTypeTree') {
|
||||
if (!this.workTypeTreeColumns[0] || !this.workTypeTreeColumns[0].length) {
|
||||
uni.showToast({title: '工种数据未加载,请稍后重试'});
|
||||
uni.showToast({title: '工种数据未加载,请稍后重试', icon: 'none'});
|
||||
return;
|
||||
}
|
||||
// 弹窗打开时,初始化临时columns和index
|
||||
@@ -519,35 +513,21 @@
|
||||
})
|
||||
},
|
||||
async saveInfo() {
|
||||
this.setName()
|
||||
uni.showLoading();
|
||||
try {
|
||||
console.log("this.formData.personName",this.formData.personName)
|
||||
// 先检查求职说明是否为空,如果为空直接提示
|
||||
if (!this.formData.jobDescription || this.formData.jobDescription.trim() === '') {
|
||||
uni.showToast({ title: '请填写求职说明!', icon: 'none' });
|
||||
uni.showToast({title: '请填写求职说明!', icon: 'none'});
|
||||
return;
|
||||
}
|
||||
|
||||
// 简单的表单验证
|
||||
|
||||
// 验证表单
|
||||
console.log(this.formData)
|
||||
if (!this.formData.personName) {
|
||||
uni.showToast({ title: '请填写姓名!', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!this.formData.jobWorkType) {
|
||||
uni.showToast({ title: '请选择求职工种!', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!this.formData.minRecruitmentSalary) {
|
||||
uni.showToast({ title: '请填写最低薪酬!', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!this.formData.highRecruitmentSalary) {
|
||||
uni.showToast({ title: '请填写最高薪酬!', icon: 'none' });
|
||||
return;
|
||||
const isValid = await this.$refs.uForm.validate();
|
||||
if (!isValid) {
|
||||
throw new Error('表单验证失败');
|
||||
}
|
||||
// 显示全局加载
|
||||
uni.showLoading({ title: '加载中...' });
|
||||
this.formData.demandType = 1;
|
||||
// this.formData.userId = this.formData.personId
|
||||
// 根据 formData 是否有 id 来决定是更新还是新增
|
||||
@@ -562,25 +542,25 @@
|
||||
}
|
||||
// 检查响应码是否为200
|
||||
if (response.code === 200) {
|
||||
uni.showToast({ title: successMessage });
|
||||
uni.showToast({title: successMessage, icon: 'none'});
|
||||
// 如果是编辑模式,关闭编辑状态;否则返回上一页
|
||||
if (this.formData.id) {
|
||||
this.edit = false;
|
||||
} else {
|
||||
// 延迟1秒后返回
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if(error && error.length){
|
||||
uni.showToast({ title: '请填写完整信息!', icon: 'none' });
|
||||
} else {
|
||||
uni.showToast({ title: '系统错误,请联系管理员!', icon: 'none' });
|
||||
if(error.length){
|
||||
uni.showToast({title: '请填写完整信息!', icon: 'none'});
|
||||
}else{
|
||||
uni.showToast({title: '系统错误,请联系管理员!', icon: 'none'});
|
||||
}
|
||||
}
|
||||
finally {
|
||||
// uni.showToast({title: '请检查必填项填写', icon: 'none'});
|
||||
|
||||
} finally {
|
||||
// 确保加载页总是会被隐藏
|
||||
uni.hideLoading();
|
||||
}
|
||||
@@ -611,18 +591,18 @@
|
||||
this.workTypeColumns = [[], [], []];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 第一级
|
||||
const level1 = treeData.filter(item => item.level === "1");
|
||||
// 第二级
|
||||
const level2 = treeData.filter(item => item.level === "2");
|
||||
// 第三级
|
||||
const level3 = treeData.filter(item => item.level === "3");
|
||||
|
||||
|
||||
// 构建级联数据
|
||||
const columns = [];
|
||||
columns[0] = level1;
|
||||
|
||||
|
||||
// 根据第一级选择,过滤第二级
|
||||
if (level1.length > 0) {
|
||||
const firstLevelId = level1[0].id;
|
||||
@@ -630,7 +610,7 @@
|
||||
} else {
|
||||
columns[1] = [];
|
||||
}
|
||||
|
||||
|
||||
// 根据第二级选择,过滤第三级
|
||||
if (columns[1].length > 0) {
|
||||
const secondLevelId = columns[1][0].id;
|
||||
@@ -638,23 +618,23 @@
|
||||
} else {
|
||||
columns[2] = [];
|
||||
}
|
||||
|
||||
|
||||
this.workTypeColumns = columns;
|
||||
console.log('级联数据构建完成:', this.workTypeColumns);
|
||||
},
|
||||
|
||||
|
||||
// 级联选择器列变化事件
|
||||
onWorkTypeColumnChange(e) {
|
||||
const { column, value } = e.detail;
|
||||
const newIndexes = [...this.workTypeIndexes];
|
||||
newIndexes[column] = value;
|
||||
|
||||
|
||||
// 重置后续列的数据
|
||||
if (column === 0) {
|
||||
// 第一列变化,重置第二、三列
|
||||
const selectedLevel1 = this.workTypeColumns[0][value];
|
||||
if (selectedLevel1) {
|
||||
const level2 = this.jobTypeList.filter(item =>
|
||||
const level2 = this.jobTypeList.filter(item =>
|
||||
item.level === "2" && item.parentId === selectedLevel1.id
|
||||
);
|
||||
this.workTypeColumns[1] = level2;
|
||||
@@ -666,24 +646,24 @@
|
||||
// 第二列变化,重置第三列
|
||||
const selectedLevel2 = this.workTypeColumns[1][value];
|
||||
if (selectedLevel2) {
|
||||
const level3 = this.jobTypeList.filter(item =>
|
||||
const level3 = this.jobTypeList.filter(item =>
|
||||
item.level === "3" && item.parentId === selectedLevel2.id
|
||||
);
|
||||
this.workTypeColumns[2] = level3;
|
||||
newIndexes[2] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.workTypeIndexes = newIndexes;
|
||||
},
|
||||
|
||||
|
||||
// 级联选择器确认事件
|
||||
onWorkTypePickerChange(e) {
|
||||
const indexes = e.detail.value;
|
||||
const selectedLevel1 = this.workTypeColumns[0][indexes[0]];
|
||||
const selectedLevel2 = this.workTypeColumns[1][indexes[1]];
|
||||
const selectedLevel3 = this.workTypeColumns[2][indexes[2]];
|
||||
|
||||
|
||||
if (selectedLevel3) {
|
||||
// 选择第三级
|
||||
this.formData.jobWorkType = selectedLevel3.id;
|
||||
@@ -697,16 +677,16 @@
|
||||
this.formData.jobWorkType = selectedLevel1.id;
|
||||
this.formData.jobWorkTypeName = selectedLevel1.workTypeName;
|
||||
}
|
||||
|
||||
|
||||
this.workTypeIndexes = indexes;
|
||||
},
|
||||
|
||||
|
||||
// 根据工种ID设置索引
|
||||
setWorkTypeIndexes(workTypeId) {
|
||||
// 在工种列表中查找对应的工种
|
||||
const targetWorkType = this.jobTypeList.find(item => item.id == workTypeId);
|
||||
if (!targetWorkType) return;
|
||||
|
||||
|
||||
// 根据level确定是哪一级
|
||||
if (targetWorkType.level === "1") {
|
||||
const index = this.workTypeColumns[0].findIndex(item => item.id == workTypeId);
|
||||
|
||||
Reference in New Issue
Block a user