From a09cff714f32c84894b9ece2ddfb8c7ed4db4d96 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 28 二月 2022 18:12:24 +0800
Subject: [PATCH] 2022-02-28

---
 src/utils/utils.js |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 104 insertions(+), 13 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 44fdb03..24ebbb6 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -248,6 +248,7 @@
       item.hidden = item.Hide === 'true'
       item.required = !item.hidden && item.required === 'true'
       item.advanced = item.advanced === 'true'
+      item.$forbid = item.query === 'false'
 
       if (item.type === 'date') { // 鏃堕棿鎼滅储
         item.initval = item.initval ? moment().subtract(item.initval, 'days').format('YYYY-MM-DD') : ''
@@ -256,7 +257,11 @@
       } else if (item.type === 'dateweek') {
         item.initval = item.initval ? moment().subtract(item.initval * 7, 'days').format('YYYY-MM-DD') : ''
       } else if (item.type === 'daterange') {
-        if (item.initval) {
+        if (item.initval === 'week') {
+          item.initval = [moment().startOf('week').format('YYYY-MM-DD'), moment().endOf('week').format('YYYY-MM-DD')].join(',')
+        } else if (item.initval === 'month') {
+          item.initval = [moment().startOf('month').format('YYYY-MM-DD'), moment().endOf('month').format('YYYY-MM-DD')].join(',')
+        } else if (item.initval) {
           try {
             let _initval = JSON.parse(item.initval)
             let _vals = [moment().subtract(_initval[0], 'days').format('YYYY-MM-DD'), moment().subtract(_initval[1], 'days').format('YYYY-MM-DD')]
@@ -352,7 +357,8 @@
         type: cell.type,
         label: cell.label,
         value: cell.initval,
-        required: cell.required
+        required: cell.required,
+        forbid: cell.$forbid
       }
       
       if (cell.type === 'multiselect' || (cell.type === 'checkcard' && cell.multiple === 'true')) {
@@ -701,14 +707,16 @@
   static getSelectQueryOptions (item) {
     let arrfield = [item.valueField, item.valueText]
 
-    if (item.type === 'link') {
-      arrfield.push(item.linkField)
-    } else if (item.type === 'checkcard') {
+    if (item.type === 'checkcard') {
       arrfield = item.fields.map(f => f.field)
       arrfield.push(item.cardValField)
       if (item.urlField) {
         arrfield.push(item.urlField)
       }
+    }
+
+    if (item.linkField) {
+      arrfield.push(item.linkField)
     }
     if (['select', 'radio', 'link', 'checkcard'].includes(item.type) && item.linkSubField && item.linkSubField.length > 0) {
       arrfield.push(...item.linkSubField)
@@ -729,9 +737,11 @@
     arrfield = arrfield.join(',')
 
     if (item.orderBy) {
-      sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}`
+      // sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}`
+      sql = `select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} order by orderfield ${item.orderType}`
     } else {
-      sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield} from ${_datasource}) a`
+      // sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield} from ${_datasource}) a`
+      sql = `select distinct ${arrfield} from ${_datasource}`
     }
 
     if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
@@ -1354,7 +1364,7 @@
   })
 
   // 闇�瑕佸0鏄庣殑鍙橀噺闆�
-  let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'login_city']
+  let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'login_city', 'bid']
 
   // 涓婚敭瀛楁
   let primaryKey = setting.primaryKey || 'id'
@@ -1375,7 +1385,7 @@
     if (!_initvars.includes(_key)) {
       _initvars.push(_key)
 
-      if (form.type === 'number') {
+      if (form.type === 'number' || form.type === 'rate') {
         let val = form.value
         if (typeof(val) !== 'number') {
           val = parseFloat(val)
@@ -1384,6 +1394,8 @@
           }
         }
         _initFormfields.push(`@${_key}=${val}`)
+      } else if (['date', 'datemonth', 'datetime'].includes(form.type)) {
+        _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`)
       } else {
         _initFormfields.push(`@${_key}='${form.value}'`)
       }
@@ -1402,6 +1414,8 @@
         _type = 'datetime'
       } else if (form.type === 'number') {
         _type = `decimal(18,${form.fieldlen})`
+      } else if (form.type === 'rate') {
+        _type = `decimal(18,2)`
       }
 
       _declarefields.push(`@${_key} ${_type}`)
@@ -1426,7 +1440,7 @@
         let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : ''
 
         if (col.datatype && /^date/ig.test(col.datatype) && !_val) {
-          _val = '1900-01-01'
+          _val = '1949-10-01'
         }
 
         _initvars.push(_key)
@@ -1476,7 +1490,7 @@
     _declarefields = ',' + _declarefields
   }
   _sql = `/* 绯荤粺鐢熸垚 */
-      Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@login_city nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields}
+      Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@login_city nvarchar(50),@bid nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields}
     `
 
   // 琛ㄥ崟鍙橀噺璧嬪��
@@ -1899,9 +1913,15 @@
       if (!_arr.includes('submituserid')) {
         _form.push('submituserid=@userid@')
       }
+      if (!_arr.includes('submituser')) {
+        _form.push('submituser=@username')
+      }
     } else {
       if (!_arr.includes('modifydate')) {
         _form.push('modifydate=getdate()')
+      }
+      if (!_arr.includes('modifyuser')) {
+        _form.push('modifyuser=@username')
       }
       if (!_arr.includes('modifyuserid')) {
         _form.push('modifyuserid=@userid@')
@@ -1950,7 +1970,7 @@
 
     _sql += `
       /* 榛樿sql */
-      update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}${_ID};`
+      update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuser=@username,modifyuserid=@userid@ where ${primaryKey}${_ID};`
   
   } else if (_actionType === 'delete') {      // 鐗╃悊鍒犻櫎
     let _msg = ''
@@ -2018,6 +2038,75 @@
     }
   } else {
     return _sql
+  }
+}
+
+/**
+ * @description 鑾峰彇鏍囪淇℃伅
+ */
+export function getMark (marks, record, style = {}) {
+  let icon = null
+  let color = null
+  let position = null
+
+  marks.some(mark => {
+    let originVal = record[mark.field[0]] + ''
+    let contrastVal = ''
+    let result = false
+
+    if (mark.field[1] === 'static') {
+      contrastVal = mark.contrastValue + ''
+    } else {
+      contrastVal = record[mark.field[2]] + ''
+    }
+
+    if (mark.match === '=') {
+      result = originVal === contrastVal
+    } else if (mark.match === '!=') {
+      result = originVal !== contrastVal
+    } else if (mark.match === 'like') {
+      result = originVal.indexOf(contrastVal) > -1
+    } else if (mark.match === '>') {
+      result = parseFloat(originVal) > parseFloat(contrastVal)
+    } else if (mark.match === '<') {
+      result = parseFloat(originVal) < parseFloat(contrastVal)
+    }
+
+    if (!result) return false
+
+    let type = mark.signType[0]
+
+    if (type === 'font') {
+      style.color = mark.color
+    } else if (type === 'background') {
+      style.background = mark.color
+      if (mark.fontColor) {
+        style.color = mark.fontColor
+      }
+    } else if (type === 'underline') {
+      style.textDecoration = 'underline'
+      style.color = mark.color
+    } else if (type === 'line-through') {
+      style.textDecoration = 'line-through'
+      style.color = mark.color
+    } else if (type.indexOf('icon') > -1) {
+      icon = mark.signType[mark.signType.length - 1]
+      color = mark.color
+      if (type === 'iconfront' || mark.signType[1] === 'front') {
+        position = 'front'
+      } else {
+        position = 'back'
+      }
+    }
+
+    return true
+  })
+
+  return {
+    style,
+    icon,
+    color,
+    position
   }
 }
 
@@ -2241,6 +2330,8 @@
             type = 'datetime=null'
           } else if (item.type === 'number') {
             type = `decimal(18,${item.decimal})=0`
+          } else if (item.type === 'rate') {
+            type = `decimal(18,2)=0`
           } else {
             type = 'nvarchar(50)=\'\''
           }
@@ -2266,7 +2357,7 @@
       form = `
         insert into ${param.name} (${field1},createuserid) select ${field2},@UserID
         
-        update ${param.name} set ${field3},modifydate=getdate(),modifyuserid=@UserID
+        update ${param.name} set ${field3},modifydate=getdate(),modifyuser=@username,modifyuserid=@UserID
       `
     } else if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') {
       form = `

--
Gitblit v1.8.0