From 59703f3a7e3d417cea645070d49f25e1c176d14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rhett=E9=9C=8D?= <741354752@qq.com> Date: Thu, 12 Feb 2026 14:41:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/FileUpload/FileUpload.js | 67 + api/orderManager/index.js | 44 + .../OrderManagerCom/ActualShipmentList.vue | 80 ++ .../OrderManagerCom/InvoiceList.vue | 132 ++ .../OrderManagerCom/OperationLog.vue | 70 + .../OrderManagerCom/goodsListC.vue | 77 ++ config.js | 4 +- manifest.json | 9 +- pages.json | 10 +- pages/login.vue | 2 +- pages/work/BusinessApproval/OrderDetail.vue | 3 - pages/work/OrderManager/ListItem.vue | 15 +- .../work/OrderManager/components/EditData.vue | 1203 ++++++++--------- .../OrderManager/components/LookDataNB.vue | 944 ++++++------- .../OrderManager/components/LookDataSY.vue | 747 +++------- pages/work/OrderManager/components/NewAdd.vue | 4 +- pages/work/OrderManager/components/data1.js | 237 ++-- pages/work/OrderManager/index.vue | 2 +- utils/utils.js | 542 ++++++++ 19 files changed, 2330 insertions(+), 1862 deletions(-) create mode 100644 api/FileUpload/FileUpload.js create mode 100644 components/SailMainComponents/OrderManagerCom/ActualShipmentList.vue create mode 100644 components/SailMainComponents/OrderManagerCom/InvoiceList.vue create mode 100644 components/SailMainComponents/OrderManagerCom/OperationLog.vue create mode 100644 components/SailMainComponents/OrderManagerCom/goodsListC.vue diff --git a/api/FileUpload/FileUpload.js b/api/FileUpload/FileUpload.js new file mode 100644 index 0000000..66fec34 --- /dev/null +++ b/api/FileUpload/FileUpload.js @@ -0,0 +1,67 @@ +import request from '@/utils/request' + +// 文件列表 +export function docList(data) { + return request({ + url: '/bussiness/ApplyDetail/docList', + method: 'post', + data: data, + isEncrypt: false + }) +} + +// 法律文书 --详情 /bussiness/ApplyDetail/image +export function imageInfo(jwSecuritycheckId) { + return request({ + url: '/bussiness/ApplyDetail/image?jwUploadId=' + jwSecuritycheckId, + method: 'get', + responseType: 'blob', // 设置响应类型为 blob + isEncrypt: false + }) +} +// 法律文书 --上传 /bussiness/ApplyDetail/uploadFile +export function uploadFile(data) { + return request({ + url: '/bussiness/ApplyDetail/uploadFile', + method: 'post', + // headers: { 'Content-Type': 'multipart/form-data' }, + data: data, + isEncrypt: false + }) +} + + +// 通用安全文件上传--通用文件上传 +export function uploadSecurityFileByType(query,data) { + return request({ + url: '/common/uploadSecurityFileByType', + method: 'post', + params: query, + data: data, + isEncrypt: false + }) +} + +// 通用上传文件下载-通用文件下载 +export function securityFileDownload(query) { + return request({ + url: '/common/securityFileDownload', + method: 'get', + params: query, + responseType: 'blob', // 设置响应类型为 blob + isEncrypt: false + }) +} + +// 分片上传大文件 +export const pieceUpload = (data) => { + return request({ + method: 'post', + headers: { + 'Content-Type': 'multipart/form-data' + }, + url: '/common/piece_upload', + data: data, + isEncrypt: false + }) +} diff --git a/api/orderManager/index.js b/api/orderManager/index.js index 2dfc880..4081ebd 100644 --- a/api/orderManager/index.js +++ b/api/orderManager/index.js @@ -1,4 +1,6 @@ import request from '@/utils/request' + + export function listsalemain(data,query) { return request({ url: '/bussiness/salemain/list', @@ -101,3 +103,45 @@ export function delsalemain(id) { // isEncrypt: false }) } + + + +// 订单详情中,查询商业用户详细--收货地址 +export function BaseuserBusinessUserDetail(BaseuserBusinessUserId) { + return request({ + url: '/baseInfo/baseuserbusiness/info?id=' + BaseuserBusinessUserId, + method: 'get', + isEncrypt: false + }) +} + +// 订单管理-实际发货清单 +export function getSaleDisDetail(saleid) { + return request({ + url: '/bussiness/salemain/getSaleDisDetail?saleId=' + saleid, + method: 'post', + isEncrypt: false + }) +} + +// 销售订单操作日志 +export function salemainlogList(data,query) { + return request({ + url: '/bussiness/salemainlog/list', + method: 'post', + data:data, + params: query, + isEncrypt: false + }) +} + +// 发货管理-订单管理--发票列表 +export function getInvoiceList(saleid) { + return request({ + url: '/bussiness/salemain/getInvoiceList?saleId=' + saleid, + method: 'post', + isEncrypt: false + }) +} + + diff --git a/components/SailMainComponents/OrderManagerCom/ActualShipmentList.vue b/components/SailMainComponents/OrderManagerCom/ActualShipmentList.vue new file mode 100644 index 0000000..41938b8 --- /dev/null +++ b/components/SailMainComponents/OrderManagerCom/ActualShipmentList.vue @@ -0,0 +1,80 @@ + + + + + \ No newline at end of file diff --git a/components/SailMainComponents/OrderManagerCom/InvoiceList.vue b/components/SailMainComponents/OrderManagerCom/InvoiceList.vue new file mode 100644 index 0000000..55ad04c --- /dev/null +++ b/components/SailMainComponents/OrderManagerCom/InvoiceList.vue @@ -0,0 +1,132 @@ + + + + + \ No newline at end of file diff --git a/components/SailMainComponents/OrderManagerCom/OperationLog.vue b/components/SailMainComponents/OrderManagerCom/OperationLog.vue new file mode 100644 index 0000000..e0cdf97 --- /dev/null +++ b/components/SailMainComponents/OrderManagerCom/OperationLog.vue @@ -0,0 +1,70 @@ + + + + + \ No newline at end of file diff --git a/components/SailMainComponents/OrderManagerCom/goodsListC.vue b/components/SailMainComponents/OrderManagerCom/goodsListC.vue new file mode 100644 index 0000000..47c2de3 --- /dev/null +++ b/components/SailMainComponents/OrderManagerCom/goodsListC.vue @@ -0,0 +1,77 @@ + + + + + \ No newline at end of file diff --git a/config.js b/config.js index c86d50a..abc9a45 100644 --- a/config.js +++ b/config.js @@ -2,8 +2,8 @@ export default { // baseUrl: 'https://vue.ruoyi.vip/prod-api', // // baseUrl: '/prod-api', //前后端分离版的接口地址,转发代理 设置在了manifest.json文件中 - // baseUrl: 'http://192.168.3.27:18090', //前后端分离版的接口地址 - baseUrl: 'http://106.15.139.36:18090', //前后端分离版的接口地址 + // baseUrl: 'http://192.168.99.25:18090', //前后端分离版的接口地址 + baseUrl: '/prod-api', //前后端分离版的接口地址 //测试提交 // 应用信息 appInfo: { diff --git a/manifest.json b/manifest.json index 141be45..70f3eec 100644 --- a/manifest.json +++ b/manifest.json @@ -57,7 +57,12 @@ }, "vueVersion": "3", "h5": { - "template": "static/index.html" + "template": "static/index.html", + "publicPath": "/h5/", // 关键修改:改为 /h5/,不是 ./ + "router": { + "mode": "history", // 或 "hash" + "base": "/h5/" // 关键修改:设置为 /h5/ + } // "devServer" : { // "port" : 30088, // "https" : false, @@ -79,7 +84,7 @@ "title": "RuoYi-App", "router": { "mode": "hash", - "base": "./" + "base": "/h5/" // 这里也要改 } } } diff --git a/pages.json b/pages.json index 16548d8..7bf4af6 100644 --- a/pages.json +++ b/pages.json @@ -128,13 +128,21 @@ } }, { - "path": "pages/work/OrderManager/components/LookData", + "path": "pages/work/OrderManager/components/LookDataSY", "style": { "navigationBarTitleText": "订单详情", "props": true // 开启 props 传参 } }, + { + "path": "pages/work/OrderManager/components/LookDataNB", + "style": { + "navigationBarTitleText": "订单详情", + "props": true + // 开启 props 传参 + } + }, { "path": "pages/work/OrderManager/components/NewAdd", "style": { diff --git a/pages/login.vue b/pages/login.vue index c7ec855..7fcb3e6 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -100,7 +100,7 @@ function loginSuccess(result) { // 设置用户信息 useUserStore().getInfo().then(res => { - proxy.$tab.reLaunch('/pages/index') + proxy.$tab.reLaunch('pages/work/index') }) } diff --git a/pages/work/BusinessApproval/OrderDetail.vue b/pages/work/BusinessApproval/OrderDetail.vue index 18cc4fe..a99363b 100644 --- a/pages/work/BusinessApproval/OrderDetail.vue +++ b/pages/work/BusinessApproval/OrderDetail.vue @@ -101,8 +101,6 @@ - - - diff --git a/pages/work/OrderManager/ListItem.vue b/pages/work/OrderManager/ListItem.vue index 7cd4bf1..e2cb988 100644 --- a/pages/work/OrderManager/ListItem.vue +++ b/pages/work/OrderManager/ListItem.vue @@ -148,7 +148,14 @@ const Edit = async (row) => { try { console.log(row,'当前行数据') //具体逻辑 - + const params = { + companyId: row.companyId, + saleid: row.saleid, + userid: row.userid, + } + // 序列化为JSON字符串,再编码 + const paramsStr = encodeURIComponent(JSON.stringify(params)) + proxy.$tab.navigateTo(`/pages/work/OrderManager/components/EditData?data=${paramsStr}`) } catch (error) { console.error('失败:', error) @@ -220,6 +227,12 @@ const handleDetail = (row) => { if(userType.value == '01' || userType.value == '02'){ proxy.$tab.navigateTo(`/pages/work/OrderManager/components/LookDataSY?id=${row.saleid}`) }else{ + // uni.showToast({ + // title: '内部用户查看还在开发完善中!!', + // icon: 'none', + // duration: 2000 + // }) + // return false; proxy.$tab.navigateTo(`/pages/work/OrderManager/components/LookDataNB?id=${row.saleid}`) } } diff --git a/pages/work/OrderManager/components/EditData.vue b/pages/work/OrderManager/components/EditData.vue index 89d58a9..99fbbd8 100644 --- a/pages/work/OrderManager/components/EditData.vue +++ b/pages/work/OrderManager/components/EditData.vue @@ -1,25 +1,23 @@ \ No newline at end of file diff --git a/pages/work/OrderManager/components/LookDataNB.vue b/pages/work/OrderManager/components/LookDataNB.vue index fd76d3f..b6de62a 100644 --- a/pages/work/OrderManager/components/LookDataNB.vue +++ b/pages/work/OrderManager/components/LookDataNB.vue @@ -1,590 +1,430 @@ - \ No newline at end of file diff --git a/pages/work/OrderManager/components/LookDataSY.vue b/pages/work/OrderManager/components/LookDataSY.vue index fd76d3f..1f7e3a6 100644 --- a/pages/work/OrderManager/components/LookDataSY.vue +++ b/pages/work/OrderManager/components/LookDataSY.vue @@ -1,590 +1,223 @@ - - -.page-title { - text-align: center; - margin-bottom: 24px; - color: #333; - font-size: 18px; - font-weight: 600; - padding: 12px 0; - background: #fff; - border-radius: 12px; - box-shadow: 0 2px 8px rgba(0,0,0,0.1); -} -/* 基础信息网格布局 */ -.info-section { - background: #fff; - border-radius: 12px; - padding: 16px; - margin-bottom: 20px; - box-shadow: 0 2px 8px rgba(0,0,0,0.1); -} - -.info-grid { - :deep(.uni-row) { - display: flex; - flex-wrap: wrap; - } - .info-value { - font-size: 15px; - color: #333; - font-weight: 500; - display: flex; - justify-content: flex-end; - } - - margin-bottom: 20rpx; - margin-top: 20rpx; -} - -.info-item { - margin-bottom: 12px; -} - -.label { - font-size: 14px; - color: #666; - margin-bottom: 4px; - font-weight: 500; -} - -.required::after { - content: '*'; - color: #f56c6c; - margin-left: 2px; -} - -.amount { - color: #f56c6c; - font-weight: 600; -} - -.select-container { - width: 100%; -} - -:deep(.uni-data-select__text) { - padding: 8px 12px; - border: 1px solid #ddd; - border-radius: 8px; - background-color: #fff; -} - -:deep(.month-popup) { - min-width: 120px; -} - -/* 商品信息区域 */ -.goods-section { - background: #fff; - border-radius: 12px; - padding: 16px; - margin-bottom: 20px; - box-shadow: 0 2px 8px rgba(0,0,0,0.1); -} - -.section-title { - font-size: 16px; - color: #333; - margin: 0 0 16px 0; - padding-bottom: 8px; - border-bottom: 1px solid #eee; - font-weight: 600; - display: flex; - align-items: center; -} - -.no-data { - text-align: center; - color: #999; - padding: 40px 0; - font-size: 14px; -} - -/* 商品双栏布局 */ -.goods-double-column { - display: flex; - flex-direction: column; - gap: 12px; -} - -.goods-item { - border: 1px solid #eee; - border-radius: 12px; - overflow: hidden; - background: #fafafa; -} - -.goods-header { - background: #409eff; - color: white; - padding: 5px 8px; - display: flex; - align-items: center; - gap: 12px; -} - -.serial-number { - display: inline-flex; - align-items: center; - justify-content: center; - width: 20px; - height: 20px; - background: rgba(255, 255, 255, 0.2); - border-radius: 50%; - font-size: 12px; - font-weight: 600; -} - -.goods-name { - font-size: 15px; - font-weight: 600; - flex: 1; -} - -/* 商品内容区域 */ -.goods-content { - padding: 12px 16px; -} - -.info-row { - display: flex; - margin-bottom: 8px; -} - -.info-pair { - flex: 1; - padding: 0 8px; -} - -.info-pair .label { - font-size: 14px; - color: #666; - margin-bottom: 2px; -} - -.info-pair .value { - font-size: 14px; - color: #333; - font-weight: 500; - text-align: right; -} - -.quantity { - color: #409eff; - font-weight: 600; -} - -.total { - color: #f56c6c; - font-weight: 600; -} - -.empty { - visibility: hidden; -} - -/* 操作按钮 */ -.action-buttons { - display: flex; - justify-content: center; - gap: 12px; - padding: 16px 0; - background: #fff; - border-radius: 12px; - box-shadow: 0 2px 8px rgba(0,0,0,0.1); -} - -.btn { - padding: 12px 24px; - border: none; - border-radius: 8px; - font-size: 15px; - font-weight: 500; - cursor: pointer; - min-width: 80px; - text-align: center; - flex: 1; -} - -.btn-primary { - background: #409eff; - color: white; -} - -.btn-secondary { - background: #67c23a; - color: white; -} - -.btn-outline { - background: #fff; - color: #333; - border: 1px solid #ddd; -} - -/* 响应式设计 */ -@media (max-width: 768px) { - .order-detail-container { - padding: 12px; - } - - .info-item { - margin-bottom: 10px; - } - - .info-pair { - padding: 0 4px; - } - - .action-buttons { - flex-direction: column; - } - - .btn { - width: 100%; - margin-bottom: 8px; - } - - .btn:last-child { - margin-bottom: 0; - } -} - -/* 添加多选框样式 */ -.uni-checkbox { - display: inline-flex; - align-items: center; - margin-right: 8px; -} - \ No newline at end of file diff --git a/pages/work/OrderManager/components/NewAdd.vue b/pages/work/OrderManager/components/NewAdd.vue index a9a7dd0..fd1320d 100644 --- a/pages/work/OrderManager/components/NewAdd.vue +++ b/pages/work/OrderManager/components/NewAdd.vue @@ -170,7 +170,6 @@ - @@ -186,7 +185,6 @@ import { onMounted, ref, nextTick } from 'vue' import { productListWithUserId, addsalemain, getsalemaincheckAmount, listsaleBusGoodsList, salemainpiAoKouList } from '../../../../api/orderManager/index.js' import { useUserStore } from '@/store' import MBLoading from "@/components/MB/MBLoading.vue"; -import data1 from './data1.js' const userStore = useUserStore() const userID = ref(userStore.id) const loading = ref(true) @@ -211,6 +209,7 @@ const tempSelectedItems = ref([]) // 临时选中的补差项 const companyOptions = ref([]) const isInitializing = ref(false) + onMounted(async () => { isInitializing.value = true try { @@ -321,7 +320,6 @@ function getEdu() { } else { remainingMoney.value = 0 } - GetlistsaleBusGoodsList() getsalemainpiAoKouList() }) diff --git a/pages/work/OrderManager/components/data1.js b/pages/work/OrderManager/components/data1.js index c242f6e..bb9d218 100644 --- a/pages/work/OrderManager/components/data1.js +++ b/pages/work/OrderManager/components/data1.js @@ -1,122 +1,119 @@ // buchadata.js export default { - data: [ - { - piaokouid: 1, - goodsid: 1, // 对应盐酸丙卡特罗片(美普清)10 - applydate: "2024-01-15", - piaokoutype: "价格补差", - shortname: "MPT10", - goodsname: "盐酸丙卡特罗片(美普清)10", - piaokou: 100 - }, - { - piaokouid: 101, - goodsid: 1, // 对应盐酸丙卡特罗片(美普清)10 - applydate: "2025-11-15", - piaokoutype: "价格补差", - shortname: "MPT10", - goodsname: "盐酸丙卡特罗片(美普清)10", - piaokou: 200 - }, - { - piaokouid: 2, - goodsid: 3, // 对应盐酸丙卡特罗片(美普清)20 - applydate: "2024-01-16", - piaokoutype: "运费补差", - shortname: "MPT20", - goodsname: "盐酸丙卡特罗片(美普清)20", - piaokou: 10000.01 - }, - { - piaokouid: 102, - goodsid: 3, // 对应盐酸丙卡特罗片(美普清)20 - applydate: "2024-01-17", - piaokoutype: "运费补差", - shortname: "MPT20", - goodsname: "盐酸丙卡特罗片(美普清)20", - piaokou: 20000.02 - }, - { - piaokouid: 3, - goodsid: 5, // 对应瑞巴派特片(膜固思达)24 - applydate: "2024-01-17", - piaokoutype: "促销补差", - shortname: "MCT24", - goodsname: "瑞巴派特片(膜固思达)24", - piaokou: 12.80 - }, - { - piaokouid: 4, - goodsid: 35, // 对应瑞巴派特片(膜固思达)48 - applydate: "2024-01-18", - piaokoutype: "价格补差", - shortname: "MCT48", - goodsname: "瑞巴派特片(膜固思达)48", - piaokou: 25.00 - }, - { - piaokouid: 5, - goodsid: 6, // 对应阿立哌唑片(安律凡)5mg - applydate: "2024-01-19", - piaokoutype: "运费补差", - shortname: "ABF5", - goodsname: "阿立哌唑片(安律凡)5mg", - piaokou: 18.50 - }, - { - piaokouid: 6, - goodsid: 8, // 对应托伐普坦片(苏麦卡) - applydate: "2024-01-20", - piaokoutype: "促销补差", - shortname: "SMC", - goodsname: "托伐普坦片(苏麦卡)", - piaokou: 45.75 - }, - { - piaokouid: 7, - goodsid: 10, // 对应白消安注射液(白舒非) - applydate: "2024-01-21", - piaokoutype: "价格补差", - shortname: "BSF", - goodsname: "白消安注射液(白舒非)", - piaokou: 120.25 - }, - { - piaokouid: 8, - goodsid: 33, // 对应德拉马尼片(德尔巴) - applydate: "2024-01-22", - piaokoutype: "运费补差", - shortname: "DLM", - goodsname: "德拉马尼片(德尔巴)", - piaokou: 280.00 - }, - { - piaokouid: 9, - goodsid: 39, // 对应注射用阿立哌唑0.4g - applydate: "2024-01-23", - piaokoutype: "促销补差", - shortname: "AOM400", - goodsname: "注射用阿立哌唑0.4g", - piaokou: 95.90 - }, - { - piaokouid: 10, - goodsid: 41, // 对应布瑞哌唑片(锐思定)1mg - applydate: "2024-01-24", - piaokoutype: "价格补差", - shortname: "RXT1", - goodsname: "布瑞哌唑片(锐思定)1mg", - piaokou: 22.40 - }, - { - piaokouid: 11, - goodsid: 42, // 对应泊那替尼片(英可欣)15mg - applydate: "2024-01-25", - piaokoutype: "运费补差", - shortname: "ISG", - goodsname: "泊那替尼片(英可欣)15mg", - piaokou: 350.60 - } - ] -}; \ No newline at end of file + data: [{ + piaokouid: 1, + goodsid: 1, // 对应盐酸丙卡特罗片(美普清)10 + applydate: "2024-01-15", + piaokoutype: "价格补差", + shortname: "MPT10", + goodsname: "盐酸丙卡特罗片(美普清)10", + piaokou: 100 + }, + { + piaokouid: 101, + goodsid: 1, // 对应盐酸丙卡特罗片(美普清)10 + applydate: "2025-11-15", + piaokoutype: "价格补差", + shortname: "MPT10", + goodsname: "盐酸丙卡特罗片(美普清)10", + piaokou: 200 + }, + { + piaokouid: 2, + goodsid: 3, // 对应盐酸丙卡特罗片(美普清)20 + applydate: "2024-01-16", + piaokoutype: "运费补差", + shortname: "MPT20", + goodsname: "盐酸丙卡特罗片(美普清)20", + piaokou: 10000.01 + }, + { + piaokouid: 102, + goodsid: 3, // 对应盐酸丙卡特罗片(美普清)20 + applydate: "2024-01-17", + piaokoutype: "运费补差", + shortname: "MPT20", + goodsname: "盐酸丙卡特罗片(美普清)20", + piaokou: 20000.02 + }, + { + piaokouid: 3, + goodsid: 5, // 对应瑞巴派特片(膜固思达)24 + applydate: "2024-01-17", + piaokoutype: "促销补差", + shortname: "MCT24", + goodsname: "瑞巴派特片(膜固思达)24", + piaokou: 12.80 + }, + { + piaokouid: 4, + goodsid: 35, // 对应瑞巴派特片(膜固思达)48 + applydate: "2024-01-18", + piaokoutype: "价格补差", + shortname: "MCT48", + goodsname: "瑞巴派特片(膜固思达)48", + piaokou: 25.00 + }, + { + piaokouid: 5, + goodsid: 6, // 对应阿立哌唑片(安律凡)5mg + applydate: "2024-01-19", + piaokoutype: "运费补差", + shortname: "ABF5", + goodsname: "阿立哌唑片(安律凡)5mg", + piaokou: 18.50 + }, + { + piaokouid: 6, + goodsid: 8, // 对应托伐普坦片(苏麦卡) + applydate: "2024-01-20", + piaokoutype: "促销补差", + shortname: "SMC", + goodsname: "托伐普坦片(苏麦卡)", + piaokou: 45.75 + }, + { + piaokouid: 7, + goodsid: 10, // 对应白消安注射液(白舒非) + applydate: "2024-01-21", + piaokoutype: "价格补差", + shortname: "BSF", + goodsname: "白消安注射液(白舒非)", + piaokou: 120.25 + }, + { + piaokouid: 8, + goodsid: 33, // 对应德拉马尼片(德尔巴) + applydate: "2024-01-22", + piaokoutype: "运费补差", + shortname: "DLM", + goodsname: "德拉马尼片(德尔巴)", + piaokou: 280.00 + }, + { + piaokouid: 9, + goodsid: 39, // 对应注射用阿立哌唑0.4g + applydate: "2024-01-23", + piaokoutype: "促销补差", + shortname: "AOM400", + goodsname: "注射用阿立哌唑0.4g", + piaokou: 95.90 + }, + { + piaokouid: 10, + goodsid: 41, // 对应布瑞哌唑片(锐思定)1mg + applydate: "2024-01-24", + piaokoutype: "价格补差", + shortname: "RXT1", + goodsname: "布瑞哌唑片(锐思定)1mg", + piaokou: 22.40 + }, + { + piaokouid: 11, + goodsid: 42, // 对应泊那替尼片(英可欣)15mg + applydate: "2024-01-25", + piaokoutype: "运费补差", + shortname: "ISG", + goodsname: "泊那替尼片(英可欣)15mg", + piaokou: 350.60 + } \ No newline at end of file diff --git a/pages/work/OrderManager/index.vue b/pages/work/OrderManager/index.vue index 3b84088..ff1103d 100644 --- a/pages/work/OrderManager/index.vue +++ b/pages/work/OrderManager/index.vue @@ -4,7 +4,7 @@ { return Number(value).toFixed(2) +} + +import {securityFileDownload} from '@/api/FileUpload/FileUpload.js' + +// 移动端文件预览优化版 - H5兼容修复 +export const YuLanfile = async (filePath) => { + + uni.showToast({ + title: '预览还在开发完善中!!', + icon: 'none', + duration: 2000 + }) + return false; + console.log("预览文件:", filePath) + if (!filePath) { + uni.showToast({ + title: '文件路径不存在', + icon: 'none' + }); + return; + } + + try { + uni.showLoading({ + title: '正在加载文件...', + mask: true + }); + + const response = await securityFileDownload({ + fileName: filePath, + delete: false + }); + + const fileExtension = filePath.split('.').pop().toLowerCase(); + const fileName = filePath.split('\\').pop() || 'preview.' + fileExtension; + + // 判断运行环境 + const platform = getPlatform(); + console.log('当前平台:', platform); + + // 根据平台和文件类型选择预览方式 + if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'].includes(fileExtension)) { + await previewImage(response, fileExtension, fileName, platform); + } else if (fileExtension === 'pdf') { + await previewPDF(response, fileName, platform); + } else { + await handleOtherFile(response, fileName, fileExtension, platform); + } + + uni.hideLoading(); + + } catch (error) { + console.error('预览失败:', error); + uni.hideLoading(); + uni.showToast({ + title: '预览失败: ' + (error.message || '未知错误'), + icon: 'none' + }); + } +} + +// 获取平台 +const getPlatform = () => { + // #ifdef H5 + return 'h5'; + // #endif + // #ifdef APP-PLUS + return 'app'; + // #endif + // #ifdef MP-WEIXIN + return 'weixin'; + // #endif + return 'h5'; // 默认 +} + +// 图片预览 +const previewImage = async (response, fileExtension, fileName, platform) => { + return new Promise((resolve, reject) => { + const blob = new Blob([response], { + type: `image/${fileExtension === 'jpg' ? 'jpeg' : fileExtension}` + }); + + // H5环境 - 使用简单可靠的方式 + if (platform === 'h5') { + const blobUrl = URL.createObjectURL(blob); + // 创建图片预览模态框 + showImageModalH5(blobUrl, fileName, resolve); + return; + } + + // App环境 + if (platform === 'app') { + const reader = new FileReader(); + reader.onload = (e) => { + const base64 = e.target.result; + uni.previewImage({ + current: 0, + urls: [base64], + success: () => resolve(), + fail: (err) => { + console.error('预览图片失败:', err); + const blobUrl = URL.createObjectURL(blob); + window.open(blobUrl, '_blank'); + resolve(); + } + }); + }; + reader.readAsDataURL(blob); + return; + } + + // 微信小程序环境 + if (platform === 'weixin') { + const reader = new FileReader(); + reader.onload = (e) => { + const base64 = e.target.result; + wx.getFileSystemManager().writeFile({ + filePath: wx.env.USER_DATA_PATH + '/temp_' + Date.now() + '.' + fileExtension, + data: base64.replace(/^data:image\/\w+;base64,/, ''), + encoding: 'base64', + success: (res) => { + wx.previewImage({ + current: 0, + urls: [res.filePath], + success: () => resolve(), + fail: (err) => reject(err) + }); + }, + fail: (err) => reject(err) + }); + }; + reader.readAsDataURL(blob); + } + }); +} + +// H5图片预览模态框 +const showImageModalH5 = (imageUrl, fileName, resolve) => { + // 移除已存在的模态框 + const existingModal = document.getElementById('h5-preview-modal'); + if (existingModal) { + document.body.removeChild(existingModal); + } + + const modal = document.createElement('div'); + modal.id = 'h5-preview-modal'; + modal.style.cssText = ` + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0,0,0,0.9); + z-index: 999999; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + `; + + const header = document.createElement('div'); + header.style.cssText = ` + position: absolute; + top: 0; + left: 0; + right: 0; + height: 50px; + background: rgba(0,0,0,0.5); + color: white; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 20px; + z-index: 1000000; + `; + header.innerHTML = ` + ${fileName} + × + `; + + const img = document.createElement('img'); + img.src = imageUrl; + img.style.cssText = ` + max-width: 100%; + max-height: 100%; + object-fit: contain; + `; + + // 关闭按钮点击 + header.querySelector('span:last-child').onclick = () => { + document.body.removeChild(modal); + URL.revokeObjectURL(imageUrl); + resolve(); + }; + + // 点击背景关闭 + modal.onclick = (e) => { + if (e.target === modal) { + document.body.removeChild(modal); + URL.revokeObjectURL(imageUrl); + resolve(); + } + }; + + // 按ESC关闭 + const escHandler = (e) => { + if (e.key === 'Escape') { + document.body.removeChild(modal); + URL.revokeObjectURL(imageUrl); + document.removeEventListener('keydown', escHandler); + resolve(); + } + }; + document.addEventListener('keydown', escHandler); + + modal.appendChild(header); + modal.appendChild(img); + document.body.appendChild(modal); +} + +// PDF预览 +const previewPDF = async (response, fileName, platform) => { + return new Promise((resolve, reject) => { + const blob = new Blob([response], { type: 'application/pdf' }); + + // H5环境 + if (platform === 'h5') { + const blobUrl = URL.createObjectURL(blob); + showPDFModalH5(blobUrl, fileName, resolve); + return; + } + + // App环境 + if (platform === 'app') { + const reader = new FileReader(); + reader.onload = (e) => { + const arrayBuffer = e.target.result; + const base64Data = arrayBufferToBase64(arrayBuffer); + + plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) { + fs.root.getFile(fileName, {create: true}, function(fileEntry) { + fileEntry.createWriter(function(writer) { + writer.onwrite = function() { + plus.runtime.openFile(fileEntry.toLocalURL()); + resolve(); + }; + writer.onerror = reject; + writer.writeAsBinary(atob(base64Data)); + }, reject); + }, reject); + }, reject); + }; + reader.readAsArrayBuffer(blob); + return; + } + + // 微信小程序环境 + if (platform === 'weixin') { + const reader = new FileReader(); + reader.onload = (e) => { + const arrayBuffer = e.target.result; + const base64Data = arrayBufferToBase64(arrayBuffer); + + wx.getFileSystemManager().writeFile({ + filePath: wx.env.USER_DATA_PATH + '/' + fileName, + data: base64Data, + encoding: 'base64', + success: (res) => { + wx.openDocument({ + filePath: wx.env.USER_DATA_PATH + '/' + fileName, + success: () => resolve(), + fail: (err) => reject(err) + }); + }, + fail: (err) => reject(err) + }); + }; + reader.readAsArrayBuffer(blob); + } + }); +} + +// H5 PDF预览模态框 +const showPDFModalH5 = (pdfUrl, fileName, resolve) => { + // 移除已存在的模态框 + const existingModal = document.getElementById('h5-preview-modal'); + if (existingModal) { + document.body.removeChild(existingModal); + } + + const modal = document.createElement('div'); + modal.id = 'h5-preview-modal'; + modal.style.cssText = ` + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: white; + z-index: 999999; + display: flex; + flex-direction: column; + `; + + const header = document.createElement('div'); + header.style.cssText = ` + height: 50px; + background: #f5f5f5; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 20px; + border-bottom: 1px solid #ddd; + `; + header.innerHTML = ` + ${fileName} + × + `; + + const iframe = document.createElement('iframe'); + iframe.src = pdfUrl; + iframe.style.cssText = ` + width: 100%; + flex: 1; + border: none; + `; + + // 关闭按钮 + header.querySelector('span:last-child').onclick = () => { + document.body.removeChild(modal); + URL.revokeObjectURL(pdfUrl); + resolve(); + }; + + // 按ESC关闭 + const escHandler = (e) => { + if (e.key === 'Escape') { + document.body.removeChild(modal); + URL.revokeObjectURL(pdfUrl); + document.removeEventListener('keydown', escHandler); + resolve(); + } + }; + document.addEventListener('keydown', escHandler); + + modal.appendChild(header); + modal.appendChild(iframe); + document.body.appendChild(modal); +} + +// 处理其他文件 +const handleOtherFile = async (response, fileName, fileExtension, platform) => { + return new Promise((resolve, reject) => { + uni.showActionSheet({ + itemList: ['预览文件', '保存到本地', '取消'], + success: async (res) => { + if (res.tapIndex === 0) { + await openWithDefaultApp(response, fileName, fileExtension, platform); + resolve(); + } else if (res.tapIndex === 1) { + await saveFile(response, fileName, platform); + resolve(); + } else { + resolve(); + } + }, + fail: (err) => reject(err) + }); + }); +} + +// 使用默认应用打开 +const openWithDefaultApp = (response, fileName, fileExtension, platform) => { + return new Promise((resolve, reject) => { + const blob = new Blob([response]); + + // H5环境 + if (platform === 'h5') { + const blobUrl = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = blobUrl; + a.download = fileName; + a.click(); + URL.revokeObjectURL(blobUrl); + uni.showToast({ + title: '开始下载', + icon: 'success' + }); + resolve(); + return; + } + + // App环境 + if (platform === 'app') { + const reader = new FileReader(); + reader.onload = (e) => { + const arrayBuffer = e.target.result; + const base64Data = arrayBufferToBase64(arrayBuffer); + + plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) { + fs.root.getFile(fileName, {create: true}, function(fileEntry) { + fileEntry.createWriter(function(writer) { + writer.onwrite = function() { + plus.runtime.openFile(fileEntry.toLocalURL()); + resolve(); + }; + writer.onerror = reject; + writer.writeAsBinary(atob(base64Data)); + }, reject); + }, reject); + }, reject); + }; + reader.readAsArrayBuffer(blob); + return; + } + + // 微信小程序环境 + if (platform === 'weixin') { + const reader = new FileReader(); + reader.onload = (e) => { + const arrayBuffer = e.target.result; + const base64Data = arrayBufferToBase64(arrayBuffer); + + wx.getFileSystemManager().writeFile({ + filePath: wx.env.USER_DATA_PATH + '/' + fileName, + data: base64Data, + encoding: 'base64', + success: (res) => { + wx.openDocument({ + filePath: wx.env.USER_DATA_PATH + '/' + fileName, + success: () => resolve(), + fail: (err) => reject(err) + }); + }, + fail: (err) => reject(err) + }); + }; + reader.readAsArrayBuffer(blob); + } + }); +} + +// 保存文件 +const saveFile = (response, fileName, platform) => { + return new Promise((resolve, reject) => { + const blob = new Blob([response]); + + // H5环境 + if (platform === 'h5') { + const blobUrl = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = blobUrl; + a.download = fileName; + a.click(); + URL.revokeObjectURL(blobUrl); + uni.showToast({ + title: '开始下载', + icon: 'success' + }); + resolve(); + return; + } + + // App环境 + if (platform === 'app') { + const reader = new FileReader(); + reader.onload = (e) => { + const arrayBuffer = e.target.result; + const base64Data = arrayBufferToBase64(arrayBuffer); + + plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) { + fs.root.getFile(fileName, {create: true}, function(fileEntry) { + fileEntry.createWriter(function(writer) { + writer.onwrite = function() { + uni.showToast({ + title: '保存成功', + icon: 'success' + }); + resolve(); + }; + writer.onerror = reject; + writer.writeAsBinary(atob(base64Data)); + }, reject); + }, reject); + }, reject); + }; + reader.readAsArrayBuffer(blob); + return; + } + + // 微信小程序环境 + if (platform === 'weixin') { + const reader = new FileReader(); + reader.onload = (e) => { + const arrayBuffer = e.target.result; + const base64Data = arrayBufferToBase64(arrayBuffer); + + wx.getFileSystemManager().writeFile({ + filePath: wx.env.USER_DATA_PATH + '/' + fileName, + data: base64Data, + encoding: 'base64', + success: (res) => { + uni.showToast({ + title: '保存成功', + icon: 'success' + }); + resolve(); + }, + fail: (err) => reject(err) + }); + }; + reader.readAsArrayBuffer(blob); + } + }); +} + +// ArrayBuffer 转 Base64 +const arrayBufferToBase64 = (buffer) => { + let binary = ''; + const bytes = new Uint8Array(buffer); + const len = bytes.byteLength; + for (let i = 0; i < len; i++) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} + +// 获取MIME类型 +const getMimeType = (extension) => { + const mimeTypes = { + 'png': 'image/png', + 'jpg': 'image/jpeg', + 'jpeg': 'image/jpeg', + 'gif': 'image/gif', + 'pdf': 'application/pdf', + 'doc': 'application/msword', + 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'xls': 'application/vnd.ms-excel', + 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'txt': 'text/plain' + }; + return mimeTypes[extension] || 'application/octet-stream'; } \ No newline at end of file