模型基础信息
This commit is contained in:
@@ -2,4 +2,7 @@
|
||||
export const ADVANCE_BOOT = '/advance-boot'
|
||||
|
||||
//技术监督
|
||||
export const PROCESS_BOOT = '/process-boot'
|
||||
export const PROCESS_BOOT = '/process-boot'
|
||||
|
||||
//工作流模块
|
||||
export const WORKFLOW_BOOT = '/workflow-boot'
|
||||
51
src/utils/formRules.js
Normal file
51
src/utils/formRules.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
export const required = (message, trigger = ['blur', 'change']) => ({
|
||||
required: true,
|
||||
message,
|
||||
trigger
|
||||
})
|
||||
|
||||
// 常用正则规则大全:https://any86.github.io/any-rule/
|
||||
|
||||
export const rules = {
|
||||
phone: {
|
||||
pattern: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
|
||||
message: '请填写符合要求的11位手机号',
|
||||
trigger: 'blur'
|
||||
},
|
||||
email: {
|
||||
pattern: /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
||||
message: '请填写正确的邮箱号',
|
||||
trigger: 'blur'
|
||||
},
|
||||
idCard: {
|
||||
pattern:
|
||||
/(^\d{8}(0\d|10|11|12)([0-2]\d|30|31)\d{3}$)|(^\d{6}(18|19|20)\d{2}(0[1-9]|10|11|12)([0-2]\d|30|31)\d{3}(\d|X|x)$)/,
|
||||
message: '请填写符合要求的身份证号',
|
||||
trigger: 'blur'
|
||||
},
|
||||
lettersNum: {
|
||||
pattern: /^[A-Za-z0-9]+$/,
|
||||
message: '填写内容须是字母或数字组成',
|
||||
trigger: 'blur'
|
||||
},
|
||||
number: {
|
||||
pattern: /^\d{1,}$/,
|
||||
message: '填写内容必须是纯数字',
|
||||
trigger: 'blur'
|
||||
},
|
||||
price: {
|
||||
pattern: /(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/,
|
||||
message: '只支持正数金额',
|
||||
trigger: 'blur'
|
||||
}
|
||||
}
|
||||
161
src/utils/tool.js
Normal file
161
src/utils/tool.js
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* Copyright [2022] [https://www.xiaonuo.vip]
|
||||
* Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Snowy源码头部的版权声明。
|
||||
* 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
||||
* 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
||||
* 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
||||
*/
|
||||
/*
|
||||
* @Descripttion: 工具集
|
||||
* @version: 1.1
|
||||
* @LastEditors: yubaoshan
|
||||
* @LastEditTime: 2022年4月19日10:58:41
|
||||
*/
|
||||
const tool = {}
|
||||
|
||||
// localStorage
|
||||
tool.data = {
|
||||
set(table, settings) {
|
||||
const _set = JSON.stringify(settings)
|
||||
return localStorage.setItem(table, _set)
|
||||
},
|
||||
get(table) {
|
||||
let data = localStorage.getItem(table)
|
||||
try {
|
||||
data = JSON.parse(data)
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
return data
|
||||
},
|
||||
remove(table) {
|
||||
return localStorage.removeItem(table)
|
||||
},
|
||||
|
||||
clear() {
|
||||
return localStorage.clear()
|
||||
}
|
||||
}
|
||||
|
||||
// sessionStorage
|
||||
tool.session = {
|
||||
set(table, settings) {
|
||||
const _set = JSON.stringify(settings)
|
||||
return sessionStorage.setItem(table, _set)
|
||||
},
|
||||
get(table) {
|
||||
let data = sessionStorage.getItem(table)
|
||||
try {
|
||||
data = JSON.parse(data)
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
return data
|
||||
},
|
||||
remove(table) {
|
||||
return sessionStorage.removeItem(table)
|
||||
},
|
||||
clear() {
|
||||
return sessionStorage.clear()
|
||||
}
|
||||
}
|
||||
|
||||
// 千分符
|
||||
tool.groupSeparator = (num) => {
|
||||
num = `${num}`
|
||||
if (!num.includes('.')) num += '.'
|
||||
|
||||
return num
|
||||
.replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
|
||||
return `${$1},`
|
||||
})
|
||||
.replace(/\.$/, '')
|
||||
}
|
||||
|
||||
// 获取所有字典数组
|
||||
tool.dictDataAll = () => {
|
||||
return tool.data.get('DICT_TYPE_TREE_DATA')
|
||||
}
|
||||
|
||||
// 字典翻译方法,界面插槽使用方法 {{ $TOOL.dictType('sex', record.sex) }}
|
||||
tool.dictTypeData = (dictValue, value) => {
|
||||
const dictTypeTree = tool.dictDataAll()
|
||||
if (!dictTypeTree) {
|
||||
return '需重新登录'
|
||||
}
|
||||
const tree = dictTypeTree.find((item) => item.dictValue === dictValue)
|
||||
if (!tree) {
|
||||
return '无此字典'
|
||||
}
|
||||
const children = tree.children
|
||||
const dict = children.find((item) => item.dictValue === value)
|
||||
return dict ? dict.dictLabel : '无此字典项'
|
||||
}
|
||||
|
||||
// 获取某个code下字典的列表,多用于字典下拉框
|
||||
tool.dictTypeList = (dictValue) => {
|
||||
const dictTypeTree = tool.dictDataAll()
|
||||
if (!dictTypeTree) {
|
||||
return []
|
||||
}
|
||||
const tree = dictTypeTree.find((item) => item.dictValue === dictValue)
|
||||
if (tree && tree.children) {
|
||||
return tree.children
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
// 获取某个code下字典的列表,基于dictTypeList 改进,保留老的,逐步替换
|
||||
tool.dictList = (dictValue) => {
|
||||
const dictTypeTree = tool.dictDataAll()
|
||||
if (!dictTypeTree) {
|
||||
return []
|
||||
}
|
||||
const tree = dictTypeTree.find((item) => item.dictValue === dictValue)
|
||||
if (tree) {
|
||||
return tree.children.map((item) => {
|
||||
return {
|
||||
value: item['dictValue'],
|
||||
label: item['name']
|
||||
}
|
||||
})
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
// 树形翻译 需要指定最顶级的 parentValue 和当级的value
|
||||
tool.translateTree = (parentValue, value) => {
|
||||
const tree = tool.dictDataAll().find((item) => item.dictValue === parentValue)
|
||||
const targetNode = findNodeByValue(tree, value)
|
||||
return targetNode ? targetNode.dictLabel : ''
|
||||
}
|
||||
const findNodeByValue = (node, value) => {
|
||||
if (node.dictValue === value) {
|
||||
return node
|
||||
}
|
||||
if (node.children) {
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const result = findNodeByValue(node.children[i], value)
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 生成UUID
|
||||
tool.snowyUuid = () => {
|
||||
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||
let r = (Math.random() * 16) | 0,
|
||||
v = c === 'x' ? r : (r & 0x3) | 0x8
|
||||
return v.toString(16)
|
||||
})
|
||||
// 首字符转换成字母
|
||||
return 'xn' + uuid.slice(2)
|
||||
}
|
||||
|
||||
export default tool
|
||||
Reference in New Issue
Block a user