增加被访区域下拉框值api接口
This commit is contained in:
@@ -20,8 +20,8 @@ Page({
|
||||
area: '',
|
||||
plateNumber: ''
|
||||
},
|
||||
areas: ['A区-生产车间', 'B区-办公楼', 'C区-仓储区', 'D区-研发中心', 'E区-综合区'],
|
||||
areaMap: { 'A区-生产车间': 'A', 'B区-办公楼': 'B', 'C区-仓储区': 'C', 'D区-研发中心': 'D', 'E区-综合区': 'E' },
|
||||
areas: [],
|
||||
departments: [],
|
||||
areaIndex: -1,
|
||||
persons: [],
|
||||
personNames: [],
|
||||
@@ -54,6 +54,24 @@ Page({
|
||||
// 使用本地时区获取当天日期,用于 picker 最小日期限制
|
||||
const today = formatDate(new Date())
|
||||
this.setData({ today })
|
||||
this.loadDepartments()
|
||||
},
|
||||
|
||||
async loadDepartments() {
|
||||
try {
|
||||
const list = await appointmentDB.getDepartmentSelector()
|
||||
const departments = list.map(item => ({
|
||||
departmentCode: item.departmentCode,
|
||||
departmentName: item.departmentName
|
||||
}))
|
||||
this.setData({
|
||||
departments,
|
||||
areas: departments.map(d => d.departmentName)
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('获取拜访区域列表失败', err)
|
||||
wx.showToast({ title: '获取拜访区域失败', icon: 'none' })
|
||||
}
|
||||
},
|
||||
|
||||
showLoginTipAndGoBack() {
|
||||
@@ -88,11 +106,11 @@ Page({
|
||||
|
||||
onAreaChange(e) {
|
||||
const index = Number(e.detail.value)
|
||||
const areaName = this.data.areas[index]
|
||||
const department = this.data.areaMap[areaName]
|
||||
const department = this.data.departments[index]
|
||||
const departmentCode = department ? department.departmentCode : ''
|
||||
this.setData({
|
||||
areaIndex: index,
|
||||
'form.area': areaName,
|
||||
'form.area': department ? department.departmentName : '',
|
||||
'form.hostId': '',
|
||||
'form.hostName': '',
|
||||
'form.personId': '',
|
||||
@@ -100,8 +118,8 @@ Page({
|
||||
personNames: [],
|
||||
personIndex: -1
|
||||
})
|
||||
if (department) {
|
||||
this.loadPersons(department)
|
||||
if (departmentCode) {
|
||||
this.loadPersons(departmentCode)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user