Merge remote-tracking branch 'origin/master' into 1.X-dev

# Conflicts:
#	yudao-ui-admin-vue3/package.json
#	yudao-ui-admin-vue3/pnpm-lock.yaml
#	yudao-ui-admin-vue3/src/main.ts
This commit is contained in:
xingyuv
2023-02-06 09:18:48 +08:00
140 changed files with 14465 additions and 2072 deletions

View File

@@ -0,0 +1,54 @@
/**
* 针对 https://github.com/xaboy/form-create-designer 封装的工具类
*/
// 编码表单 Conf
export const encodeConf = (designerRef: object) => {
// @ts-ignore
return JSON.stringify(designerRef.value.getOption())
}
// 编码表单 Fields
export const encodeFields = (designerRef: object) => {
// @ts-ignore
const rule = designerRef.value.getRule()
const fields: string[] = []
rule.forEach((item) => {
fields.push(JSON.stringify(item))
})
return fields
}
// 解码表单 Fields
export const decodeFields = (fields: string[]) => {
const rule: object[] = []
fields.forEach((item) => {
rule.push(JSON.parse(item))
})
return rule
}
// 设置表单的 Conf 和 Fields
export const setConfAndFields = (designerRef: object, conf: string, fields: string) => {
// @ts-ignore
designerRef.value.setOption(JSON.parse(conf))
// @ts-ignore
designerRef.value.setRule(decodeFields(fields))
}
// 设置表单的 Conf 和 Fields
export const setConfAndFields2 = (
detailPreview: object,
conf: string,
fields: string,
value?: object
) => {
// @ts-ignore
detailPreview.value.option = JSON.parse(conf)
// @ts-ignore
detailPreview.value.rule = decodeFields(fields)
if (value) {
// @ts-ignore
detailPreview.value.value = value
}
}

View File

@@ -147,3 +147,30 @@ export function formatAxis(param: Date): string {
else if (hour < 22) return '晚上好'
else return '夜里好'
}
/**
* 将毫秒转换成时间字符串。例如说xx 分钟
*
* @param ms 毫秒
* @returns {string} 字符串
*/
export function formatPast2(ms) {
const day = Math.floor(ms / (24 * 60 * 60 * 1000))
const hour = Math.floor(ms / (60 * 60 * 1000) - day * 24)
const minute = Math.floor(ms / (60 * 1000) - day * 24 * 60 - hour * 60)
const second = Math.floor(ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60)
if (day > 0) {
return day + '天' + hour + '小时' + minute + '分钟'
}
if (hour > 0) {
return hour + '小时' + minute + '分钟'
}
if (minute > 0) {
return minute + '分钟'
}
if (second > 0) {
return second + '秒'
} else {
return 0 + '秒'
}
}