Merge branch 'master' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/notify

# Conflicts:
#	sql/mysql/ruoyi-vue-pro.sql
#	yudao-ui-admin/src/utils/dict.js
This commit is contained in:
YunaiV
2023-01-27 23:25:08 +08:00
2233 changed files with 107040 additions and 43011 deletions

View File

@ -0,0 +1,21 @@
import CryptoJS from 'crypto-js'
/**
* @word 要加密的内容
* @keyWord String 服务器随机返回的关键字
*/
export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') {
const key = CryptoJS.enc.Utf8.parse(keyWord)
const secs = CryptoJS.enc.Utf8.parse(word)
const encrypted = CryptoJS.AES.encrypt(secs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
return encrypted.toString()
}
/**
* @word 要解密的内容
* @keyWord String 服务器随机返回的关键字
*/
export function aesDecrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') {
const key = CryptoJS.enc.Utf8.parse(keyWord)
const decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
return CryptoJS.enc.Utf8.stringify(decrypt).toString()
}

View File

@ -94,3 +94,6 @@ export function setTenantId(username) {
export function removeTenantId() {
localStorage.removeItem(TenantIdKey)
}
export class getToken {
}

View File

@ -3,6 +3,37 @@
*
* 枚举类
*/
import {beginOfDay, endOfDay} from "@/utils/dateUtils";
export const datePickerOptions = {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
const end = new Date();
picker.$emit('pick', [beginOfDay(start), endOfDay(end)]);
}
}, {
text: '最近一个月',
onClick(picker) {
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
const end = new Date();
picker.$emit('pick', [beginOfDay(start), endOfDay(end)]);
}
}, {
text: '最近三个月',
onClick(picker) {
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
const end = new Date();
picker.$emit('pick', [beginOfDay(start), endOfDay(end)]);
}
}]
}
// ========== 静态变量 ==========
/**
* 全局通用状态枚举
@ -185,37 +216,132 @@ export const PayOrderRefundStatusEnum = {
* 支付退款订单状态枚举
*/
export const PayRefundStatusEnum = {
CREATE:{
status:0,
CREATE: {
status: 0,
name: '退款订单生成'
},
SUCCESS:{
status:1,
SUCCESS: {
status: 1,
name: '退款成功'
},
FAILURE:{
status:2,
FAILURE: {
status: 2,
name: '退款失败'
},
PROCESSING_NOTIFY:{
status:3,
PROCESSING_NOTIFY: {
status: 3,
name: '退款中,渠道通知结果'
},
PROCESSING_QUERY:{
status:4,
PROCESSING_QUERY: {
status: 4,
name: '退款中,系统查询结果'
},
UNKNOWN_RETRY:{
status:5,
UNKNOWN_RETRY: {
status: 5,
name: '状态未知,请重试'
},
UNKNOWN_QUERY:{
status:6,
UNKNOWN_QUERY: {
status: 6,
name: '状态未知,系统查询结果'
},
CLOSE:{
status:99,
CLOSE: {
status: 99,
name: '退款关闭'
}
}
/**
* 商品 SPU 状态
*/
export const ProductSpuStatusEnum = {
RECYCLE: {
status: -1,
name: '回收站'
},
DISABLE: {
status: 0,
name: '下架'
},
ENABLE: {
status: 1,
name: '上架'
},
}
/**
* 优惠类型枚举
*/
export const PromotionDiscountTypeEnum = {
PRICE: {
type: 1,
name: '满减'
},
PERCENT: {
type: 2,
name: '折扣'
}
}
/**
* 优惠劵模板的有限期类型的枚举
*/
export const CouponTemplateValidityTypeEnum = {
DATE: {
type: 1,
name: '固定日期可用'
},
TERM: {
type: 2,
name: '领取之后可用'
}
}
/**
* 营销的商品范围枚举
*/
export const PromotionProductScopeEnum = {
ALL: {
scope: 1,
name: '全部商品参与'
},
SPU: {
scope: 2,
name: '指定商品参与'
}
}
/**
* 营销的条件类型枚举
*/
export const PromotionConditionTypeEnum = {
PRICE: {
type: 10,
name: '满 N 元'
},
COUNT: {
type: 20,
name: '满 N 件'
}
}
/**
* 促销活动的状态枚举
*/
export const PromotionActivityStatusEnum = {
WAIT: {
type: 10,
name: '未开始'
},
RUN: {
type: 20,
name: '进行中'
},
END: {
type: 30,
name: '已结束'
},
CLOSE: {
type: 40,
name: '已关闭'
}
}

View File

@ -24,3 +24,52 @@ export function getDate(ms) {
return 0 + "秒";
}
}
export function beginOfDay(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
export function endOfDay(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999);
}
export function betweenDay(date1, date2) {
date1 = convertDate(date1);
date2 = convertDate(date2);
// 计算差值
return Math.floor((date2.getTime() - date1.getTime()) / (24 * 3600 * 1000));
}
export function formatDate(date, fmt) {
date = convertDate(date);
const o = {
"M+": date.getMonth() + 1, //月份
"d+": date.getDate(), //日
"H+": date.getHours(), //小时
"m+": date.getMinutes(), //分
"s+": date.getSeconds(), //秒
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
"S": date.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) { // 年份
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (const k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
}
export function addTime(date, time) {
date = convertDate(date);
return new Date(date.getTime() + time);
}
export function convertDate(date) {
if (typeof date === 'string') {
return new Date(date);
}
return date;
}

View File

@ -8,6 +8,7 @@ import store from '@/store'
export const DICT_TYPE = {
USER_TYPE: 'user_type',
COMMON_STATUS: 'common_status',
TERMINAL: 'terminal',
// ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX: 'system_user_sex',
@ -25,6 +26,7 @@ export const DICT_TYPE = {
SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type',
SYSTEM_OAUTH2_GRANT_TYPE: 'system_oauth2_grant_type',
SYSTEM_NOTIFY_READ_STATUS: "system_notify_read_status",
SYSTEM_MAIL_SEND_STATUS: 'system_mail_send_status',
// ========== INFRA 模块 ==========
INFRA_BOOLEAN_STRING: 'infra_boolean_string',
@ -57,6 +59,30 @@ export const DICT_TYPE = {
PAY_ORDER_REFUND_STATUS: 'pay_order_refund_status', // 商户支付订单退款状态
PAY_REFUND_ORDER_STATUS: 'pay_refund_order_status', // 退款订单状态
PAY_REFUND_ORDER_TYPE: 'pay_refund_order_type', // 退款订单类别
// ========== MP 模块 ==========
MP_AUTO_REPLY_REQUEST_MATCH: 'mp_auto_reply_request_match', // 自动回复请求匹配类型
MP_MESSAGE_TYPE: 'mp_message_type', // 消息类型
// ========== MALL - PRODUCT 模块 ==========
PRODUCT_SPU_STATUS: 'product_spu_status', // 商品 SPU 状态
// ========== MALL - ORDER 模块 ==========
TRADE_AFTER_SALE_STATUS: 'trade_after_sale_status', // 售后 - 状态
TRADE_AFTER_SALE_WAY: 'trade_after_sale_way', // 售后 - 方式
TRADE_AFTER_SALE_TYPE: 'trade_after_sale_type', // 售后 - 类型
TRADE_ORDER_TYPE: 'trade_order_type', // 订单 - 类型
TRADE_ORDER_STATUS: 'trade_order_status', // 订单 - 状态
TRADE_ORDER_ITEM_AFTER_SALE_STATUS: 'trade_order_item_after_sale_status', // 订单项 - 售后状态
// ========== MALL - PROMOTION 模块 ==========
PROMOTION_DISCOUNT_TYPE: 'promotion_discount_type', // 优惠类型
PROMOTION_PRODUCT_SCOPE: 'promotion_product_scope', // 营销的商品范围
PROMOTION_COUPON_TEMPLATE_VALIDITY_TYPE: 'promotion_coupon_template_validity_type', // 优惠劵模板的有限期类型
PROMOTION_COUPON_STATUS: 'promotion_coupon_status', // 优惠劵的状态
PROMOTION_COUPON_TAKE_TYPE: 'promotion_coupon_take_type', // 优惠劵的领取方式
PROMOTION_ACTIVITY_STATUS: 'promotion_activity_status', // 优惠活动的状态
PROMOTION_CONDITION_TYPE: 'promotion_condition_type', // 营销的条件类型枚举
}
/**
@ -115,6 +141,3 @@ export function getDictDataLabel(dictType, value) {
const dict = getDictData(dictType, value);
return dict ? dict.label : '';
}
export class getDictDataL {
}

View File

@ -1,13 +1,32 @@
/**
* 将服务端返回的 fields 字符串数组,解析成 JSON 数组
* 如果指定了 variables 参数可对表单进行初始化
*
* @param fields JSON 字符串数组
* @param variables Object 表单初始值
* @returns {*[]} JSON 数组
*/
export function decodeFields(fields) {
const drawingList = []
fields.forEach(item => {
drawingList.push(JSON.parse(item))
export function decodeFields(fields, variables) {
const drawingList = (fields || []).map(json => {
const item = JSON.parse(json)
if (typeof variables === 'undefined' ) return item
const setDefault = (item, variables) => {
if (typeof variables[item.__vModel__] !== 'undefined') {
item.__config__.defaultValue = variables[item.__vModel__]
}
if (item.__config__.children && item.__config__.children.length) {
item.__config__.children.forEach(child => {
setDefault(child, variables)
})
}
}
setDefault(item, variables)
return item
})
return drawingList
}

View File

@ -4,14 +4,14 @@ import { parseTime } from './ruoyi'
* 表格时间格式化
*/
export function formatDate(cellValue) {
if (cellValue == null || cellValue == "") return "";
var date = new Date(cellValue)
var year = date.getFullYear()
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
if (cellValue == null || cellValue === "") return "";
const date = new Date(cellValue)
const year = date.getFullYear()
const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
const hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
const seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
}
@ -78,13 +78,13 @@ export function getQueryObject(url) {
}
/**
* @param {string} input value
* @returns {number} output value
* @param str
* @param str
*/
export function byteLength(str) {
// returns the byte length of an utf8 string
let s = str.length
for (var i = str.length - 1; i >= 0; i--) {
for (let i = str.length - 1; i >= 0; i--) {
const code = str.charCodeAt(i)
if (code > 0x7f && code <= 0x7ff) s++
else if (code > 0x7ff && code <= 0xffff) s += 2
@ -136,8 +136,7 @@ export function param2Obj(url) {
const index = v.indexOf('=')
if (index !== -1) {
const name = v.substring(0, index)
const val = v.substring(index + 1, v.length)
obj[name] = val
obj[name] = v.substring(index + 1, v.length)
}
})
return obj
@ -330,7 +329,7 @@ export function createUniqueString() {
/**
* Check if an element has a class
* @param {HTMLElement} elm
* @param ele
* @param {string} cls
* @returns {boolean}
*/
@ -340,7 +339,7 @@ export function hasClass(ele, cls) {
/**
* Add class to element
* @param {HTMLElement} elm
* @param ele
* @param {string} cls
*/
export function addClass(ele, cls) {
@ -349,7 +348,7 @@ export function addClass(ele, cls) {
/**
* Remove class from element
* @param {HTMLElement} elm
* @param ele
* @param {string} cls
*/
export function removeClass(ele, cls) {

View File

@ -15,10 +15,8 @@ export function checkPermi(value) {
return all_permission === permission || permissionDatas.includes(permission)
})
if (!hasPermission) {
return false
}
return true
return hasPermission;
} else {
console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`)
return false
@ -40,12 +38,10 @@ export function checkRole(value) {
return super_admin === role || permissionRoles.includes(role)
})
if (!hasRole) {
return false
}
return true
return hasRole;
} else {
console.error(`need roles! Like checkRole="['admin','editor']"`)
return false
}
}
}

View File

@ -49,12 +49,12 @@ service.interceptors.request.use(config => {
let url = config.url + '?';
for (const propName of Object.keys(config.params)) {
const value = config.params[propName];
var part = encodeURIComponent(propName) + "=";
const part = encodeURIComponent(propName) + '='
if (value !== null && typeof(value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
let params = propName + '[' + key + ']';
var subPart = encodeURIComponent(params) + "=";
const subPart = encodeURIComponent(params) + '='
url += subPart + encodeURIComponent(value[key]) + "&";
}
} else {

View File

@ -18,7 +18,7 @@ export function parseTime(time, pattern) {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
} else if (typeof time === 'string') {
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm),'');
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm),'');
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
@ -34,7 +34,7 @@ export function parseTime(time, pattern) {
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
@ -102,9 +102,11 @@ export function addBeginAndEndTime(params, dateRange, propName) {
// 字符串格式化(%s )
export function sprintf(str) {
var args = arguments, flag = true, i = 1;
const args = arguments
let flag = true
const i = 1
str = str.replace(/%s/g, function () {
var arg = args[i++];
const arg = args[i++]
if (typeof arg === 'undefined') {
flag = false;
return '';
@ -116,7 +118,7 @@ export function sprintf(str) {
// 转换字符串undefined,null等转化为""
export function praseStrEmpty(str) {
if (!str || str == "undefined" || str == "null") {
if (!str || str === "undefined" || str === "null") {
return "";
}
return str;
@ -185,6 +187,19 @@ export function getTenantEnable() {
return process.env.VUE_APP_TENANT_ENABLE || true;
}
/**
* 获得验证码功能是否开启
*/
export function getCaptchaEnable() {
if (process.env.VUE_APP_CAPTCHA_ENABLE === "true") {
return true;
}
if (process.env.VUE_APP_CAPTCHA_ENABLE === "false") {
return false;
}
return process.env.VUE_APP_CAPTCHA_ENABLE || true;
}
/**
* 获得文档是否开启
*/
@ -222,3 +237,17 @@ export function getPath(path) {
}
return basePath + path;
}
/**
* 除法保留两位小数
*
* @param {*} divisor 除数
* @param {*} dividend 被除数
* @returns
*/
export function divide(divisor, dividend) {
if(divisor == null || dividend == null || dividend === 0){
return null;
}
return Math.floor(divisor/dividend*100)/100;
}

View File

@ -8,8 +8,10 @@ Math.easeInOutQuad = function(t, b, c, d) {
}
// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
var requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) }
const requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) {
window.setTimeout(callback, 1000 / 60)
}
})()
/**
@ -37,11 +39,11 @@ export function scrollTo(to, duration, callback) {
const increment = 20
let currentTime = 0
duration = (typeof (duration) === 'undefined') ? 500 : duration
var animateScroll = function() {
const animateScroll = function() {
// increment the time
currentTime += increment
// find the value with the quadratic in-out easing function
var val = Math.easeInOutQuad(currentTime, start, change, duration)
const val = Math.easeInOutQuad(currentTime, start, change, duration)
// move the document.body
move(val)
// do the animation unless its over

View File

@ -56,7 +56,7 @@ export function validAlphabets(str) {
* @returns {Boolean}
*/
export function validEmail(email) {
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
const reg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return reg.test(email)
}
@ -65,10 +65,8 @@ export function validEmail(email) {
* @returns {Boolean}
*/
export function isString(str) {
if (typeof str === 'string' || str instanceof String) {
return true
}
return false
return typeof str === 'string' || str instanceof String;
}
/**