增加被访区域下拉框值api接口
This commit is contained in:
@@ -20,8 +20,8 @@ Page({
|
|||||||
area: '',
|
area: '',
|
||||||
plateNumber: ''
|
plateNumber: ''
|
||||||
},
|
},
|
||||||
areas: ['A区-生产车间', 'B区-办公楼', 'C区-仓储区', 'D区-研发中心', 'E区-综合区'],
|
areas: [],
|
||||||
areaMap: { 'A区-生产车间': 'A', 'B区-办公楼': 'B', 'C区-仓储区': 'C', 'D区-研发中心': 'D', 'E区-综合区': 'E' },
|
departments: [],
|
||||||
areaIndex: -1,
|
areaIndex: -1,
|
||||||
persons: [],
|
persons: [],
|
||||||
personNames: [],
|
personNames: [],
|
||||||
@@ -54,6 +54,24 @@ Page({
|
|||||||
// 使用本地时区获取当天日期,用于 picker 最小日期限制
|
// 使用本地时区获取当天日期,用于 picker 最小日期限制
|
||||||
const today = formatDate(new Date())
|
const today = formatDate(new Date())
|
||||||
this.setData({ today })
|
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() {
|
showLoginTipAndGoBack() {
|
||||||
@@ -88,11 +106,11 @@ Page({
|
|||||||
|
|
||||||
onAreaChange(e) {
|
onAreaChange(e) {
|
||||||
const index = Number(e.detail.value)
|
const index = Number(e.detail.value)
|
||||||
const areaName = this.data.areas[index]
|
const department = this.data.departments[index]
|
||||||
const department = this.data.areaMap[areaName]
|
const departmentCode = department ? department.departmentCode : ''
|
||||||
this.setData({
|
this.setData({
|
||||||
areaIndex: index,
|
areaIndex: index,
|
||||||
'form.area': areaName,
|
'form.area': department ? department.departmentName : '',
|
||||||
'form.hostId': '',
|
'form.hostId': '',
|
||||||
'form.hostName': '',
|
'form.hostName': '',
|
||||||
'form.personId': '',
|
'form.personId': '',
|
||||||
@@ -100,8 +118,8 @@ Page({
|
|||||||
personNames: [],
|
personNames: [],
|
||||||
personIndex: -1
|
personIndex: -1
|
||||||
})
|
})
|
||||||
if (department) {
|
if (departmentCode) {
|
||||||
this.loadPersons(department)
|
this.loadPersons(departmentCode)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -187,6 +187,18 @@ const appointmentDB = {
|
|||||||
return mapApiRecord(data) || null
|
return mapApiRecord(data) || null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取被访部门/区域列表
|
||||||
|
* @returns {Promise<Array>} 部门列表
|
||||||
|
*/
|
||||||
|
async getDepartmentSelector() {
|
||||||
|
const data = await request({
|
||||||
|
url: BASE_URL + API.DEPARTMENT_SELECTOR,
|
||||||
|
method: 'GET'
|
||||||
|
})
|
||||||
|
return data || []
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取被访人列表
|
* 获取被访人列表
|
||||||
* @param {string} department - 部门/区域编码
|
* @param {string} department - 部门/区域编码
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const API = {
|
|||||||
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail',
|
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',
|
PERSON_SELECTOR: '/api/wx-mini/appointment/person/selector',
|
||||||
|
DEPARTMENT_SELECTOR: '/api/wx-mini/appointment/department/selector',
|
||||||
NOTIFY_HOST: '/visitor/notify-host'
|
NOTIFY_HOST: '/visitor/notify-host'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user