diff --git a/App.vue b/App.vue index d9221e2..0bb9183 100644 --- a/App.vue +++ b/App.vue @@ -61,4 +61,8 @@ page { //padding-bottom: env(safe-area-inset-bottom); /* #endif */ } +.commonPageLRpadding{ + padding-left: 15px; + padding-right: 15px; +} \ No newline at end of file diff --git a/api/common.js b/api/common.js index e69de29..b40c2dd 100644 --- a/api/common.js +++ b/api/common.js @@ -0,0 +1,20 @@ + +import { post, get } from '@/common/utils/request'; + + +/** + * 根据经纬度获取道路接口 + * @param {Object} params {mobile, password, code} + * @returns {Promise} + */ +export const getRoadListByLatLng = (params) => { + return get('/app-api/bpm/garden/workorder/listRoadInfo', params); +}; + +// export const fileUpload = (params) => { +// return post('/app-api/infra/file/upload', params); +// }; + export const fileUpload = '/app-api/infra/file/upload' + + + diff --git a/api/quick-order/quick-order.js b/api/quick-order/quick-order.js new file mode 100644 index 0000000..646ed56 --- /dev/null +++ b/api/quick-order/quick-order.js @@ -0,0 +1,28 @@ +import { post, get } from '@/common/utils/request'; + +// work_name +/** + * 快速工单 所有工单列表接口 + * @param {Object} params {mobile, password, code} + * @returns {Promise} + */ +export const workorderPage = (params) => { + return get('/app-api/bpm/garden/workorder/page', params); +}; + + +/** + * 快速工单 创建 + * @returns {Promise} + */ +export const createQuick = (data) => { + return post('/app-api/bpm/garden/workorder/createQuick',data); +}; + +/** + * 快速工单 获取详情 + * @returns {Promise} + */ +export const inspectionPlanDetail = (params) => { + return get('/app-api/bpm/garden/workorder/get',params); +}; diff --git a/api/upload.js b/api/upload.js index e69de29..f1cb11e 100644 --- a/api/upload.js +++ b/api/upload.js @@ -0,0 +1,23 @@ + +import globalConfig from '@/common/config/global'; +import cache from '@/common/utils/cache'; + +const fileUpload = '/app-api/infra/file/upload' + +export const uploadFilePromise = (url) => { + return new Promise((resolve, reject) => { + let a = uni.uploadFile({ + url: `${globalConfig.api.baseUrl}${fileUpload}`, + filePath: url, + name: 'file', + formData: { + user: 'test', + }, + success: (res) => { + setTimeout(() => { + resolve(res.data.data); + }, 1000); + }, + }); + }); +}; \ No newline at end of file diff --git a/api/user.js b/api/user.js index 3464c86..d1a36f2 100644 --- a/api/user.js +++ b/api/user.js @@ -39,5 +39,5 @@ export const moduleList = () => { * @returns {Promise} */ export const getSimpleDictDataList = () => { - return get({ url: '/system/dict-data/simple-list' }) + return get('/admin-api/system/dict-data/simple-list') } diff --git a/common/config/global.js b/common/config/global.js index 668c159..2ed4bd5 100644 --- a/common/config/global.js +++ b/common/config/global.js @@ -23,7 +23,7 @@ export default { expireTimeKey: 'jcss_token_expire', userIdKey:'jcss_user_id', moduleListKey:'jcss_module_list', - + dictDataKey:'jcss_dict_data' }, appName: 'JCSS管理系统', tokenExpireTime: 7 * 24 * 60 * 60 * 1000 diff --git a/common/utils/upload.js b/common/utils/upload.js index f54da21..5e0a4ab 100644 --- a/common/utils/upload.js +++ b/common/utils/upload.js @@ -1,68 +1,63 @@ +// @/common/utils/upload.ts import globalConfig from '@/common/config/global'; import cache from '@/common/utils/cache'; +import { useUserStore } from '@/pinia/user'; +import { fileUpload } from '@/api/common'; -export const uploadImages = (files, options = {}) => { - const opts = { count: 9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], showLoading: true, ...options }; - const token = cache.get(globalConfig.cache.tokenKey); +// 统一的多文件上传方法(单/多图都走这个) +export const uploadImages = async (options) => { + const { + filePaths, + fileKey = 'file', + header = {}, + ignoreError = true // 忽略单张失败,继续上传其他 + } = options; - if (!token) { - uni.showToast({ title: '请先登录', icon: 'none' }); - return Promise.reject('未登录'); + if (!filePaths || filePaths.length === 0) { + uni.showToast({title: '请选择要上传的图片', icon: 'none'}); + return []; } - if (files.length > opts.count) { - uni.showToast({ title: `最多上传${opts.count}张`, icon: 'none' }); - return Promise.reject('超出数量'); - } - - if (opts.showLoading) uni.showLoading({ title: '上传中...' }); + const userStore = useUserStore() + const defaultHeader = { + 'Content-Type': 'multipart/form-data', + 'Authorization': 'Bearer ' + (userStore.token || cache.get(globalConfig.cache.tokenKey) || '') + }; + const finalHeader = {...defaultHeader, ...header}; + const resultUrls = []; // 最终返回的URL数组 - const uploadPromises = files.map(filePath => { - return new Promise((resolve, reject) => { - uni.uploadFile({ - url: globalConfig.api.uploadUrl, - filePath, - name: 'file', - header: { 'Authorization': `Bearer ${token}` }, - formData: opts.formData || {}, - success: (res) => { - const data = JSON.parse(res.data); - if (data.code === 200) resolve(data.data); - else { - uni.showToast({ title: data.msg || '上传失败', icon: 'none' }); - reject(data); + // 遍历上传(单/多图统一遍历逻辑) + for (let i = 0; i < filePaths.length; i++) { + try { + const url = await new Promise((resolve, reject) => { + uni.uploadFile({ + url: `${globalConfig.api.baseUrl}${fileUpload}`, + filePath: filePaths[i], + name: fileKey, + header: finalHeader, + success: (res) => { + try { + const data = JSON.parse(res.data); + if (data.code === 0) { + resolve(data.data); // 接口返回的URL在data.data中 + } else { + reject(new Error(data.msg || '上传失败')); + } + } catch (e) { + reject(new Error('解析返回数据失败')); + } + }, + fail: (err) => { + reject(new Error(err.errMsg || '网络错误')); } - }, - fail: (err) => { - uni.showToast({ title: '上传失败', icon: 'none' }); - reject(err); - } + }); }); - }); - }); - - return Promise.all(uploadPromises) - .then(results => { - if (opts.showLoading) uni.hideLoading(); - return results; - }) - .catch(err => { - if (opts.showLoading) uni.hideLoading(); - return Promise.reject(err); - }); -}; + resultUrls.push(url); // 成功的URL加入数组 + } catch (err) { + console.error(`第${i+1}张图片上传失败:`, err); + if (!ignoreError) break; // 不忽略错误则终止上传 + } + } -export const chooseAndUploadImages = (options = {}) => { - const opts = { count: 9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], ...options }; - return new Promise((resolve, reject) => { - uni.chooseImage({ - count: opts.count, - sizeType: opts.sizeType, - sourceType: opts.sourceType, - success: (res) => { - uploadImages(res.tempFilePaths, opts).then(resolve).catch(reject); - }, - fail: reject - }); - }); + return resultUrls; // 始终返回数组(单图返回长度1,多图返回对应长度,无成功则返回空数组) }; \ No newline at end of file diff --git a/components/upload-image/upload-image.vue b/components/upload-image/upload-image.vue index 262c640..7c75aed 100644 --- a/components/upload-image/upload-image.vue +++ b/components/upload-image/upload-image.vue @@ -1,62 +1,200 @@ - - \ No newline at end of file diff --git a/main.js b/main.js index cd04af4..9047c6c 100644 --- a/main.js +++ b/main.js @@ -4,6 +4,8 @@ import uviewPlus from '@/uni_modules/uview-plus' // 导入 Pinia 实例(你的 stores/index.js 导出的 pinia) import pinia from '@/pinia/index' import EmptyView from '@/components/empty-view/empty-view.vue'; +import UploadImage from '@/components/upload-image/upload-image.vue'; + // #ifdef VUE3 import { createSSRApp } from 'vue' @@ -17,6 +19,7 @@ export function createApp() { // 4. 注册 Pinia(核心:在 app 挂载前注册) app.use(pinia) app.component('EmptyView', EmptyView) + app.component('UploadImage', UploadImage) // 5. 返回 app + pinia(可选,便于调试) return { app, diff --git a/manifest.json b/manifest.json index 64e25ce..d2764ba 100644 --- a/manifest.json +++ b/manifest.json @@ -55,6 +55,17 @@ "urlCheck" : false }, "usingComponents" : true, + "permission" : { + "scope.userLocation" : { + "desc" : "定位" + } + }, + "requiredPrivateInfos" : [ + "getLocation", + "chooseLocation", + "startLocationUpdate", + "onLocationChange" + ], "mergeVirtualHostAttributes" : true }, "mp-alipay" : { diff --git a/pages-sub/daily/patrol-manage/patrol-plan/index.vue b/pages-sub/daily/patrol-manage/patrol-plan/index.vue index e167498..b13eacf 100644 --- a/pages-sub/daily/patrol-manage/patrol-plan/index.vue +++ b/pages-sub/daily/patrol-manage/patrol-plan/index.vue @@ -32,7 +32,7 @@ > - + { console.log(activeTab.value) activeTab.value = val.id searchValue.value = '' - // paging.value.reload() - // queryList(pageNo, pageSize) paging.value.reload() }; // 搜索/清空搜索 @@ -133,7 +131,7 @@ const handleSearchClear = () => { // searchValue.value = '' paging.value.reload() }; -// 加载数据(核心修复) +// 加载数据 const queryList = async (pageNo, pageSize) => { try { const params = { diff --git a/pages-sub/daily/quick-order/add-order.vue b/pages-sub/daily/quick-order/add-order.vue new file mode 100644 index 0000000..2cf5b58 --- /dev/null +++ b/pages-sub/daily/quick-order/add-order.vue @@ -0,0 +1,664 @@ + + + + + \ No newline at end of file diff --git a/pages-sub/daily/quick-order/index.vue b/pages-sub/daily/quick-order/index.vue index 96c0baf..aea40ae 100644 --- a/pages-sub/daily/quick-order/index.vue +++ b/pages-sub/daily/quick-order/index.vue @@ -1,11 +1,227 @@ - + + + + + + - - \ No newline at end of file diff --git a/pages-sub/daily/quick-order/order-detail.vue b/pages-sub/daily/quick-order/order-detail.vue new file mode 100644 index 0000000..c97fd54 --- /dev/null +++ b/pages-sub/daily/quick-order/order-detail.vue @@ -0,0 +1,224 @@ + + + + + \ No newline at end of file diff --git a/pages-sub/daily/quick-order/order-list.vue b/pages-sub/daily/quick-order/order-list.vue new file mode 100644 index 0000000..89b1f33 --- /dev/null +++ b/pages-sub/daily/quick-order/order-list.vue @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/pages.json b/pages.json index 9202040..67334a8 100644 --- a/pages.json +++ b/pages.json @@ -70,6 +70,16 @@ "style": { "navigationBarTitleText": "快速工单" } }, { + "path": "quick-order/add-order", + "style": { "navigationBarTitleText": "新增快速工单" } + }, + { + "path": "quick-order/order-detail", + "style": { "navigationBarTitleText": "快速工单详情" } + }, + + + { "path": "12345-order/index", "style": { "navigationBarTitleText": "12345工单" } }, diff --git a/pages/workbench/index.vue b/pages/workbench/index.vue index ac9e8e3..fc8b86b 100644 --- a/pages/workbench/index.vue +++ b/pages/workbench/index.vue @@ -1,6 +1,14 @@