| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * 管理端公共选项(审批人选人等)
- * 协议:门户信封 code===200
- */
- import { request, parseResponseJson } from '@/utils/request'
- function unwrap(res) {
- const body = parseResponseJson(res)
- if (!body || typeof body !== 'object') {
- throw new Error('接口响应异常')
- }
- if (body.code != null && body.code !== 200) {
- throw new Error(body.message || body.msg || '请求失败')
- }
- return body.data != null ? body.data : body
- }
- /**
- * @returns {Promise<Array<{ userId: string, nickName: string, userNo: string, label: string }>>}
- */
- export async function fetchUserOptions() {
- const res = await request({
- url: '/web/admin/users/options',
- method: 'GET'
- })
- const data = unwrap(res)
- const list = Array.isArray(data) ? data : []
- return list
- .map((item) => {
- const userId = String(item.value ?? item.userId ?? item.id ?? '')
- const nickName = String(item.nickName ?? item.label ?? item.userName ?? '')
- const userNo = String(item.userNo ?? item.userName ?? '')
- return {
- userId,
- nickName,
- userNo,
- label: nickName || userNo || userId
- }
- })
- .filter((u) => u.userId)
- }
|