feat(utils): 添加parseTime2和printElement函数

新增parseTime2函数,支持更丰富的日期格式化功能,包括12/24小时制、
星期显示、中文相对时间等特性。

新增printElement函数,实现页面元素打印功能,支持自定义样式和
A4纸张格式设置。

refactor(views): 统一使用parseTime2替换parseTime

将forceNotice模块中所有组件的parseTime调用替换为parseTime2,
以使用新的日期格式化功能。

fix(views): 修复字段名错误

修复SpeList.vue中uniscid和entname字段名错误,应为uniscId和entName。

refactor(api): 统一API参数命名规范

将bizSeqNo和attachType参数名改为bizseq和attachtype,保持命名一致性。
This commit is contained in:
chenxf 2026-01-06 19:41:40 +08:00
parent 08e2af3401
commit b5f8ca3f04
11 changed files with 186 additions and 53 deletions

View File

@ -47,6 +47,66 @@ export function parseTime(time, cFormat) {
return time_str
}
export function parseTime2(time, format = 'yyyy-MM-dd hh:mm:ss') {
const date = time instanceof Date ? time : new Date(time)
const o = {
'M+': date.getMonth() + 1, // 月份
'd+': date.getDate(), // 日
'h+': date.getHours() % 12, // 12小时
'H+': date.getHours(), // 24小时
'm+': date.getMinutes(), // 分
's+': date.getSeconds(), // 秒
'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
'S': date.getMilliseconds(), // 毫秒
'D': (() => {
switch (date.getDay()) {
case 1:
return '星期一'
case 2:
return '星期二'
case 3:
return '星期三'
case 4:
return '星期四'
case 5:
return '星期五'
case 6:
return '星期六'
case 0:
return '星期日'
default:
return String(date.getDay())
}
})()
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (const k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
if (/CN/.test(format)) {
format = format.replace('CN', () => {
const now = Date.now()
const diff = (now - date) / 1000
if (diff < 30) {
return '刚刚'
} else if (diff < 3600) {
// less 1 hour
return Math.ceil(diff / 60) + '分钟前'
} else if (diff < 3600 * 24) {
return Math.ceil(diff / 3600) + '小时前'
} else if (diff < 3600 * 24 * 2) {
return '1天前'
}
})
}
return format
}
/**
* @param {number} time
* @param {string} option
@ -175,3 +235,76 @@ export const createGlobalLoading = (function() {
})
}
})()
/**
* 调用浏览器的打印打印元素
* @param {*} el
* @param {*} userStyle
* @param {*} width
*/
export function printElement(el, userStyle = {}, width) {
try {
const newWindow = window.open('打印窗口', '_blank')// 打印窗口要换成页面的url
let styles = ''
const tags = document.querySelectorAll('style')
for (const tag of tags) {
styles += `<style type="text/css">${tag.innerHTML}</style>`
}
for (const { cssRules } of document.styleSheets) {
let style = ''
for (const { cssText } of cssRules) {
style += cssText
}
styles += `<style type="text/css">${style}</style>`
}
let userStyles = ''
for (const selector in userStyle) {
let style = ''
for (const cssKey in userStyle[selector]) {
style += `${cssKey}:${userStyle[selector][cssKey]};`
}
userStyles += `${selector}{${style}}`
}
styles += `<style type="text/css">${userStyles}</style>`
const docStr = el.outerHTML
newWindow.document.write(`
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
body{
width: ${width || el.offsetWidth}px!important;
margin: 0 auto!important;
}
@page {
/* A4纸 */
size: a4 portrait;
/* todo */
margin: 15mm 20mm;
}
/*设置横向页面*/
@page landscape {
/* A4纸 landscape */
size: a4 landscape;
/* todo */
margin: 28mm 28mm;
}
tr{
page-break-inside:avoid;
}
</style>
${styles}
</head>
<body>
${docStr}
</body>
</html>
`)
newWindow.document.close()
newWindow.print()
newWindow.close()
} catch (e) {
console.log(e)
}
}

View File

@ -88,7 +88,7 @@ export default {
showOverflowTooltip: true,
width: '200px',
formatter: (row, column, cellValue, index) => {
return `${row.uniscid || row.regNO || ''}`
return `${row.uniscId || row.regNO || ''}`
}
},
showInTable: this.params !== 'force'
@ -104,7 +104,7 @@ export default {
showOverflowTooltip: true,
width: '280px',
formatter: (row, column, cellValue, index) => {
return `${row.entname || ''}`
return `${row.entName || ''}`
}
},
showInTable: this.params !== 'force'

View File

@ -18,7 +18,7 @@
</div>
<div class="footer">
<div class="a" contenteditable>{{ data.incAbnDecisionMap.areaName }}公章</div>
<div class="date">{{ parseTime(data.incAbnDecisionMap.writTime, 'yyyy年MM月dd日') }}</div>
<div class="date">{{ parseTime2(data.incAbnDecisionMap.writTime, 'yyyy年MM月dd日') }}</div>
</div>
</el-tab-pane>
<el-tab-pane label="强制注销决定送达公告内容" name="强制注销决定送达公告内容" class="doc-preview">
@ -31,7 +31,7 @@
</div>
<div class="footer">
<div class="a" contenteditable>{{ data.remAbnDecisionMap.areaName }}公章</div>
<div class="date">{{ parseTime(data.remAbnDecisionMap.writTime, 'yyyy年MM月dd日') }}</div>
<div class="date">{{ parseTime2(data.remAbnDecisionMap.writTime, 'yyyy年MM月dd日') }}</div>
</div>
</el-tab-pane>
<el-tab-pane label="强制注销审批表" name="强制注销审批表" class="doc-preview">
@ -63,7 +63,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -77,7 +77,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -91,7 +91,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -115,12 +115,12 @@
</template>
<script>
import { printElement, parseTime } from '@/utils'
import { printElement, parseTime2 } from '@/utils'
export default {
data() {
return {
parseTime,
parseTime2,
visible: false,
data: {},
name: '拟强制注销公告'

View File

@ -93,7 +93,7 @@
</div>
<div>
<span class="step-description-label">{{ step.opinionType }}日期</span>
<span class="step-description-value">{{ parseTime(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
<span class="step-description-value">{{ parseTime2(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
</div>
</div>
</template>
@ -154,7 +154,7 @@
<script>
import { getUsersWithPermission } from '@/api/user'
import { createGlobalLoading, parseTime } from '@/utils'
import { createGlobalLoading, parseTime2 } from '@/utils'
import {
findCurrentNode,
findNextSequenceFlowList,
@ -173,7 +173,7 @@ export default {
data() {
return {
authItemMap: [],
parseTime,
parseTime2,
action: process.env.VUE_APP_BASE_API + '/attachment/uploadFileByBizseq',
nextPerformerMap: [],
generatingContent: false,
@ -592,8 +592,8 @@ export default {
}
}),
xrAttachmentListByBizSepNo({
bizSeqNo: this.$route.query.bizSeqNo,
attachType: '1'
bizseq: this.$route.query.bizSeqNo,
attachtype: '1'
}).then((data) => {
this.data.fileList = data.map((item) => {
return {

View File

@ -17,7 +17,7 @@
</div>
<div class="footer">
<div class="a" contenteditable>{{ data.repairMap.areaName }}公章</div>
<div class="date">{{ parseTime(data.repairMap.writTime, 'yyyy年MM月dd日') }}</div>
<div class="date">{{ parseTime2(data.repairMap.writTime, 'yyyy年MM月dd日') }}</div>
</div>
</el-tab-pane>
<el-tab-pane label="拟强制注销公告审批表" name="拟强制注销公告审批表" class="doc-preview">
@ -49,7 +49,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -63,7 +63,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -77,7 +77,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -101,12 +101,12 @@
</template>
<script>
import { printElement, parseTime } from '@/utils'
import { printElement, parseTime2 } from '@/utils'
export default {
data() {
return {
parseTime,
parseTime2,
visible: false,
data: {},
name: '拟强制注销公告'

View File

@ -75,7 +75,7 @@
</div>
<div>
<span class="step-description-label">{{ step.opinionType }}日期</span>
<span class="step-description-value">{{ parseTime(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
<span class="step-description-value">{{ parseTime2(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
</div>
</div>
</template>
@ -136,7 +136,7 @@
<script>
import { getUsersWithPermission } from '@/api/user'
import { createGlobalLoading, parseTime } from '@/utils'
import { createGlobalLoading, parseTime2 } from '@/utils'
import { findCurrentNode, findNextSequenceFlowList, taskInfo } from '@/api'
import {
getForceDeregisterContent,
@ -151,7 +151,7 @@ export default {
data() {
return {
authItemMap: [],
parseTime,
parseTime2,
action: process.env.VUE_APP_BASE_API + '/attachment/uploadFileByBizseq',
nextPerformerMap: [],
generatingContent: false,
@ -546,7 +546,7 @@ export default {
},
currentNodeID: this.currentNodeID
}).then((data) => {
this.$message.success(`已完成对“${formData.entname}”的业务办理!`)
this.$message.success(`已完成对“${formData.entName}”的业务办理!`)
this.$router.push({
path: `/forceNotice/inclusion/${this.$route.meta.type}`
})
@ -576,8 +576,8 @@ export default {
}
}),
xrAttachmentListByBizSepNo({
bizSeqNo: this.$route.query.bizSeqNo,
attachType: '1'
bizseq: this.$route.query.bizSeqNo,
attachtype: '1'
}).then((data) => {
this.data.fileList = data.map((item) => {
return {

View File

@ -17,7 +17,7 @@
</div>
<div class="footer">
<div class="a" contenteditable>{{ data.repairMap.areaName }}公章</div>
<div class="date">{{ parseTime(data.repairMap.writTime, 'yyyy年MM月dd日') }}</div>
<div class="date">{{ parseTime2(data.repairMap.writTime, 'yyyy年MM月dd日') }}</div>
</div>
</el-tab-pane>
<el-tab-pane label="营业执照作废公告审批表" name="营业执照作废公告审批表" class="doc-preview">
@ -49,7 +49,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -63,7 +63,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -77,7 +77,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -101,12 +101,12 @@
</template>
<script>
import { printElement, parseTime } from '@/utils'
import { printElement, parseTime2 } from '@/utils'
export default {
data() {
return {
parseTime,
parseTime2,
visible: false,
data: {},
name: '营业执照作废公告'

View File

@ -51,7 +51,7 @@
</div>
<div>
<span class="step-description-label">{{ step.opinionType }}日期</span>
<span class="step-description-value">{{ parseTime(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
<span class="step-description-value">{{ parseTime2(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
</div>
</div>
</template>
@ -102,7 +102,7 @@
<script>
import { getUsersWithPermission } from '@/api/user'
import { createGlobalLoading, parseTime } from '@/utils'
import { createGlobalLoading, parseTime2 } from '@/utils'
import { findCurrentNode, findNextSequenceFlowList, taskInfo } from '@/api'
import {
generateLiccanSta,
@ -116,7 +116,7 @@ export default {
data() {
return {
authItemMap: [],
parseTime,
parseTime2,
action: process.env.VUE_APP_BASE_API + '/attachment/uploadFileByBizseq',
nextPerformerMap: [],
generatingContent: false,
@ -448,8 +448,8 @@ export default {
}
}),
xrAttachmentListByBizSepNo({
bizSeqNo: this.$route.query.bizSeqNo,
attachType: '1'
bizseq: this.$route.query.bizSeqNo,
attachtype: '1'
}).then((data) => {
this.data.fileList = data.map((item) => {
return {

View File

@ -18,7 +18,7 @@
</div>
<div class="footer">
<div class="a" contenteditable>{{ data.repairMap.areaName }}公章</div>
<div class="date">{{ parseTime(data.repairMap.writTime, 'yyyy年MM月dd日') }}</div>
<div class="date">{{ parseTime2(data.repairMap.writTime, 'yyyy年MM月dd日') }}</div>
</div>
</el-tab-pane>
<el-tab-pane label="恢复登记审批表" name="恢复登记审批表" class="doc-preview">
@ -50,7 +50,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -64,7 +64,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -78,7 +78,7 @@
>
<span class="opinionContent">{{ item.opinionContent }}</span>
<span class="handler">{{ item.handler }}</span>
<span class="laupTime">{{ parseTime(item.handelDate, 'yyyy年MM月dd日') }}</span>
<span class="laupTime">{{ parseTime2(item.handelDate, 'yyyy年MM月dd日') }}</span>
</div>
</td>
</tr>
@ -102,12 +102,12 @@
</template>
<script>
import { printElement, parseTime } from '@/utils'
import { printElement, parseTime2 } from '@/utils'
export default {
data() {
return {
parseTime,
parseTime2,
visible: false,
data: {},
name: '营业执照作废公告'

View File

@ -51,7 +51,7 @@
</div>
<div>
<span class="step-description-label">{{ step.opinionType }}日期</span>
<span class="step-description-value">{{ parseTime(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
<span class="step-description-value">{{ parseTime2(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
</div>
</div>
</template>
@ -102,7 +102,7 @@
<script>
import { getUsersWithPermission } from '@/api/user'
import { createGlobalLoading, parseTime } from '@/utils'
import { createGlobalLoading, parseTime2 } from '@/utils'
import { findCurrentNode, findNextSequenceFlowList, taskInfo } from '@/api'
import {
generateDecisionContent,
@ -116,7 +116,7 @@ export default {
data() {
return {
authItemMap: [],
parseTime,
parseTime2,
action: process.env.VUE_APP_BASE_API + '/attachment/uploadFileByBizseq',
nextPerformerMap: [],
generatingContent: false,
@ -502,8 +502,8 @@ export default {
}
}),
xrAttachmentListByBizSepNo({
bizSeqNo: this.$route.query.bizSeqNo,
attachType: '1'
bizseq: this.$route.query.bizSeqNo,
attachtype: '1'
}).then((data) => {
this.data.fileList = data.map((item) => {
return {

View File

@ -51,7 +51,7 @@
</div>
<div>
<span class="step-description-label">{{ step.opinionType }}日期</span>
<span class="step-description-value">{{ parseTime(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
<span class="step-description-value">{{ parseTime2(step.createTime, 'yyyy-MM-dd hh:mm') }}</span>
</div>
</div>
</template>
@ -102,7 +102,7 @@
<script>
import { getUsersWithPermission } from '@/api/user'
import { createGlobalLoading, parseTime } from '@/utils'
import { createGlobalLoading, parseTime2 } from '@/utils'
import { findCurrentNode, findNextSequenceFlowList, taskInfo } from '@/api'
import {
xrForceDeregisterRemByBizSeqNo, xrForceDeregisterRemProcessControl,
@ -115,7 +115,7 @@ export default {
data() {
return {
authItemMap: [],
parseTime,
parseTime2,
action: process.env.VUE_APP_BASE_API + '/attachment/uploadFileByBizseq',
nextPerformerMap: [],
generatingContent: false,
@ -507,8 +507,8 @@ export default {
}
}),
xrAttachmentListByBizSepNo({
bizSeqNo: this.$route.query.bizSeqNo,
attachType: '1'
bizseq: this.$route.query.bizSeqNo,
attachtype: '1'
}).then((data) => {
this.data.fileList = data.map((item) => {
return {