diff --git a/api/base.js b/api/base.js index bd3ecd8..72643e7 100644 --- a/api/base.js +++ b/api/base.js @@ -1,7 +1,10 @@ import { get, - post + post, + baseUrl } from '@/utils/request.js' +import { useUserStore } from '@/store' + /** * 请求单位工程 @@ -21,4 +24,45 @@ export const reqUnitByProjectIdUnitType = (projectId, unitType="")=>get(`Unit/ge /** * 获取待办 */ -export const reqToDoItemByProjectIdUserId = (projectId, personId)=>get(`ToDoItem/getToDoItemByProjectIdUserId?projectId=${projectId}&personId=${personId}`) \ No newline at end of file +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} 返回服务器返回的附件地址数组 + */ +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) + }) + } + }) +} \ No newline at end of file diff --git a/api/hj.js b/api/hj.js index a8e3d1c..ec9b04b 100644 --- a/api/hj.js +++ b/api/hj.js @@ -17,8 +17,8 @@ export const reqGetWeldJointByWeldJointId = (id) => get(`PipeJoint/getWeldJointB /** * 焊接日报填报 */ -export const reqSaveWeldingDailyByWeldJointId = (data) => get( - `PreWeldingDaily/SaveWeldingDailyByWeldJointId?WeldJointId=${data.WeldJointId||''}&Personid=${data.Personid||''}&time=${data.time||''}&weldingLocation=${data.weldingLocation||''}&welderType=${data.welderType||''}` +export const reqSaveWeldingDailyByWeldJointId = (data={}) => post( + `PreWeldingDaily/SaveWeldingDailyByWeldJointId`,data ) // ==================== 点口管理 ================================================ /** diff --git a/pages.json b/pages.json index 642d5af..36b8a32 100644 --- a/pages.json +++ b/pages.json @@ -50,12 +50,6 @@ "navigationBarTitleText": "点口管理" } }, - { - "path": "weld/daily_paper", - "style": { - "navigationBarTitleText": "焊接日报" - } - }, { "path": "pressure/index", "style": { @@ -144,6 +138,12 @@ "style": { "navigationBarTitleText": "组队抽查" } + }, + { + "path": "hj/daily_paper", + "style": { + "navigationBarTitleText": "焊接日报" + } } ] } diff --git a/pipe/weld/daily_paper.vue b/pipe/weld/daily_paper.vue deleted file mode 100644 index a18b28d..0000000 --- a/pipe/weld/daily_paper.vue +++ /dev/null @@ -1,208 +0,0 @@ - - - \ No newline at end of file diff --git a/scanpages/hj/daily_paper.vue b/scanpages/hj/daily_paper.vue new file mode 100644 index 0000000..354c3d8 --- /dev/null +++ b/scanpages/hj/daily_paper.vue @@ -0,0 +1,409 @@ + + + + + diff --git a/static/images/bg_backup.jpg b/static/images/bg_backup.jpg deleted file mode 100644 index 49a7e54..0000000 Binary files a/static/images/bg_backup.jpg and /dev/null differ diff --git a/utils/request.js b/utils/request.js index fe6ca71..2c069a6 100644 --- a/utils/request.js +++ b/utils/request.js @@ -2,7 +2,7 @@ import { useUserStore } from '@/store' // TODO: 替换为实际的 API 地址 export const baseUrl = 'https://lygcgs.com.cn:8078/shjapi/api/' - +export const baseFileUrl = 'https://lygcgs.com.cn:8078/shj/' // ===== 防止重复请求 ===== const pendingRequests = new Map() @@ -148,6 +148,22 @@ export const post = (url, data = {}) => { } +/** + * 解析附件 URL 字符串为可展示的照片列表 + * @param {string} urlStr - 逗号分隔的附件路径,如 "FileUpLoad/xxx.png,FileUpLoad/yyy.png" + * @param {number} startId - 起始 ID,用于生成唯一标识 + * @returns {Array<{_id: number, src: string, uploaded: boolean}>} + */ +export const parseAttachUrls = (urlStr, startId = 0) => { + if (!urlStr) return [] + let id = startId + return urlStr.split(',').filter(Boolean).map(url => ({ + _id: ++id, + src: `${baseFileUrl}${url}`, + uploaded: true + })) +} + export const getUrlParam = (url, name) => { if (!url || !name) return null; diff --git a/utils/scanUtils.js b/utils/scanUtils.js index e28e7d4..87776f0 100644 --- a/utils/scanUtils.js +++ b/utils/scanUtils.js @@ -9,12 +9,12 @@ export const parseScanResult = (str) => { if (!str) return null // 焊接接头二维码:https://sggl.sedin.com.cn/StaticPage/HJGL/index.html?id=xxx&weldjoint=1 - // if (str.includes('weldjoint')) { - // const id = getUrlParam(str, 'id') - // if (id) { - // return { path: '/scanpages/hj/material_sampling', query: `id=${id}` } - // } - // } + if (str.includes('weldjoint')) { + const id = getUrlParam(str, 'id') + if (id) { + return { path: '/scanpages/hj/daily_paper', query: `id=${id}` } + } + } // 后续可在此扩展其他扫码类型...