Browse Source

新增日期转化方法

qymljy 6 months ago
parent
commit
3f630dbd26
1 changed files with 16 additions and 8 deletions
  1. 16 8
      src/utils/tool.js

+ 16 - 8
src/utils/tool.js

@@ -10,13 +10,13 @@ export default {
   checkAuth (appname,auth) {
     // await this.sleep(3000)
     let _haveAuth = false
-    
+
     let app = JSON.parse(sessionStorage.getItem('activeApp'))
     // 获取当前应用权限
     let auth_list = app.meta.auth
     // 判断是否拥有权限
     _haveAuth = auth_list.some(item=>item.option === auth)
-    
+
     return _haveAuth
   },
 
@@ -25,7 +25,7 @@ export default {
     try {
       // 获取应用数据
       let apps = JSON.parse(sessionStorage.getItem('active_modules'))
-      
+
       let module_list =  apps.apps
       // 获取当前应用数据
       let active_modules = module_list.filter(item => {
@@ -45,7 +45,7 @@ export default {
     try {
       message = res.msg || '操作成功'
     } catch (error) {
-      
+
     }
 
     try {
@@ -79,7 +79,7 @@ export default {
       index = href.indexOf('/',index+1)
       if (num++ == 3) {
         return href.slice(0,index)
-      } 
+      }
     }
   },
   // 处理省市县数据结构
@@ -225,21 +225,21 @@ export default {
         result.push(data[index]) // 依次把index对应的元素data[index]添加进去即可
       })
     })
-    
+
     return result
   },
   calculatedColumnWidth(dom, layout) {
     if (!dom || _uids.includes(dom._uid)) return;
     _uids.push(dom._uid)
     let lang = localStorage.getItem('lang') || 'ZH';
-    if (lang!='ZH') setTimeout(() => {     
+    if (lang!='ZH') setTimeout(() => {
       try {
         const ths = dom.$el.querySelector('.el-table__header-wrapper').querySelectorAll('table thead tr:first-child th'),
           nodes = [];
         for (var key of ths.keys()) {
             const node = ths[key].querySelector('.cell')
             if (node && layout.some(v => v.title == node.innerText)) nodes.push(node);
-          } 
+          }
         layout.forEach((v,i) => {
           v.width = v.width > nodes[i].offsetWidth ? v.width : nodes[i].offsetWidth
         })
@@ -257,4 +257,12 @@ export default {
       return colors[status] ? `color:${colors[status]}` : "#999";
     }
   },
+  /*日期转化*/
+  getDataChange(data){
+    const newData = new Date(data)
+    const year = newData.getFullYear()
+    const month = String(newData.getMonth() + 1).padStart(2,'0')
+    const date = String(newData.getDate()).padStart(2,'0')
+    return year + '-' + month +'-' + date
+  }
 }