Browse Source

校验

master
zhang_li 6 months ago
parent
commit
e5e484bcd0
  1. 808
      src/utils/validator.ts
  2. 170
      src/views/base/linuxAccess/index.vue
  3. 183
      src/views/base/qadAccess/index.vue
  4. 56
      src/views/excel/index.vue

808
src/utils/validator.ts

@ -0,0 +1,808 @@
//校验学校编码 只能为数字
export function validateCode(rule, value, callback) {
if (!value) {
return callback(new Error('学校编码不能为空'))
} else {
const codeReg = /^[0-9]+$/
const codeMax = /^\d{0,5}$/
if (codeReg.test(value)) {
if (codeMax.test(value)) {
callback()
} else {
callback(new Error('学校编码不能大于5位'))
}
} else {
callback(new Error('请输入正确的学校编码,只能是数字'))
}
}
}
//校验邮箱
export function validateEmail(rule, value, callback) {
if (value) {
const mailReg = /^([a-zA-Z0-9_-]+.)+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-]+.)+/
if (mailReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的邮箱格式'))
}
} else {
callback()
}
}
//校验英文
export function validateEng(rule, value, callback) {
if (value) {
const mailReg = /^[A-Za-z\-\&\(\)\Ⅰ\Ⅱ\Ⅲ\Ⅳ\Ⅴ\Ⅵ\Ⅶ\Ⅷ\Ⅸ\Ⅹ\s]+$/;
if (mailReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的英文名字'))
}
} else {
callback()
}
}
//校验姓名拼音
export function validateEngName(rule, value, callback) {
if (value) {
const EngNameReg = /^[A-Za-z \(\)\s]+$/
if (EngNameReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的姓名拼音'))
}
} else {
callback()
}
}
//校验手机号码
export function validateHanset(rule, value, callback) {
if (value) {
// const regs =/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
// const regs = /^1[3|4|5|7|8][0-9]\d{8}$/
const regs = /^1[3-9]\d{9}$/
if (regs.test(value)) {
callback()
} else {
return callback(new Error('请输入正确的手机号'))
}
} else {
callback()
}
}
//校验座机电话
export function validatePhone(rule, value, callback) {
if (value) {
//const reg = /^1[3|4|5|7|8][0-9]\d{8}$/
// const regs = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
const regs = /^((0\d{2,3}-\d{7,8}))$/;
if (regs.test(value)) {
callback()
} else {
return callback(new Error('请输入正确的座机号'))
}
} else {
callback()
}
}
//校验家庭电话 手机或者座机
export function validateFamilyPhone(rule, value, callback) {
if (value) {
const isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
// const isMob = /^((\+?86)|(\+86))?(13[0123456789][0-9]{8}|15[0123456789][0-9]{8}|17[0123456789][0-9]{8}|18[0123456789][0-9]{8}|147[0-9]{8}|1349[0-9]{7})$/;
const isMob = /^1[3-9]\d{9}$/
if (isPhone.test(value) || isMob.test(value)) {
callback()
} else {
return callback(new Error('请输入正确的手机或者座机电话'))
}
} else {
callback()
}
}
// 校验只能为中文
export function validateChinese(rule, value, callback) {
if (value) {
const chineseReg = /^[\u4E00-\u9FA5]+$/
if (chineseReg.test(value)) {
callback()
} else {
callback(new Error('请输入简介,只能为中文'))
}
} else {
callback()
}
}
// 校验名称既能为中文也可以为英文
export function validateName(rule, value, callback) {
if (value) {
const chineseReg = /^[\u4E00-\u9FA5]+$/
const engLish = /^[A-Za-z]+$/
if (chineseReg.test(value) || engLish.test(value)) {
callback()
} else {
callback(new Error('请输入正确的中文或者英文名称'))
}
} else {
callback()
}
}
// 校验负责人既能为中文也可以为英文
export function validateChargeperson(rule, value, callback) {
if (value) {
const chineseReg = /^[\u4E00-\u9FA5]+$/
const engLish = /^[A-Za-z]+$/
if (chineseReg.test(value) || engLish.test(value)) {
callback()
} else {
callback(new Error('请输入正确的负责人(中英文都可以)'))
}
} else {
callback()
}
}
//校验学校名称不能为空
export function validateXXMC(rule, value, callback) {
if (!value) {
return callback(new Error('案例名称不能为空'))
} else {
const chineseReg = /^[\u4E00-\u9FA5]+$/
if (chineseReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的案例名称,只能是汉字'))
}
}
}
//校验中英文数字和下划线都可以
export function validateZYS(rule, value, callback) {
if (value) {
//const postReg =/^[\u4e00-\u9fa5_a-zA-Z0-9_]{4,10}+$/
const Reg = /^[\u4e00-\u9fa5a-zA-Z0-9]+$/
if (Reg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的名称'))
}
} else {
callback()
}
}
// 校验邮政编码
export function validatePostCode(rule, value, callback) {
if (value) {
const postReg = /^[1-9]\d{5}$/
if (postReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的邮政编码'))
}
} else {
callback()
}
}
// 数字
export function validateNum(rule, value, callback) {
if (value) {
const numReg = /^[\d]+$/
if (numReg.test(value)) {
callback()
} else {
callback(new Error('请输入数字'))
}
} else {
callback()
}
}
//数字和小数点
export function validateNumDot(rule, value, callback) {
if (value) {
const numReg = /^\d+$|^\d+\.\d+$/g
if (numReg.test(value)) {
callback()
} else {
callback(new Error('请输入数字或小数点'))
}
} else {
callback()
}
}
// 组织机构代码
export function validateOrganization(rule, value, callback) {
if (value) {
const orgReg = /^[A-Za-z0-9]\w{14}$/g
if (orgReg.test(value)) {
callback()
} else {
callback(new Error('请输入组织机构代码'))
}
} else {
callback()
}
}
// 传真
export function validateFax(rule, value, callback) {
if (value) {
const faxReg = /^(\d{3,4}-)?\d{7,8}$/
if (faxReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的传真'))
}
} else {
callback()
}
}
// 主页地址
export function validateHome(rule, value, callback) {
if (value) {
const homeReg = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/
if (homeReg.test(value)) {
callback()
} else {
return callback(new Error('请输入正确的主页地址'))
}
} else {
callback()
}
}
// 学分 小数,且保留最多三位小数
export function validateXf(rule, value, callback) {
if (!value) {
return callback(new Error('学分不能为空'))
} else {
const numReg = /^[0-9]+\.[0-9]{0,3}$/
if (numReg.test(value)) {
callback()
} else {
callback(new Error('请输入小数,且小数点后最多三位'))
}
}
}
// 数字格式 小数点后一位
export function validateOneNum(rule, value, callback) {
if (value) {
const numReg = /^\d+(\.\d+)?$/
const numOneReg = /^\d*\.{0,1}\d{0,1}$/
if (numReg.test(value)) {
if (numOneReg.test(value)) {
callback()
} else {
callback(new Error('小数点后最多1位'))
}
} else {
callback(new Error('请输入数字'))
}
}
callback()
}
// 数字格式 小数点后两位
export function validateTwoNum(rule, value, callback) {
if (value) {
const numReg = /^\d+(\.\d+)?$/
const numTwoReg = /^\d*\.{0,2}\d{0,2}$/
if (numReg.test(value)) {
if (numTwoReg.test(value)) {
callback()
} else {
callback(new Error('小数点后最多2位'))
}
} else {
callback(new Error('请输入数字'))
}
}
callback()
}
// 小数点前位数不得大于6位
export function validateNumSix(rule, value, callback) {
if (value) {
if (value.split('.')[0].length > 6) {// 校验value值不能大于10000
callback(new Error('版本号小数点前位数不得大于6'))
}else{
callback()
}
}
callback()
}
// 数字格式 小数点后两位 小数点前保留五位
export function validateTwoNumThree(rule, value, callback) {
if (value) {
if (Number(value) > 10000) {// 校验value值不能大于10000
callback(new Error('数值过大,请重新输入'))
}
const numReg = /^\d+(\.\d+)?$/
const numTwoReg = /^\d*\.{0,2}\d{0,2}$/
if (numReg.test(value)) {
if (numTwoReg.test(value)) {
callback()
} else {
callback(new Error('小数点后最多2位'))
}
} else {
callback(new Error('请输入数字'))
}
}
callback()
}
// 数字格式 数字不可以大于5
export function validateMaxNumber5(rule, value, callback) {
if (parseInt(value) <= 5) {
callback()
} else {
callback(new Error('不能大于5'))
}
}
// 数字格式 小数点后三位
export function validateThreeNum(rule, value, callback) {
if (value) {
const numReg = /^\d+(\.\d+)?$/
const numTwoReg = /^\d*\.{0,3}\d{0,3}$/
if (numReg.test(value)) {
if (numTwoReg.test(value)) {
callback()
} else {
callback(new Error('小数点后最多3位'))
}
} else {
callback(new Error('请输入数字'))
}
}
callback()
// if (!value) {
// return callback(new Error('字段不能为空'))
// } else {
// const numReg = /^\d+(\.\d+)?$/
// const numTwoReg = /^\d*\.{0,3}\d{0,3}$/
// if (numReg.test(value)) {
// if (numTwoReg.test(value)) {
// callback()
// } else {
// callback(new Error('小数点后最多3位'))
// }
// } else {
// callback(new Error('请输入数字'))
// }
// }
}
//校验年份必须为4位数字
export function validateNF(rule, value, callback) {
if (value) {
const NFReg = /^\d{4}$/
if (NFReg.test(value)) {
callback()
} else {
callback(new Error('请输入4位数字'))
}
} else {
callback()
}
}
//校验年份必须为4位数字
export function validateXQ(rule, value, callback) {
if (value) {
const NFReg = /^\d{5}$/
if (NFReg.test(value)) {
callback()
} else {
callback(new Error('请输入5位数字'))
}
} else {
callback()
}
}
//校验分数最大值
export function validateMaxNumber(rule, value, callback) {
if (parseInt(value) <= 200) {
callback()
} else {
callback(new Error('分数不能大于200'))
}
}
//校验正整数
export function validateInteger(rule, value, callback) {
if (value) {
const integerReg = /^[+]{0,1}(\d+)$/
if (integerReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的整数'))
}
} else {
callback()
}
}
//校验整数
export function validateroundNumber(rule, value, callback) {
if (value) {
const numReg = /^[1-9]\d*$/
if (numReg.test(value)) {
callback()
} else {
callback(new Error('请输入正确的整数'))
}
} else {
callback()
}
}
//校验身份证号
export function validateCard(rule, value, callback) {
if (value) {
const cardBoolean = IdCardValidate(value);
// const cardReg =/(^\d{18}$)|(^\d{17}(\d|X|x)$)/
// if (cardReg.test(value)) {
if (cardBoolean) {
callback()
} else {
callback(new Error('请输入正确的身份证号'))
}
} else {
callback()
}
}
//身份证:身份证校验
function IdCardValidate(code) {
let tip = "";
if (code != "") {
const city = {
11: "北京",
12: "天津",
13: "河北",
14: "山西",
15: "内蒙古",
21: "辽宁",
22: "吉林",
23: "黑龙江 ",
31: "上海",
32: "江苏",
33: "浙江",
34: "安徽",
35: "福建",
36: "江西",
37: "山东",
41: "河南",
42: "湖北 ",
43: "湖南",
44: "广东",
45: "广西",
46: "海南",
50: "重庆",
51: "四川",
52: "贵州",
53: "云南",
54: "西藏 ",
61: "陕西",
62: "甘肃",
63: "青海",
64: "宁夏",
65: "新疆",
71: "台湾",
81: "香港",
82: "澳门",
91: "国外 "
};
let pass = true;
//是否为空
if (code === '') {
tip = "请输入身份证号,身份证号不能为空";
pass = false;
}
//校验长度,类型
else if (isCardNo(code) === false) {
tip = "您输入的身份证号码不正确,请重新输入";
pass = false;
}
//检查省份
else if (checkProvince(code, city) === false) {
tip = "您输入的身份证号码不正确,请重新输入";
pass = false;
}
//校验生日
else if (checkBirthday(code) === false) {
tip = "您输入的身份证号码生日不正确,请重新输入";
pass = false;
} else {
//18位身份证需要验证最后一位校验位
if (code.length == 18) {
code = code.split('');
//∑(ai×Wi)(mod 11)
//加权因子
const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
//校验位
const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
let sum = 0;
let ai = 0;
let wi = 0;
for (let i = 0; i < 17; i++) {
ai = code[i];
wi = factor[i];
sum += ai * wi;
}
const last = parity[sum % 11];
if (parity[sum % 11] != code[17]) {
tip = "身份证格式错误";
pass = false;
}
}
}
return pass;
}
}
//身份证:检查身份证号码是否符合规范,包括长度,类型
function isCardNo(card) {
//身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X
const reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
if (reg.test(card) === false) {
return false;
}
return true;
};
//身份证:取身份证前两位,校验省份
function checkProvince(card, city) {
const province = card.substr(0, 2);
if (city[province] == undefined) {
return false;
}
return true;
};
//身份证:检查生日是否正确
function checkBirthday(card) {
const len = card.length;
//身份证15位时,次序为省(3位)市(3位)年(2位)月(2位)日(2位)校验位(3位),皆为数字
if (len == '15') {
const re_fifteen = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/;
const arr_data = card.match(re_fifteen);
const year = arr_data[2];
const month = arr_data[3];
const day = arr_data[4];
const birthday = new Date('19' + year + '/' + month + '/' + day);
return verifyBirthday('19' + year, month, day, birthday);
}
//身份证18位时,次序为省(3位)市(3位)年(4位)月(2位)日(2位)校验位(4位),校验位末尾可能为X
if (len == '18') {
const re_eighteen = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
const arr_data = card.match(re_eighteen);
const year = arr_data[2];
const month = arr_data[3];
const day = arr_data[4];
const birthday = new Date(year + '/' + month + '/' + day);
return verifyBirthday(year, month, day, birthday);
}
return false;
};
//身份证:校验日期
function verifyBirthday(year, month, day, birthday) {
const now = new Date();
const now_year = now.getFullYear();
//年月日是否合理
if (birthday.getFullYear() == year && (birthday.getMonth() + 1) == month && birthday.getDate() == day) {
//判断年份的范围(3岁到100岁之间)
const time = now_year - year;
if (time >= 3 && time <= 100) {
return true;
}
return false;
}
return false;By18Val
};
/**
* 18
* @param a_idCard
* @return
*/
function isTrueValidateCodeBy18IdCard(a_idCard) {
const By18Val = a_idCard[17].toLowerCase(); // 获取第十八位值
const numReg = /^[1-9]\d*$/
let numVal = false; // 校验第十八位是否为整数
if (numReg.test(Number(By18Val))) {
numVal = true
} else {
numVal = false
}
if (By18Val == 'x' || By18Val == 'X' || numVal) {
return true
} else {
return false
}
}
/**
*
* @param AddressNum
* @constructor
*/
function IdCardValidateAddress(AddressNum) {
const city = {
11: "北京",
12: "天津",
13: "河北",
14: "山西",
15: "内蒙古",
21: "辽宁",
22: "吉林",
23: "黑龙江 ",
31: "上海",
32: "江苏",
33: "浙江",
34: "安徽",
35: "福建",
36: "江西",
37: "山东",
41: "河南",
42: "湖北 ",
43: "湖南",
44: "广东",
45: "广西",
46: "海南",
50: "重庆",
51: "四川",
52: "贵州",
53: "云南",
54: "西藏 ",
61: "陕西",
62: "甘肃",
63: "青海",
64: "宁夏",
65: "新疆",
71: "台湾",
81: "香港",
82: "澳门",
91: "国外 "
};
if (city[AddressNum.substr(0, 2)]) {
return true
} else {
return false
}
}
/**
* 18
* @param idCard 18
* @return
*/
function isValidityBrithBy18IdCard(idCard18) {
const year = idCard18.substring(6, 10);
const month = idCard18.substring(10, 12);
const day = idCard18.substring(12, 14);
const temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day));
// 这里用getFullYear()获取年份,避免千年虫问题
if (temp_date.getFullYear() != parseFloat(year)
|| temp_date.getMonth() != parseFloat(month) - 1
|| temp_date.getDate() != parseFloat(day)) {
return false;
} else {
return true;
}
}
/**
* 15
* @param idCard15 15
* @return
*/
function isValidityBrithBy15IdCard(idCard15) {
const year = idCard15.substring(6, 8);
const month = idCard15.substring(8, 10);
const day = idCard15.substring(10, 12);
const temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day));
// 对于老身份证中的你年龄则不需考虑千年虫问题而使用getYear()方法
if (temp_date.getYear() != parseFloat(year)
|| temp_date.getMonth() != parseFloat(month) - 1
|| temp_date.getDate() != parseFloat(day)) {
return false;
} else {
return true;
}
}
/**
*
* @param str
* @returns {*}
*/
function trim(str) {
return str.replace(/(^\s*)|(\s*$)/g, "");
}
//校验只可输入大小写字母及数字
export function validateYS(rule, value, callback) {
if (value) {
const regs = /^[a-zA-Z0-9-_.]+$/
if(regs.test(value)){
callback()
} else {
callback(new Error('只能输入大小写字母及数字'))
}
}
else {
callback()
}
}
// 校验百分比
export function validatePercent(rule, value, callback){
if (!value) {
return callback(new Error('百分比不能为空'))
} else {
if(value < 0 || value > 100){
return callback(new Error('百分比范围 0 ~ 100'))
}
callback()
}
}
export default {
validateCode,
validateEmail,
validateEng,
validatePhone,
validateChinese,
validatePostCode,
validateNum,
validateNumDot,
validateZYS,
validateOrganization,
validateFax,
validateHome,
validateXXMC,
validateXf,
validateOneNum,
validateMaxNumber,
validateTwoNum,
validateTwoNumThree,
validateThreeNum,
validateInteger,
validateNF,
validateXQ,
validateroundNumber,
validateEngName,
validateCard,
validateHanset,
validateFamilyPhone,
validateName,
validateChargeperson,
validateYS,
validateMaxNumber5,
validatePercent,
validateNumSix
}

170
src/views/base/linuxAccess/index.vue

@ -165,12 +165,12 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="errorPath" prop="errorPath">
<el-form-item label="处理错误目录" prop="errorPath">
<el-input v-model="form.errorPath" placeholder="请输入" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="archivePath" prop="archivePath">
<el-form-item label="存档目录" prop="archivePath">
<el-input v-model="form.archivePath" placeholder="请输入" />
</el-form-item>
</el-col>
@ -213,7 +213,7 @@
<script setup name="LinuxAccess">
import { listLinuxAccess, getLinuxAccess, delLinuxAccess, addLinuxAccess, updateLinuxAccess } from "@/api/base/linuxAccess";
import { validateInteger } from '@/utils/validator'
const { proxy } = getCurrentInstance();
const linuxAccessList = ref([]);
@ -236,9 +236,173 @@ const data = reactive({
uri: null,
},
rules: {
companyCode:[{
required:true,
message: '请输入公司编码',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
companyName:[{
required:true,
message: '请输入公司名称',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
serverCode:[{
required:true,
message: '请输入服务器编码',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
ipAddress:[{
required:true,
message: '请输入ip地址',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
port:[{
required:true,
message: '请输入端口',
trigger: 'blur'
},
{
validator:validateInteger,
message:'请输入整数',
trigger:'blur'
}],
userName:[{
required:true,
message: '请输入用户',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
password:[{
required:true,
message: '请输入密码',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
workPath:[{
required:true,
message: '请输入工作目录',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
inPath:[{
required:true,
message: '请输入输入目录',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
outPath:[{
required:true,
message: '请输入输出目录',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
successPath:[{
required:true,
message: '请输入处理成功目录',
trigger: 'blur'
}],
errorPath:[{
required:true,
message: '请输入处理错误目录',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
archivePath:[{
required:true,
message: '请输入存档目录',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
uri:[{
required:true,
message: '请输入uri',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
qadProgramCode:[{
required:true,
message: '请输入qad程序编码',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
scriptPath:[{
required:true,
message: '请输入脚本路径',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
scriptName:[{
required:true,
message: '请输入程序名',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
scriptProgram:[{
required:true,
message: '请输入程序',
trigger: 'blur'
},{
max:50,
message: '字符长度不得超于50',
trigger: 'blur'
}],
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询访问控制列表 */

183
src/views/base/qadAccess/index.vue

@ -1,6 +1,12 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form
:model="queryParams"
ref="queryRef"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="公司编码" prop="companyCode">
<el-input
v-model="queryParams.companyCode"
@ -18,59 +24,66 @@
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button type="info" plain icon="Refresh" @click="resetQuery">重置</el-button>
<el-button type="primary" icon="Search" @click="handleQuery"
>搜索</el-button
>
<el-button type="info" plain icon="Refresh" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="success"
icon="Plus"
@click="handleAdd"
>新增</el-button>
<el-button type="success" icon="Plus" @click="handleAdd"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="Delete"
@click="handleDelete"
>删除</el-button>
<el-button type="success" icon="Delete" @click="handleDelete"
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="Download"
@click="handleExport"
>导出</el-button>
<el-button type="warning" icon="Download" @click="handleExport"
>导出</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
<right-toolbar
v-model:showSearch="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="qadAccessList" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="qadAccessList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="公司编码" align="center" prop="companyCode" />
<el-table-column label="公司名称" align="center" prop="companyName" />
<el-table-column label="用户" align="center" prop="userName" />
<el-table-column label="密码" align="center" prop="password" />
<el-table-column label="域" align="center" prop="domain" />
<el-table-column label="操作" width="150" align="center" class-name="small-padding fixed-width" fixed="right">
<el-table-column
label="操作"
width="150"
align="center"
class-name="small-padding fixed-width"
fixed="right"
>
<template #default="scope">
<el-button
type="text"
icon="Edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
type="text"
icon="Delete"
@click="handleDelete(scope.row)"
>删除</el-button>
<el-button type="text" icon="Edit" @click="handleUpdate(scope.row)"
>修改</el-button
>
<el-button type="text" icon="Delete" @click="handleDelete(scope.row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@ -78,16 +91,27 @@
/>
<!-- 添加或修改qad访问控制对话框 -->
<el-dialog :title="title" v-model="open" width="800px" append-to-body>
<el-form ref="qadAccessRef" :model="form" :rules="rules" label-width="120px">
<el-form
ref="qadAccessRef"
:model="form"
:rules="rules"
label-width="120px"
>
<el-row>
<el-col :span="12">
<el-form-item label="公司编码" prop="companyCode">
<el-input v-model="form.companyCode" placeholder="请输入公司编码" />
<el-input
v-model="form.companyCode"
placeholder="请输入公司编码"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="公司名称" prop="companyName">
<el-input v-model="form.companyName" placeholder="请输入公司名称" />
<el-input
v-model="form.companyName"
placeholder="请输入公司名称"
/>
</el-form-item>
</el-col>
<el-col :span="12">
@ -118,7 +142,13 @@
</template>
<script setup name="QadAccess">
import { listQadAccess, getQadAccess, delQadAccess, addQadAccess, updateQadAccess } from "@/api/base/qadAccess";
import {
listQadAccess,
getQadAccess,
delQadAccess,
addQadAccess,
updateQadAccess,
} from "@/api/base/qadAccess";
const { proxy } = getCurrentInstance();
@ -145,21 +175,56 @@ const data = reactive({
},
rules: {
companyCode: [
{ required: true, message: "公司编码不能为空", trigger: "blur" }
{ required: true,
message: "公司编码不能为空",
trigger: "blur" },
{
max: 50,
message: "字符长度不得超于50",
trigger: "blur",
},
],
companyName: [
{ required: true, message: "公司名称不能为空", trigger: "blur" }
{ required: true,
message: "公司名称不能为空",
trigger: "blur" },
{
max: 50,
message: "字符长度不得超于50",
trigger: "blur",
},
],
userName: [
{ required: true, message: "用户不能为空", trigger: "blur" }
{ required: true,
message: "用户不能为空",
trigger: "blur" },
{
max: 50,
message: "字符长度不得超于50",
trigger: "blur",
},
],
password: [
{ required: true, message: "密码不能为空", trigger: "blur" }
{ required: true,
message: "密码不能为空",
trigger: "blur" },
{
max: 50,
message: "字符长度不得超于50",
trigger: "blur",
},
],
domain: [
{ required: true, message: "域不能为空", trigger: "blur" }
{ required: true,
message: "域不能为空",
trigger: "blur" },
{
max: 50,
message: "字符长度不得超于50",
trigger: "blur",
},
],
}
},
});
const { queryParams, form, rules } = toRefs(data);
@ -167,7 +232,7 @@ const { queryParams, form, rules } = toRefs(data);
/** 查询qad访问控制列表 */
function getList() {
loading.value = true;
listQadAccess(queryParams.value).then(response => {
listQadAccess(queryParams.value).then((response) => {
qadAccessList.value = response.rows;
total.value = response.total;
loading.value = false;
@ -208,7 +273,7 @@ function resetQuery() {
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id);
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
@ -223,8 +288,8 @@ function handleAdd() {
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getQadAccess(_id).then(response => {
const _id = row.id || ids.value;
getQadAccess(_id).then((response) => {
form.value = response.data;
open.value = true;
title.value = "修改qad访问控制";
@ -233,16 +298,16 @@ function handleUpdate(row) {
/** 提交按钮 */
function submitForm() {
proxy.$refs["qadAccessRef"].validate(valid => {
proxy.$refs["qadAccessRef"].validate((valid) => {
if (valid) {
if (form.value.id != null) {
updateQadAccess(form.value).then(response => {
updateQadAccess(form.value).then((response) => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addQadAccess(form.value).then(response => {
addQadAccess(form.value).then((response) => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
@ -255,19 +320,27 @@ function submitForm() {
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value;
proxy.$modal.confirm('是否确认删除qad访问控制编号为"' + _ids + '"的数据项?').then(function() {
proxy.$modal
.confirm('是否确认删除qad访问控制编号为"' + _ids + '"的数据项?')
.then(function () {
return delQadAccess(_ids);
}).then(() => {
})
.then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
})
.catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/qadAccess/export', {
...queryParams.value
}, `qadAccess_${new Date().getTime()}.xlsx`)
proxy.download(
"system/qadAccess/export",
{
...queryParams.value,
},
`qadAccess_${new Date().getTime()}.xlsx`
);
}
getList();

56
src/views/excel/index.vue

@ -1,6 +1,12 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
<el-form
:model="queryParams"
ref="queryRef"
:inline="true"
:rules="rules"
label-width="68px"
>
<el-form-item label="订单号" prop="orderNo">
<el-input
v-model="queryParams.orderNo"
@ -10,10 +16,21 @@
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleExport('changchun')">导出长春</el-button>
<el-button type="primary" icon="Search" @click="handleExport('foshan')">导出佛山青岛</el-button>
<el-button type="primary" icon="Search" @click="handleExport('guowai')">导出国外</el-button>
<el-button type="info" plain icon="Refresh" @click="resetQuery">重置</el-button>
<el-button
type="primary"
icon="Search"
@click="handleExport('changchun')"
>导出长春</el-button
>
<el-button type="primary" icon="Search" @click="handleExport('foshan')"
>导出佛山青岛</el-button
>
<el-button type="primary" icon="Search" @click="handleExport('guowai')"
>导出国外</el-button
>
<el-button type="info" plain icon="Refresh" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
</div>
@ -31,11 +48,25 @@ const loading = ref(true);
const data = reactive({
queryParams: {
orderNo: null,
type: 'changchun'
type: "changchun",
},
rules: {
orderNo: [
{
required: true,
message: "订单号不能为空",
trigger: "blur",
},
{
max: 50,
message: "字符长度不得超于50",
trigger: "blur",
}
]
}
});
const { queryParams } = toRefs(data);
const { queryParams, rules } = toRefs(data);
/** 搜索按钮操作 */
function handleQuery() {
@ -49,14 +80,17 @@ function resetQuery() {
/** 导出按钮操作 */
function handleExport(type) {
proxy.$refs["queryRef"].validate((valid) => {
if (valid) {
loading.value = true;
queryParams.value.type = type;
exportOut(queryParams.value).then(response => {
response.data.forEach(item => {
window.open(uploadImgUrl.value + '/' + item, "_blank")
exportOut(queryParams.value).then((response) => {
response.data.forEach((item) => {
window.open(uploadImgUrl.value + "/" + item, "_blank");
});
loading.value = false;
});
}
});
}
</script>

Loading…
Cancel
Save