提交11月3日

This commit is contained in:
wuzhimiao
2025-11-03 09:32:51 +08:00
parent 228800c214
commit 97922abde8
8 changed files with 1171 additions and 642 deletions

View File

@@ -54,8 +54,9 @@ onHide(() => {
});
</script>
<style>
<style lang="scss">
/*每个页面公共css */
@import 'uview-ui/index.scss';
@import '@/common/animation.css';
@import '@/common/common.css';
/* 引入阿里图标库 */

39
main.js
View File

@@ -32,10 +32,49 @@ const directives = import.meta.glob('./directives/*.js', {
});
import { createSSRApp } from 'vue'
import { createStore } from 'vuex'
// 导入已安装的uni-ui组件
import uniIcons from './uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
import uniPopup from './uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
// 创建Vuex store实例避免从分包导入
const storeRc = createStore({
state() {
return {
userInfo: null,
token: '',
roles: []
}
},
mutations: {
setUserInfo(state, userInfo) {
state.userInfo = userInfo
},
setToken(state, token) {
state.token = token
},
setRoles(state, roles) {
state.roles = roles
},
logout(state) {
state.userInfo = null
state.token = ''
state.roles = []
}
},
actions: {
async login({ commit }, userData) {
// 登录逻辑
commit('setUserInfo', userData)
commit('setToken', 'mock-token')
commit('setRoles', ['user'])
}
},
getters: {
roles: state => state.roles
}
})
// const foldFeature = window.visualViewport && 'segments' in window.visualViewport
// console.log('是否支持多段屏幕:', foldFeature)

View File

@@ -24,18 +24,45 @@
<div class="form-item required">
<label class="form-label">帮扶方式</label>
<div class="form-value" @click="showPicker('demandType')" :class="{ noValue: !serviceForm.demandType }">
<div class="form-select-wrapper" style="position: relative;">
<!-- 显示区域 -->
<div
class="form-value"
:class="{ 'noValue': !serviceForm.demandType }"
@click="showDemandTypePicker = !showDemandTypePicker"
style="width: 100%; height: 40px; padding: 0 10px; border: 1px solid #e6e6e6; border-radius: 8rpx; background-color: #fff; display: flex; align-items: center; justify-content: space-between; cursor: pointer;"
>
{{ getDemandTypeLabel(serviceForm.demandType) || "请选择" }}
<span class="arrow-down"></span>
</div>
<!-- 选项列表 -->
<div
v-if="showDemandTypePicker"
class="options-list"
style="position: absolute; top: 45px; left: 0; right: 0; background-color: #fff; border: 1px solid #e6e6e6; border-radius: 8rpx; z-index: 1000; max-height: 200px; overflow-y: auto;"
>
<div
v-for="option in demandTypeOptions"
:key="option.value"
@click="selectDemandType(option.value)"
style="padding: 10px; border-bottom: 1px solid #f0f0f0; cursor: pointer;"
>
{{ option.label }}
</div>
</div>
</div>
</div>
<div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<label class="form-label">帮扶时间</label>
<div class="form-value" @click="showPicker('practicalSolutionTime')" :class="{ noValue: !serviceForm.practicalSolutionTime }">
{{ serviceForm.practicalSolutionTime || "请选择" }}
<span class="arrow-down"></span>
</div>
<label class="form-label">帮扶时间 <text class="required">*</text></label>
<picker mode="date" :value="serviceForm.practicalSolutionTime" start="1900-01-01" end="2100-12-31" @change="onDateChange">
<view class="date-picker-wrapper" :class="{ noValue: !serviceForm.practicalSolutionTime }">
<view v-if="serviceForm.practicalSolutionTime" class="date-value">{{ serviceForm.practicalSolutionTime }}</view>
<view v-else>请选择</view>
<view class="icon-right"></view>
</view>
</picker>
</div>
<div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
@@ -67,9 +94,18 @@
<div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<label class="form-label">帮扶内容</label>
<div class="form-value" @click="showPicker('serviceContent')" :class="{ noValue: !serviceForm.serviceContent }">
<div class="date-picker-wrapper" :class="{ noValue: !serviceForm.serviceContent }">
<picker
@change="onServiceContentChange"
:range="serviceContentOptions.map(item => item.label)"
:value="getServiceContentIndex(serviceForm.serviceContent)"
mode="selector"
>
<view class="date-value">
{{ getServiceContentLabel(serviceForm.serviceContent) || "请选择" }}
<span class="arrow-down"></span>
</view>
</picker>
</div>
</div>
</view>
@@ -83,9 +119,40 @@
placeholder="请输入"
></textarea>
</div>
</view>
<view class="inner-part">
<div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<label class="form-label">帮扶情况说明</label>
<div class="file-upload-container">
<button class="upload-btn" @click="chooseImages" :disabled="fileList.length >= 6">
+ 添加图片 ({{ fileList.length }}/6)
</button>
<div class="file-list" v-if="fileList.length > 0">
<div v-for="(file, index) in fileList" :key="index" class="file-item">
<image :src="file.url" mode="aspectFill" class="uploaded-image"></image>
<span class="delete-btn" @click="removeImage(index)">删除</span>
</div>
</div>
</div>
</div>
</view>
// </view>
<view class="inner-part" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<div class="form-item">
@@ -147,7 +214,10 @@
</template>
<script>
import ImageUpload from "@/components/ImageUpload";
import {getJbrInfo} from "../../api/personinfo/index"
import { getDicts } from '@/apiRc/system/dict.js';
export default {
data() {
return {
@@ -164,10 +234,30 @@ export default {
personStatus: '', // 人员状态
fileUrl: [] // 附件
},
serviceContentMap: {
'1': '就业政策咨询',
'2': '职业指导',
'3': '技能培训',
'4': '岗位推荐',
'5': '创业指导',
'6': '其他'
},
// 帮扶内容选项picker组件需要的格式
serviceContentOptions: [
{ value: '1', label: '就业政策咨询' },
{ value: '2', label: '职业指导' },
{ value: '3', label: '技能培训' },
{ value: '4', label: '岗位推荐' },
{ value: '5', label: '创业指导' },
{ value: '6', label: '其他' }
],
showDemandTypePicker: false, // 控制帮扶方式选择器显示
jingbrList1:[],
currentPicker: null,
selectedOption: '',
manualDateTime: this.formatDateTime(new Date()),
fileList: [], // 初始化文件列表
// 帮扶方式选项 (4: 上门服务, 5: 电话回访)
demandTypeOptions: [
{ value: '4', label: '上门服务' },
@@ -185,29 +275,34 @@ export default {
{ value: '2', label: '未接通' },
{ value: '3', label: '拒绝沟通' }
],
// 帮扶内容选项
serviceContentOptions: [
{ value: '1', label: '政策宣传' },
{ value: '2', label: '就业指导' },
{ value: '3', label: '技能培训' },
{ value: '4', label: '岗位推荐' },
{ value: '5', label: '其他' }
],
// 人员状态选项
personStatusOptions: [
{ value: '1', label: '已就业' },
{ value: '2', label: '未就业' },
{ value: '3', label: '灵活就业' }
]
// 帮扶内容选项(通过字典获取)
serviceContentOptions: [],
// 人员状态选项(通过字典获取)
personStatusOptions: []
};
},
async created(){
this.getJbrInfo11()
const serviceContentOptions = await this.$getDictSelectOption('qcjy_fwnr');
console.log('帮扶内容选项:', serviceContentOptions);
this.serviceContentOptions = serviceContentOptions;
const serviceContentOptions1 = await this.$getDictSelectOption('qcjy_ryzt');
this.personStatusOptions=serviceContentOptions1
created(){
this.getJbrInfo11();
// 使用getDicts API获取帮扶内容字典数据
getDicts('qcjy_fwnr').then(res => {
if (res.data && Array.isArray(res.data)) {
// 将字典数据转换为picker组件需要的格式
this.serviceContentOptions = res.data.map(item => ({
value: item.dictValue,
label: item.dictLabel
}));
}
});
// 使用getDicts API获取人员状态字典数据
getDicts('qcjy_ryzt').then(res => {
if (res.data && Array.isArray(res.data)) {
this.personStatusOptions = res.data.map(item => ({
value: item.dictValue,
label: item.dictLabel
}));
}
});
},
onLoad(options) {
if (options.name) {
@@ -218,6 +313,46 @@ this.personStatusOptions=serviceContentOptions1
}
},
methods: {
// 选择图片
chooseImages() {
const remainingCount = 6 - this.fileList.length;
if (remainingCount <= 0) {
uni.showToast({ title: '最多只能上传6张图片', icon: 'none' });
return;
}
uni.chooseImage({
count: remainingCount,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
// 添加新选择的图片到列表
res.tempFilePaths.forEach((path, index) => {
this.fileList.push({
url: path,
file: res.tempFiles[index]
});
});
// 更新 serviceForm.fileUrl
this.updateFileUrls();
},
fail: (err) => {
console.error('选择图片失败:', err);
}
});
},
// 移除图片
removeImage(index) {
this.fileList.splice(index, 1);
// 更新 serviceForm.fileUrl
this.updateFileUrls();
},
// 更新文件URL数组
updateFileUrls() {
this.serviceForm.fileUrl = this.fileList.map(file => file.url);
},
async getJbrInfo11(){
const res=await getJbrInfo()
this.jingbrList1=res
@@ -296,6 +431,17 @@ this.personStatusOptions=serviceContentOptions1
this.serviceForm.agentUserName = '';
}
},
// 处理帮扶方式选择变化
handleDemandTypeChange(event) {
this.serviceForm.demandType = event.target.value;
},
// 选择帮扶方式
selectDemandType(value) {
this.serviceForm.demandType = value;
this.showDemandTypePicker = false;
},
// 获取电话沟通结果标签
getDhgtjgLabel(value) {
const option = this.dhgtjgOptions.find(item => item.value === value);
@@ -303,8 +449,22 @@ this.personStatusOptions=serviceContentOptions1
},
// 获取帮扶内容标签
getServiceContentLabel(value) {
const option = this.serviceContentOptions.find(item => item.value === value);
return option ? option.label : '';
return this.serviceContentMap[value] || '';
},
// 处理帮扶内容选择变化
onServiceContentChange(e) {
const index = e.detail.value;
if (this.serviceContentOptions && this.serviceContentOptions[index]) {
this.serviceForm.serviceContent = this.serviceContentOptions[index].value;
}
},
// 获取帮扶内容当前索引
getServiceContentIndex(value) {
if (!value) return 0;
const index = this.serviceContentOptions.findIndex(item => item.value === value);
return index !== -1 ? index : 0;
},
// 格式化日期时间为YYYY-MM-DDTHH:MM格式datetime-local输入框需要
formatDateTime(date) {
@@ -316,6 +476,11 @@ this.personStatusOptions=serviceContentOptions1
return `${year}-${month}-${day}T${hours}:${minutes}`;
},
// 日期选择变化处理
onDateChange(e) {
this.serviceForm.practicalSolutionTime = e.detail.value;
},
// 手动确认日期选择
manualConfirmDate() {
// 将datetime-local格式转换为显示格式
@@ -389,7 +554,13 @@ this.personStatusOptions=serviceContentOptions1
return true;
},
setName(){
this.serviceForm.serviceObjectName = this.name
this.serviceForm.serviceObjectId = this.userId
this.serviceForm.userId = this.userId
this.$forceUpdate();
},
// 提交表单
async submitServiceForm() {
try {
@@ -471,6 +642,36 @@ this.personStatusOptions=serviceContentOptions1
.form-select-wrapper {
flex: 1;
padding: 5px 0;
position: relative;
}
.form-select {
width: 100%;
padding: 20rpx;
border: 1px solid #e6e6e6;
border-radius: 8rpx;
font-size: 28rpx;
color: #333;
background-color: #fff;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
cursor: pointer;
}
.form-select.noValue {
color: #999;
}
.form-select-wrapper::after {
content: '▼';
position: absolute;
right: 30rpx;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
color: #999;
font-size: 20rpx;
}
.form-item.required .form-label::after {
@@ -570,6 +771,59 @@ this.personStatusOptions=serviceContentOptions1
color: #666;
}
/* 文件上传样式 */
.file-upload-container {
width: 100%;
padding: 10px 0;
}
.upload-btn {
padding: 10px 20px;
background-color: #f0f0f0;
border: 1px dashed #ddd;
border-radius: 4px;
color: #666;
margin-bottom: 10px;
width: 100%;
}
.upload-btn:disabled {
opacity: 0.6;
}
.file-list {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.file-item {
position: relative;
width: 100px;
height: 100px;
}
.uploaded-image {
width: 100%;
height: 100%;
border-radius: 4px;
}
.delete-btn {
position: absolute;
top: -8px;
right: -8px;
background-color: #ff4444;
color: white;
width: 20px;
height: 20px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
}
/* 选择器样式 */
.datetime-picker-overlay {
position: fixed;
@@ -586,39 +840,99 @@ this.personStatusOptions=serviceContentOptions1
.datetime-picker {
background-color: #fff;
border-radius: 8px;
width: 80%;
max-width: 400px;
border-radius: 12px;
width: 85%;
max-width: 420px;
overflow: hidden;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.picker-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
border-bottom: 1px solid #f0f0f0;
padding: 16px 20px;
border-bottom: 1px solid #f5f5f5;
font-size: 17px;
background-color: #fafafa;
}
.picker-header > span:first-child {
color: #666;
font-size: 16px;
}
.picker-header > span:last-child {
color: #1d64cf;
font-size: 16px;
font-weight: 500;
}
.picker-content {
max-height: 300px;
max-height: 280px;
overflow-y: auto;
}
.picker-options {
padding: 10px 0;
padding: 5px 0;
}
.picker-options > div {
padding: 15px 20px;
font-size: 14px;
color: #666;
padding: 16px 20px;
font-size: 16px;
color: #333;
position: relative;
transition: all 0.2s ease;
display: flex;
align-items: center;
}
.picker-options > div:not(:last-child) {
border-bottom: 1px solid #f8f8f8;
}
.picker-options > div:active {
background-color: #f5f5f5;
}
.picker-options > div.selected {
background-color: #f0f8ff;
background-color: #f0f7ff;
color: #1d64cf;
font-weight: 500;
}
/* 添加选中状态的对勾图标 */
.picker-options > div.selected::after {
content: '✓';
position: absolute;
right: 20px;
font-size: 18px;
font-weight: bold;
color: #1d64cf;
}
/* 日期选择器样式 */
.date-picker-wrapper {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
background-color: #fff;
}
.date-picker-wrapper.noValue {
background-color: #f9f9f9;
}
.date-value {
color: #333;
}
.icon-right {
color: #999;
font-size: 16px;
}
.noValue {

View File

@@ -628,12 +628,36 @@ export default {
},
goAddServices() {
console.log("服务按钮点击事件触发");
console.log("form数据:", this.form);
console.log("userId:", this.form?.userId);
console.log("name:", this.form?.name);
try {
const url = `/packageRc/pages/daiban/addbangfu?id=${this.form?.userId || ''}&name=${this.form.name}`;
console.log("导航URL:", url);
uni.navigateTo({
url:`/packageRc/pages/daiban/addbangfu?id=${this.form.userId}&name=${this.form.name}`
})
url: url,
success: () => {
console.log("导航成功");
},
fail: (err) => {
console.error("导航失败:", err);
uni.showToast({
title: '导航失败: ' + JSON.stringify(err),
icon: 'none'
});
}
});
} catch (error) {
console.error("执行出错:", error);
uni.showToast({
title: '执行出错: ' + error.message,
icon: 'none'
});
}
},
goRecommend() {
this.$tab.navigateTo(
@@ -1095,6 +1119,7 @@ export default {
}
}
.top_box_bg_service {
display:none;
position: absolute;
top: 20rpx;
left: 40rpx;

View File

@@ -4,7 +4,7 @@
* @LastEditTime: 2025-05-06 16:56:20
-->
<template>
<view class="container" style="background-color: #f7f7f7;">
<view class="container" style="background-color: #eef1f5;">
<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 150px)':'calc(100vh - 144px)'}">
<view class="inner">
<view class="part-title" style="display: flex;justify-content: space-between;">创业需求信息
@@ -210,10 +210,10 @@
async created() {
this.loading = true;
// await this.$delay(600)
// this.setDefaultValues()
// setTimeout(() => {
// this.setName()
// }, 0);
this.setDefaultValues()
setTimeout(() => {
this.setName()
}, 0);
},
methods: {
cancelPage() {
@@ -225,11 +225,13 @@
}
},
setName(){
// 只有在name有值时才设置人员信息
if(this.name) {
this.formData.personName = this.name
this.formData.personId = this.needId
this.formData.userId = this.needId
}
console.log("this",this)
},
openPersonChooser() {
if (this.edit && this.canChoosePerson) {

View File

@@ -5,7 +5,7 @@
-->
<template>
<view class="container" style="background-color: #f7f7f7;">
<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 150px)':'calc(100vh - 144px)'}">
<scroll-view scroll-y="true" >
<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"
@@ -156,18 +156,16 @@
</u--form>
</view>
</view>
</scroll-view>
<!-- 使用原生picker组件代替uView的选择器 -->
<!-- 工种选择器弹窗 -->
</scroll-view>
<view class="button-area" v-if="edit">
<view class="btn" @click="cancelPage">取消</view>
<view class="btn reset" @click="getDetail(formData.id)">重置</view>
<view class="btn save" @click="saveInfo">保存</view>
</view>
</scroll-view>
</view>
</template>
<script>
@@ -230,6 +228,7 @@
jobDescription: '',
// fileUrl: []
},
bfnrzd:[],
rules: {
personName: [{
required: true,
@@ -303,6 +302,9 @@
},
// 移除uView表单验证相关代码
created() {
getDicts('qcjy_fwnr').then(res => {
this.bfnrzd = res.data;
});
this.setName()
this.loading = true;
let arr = [{
@@ -380,12 +382,15 @@
}
},
setName(){
// 只有在name有值时才设置人员信息避免覆盖已有数据
if(this.name) {
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
@@ -745,80 +750,100 @@
}
}
</script>
<style scoped>
.inner {
padding: 40rpx;
<style lang="scss">
.page ::v-deep .u-navbar__content {
background-color: transparent !important;
}
.page {
background-color: #3161c7;
height: 100vh;
background-image: url('https://rc.jinan.gov.cn/qcwjyH5/static/images/top.png');
background-repeat: no-repeat;
background-size: 100% auto;
}
.inner {
background: #eef1f5;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
}
.inner-part {
width: 100%;
}
/* 为表单元素添加一些间距 */
.self-form {
width: 100%;
}
/* 表单项目样式 */
.form-item {
display: flex;
margin-bottom: 40rpx;
align-items: center;
align-items: flex-start;
margin-bottom: 24rpx;
background-color: #fff;
border-radius: 12rpx;
padding: 20rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
border-radius: 8rpx;
padding: 24rpx;
}
.form-label {
width: 140rpx;
font-size: 30rpx;
width: 200rpx;
font-size: 28rpx;
color: #333;
line-height: 1.5;
font-weight: 500;
margin-right: 30rpx;
text-align: right;
flex-shrink: 0;
line-height: 48rpx;
}
.required {
color: #f56c6c;
margin-left: 4rpx;
}
.form-input {
flex: 1;
height: 80rpx;
padding: 0 25rpx;
border: 1px solid #e8e8e8;
border-radius: 8rpx;
font-size: 30rpx;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background-color: #fafafa;
}
.form-input:focus {
border-color: #1989fa;
background-color: #fff;
box-shadow: 0 0 0 3rpx rgba(25, 137, 250, 0.1);
background: none;
height: 48rpx;
line-height: 48rpx;
}
.form-input-disabled {
color: #999;
background-color: #f5f5f5;
color: #909399;
background-color: #f5f7fa;
}
.form-textarea {
flex: 1;
min-height: 200rpx;
padding: 25rpx;
border: 1px solid #e8e8e8;
border-radius: 8rpx;
font-size: 30rpx;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background-color: #fafafa;
resize: vertical;
}
.form-textarea:focus {
border-color: #1989fa;
background-color: #fff;
box-shadow: 0 0 0 3rpx rgba(25, 137, 250, 0.1);
background: none;
min-height: 120rpx;
line-height: 40rpx;
}
.form-textarea-disabled {
color: #999;
background-color: #f5f5f5;
color: #909399;
background-color: #f5f7fa;
}
.required {
color: #FF4D4F;
margin-left: 4rpx;
.icon-right {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
}
.picker-view {
@@ -826,25 +851,61 @@
display: flex;
justify-content: space-between;
align-items: center;
height: 80rpx;
border: 1px solid #e8e8e8;
border-radius: 8rpx;
padding: 0 25rpx;
background-color: #fafafa;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background: none;
height: 48rpx;
line-height: 48rpx;
}
.picker-view-text {
font-size: 30rpx;
font-size: 28rpx;
color: #333;
}
.disabledLine {
background-color: #f5f5f5;
color: #999;
/* 按钮区域样式 */
.button-area {
padding: 24rpx 32rpx 68rpx;
width: calc(100% + 64rpx);
margin-left: -32rpx;
background: #fff;
display: flex;
box-sizing: border-box;
margin-top: 40rpx;
border-radius: 16px 16px 0px 0px;
.btn {
line-height: 72rpx;
width: 176rpx;
margin-right: 16rpx;
font-size: 28rpx;
border: 1px solid #B8C5D4;
color: #282828;
text-align: center;
border-radius: 8rpx;
}
.reset {
background: #DCE2E9;
}
.save {
background: linear-gradient(103deg, #1D64CF 0%, #1590D4 99%);
color: #fff;
border: 0;
flex-grow: 1;
}
}
.noValue {
color: #999;
color: rgb(192, 196, 204);
}
.disabledLine {
background: rgb(245, 247, 250);
cursor: not-allowed;
}
.ellipsis_1 {
@@ -853,44 +914,15 @@
white-space: nowrap;
}
/* 按钮区域样式 */
.button-area {
display: flex;
justify-content: center;
padding: 40rpx;
gap: 30rpx;
background-color: #fff;
border-top: 1px solid #eee;
margin-top: 20rpx;
}
.btn {
flex: 1;
height: 88rpx;
line-height: 88rpx;
text-align: center;
border-radius: 44rpx;
font-size: 32rpx;
font-weight: 500;
color: #333;
background-color: #f5f5f5;
}
.btn.save {
color: #fff;
background-color: #1989fa;
}
.btn.reset {
color: #666;
background-color: #f0f0f0;
}
/* 图标样式优化 */
.icon-right {
margin-left: 20rpx;
font-size: 36rpx;
color: #1989fa;
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
}
</style>

View File

@@ -4,72 +4,57 @@
* @LastEditTime: 2025-05-07 10:03:20
-->
<template>
<view class="input-outer-part">
<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 330rpx)':'calc(90vh - 200rpx)'}">
<view class="container">
<scroll-view scroll-y="true" >
<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"
style="font-weight: normal;display: flex;" @click="edit=true">编辑<u-icon name="edit-pen"
color="#A6A6A6"></u-icon></view>
style="font-weight: normal;display: flex;" @click="edit=true">编辑<view class="icon-right"></view></view>
</view>
<view class="inner-part">
<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm" class="self-form"
labelWidth="100">
<u-form-item label="姓名" prop="personName" required
v-if="$store.getters.roles.includes('shequn')|| $store.getters.roles.includes('gly')">
<view style="width: 100%;" @click="openPersonChooser"
<view class="self-form">
<view class="form-item">
<view class="form-label">姓名 <text class="required">*</text></view>
<view v-if="name" style="width: 100%;" class="disabledLine">
{{ formData.personName || '请选择' }}
</view>
<view v-else style="width: 100%;" @click="openPersonChooser"
:class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}">
{{ formData.personName || '请选择' }}
</view>
<u-icon slot="right" name="edit-pen" color="#A6A6A6"></u-icon>
</u-form-item>
<view class="icon-right"></view>
</view>
<u-form-item label="需求说明" prop="jobDescription" required>
<u-textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入"></u-textarea>
</u-form-item>
</u--form>
<view class="form-item">
<view class="form-label">需求说明 <text class="required">*</text></view>
<textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入" :class="['form-textarea', { 'form-textarea-disabled': !edit }]"></textarea>
</view>
</view>
</view>
</view>
<!-- 办理完成后 需求说明 -->
<req-comp :form="{
actualSolveDate: formData.actualSolveDate,
actualSolvePeople: formData.actualSolvePeople,
solveDesc: formData.solveDesc,
fileUrl: formData.fileUrl
}" />
</scroll-view>
<u-datetime-picker :show="show.hopeSolveDate" v-model="dates.hopeSolveDate" mode="date"
@confirm="confirmDate('hopeSolveDate', $event)" @cancel="cancelPicker('hopeSolveDate')"></u-datetime-picker>
<choose-person ref="personChooser" @confirm="personNameConfirm" />
<view class="button-area" v-if="edit">
<view class="btn" @click="cancelPage">取消</view>
<view class="btn reset" @click="getDetail(formData.id)">重置</view>
<view class="btn reset" @click="formData.id ? getDetail(formData.id) : setDefaultValues()">重置</view>
<view class="btn save" @click="saveInfo">保存</view>
</view>
</view>
</template>
<script>
// import {
// getPersonBase
// } from "@/api/person";
// import {
// addPersonDemand,
// updatePersonDemand,
// getPersonDemand
// } from "@/api/needs/personDemand";
// import ImageUpload from '@/components/ImageUpload'
// import ChoosePerson from '@/pages/needs/components/choosePerson';
// import {
// listJobType
// } from "@/api/jobType/index";
// import dayjs from "dayjs";
import { getPersonBase } from "@/packageRc/api/personinfo/index";
import { addPersonDemand, updatePersonDemand, getPersonDemand } from "@/packageRc/api/needs/personDemand";
//import reqComp from './req-comp';
export default {
components: {
// ChoosePerson,
//ImageUpload
// reqComp
},
props: {
needId: {
@@ -83,65 +68,60 @@
},
data() {
return {
fileList: [],
edit: true,
personBase: {},
dates: {},
formData: {
isAcceptAssistance: '',
isAcceptApprovalResult: '',
qtxqsm: ''
},
rules: {
personName: [{
required: true,
message: '请填写姓名',
trigger: ['blur', 'change'],
}, ],
qtxqsm: [{
required: true,
message: '请填写需求说明',
trigger: ['blur', 'change'],
}, ],
},
dict: {},
show: {},
currentCityArr: [],
originalDept: [],
currentCity: '请选择',
bysj: '',
loading: false,
jobTypeList: [],
route: {},
canChoosePerson: false,
formData: {
id: '',
personName: '',
personId: '',
demandType:"9",
userId: '',
demandTitle: '',
jobDescription: '',
actualSolveDate: '',
actualSolvePeople: '',
solveDesc: '',
fileUrl: '',
currentStatus: ''
}
}
},
onReady() {
this.$refs.uForm.setRules(this.rules)
// 组件已准备就绪
},
created() {
this.loading = true;
// 直接使用传入的参数设置姓名信息
if(this.name && this.needId) {
this.formData.personName = this.name;
this.formData.personId = this.needId;
this.formData.userId = this.needId;
}
// 如果需要获取详情
if (this.needId) {
this.getDetail(this.needId);
}
},
methods: {
cancelPage() {
if (this.formData.id) {
this.edit = false;
this.getDetail(this.formData.id)
if (!this.formData.id) {
this.$u.navigateBack();
} else {
uni.navigateBack()
this.edit = false;
this.getDetail(this.formData.id);
}
},
workTypeRemoteMethod(key) {
listJobType({
workTypeName: key,
pageNum: 1,
pageSize: 50
}).then(
(res) => {
this.jobTypeList = res.rows;
}
);
},
// workTypeRemoteMethod(key) {
// listJobType({
// workTypeName: key,
// pageNum: 1,
// pageSize: 50
// }).then(
// (res) => {
// this.jobTypeList = res.rows;
// }
// );
// },
openPersonChooser() {
if (this.edit && this.canChoosePerson) {
this.$refs.personChooser.open();
@@ -151,214 +131,173 @@
this.formData.personName = event.name
this.formData.personId = event.id
this.formData.userId = event.userId
this.formNameChange();
this.$forceUpdate();
},
changeFile(e) {
// 清空当前的 fileUrl 数组
this.formData.fileUrl = [];
// 如果 e 有长度(即用户选择了文件)
if (e.length) {
// 遍历每个文件对象并获取其 url
for (let data of e) {
const url = data.data ? data.data.url : data.url;
this.formData.fileUrl.push(url);
}
}
this.formData.fileUrl = this.$arrayToString(this.formData.fileUrl)
},
addOne() {
this.formData = {}
this.getPersonInfo()
if(this.name){
this.formData.personName = this.name
this.formData.userId = this.needid
}
this.edit = true
},
getDetail(id) {
getPersonDemand(id).then(res => {
this.$request({
url: '/mini/demand/getPersonDemandById',
method: 'GET',
data: {
id: id
}
}).then(res => {
if (res.code == 200) {
this.formData = res.data;
this.edit = false
this.fileList = this.$processFileUrl(this.formData.fileUrl)
})
},
confirmDate(type, e) {
this.show[type] = false;
let date = new Date(e.value)
this.formData[type] =
`${date.getFullYear()}-${(date.getMonth()+1)>9?(date.getMonth()+1):('0'+(date.getMonth()+1))}-${date.getDate()>9?date.getDate():('0'+date.getDate())}`
this.$forceUpdate();
}
}).catch(err => {
console.log(err);
});
},
goBack() {
uni.navigateBack();
},
cancelPicker(type) {
this.show[type] = false
this.$forceUpdate();
},
getDictLabel(value, list) {
if (list) {
let arr = list.filter(ele => ele.dictValue == value)
if (arr.length) {
return arr[0].dictLabel
} else {
return '请选择'
}
setName() {
// 确保personName存在
if (!this.formData.personName) {
this.formData.personName = '未知用户';
}
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
month = month < 10 ? '0' + month : month;
let day = date.getDate();
day = day < 10 ? '0' + day : day;
this.formData.demandTitle = `${this.formData.personName}_于${year}-${month}-${day}_提出其他需求`;
},
pickerConfirm(type, event) {
this.show[type] = false
this.formData[type] = event.value[0].dictValue
this.$forceUpdate();
},
showPicker(type) {
if (this.edit) {
this.show[type] = true
this.$forceUpdate()
}
},
getPersonInfo() {
this.loading = true;
this.$store.dispatch("GetInfo").then((res) => {
if (res.data.roles.indexOf('qunzhong') == -1) {
this.canChoosePerson = true;
} else {
this.canChoosePerson = false;
getPersonBase(res.data.user.userId).then(resp => {
this.formData.personId = resp.data.id
this.formData.userId = resp.data.userId
this.formData.personName = resp.data.name
this.formNameChange();
this.$forceUpdate();
})
}
})
},
formNameChange() {
let date = new Date()
let day =
`${date.getFullYear()}-${(date.getMonth()+1) + 1 > 9 ? (date.getMonth()+1) + 1: '0'+((date.getMonth()+1) + 1)}-${date.getDate() > 9 ? date.getDate(): '0'+date.getDate()}`
const dayNew = dayjs(date).format("YYYY-MM-DD");
this.formData.demandTitle = `${this.formData.personName}_于${dayNew}_提出其他需求`
},
async saveInfo() {
saveInfo() {
console.log("执行")
try {
// 验证表单
const isValid = await this.$refs.uForm.validate();
if (!isValid) {
throw new Error('请检查必填项填写');
// 验证必填项
if (!this.formData.personName) {
uni.showToast({
title: '请选择姓名',
icon: 'none'
});
return;
}
// 显示全局加载
this.$showLoading();
// 根据 formData 是否有 id 来决定是更新还是新增
let response;
let successMessage;
this.formData.demandType = 9;
// this.formData.userId = this.formData.personId
if (this.formData.id) {
response = await updatePersonDemand(this.formData);
successMessage = '修改成功';
} else {
response = await addPersonDemand(this.formData);
successMessage = '保存成功';
if (!this.formData.jobDescription) {
uni.showToast({
title: '请输入需求说明',
icon: 'none'
});
return;
}
// 检查响应码是否为200
if (response.code === 200) {
this.$u.toast(successMessage);
// 如果是编辑模式,关闭编辑状态;否则返回上一页
if (this.formData.id) {
uni.showLoading({
title: '保存中...'
});
this.setName();
let params = {
...this.formData,
type: '3'
};
const requestFn = this.formData.id ? updatePersonDemand : addPersonDemand;
requestFn(params).then(res => {
if (res.code == 200) {
uni.showToast({
title: '保存成功',
icon: 'success'
});
this.edit = false;
} else {
await this.$delay(1000); // 延迟1秒后返回上一页
uni.navigateBack();
if (!this.formData.id) {
this.formData.id = res.data;
}
} else {
throw new Error('服务器响应错误');
uni.showToast({
title: res.message,
icon: 'none'
});
}
}).catch(err => {
if (err.message) {
uni.showToast({
title: err.message,
icon: 'none'
});
}
});
} catch (error) {
if(error.length){
this.$u.toast('请填写完整信息!');
}else{
this.$u.toast('系统错误,请联系管理员!');
}
console.error('保存失败:', error);
} finally {
// 确保加载页总是会被隐藏
this.$hideLoading();
uni.hideLoading();
}
}
// saveInfo() {
// this.$refs.uForm.validate().then(res => {
// if (this.formData.id) {
// updatePersonDemand(this.formData).then(res => {
// if (res.code == 200) {
// uni.showToast({
// title: '修改成功'
// })
// this.edit = false;
// }
// })
// } else {
// addPersonDemand(this.formData).then(res => {
// if (res.code == 200) {
// uni.showToast({
// title: '保存成功'
// })
// uni.navigateBack();
// }
// })
// }
// }).catch(() => {
// uni.showToast({
// title: '请检查必填项填写',
// icon: 'none'
// })
// })
// }
}
}
</script>
<style lang="scss">
.page ::v-deep .u-navbar__content {
background-color: transparent !important;
<style lang="scss"> .container {
height: 100vh;
overflow: hidden;
background-color: #f7f7f7;
}
.page {
background-color: #EEF1F5 !important;
height: 100vh;
background-image: url('https://rc.jinan.gov.cn/qcwjyH5/static/images/top.png');
background-repeat: no-repeat;
background-size: 100% auto;
}
.input-outer-part {
padding: 0 32rpx;
box-sizing: border-box;
}
.inner {
background: #eef1f5;
background: #fff;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
}
.inner-part {
width: 100%;
}
/* 为表单元素添加一些间距 */
.self-form {
width: 100%;
}
/* 调整按钮区域样式 */
.button-area {
margin-top: 24rpx;
.form-item {
display: flex;
align-items: flex-start;
margin-bottom: 24rpx;
background-color: #fff;
border-radius: 8rpx;
padding: 24rpx;
}
.form-label {
width: 200rpx;
font-size: 28rpx;
color: #333;
flex-shrink: 0;
line-height: 48rpx;
}
.required {
color: #f56c6c;
margin-left: 4rpx;
}
.form-textarea {
flex: 1;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background: none;
min-height: 120rpx;
line-height: 40rpx;
}
.form-textarea-disabled {
color: #909399;
background-color: #f5f7fa;
}
.icon-right {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
}
.button-area {
padding: 24rpx 32rpx 68rpx;
width: calc(100% + 64rpx);
@@ -392,6 +331,67 @@
}
}
.container {
background-color: #f7f7f7;
}
.inner {
background-color: #f7f7f7;
padding: 24rpx 32rpx;
}
.self-form {
width: 100%;
}
.form-item {
display: flex;
align-items: flex-start;
margin-bottom: 24rpx;
background-color: #fff;
border-radius: 8rpx;
padding: 24rpx;
}
.form-label {
width: 200rpx;
font-size: 28rpx;
color: #333;
flex-shrink: 0;
line-height: 48rpx;
}
.required {
color: #f56c6c;
margin-left: 4rpx;
}
.form-textarea {
flex: 1;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background: none;
min-height: 120rpx;
line-height: 40rpx;
}
.form-textarea-disabled {
color: #909399;
background-color: #f5f7fa;
}
.icon-right {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
}
.noValue {
color: rgb(192, 196, 204);
}

View File

@@ -4,48 +4,30 @@
* @LastEditTime: 2025-05-07 09:33:39
-->
<template>
<view class="container">
<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 150px)':'calc(100vh - 144px)', backgroundColor: '#eef1f5'}">
<view class="input-outer-part">
<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 150px)':'calc(100vh - 144px)'}">
<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"
style="font-weight: normal;display: flex;" @click="edit=true">编辑<u-icon name="edit-pen"
color="#A6A6A6"></u-icon></view>
style="font-weight: normal;display: flex;" @click="edit=true">编辑<view class="icon-right"></view></view>
</view>
<view class="inner-part">
<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm" class="self-form"
labelWidth="120">
<u-form-item label="姓名" prop="personName" required
v-if="$store.getters.roles.includes('shequn'|| $store.getters.roles.includes('gly'))">
<view style="width: 100%;" @click="openPersonChooser"
<view class="self-form">
<view class="form-item">
<view class="form-label">姓名 <text class="required">*</text></view>
<view v-if="name" style="width: 100%;"
class="disabledLine">
{{ formData.personName || '请选择' }}
</view>
<view v-else style="width: 100%;" @click="openPersonChooser"
:class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}">
{{ formData.personName || '请选择' }}
</view>
<u-icon slot="right" name="edit-pen" color="#A6A6A6"></u-icon>
</u-form-item>
<!-- <u-form-item label="需求标题" prop="demandTitle" required>
<u--textarea :disabled="!edit" v-model="formData.demandTitle"
placeholder="请输入"></u--textarea>
<u-icon slot="right" name="edit-pen" color="#A6A6A6"></u-icon>
</u-form-item -->
<!-- <u-form-item label="有无创业指导需求" prop="isWillingnessReceiveTraining" required>
<u-radio-group :disabled="!edit" v-model="formData.isWillingnessReceiveTraining"
placement="row">
<u-radio :customStyle="{marginRight: '16px'}" label="是" name="是" value="1"></u-radio>
<u-radio :customStyle="{marginRight: '16px'}" label="否" name="否" value="0"></u-radio>
</u-radio-group>
</u-form-item>
<u-form-item label="是否接受推荐工作" prop="isAcceptRecommendedJobs" required>
<u-radio-group :disabled="!edit" v-model="formData.isAcceptRecommendedJobs" placement="row">
<u-radio :customStyle="{marginRight: '16px'}" label="是" name="是" value="1"></u-radio>
<u-radio :customStyle="{marginRight: '16px'}" label="否" name="否" value="0"></u-radio>
</u-radio-group>
</u-form-item> -->
<u-form-item label="培训意愿工种" prop="qwpxgz" required>
<view class="icon-right"></view>
</view>
<view class="form-item">
<view class="form-label">培训意愿工种 <text class="required">*</text></view>
<picker
mode="multiSelector"
:range="workTypeColumns"
@@ -56,39 +38,33 @@
v-if="workTypeColumns[0] && workTypeColumns[0].length"
>
<view class="picker-view">
<text>{{ formData.qwpxgzName || '请选择工种' }}</text>
<view class="picker-view-text">{{ formData.qwpxgzName || '请选择工种' }}</view>
<view class="icon-right"></view>
</view>
</picker>
<view v-else class="picker-view">
<text>工种数据加载中...</text>
<view class="picker-view-text">工种数据加载中...</view>
</view>
</view>
<view class="form-item">
<view class="form-label">期望培训时间 <text class="required">*</text></view>
<picker mode="date" :value="formData.qwpxsj" start="1900-01-01" end="2100-12-31" @change="onDateChange">
<view class="date-picker-wrapper" :class="{ noValue: !formData.qwpxsj }">
<view v-if="formData.qwpxsj" class="date-value">{{ formData.qwpxsj }}</view>
<view v-else>请选择</view>
<view class="icon-right"></view>
</view>
</picker>
</view>
<view class="form-item">
<view class="form-label">需求说明 <text class="required">*</text></view>
<textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入" :class="['form-textarea', { 'form-textarea-disabled': !edit }]"></textarea>
</view>
</view>
</u-form-item>
<u-form-item label="期望培训时间" prop="qwpxsj" required>
<view class="bordered" style="width: 100%" @click="showTime = true"
:class="{ noValue: !formData.qwpxsj }">
{{ formData.qwpxsj || "请选择" }}</view>
<view class="icon-right"></view>
</u-form-item>
</u--form>
<u--form labelPosition="left" class="self-form" labelWidth="110">
<u-form-item label="需求说明" prop="jobDescription">
<u-textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入"></u-textarea>
</u-form-item>
</u--form>
</view>
</view>
<!-- <view class="inner">
<view class="part-title" style="margin-top: 32rpx;">附件信息</view>
<view class="inner-part">
<u--form labelPosition="left" class="self-form" labelWidth="110">
<u-form-item label="附件" prop="fileUrl">
<ImageUpload :fileList="fileList" @update="changeFile" :maxCount="6" />
</u-form-item>
</u--form>
</view>
</view> -->
<!-- 办理完成后 需求说明 -->
<req-comp :form="{
@@ -99,14 +75,6 @@
}" />
</scroll-view>
<u-datetime-picker :show="show.qwpxsj" v-model="dates.qwpxsj" mode="date"
@confirm="confirmDate('qwpxsj', $event)" @cancel="cancelPicker('qwpxsj')"></u-datetime-picker>
<u-picker :show="show.qwpxgz" :columns="[jobTypeList]" keyName="workTypeName"
@confirm="jobTypeConfirm('qwpxgz', $event)" @cancel="cancelPicker('qwpxgz')"></u-picker>
<choose-person ref="personChooser" @confirm="personNameConfirm" />
<u-datetime-picker style="position: relative; z-index: 100" :show="showTime" v-model="hopeSolveDate"
mode="datetime" closeOnClickOverlay @confirm="confirmDate" @cancel="showTime = false"
@close="showTime = false"></u-datetime-picker>
<view class="button-area" v-if="edit">
<view class="btn" @click="cancelPage">取消</view>
<view class="btn reset" @click="getDetail(formData.id)">重置</view>
@@ -116,25 +84,15 @@
</template>
<script>
import {
getPersonBase
} from "@/packageRc/api/personinfo/index";
import {
addPersonDemand,
updatePersonDemand,
getPersonDemand
} from "@/packageRc/api/needs/personDemand";
import {
listJobType
} from "@/packageRc/api/jobType/index";
import ImageUpload from './ImageUpload'
import ChoosePerson from './choosePerson';
// import dayjs from "dayjs";
import { getPersonBase } from "@/packageRc/api/personinfo/index";
import { addPersonDemand, updatePersonDemand, getPersonDemand } from "@/packageRc/api/needs/personDemand";
import { listJobType } from "@/packageRc/api/jobType/index";
import uniDateformat from '@/uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.vue';
export default {
components: {
// ChoosePerson,
// ImageUpload
// ChoosePerson
},
props: {
needId: {
@@ -148,24 +106,20 @@
},
data() {
return {
fileList: [],
edit: true,
showTime: false,
personBase: {},
hopeSolveDate: Number(new Date()),
dates: {},
formData: {
userId:"",
personName:"",
demandType: "3",
personName: '',
personId: "",
userId: "",
demandTitle: '',
isAcceptAssistance: '',
isAcceptApprovalResult: '',
personName: '',
qwpxsj: '',
qwpxgz: '',
qwpxgzName: ''
qwpxgzName: '',
jobDescription: ''
},
rules: {
personName: [{
@@ -211,10 +165,27 @@
this.$refs.uForm.setRules(this.rules)
},
created() {
this.setName();
this.loading = true;
this.workTypeRemoteMethod('');
},
methods: {
setName() {
// 直接设置人员信息
this.formData.personName = this.name;
this.formData.personId = this.needId;
this.formData.userId = this.needId;
// 设置需求标题
if (this.formData.personName) {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0');
const day = String(today.getDate()).padStart(2, '0');
const formattedDate = `${year}-${month}-${day}`;
this.formData.demandTitle = `${this.formData.personName}_于${formattedDate}_提出培训需求`;
}
},
cancelPage() {
if (this.formData.id) {
this.edit = false;
@@ -235,14 +206,9 @@
this.formNameChange();
this.$forceUpdate();
},
confirmDate(e) {
this.showTime = false;
// 获取选中的日期
const date = e.value;
// 使用 uView 的 uTime 方法格式化日期,包含时分秒
const formattedDateTime = uni.$u.timeFormat(date, "yyyy-mm-dd");
// 设置表单数据
this.formData.qwpxsj = formattedDateTime;
// 使用picker组件的日期选择
onDateChange(e) {
this.formData.qwpxsj = e.detail.value;
},
changeFile(e) {
// 清空当前的 fileUrl 数组
@@ -298,7 +264,7 @@
this.setWorkTypeIndexes(this.formData.qwpxgz);
}
this.edit = false;
this.fileList = this.$processFileUrl(this.formData.fileUrl)
}).catch(error => {
console.error('Error fetching training detail:', error);
});
@@ -337,6 +303,7 @@
this.$store.dispatch("GetInfo").then((res) => {
if (res.data.roles.indexOf('qunzhong') == -1) {
this.canChoosePerson = true;
this.setName() // 确保非群众角色也能获取姓名
} else {
this.canChoosePerson = false;
getPersonBase(res.data.user.userId).then(resp => {
@@ -349,35 +316,46 @@
}
})
},
formNameChange() {
let date = new Date()
const dayNew = dayjs(date).format("YYYY-MM-DD");
this.formData.demandTitle = `${this.formData.personName}_于${dayNew}_提出培训需求`
setName() {
this.formData.personName = this.name;
this.formData.personId = this.needId;
this.formData.userId = this.needId;
let date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const dayNew = `${year}-${month}-${day}`;
this.formData.demandTitle = `${this.formData.personName}_于${dayNew}_提出培训需求`;
},
async saveInfo() {
try {
this.setName();
console.log("执行保存,表单数据:", this.formData);
console.log("personName:", this.formData.personName);
console.log("personId:", this.formData.personId);
console.log("userId:", this.formData.userId);
// 手动检查培训意愿工种是否已选择
if (!this.formData.qwpxgz || this.formData.qwpxgz.trim() === '') {
this.$u.toast('请选择培训意愿工种!');
if (!this.formData.qwpxgz || (typeof this.formData.qwpxgz === 'string' && this.formData.qwpxgz.trim() === '')) {
uni.showToast({
title: '请选择培训意愿工种!',
icon: 'none'
});
return;
}
// 手动检查期望培训时间是否已选择
if (!this.formData.qwpxsj || this.formData.qwpxsj.trim() === '') {
this.$u.toast('请选择期望培训时间!');
if (!this.formData.qwpxsj || (typeof this.formData.qwpxsj === 'string' && this.formData.qwpxsj.trim() === '')) {
uni.showToast({
title: '请选择期望培训时间!',
icon: 'none'
});
return;
}
// 验证表单
const isValid = await this.$refs.uForm.validate();
if (!isValid) {
throw new Error('请检查必填项填写');
return
}
this.$showLoading();
// 表单字段已通过手动检查,无需额外验证
uni.showLoading({
title: '加载中...'
});
let response;
let successMessage;
this.formData.demandType = 3;
@@ -390,24 +368,42 @@
}
// 检查响应码是否为200
if (response.code === 200) {
this.$u.toast(successMessage);
uni.showToast({
title: successMessage,
icon: 'success'
});
// 如果是编辑模式,关闭编辑状态;否则返回上一页
if (this.formData.id) {
this.edit = false;
} else {
await this.$delay(1000); // 延迟1秒后返回上一页
setTimeout(() => {
uni.navigateBack();
}, 1000);
}
} else {
// 响应码不为200时显示服务器返回的错误信息或默认错误信息
uni.showToast({
title: response.msg || '操作失败,请重试!',
icon: 'none'
});
}
} catch (error) {
if(error.length){
this.$u.toast('请填写完整信息!');
console.error('保存失败:', error);
// 检查错误是否为字符串类型或有特定消息
if(typeof error === 'string' || (error && error.message && error.message.includes('请检查'))){
uni.showToast({
title: '请填写完整信息!',
icon: 'none'
});
} else {
this.$u.toast('系统错误,请联系管理员!');
uni.showToast({
title: '系统错误,请联系管理员!',
icon: 'none'
});
}
} finally {
// 确保加载页总是会被隐藏
this.$hideLoading();
uni.hideLoading();
}
},
// getWorkTypeTree() {
@@ -500,19 +496,19 @@
const selectedLevel2 = this.workTypeColumns[1][indexes[1]];
const selectedLevel3 = this.workTypeColumns[2][indexes[2]];
// 使用$set确保响应式更新
// 直接赋值确保响应式更新
if (selectedLevel3) {
// 选择第三级
this.$set(this.formData, 'qwpxgz', selectedLevel3.id);
this.$set(this.formData, 'qwpxgzName', `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}/${selectedLevel3.workTypeName}`);
this.formData.qwpxgz = selectedLevel3.id;
this.formData.qwpxgzName = `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}/${selectedLevel3.workTypeName}`;
} else if (selectedLevel2) {
// 选择第二级
this.$set(this.formData, 'qwpxgz', selectedLevel2.id);
this.$set(this.formData, 'qwpxgzName', `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}`);
this.formData.qwpxgz = selectedLevel2.id;
this.formData.qwpxgzName = `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}`;
} else if (selectedLevel1) {
// 选择第一级
this.$set(this.formData, 'qwpxgz', selectedLevel1.id);
this.$set(this.formData, 'qwpxgzName', selectedLevel1.workTypeName);
this.formData.qwpxgz = selectedLevel1.id;
this.formData.qwpxgzName = selectedLevel1.workTypeName;
}
this.workTypeIndexes = indexes;
@@ -563,29 +559,46 @@
</script>
<style lang="scss">
.date-picker-wrapper {
width: 100%;
padding: 10px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
border: 1px solid #ddd;
border-radius: 4px;
}
.date-picker-wrapper.noValue {
color: #999;
}
.date-value {
color: #333;
}
.page ::v-deep .u-navbar__content {
background-color: transparent !important;
}
.container {
height: 100vh;
overflow: hidden;
background-color: #f7f7f7;
}
.page {
background-color: #EEF1F5 !important;
background-color: #3161c7;
height: 100vh;
background-image: url('https://rc.jinan.gov.cn/qcwjyH5/static/images/top.png');
background-repeat: no-repeat;
background-size: 100% auto;
}
.input-outer-part {
padding: 0 32rpx;
box-sizing: border-box;
}
.inner {
background: #eef1f5;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
}
.inner-part {
width: 100%;
}
@@ -595,10 +608,129 @@
width: 100%;
}
/* 表单项目样式 */
.form-item {
display: flex;
align-items: flex-start;
margin-bottom: 24rpx;
background-color: #fff;
border-radius: 8rpx;
padding: 24rpx;
}
.form-label {
width: 200rpx;
font-size: 28rpx;
color: #333;
flex-shrink: 0;
line-height: 48rpx;
}
.required {
color: #f56c6c;
margin-left: 4rpx;
}
.form-input {
flex: 1;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background: none;
height: 48rpx;
line-height: 48rpx;
}
.form-input-disabled {
color: #909399;
background-color: #f5f7fa;
}
.form-textarea {
flex: 1;
border: none;
outline: none;
font-size: 28rpx;
color: #333;
background: none;
min-height: 120rpx;
line-height: 40rpx;
}
.form-textarea-disabled {
color: #909399;
background-color: #f5f7fa;
}
.icon-right {
width: 40rpx;
height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
}
/* 单选框样式 */
.radio-group {
flex: 1;
display: flex;
align-items: center;
}
.radio-item {
display: flex;
align-items: center;
margin-right: 32rpx;
cursor: pointer;
}
.radio-item.radio-disabled {
cursor: not-allowed;
}
.radio {
width: 28rpx;
height: 28rpx;
border-radius: 50%;
border: 2rpx solid #dcdfe6;
margin-right: 12rpx;
position: relative;
}
.radio.radio-checked {
border-color: #409eff;
background-color: #409eff;
}
.radio.radio-checked::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background-color: #fff;
}
/* 调整按钮区域样式 */
.button-area {
margin-top: 24rpx;
}
.picker-cover {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 99;
}
.button-area {
padding: 24rpx 32rpx 68rpx;
width: calc(100% + 64rpx);
@@ -652,28 +784,12 @@
align-items: center;
justify-content: space-between;
width: 100%;
padding: 28rpx 36rpx;
background: #ffffff;
border: 2rpx solid #e5e5e5;
border-radius: 12rpx;
min-height: 88rpx;
box-sizing: border-box;
transition: all 0.3s ease;
}
.picker-view:active {
background: #f8f9fa;
border-color: #007aff;
}
.picker-view text {
.picker-view-text {
color: #333333;
font-size: 28rpx;
flex: 1;
text-align: left; font-size: 28rpx;
flex: 1;
}
.picker-view .u-icon {
margin-left: 16rpx;
color: #999999;
}
</style>