import { get, post, baseUrl } from '@/utils/request.js' import { useUserStore } from '@/store' /** * 请求单位工程 */ export const reqProjectWorkArea = (projectId)=>get(`BaseInfo/getProjectWorkArea?projectId=${projectId}`) /** * 请求焊口位置 */ export const reqWeldingLocation = ()=>get(`BaseInfo/getWeldingLocation`) /** * 根据项目ID单位类型请求单位 */ export const reqUnitByProjectIdUnitType = (projectId, unitType="")=>get(`Unit/getUnitByProjectIdUnitType?projectId=${projectId}&unitType=${unitType}`) /** * 获取待办 */ export const reqToDoItemByProjectIdUserId = (projectId, personId)=>get(`ToDoItem/getToDoItemByProjectIdUserId?projectId=${projectId}&personId=${personId}`) /** * 获取坡口类型列表 */ export const reqGetGrooveTypeList = ()=>get(`BaseInfo/GetGrooveType`) /** * 获取焊缝类型列表 */ export const reqGetWeldTypeList = () => get(`BaseInfo/GetWeldType`) /** * 按关键字分页查询入库明细条码 * @param {object} data * @param {string} data.barCodeKeyword - 条码关键字 * @param {number} data.pageIndex - 页码(从 1 开始) * @param {number} data.pageSize - 每页条数 */ export const reqGetInputDetailBarCodes = (data = {}) => get('BaseInfo/GetInputDetailBarCodes', { barCodeKeyword: data.barCodeKeyword ?? '', pageIndex: data.pageIndex ?? 1, pageSize: data.pageSize ?? 20, }) /** * 获取焊接方法列表 */ export const reqGetWeldingMethodList = () => get(`BaseInfo/GetWeldingMethod`) /** * 按类型获取焊接耗材 * @param {number} consumablesType - 焊材类型:1焊丝,2焊条 */ export const reqGetWeldingConsumables = (consumablesType) => get('BaseInfo/GetWeldingConsumables', { consumablesType }) /** * 附件上传 * @param {string} filePath - 本地文件路径 * @param {object} formData - 额外表单参数,如 { typeName: 'TestRecord', ... } * @param {function} onProgress - 上传进度回调 (progress: number) * @returns {Promise} 返回服务器返回的附件地址数组 */ 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) }) } }) }