提交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> </script>
<style> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
@import 'uview-ui/index.scss';
@import '@/common/animation.css'; @import '@/common/animation.css';
@import '@/common/common.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 { createSSRApp } from 'vue'
import { createStore } from 'vuex'
// 导入已安装的uni-ui组件 // 导入已安装的uni-ui组件
import uniIcons from './uni_modules/uni-icons/components/uni-icons/uni-icons.vue' 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' 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 // const foldFeature = window.visualViewport && 'segments' in window.visualViewport
// console.log('是否支持多段屏幕:', foldFeature) // console.log('是否支持多段屏幕:', foldFeature)

View File

@@ -24,18 +24,45 @@
<div class="form-item required"> <div class="form-item required">
<label class="form-label">帮扶方式</label> <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) || "请选择" }} {{ getDemandTypeLabel(serviceForm.demandType) || "请选择" }}
<span class="arrow-down"></span> <span class="arrow-down"></span>
</div> </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>
<div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'"> <div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<label class="form-label">帮扶时间</label> <label class="form-label">帮扶时间 <text class="required">*</text></label>
<div class="form-value" @click="showPicker('practicalSolutionTime')" :class="{ noValue: !serviceForm.practicalSolutionTime }"> <picker mode="date" :value="serviceForm.practicalSolutionTime" start="1900-01-01" end="2100-12-31" @change="onDateChange">
{{ serviceForm.practicalSolutionTime || "请选择" }} <view class="date-picker-wrapper" :class="{ noValue: !serviceForm.practicalSolutionTime }">
<span class="arrow-down"></span> <view v-if="serviceForm.practicalSolutionTime" class="date-value">{{ serviceForm.practicalSolutionTime }}</view>
</div> <view v-else>请选择</view>
<view class="icon-right"></view>
</view>
</picker>
</div> </div>
<div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'"> <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'"> <div class="form-item required" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<label class="form-label">帮扶内容</label> <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) || "请选择" }} {{ getServiceContentLabel(serviceForm.serviceContent) || "请选择" }}
<span class="arrow-down"></span> <span class="arrow-down"></span>
</view>
</picker>
</div> </div>
</div> </div>
</view> </view>
@@ -83,9 +119,40 @@
placeholder="请输入" placeholder="请输入"
></textarea> ></textarea>
</div> </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'"> <view class="inner-part" v-if="serviceForm.demandType == '4' || serviceForm.demandType == '5'">
<div class="form-item"> <div class="form-item">
@@ -147,7 +214,10 @@
</template> </template>
<script> <script>
import ImageUpload from "@/components/ImageUpload";
import {getJbrInfo} from "../../api/personinfo/index" import {getJbrInfo} from "../../api/personinfo/index"
import { getDicts } from '@/apiRc/system/dict.js';
export default { export default {
data() { data() {
return { return {
@@ -164,10 +234,30 @@ export default {
personStatus: '', // 人员状态 personStatus: '', // 人员状态
fileUrl: [] // 附件 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:[], jingbrList1:[],
currentPicker: null, currentPicker: null,
selectedOption: '', selectedOption: '',
manualDateTime: this.formatDateTime(new Date()), manualDateTime: this.formatDateTime(new Date()),
fileList: [], // 初始化文件列表
// 帮扶方式选项 (4: 上门服务, 5: 电话回访) // 帮扶方式选项 (4: 上门服务, 5: 电话回访)
demandTypeOptions: [ demandTypeOptions: [
{ value: '4', label: '上门服务' }, { value: '4', label: '上门服务' },
@@ -185,29 +275,34 @@ export default {
{ value: '2', label: '未接通' }, { value: '2', label: '未接通' },
{ value: '3', label: '拒绝沟通' } { value: '3', label: '拒绝沟通' }
], ],
// 帮扶内容选项 // 帮扶内容选项(通过字典获取)
serviceContentOptions: [ serviceContentOptions: [],
{ value: '1', label: '政策宣传' }, // 人员状态选项(通过字典获取)
{ value: '2', label: '就业指导' }, personStatusOptions: []
{ value: '3', label: '技能培训' },
{ value: '4', label: '岗位推荐' },
{ value: '5', label: '其他' }
],
// 人员状态选项
personStatusOptions: [
{ value: '1', label: '已就业' },
{ value: '2', label: '未就业' },
{ value: '3', label: '灵活就业' }
]
}; };
}, },
async created(){ created(){
this.getJbrInfo11() this.getJbrInfo11();
const serviceContentOptions = await this.$getDictSelectOption('qcjy_fwnr'); // 使用getDicts API获取帮扶内容字典数据
console.log('帮扶内容选项:', serviceContentOptions); getDicts('qcjy_fwnr').then(res => {
this.serviceContentOptions = serviceContentOptions; if (res.data && Array.isArray(res.data)) {
const serviceContentOptions1 = await this.$getDictSelectOption('qcjy_ryzt'); // 将字典数据转换为picker组件需要的格式
this.personStatusOptions=serviceContentOptions1 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) { onLoad(options) {
if (options.name) { if (options.name) {
@@ -218,6 +313,46 @@ this.personStatusOptions=serviceContentOptions1
} }
}, },
methods: { 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(){ async getJbrInfo11(){
const res=await getJbrInfo() const res=await getJbrInfo()
this.jingbrList1=res this.jingbrList1=res
@@ -296,6 +431,17 @@ this.personStatusOptions=serviceContentOptions1
this.serviceForm.agentUserName = ''; this.serviceForm.agentUserName = '';
} }
}, },
// 处理帮扶方式选择变化
handleDemandTypeChange(event) {
this.serviceForm.demandType = event.target.value;
},
// 选择帮扶方式
selectDemandType(value) {
this.serviceForm.demandType = value;
this.showDemandTypePicker = false;
},
// 获取电话沟通结果标签 // 获取电话沟通结果标签
getDhgtjgLabel(value) { getDhgtjgLabel(value) {
const option = this.dhgtjgOptions.find(item => item.value === value); const option = this.dhgtjgOptions.find(item => item.value === value);
@@ -303,8 +449,22 @@ this.personStatusOptions=serviceContentOptions1
}, },
// 获取帮扶内容标签 // 获取帮扶内容标签
getServiceContentLabel(value) { getServiceContentLabel(value) {
const option = this.serviceContentOptions.find(item => item.value === value); return this.serviceContentMap[value] || '';
return option ? option.label : ''; },
// 处理帮扶内容选择变化
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输入框需要 // 格式化日期时间为YYYY-MM-DDTHH:MM格式datetime-local输入框需要
formatDateTime(date) { formatDateTime(date) {
@@ -316,6 +476,11 @@ this.personStatusOptions=serviceContentOptions1
return `${year}-${month}-${day}T${hours}:${minutes}`; return `${year}-${month}-${day}T${hours}:${minutes}`;
}, },
// 日期选择变化处理
onDateChange(e) {
this.serviceForm.practicalSolutionTime = e.detail.value;
},
// 手动确认日期选择 // 手动确认日期选择
manualConfirmDate() { manualConfirmDate() {
// 将datetime-local格式转换为显示格式 // 将datetime-local格式转换为显示格式
@@ -389,7 +554,13 @@ this.personStatusOptions=serviceContentOptions1
return true; return true;
}, },
setName(){
this.serviceForm.serviceObjectName = this.name
this.serviceForm.serviceObjectId = this.userId
this.serviceForm.userId = this.userId
this.$forceUpdate();
},
// 提交表单 // 提交表单
async submitServiceForm() { async submitServiceForm() {
try { try {
@@ -471,6 +642,36 @@ this.personStatusOptions=serviceContentOptions1
.form-select-wrapper { .form-select-wrapper {
flex: 1; flex: 1;
padding: 5px 0; 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 { .form-item.required .form-label::after {
@@ -570,6 +771,59 @@ this.personStatusOptions=serviceContentOptions1
color: #666; 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 { .datetime-picker-overlay {
position: fixed; position: fixed;
@@ -586,39 +840,99 @@ this.personStatusOptions=serviceContentOptions1
.datetime-picker { .datetime-picker {
background-color: #fff; background-color: #fff;
border-radius: 8px; border-radius: 12px;
width: 80%; width: 85%;
max-width: 400px; max-width: 420px;
overflow: hidden; overflow: hidden;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
} }
.picker-header { .picker-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 15px; padding: 16px 20px;
border-bottom: 1px solid #f0f0f0; border-bottom: 1px solid #f5f5f5;
font-size: 17px;
background-color: #fafafa;
}
.picker-header > span:first-child {
color: #666;
font-size: 16px; font-size: 16px;
} }
.picker-header > span:last-child {
color: #1d64cf;
font-size: 16px;
font-weight: 500;
}
.picker-content { .picker-content {
max-height: 300px; max-height: 280px;
overflow-y: auto; overflow-y: auto;
} }
.picker-options { .picker-options {
padding: 10px 0; padding: 5px 0;
} }
.picker-options > div { .picker-options > div {
padding: 15px 20px; padding: 16px 20px;
font-size: 14px; font-size: 16px;
color: #666; 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 { .picker-options > div.selected {
background-color: #f0f8ff; background-color: #f0f7ff;
color: #1d64cf; 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 { .noValue {

View File

@@ -628,12 +628,36 @@ export default {
}, },
goAddServices() { 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({ 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() { goRecommend() {
this.$tab.navigateTo( this.$tab.navigateTo(
@@ -1095,6 +1119,7 @@ export default {
} }
} }
.top_box_bg_service { .top_box_bg_service {
display:none;
position: absolute; position: absolute;
top: 20rpx; top: 20rpx;
left: 40rpx; left: 40rpx;

View File

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

View File

@@ -5,7 +5,7 @@
--> -->
<template> <template>
<view class="container" style="background-color: #f7f7f7;"> <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="inner">
<view class="part-title" style="display: flex;justify-content: space-between;">求职需求信息 <view class="part-title" style="display: flex;justify-content: space-between;">求职需求信息
<view v-if="!edit&&formData.id&&formData.currentStatus!=3" class="btn" <view v-if="!edit&&formData.id&&formData.currentStatus!=3" class="btn"
@@ -156,18 +156,16 @@
</u--form> </u--form>
</view> </view>
</view> </view>
</scroll-view>
<!-- 使用原生picker组件代替uView的选择器 --> <!-- 使用原生picker组件代替uView的选择器 -->
<!-- 工种选择器弹窗 --> <!-- 工种选择器弹窗 -->
</scroll-view>
<view class="button-area" v-if="edit"> <view class="button-area" v-if="edit">
<view class="btn" @click="cancelPage">取消</view> <view class="btn" @click="cancelPage">取消</view>
<view class="btn reset" @click="getDetail(formData.id)">重置</view> <view class="btn reset" @click="getDetail(formData.id)">重置</view>
<view class="btn save" @click="saveInfo">保存</view> <view class="btn save" @click="saveInfo">保存</view>
</view> </view>
</scroll-view>
</view> </view>
</template> </template>
<script> <script>
@@ -230,6 +228,7 @@
jobDescription: '', jobDescription: '',
// fileUrl: [] // fileUrl: []
}, },
bfnrzd:[],
rules: { rules: {
personName: [{ personName: [{
required: true, required: true,
@@ -303,6 +302,9 @@
}, },
// 移除uView表单验证相关代码 // 移除uView表单验证相关代码
created() { created() {
getDicts('qcjy_fwnr').then(res => {
this.bfnrzd = res.data;
});
this.setName() this.setName()
this.loading = true; this.loading = true;
let arr = [{ let arr = [{
@@ -380,12 +382,15 @@
} }
}, },
setName(){ setName(){
// 只有在name有值时才设置人员信息避免覆盖已有数据
if(this.name) {
this.formData.personName = this.name this.formData.personName = this.name
this.formData.personId = this.needId this.formData.personId = this.needId
this.formData.userId = this.needId this.formData.userId = this.needId
}
}, },
personNameConfirm(event) { personNameConfirm(event) {
this.formData.personName = event.name // this.formData.personName = event.name
this.formData.personId = event.id this.formData.personId = event.id
this.formData.userId = event.userId this.formData.userId = event.userId
@@ -745,80 +750,100 @@
} }
} }
</script> </script>
<style scoped> <style lang="scss">
.inner {
padding: 40rpx; .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 { .form-item {
display: flex; display: flex;
margin-bottom: 40rpx; align-items: flex-start;
align-items: center; margin-bottom: 24rpx;
background-color: #fff; background-color: #fff;
border-radius: 12rpx; border-radius: 8rpx;
padding: 20rpx; padding: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
} }
.form-label { .form-label {
width: 140rpx; width: 200rpx;
font-size: 30rpx; font-size: 28rpx;
color: #333; color: #333;
line-height: 1.5;
font-weight: 500;
margin-right: 30rpx;
text-align: right;
flex-shrink: 0; flex-shrink: 0;
line-height: 48rpx;
}
.required {
color: #f56c6c;
margin-left: 4rpx;
} }
.form-input { .form-input {
flex: 1; flex: 1;
height: 80rpx; border: none;
padding: 0 25rpx; outline: none;
border: 1px solid #e8e8e8; font-size: 28rpx;
border-radius: 8rpx;
font-size: 30rpx;
color: #333; color: #333;
background-color: #fafafa; background: none;
} height: 48rpx;
line-height: 48rpx;
.form-input:focus {
border-color: #1989fa;
background-color: #fff;
box-shadow: 0 0 0 3rpx rgba(25, 137, 250, 0.1);
} }
.form-input-disabled { .form-input-disabled {
color: #999; color: #909399;
background-color: #f5f5f5; background-color: #f5f7fa;
} }
.form-textarea { .form-textarea {
flex: 1; flex: 1;
min-height: 200rpx; border: none;
padding: 25rpx; outline: none;
border: 1px solid #e8e8e8; font-size: 28rpx;
border-radius: 8rpx;
font-size: 30rpx;
color: #333; color: #333;
background-color: #fafafa; background: none;
resize: vertical; min-height: 120rpx;
} line-height: 40rpx;
.form-textarea:focus {
border-color: #1989fa;
background-color: #fff;
box-shadow: 0 0 0 3rpx rgba(25, 137, 250, 0.1);
} }
.form-textarea-disabled { .form-textarea-disabled {
color: #999; color: #909399;
background-color: #f5f5f5; background-color: #f5f7fa;
} }
.required { .icon-right {
color: #FF4D4F; width: 40rpx;
margin-left: 4rpx; height: 40rpx;
display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
} }
.picker-view { .picker-view {
@@ -826,25 +851,61 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
height: 80rpx; border: none;
border: 1px solid #e8e8e8; outline: none;
border-radius: 8rpx; font-size: 28rpx;
padding: 0 25rpx; color: #333;
background-color: #fafafa; background: none;
height: 48rpx;
line-height: 48rpx;
} }
.picker-view-text { .picker-view-text {
font-size: 30rpx; font-size: 28rpx;
color: #333; color: #333;
} }
.disabledLine { /* 按钮区域样式 */
background-color: #f5f5f5; .button-area {
color: #999; 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 { .noValue {
color: #999; color: rgb(192, 196, 204);
}
.disabledLine {
background: rgb(245, 247, 250);
cursor: not-allowed;
} }
.ellipsis_1 { .ellipsis_1 {
@@ -853,44 +914,15 @@
white-space: nowrap; 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 { .icon-right {
margin-left: 20rpx; width: 40rpx;
font-size: 36rpx; height: 40rpx;
color: #1989fa; display: flex;
align-items: center;
justify-content: center;
color: #A6A6A6;
margin-left: 16rpx;
} }
</style> </style>

View File

@@ -4,72 +4,57 @@
* @LastEditTime: 2025-05-07 10:03:20 * @LastEditTime: 2025-05-07 10:03:20
--> -->
<template> <template>
<view class="container">
<view class="input-outer-part"> <scroll-view scroll-y="true" >
<scroll-view scroll-y="true" :style="{height: edit?'calc(90vh - 330rpx)':'calc(90vh - 200rpx)'}">
<view class="inner"> <view class="inner">
<view class="part-title" style="display: flex;justify-content: space-between;">需求信息 <view class="part-title" style="display: flex;justify-content: space-between;">需求信息
<view v-if="!edit&&formData.id&&formData.currentStatus!=3" class="btn" <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" style="font-weight: normal;display: flex;" @click="edit=true">编辑<view class="icon-right"></view></view>
color="#A6A6A6"></u-icon></view>
</view> </view>
<view class="inner-part"> <view class="inner-part">
<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm" class="self-form" <view class="self-form">
labelWidth="100"> <view class="form-item">
<u-form-item label="姓名" prop="personName" required <view class="form-label">姓名 <text class="required">*</text></view>
v-if="$store.getters.roles.includes('shequn')|| $store.getters.roles.includes('gly')"> <view v-if="name" style="width: 100%;" class="disabledLine">
<view style="width: 100%;" @click="openPersonChooser" {{ formData.personName || '请选择' }}
</view>
<view v-else style="width: 100%;" @click="openPersonChooser"
:class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}"> :class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}">
{{ formData.personName || '请选择' }} {{ formData.personName || '请选择' }}
</view> </view>
<u-icon slot="right" name="edit-pen" color="#A6A6A6"></u-icon> <view class="icon-right"></view>
</u-form-item> </view>
<u-form-item label="需求说明" prop="jobDescription" required> <view class="form-item">
<u-textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入"></u-textarea> <view class="form-label">需求说明 <text class="required">*</text></view>
</u-form-item> <textarea :disabled="!edit" v-model="formData.jobDescription" placeholder="请输入" :class="['form-textarea', { 'form-textarea-disabled': !edit }]"></textarea>
</u--form>
</view> </view>
</view> </view>
</view>
</view>
<!-- 办理完成后 需求说明 --> <!-- 办理完成后 需求说明 -->
<req-comp :form="{
actualSolveDate: formData.actualSolveDate,
actualSolvePeople: formData.actualSolvePeople,
solveDesc: formData.solveDesc,
fileUrl: formData.fileUrl
}" />
</scroll-view> </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" /> <choose-person ref="personChooser" @confirm="personNameConfirm" />
<view class="button-area" v-if="edit"> <view class="button-area" v-if="edit">
<view class="btn" @click="cancelPage">取消</view> <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 class="btn save" @click="saveInfo">保存</view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
// import { import { getPersonBase } from "@/packageRc/api/personinfo/index";
// getPersonBase import { addPersonDemand, updatePersonDemand, getPersonDemand } from "@/packageRc/api/needs/personDemand";
// } from "@/api/person"; //import reqComp from './req-comp';
// 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";
export default { export default {
components: { components: {
// ChoosePerson, // reqComp
//ImageUpload
}, },
props: { props: {
needId: { needId: {
@@ -83,65 +68,60 @@
}, },
data() { data() {
return { return {
fileList: [],
edit: true, 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, canChoosePerson: false,
formData: {
id: '',
personName: '',
personId: '',
demandType:"9",
userId: '',
demandTitle: '',
jobDescription: '',
actualSolveDate: '',
actualSolvePeople: '',
solveDesc: '',
fileUrl: '',
currentStatus: ''
}
} }
}, },
onReady() { onReady() {
this.$refs.uForm.setRules(this.rules) // 组件已准备就绪
}, },
created() { created() {
this.loading = true; 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: { methods: {
cancelPage() { cancelPage() {
if (this.formData.id) { if (!this.formData.id) {
this.edit = false; this.$u.navigateBack();
this.getDetail(this.formData.id)
} else { } else {
uni.navigateBack() this.edit = false;
this.getDetail(this.formData.id);
} }
}, },
workTypeRemoteMethod(key) { // workTypeRemoteMethod(key) {
listJobType({ // listJobType({
workTypeName: key, // workTypeName: key,
pageNum: 1, // pageNum: 1,
pageSize: 50 // pageSize: 50
}).then( // }).then(
(res) => { // (res) => {
this.jobTypeList = res.rows; // this.jobTypeList = res.rows;
} // }
); // );
}, // },
openPersonChooser() { openPersonChooser() {
if (this.edit && this.canChoosePerson) { if (this.edit && this.canChoosePerson) {
this.$refs.personChooser.open(); this.$refs.personChooser.open();
@@ -151,214 +131,173 @@
this.formData.personName = event.name this.formData.personName = event.name
this.formData.personId = event.id this.formData.personId = event.id
this.formData.userId = event.userId this.formData.userId = event.userId
this.formNameChange();
this.$forceUpdate(); 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) { 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.formData = res.data;
this.edit = false }
this.fileList = this.$processFileUrl(this.formData.fileUrl) }).catch(err => {
}) console.log(err);
}, });
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();
}, },
goBack() { goBack() {
uni.navigateBack(); uni.navigateBack();
}, },
cancelPicker(type) {
this.show[type] = false setName() {
this.$forceUpdate(); // 确保personName存在
}, if (!this.formData.personName) {
getDictLabel(value, list) { this.formData.personName = '未知用户';
if (list) {
let arr = list.filter(ele => ele.dictValue == value)
if (arr.length) {
return arr[0].dictLabel
} else {
return '请选择'
}
} }
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) { saveInfo() {
this.show[type] = false console.log("执行")
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() {
try { try {
// 验证表单 // 验证必填项
const isValid = await this.$refs.uForm.validate(); if (!this.formData.personName) {
if (!isValid) { uni.showToast({
throw new Error('请检查必填项填写'); title: '请选择姓名',
icon: 'none'
});
return;
} }
// 显示全局加载 if (!this.formData.jobDescription) {
this.$showLoading(); uni.showToast({
title: '请输入需求说明',
// 根据 formData 是否有 id 来决定是更新还是新增 icon: 'none'
let response; });
let successMessage; return;
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 = '保存成功';
} }
// 检查响应码是否为200 uni.showLoading({
if (response.code === 200) { title: '保存中...'
this.$u.toast(successMessage); });
// 如果是编辑模式,关闭编辑状态;否则返回上一页 this.setName();
if (this.formData.id) { 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; this.edit = false;
} else { if (!this.formData.id) {
await this.$delay(1000); // 延迟1秒后返回上一页 this.formData.id = res.data;
uni.navigateBack();
} }
} else { } 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) { } catch (error) {
if(error.length){ console.error('保存失败:', error);
this.$u.toast('请填写完整信息!');
}else{
this.$u.toast('系统错误,请联系管理员!');
}
} finally { } finally {
// 确保加载页总是会被隐藏 uni.hideLoading();
this.$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> </script>
<style lang="scss"> <style lang="scss"> .container {
.page ::v-deep .u-navbar__content { height: 100vh;
background-color: transparent !important; 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 { .inner {
background: #eef1f5; background: #fff;
border-radius: 16rpx; border-radius: 16rpx;
padding: 32rpx; padding: 32rpx;
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
.inner-part { .inner-part {
width: 100%; width: 100%;
} }
/* 为表单元素添加一些间距 */
.self-form { .self-form {
width: 100%; width: 100%;
} }
/* 调整按钮区域样式 */ .form-item {
.button-area { display: flex;
margin-top: 24rpx; 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 { .button-area {
padding: 24rpx 32rpx 68rpx; padding: 24rpx 32rpx 68rpx;
width: calc(100% + 64rpx); 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 { .noValue {
color: rgb(192, 196, 204); color: rgb(192, 196, 204);
} }

View File

@@ -4,48 +4,30 @@
* @LastEditTime: 2025-05-07 09:33:39 * @LastEditTime: 2025-05-07 09:33:39
--> -->
<template> <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="inner">
<view class="part-title" style="display: flex;justify-content: space-between;">培训需求信息 <view class="part-title" style="display: flex;justify-content: space-between;">培训需求信息
<view v-if="!edit&&formData.id&&formData.currentStatus!=3" class="btn" <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" style="font-weight: normal;display: flex;" @click="edit=true">编辑<view class="icon-right"></view></view>
color="#A6A6A6"></u-icon></view>
</view> </view>
<view class="inner-part"> <view class="inner-part">
<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm" class="self-form" <view class="self-form">
labelWidth="120"> <view class="form-item">
<u-form-item label="姓名" prop="personName" required <view class="form-label">姓名 <text class="required">*</text></view>
v-if="$store.getters.roles.includes('shequn'|| $store.getters.roles.includes('gly'))"> <view v-if="name" style="width: 100%;"
<view style="width: 100%;" @click="openPersonChooser" class="disabledLine">
{{ formData.personName || '请选择' }}
</view>
<view v-else style="width: 100%;" @click="openPersonChooser"
:class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}"> :class="{disabledLine: !edit||!canChoosePerson, noValue: !formData.personName}">
{{ formData.personName || '请选择' }} {{ formData.personName || '请选择' }}
</view> </view>
<u-icon slot="right" name="edit-pen" color="#A6A6A6"></u-icon> <view class="icon-right"></view>
</u-form-item> </view>
<view class="form-item">
<!-- <u-form-item label="需求标题" prop="demandTitle" required> <view class="form-label">培训意愿工种 <text class="required">*</text></view>
<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>
<picker <picker
mode="multiSelector" mode="multiSelector"
:range="workTypeColumns" :range="workTypeColumns"
@@ -56,39 +38,33 @@
v-if="workTypeColumns[0] && workTypeColumns[0].length" v-if="workTypeColumns[0] && workTypeColumns[0].length"
> >
<view class="picker-view"> <view class="picker-view">
<text>{{ formData.qwpxgzName || '请选择工种' }}</text> <view class="picker-view-text">{{ formData.qwpxgzName || '请选择工种' }}</view>
<view class="icon-right"></view> <view class="icon-right"></view>
</view> </view>
</picker> </picker>
<view v-else class="picker-view"> <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> </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> </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="{ <req-comp :form="{
@@ -99,14 +75,6 @@
}" /> }" />
</scroll-view> </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="button-area" v-if="edit">
<view class="btn" @click="cancelPage">取消</view> <view class="btn" @click="cancelPage">取消</view>
<view class="btn reset" @click="getDetail(formData.id)">重置</view> <view class="btn reset" @click="getDetail(formData.id)">重置</view>
@@ -116,25 +84,15 @@
</template> </template>
<script> <script>
import { import { getPersonBase } from "@/packageRc/api/personinfo/index";
getPersonBase import { addPersonDemand, updatePersonDemand, getPersonDemand } from "@/packageRc/api/needs/personDemand";
} from "@/packageRc/api/personinfo/index"; import { listJobType } from "@/packageRc/api/jobType/index";
import {
addPersonDemand, import uniDateformat from '@/uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.vue';
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";
export default { export default {
components: { components: {
// ChoosePerson, // ChoosePerson
// ImageUpload
}, },
props: { props: {
needId: { needId: {
@@ -148,24 +106,20 @@
}, },
data() { data() {
return { return {
fileList: [],
edit: true, edit: true,
showTime: false,
personBase: {}, personBase: {},
hopeSolveDate: Number(new Date()),
dates: {},
formData: { formData: {
userId:"",
personName:"",
demandType: "3", demandType: "3",
personName: '', personName: '',
personId: "", personId: "",
userId: "", userId: "",
demandTitle: '', demandTitle: '',
isAcceptAssistance: '',
isAcceptApprovalResult: '',
personName: '',
qwpxsj: '', qwpxsj: '',
qwpxgz: '', qwpxgz: '',
qwpxgzName: '' qwpxgzName: '',
jobDescription: ''
}, },
rules: { rules: {
personName: [{ personName: [{
@@ -211,10 +165,27 @@
this.$refs.uForm.setRules(this.rules) this.$refs.uForm.setRules(this.rules)
}, },
created() { created() {
this.setName();
this.loading = true; this.loading = true;
this.workTypeRemoteMethod(''); this.workTypeRemoteMethod('');
}, },
methods: { 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() { cancelPage() {
if (this.formData.id) { if (this.formData.id) {
this.edit = false; this.edit = false;
@@ -235,14 +206,9 @@
this.formNameChange(); this.formNameChange();
this.$forceUpdate(); this.$forceUpdate();
}, },
confirmDate(e) { // 使用picker组件的日期选择
this.showTime = false; onDateChange(e) {
// 获取选中的日期 this.formData.qwpxsj = e.detail.value;
const date = e.value;
// 使用 uView 的 uTime 方法格式化日期,包含时分秒
const formattedDateTime = uni.$u.timeFormat(date, "yyyy-mm-dd");
// 设置表单数据
this.formData.qwpxsj = formattedDateTime;
}, },
changeFile(e) { changeFile(e) {
// 清空当前的 fileUrl 数组 // 清空当前的 fileUrl 数组
@@ -298,7 +264,7 @@
this.setWorkTypeIndexes(this.formData.qwpxgz); this.setWorkTypeIndexes(this.formData.qwpxgz);
} }
this.edit = false; this.edit = false;
this.fileList = this.$processFileUrl(this.formData.fileUrl)
}).catch(error => { }).catch(error => {
console.error('Error fetching training detail:', error); console.error('Error fetching training detail:', error);
}); });
@@ -337,6 +303,7 @@
this.$store.dispatch("GetInfo").then((res) => { this.$store.dispatch("GetInfo").then((res) => {
if (res.data.roles.indexOf('qunzhong') == -1) { if (res.data.roles.indexOf('qunzhong') == -1) {
this.canChoosePerson = true; this.canChoosePerson = true;
this.setName() // 确保非群众角色也能获取姓名
} else { } else {
this.canChoosePerson = false; this.canChoosePerson = false;
getPersonBase(res.data.user.userId).then(resp => { getPersonBase(res.data.user.userId).then(resp => {
@@ -349,35 +316,46 @@
} }
}) })
}, },
formNameChange() { setName() {
let date = new Date() this.formData.personName = this.name;
const dayNew = dayjs(date).format("YYYY-MM-DD"); this.formData.personId = this.needId;
this.formData.demandTitle = `${this.formData.personName}_于${dayNew}_提出培训需求` 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() { async saveInfo() {
try { try {
this.setName(); 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() === '') { if (!this.formData.qwpxgz || (typeof this.formData.qwpxgz === 'string' && this.formData.qwpxgz.trim() === '')) {
this.$u.toast('请选择培训意愿工种!'); uni.showToast({
title: '请选择培训意愿工种!',
icon: 'none'
});
return; return;
} }
// 手动检查期望培训时间是否已选择 // 手动检查期望培训时间是否已选择
if (!this.formData.qwpxsj || this.formData.qwpxsj.trim() === '') { if (!this.formData.qwpxsj || (typeof this.formData.qwpxsj === 'string' && this.formData.qwpxsj.trim() === '')) {
this.$u.toast('请选择期望培训时间!'); uni.showToast({
title: '请选择期望培训时间!',
icon: 'none'
});
return; return;
} }
// 表单字段已通过手动检查,无需额外验证
uni.showLoading({
// 验证表单 title: '加载中...'
const isValid = await this.$refs.uForm.validate(); });
if (!isValid) {
throw new Error('请检查必填项填写');
return
}
this.$showLoading();
let response; let response;
let successMessage; let successMessage;
this.formData.demandType = 3; this.formData.demandType = 3;
@@ -390,24 +368,42 @@
} }
// 检查响应码是否为200 // 检查响应码是否为200
if (response.code === 200) { if (response.code === 200) {
this.$u.toast(successMessage); uni.showToast({
title: successMessage,
icon: 'success'
});
// 如果是编辑模式,关闭编辑状态;否则返回上一页 // 如果是编辑模式,关闭编辑状态;否则返回上一页
if (this.formData.id) { if (this.formData.id) {
this.edit = false; this.edit = false;
} else { } else {
await this.$delay(1000); // 延迟1秒后返回上一页 setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
}, 1000);
} }
} else {
// 响应码不为200时显示服务器返回的错误信息或默认错误信息
uni.showToast({
title: response.msg || '操作失败,请重试!',
icon: 'none'
});
} }
} catch (error) { } catch (error) {
if(error.length){ console.error('保存失败:', error);
this.$u.toast('请填写完整信息!'); // 检查错误是否为字符串类型或有特定消息
if(typeof error === 'string' || (error && error.message && error.message.includes('请检查'))){
uni.showToast({
title: '请填写完整信息!',
icon: 'none'
});
} else { } else {
this.$u.toast('系统错误,请联系管理员!'); uni.showToast({
title: '系统错误,请联系管理员!',
icon: 'none'
});
} }
} finally { } finally {
// 确保加载页总是会被隐藏 // 确保加载页总是会被隐藏
this.$hideLoading(); uni.hideLoading();
} }
}, },
// getWorkTypeTree() { // getWorkTypeTree() {
@@ -500,19 +496,19 @@
const selectedLevel2 = this.workTypeColumns[1][indexes[1]]; const selectedLevel2 = this.workTypeColumns[1][indexes[1]];
const selectedLevel3 = this.workTypeColumns[2][indexes[2]]; const selectedLevel3 = this.workTypeColumns[2][indexes[2]];
// 使用$set确保响应式更新 // 直接赋值确保响应式更新
if (selectedLevel3) { if (selectedLevel3) {
// 选择第三级 // 选择第三级
this.$set(this.formData, 'qwpxgz', selectedLevel3.id); this.formData.qwpxgz = selectedLevel3.id;
this.$set(this.formData, 'qwpxgzName', `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}/${selectedLevel3.workTypeName}`); this.formData.qwpxgzName = `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}/${selectedLevel3.workTypeName}`;
} else if (selectedLevel2) { } else if (selectedLevel2) {
// 选择第二级 // 选择第二级
this.$set(this.formData, 'qwpxgz', selectedLevel2.id); this.formData.qwpxgz = selectedLevel2.id;
this.$set(this.formData, 'qwpxgzName', `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}`); this.formData.qwpxgzName = `${selectedLevel1.workTypeName}/${selectedLevel2.workTypeName}`;
} else if (selectedLevel1) { } else if (selectedLevel1) {
// 选择第一级 // 选择第一级
this.$set(this.formData, 'qwpxgz', selectedLevel1.id); this.formData.qwpxgz = selectedLevel1.id;
this.$set(this.formData, 'qwpxgzName', selectedLevel1.workTypeName); this.formData.qwpxgzName = selectedLevel1.workTypeName;
} }
this.workTypeIndexes = indexes; this.workTypeIndexes = indexes;
@@ -563,29 +559,46 @@
</script> </script>
<style lang="scss"> <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 { .page ::v-deep .u-navbar__content {
background-color: transparent !important; background-color: transparent !important;
} }
.container {
height: 100vh;
overflow: hidden;
background-color: #f7f7f7;
}
.page { .page {
background-color: #EEF1F5 !important; background-color: #3161c7;
height: 100vh; height: 100vh;
background-image: url('https://rc.jinan.gov.cn/qcwjyH5/static/images/top.png'); background-image: url('https://rc.jinan.gov.cn/qcwjyH5/static/images/top.png');
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% auto; background-size: 100% auto;
} }
.input-outer-part {
padding: 0 32rpx;
box-sizing: border-box;
}
.inner { .inner {
background: #eef1f5; background: #eef1f5;
border-radius: 16rpx; border-radius: 16rpx;
padding: 32rpx; padding: 32rpx;
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
.inner-part { .inner-part {
width: 100%; width: 100%;
} }
@@ -595,10 +608,129 @@
width: 100%; 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 { .button-area {
margin-top: 24rpx; 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 { .button-area {
padding: 24rpx 32rpx 68rpx; padding: 24rpx 32rpx 68rpx;
width: calc(100% + 64rpx); width: calc(100% + 64rpx);
@@ -652,28 +784,12 @@
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
width: 100%; 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 { .picker-view-text {
background: #f8f9fa;
border-color: #007aff;
}
.picker-view text {
color: #333333; color: #333333;
font-size: 28rpx; flex: 1;
text-align: left; font-size: 28rpx;
flex: 1; flex: 1;
} }
.picker-view .u-icon {
margin-left: 16rpx;
color: #999999;
}
</style> </style>