105 lines
3.3 KiB
JavaScript
105 lines
3.3 KiB
JavaScript
import request from "./http";
|
||
|
||
const urlsConfig = {
|
||
corp: {
|
||
getCorpMemberHomepageInfo: 'getCorpMemberHomepageInfo',
|
||
getTeamBaseInfo: 'getTeamBaseInfo',
|
||
getTeamData: 'getTeamData',
|
||
getTeamBymember: 'getTeamBymember',
|
||
getCurrentTemplate: 'getCurrentTemplate',
|
||
wxAppLogin: 'wxAppLogin',
|
||
getDeptList: 'getRealDeptList',
|
||
getHospitalList: 'getRealHospital',
|
||
addCorpMember: 'addCorpMember',
|
||
getCorpMemberData: 'getCorpMemberData',
|
||
updateCorpMember: 'updateCorpMember'
|
||
},
|
||
|
||
knowledgeBase: {
|
||
getArticleByIds: 'getArticleByIds',
|
||
// 诊断库(对齐 ykt-management-mobile/src/api/knowledgeBase.js)
|
||
getDisease: 'getDisease',
|
||
},
|
||
member: {
|
||
addCustomer: 'add',
|
||
updateCustomer: 'update',
|
||
transferCustomers: 'transferCustomers',
|
||
getGroups: 'getGroups',
|
||
createGroup: 'createGroup',
|
||
updateGroup: 'updateGroup',
|
||
removeGroup: 'removeGroup',
|
||
sortGroups: 'sortGroups',
|
||
addGroupIdForMember: 'addGroupIdForMember',
|
||
bindMiniAppArchive: "bindMiniAppArchive",
|
||
getCustomerByCustomerId: 'getCustomerByCustomerId',
|
||
getMiniAppCustomers: 'getMiniAppCustomers',
|
||
getTeamCustomers: 'getTeamCustomers',
|
||
getUnbindMiniAppCustomers: 'getUnbindMiniAppCustomers',
|
||
searchCorpCustomer: 'searchCorpCustomer',
|
||
searchCorpCustomerWithFollowTime: 'searchCorpCustomerWithFollowTime',
|
||
unbindMiniAppArchive: 'unbindMiniAppArchive',
|
||
// 健康档案相关接口(对齐 ykt-management-mobile/src/api/member.js)
|
||
addMedicalRecord: 'addMedicalRecord',
|
||
getMedicalRecordById: 'getMedicalRecordById',
|
||
updateMedicalRecord: 'updateMedicalRecord',
|
||
removeMedicalRecord: 'removeMedicalRecord',
|
||
getCustomerMedicalRecord: 'getCustomerMedicalRecord',
|
||
},
|
||
wecom: {
|
||
addContactWay: 'addContactWay'
|
||
},
|
||
im: {
|
||
getUserSig: 'getUserSig',
|
||
sendSystemMessage: "sendSystemMessage",
|
||
getChatRecordsByGroupId: "getChatRecordsByGroupId"
|
||
},
|
||
todo: {
|
||
getCustomerTodos: 'getCustomerTodos',
|
||
getTodoById: 'getTodoById',
|
||
setTodoStatus: 'setTodoStatus',
|
||
updateTaskTodoResult: 'updateTaskTodoResult',
|
||
updateEvent: 'updateEvent',
|
||
removeTodo: 'removeTodo',
|
||
createEvents: 'createEvents',
|
||
executeManagementPlanTodo: 'executeManagementPlanTodo',
|
||
getManagementPlan: 'getManagementPlan',
|
||
getManagementPlanById: 'getManagementPlanById',
|
||
getNextFollowUpTime: 'getNextFollowUpTime',
|
||
// 服务记录(对齐 ykt-management-mobile/src/api/todo.js)
|
||
getServiceRecord: 'getServiceRecord',
|
||
addServiceRecord: 'addServiceRecord',
|
||
updateServiceRecord: 'updateServiceRecord',
|
||
removeServiceRecord: 'removeServiceRecord',
|
||
}
|
||
|
||
}
|
||
const urls = Object.keys(urlsConfig).reduce((acc, path) => {
|
||
const config = urlsConfig[path] || {};
|
||
const keys = Object.keys(config);
|
||
keys.forEach((key) => {
|
||
const data = acc[key];
|
||
if (data) {
|
||
throw new Error(`${data[0]}.${data[1]}和${path}.${url}重复了`)
|
||
}
|
||
acc[key] = [path, config[key]]
|
||
return acc
|
||
})
|
||
return acc
|
||
}, {})
|
||
console.log('urls: ', urls)
|
||
|
||
export default async function api(urlId, data) {
|
||
const config = urls[urlId];
|
||
if (!config) {
|
||
throw new Error(`Unknown URL ID: ${urlId}`);
|
||
}
|
||
const [path, type] = config;
|
||
return request({
|
||
url: `/getYoucanData/${path}`,
|
||
data: {
|
||
...data,
|
||
type,
|
||
}
|
||
})
|
||
}
|