From d66216c669ac671c96f11a58a30471f21d38ff43 Mon Sep 17 00:00:00 2001 From: 18154758993 <605281283@qq.com> Date: Wed, 8 Oct 2025 16:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=84=E7=90=86=E6=84=8F?= =?UTF-8?q?=E8=A7=81=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/flow-step/flow-step.vue | 69 +++++- package.json | 2 + pages/sub/StuApply.vue | 32 ++- pages/sub/StudoEdit.vue | 313 ++++++++++++++++++++++++++-- static/data/province-city-county.js | 93 +++++++++ 5 files changed, 482 insertions(+), 27 deletions(-) create mode 100644 static/data/province-city-county.js diff --git a/components/flow-step/flow-step.vue b/components/flow-step/flow-step.vue index c8d3c14..df1c2b9 100644 --- a/components/flow-step/flow-step.vue +++ b/components/flow-step/flow-step.vue @@ -6,8 +6,18 @@ - {{step.taskName}}: - {{step.assigneeName}} + + {{step.taskName}}: + {{step.assigneeName}} + + + 处理意见: + {{step.comment.comment}} + + + 处理时间: + {{step.finishTime}} + @@ -51,11 +61,12 @@ .step { display: flex; - align-items: center; + align-items: flex-start; margin-bottom: 50rpx; .icon { width: 35rpx; + margin-top: 5rpx; } .line { @@ -66,9 +77,55 @@ .right { flex: 1.4; - text:first-child { - color: #9E9E9E; - margin-right: 10rpx; + .step-header { + display: flex; + align-items: center; + margin-bottom: 10rpx; + + .task-name { + color: #9E9E9E; + margin-right: 10rpx; + font-size: 28rpx; + } + + .assignee-name { + color: #333; + font-size: 28rpx; + font-weight: 500; + } + } + + .comment { + margin-bottom: 8rpx; + padding: 8rpx 12rpx; + background-color: #f8f9fa; + border-radius: 8rpx; + border-left: 3rpx solid #007aff; + + .comment-label { + color: #666; + font-size: 24rpx; + margin-right: 8rpx; + } + + .comment-text { + color: #333; + font-size: 26rpx; + line-height: 1.4; + } + } + + .finish-time { + .time-label { + color: #999; + font-size: 22rpx; + margin-right: 8rpx; + } + + .time-text { + color: #666; + font-size: 22rpx; + } } } } diff --git a/package.json b/package.json index de63eeb..b5057d8 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,11 @@ "@dcloudio/uni-migration": "^2.0.2-4070520250711001", "@dcloudio/uni-stat": "^2.0.2-4070520250711001", "@dcloudio/vue-cli-plugin-uni": "^2.0.2-4070520250711001", + "@dcloudio/webpack-uni-pages-loader": "^2.0.2-4070620250821001", "@vue/cli-service": "^5.0.8", "@wecom/jssdk": "^2.3.1", "axios": "^1.11.0", + "china-area-data": "^5.0.1", "dompurify": "^3.2.6", "markdown-it": "^14.1.0", "weixin-js-sdk": "^1.6.5" diff --git a/pages/sub/StuApply.vue b/pages/sub/StuApply.vue index 697bf99..f0291ab 100644 --- a/pages/sub/StuApply.vue +++ b/pages/sub/StuApply.vue @@ -363,11 +363,19 @@ this.getDicts(); }, methods: { - getDicts() { - let res = getDicts("more_dept_name"); - if (res.code == 200) { - console.log('res:',res) - this.moreDeptList = [...res.data]; + async getDicts() { + try { + let res = await getDicts("more_dept_name"); + if (res.code == 200) { + console.log('res:',res) + this.moreDeptList = [...res.data]; + } else { + console.error('获取部门字典数据失败:', res); + this.moreDeptList = []; + } + } catch (error) { + console.error('获取部门字典数据异常:', error); + this.moreDeptList = []; } }, async getOwnFamily() { @@ -733,7 +741,19 @@ this.formData.className = this.ownClassName; this.formData.name = this.ownName; this.formData.stuNo = this.ownStuNo; - this.formData.moreDeptName = this.moreDeptList.filter(x => x.dictValue.includes(this.ownDeptName))[0].dictValue; + + // 安全检查:确保moreDeptList存在且不为空,并且能找到匹配的部门 + if (this.moreDeptList && this.moreDeptList.length > 0 && this.ownDeptName) { + const matchedDept = this.moreDeptList.filter(x => x && x.dictValue && x.dictValue.includes(this.ownDeptName)); + if (matchedDept.length > 0) { + this.formData.moreDeptName = matchedDept[0].dictValue; + } else { + // 如果没有找到匹配的部门,使用第一个部门或者设置为空 + this.formData.moreDeptName = this.moreDeptList[0] && this.moreDeptList[0].dictValue ? this.moreDeptList[0].dictValue : ''; + } + } else { + this.formData.moreDeptName = ''; + } } // console.log("doEdit", this.formData) // this.lookV = true; diff --git a/pages/sub/StudoEdit.vue b/pages/sub/StudoEdit.vue index 89c05f8..a61076b 100644 --- a/pages/sub/StudoEdit.vue +++ b/pages/sub/StudoEdit.vue @@ -128,7 +128,41 @@ - + + + + + + + + + + + + + + + + + + + + @@ -230,6 +264,18 @@ + + + + + + + + + @@ -240,23 +286,29 @@ import DateTimePicker from "@/components/DateTimePicker.vue"; import { - stuGetRecordBySvId, - stuLeaveApply, - stuHomeUpdate, - } from '@/api/sur'; - import { - getWxConfig - } from "@/api/common/wechat"; + getWxConfig +} from "@/api/common/wechat"; +import { + stuGetRecordBySvId, + stuHomeUpdate, + stuLeaveApply, +} from '@/api/sur'; import { - getDicts - } from "@/api/system/dict/data.js"; + isEmpty, + isValidPhone +} from "@/api/helpFunc/index.js"; +import { + getDicts +} from "@/api/system/dict/data.js"; + import { - isEmpty, - isValidPhone - } from "@/api/helpFunc/index.js"; + getCitiesByProvince, + getCountiesByCity, + provinceData +} from "@/static/data/province-city-county.js"; - import * as ww from '@wecom/jssdk' + import * as ww from '@wecom/jssdk'; export default { components: { DateTimePicker @@ -275,6 +327,25 @@ showDeptPicker: false, //院校选择器 showCalendar: false, //离校日期选择器 modeCalendar: "range", + // 省市县联动相关数据 + provinceList: [], + cityList: [], + countyList: [], + selectedProvinceIndex: 0, + selectedCityIndex: 0, + selectedCountyIndex: 0, + // 省市县选择弹窗控制 + showProvincePicker: false, + showCityPicker: false, + showCountyPicker: false, + // 显示的省市县名称 + selectedProvinceName: '', + selectedCityName: '', + selectedCountyName: '', + // 临时存储选中的省市县信息 + tempProvince: '', + tempCity: '', + tempCounty: '', } }, computed: { @@ -295,6 +366,7 @@ this.getstuGetRecordBySvId() } this.initWxConfig(); // 初始化微信配置 + this.initLocationData(); // 初始化省市县数据 }, async onShow() { this.getDicts(); @@ -446,7 +518,16 @@ if (isEmpty(sdata.willAddr)) { uni.showToast({ - title: "请输入去向地", + title: "请选择去向地", + icon: "none", + mask: true + }); + return; + } + + if (isEmpty(sdata.willDetailAddr)) { + uni.showToast({ + title: "请输入详细地址", icon: "none", mask: true }); @@ -575,6 +656,10 @@ that.formData = { ...res.data }; + // 数据加载完成后,解析地址信息 + if (that.formData.willAddr) { + that.parseAddressFromWillAddr(that.formData.willAddr); + } that.$forceUpdate(); } }); @@ -657,6 +742,174 @@ } }); }, + + // 初始化省市县数据 + initLocationData() { + // 初始化省份列表 + this.provinceList = provinceData.map(province => ({ + label: province.label, + value: province.value + })); + + // 如果formData中已有地址数据,则初始化选中状态 + if (this.formData.willAddr) { + this.initSelectedLocation(); + } + }, + + // 初始化已选择的省市县 + initSelectedLocation() { + // 如果willAddr已有值,尝试解析省市县信息 + if (this.formData.willAddr) { + this.parseAddressFromWillAddr(this.formData.willAddr); + } + }, + + // 从willAddr解析省市区县信息 + parseAddressFromWillAddr(address) { + if (!address) return; + + // 遍历省份数据,尝试匹配 + for (let province of this.provinceList) { + if (address.includes(province.label)) { + // 找到匹配的省份 + this.selectedProvinceName = province.label; + this.tempProvince = province.value; + + // 更新城市列表 + this.cityList = getCitiesByProvince(province.value); + + // 尝试匹配城市 + for (let city of this.cityList) { + if (address.includes(city.label)) { + // 找到匹配的城市 + this.selectedCityName = city.label; + this.tempCity = city.value; + + // 更新区县列表 + this.countyList = getCountiesByCity(city.value); + + // 尝试匹配区县 + for (let county of this.countyList) { + if (address.includes(county.label)) { + // 找到匹配的区县 + this.selectedCountyName = county.label; + this.tempCounty = county.value; + break; + } + } + break; + } + } + break; + } + } + }, + + // 合并省市县为完整地址 + combineLocation() { + if (this.selectedProvinceName && this.selectedCityName && this.selectedCountyName) { + this.formData.willAddr = `${this.selectedProvinceName}${this.selectedCityName}${this.selectedCountyName}`; + } else if (this.selectedProvinceName && this.selectedCityName) { + this.formData.willAddr = `${this.selectedProvinceName}${this.selectedCityName}`; + } else if (this.selectedProvinceName) { + this.formData.willAddr = this.selectedProvinceName; + } + }, + + // 省份选择确认 + onProvinceConfirm(e) { + const selectedLabel = e.value[0]; + this.selectedProvinceName = selectedLabel; + + // 根据选中的标签找到对应的省份数据 + const selectedProvince = this.provinceList.find(province => province.label === selectedLabel); + if (selectedProvince) { + this.formData.willProvince = selectedProvince.label; + this.tempProvince = selectedProvince.value; + + // 更新城市列表 + this.cityList = getCitiesByProvince(selectedProvince.value); + + // 重置城市和区县选择 + this.selectedCityName = ''; + this.selectedCountyName = ''; + this.formData.willCity = ''; + this.formData.willCounty = ''; + this.tempCity = ''; + this.tempCounty = ''; + this.countyList = []; + + // 合并地址 + this.combineLocation(); + } + this.showProvincePicker = false; + }, + + // 城市选择确认 + onCityConfirm(e) { + const selectedLabel = e.value[0]; + this.selectedCityName = selectedLabel; + + // 根据选中的标签找到对应的城市数据 + const selectedCity = this.cityList.find(city => city.label === selectedLabel); + if (selectedCity) { + this.formData.willCity = selectedCity.label; + this.tempCity = selectedCity.value; + + // 更新区县列表 + this.countyList = getCountiesByCity(selectedCity.value); + + // 重置区县选择 + this.selectedCountyName = ''; + this.formData.willCounty = ''; + this.tempCounty = ''; + + // 合并地址 + this.combineLocation(); + } + this.showCityPicker = false; + }, + + // 区县选择确认 + onCountyConfirm(e) { + const selectedLabel = e.value[0]; + this.selectedCountyName = selectedLabel; + + // 根据选中的标签找到对应的区县数据 + const selectedCounty = this.countyList.find(county => county.label === selectedLabel); + if (selectedCounty) { + this.formData.willCounty = selectedCounty.label; + this.tempCounty = selectedCounty.value; + + // 合并地址 + this.combineLocation(); + } + this.showCountyPicker = false; + }, + + // 显示省份选择器 + showProvinceSelector() { + this.showProvincePicker = true; + }, + + // 显示城市选择器 + showCitySelector() { + if (this.cityList.length > 0) { + this.showCityPicker = true; + } else { + this.$u.toast('请先选择省份'); + } + }, + + // 显示区县选择器 + showCountySelector() { + if (this.countyList.length > 0) { + this.showCountyPicker = true; + } else { + this.$u.toast('请先选择城市'); + } + }, } } @@ -725,4 +978,34 @@ gap: 20rpx; align-items: center; } + + .location-selector { + width: 100%; + + .location-row { + display: flex; + gap: 10rpx; + align-items: center; + + .input-wrapper { + flex: 1; + min-width: 0; + cursor: pointer; + } + + .u-picker { + flex: 1; + min-width: 0; + } + } + + .selected-location { + margin-top: 10rpx; + padding: 16rpx 24rpx; + background-color: #f5f5f5; + border-radius: 8rpx; + font-size: 28rpx; + color: #666; + } + } \ No newline at end of file diff --git a/static/data/province-city-county.js b/static/data/province-city-county.js new file mode 100644 index 0000000..69f6f05 --- /dev/null +++ b/static/data/province-city-county.js @@ -0,0 +1,93 @@ +// 使用china-area-data包提供完整的省市区数据 +import areaData from 'china-area-data'; + +// 转换数据格式为我们需要的格式 +function convertAreaData() { + const provinces = []; + + // 遍历省份 + Object.keys(areaData['86']).forEach(provinceCode => { + const provinceName = areaData['86'][provinceCode]; + const province = { + value: provinceCode, + label: provinceName, + children: [] + }; + + // 遍历城市 + if (areaData[provinceCode]) { + Object.keys(areaData[provinceCode]).forEach(cityCode => { + const cityName = areaData[provinceCode][cityCode]; + const city = { + value: cityCode, + label: cityName, + children: [] + }; + + // 遍历区县 + if (areaData[cityCode]) { + Object.keys(areaData[cityCode]).forEach(countyCode => { + const countyName = areaData[cityCode][countyCode]; + city.children.push({ + value: countyCode, + label: countyName + }); + }); + } + + province.children.push(city); + }); + } + + provinces.push(province); + }); + + return provinces; +} + +// 生成完整的省市区数据 +const provinceData = convertAreaData(); + +// 根据省份代码获取城市列表 +function getCitiesByProvince(provinceCode) { + const province = provinceData.find(p => p.value === provinceCode); + return province ? province.children : []; +} + +// 根据城市代码获取区县列表 +function getCountiesByCity(cityCode) { + for (const province of provinceData) { + const city = province.children.find(c => c.value === cityCode); + if (city) { + return city.children; + } + } + return []; +} + +// 根据代码获取名称 +function getNameByCode(code) { + // 查找省份 + for (const province of provinceData) { + if (province.value === code) { + return province.label; + } + // 查找城市 + for (const city of province.children) { + if (city.value === code) { + return city.label; + } + // 查找区县 + if (city.children) { + for (const county of city.children) { + if (county.value === code) { + return county.label; + } + } + } + } + } + return ''; +} + +export { provinceData, getCitiesByProvince, getCountiesByCity, getNameByCode }; \ No newline at end of file