From b48528b1a1a88e289fc0b7ad52f2da213a3f9dfe Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 23 四月 2025 16:34:38 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  183 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 168 insertions(+), 15 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 34e1669..5b331b5 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -8,6 +8,7 @@
 import Utils from '@/utils/utils.js'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import { updateForm } from '@/utils/utils-update.js'
+import UtilsDM from '@/utils/utils-datamanage.js'
 import MKEmitter from '@/utils/events.js'
 import MkIcon from '@/components/mk-icon'
 // import './index.scss'
@@ -150,7 +151,7 @@
 
     this.setState({autoMatic: type === 'autoMatic'})
 
-    let _this = this
+    let that = this
     let data = record || selectedData || []
 
     if (btn.Ot !== 'notRequired' && data.length === 0) {
@@ -179,6 +180,7 @@
       let modal = this.state.btnconfig
       if (!modal && btn.modal) {
         modal = this.handleModelConfig(btn.modal)
+        modal.uuid = btn.uuid
       }
 
       this.setState({
@@ -194,10 +196,10 @@
         okText: dict['ok'] || '纭畾',
         cancelText: dict['cancel'] || '鍙栨秷',
         onOk() {
-          _this.triggerPrint(data)
+          that.triggerPrint(data)
         },
         onCancel() {
-          _this.setState({ loading: false })
+          that.setState({ loading: false })
         }
       })
     } else {
@@ -556,9 +558,47 @@
     const { btn } = this.props
 
     let callback = null
+    let printReject = null
+    let skip = false
+    let send = false
+
+    let data = fromJS({
+      data: printlist,
+      form: formdata
+    }).toJS()
+
+    if (!window.GLOB.errorLog) {
+      printReject = (msg) => {
+        if (send) return
+
+        send = true
+        data.message = msg
+
+        window.mkInfo(JSON.stringify(data))
+      }
+    } else {
+      printReject = (msg) => {
+        if (send) return
+
+        send = true
+        data.message = msg
+
+        let param = {
+          func: 's_special_error_note_log',
+          api_url: btn.logLabel,
+          error_code: 507,
+          error_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+          api_param: JSON.stringify(data)
+        }
+        Api.genericInterface(param)
+      }
+    }
 
     if (/callback\(\)/.test(btn.verify.printFunc)) {
       callback = () => {
+        if (skip) return
+        skip = true
+
         this.execSuccess({
           ErrCode: '-1',
           message: '',
@@ -575,8 +615,8 @@
 
     try {
       // eslint-disable-next-line
-      let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', 'callback', btn.verify.printFunc)
-      func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType, callback)
+      let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', 'callback', 'printReject', btn.verify.printFunc)
+      func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType, callback, printReject)
 
       // 鑷畾涔夋墦鍗扮ず渚�
       // let defaultPrinter = printer.defaultPrinter || 'lackprinter'
@@ -777,6 +817,8 @@
         message: window.GLOB.dict['func_error'] || '鑷畾涔夊嚱鏁版墽琛岄敊璇紒',
         duration: 5
       })
+
+      printReject(window.GLOB.dict['func_error'] || '鑷畾涔夊嚱鏁版墽琛岄敊璇紒')
     }
   }
 
@@ -922,7 +964,7 @@
           Promise.all(deffers).then(result => {
             let errorMsg = ''
             result.forEach(res => {
-              if (!res.status) {
+              if (!res.status && !errorMsg) {
                 errorMsg = res
               }
             })
@@ -947,6 +989,65 @@
    */
   getDefaultSql = (formlist, data, ID) => {
     const { BID, btn, columns } = this.props
+
+    if (window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) {
+      let setting = {...btn.verify.setting}
+      setting.interType = 'system'
+      setting.uuid = btn.uuid
+
+      let _param = UtilsDM.getQueryDataParams(setting, [], setting.order, 1, 9999, BID, ID)
+      let item = window.GLOB.CacheData.get('sql_' + btn.uuid)
+
+      _param.data[0].exps = _param.data[0].exps.filter(n => n.key !== 'mk_search')
+      let formkeys = []
+
+      formlist.forEach(form => {
+        if (!item.reps.includes(form.key)) return
+
+        formkeys.push(form.key)
+
+        let val = form.value
+        if (form.type === 'number' || form.type === 'rate') {
+          if (isNaN(val) || val === '') {
+            val = 0
+          }
+        } else if (['date', 'datemonth'].includes(form.type)) {
+          val = val || '1949-10-01'
+        }
+
+        _param.data[0].exps.push({
+          key: 'mk_' + form.key + '_mk',
+          value: val
+        })
+      })
+
+      if (data && columns && columns.length > 0) {
+        let datavars = {}
+  
+        Object.keys(data).forEach(key => {
+          datavars[key.toLowerCase()] = data[key]
+        })
+    
+        columns.forEach(col => {
+          if (!item.reps.includes(col.field) || formkeys.includes(col.field)) return
+          if (!col.datatype) return
+  
+          let _key = col.field.toLowerCase()
+          let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : ''
+  
+          if (/^date/ig.test(col.datatype) && !_val) {
+            _val = '1949-10-01'
+          }
+
+          _param.data[0].exps.push({
+            key: 'mk_' + col.field + '_mk',
+            value: _val
+          })
+        })
+      }
+
+      return _param
+    }
 
     let arrFields = btn.verify.columns.map(col => col.field).join(',')
 
@@ -997,8 +1098,15 @@
       _dataresource = ''
     }
 
+    let custompage = false
+
+    if (/order\s+by\s+sort_id\s*$/i.test(_dataresource)) {
+      custompage = true
+    } else if (/@pageSize@|@orderBy@|@mk_total/i.test(_dataresource + _customScript + _tailScript)) {
+      custompage = true
+    }
+    
     let isDataM = sessionStorage.getItem('dataM') === 'true'
-    let custompage = /@pageSize@|@orderBy@|@mk_total/i.test(_dataresource + _customScript + _tailScript)
     let regoptions = [
       { reg: /@orderBy@/ig, value: btn.verify.setting.order },
       { reg: /@pageSize@/ig, value: '9999' },
@@ -1037,13 +1145,11 @@
     formlist.forEach(form => {
       let _key = form.key.toLowerCase()
 
-      if (_vars.includes(_key)) return
-
       _vars.push(_key)
 
       if (form.type === 'number' || form.type === 'rate') {
         let val = form.value
-        if (isNaN(val)) {
+        if (isNaN(val) || val === '') {
           val = 0
         }
         _initvars.push(`@${_key}=${val}`)
@@ -1635,6 +1741,41 @@
     const { btn } = this.props
     const { dict } = this.state
 
+    let printReject = null
+    let send = false
+
+    let data = fromJS({ 
+      data: list,
+      template: template
+    }).toJS()
+
+    if (!window.GLOB.errorLog) {
+      printReject = (msg) => {
+        if (send) return
+
+        send = true
+        data.message = msg
+
+        window.mkInfo(JSON.stringify(data))
+      }
+    } else {
+      printReject = (msg) => {
+        if (send) return
+
+        send = true
+        data.message = msg
+
+        let param = {
+          func: 's_special_error_note_log',
+          api_url: btn.logLabel,
+          error_code: 507,
+          error_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+          api_param: JSON.stringify(data)
+        }
+        Api.genericInterface(param)
+      }
+    }
+
     let _errors = []
 
     let defaultPrinter = btn.verify.defaultPrinter || 'lackprinter'
@@ -1847,6 +1988,8 @@
           message: data.message,
           status: false
         })
+
+        printReject(data.message)
       }
     }
 
@@ -2071,6 +2214,7 @@
         } else {
           _LongParam = updateForm(_LongParam)
           _LongParam = this.handleModelConfig(_LongParam)
+          _LongParam.uuid = btn.uuid
 
           this.setState({
             btnconfig: _LongParam
@@ -2113,7 +2257,7 @@
 
   modelconfirm = () => {
     const { btnconfig, selines, dict } = this.state
-    let _this = this
+    let that = this
     let result = []
     let _data = {}
     let BData = {}
@@ -2145,6 +2289,10 @@
       let key = item.field.toLowerCase()
       let _readin = item.readin !== 'false'
 
+      if (item.type === 'linkMain' && item.verifyVal === 'true') {
+        _item.$verify = true
+        _item.label = item.label
+      }
       if (_item.type === 'date') { // 鏃堕棿鍏煎
         _item.precision = item.precision || 'day'
       } else if (_item.type === 'datetime') {
@@ -2213,8 +2361,13 @@
             _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
           }
         }
-        if (_item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲
-          _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || ''))
+        if (_item.type === 'text') {
+          if (/@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲
+            _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || ''))
+          }
+          if (/@currentYear@/ig.test(_item.value)) { // 绯荤粺鍙橀噺鏇挎崲
+            _item.value = _item.value.replace(/@currentYear@/ig, moment().format('YYYY'))
+          }
         }
         if (_item.type === 'text' && item.lenControl && item.lenControl !== 'limit') {
           if (item.lenControl === 'left') {
@@ -2259,10 +2412,10 @@
         okText: dict['ok'] || '纭畾',
         cancelText: dict['cancel'] || '鍙栨秷',
         onOk() {
-          _this.triggerPrint(selines, result)
+          that.triggerPrint(selines, result)
         },
         onCancel() {
-          _this.setState({ loading: false })
+          that.setState({ loading: false })
         }
       })
     }

--
Gitblit v1.8.0