lizhenhao 2 роки тому
батько
коміт
77455b4bd4
5 змінених файлів з 159 додано та 8 видалено
  1. 1 0
      src/api/AppPath.js
  2. 9 8
      src/api/sys/OSSService.js
  3. 6 0
      src/main.js
  4. 75 0
      src/utils/validateXG.js
  5. 68 0
      src/utils/validatorXG.js

+ 1 - 0
src/api/AppPath.js

@@ -7,3 +7,4 @@ export const UREPORT_PATH = "/ureport-server";
 export const WPS_PATH = "/wps-server";
 export const TEST_PATH = "/test-server";
 export const ASSESS_PATH = "/assess-server";
+export const PUBLIC_MODULES_PATH = "/public-modules-server";

+ 9 - 8
src/api/sys/OSSService.js

@@ -1,46 +1,47 @@
 import OSS from 'ali-oss'
 import { ElMessage } from 'element-plus'
 import request from '@/utils/httpRequest'
+import { PUBLIC_MODULES_PATH as prefix } from "../AppPath";
 
 export default class OSSSerive {
   saveMsg (param) {
     return request({
-      url: '/oss/file/saveMsg',
+      url: prefix + '/oss/file/saveMsg',
       method: 'post',
       data: param
     })
   }
   findFileList (attachmentId) {
     return request({
-      url: '/oss/file/findFileList',
+		  url: prefix + '/oss/file/findFileList',
       method: 'get',
       params: {attachmentId: attachmentId}
     })
   }
   getTemporaryUrl (url) {
     return request({
-      url: '/oss/file/getTemporaryUrl',
+      url: prefix + '/oss/file/getTemporaryUrl',
       method: 'get',
       params: {url: url}
     })
   }
   getFileSizeByUrl (url) {
     return request({
-      url: '/oss/file/getFileSizeByUrl',
+      url: prefix + '/oss/file/getFileSizeByUrl',
       method: 'get',
       params: {url: url}
     })
   }
   deleteMsgById (id) {
     return request({
-      url: '/oss/file/deleteMsgById',
+      url: prefix + '/oss/file/deleteMsgById',
       method: 'get',
       params: {id: id}
     })
   }
   downLoadAttach (url) {
     return request({
-      url: '/oss/file/downLoadAttach',
+      url: prefix + '/oss/file/downLoadAttach',
       method: 'get',
       responseType: 'blob',
       params: {file: url}
@@ -182,7 +183,7 @@ export async function httpRequest (file, name, type, maxValue) { // 阿里云OSS
 // eslint-disable-next-line no-unused-vars
 function getTemporaryByUrl (url) {
   return request({
-    url: '/oss/file/getTemporaryUrl',
+    url: prefix + '/oss/file/getTemporaryUrl',
     method: 'get',
     params: {url: url}
   })
@@ -221,7 +222,7 @@ export async function toHref (row) {
   }
   const link = document.createElement('a')
   await getTemporaryByUrl(row.url).then((data) => {
-    const url = data.data // 完整的url则直接使用
+    const url = data // 完整的url则直接使用
     // 这里是将url转成blob地址,
     fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
       link.href = URL.createObjectURL(blob)

+ 6 - 0
src/main.js

@@ -12,6 +12,9 @@ import dictUtils from "@/utils/dictUtils";
 import httpRequest from "@/utils/httpRequest";
 import commonJS from '@/utils/common';
 import validator from "@/utils/validator";
+import validate from '@/utils/validate'
+import validatorXG from '@/utils/validatorXG'
+import validateXG from '@/utils/validateXG'
 import components from "./components";
 import i18n from "./i18n";
 import router from "./router";
@@ -44,6 +47,9 @@ app.config.globalProperties.recover = utils.recover;
 app.config.globalProperties.recoverNotNull = utils.recoverNotNull;
 app.config.globalProperties.pickProperties = utils.pickProperties;
 app.config.globalProperties.validator = validator;
+app.config.globalProperties.validate = validate
+app.config.globalProperties.validatorXG = validatorXG
+app.config.globalProperties.validateXG = validateXG
 app.config.globalProperties.moment = moment;
 app.config.globalProperties.lodash = lodash;
 app.config.globalProperties.deepClone = utils.deepClone;

+ 75 - 0
src/utils/validateXG.js

@@ -0,0 +1,75 @@
+/**
+ * 移动电话号码验证
+ * @param str
+ * @returns {boolean}
+ */
+export function isMobile (str) {
+  const mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(19[0-9]{1}))+\d{8})$/
+  return mobile.test(str)
+}
+
+/**
+ * 固定电话号码验证
+ * @param str
+ * @returns {boolean}
+ */
+export function isPhone (str) {
+  const phone = /(^(\d{3,4}-)?\d{6,8}$)|(^(\d{3,4}-)?\d{6,8}(-\d{1,5})?$)/
+  return phone.test(str)
+}
+
+/**
+ * 固定电话或移动电话号码验证
+ * @param str
+ * @returns {boolean}
+ */
+export function isPhoneOrMobile (str) {
+  const phone = /(^(\d{3,4}-)?\d{6,8}$)|(^(\d{3,4}-)?\d{6,8}(-\d{1,5})?$)|(^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(19[0-9]{1}))+\d{8})$)/
+  return phone.test(str)
+}
+
+/**
+ * 开户行账号验证
+ * 开户行账号只能为数字、长度限定为1到20位之间
+ * @param str
+ * @returns {boolean}
+ */
+export function isBankNumber (str) {
+  // const bankNumber = /^([1-9]{1})(\d{15}|\d{18})$/
+  const bankNumber = /^[1-9]\d{0,19}$/
+  return bankNumber.test(str)
+}
+
+/**
+ * 联系人联系方式验证
+ * 联系人联系方式只能为数字,长度限定为20
+ * @param str
+ * @returns {boolean}
+ */
+export function isLinkMobile (str) {
+  const linkMobile = /^[0-9]\d{19}$/
+  return linkMobile.test(str)
+}
+
+/**
+ * 银行卡号验证
+ * 银行卡号:12位 16位 17 18 19
+ * @param str
+ * @returns {boolean}
+ */
+export function isBankNum (str) {
+  const bankNumber = /^([1-9]{1})(\d{11}|\d{15}|\d{16}|\d{17}|\d{18})$/
+  return bankNumber.test(str)
+}
+
+/**
+ * 邮箱验证
+ * @param str
+ * @returns {boolean}
+ */
+export function isEmail (str) {
+  const email = /^((https|http|ftp|rtsp|mms)?:\/\/)?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
+  return email.test(str)
+}
+
+export default {isMobile, isPhone, isBankNumber, isLinkMobile, isBankNum, isPhoneOrMobile, isEmail}

+ 68 - 0
src/utils/validatorXG.js

@@ -0,0 +1,68 @@
+import validateXG from './validateXG'
+import validate from './validate'
+
+var isMobile = (rule, value, callback) => {
+  if (value && !validateXG.isMobile(value)) {
+    callback(new Error('请输入正确的电话号码'))
+  } else {
+    callback()
+  }
+}
+
+var isPhone = (rule, value, callback) => {
+  if (value && !validateXG.isPhone(value)) {
+    callback(new Error('请输入正确的电话号码'))
+  } else {
+    callback()
+  }
+}
+
+var isPhoneOrMobile = (rule, value, callback) => {
+  if (value && !validateXG.isPhoneOrMobile(value)) {
+    callback(new Error('请输入正确的电话号码'))
+  } else {
+    callback()
+  }
+}
+
+var isBankNumber = (rule, value, callback) => {
+  if (value && !validateXG.isBankNumber(value)) {
+    callback(new Error('请输入正确的开票账号'))
+  } else {
+    callback()
+  }
+}
+
+var isLinkMobile = (rule, value, callback) => {
+  if (value && !validateXG.isLinkMobile(value)) {
+    callback(new Error('请输入正确的联系人联系方式'))
+  } else {
+    callback()
+  }
+}
+
+var isIntGtZero = (rule, value, callback) => {
+  if (value && !validate.isIntGtZero(value)) {
+    callback(new Error('请输入大于0整数'))
+  } else {
+    callback()
+  }
+}
+
+var isBankNum = (rule, value, callback) => {
+  if (value && !validateXG.isBankNum(value)) {
+    callback(new Error('请输入正确的银行卡号'))
+  } else {
+    callback()
+  }
+}
+
+var isEmail = (rule, value, callback) => {
+  if (value && !validateXG.isEmail(value)) {
+    callback(new Error('请输入正确的邮箱地址'))
+  } else {
+    callback()
+  }
+}
+
+export default {isMobile, isPhone, isBankNumber, isLinkMobile, isIntGtZero, isBankNum, isPhoneOrMobile, isEmail}