主要更新uniapp相关功能
This commit is contained in:
1 parent
aa92ca40a2
commit
5b4dbb2b46
65 files changed
+8532
-1921
No files matched your search
+20
-1
@@ -21,10 +21,15 @@ export function login(data) {
|
||||
|
||||
/** 统一认证:账号密码登录 */
|
||||
export function loginUAC(data) {
|
||||
// 小程序端与一键登录同用 yz-miniapp:后端据此跳过极验(小程序无 SDK 支持)
|
||||
let clientId = 'yz-uniapp'
|
||||
// #ifdef MP-WEIXIN
|
||||
clientId = 'yz-miniapp'
|
||||
// #endif
|
||||
return request({
|
||||
url: '/auth/login',
|
||||
method: 'POST',
|
||||
data: Object.assign({ client_id: 'yz-uniapp' }, data)
|
||||
data: Object.assign({ client_id: clientId }, data)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -113,6 +118,20 @@ export function loginByMiniapp({ code, phoneCode = '' } = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 已登录态下把当前微信 openid 绑定到该账号(静默调用,失败不提示)。
|
||||
* 小程序认证中 / 未开通手机号能力时,一键登录靠这条绑定按 openid 认人。
|
||||
*/
|
||||
export function bindMiniapp(data) {
|
||||
return request({
|
||||
url: '/auth/wechat/miniapp/bind',
|
||||
method: 'POST',
|
||||
data: Object.assign({ client_id: 'yz-miniapp' }, data),
|
||||
silent: true,
|
||||
timeout: 8000
|
||||
})
|
||||
}
|
||||
|
||||
/** 统一认证:刷新访问令牌 */
|
||||
export function refreshTokenUAC(data) {
|
||||
return request({
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 通讯录(移动端)接口封装。
|
||||
* 对应后端 go/controllers/app_contact.go 的 /app/oa/contact/* 只读接口。
|
||||
*/
|
||||
import { request } from '@/api/request.js'
|
||||
|
||||
/** 联系人类型:1-内部员工 2-外部联系人 */
|
||||
export const CONTACT_TYPE_OPTIONS = [
|
||||
{ value: 1, label: '内部' },
|
||||
{ value: 2, label: '外部' }
|
||||
]
|
||||
|
||||
export function getContactTypeLabel(value) {
|
||||
return Number(value) === 2 ? '外部' : '内部'
|
||||
}
|
||||
|
||||
/**
|
||||
* 多手机号格式化:JSON 数组 / 分隔符字符串 / 单个号码 → "138…、139…"(无内容返回空串)。
|
||||
* 与 Web 管理端 contact/index.vue 的 formatMobiles 口径保持一致。
|
||||
*/
|
||||
export function formatMobiles(val) {
|
||||
if (!val) return ''
|
||||
let arr = []
|
||||
if (Array.isArray(val)) {
|
||||
arr = val
|
||||
} else {
|
||||
const s = String(val).trim()
|
||||
if (!s) return ''
|
||||
try {
|
||||
const parsed = JSON.parse(s)
|
||||
arr = Array.isArray(parsed) ? parsed : [s]
|
||||
} catch (e) {
|
||||
arr = s.split(/[,,、;;\s]+/)
|
||||
}
|
||||
}
|
||||
return arr.map((m) => String(m || '').trim()).filter(Boolean).join('、')
|
||||
}
|
||||
|
||||
/** 取联系人首选号码:优先 phone,其次 mobiles 中的第一个 */
|
||||
export function primaryPhone(contact) {
|
||||
if (!contact) return ''
|
||||
const phone = String(contact.phone || '').trim()
|
||||
if (phone) return phone
|
||||
const first = formatMobiles(contact.mobiles)
|
||||
return first ? first.split('、')[0] : ''
|
||||
}
|
||||
|
||||
/** 分页查询通讯录 */
|
||||
export async function fetchContacts(params = {}) {
|
||||
const data = await request({
|
||||
url: '/app/oa/contact/list',
|
||||
data: {
|
||||
page: params.page || 1,
|
||||
pageSize: params.pageSize || 20,
|
||||
keyword: params.keyword || '',
|
||||
org_id: params.orgId || 0,
|
||||
contact_type: params.contactType || 0
|
||||
}
|
||||
})
|
||||
return { list: (data && data.list) || [], total: (data && data.total) || 0 }
|
||||
}
|
||||
|
||||
/** 组织架构树(含各部门内部联系人数量) */
|
||||
export function fetchContactOrgTree() {
|
||||
return request({ url: '/app/oa/contact/org-tree' })
|
||||
}
|
||||
|
||||
/** 联系人详情 */
|
||||
export function getContact(id) {
|
||||
return request({ url: `/app/oa/contact/${id}` })
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* OA 协同办公(移动端)接口封装。
|
||||
* 对应后端 go/controllers/app_oa.go 的 /app/oa/* 只读接口。
|
||||
*/
|
||||
import { request } from '@/api/request.js'
|
||||
|
||||
/** 公告类型:0-通知 1-公告 2-活动 */
|
||||
export const NOTICE_TYPE_OPTIONS = [
|
||||
{ value: 0, label: '通知' },
|
||||
{ value: 1, label: '公告' },
|
||||
{ value: 2, label: '活动' }
|
||||
]
|
||||
|
||||
/** 公告级别:0-普通 1-重要 2-紧急 */
|
||||
export const NOTICE_LEVEL_OPTIONS = [
|
||||
{ value: 0, label: '普通' },
|
||||
{ value: 1, label: '重要' },
|
||||
{ value: 2, label: '紧急' }
|
||||
]
|
||||
|
||||
/** 文档类型:与 models.DocType* 常量一致 */
|
||||
export const DOC_TYPE_OPTIONS = [
|
||||
{ value: 0, label: '其他', icon: 'file' },
|
||||
{ value: 1, label: '文档', icon: 'file-lines' },
|
||||
{ value: 2, label: '表格', icon: 'file-excel' },
|
||||
{ value: 3, label: '演示', icon: 'file-powerpoint' },
|
||||
{ value: 4, label: 'PDF', icon: 'file-pdf' },
|
||||
{ value: 5, label: '图片', icon: 'file-image' },
|
||||
{ value: 6, label: '压缩包', icon: 'file-zipper' },
|
||||
{ value: 7, label: '视频', icon: 'file-video' },
|
||||
{ value: 8, label: '音频', icon: 'file-audio' }
|
||||
]
|
||||
|
||||
/** 薪资单状态:0-草稿 1-已确认 2-已发放 3-已归档 */
|
||||
export const PAYROLL_STATUS_OPTIONS = [
|
||||
{ value: 0, label: '草稿' },
|
||||
{ value: 1, label: '已确认' },
|
||||
{ value: 2, label: '已发放' },
|
||||
{ value: 3, label: '已归档' }
|
||||
]
|
||||
|
||||
/** 在职状态:1-试用 2-正式 3-离职 */
|
||||
export const EMPLOYMENT_STATUS_OPTIONS = [
|
||||
{ value: 1, label: '试用' },
|
||||
{ value: 2, label: '正式' },
|
||||
{ value: 3, label: '离职' }
|
||||
]
|
||||
|
||||
/** 婚姻状况:0-未填 1-未婚 2-已婚 3-离异 4-丧偶 */
|
||||
export const MARITAL_STATUS_OPTIONS = [
|
||||
{ value: 0, label: '未填' },
|
||||
{ value: 1, label: '未婚' },
|
||||
{ value: 2, label: '已婚' },
|
||||
{ value: 3, label: '离异' },
|
||||
{ value: 4, label: '丧偶' }
|
||||
]
|
||||
|
||||
/** 档案子记录类型:1-教育经历 2-工作经历 3-合同信息 4-证照附件 */
|
||||
export const FILE_RECORD_TYPE_OPTIONS = [
|
||||
{ value: 1, label: '教育经历' },
|
||||
{ value: 2, label: '工作经历' },
|
||||
{ value: 3, label: '合同信息' },
|
||||
{ value: 4, label: '证照附件' }
|
||||
]
|
||||
|
||||
function labelOf(options, value, fallback = '') {
|
||||
const hit = options.find(item => item.value === Number(value))
|
||||
return hit ? hit.label : fallback
|
||||
}
|
||||
|
||||
export function getNoticeTypeLabel(value) {
|
||||
return labelOf(NOTICE_TYPE_OPTIONS, value, '通知')
|
||||
}
|
||||
|
||||
export function getNoticeLevelLabel(value) {
|
||||
return labelOf(NOTICE_LEVEL_OPTIONS, value, '普通')
|
||||
}
|
||||
|
||||
export function getPayrollStatusLabel(value) {
|
||||
return labelOf(PAYROLL_STATUS_OPTIONS, value, '草稿')
|
||||
}
|
||||
|
||||
export function getEmploymentStatusLabel(value) {
|
||||
return labelOf(EMPLOYMENT_STATUS_OPTIONS, value, '在职')
|
||||
}
|
||||
|
||||
export function getMaritalStatusLabel(value) {
|
||||
return labelOf(MARITAL_STATUS_OPTIONS, value, '未填')
|
||||
}
|
||||
|
||||
export function getFileRecordTypeLabel(value) {
|
||||
return labelOf(FILE_RECORD_TYPE_OPTIONS, value, '记录')
|
||||
}
|
||||
|
||||
export function getDocTypeMeta(value) {
|
||||
return DOC_TYPE_OPTIONS.find(item => item.value === Number(value)) || DOC_TYPE_OPTIONS[0]
|
||||
}
|
||||
|
||||
/** 文件大小人性化展示 */
|
||||
export function formatFileSize(size) {
|
||||
const bytes = Number(size) || 0
|
||||
if (bytes <= 0) return ''
|
||||
if (bytes < 1024) return bytes + ' B'
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
|
||||
if (bytes < 1024 * 1024 * 1024) return (bytes / 1024 / 1024).toFixed(1) + ' MB'
|
||||
return (bytes / 1024 / 1024 / 1024).toFixed(2) + ' GB'
|
||||
}
|
||||
|
||||
// ---------------- 通知公告 ----------------
|
||||
|
||||
export async function fetchNotices(params = {}) {
|
||||
const data = await request({
|
||||
url: '/app/oa/notice/list',
|
||||
data: {
|
||||
page: params.page || 1,
|
||||
pageSize: params.pageSize || 20,
|
||||
keyword: params.keyword || ''
|
||||
}
|
||||
})
|
||||
return { list: (data && data.list) || [], total: (data && data.total) || 0 }
|
||||
}
|
||||
|
||||
export function getNotice(id) {
|
||||
return request({ url: `/app/oa/notice/${id}` })
|
||||
}
|
||||
|
||||
// ---------------- 文档库 ----------------
|
||||
|
||||
export function fetchDocCategories(scope = 'shared') {
|
||||
return request({ url: '/app/oa/document/categories', data: { scope } })
|
||||
}
|
||||
|
||||
export async function fetchDocs(params = {}) {
|
||||
const data = await request({
|
||||
url: '/app/oa/document/list',
|
||||
data: {
|
||||
scope: params.scope || 'shared',
|
||||
keyword: params.keyword || '',
|
||||
category_id: params.categoryId || 0,
|
||||
uncategorized: params.uncategorized ? 1 : 0,
|
||||
mine: params.mine ? 1 : 0,
|
||||
star: params.star ? 1 : -1,
|
||||
page: params.page || 1,
|
||||
pageSize: params.pageSize || 20
|
||||
}
|
||||
})
|
||||
return { list: (data && data.list) || [], total: (data && data.total) || 0 }
|
||||
}
|
||||
|
||||
export function getDoc(id) {
|
||||
return request({ url: `/app/oa/document/${id}` })
|
||||
}
|
||||
|
||||
export function downloadDoc(id) {
|
||||
return request({ url: `/app/oa/document/download/${id}` })
|
||||
}
|
||||
|
||||
export function toggleDocStar(id) {
|
||||
return request({ url: `/app/oa/document/${id}/star`, method: 'POST' })
|
||||
}
|
||||
|
||||
// ---------------- 薪酬工资单(仅本人) ----------------
|
||||
|
||||
export async function fetchPayrolls(params = {}) {
|
||||
const data = await request({
|
||||
url: '/app/oa/compensation/payrolls',
|
||||
data: {
|
||||
payroll_month: params.payrollMonth || '',
|
||||
page: params.page || 1,
|
||||
pageSize: params.pageSize || 20
|
||||
}
|
||||
})
|
||||
return { list: (data && data.list) || [], total: (data && data.total) || 0 }
|
||||
}
|
||||
|
||||
export function getPayroll(id) {
|
||||
return request({ url: `/app/oa/compensation/payrolls/${id}` })
|
||||
}
|
||||
|
||||
// ---------------- 员工档案(仅本人) ----------------
|
||||
|
||||
export function getMyEmployeeFile() {
|
||||
return request({ url: '/app/oa/employee-file' })
|
||||
}
|
||||
@@ -47,6 +47,8 @@ export function normalizeSchedule(item) {
|
||||
content,
|
||||
remindChannels,
|
||||
remindMinutes: item.advance_minutes ?? item.remindMinutes ?? 15,
|
||||
repeatIntervalMinutes: item.repeat_interval_minutes ?? item.repeatIntervalMinutes ?? 0,
|
||||
maxSendCount: item.max_send_count ?? item.maxSendCount ?? 1,
|
||||
completed: item.is_finished ?? item.completed ?? false,
|
||||
datetime,
|
||||
createdAt,
|
||||
@@ -94,7 +96,9 @@ export async function createSchedule(data) {
|
||||
content: data.content,
|
||||
schedule_time: formatDateTime(data.datetime),
|
||||
remind_channels: channels,
|
||||
advance_minutes: data.remindMinutes ?? 15
|
||||
advance_minutes: data.remindMinutes ?? 15,
|
||||
repeat_interval_minutes: data.repeatIntervalMinutes ?? 0,
|
||||
max_send_count: data.maxSendCount ?? 1
|
||||
}
|
||||
})
|
||||
return res
|
||||
@@ -115,7 +119,9 @@ export async function updateSchedule(id, data) {
|
||||
content: data.content,
|
||||
schedule_time: formatDateTime(data.datetime),
|
||||
remind_channels: channels,
|
||||
advance_minutes: data.remindMinutes ?? 15
|
||||
advance_minutes: data.remindMinutes ?? 15,
|
||||
repeat_interval_minutes: data.repeatIntervalMinutes ?? 0,
|
||||
max_send_count: data.maxSendCount ?? 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user