From 5223edbcccfed84a33a706e5637ee65a61f377aa Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 十二月 2021 18:00:39 +0800
Subject: [PATCH] 2021-12-22

---
 src/utils/utils.js |   97 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 90 insertions(+), 7 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 86fd067..53170d2 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')) {
@@ -729,9 +735,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 +1362,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 +1383,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 +1392,8 @@
           }
         }
         _initFormfields.push(`@${_key}=${val}`)
+      } else if (['date', 'datemonth', 'datetime'].includes(form.type)) {
+        _initFormfields.push(`@${_key}='${form.value || '1900-01-01'}'`)
       } else {
         _initFormfields.push(`@${_key}='${form.value}'`)
       }
@@ -1402,6 +1412,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}`)
@@ -1476,7 +1488,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}
     `
 
   // 琛ㄥ崟鍙橀噺璧嬪��
@@ -2028,6 +2040,75 @@
 }
 
 /**
+ * @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
+  }
+}
+
+/**
  * @description 鐢熸垚鏇挎崲鍑芥暟鍒楄〃
  */
 export function setGLOBFuncs () {
@@ -2247,6 +2328,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)=\'\''
           }

--
Gitblit v1.8.0