From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/views/billprint/index.jsx |  250 ++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 211 insertions(+), 39 deletions(-)

diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx
index a3764b8..d1e8084 100644
--- a/src/views/billprint/index.jsx
+++ b/src/views/billprint/index.jsx
@@ -5,9 +5,9 @@
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
+import options, { styles } from '@/store/options.js'
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
-import options from '@/store/options.js'
 import UtilsDM from '@/utils/utils-datamanage.js'
 import NotFount from '@/components/404'
 import asyncComponent from '@/utils/asyncComponent'
@@ -25,6 +25,7 @@
 const NormalTable = asyncComponent(() => import('@/tabviews/custom/components/table/normal-table'))
 const SandBox = asyncComponent(() => import('@/tabviews/custom/components/code/sand-box'))
 const TimeLine = asyncComponent(() => import('@/tabviews/custom/components/timeline/normal-timeline'))
+const Balcony = asyncComponent(() => import('@/tabviews/custom/components/card/balcony'))
 
 class BillPrint extends Component {
   state = {
@@ -36,26 +37,38 @@
     data: '',
     tempId: '',
     config: null,
+    auto: true
   }
 
   UNSAFE_componentWillMount() {
-    try {
-      let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
+    const { params } = this.props.match
 
-      sessionStorage.setItem('dataM', param.dataM || '')
-      sessionStorage.setItem('localDataM', param.dataM || '')
+    if (params.menuId) {
       this.setState({
-        BID: param.id || '',
-        tempId: param.tempId
+        BID: params.id || '',
+        tempId: params.menuId
       }, () => {
-        this.getMenuParam()
+        this.getTouristMsg()
       })
-    } catch (e) {
-      notification.warning({
-        top: 92,
-        message: '鑿滃崟淇℃伅瑙f瀽閿欒锛�',
-        duration: 5
-      })
+    } else {
+      try {
+        let param = JSON.parse(window.decodeURIComponent(window.atob(params.param)))
+  
+        sessionStorage.setItem('dataM', param.dataM || '')
+        sessionStorage.setItem('localDataM', param.dataM || '')
+        this.setState({
+          BID: param.id || '',
+          tempId: param.tempId
+        }, () => {
+          this.getMenuParam()
+        })
+      } catch (e) {
+        notification.warning({
+          top: 92,
+          message: '鑿滃崟淇℃伅瑙f瀽閿欒锛�',
+          duration: 5
+        })
+      }
     }
   }
 
@@ -72,6 +85,55 @@
     }
   }
 
+  getTouristMsg = () => {
+    Api.getTouristMsg().then(result => {
+      if (result.status) {
+        sessionStorage.setItem('UserID', result.UserID || '')
+        sessionStorage.setItem('LoginUID', result.LoginUID || '')
+        sessionStorage.setItem('dataM', 'false')
+
+        this.getMenuParam()
+
+        // 鑾峰彇绯荤粺淇℃伅
+        let _param = {
+          func: 's_Get_style',
+          TypeCharOne: 'PC',
+          LText: `select '${window.GLOB.appkey}'`,
+        }
+
+        _param.userid = result.UserID
+        _param.LoginUID = result.LoginUID
+        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
+
+        Api.getSystemConfig(_param).then(res => {
+          if (res.status) {
+            window.GLOB.style = res.CSS
+            document.title = res.titleName
+        
+            if (window.GLOB.style && styles[window.GLOB.style]) {
+              document.body.className = styles[window.GLOB.style] + ' ' + (res.split_line_show === 'false' ? 'hidden-split-line' : '')
+            }
+
+            if (res.titlelogo) {
+              let link = document.querySelector("link[rel*='icon']") || document.createElement('link')
+              link.type = 'image/x-icon'
+              link.rel = 'shortcut icon'
+              link.href = res.titlelogo
+              document.getElementsByTagName('head')[0].appendChild(link)
+            }
+          }
+        })
+      } else {
+        notification.warning({
+          top: 92,
+          message: result.message,
+          duration: 5
+        })
+      }
+    })
+  }
+
   getMenuParam = () => {
     const { tempId, BID } = this.state
 
@@ -79,6 +141,8 @@
       func: 'sPC_Get_LongParam',
       MenuID: tempId
     }
+
+    window.GLOB.dataFormat = false // 鎵撳嵃鍘婚櫎姘村嵃
 
     if (window.GLOB.mainSystemApi) { // 浠庡崟鐐圭櫥褰曟湇鍔″櫒鍙栨墦鍗伴厤缃俊鎭�
       _param.rduri = window.GLOB.mainSystemApi
@@ -186,6 +250,21 @@
           if (component.search) component.search = []
           component.data = [] // 鍒濆鍖栨暟鎹负绌�
 
+          if (component.type === 'table' && component.subtype === 'normaltable') {
+            let getColumns = (cols) => {
+              return cols.map(item => {
+                if (item.type === 'colspan') {
+                  item.subcols = getColumns(item.subcols)
+                } else {
+                  item.IsSort = 'false'
+                }
+          
+                return item
+              })
+            }
+            component.cols = getColumns(component.cols)
+          }
+
           if (component.wrap.datatype === 'static') {
             component.format = ''
           }
@@ -292,7 +371,7 @@
   }
 
   /**
-   * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁�
+   * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼鍙傛暟
    */
   getDefaultParam = (component) => {
     const { columns, setting, dataName, format } = component
@@ -308,7 +387,7 @@
     }
 
     // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
-    if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
+    if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
       _customScript &&  console.info(`${_dataresource ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`)
       _dataresource &&  console.info(_dataresource)
     }
@@ -332,12 +411,26 @@
     if (!params || params.length === 0) return ''
     let LText_field = []
     let transaction = false
+
+    let userName = sessionStorage.getItem('User_Name') || ''
+    let fullName = sessionStorage.getItem('Full_Name') || ''
+    let RoleID = sessionStorage.getItem('role_id') || ''
+    let departmentcode = sessionStorage.getItem('departmentcode') || ''
+    let organization = sessionStorage.getItem('organization') || ''
+    let city = sessionStorage.getItem('city') || ''
+  
+    if (sessionStorage.getItem('isEditState') === 'true') {
+      userName = sessionStorage.getItem('CloudUserName') || ''
+      fullName = sessionStorage.getItem('CloudFullName') || ''
+    }
+
     let LText = params.map((item, index) => {
       let _sql = item.sql
       let _script = item.script
 
       if (index === 0) {
-        _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg =''
+        _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@login_city nvarchar(50)
+          select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @login_city='${city}'
           ${_script}
         `
       }
@@ -424,6 +517,12 @@
         this.setState({loadingview: false, pages})
       }
 
+      let auto = true
+
+      if (comps[comps.length - 1].wrap && comps[comps.length - 1].wrap.printHeight) {
+        auto = false
+      }
+
       while (!over) {
         let page = []
         let count = 0
@@ -445,23 +544,57 @@
             return
           } else if (item.subtype === 'datacard' || item.type === 'table') {
             if (_item.dataArray && _item.dataArray.length > 0) {
-              item.data = []
-
-              while (count < limit && _item.dataArray.length > 0) {
-                item.data.push(_item.dataArray.shift())
-                count++
-              }
+              if (item.subtype === 'datacard' && item.wrap.layout === 'flex') {
+                if (!item.added && item.wrap.printHeight) {
+                  count += item.wrap.printHeight
+                  if (count >= limit) {
+                    _pageover = true
+                  }
+                  if (count <= limit) {
+                    _item.added = true
+                    page.push(item)
+                  }
+                } else if (!item.added) {
+                  _item.added = true
+                  page.push(item)
+                }
+              } else {
+                item.data = []
   
-              if (count >= limit) {
-                _pageover = true
+                while (count + 1 <= limit && _item.dataArray.length > 0) {
+                  item.data.push(_item.dataArray.shift())
+                  count++
+                }
+    
+                if (count >= limit) {
+                  _pageover = true
+                }
+                page.push(item)
               }
+              _item.added = true
+            } else if (!item.added) {
+              _item.added = true
+              page.push(item)
+            }
+          } else if (!item.added && item.wrap && item.wrap.printHeight) {
+            if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) {
+              _item.added = true
+              return
+            }
+
+            count += item.wrap.printHeight
+            if (count >= limit) {
+              _pageover = true
+            }
+            if (count <= limit) {
+              _item.added = true
               page.push(item)
             }
           } else if (!item.added) {
             _item.added = true
             page.push(item)
           }
-
+          
           if (index + 1 >= length && !_pageover) {
             pagesover = true
           }
@@ -491,16 +624,49 @@
               return
             } else if (item.subtype === 'datacard' || item.type === 'table') {
               if (_item.dataArray && _item.dataArray.length > 0) {
-                item.data = []
-  
-                while (count < limit && _item.dataArray.length > 0) {
-                  item.data.push(_item.dataArray.shift())
-                  count++
+                if (item.subtype === 'datacard' && item.wrap.layout === 'flex') {
+                  if (!item.added && item.wrap.printHeight) {
+                    count += item.wrap.printHeight
+                    if (count >= limit) {
+                      _pageover = true
+                    }
+                    if (count <= limit) {
+                      _item.added = true
+                      page.push(item)
+                    }
+                  } else if (!item.added) {
+                    _item.added = true
+                    page.push(item)
+                  }
+                } else {
+                  item.data = []
+
+                  while (count + 1 <= limit && _item.dataArray.length > 0) {
+                    item.data.push(_item.dataArray.shift())
+                    count++
+                  }
+      
+                  if (count >= limit) {
+                    _pageover = true
+                  }
+                  page.push(item)
                 }
-    
-                if (count >= limit) {
-                  _pageover = true
-                }
+                _item.added = true
+              } else if (!item.added) {
+                _item.added = true
+                page.push(item)
+              }
+            } else if (!item.added && item.wrap && item.wrap.printHeight) {
+              if (item.wrap.empty === 'hidden' && (!item.data || item.data.length === 0)) {
+                _item.added = true
+                return
+              }
+              count += item.wrap.printHeight
+              if (count >= limit) {
+                _pageover = true
+              }
+              if (count <= limit) {
+                _item.added = true
                 page.push(item)
               }
             } else if (!item.added) {
@@ -522,7 +688,7 @@
         }
       }
 
-      this.setState({loadingview: false, pages})
+      this.setState({loadingview: false, pages, auto})
     })
   }
 
@@ -551,7 +717,7 @@
           doc.write(`<LINK rel="stylesheet" type="text/css" href="${linkList[i].href}">`)
         }
       }
-      doc.write(`<style>body{width: ${config.width}px!important;}*{border-style: solid;border-width: 0;}</style>`)
+      doc.write(`<style>body{width: ${config.width}px!important;}*{border-style: solid;border-width: 0;}.ant-table-placeholder{display: none;}.ant-empty{display: none;}</style>`)
       for (let i = 0;i < styleList.length;i++) {
         doc.write('<style>' + styleList[i].innerHTML + '</style>')
       }
@@ -635,6 +801,12 @@
             <SandBox config={item} initdata={item.data} mainSearch={[]} menuType="" />
           </Col>
         )
+      } else if (item.type === 'balcony') {
+        return (
+          <Col span={item.width} key={item.uuid}>
+            <Balcony config={item} initdata={item.data} menuType="" />
+          </Col>
+        )
       } else if (item.type === 'timeline') {
         return (
           <Col span={item.width} key={item.uuid}>
@@ -648,13 +820,13 @@
   }
 
   render() {
-    const { loadingview, viewlost, config, pages } = this.state
+    const { loadingview, viewlost, config, pages, auto } = this.state
 
     return (
       <div className="bill-print-wrap" >
         {loadingview && <Spin size="large" />}
         {pages ? <div id="bill-print">
-          {pages.map((components, index) => (<div className="print-page" key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row>{this.getComponents(components)}</Row></div>))}
+          {pages.map((components, index) => (<div className={'print-page' + (auto ? ' auto' : '')} key={index} style={{...config.style, overflow: 'hidden', boxSizing: 'border-box'}}><Row>{this.getComponents(components)}</Row></div>))}
         </div> : null}
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
         {pages && !loadingview && !viewlost ? <div className="print-button"><Button icon="printer" size="large" shape="circle" onClick={this.print}></Button></div> : null}

--
Gitblit v1.8.0