Commit a80102cf6925a583686f21ff703aa3dee5bc68f5

Authored by Min
1 parent 2343083f

1.Pad拍照后,支持照片展示,点击预览功能

src/components/Common/CommonViewTable/index.js
@@ -8,7 +8,8 @@ import AntdDraggableModal from '@/components/Common/AntdDraggableModal'; @@ -8,7 +8,8 @@ import AntdDraggableModal from '@/components/Common/AntdDraggableModal';
8 import CommonListSelectTree from '@/components/Common/CommonListSelectTree'; 8 import CommonListSelectTree from '@/components/Common/CommonListSelectTree';
9 import CommonListSelect from '@/components/Common/CommonListSelect'; 9 import CommonListSelect from '@/components/Common/CommonListSelect';
10 import * as commonUtils from '@/utils/utils';/* 通用方法 */ 10 import * as commonUtils from '@/utils/utils';/* 通用方法 */
11 - 11 +import commonConfig from "@/utils/config";
  12 +import preView from '../../../mobile/components/preView';
12 13
13 export default class CommonViewTable extends Component { 14 export default class CommonViewTable extends Component {
14 constructor(props) { 15 constructor(props) {
@@ -307,7 +308,123 @@ export default class CommonViewTable extends Component { @@ -307,7 +308,123 @@ export default class CommonViewTable extends Component {
307 <Row type="flex" className="viewStyle" style={{ height: 'auto', overflow: 'auto', marginTop: viewOrder ? 0 : '8px' }}> 308 <Row type="flex" className="viewStyle" style={{ height: 'auto', overflow: 'auto', marginTop: viewOrder ? 0 : '8px' }}>
308 { 309 {
309 viewConfigs && viewConfigs.map((child) => { 310 viewConfigs && viewConfigs.map((child) => {
  311 + const viewRowNew = this.props.getViewRow?.(child) || viewRow;
310 const iOrder = sMemo ? 100 : child.iOrder > 100 ? 100 : child.iOrder; /* 排序 */ 312 const iOrder = sMemo ? 100 : child.iOrder > 100 ? 100 : child.iOrder; /* 排序 */
  313 +
  314 + const isPadPicture = child.sName?.toLowerCase().includes('padpicture');
  315 + const isPicturePath = child.sName?.toLowerCase().includes('picture');
  316 + if (isPadPicture || isPicturePath) {
  317 + // 直接从隐藏字段获取图片路径(跨表场景)
  318 + let fileValue = '';
  319 + const { token } = app;
  320 + let imgBox = null;
  321 + fileValue = viewRowNew[child.sName];
  322 + // 从隐藏 input 获取图片路径
  323 + // const hiddenInput = document.getElementById('hiddenPicturePaths');
  324 + // if (commonUtils.isEmpty(fileValue) && hiddenInput) {
  325 + // fileValue = hiddenInput.value;
  326 + // }
  327 + if (commonUtils.isNotEmptyStr(fileValue)) {
  328 + const picAddr = fileValue.split(',');
  329 + const previewImageArr = [];
  330 + const dWidth = 800; // 预览图宽度
  331 + const dHeight = 600; // 预览图高度
  332 + // 拼接预览地址
  333 + if ( commonUtils.isNotEmptyArr(picAddr)) {
  334 + picAddr.forEach((item) => {
  335 + const dataPreviewUrl = `${commonConfig.file_host}file/download?savePathStr=${item}&width=${dWidth}&height=${dHeight}&sModelsId=100&token=${token}`;
  336 + previewImageArr.push(dataPreviewUrl);
  337 + });
  338 +
  339 + imgBox = (
  340 + <div style={{
  341 + display: 'flex',
  342 + flexWrap: 'wrap',
  343 + gap: '8px',
  344 + marginTop: '8px'
  345 + }}>
  346 + {picAddr.map((item, index) => {
  347 + const dataUrl = `${commonConfig.file_host}file/download?savePathStr=${item}&width=100&height=100&sModelsId=100&token=${token}`;
  348 + return (
  349 + <div
  350 + key={index}
  351 + style={{
  352 + width: '100px',
  353 + height: '100px',
  354 + borderRadius: '6px',
  355 + overflow: 'hidden',
  356 + cursor: 'pointer',
  357 + transition: 'transform 0.2s ease, box-shadow 0.2s ease',
  358 + boxShadow: '0 1px 3px rgba(0,0,0,0.1)',
  359 + display: 'flex',
  360 + alignItems: 'center',
  361 + justifyContent: 'center',
  362 + backgroundColor: '#f5f5f5'
  363 + }}
  364 + onClick={(e) => preView(previewImageArr, e)}
  365 + onMouseOver={(e) => {
  366 + e.currentTarget.style.transform = 'scale(1.05)';
  367 + e.currentTarget.style.boxShadow = '0 4px 8px rgba(0,0,0,0.15)';
  368 + }}
  369 + onMouseOut={(e) => {
  370 + e.currentTarget.style.transform = 'scale(1)';
  371 + e.currentTarget.style.boxShadow = '0 1px 3px rgba(0,0,0,0.1)';
  372 + }}
  373 + >
  374 + <img
  375 + src={dataUrl}
  376 + alt={`图片 ${index + 1}`}
  377 + style={{
  378 + width: '100%',
  379 + height: '100%',
  380 + objectFit: 'cover'
  381 + }}
  382 + />
  383 + </div>
  384 + );
  385 + })}
  386 + </div>
  387 + );
  388 + }
  389 + }
  390 + return (
  391 + <Col key={child.sId} span={iColValue} order={iOrder} id="imgView" >
  392 + <div style={{
  393 + display: 'flex',
  394 + alignItems: 'flex-start',
  395 + padding: '8px 0 16px 0',
  396 + minHeight: '140px',
  397 + marginBottom: '16px',
  398 + position: 'relative',
  399 + zIndex: 1,
  400 + height:'100px'
  401 + }}>
  402 + {/* 左侧字段名 - 增大字体 */}
  403 + <span style={{
  404 + flex: 'none',
  405 + paddingRight: '12px',
  406 + // fontWeight: 'bold',
  407 + minWidth: '90px',
  408 + fontSize: '18px',
  409 + color: 'rgba(0, 0, 0, 0.85)',
  410 + lineHeight: '28px',
  411 + }}>
  412 + {child.showName || child.sName}:
  413 + </span>
  414 + {/* 右侧图片内容 - 确保不被遮挡 */}
  415 + <div style={{
  416 + flex: 1,
  417 + marginLeft: '55px',
  418 + minHeight: '120px',
  419 + overflow: 'visible',
  420 + paddingBottom: '8px'
  421 + }}>
  422 + {imgBox || <span style={{ color: '#999', fontSize: '18px' }}></span>}
  423 + </div>
  424 + </div>
  425 + </Col>
  426 + );
  427 + }
311 if (child.sControlName?.includes('DividerArea')) { 428 if (child.sControlName?.includes('DividerArea')) {
312 return ( 429 return (
313 <Col key={child.sId} span={24} order={iOrder}> 430 <Col key={child.sId} span={24} order={iOrder}>
@@ -361,7 +478,7 @@ export default class CommonViewTable extends Component { @@ -361,7 +478,7 @@ export default class CommonViewTable extends Component {
361 enabledNew = true; 478 enabledNew = true;
362 } 479 }
363 480
364 - const viewRowNew = this.props.getViewRow?.(child) || viewRow; 481 + // const viewRowNew = this.props.getViewRow?.(child) || viewRow;
365 482
366 const showTypeProps = { 483 const showTypeProps = {
367 app, 484 app,
src/mobile/common/CommobilePadBill/index.less
@@ -93,6 +93,10 @@ @@ -93,6 +93,10 @@
93 .ant-col { 93 .ant-col {
94 height: 45px; 94 height: 45px;
95 } 95 }
  96 + #imgView{
  97 + padding:10px;
  98 + height:150px!important;
  99 + }
96 100
97 .ant-col.ant-col-24.ant-col-order-5 { 101 .ant-col.ant-col-24.ant-col-order-5 {
98 height: auto; 102 height: auto;
@@ -357,4 +361,4 @@ @@ -357,4 +361,4 @@
357 border-top: 1px solid #AAA; 361 border-top: 1px solid #AAA;
358 font-size: 12px; 362 font-size: 12px;
359 padding-left: 4px; 363 padding-left: 4px;
360 -}  
361 \ No newline at end of file 364 \ No newline at end of file
  365 +}
src/mobile/components/FileManageMobile.js
@@ -237,6 +237,7 @@ class FileManageMobile extends React.Component { @@ -237,6 +237,7 @@ class FileManageMobile extends React.Component {
237 const album = commonFunc.showLocalMessage(this.props, 'Album', '相册'); 237 const album = commonFunc.showLocalMessage(this.props, 'Album', '相册');
238 238
239 const btnCancel = commonFunc.showLocalMessage(this.props, 'btnCancel', '取消'); 239 const btnCancel = commonFunc.showLocalMessage(this.props, 'btnCancel', '取消');
  240 + const bPad = location.pathname.toLowerCase()?.indexOf('pad') > -1;
240 241
241 /* 上传照片样式定位 */ 242 /* 上传照片样式定位 */
242 let imgDivTop = '500'; 243 let imgDivTop = '500';
@@ -250,12 +251,42 @@ class FileManageMobile extends React.Component { @@ -250,12 +251,42 @@ class FileManageMobile extends React.Component {
250 } 251 }
251 } 252 }
252 } 253 }
  254 + if (bPad) {
  255 + // 正确获取单个元素
  256 + const mobileBarStyle = document.getElementById('imgView');
  257 + // 判断元素是否存在
  258 + if (mobileBarStyle) {
  259 + // 获取元素高度(3种任选,我给你最稳的)
  260 + const obj = mobileBarStyle.getBoundingClientRect();
  261 + const dHeight = document.documentElement.clientHeight; // 屏幕可视高度
  262 +
  263 + // 你原来的逻辑我帮你修正
  264 + if (obj.top < dHeight) {
  265 + imgDivTop = Math.floor(obj.top + 30);
  266 + }
  267 + }
  268 + }
  269 +
253 270
254 return ( 271 return (
255 <div> 272 <div>
256 {commonUtils.isEmptyObject(btnUpdConfig) ? '' : 273 {commonUtils.isEmptyObject(btnUpdConfig) ? '' :
257 <div className="content"> 274 <div className="content">
258 - <div className={styles.commonImage} id="imgDiv" key="imgDivKey" style={{ top: imgDivTop }}> 275 + {/* 隐藏字段,用于存储所有图片路径 */}
  276 + <input
  277 + type="hidden"
  278 + id="hiddenPicturePaths"
  279 + value={commonUtils.isNotEmptyArr(files) ? files.map(f => f.filePath).join(',') : ''}
  280 + onChange={(e) => {
  281 + console.log('隐藏字段值:', e.target.value);
  282 + // 触发自定义事件,通知其他组件图片路径更新
  283 + const event = new CustomEvent('picturePathsUpdated', {
  284 + detail: { paths: e.target.value }
  285 + });
  286 + window.dispatchEvent(event);
  287 + }}
  288 + />
  289 + <div className={styles.commonImage} id="imgDiv" key="imgDivKey" style={{ top: imgDivTop, left: bPad ? '20%' : null }} >
259 { 290 {
260 commonUtils.isNotEmptyArr(files) && files.length > 0 ? 291 commonUtils.isNotEmptyArr(files) && files.length > 0 ?
261 files.map((child) => { 292 files.map((child) => {