重构(组织选择器): 提取通用请求参数并完善API文档
新增 getOrgFieldRequestParams 辅助函数统一组装公共参数,替换组件内重复的参数构造代码,补充API文档中的field_name参数注释
Showing
2 changed files
with
12 additions
and
3 deletions
| ... | @@ -26,6 +26,7 @@ export const getComponentAPI = (params) => fn(fetch.get(Api.QUERY_COMPONENT, par | ... | @@ -26,6 +26,7 @@ export const getComponentAPI = (params) => fn(fetch.get(Api.QUERY_COMPONENT, par |
| 26 | /** | 26 | /** |
| 27 | * @description: 查询部门列表 | 27 | * @description: 查询部门列表 |
| 28 | * @param: form_code 表单code | 28 | * @param: form_code 表单code |
| 29 | + * @param: field_name 字段名 | ||
| 29 | * { ...params, headers: { "only-data": true, "keep-data": true } } | 30 | * { ...params, headers: { "only-data": true, "keep-data": true } } |
| 30 | */ | 31 | */ |
| 31 | export const getFlowDeptListAPI = (params) => fn(fetch.get(Api.FLOW_DEPT_LIST, params)); | 32 | export const getFlowDeptListAPI = (params) => fn(fetch.get(Api.FLOW_DEPT_LIST, params)); |
| ... | @@ -33,6 +34,7 @@ export const getFlowDeptListAPI = (params) => fn(fetch.get(Api.FLOW_DEPT_LIST, p | ... | @@ -33,6 +34,7 @@ export const getFlowDeptListAPI = (params) => fn(fetch.get(Api.FLOW_DEPT_LIST, p |
| 33 | /** | 34 | /** |
| 34 | * @description: 查询角色列表 | 35 | * @description: 查询角色列表 |
| 35 | * @param: form_code 表单code | 36 | * @param: form_code 表单code |
| 37 | + * @param: field_name 字段名 | ||
| 36 | * { ...params, headers: { "only-data": true, "keep-data": true } } | 38 | * { ...params, headers: { "only-data": true, "keep-data": true } } |
| 37 | */ | 39 | */ |
| 38 | export const getFlowRoleListAPI = (params) => fn(fetch.get(Api.FLOW_ROLE_LIST, params)); | 40 | export const getFlowRoleListAPI = (params) => fn(fetch.get(Api.FLOW_ROLE_LIST, params)); |
| ... | @@ -40,6 +42,7 @@ export const getFlowRoleListAPI = (params) => fn(fetch.get(Api.FLOW_ROLE_LIST, p | ... | @@ -40,6 +42,7 @@ export const getFlowRoleListAPI = (params) => fn(fetch.get(Api.FLOW_ROLE_LIST, p |
| 40 | /** | 42 | /** |
| 41 | * @description: 查询用户部门角色 | 43 | * @description: 查询用户部门角色 |
| 42 | * @param: form_code 表单code | 44 | * @param: form_code 表单code |
| 45 | + * @param: field_name 字段名 | ||
| 43 | * @param: word 搜索内容 | 46 | * @param: word 搜索内容 |
| 44 | */ | 47 | */ |
| 45 | export const searchUserDeptRoleAPI = (params) => fn(fetch.get(Api.SEARCH_USER_DEPT_ROLE, params)); | 48 | export const searchUserDeptRoleAPI = (params) => fn(fetch.get(Api.SEARCH_USER_DEPT_ROLE, params)); | ... | ... |
| ... | @@ -362,14 +362,20 @@ onMounted(async () => { | ... | @@ -362,14 +362,20 @@ onMounted(async () => { |
| 362 | // }) | 362 | // }) |
| 363 | }); | 363 | }); |
| 364 | 364 | ||
| 365 | +const getOrgFieldRequestParams = (extraParams = {}) => ({ | ||
| 366 | + form_code: $route.query.code, | ||
| 367 | + field_name: props.key, | ||
| 368 | + ...extraParams, | ||
| 369 | +}); | ||
| 370 | + | ||
| 365 | const mountedLogic = async () => { | 371 | const mountedLogic = async () => { |
| 366 | await nextTick(); | 372 | await nextTick(); |
| 367 | // TAG: 获取后台数据 | 373 | // TAG: 获取后台数据 |
| 368 | - const flowDeptList = await getFlowDeptListAPI({ form_code: $route.query.code }); | 374 | + const flowDeptList = await getFlowDeptListAPI(getOrgFieldRequestParams()); |
| 369 | if (flowDeptList.code) { | 375 | if (flowDeptList.code) { |
| 370 | role_list = flowDeptList.data; | 376 | role_list = flowDeptList.data; |
| 371 | } | 377 | } |
| 372 | - const flowRoleList = await getFlowRoleListAPI({ form_code: $route.query.code }); | 378 | + const flowRoleList = await getFlowRoleListAPI(getOrgFieldRequestParams()); |
| 373 | if (flowRoleList.code) { | 379 | if (flowRoleList.code) { |
| 374 | dept_list = flowRoleList.data; | 380 | dept_list = flowRoleList.data; |
| 375 | } | 381 | } |
| ... | @@ -523,7 +529,7 @@ const is_search = ref(false); // 默认不显示搜索框 | ... | @@ -523,7 +529,7 @@ const is_search = ref(false); // 默认不显示搜索框 |
| 523 | const search_result_checked = ref([]); | 529 | const search_result_checked = ref([]); |
| 524 | 530 | ||
| 525 | const onSearchBlur = async () => { // 搜索框失去焦点 | 531 | const onSearchBlur = async () => { // 搜索框失去焦点 |
| 526 | - const { code, data } = await searchUserDeptRoleAPI({ form_code: $route.query.code, word: searchValue.value }) | 532 | + const { code, data } = await searchUserDeptRoleAPI(getOrgFieldRequestParams({ word: searchValue.value })) |
| 527 | if (code) { | 533 | if (code) { |
| 528 | // 单选模式 | 534 | // 单选模式 |
| 529 | if (check_type.value === 'single') { | 535 | if (check_type.value === 'single') { | ... | ... |
-
Please register or login to post a comment