Browse Source

合同打印问题调整

liangluogis 2 years ago
parent
commit
d73b484275

BIN
public/Lodop/CLodop_Setup_for_Win32NT.exe


BIN
public/Lodop/install_lodop32.exe


BIN
public/Lodop/install_lodop64.exe


+ 1 - 1
src/components/projectCom/fileShow/index.vue

@@ -38,6 +38,7 @@
         <template v-for="(item, index) in otherList">
           <div class="otherItem" :key="currentDate + '_otherItem_' + index">
             <a :href="item.address" :download="item.fileName">{{ item.fileName }}</a>
+              <slot></slot>
           </div>
         </template>
       </div>
@@ -47,7 +48,6 @@
         <span>暂无附件</span>
       </div>
     </template>
-    <slot></slot>
   </div>
 </template>
 

+ 3 - 0
src/components/projectCom/inputForm/index.vue

@@ -151,7 +151,10 @@
                     :inputData="item.inputData"
                     :code="item.code"
                     :serviceImpls="item.serviceImpls"
+                    :buttonShow='item.buttonShow'
                     v-model="ruleForm[item.field]"
+                    :buttonTitle="item.buttonTitle"
+                    :buttonClick='item.buttonClick'
                     @change="updateModel"
                   ></linkFileLook>
                 </el-form-item>

+ 7 - 1
src/components/projectCom/linkFileLook/index.vue

@@ -1,7 +1,10 @@
 
 <template>
   <!-- 本组件用于查看部分环节的附件 -->
-  <fileShow v-if="this.fileList" :fileList="this.fileList"></fileShow>
+  <fileShow v-if="this.fileList" :fileList="this.fileList">
+      <el-button style="margin-left: 30px;" v-if='buttonShow&&buttonClick'  type="success" @click="buttonClick(fileList)">{{buttonTitle}}</el-button>
+  </fileShow>
+
 </template>
 
 <script>
@@ -11,6 +14,9 @@ export default {
   components:{fileShow},
   props:{ 
     inputData:null,
+    buttonShow:false,
+    buttonTitle:null,
+    buttonClick:null,
     code:null,
     field:"",
     serviceImpls:null,

+ 4 - 2
src/components/projectCom/table/index.vue

@@ -20,12 +20,13 @@
         <img src="@/assets/icon/null.png" alt="" />
         <p class="empty-p">暂无数据</p>
       </template>
-      <el-table-column v-if="config.check" align="center" type="selection" width="55" />
-      <el-table-column v-if="config.index" align="center" type="index" width="50" label="序号" />
+      <el-table-column v-if="config.check" :fixed="config.fieldList[0].fixed" align="center" type="selection" width="55" />
+      <el-table-column :fixed="config.fieldList[0].fixed" v-if="config.index" align="center" type="index" width="50" label="序号" />
       <template v-for="(item, index) in config.fieldList">
         <el-table-column
           :key="currentDate + 'header_' + index"
           align="center"
+          :fixed="item.fixed"
           :prop="item.field"
           :width="item.width ? item.width : ''"
           :min-width="item.minWidth"
@@ -98,6 +99,7 @@ export default {
         dataList:[],//同步数据
         showFoot:true,
         size:30,
+        fixedInfo:[''],
         testData: false, // 是否使用测试数据
         handleTimeData:true,//是否处理时间数据
         fieldList: [

+ 2 - 1
src/main.js

@@ -27,7 +27,8 @@ import './utils/dialog'
 
 // 全局修改默认配置,点击空白处不能关闭弹窗
 ElementUI.Dialog.props.closeOnClickModal.default = false
-
+import printPdf from '@/utils/printPdf'
+Vue.use(printPdf)
 import echarts from 'echarts'
 Vue.prototype.$echarts = echarts
 import html2pdf from '@/utils/html2pdf'

+ 256 - 0
src/utils/LodopFuncs.js

@@ -0,0 +1,256 @@
+import { MessageBox, Message } from 'element-ui'
+//==本JS是加载Lodop插件或Web打印服务CLodop/Lodop7的综合示例,可直接使用,建议理解后融入自己程序==
+
+//用双端口加载主JS文件Lodop.js(或CLodopfuncs.js兼容老版本)以防其中某端口被占:
+var MainJS ="CLodopfuncs.js",
+    URL_WS1   = "ws://localhost:8000/"+MainJS,                //ws用8000/18000
+    URL_WS2   = "ws://localhost:18000/"+MainJS,
+    URL_HTTP1 = "http://localhost:8000/"+MainJS,              //http用8000/18000
+    URL_HTTP2 = "http://localhost:18000/"+MainJS,
+    URL_HTTP3 = "https://localhost.lodop.net:8443/"+MainJS;   //https用8000/8443
+
+var CreatedOKLodopObject, CLodopIsLocal, LoadJsState;
+
+//==判断是否需要CLodop(那些不支持插件的浏览器):==
+function needCLodop() {
+    try {
+        var ua = navigator.userAgent;
+        if (ua.match(/Windows\sPhone/i) ||
+            ua.match(/iPhone|iPod|iPad/i) ||
+            ua.match(/Android/i) ||
+            ua.match(/Edge\D?\d+/i))
+            return true;
+        var verTrident = ua.match(/Trident\D?\d+/i);
+        var verIE = ua.match(/MSIE\D?\d+/i);
+        var verOPR = ua.match(/OPR\D?\d+/i);
+        var verFF = ua.match(/Firefox\D?\d+/i);
+        var x64 = ua.match(/x64/i);
+        if ((!verTrident) && (!verIE) && (x64)) return true;
+        else if (verFF) {
+            verFF = verFF[0].match(/\d+/);
+            if ((verFF[0] >= 41) || (x64)) return true;
+        } else if (verOPR) {
+            verOPR = verOPR[0].match(/\d+/);
+            if (verOPR[0] >= 32) return true;
+        } else if ((!verTrident) && (!verIE)) {
+            var verChrome = ua.match(/Chrome\D?\d+/i);
+            if (verChrome) {
+                verChrome = verChrome[0].match(/\d+/);
+                if (verChrome[0] >= 41) return true;
+            }
+        }
+        return false;
+    } catch (err) {
+        return true;
+    }
+}
+
+//==检查加载成功与否,如没成功则用http(s)再试==
+//==低版本CLODOP6.561/Lodop7.043及前)用本方法==
+function checkOrTryHttp() {
+  if (window.getCLodop) {
+     LoadJsState = "complete";
+     return true;
+  }
+  if (LoadJsState == "loadingB" || LoadJsState == "complete") return;
+  LoadJsState = "loadingB";
+  var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
+  var JS1 = document.createElement("script")
+     ,JS2 = document.createElement("script")
+     ,JS3 = document.createElement("script");
+  JS1.src = URL_HTTP1;
+  JS2.src = URL_HTTP2;
+  JS3.src = URL_HTTP3;
+  JS1.onload = JS2.onload = JS3.onload = JS2.onerror = JS3.onerror=function(){LoadJsState = "complete";}
+  JS1.onerror = function(e) {
+      if (window.location.protocol !== 'https:')
+          head.insertBefore(JS2, head.firstChild); else
+          head.insertBefore(JS3, head.firstChild);
+  }
+  head.insertBefore(JS1,head.firstChild);
+}
+
+//==加载Lodop对象的主过程:==
+(function loadCLodop(){
+  if (!needCLodop()) return;
+  CLodopIsLocal = !!((URL_WS1 + URL_WS2).match(/\/\/localho|\/\/127.0.0./i));
+  LoadJsState = "loadingA";
+  if (!window.WebSocket && window.MozWebSocket) window.WebSocket=window.MozWebSocket;
+  //ws方式速度快(小于200ms)且可避免CORS错误,但要求Lodop版本足够新:
+  try {
+    var WSK1=new WebSocket(URL_WS1);
+    WSK1.onopen = function(e) { setTimeout("checkOrTryHttp();",200); }
+    WSK1.onmessage = function(e) {if (!window.getCLodop) eval(e.data);}
+    WSK1.onerror = function(e) {
+         var WSK2=new WebSocket(URL_WS2);
+         WSK2.onopen = function(e) {setTimeout("checkOrTryHttp();",200);}
+         WSK2.onmessage = function(e) {if (!window.getCLodop) eval(e.data);}
+         WSK2.onerror= function(e) {checkOrTryHttp();}
+    }
+  } catch(e){
+    checkOrTryHttp();
+  }
+})();
+
+//==获取LODOP对象主过程,判断是否安装、需否升级:==
+function getLodop(oOBJECT, oEMBED) {
+    var strFontTag = "打印控件";
+    var strLodopInstall = strFontTag + "未安装,请点击确认按钮,下载并安装打印插件";
+    var strLodopUpdate = strFontTag + "需要升级,请点击确认按钮,下载并升级打印插件";
+    var strLodop64Install = strFontTag + "未安装,请点击确认按钮,下载并安装打印插件";
+    var strLodop64Update = strFontTag + "需要升级,请点击确认按钮,下载并升级打印插件";
+    var strCLodopInstallA = "Web打印服务CLodop未安装启动";
+    var strCLodopInstallB = "若此前已安装过,请查看打印服务是否已启动";
+    var strCLodopUpdate = " Web打印服务CLodop需升级,请点击确认按钮,进行升级";
+
+    var strLodop7FontTag = "<br><font color='#FF00FF'>Web打印服务Lodop7";
+    var strLodop7HrefX86 = "点击这里<a href='Lodop7_Linux_X86_64.tar.gz' target='_self'>下载安装</a>(下载后解压,点击lodop文件开始执行)";
+    var strLodop7HrefARM = "点击这里<a href='Lodop7_Linux_ARM64.tar.gz'  target='_self'>下载安装</a>(下载后解压,点击lodop文件开始执行)";
+    var strLodop7Install_X86 = strLodop7FontTag + "未安装启动," + strLodop7HrefX86;
+    var strLodop7Install_ARM = strLodop7FontTag + "未安装启动," + strLodop7HrefARM;
+    var strLodop7Update_X86 = strLodop7FontTag + "需升级," + strLodop7HrefX86;
+    var strLodop7Update_ARM = strLodop7FontTag + "需升级," + strLodop7HrefARM;
+    var strInstallOK = ",成功后请刷新本页面或重启浏览器";
+
+    //var 安装,升级路径
+    var installPath32 = "http://183.255.30.6:8082/Lodop/install_lodop32.exe"
+    var installPath64 = "http://183.255.30.6:8082/Lodop/install_lodop64.exe"
+    var updatePath64 = "http://183.255.30.6:8082/Lodop/CLodop_Setup_for_Win32NT.exe"
+
+    var LODOP;
+    try {
+        var isWinIE = (/MSIE/i.test(navigator.userAgent)) || (/Trident/i.test(navigator.userAgent));
+        var isWinIE64 = isWinIE && (/x64/i.test(navigator.userAgent));
+        var isLinuxX86 = (/Linux/i.test(navigator.platform)) && (/x86/i.test(navigator.platform));
+        var isLinuxARM = (/Linux/i.test(navigator.platform)) && (/aarch/i.test(navigator.platform));
+
+        if (needCLodop() || isLinuxX86 || isLinuxARM) {
+            try {
+                LODOP = window.getCLodop();
+            } catch (err) {}
+            if (!LODOP && LoadJsState !== "complete") {
+                if (!LoadJsState){
+                  MessageBox.confirm('未曾加载Lodop主JS文件,请先调用loadCLodop过程.', '系统提示', {
+                    confirmButtonText: '确定',
+                    type: 'warning'
+                  })
+                }else{
+                  MessageBox.confirm('网页还没下载完毕,请稍等一下再操作', '系统提示', {
+                    confirmButtonText: '确定',
+                    cancelButtonText: '取消'
+                  })
+                }
+                return;
+            }
+            var strAlertMessage;
+            if (!LODOP) {
+                if (isLinuxX86)
+                    strAlertMessage = strLodop7Install_X86;
+                else if (isLinuxARM)
+                    strAlertMessage = strLodop7Install_ARM;
+                else{
+                  strAlertMessage = strCLodopInstallA + (CLodopIsLocal ? ','+strCLodopInstallB : "");
+                  // document.body.innerHTML = strAlertMessage + strInstallOK + document.body.innerHTML;
+                  let msgHtml = strAlertMessage + strInstallOK;
+                  MessageBox.confirm(msgHtml, '提示', {
+                    confirmButtonText: '确定',
+                    cancelButtonText: '取消',
+                    type: 'warning'
+                  }).then((action) => {
+                    if(action=="confirm"){
+                      window.open(updatePath64)
+                    }
+                  })
+                }
+                return;
+            } else {
+                if (isLinuxX86 && LODOP.CVERSION < "7.0.4.3")
+                    strAlertMessage = strLodop7Update_X86;
+                else if (isLinuxARM && LODOP.CVERSION < "7.0.4.3")
+                    strAlertMessage = strLodop7Update_ARM;
+                else if (CLODOP.CVERSION < "6.5.6.9")
+                    strAlertMessage = strCLodopUpdate;
+
+                if (strAlertMessage){
+                  // document.body.innerHTML = strAlertMessage + strInstallOK + document.body.innerHTML;
+                  let msgHtml = strAlertMessage + ','+ strInstallOK;
+                  MessageBox.confirm(msgHtml, '提示', {
+                    confirmButtonText: '确定',
+                    cancelButtonText: '取消',
+                    type: 'warning'
+                  }).then((action) => {
+                    if(action=="confirm"){
+                      window.open(updatePath64)
+                    }
+                  })
+                }
+                    
+            }
+        } else {
+            //==如果页面有Lodop插件就直接使用,否则新建:==
+            if (oOBJECT || oEMBED) {
+                if (isWinIE)
+                    LODOP = oOBJECT;
+                else
+                    LODOP = oEMBED;
+            } else if (!CreatedOKLodopObject) {
+                LODOP = document.createElement("object");
+                LODOP.setAttribute("width", 0);
+                LODOP.setAttribute("height", 0);
+                LODOP.setAttribute("style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;");
+                if (isWinIE)
+                    LODOP.setAttribute("classid", "clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
+                else
+                    LODOP.setAttribute("type", "application/x-print-lodop");
+                document.documentElement.appendChild(LODOP);
+                CreatedOKLodopObject = LODOP;
+            } else
+                LODOP = CreatedOKLodopObject;
+            //==Lodop插件未安装时提示下载地址:==
+            if ((!LODOP) || (!LODOP.VERSION)) {
+                // document.body.innerHTML = (isWinIE64 ? strLodop64Install : strLodopInstall) + strInstallOK + document.body.innerHTML;
+                let msgHtml = (isWinIE64 ? strLodop64Install : strLodopInstall) + ','+ strInstallOK;
+                let openUrl = isWinIE64 ? installPath64 : installPath32
+                MessageBox.confirm(msgHtml, '提示', {
+                  confirmButtonText: '确定',
+                  cancelButtonText: '取消',
+                  type: 'warning'
+                }).then((action) => {
+                  if(action=="confirm"){
+                    window.open(openUrl)
+                  }
+                })
+                return LODOP;
+            }
+            if (LODOP.VERSION < "6.2.2.6") {
+                // document.body.innerHTML = (isWinIE64 ? strLodop64Update : strLodopUpdate) + strInstallOK + document.body.innerHTML;
+                let msgHtml = (isWinIE64 ? strLodop64Update : strLodopUpdate) + ','+ strInstallOK;
+                let openUrl = isWinIE64 ? installPath64 : installPath32
+                MessageBox.confirm(msgHtml, '提示', {
+                  confirmButtonText: '确定',
+                  cancelButtonText: '取消',
+                  type: 'warning'
+                }).then((action) => {
+                  if(action=="confirm"){
+                    window.open(openUrl)
+                  }
+                })
+            }
+        }
+        //===如下空白位置适合调用统一功能(如注册语句、语言选择等):=======================
+
+
+        //===============================================================================
+        return LODOP;
+    } catch (err) {
+        MessageBox.confirm('getLodop出错' + err, '确认注销', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          
+        })
+    }
+}
+
+export { getLodop } // 导出getLodop

+ 70 - 0
src/utils/printPdf.js

@@ -0,0 +1,70 @@
+import { getLodop } from '@/utils/LodopFuncs'
+export default {
+  install(Vue, options) {
+    Vue.prototype.$printPdf = function(strURL) {
+      debugger
+      // const domId = 'pdfDom'
+      let LODOP = null
+      // const shareContent = document.getElementById(domId) // 需要截图的包裹的(原生的)DOM 对象
+      // const width = shareContent.clientWidth // 获取dom 宽度
+      // const height = shareContent.clientHeight // 获取dom 高度
+      // var strBodyStyle = '<style>' + shareContent.innerHTML + '</style>'
+      // var strFormHtml = strBodyStyle + '<body>' + shareContent.innerHTML + '</body>'
+      LODOP = getLodop()
+      LODOP.SET_LICENSES("成都同飞科技有限责任公司","1B006F09DFEA0DEDB26058C928E1CA12","成都同飛科技有限責任公司","1E93D80582DBF553F0F902A73C02977C");
+      LODOP.PRINT_INIT('测试');
+      function demoGetBASE64(dataArray) {
+        var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+        var strData = "";
+        for (var i = 0, ii = dataArray.length; i < ii; i += 3) {
+            if (isNaN(dataArray[i])) break;
+            var b1 = dataArray[i] & 0xFF, b2 = dataArray[i + 1] & 0xFF, b3 = dataArray[i + 2] & 0xFF;
+            var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
+            var d3 = i + 1 < ii ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
+            var d4 = i + 2 < ii ? (b3 & 0x3F) : 64;
+            strData += digits.substring(d1, d1 + 1) + digits.substring(d2, d2 + 1) + digits.substring(d3, d3 + 1) + digits.substring(d4, d4 + 1);
+        }
+        return strData;
+      }
+      function demoDownloadPDF(url){
+        if (!(/^https?:/i.test(url))) return;
+        if (window.XMLHttpRequest) var xhr = new XMLHttpRequest(); else var xhr = new ActiveXObject("MSXML2.XMLHTTP");
+        xhr.open('GET',url,false); //同步方式
+        if (xhr.overrideMimeType)
+        try{
+              xhr.responseType = 'arraybuffer';
+              var arrybuffer=true;
+        }catch(err){
+              xhr.overrideMimeType('text/plain; charset=x-user-defined');
+        }
+        xhr.send(null);
+        var data = xhr.response || xhr.responseBody;
+        if (typeof Uint8Array !== 'undefined') {
+              if (arrybuffer) var dataArray = new Uint8Array(data); else {
+                    var dataArray = new Uint8Array(data.length);
+                    for (var i = 0; i < dataArray.length; i++) {dataArray[i] = data.charCodeAt(i);}
+              }
+        } else
+        var dataArray = VBS_BinaryToArray(data).toArray(); //兼容IE低版本
+        return demoGetBASE64(dataArray);
+      }
+      LODOP.ADD_PRINT_PDF(0,0,"100%","100%",demoDownloadPDF(strURL));
+      // LODOP.SET_PRINT_PAGESIZE(0, width, height, '')
+      // LODOP.SET_PRINT_STYLE('FontSize', 24)
+      // LODOP.SET_PRINT_STYLE('Bold', 1)
+      // LODOP.ADD_PRINT_RECT(0, 0, 1143, 1210, 0, 1)
+      // LODOP.ADD_PRINT_HTM(0, 0, width, height, shareContent.innerHTML)
+      // this.LODOP.SET_PRINT_STYLE('FontSize', 18)
+      //   this.LODOP.SET_PRINT_STYLE('Bold', 1)
+
+
+      // LODOP.SET_PRINT_MODE('FULL_WIDTH_FOR_OVERFLOW', true)
+      // LODOP.SET_PRINT_MODE('FULL_HEIGHT_FOR_OVERFLOW', true)
+      // LODOP.ADD_PRINT_HTM(10, 10, '100%', '100%', strFormHtml)
+      LODOP.PREVIEW()
+      // LODOP.PRINT_SETUP()
+    }
+  }
+}
+// var strBodyStyle="<style>"+document.getElementById("style1").innerHTML+"</style>";
+// 		var strFormHtml=strBodyStyle+"<body>"+document.getElementById("form1").innerHTML+"</body>";

+ 8 - 4
src/views/zhpt/projectAccount/index.vue

@@ -164,6 +164,7 @@ export default {
         "创建人"
       ],
       tableInfo: {},
+      fixedInfo:['工程类型','工程编号','工程名称','工程地址','项目负责人'],
       tableStaticConfig: {
         check: true,
         index: true,
@@ -290,14 +291,17 @@ export default {
     getFieldList() {
       return this.cols.map(c => {
         // 判断重复项
-        let dup = this.customCols && this.customCols.find(f => f.label === c)
+        let dup = this.customCols && this.customCols.find(f => f.label === c);
         if (dup) {
           return dup
         } else {
-          let find = commonFields.find(f => f.label === c)
+          let find = commonFields.find(f => f.label === c);
+          if(find){
+            find.fixed=this.fixedInfo.includes(find.label);
+          }
           // 表格未占满时,设置 isAdaptive 宽度自适应
-          if (this.isAdaptive) { find = { ...find, width: '' } }
-          return find || { label: c, field: '', width: '' }
+          if (this.isAdaptive) { find = { ...find, width: '',fixed: this.fixedInfo.includes(c) } }
+          return find || { label: c, field: '', width: '',fixed: this.fixedInfo.includes(c)};
         }
       })
     },

+ 10 - 8
src/views/zhpt/projectManager/newInstall/userPayment/addUserSettle/inputPage.vue

@@ -72,6 +72,7 @@ import Config from '@/views/imConfig.js'
 import { subMixin } from '@/views/zhpt/projectManager/common/mixins/subPage.js'
 import commonMe from '@/utils/common.js'
 import commonFlow from '@/utils/commonFlow.js'
+import { getFileUrl } from '@/api/ftp'
 export default {
   components: {
     inputForm,
@@ -107,15 +108,15 @@ export default {
               label: '合同文件PDF', //显示标签
               inputData: this.inputData,
               serviceImpls:"tfContractWService",
-              code: Config.flowKey.contractCheckAddProject
+              code: Config.flowKey.contractCheckAddProject,
+              buttonShow:true,
+              buttonTitle:"打印",
+              buttonClick:(e)=>{
+                debugger
+                const addre=getFileUrl(e[0].filePath, e[0].fileName);
+                this.$printPdf(addre)
+              }
             },
-            // {
-            //     field: 'contractBtn',
-            //     type: 'btn',
-            //     label: '',
-            //     text: '合同打印',
-            //     event: () => this.printPdf()
-            // },
             {
               field: 'contractFile', //存储字段
               type: 'fileShow', //类型,不写入此参数则默认是text
@@ -549,6 +550,7 @@ export default {
           if (params.settlementMode !== '按实结算') {
             params.settlementMode = params.totalContract
           }else{
+            debugger
             params.settlementMode = params.totalContract+(params.deductExpenses? parseFloat(params.deductExpenses):0) - (params.waterElectricity? parseFloat(params.waterElectricity):0);
           }
           params.deductExpenses =commonMe.valueIsEmpty(params.deductExpenses) ?params.deductExpenses:"无";