Просмотр исходного кода

增加通用时间方法,修复部分bug

cfort 2 лет назад
Родитель
Сommit
18d272f078

+ 1 - 1
src/business/platform/bpmn/form/action.js

@@ -673,7 +673,7 @@ export default {
                 }
                 const path = data[0].bao_biao_lu_jing_
                 const url = this.$getReportFile(path, `id_=${id}`)
-                const fileName = name + this.$common.getNow(16, 'string')
+                const fileName = name + this.$common.getDateNow(16, 'string')
                 console.log(url, fileName)
                 this.$common.snapshoot({
                     url,

+ 1 - 1
src/layout/header-aside/layout.vue

@@ -10,7 +10,7 @@
             name="iframeContain"
             seamless
             scrolling="yes"
-            src="https://www.szjyxt.com/#/fileView?url=https%3A%2F%2Fwww.szjyxt.com%2Fibps%2Fplatform%2Fv3%2Ffile%2Fdownload%3FattachmentId%3D925044155762081792&isEdit=true&fileType=docx&title=GDYR-CX01-A0%20%E4%BF%9D%E8%AF%81%E5%85%AC%E6%AD%A3%E6%80%A7%E7%AE%A1%E7%90%86%E7%A8%8B%E5%BA%8F&user=%5Bobject%20Object%5D&mode=view&editUrl=https%3A%2F%2Fwww.szjyxt.com%2Fibps%2Fplatform%2Fv3%2Ffile%2FeditCallback%3FfileName%3DGDYR-CX01-A0%20%E4%BF%9D%E8%AF%81%E5%85%AC%E6%AD%A3%E6%80%A7%E7%AE%A1%E7%90%86%E7%A8%8B%E5%BA%8F%26fileType%3Ddocx&key="
+            src=""
         >
         </iframe> -->
 

+ 87 - 2
src/utils/common.js

@@ -39,13 +39,96 @@ export const downloadByBlob = (o, name) => {
 }
 
 // 获取当前时间
-export const getNow = (length, formatType) => {
+export const getDateNow = (length = 10, formatType) => {
     if (formatType === 'string') {
         return new Date(new Date().getTime() + 28800000).toJSON().slice(0, length).replace(/[-:T]/g, '')
     }
     return new Date(new Date().getTime() + 28800000).toJSON().slice(0, length).replace('T', ' ')
 }
 
+// 获取指定值后的日期
+export const getDate = (type, value, date) => {
+    const d = date || getDateNow(19)
+    if (typeof type !== 'string' || !Number.isInteger(value) || typeof d !== 'string') {
+        console.log('参数类型错误')
+        return null
+    }
+    const now = new Date(d)
+    const D = {
+        day: value * 24 * 60 * 60 * 1000,
+        hour: value * 60 * 60 * 1000,
+        minute: value * 60 * 1000,
+        second: value * 1000
+    }
+    const year = now.getFullYear()
+    const month = now.getMonth()
+    const day = now.getDate()
+    const hour = now.getHours()
+    const minute = now.getMinutes()
+    const second = now.getSeconds()
+
+    switch (type) {
+        case 'year': {
+            const isLeapYear = new Date(year + value, 1, 29).getDate() === 29
+            return new Date(year + value, isLeapYear && month === 1 && day === 29 ? 1 : month, isLeapYear && month === 1 && day === 29 ? 29 : day, hour, minute, second)
+        }
+        case 'month': {
+            let newYear = year
+            let newMonth = month + value
+            if (newMonth < 0) {
+                newYear -= Math.ceil(Math.abs(newMonth) / 12)
+                newMonth = 12 - Math.abs(newMonth) % 12
+            } else if (newMonth > 11) {
+                newYear += Math.floor(newMonth / 12)
+                newMonth = newMonth % 12
+            }
+            const isLeapMonth = new Date(newYear, newMonth + 1, 0).getDate() === 29
+            return new Date(newYear, isLeapMonth && month === 1 && day === 29 ? 1 : newMonth, isLeapMonth && month === 1 && day === 29 ? 29 : day, hour, minute, second)
+        }
+        case 'day': case 'hour': case 'minute': case 'second':
+            return new Date(now.getTime() + D[type])
+        default:
+            console.log('无效的日期类型')
+            return null
+    }
+}
+
+// 时间格式化
+export const getFormatDate = (type, length, date = new Date()) => {
+    const now = new Date(new Date(date).getTime())
+    // eslint-disable-next-line
+    if (now == 'Invalid Date') {
+        console.log('非法日期,无法格式化')
+        return date
+    }
+    const year = now.getFullYear()
+    const month = now.getMonth() + 1
+    const day = now.getDate()
+    const hours = now.getHours()
+    const minutes = now.getMinutes()
+    const seconds = now.getSeconds()
+    // 补零
+    const padZero = (num) => {
+        return num.toString().padStart(2, '0')
+    }
+    // 默认返回String类型
+    let result = `${year}-${padZero(month)}-${padZero(day)} ${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`
+    switch (type) {
+        case 'string':
+            result = `${year}-${padZero(month)}-${padZero(day)} ${padZero(hours)}:${padZero(minutes)}:${padZero(seconds)}`
+            break
+        case 'cn':
+            result = `${year}年${padZero(month)}月${padZero(day)}日 ${padZero(hours)}时${padZero(minutes)}分${padZero(seconds)}秒`
+            break
+        case 'number':
+            result = `${year}${padZero(month)}${padZero(day)}${padZero(hours)}${padZero(minutes)}${padZero(seconds)}`
+            break
+        default:
+            break
+    }
+    return result.slice(0, length || result.length)
+}
+
 export default {
     preview,
     request,
@@ -58,7 +141,9 @@ export default {
     sendMsg,
     saveNews,
     bpmTaskSave,
-    getNow,
+    getDate,
+    getDateNow,
+    getFormatDate,
     onlyOfficeToPdf,
     download
 }

+ 1 - 1
src/utils/fecha.js

@@ -505,7 +505,7 @@ const dateDealFmt = {
       if (has != null) {
         const val = parseInt(dateStr.substring(has.index, has.index + has[0].length), 10)
         if (p === 'y') { date.setYear(val) }
-        if (p === 'M') { date.setMonth(val - 1) }
+        if (p === 'M') { date.setMonth(val - 1, 1) }
         if (p === 'd') { date.setDate(val) }
         if (p === 'H') { date.setHours(val) }
         if (p === 'm') { date.setMinutes(val) }

+ 33 - 41
src/views/component/qrcodeed.vue

@@ -1,53 +1,45 @@
 <template>
-<div style="height:50vh;">
-   <div id="qrcode" ref="qrcode" style="margin-top:25vh;"></div>
-</div>
+    <div style="height:50vh;">
+        <div id="qrcode" ref="qrcode" style="margin-top:25vh;" />
+    </div>
 
 </template>
 
 <script>
 import QRCode from 'qrcodejs2' // 引入qrcode
 export default {
-  name: "qrcode",
-  props: {
-    field: Object,
-    formData: {
-      type: Object,
-      default() {
-        return {}
-      }
+    name: 'qrcode',
+    props: {
+        field: Object,
+        formData: {
+            type: Object,
+            default () {
+                return {}
+            }
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        }
     },
-    readonly: {
-      type: Boolean,
-      default: false,
-    }
-  },
-
-  methods: {
-    qrcode() {
-      console.log(this.formData.changJingId)
-      let qrcode = new QRCode('qrcode', {
-        width: 132,
-        height: 132,
-        text: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.changJingId}#wechat_redirect`,
-      //text: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxea2c214ca5d25739&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.changJingId}#wechat_redirect`,
-        colorDark: "#000000", //前景色
-        colorLight: "#FFFFFF", //背景色
-        correctLevel: QRCode.CorrectLevel.L,
-
-
-      })
+    mounted () {
+        this.qrcode()
     },
-  },
-  mounted() {
-    let this_ = this;
-    console.log(QRCode)
-    this.$nextTick(() => {
-      setTimeout(() => {
-        this_.qrcode();
-      }, 0)
-    })
-  },
+
+    methods: {
+        qrcode () {
+            console.log(this)
+            const qrcode = new QRCode('qrcode', {
+                width: 132,
+                height: 132,
+                text: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0aecf99696061a3&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.changJingId}#wechat_redirect`,
+                // text: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxea2c214ca5d25739&redirect_uri=https%3A%2F%2Fwww.szjyxt.com%2F%23%2Fziliao&response_type=code&scope=snsapi_base&state=${this.formData.changJingId}#wechat_redirect`,
+                colorDark: '#000000', // 前景色
+                colorLight: '#FFFFFF', // 背景色
+                correctLevel: QRCode.CorrectLevel.L
+            })
+        }
+    }
 }
 </script>
 

+ 1 - 1
src/views/platform/message/inner/detail/dialog.vue

@@ -161,7 +161,7 @@ export default {
                             id: ryjbqkDatas[0].qian_zi_tu_wen_,
                             fileName: '确认签名'
                         }]),
-                        que_ren_ri_qi_: this.$common.getNow(10),
+                        que_ren_ri_qi_: this.$common.getDateNow(10),
                         que_ren_ren_xing_: perInfosName
                     }
                     const returnParams = {

+ 3 - 2
src/views/system/error/404/index.vue

@@ -10,7 +10,7 @@
         </div>
         <div class="bullshit">
           <div class="bullshit__oops">OOPS!</div>
-          <div class="bullshit__info"><a class="link-type" href="https://www.szjyxt.com/" target="_blank">{{ $t('common.company') }}</a>©{{ $t('common.copyright') }}</div>
+          <div class="bullshit__info"><a class="link-type" :href="url" target="_blank">{{ $t('common.company') }}</a>©{{ $t('common.copyright') }}</div>
           <div class="bullshit__headline">{{ message }}</div>
           <div class="bullshit__info">{{ $t('error.page404.info') }}</div>
           <a href="javascript:void(0)" class="bullshit__return-home" @click="backHome">{{ $t('error.backHome') }}</a>
@@ -29,7 +29,8 @@ export default {
   data() {
     return {
       img_404: img404,
-      img_404_cloud: img404Cloud
+      img_404_cloud: img404Cloud,
+      url: process.env.VUE_APP_BASE_URL
     }
   },
   computed: {