修改发票管理页面
This commit is contained in:
@@ -441,26 +441,6 @@ export default {
|
||||
const user = this.userList.find(u => String(u.employeeId) === String(employeeId));
|
||||
return user ? user.name : '';
|
||||
},
|
||||
|
||||
// 检查是否有权限修改指定记录
|
||||
canModifyRecord(record) {
|
||||
// 管理员可以修改所有记录,普通用户只能修改自己的
|
||||
return this.isAdmin || record.employeeId === this.currentUser.employeeId;
|
||||
},
|
||||
|
||||
// 检查权限并执行操作
|
||||
checkPermissionAndExecute(record, operation) {
|
||||
if (this.canModifyRecord(record)) {
|
||||
operation();
|
||||
} else {
|
||||
alert('您没有权限修改此记录!');
|
||||
}
|
||||
},
|
||||
|
||||
// 更新员工ID
|
||||
updateEmployeeId(item, employeeId) {
|
||||
item.employeeId = employeeId;
|
||||
},
|
||||
|
||||
addNewRow() {
|
||||
// 新增行时自动填充当前用户信息
|
||||
@@ -937,6 +917,21 @@ export default {
|
||||
},
|
||||
|
||||
// 检查号码范围是否与其他记录重叠
|
||||
// 提取数字部分进行比较的辅助方法
|
||||
extractNumber(str) {
|
||||
if (!str) return 0;
|
||||
const match = str.match(/\d+$/);
|
||||
return match ? parseInt(match[0], 10) : 0;
|
||||
},
|
||||
|
||||
// 提取完整前缀的辅助方法(包括字母和数字)
|
||||
extractPrefix(str) {
|
||||
if (!str) return '';
|
||||
// 匹配开头的所有非数字字符(字母等)和随后的数字部分,直到遇到第一个非数字字符为止
|
||||
const match = str.match(/^[A-Za-z0-9]+/);
|
||||
return match ? match[0] : '';
|
||||
},
|
||||
|
||||
checkRangeOverlap(record) {
|
||||
// 确保当前记录有必要的数据
|
||||
if (!record || !record.startNum || !record.endNum) {
|
||||
@@ -947,25 +942,10 @@ export default {
|
||||
// 使用keyId作为比较依据,因为它是前端唯一标识符
|
||||
const otherRecords = this.invoiceData.filter(item => item.keyId !== record.keyId);
|
||||
|
||||
// 提取数字部分进行比较的辅助函数
|
||||
const extractNumber = function(str) {
|
||||
if (!str) return 0;
|
||||
const match = str.match(/\d+$/);
|
||||
return match ? parseInt(match[0], 10) : 0;
|
||||
};
|
||||
|
||||
// 提取完整前缀的辅助函数(包括字母和数字)
|
||||
const extractPrefix = function(str) {
|
||||
if (!str) return '';
|
||||
// 匹配开头的所有非数字字符(字母等)和随后的数字部分,直到遇到第一个非数字字符为止
|
||||
const match = str.match(/^[A-Za-z0-9]+/);
|
||||
return match ? match[0] : '';
|
||||
};
|
||||
|
||||
// 提取当前记录的前缀和数字范围
|
||||
const currentPrefix = extractPrefix(record.startNum);
|
||||
const currentStartNum = extractNumber(record.startNum);
|
||||
const currentEndNum = extractNumber(record.endNum);
|
||||
const currentPrefix = this.extractPrefix(record.startNum);
|
||||
const currentStartNum = this.extractNumber(record.startNum);
|
||||
const currentEndNum = this.extractNumber(record.endNum);
|
||||
|
||||
// 确保当前记录的起始号码小于等于终止号码
|
||||
if (currentStartNum > currentEndNum) {
|
||||
@@ -976,14 +956,14 @@ export default {
|
||||
if (!item.startNum || !item.endNum) continue;
|
||||
|
||||
// 提取其他记录的前缀
|
||||
const otherPrefix = extractPrefix(item.startNum);
|
||||
const otherPrefix = this.extractPrefix(item.startNum);
|
||||
|
||||
// 检查前缀是否匹配(实现数字对应数字,字母对应字母的匹配规则)
|
||||
if (currentPrefix !== otherPrefix) continue;
|
||||
|
||||
// 提取其他记录的数字范围
|
||||
const otherStartNum = extractNumber(item.startNum);
|
||||
const otherEndNum = extractNumber(item.endNum);
|
||||
const otherStartNum = this.extractNumber(item.startNum);
|
||||
const otherEndNum = this.extractNumber(item.endNum);
|
||||
|
||||
// 全面检查范围重叠
|
||||
const hasOverlap =
|
||||
@@ -1009,12 +989,6 @@ export default {
|
||||
// 如果当前号码为空,允许保存
|
||||
if (!currentNum) return true;
|
||||
|
||||
// 数字部分比较(纯数字或字母前缀+数字)
|
||||
const extractNumber = (str) => {
|
||||
const match = str.match(/\d+$/);
|
||||
return match ? parseInt(match[0], 10) : 0;
|
||||
};
|
||||
|
||||
// 检查两个字符串的每一位是否类型匹配(数字对应数字,字母对应字母)
|
||||
const checkCharacterTypesMatch = (str1, str2) => {
|
||||
const maxLength = Math.max(str1.length, str2.length);
|
||||
@@ -1036,9 +1010,9 @@ export default {
|
||||
return false;
|
||||
}
|
||||
|
||||
const currentNumValue = extractNumber(currentNum);
|
||||
const startNumValue = extractNumber(startNum);
|
||||
const endNumValue = extractNumber(endNum);
|
||||
const currentNumValue = this.extractNumber(currentNum);
|
||||
const startNumValue = this.extractNumber(startNum);
|
||||
const endNumValue = this.extractNumber(endNum);
|
||||
|
||||
return currentNumValue >= startNumValue && currentNumValue <= endNumValue;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user