diff --git a/pages/appointment/appointment.js b/pages/appointment/appointment.js
index 8bd380b..6827d0f 100644
--- a/pages/appointment/appointment.js
+++ b/pages/appointment/appointment.js
@@ -15,10 +15,15 @@ Page({
date: '',
time: '',
hostName: '',
+ hostId: '',
area: ''
},
areas: ['A区-生产车间', 'B区-办公楼', 'C区-仓储区', 'D区-研发中心', 'E区-综合区'],
+ areaMap: { 'A区-生产车间': 'A', 'B区-办公楼': 'B', 'C区-仓储区': 'C', 'D区-研发中心': 'D', 'E区-综合区': 'E' },
areaIndex: -1,
+ persons: [],
+ personNames: [],
+ personIndex: -1,
today: '',
submitting: false
},
@@ -53,10 +58,53 @@ Page({
onAreaChange(e) {
const index = Number(e.detail.value)
+ const areaName = this.data.areas[index]
+ const department = this.data.areaMap[areaName]
this.setData({
areaIndex: index,
- 'form.area': this.data.areas[index]
+ 'form.area': areaName,
+ 'form.hostId': '',
+ 'form.hostName': '',
+ persons: [],
+ personNames: [],
+ personIndex: -1
})
+ if (department) {
+ this.loadPersons(department)
+ }
+ },
+
+ async loadPersons(department) {
+ wx.showLoading({ title: '加载被访人中...' })
+ try {
+ const list = await appointmentDB.getPersonSelector(department)
+ const persons = list.map(item => ({
+ personId: item.personId,
+ personName: item.personName
+ }))
+ this.setData({
+ persons,
+ personNames: persons.map(p => p.personName),
+ personIndex: -1
+ })
+ } catch (err) {
+ console.error('获取被访人列表失败', err)
+ wx.showToast({ title: '获取被访人列表失败', icon: 'none' })
+ } finally {
+ wx.hideLoading()
+ }
+ },
+
+ onPersonChange(e) {
+ const index = Number(e.detail.value)
+ const person = this.data.persons[index]
+ if (person) {
+ this.setData({
+ personIndex: index,
+ 'form.hostId': person.personId,
+ 'form.hostName': person.personName
+ })
+ }
},
onDateChange(e) {
@@ -94,7 +142,7 @@ Page({
return false
}
if (!hostName.trim()) {
- wx.showToast({ title: '请输入被访人姓名', icon: 'none' })
+ wx.showToast({ title: '请选择被访人', icon: 'none' })
return false
}
if (!area) {
diff --git a/pages/appointment/appointment.wxml b/pages/appointment/appointment.wxml
index 69dcda8..efdac13 100644
--- a/pages/appointment/appointment.wxml
+++ b/pages/appointment/appointment.wxml
@@ -47,10 +47,6 @@
被访人信息
-
- 被访人
-
-
拜访区域
@@ -60,6 +56,19 @@
+
+ 被访人
+
+
+ {{personIndex >= 0 ? personNames[personIndex] : '请选择被访人'}}
+ ›
+
+
+
+ 请先选择拜访区域
+
+
+
diff --git a/utils/api.js b/utils/api.js
index 2e37d1b..1f47f08 100644
--- a/utils/api.js
+++ b/utils/api.js
@@ -183,6 +183,20 @@ const appointmentDB = {
data: { id }
})
return mapApiRecord(data) || null
+ },
+
+ /**
+ * 获取被访人列表
+ * @param {string} department - 部门/区域编码
+ * @returns {Promise} 被访人列表
+ */
+ async getPersonSelector(department) {
+ const data = await request({
+ url: BASE_URL + API.PERSON_SELECTOR,
+ method: 'GET',
+ data: { department }
+ })
+ return data || []
}
}
diff --git a/utils/config.js b/utils/config.js
index 2405283..3e06bd8 100644
--- a/utils/config.js
+++ b/utils/config.js
@@ -6,7 +6,8 @@ const ENV_CONFIG = {
// release: 'https://xcx.yun.588580.xyz',
trial: 'https://qywx.yun.588580.xyz',
// 开发版 & 体验版
- develop: 'http://172.16.60.235:8080'
+ // develop: 'http://172.16.60.235:8080'
+ develop: 'http://10.50.13.191:8080'
}
// 自动判断当前运行环境
@@ -27,7 +28,8 @@ const API = {
APPOINTMENT_CREATE: '/api/wx-mini/appointment/create',
APPOINTMENT_CANCEL: '/api/wx-mini/appointment/cancel',
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail',
- WXACODE: '/api/wx-mini/wxacode'
+ WXACODE: '/api/wx-mini/wxacode',
+ PERSON_SELECTOR: '/api/wx-mini/appointment/person/selector'
}
console.log('[config] 当前环境:', wx.getAccountInfoSync().miniProgram.envVersion, 'BASE_URL:', BASE_URL)