Files
sh-app/api/base.js
T

68 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-06-10 14:17:54 +08:00
import {
get,
2026-06-24 16:50:38 +08:00
post,
baseUrl
2026-06-10 14:17:54 +08:00
} from '@/utils/request.js'
2026-06-24 16:50:38 +08:00
import { useUserStore } from '@/store'
2026-06-10 14:17:54 +08:00
/**
* 请求单位工程
*/
2026-06-11 09:43:42 +08:00
export const reqProjectWorkArea = (projectId)=>get(`BaseInfo/getProjectWorkArea?projectId=${projectId}`)
/**
2026-06-11 14:11:56 +08:00
* 请求焊口位置
2026-06-11 09:43:42 +08:00
*/
2026-06-11 14:11:56 +08:00
export const reqWeldingLocation = ()=>get(`BaseInfo/getWeldingLocation`)
/**
* 根据项目ID单位类型请求单位
*/
2026-06-16 19:26:48 +08:00
export const reqUnitByProjectIdUnitType = (projectId, unitType="")=>get(`Unit/getUnitByProjectIdUnitType?projectId=${projectId}&unitType=${unitType}`)
/**
* 获取待办
*/
2026-06-24 16:50:38 +08:00
export const reqToDoItemByProjectIdUserId = (projectId, personId)=>get(`ToDoItem/getToDoItemByProjectIdUserId?projectId=${projectId}&personId=${personId}`)
/**
* 附件上传
* @param {string} filePath - 本地文件路径
* @param {object} formData - 额外表单参数,如 { typeName: 'TestRecord', ... }
* @param {function} onProgress - 上传进度回调 (progress: number)
* @returns {Promise<array>} 返回服务器返回的附件地址数组
*/
export const uploadAttach = (filePath, formData = {}, onProgress) => {
return new Promise((resolve, reject) => {
const userStore = useUserStore()
const uploadTask = uni.uploadFile({
url: `${baseUrl}FileUpload/Post`,
filePath,
name: 'files',
formData,
header: {
'Content-Type': 'multipart/form-data',
'accept': 'application/json',
'token': userStore.token
},
success: (res) => {
try {
const data = JSON.parse(res.data)
resolve(data)
} catch (e) {
reject(new Error('解析上传响应失败'))
}
},
fail: (e) => {
reject(e)
}
})
if (onProgress) {
uploadTask.onProgressUpdate((res) => {
onProgress(res.progress)
})
}
})
}