Explorar o código

处理时间、日期之间简单算术

skyzhou %!s(int64=4) %!d(string=hai) anos
pai
achega
8f1ad3e6ac

+ 0 - 2
ruoyi-ui/src/components/DynamicFormsteo/index.vue

@@ -173,10 +173,8 @@
      'queryData': {
        handler: function() {
          if (this.formConfig.extendedAttributes) {
-           console.log(this.formConfig,11111)
            let extend = JSON.parse(this.formConfig.extendedAttributes)
            this.formConfig.extend=extend
-           console.log(this.formConfig.extend,11111)
            this.extFn(extend.col, extend.comp)
          }
        },

+ 14 - 1
ruoyi-ui/src/utils/currencyFn.js

@@ -2,7 +2,6 @@ export function getDyn(col, arr, comp) {
   let str = comp
   let is = true
   let type = ''
-
   for (let item of arr) {
     for (let itemChild of item.hrChildren) {
       for (let colItem of col) {
@@ -20,6 +19,13 @@ export function getDyn(col, arr, comp) {
             }else{
               is=true
             }
+          }else if(itemChild.htmlType == "datetime-date") {
+            type = 3
+            if (getTime(itemChild.columnValue)) {
+              str = str.replace(itemChild.columnName, getTime(itemChild.columnValue))
+            } else {
+              is = true
+            }
           }
         }
       }
@@ -29,6 +35,9 @@ export function getDyn(col, arr, comp) {
     return
   }
   if (type == 2) {
+    return setTimeH(evals(str))
+  }
+  if(type==3){
     return setTime(evals(str))
   }
   return evals(str)
@@ -42,6 +51,10 @@ function evals(code) {
 function setTime(val) {
   return Math.round(Number(val) / (1000 * 3600 * 24))
 }
+// 时间戳转成小时
+function setTimeH(val) {
+  return Math.round(Number(val) / (1000 * 3600))
+}
 // 转化成时间戳
 function getTime(val) {
   var date = new Date(val);