From 9353bc84d8c65da2130db48a2fe48dd714b0acb9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 23 五月 2021 00:05:18 +0800
Subject: [PATCH] 2021-05-23

---
 src/tabviews/zshare/normalTable/index.jsx |   42 +++++++++++++++++++++---------------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx
index ac7f9c5..aa989fb 100644
--- a/src/tabviews/zshare/normalTable/index.jsx
+++ b/src/tabviews/zshare/normalTable/index.jsx
@@ -17,6 +17,7 @@
 const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton'))
 const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton'))
 const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
+const ImgScale = asyncComponent(() => import('@/tabviews/zshare/imgScale'))
 
 class NormalTable extends Component {
   static propTpyes = {
@@ -45,7 +46,7 @@
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
     columns: null,        // 鏄剧ず鍒�
     imgShow: false,       // 鍥剧墖鏀惧ぇ妯℃�佹
-    imgSrc: '',           // 鍥剧墖璺緞
+    imgData: {},          // 鍥剧墖闆�
     lineMarks: null,      // 琛屾爣璁�
     activeIndex: null,    // 鏍囪褰撳墠閫変腑琛�
     rowspans: null        // 琛屽悎骞跺瓧娈典俊鎭�
@@ -547,7 +548,7 @@
       let photos = ''
       if (item.field && record.hasOwnProperty(item.field)) {
         photos = record[item.field] + ''
-        photos = photos.split(',')
+        photos = photos.split(',').filter(Boolean)
       } else {
         photos = ''
       }
@@ -557,7 +558,7 @@
         <div className="picture-col">
           {photos && photos.map((url, i) => {
             if (item.scale === 'true') {
-              return <img style={{maxHeight: maxHeight}} className="image-scale" onClick={this.imgScale} key={`${i}`} src={url} alt=""/>
+              return <img style={{maxHeight: maxHeight}} className="image-scale" onClick={() => this.imgScale(photos, i)} key={`${i}`} src={url} alt=""/>
             } else {
               return <img style={{maxHeight: maxHeight}} key={`${i}`} src={url} alt=""/>
             }
@@ -733,7 +734,7 @@
           let photos = []
           try {
             photos = record[col.field] + ''
-            photos = photos.split(',')
+            photos = photos.split(',').filter(Boolean)
           } catch {
             photos = []
           }
@@ -869,9 +870,8 @@
         <div className="content-fence">
           <div className="content-fence-top" style={images[0] ? {textAlign: images[0].align} : null}>
             {images.map((_img, index) => {
-              if (!_img.url) return ''
               if (_img.scale) {
-                return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={this.imgScale} key={`${index}`} src={_img.url} alt=""/>
+                return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={() => this.imgScale(images, index)} key={`${index}`} src={_img.url} alt=""/>
               } else {
                 return (<img style={{maxHeight: _img.maxHeight}} key={`${index}`} src={_img.url} alt=""/>)
               }
@@ -889,9 +889,8 @@
         <div className="content-fence">
           <div className="content-fence-left" style={images[0] ? {textAlign: images[0].align} : null}>
             {images.map((_img, index) => {
-              if (!_img.url) return ''
               if (_img.scale) {
-                return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={this.imgScale} key={`${index}`} src={_img.url} alt=""/>
+                return <img style={{maxHeight: _img.maxHeight}} className="image-scale" onClick={() => this.imgScale(images, index)} key={`${index}`} src={_img.url} alt=""/>
               } else {
                 return (<img style={{maxHeight: _img.maxHeight}} key={`${index}`} src={_img.url} alt=""/>)
               }
@@ -910,18 +909,19 @@
   /**
    * @description 鍥剧墖缂╂斁
    */
-  imgScaleClose = () => {
+  imgScale = (images, index) => {
     this.setState({
-     imgShow: false
+      imgShow: true,
+      imgData: {
+        list: images.map(item => {
+          if (typeof(item) === 'string') {
+            return item
+          }
+          return item.url
+        }),
+        index
+      }
     })
-  }
-  imgScale = (e) => {
-    if (e.target.nodeName === 'IMG') {
-      this.setState({
-        imgShow: true,
-        imgSrc: e.target.src
-      })
-    }
   }
 
   /**
@@ -1237,12 +1237,12 @@
           visible={this.state.imgShow}
           width="70vw"
           maskClosable={true}
-          onCancel={this.imgScaleClose}
+          onCancel={() => {this.setState({ imgShow: false })}}
           title={this.props.dict['main.form.picture.check']}
-          footer={[<span key="close" onClick={this.imgScaleClose}>{this.props.dict['main.close']}</span>]}
+          footer={[<span key="close" onClick={() => {this.setState({ imgShow: false })}}>{this.props.dict['main.close']}</span>]}
           destroyOnClose
         >
-         <img style={{maxWidth:'100%'}} src={this.state.imgSrc} alt="" />
+          <ImgScale data={this.state.imgData}/>
         </Modal>
       </div>
     )

--
Gitblit v1.8.0