修正ts类型

This commit is contained in:
Zy
2026-05-13 15:28:25 +08:00
parent 1b738c0f4d
commit a1750bc67b
114 changed files with 2346 additions and 613 deletions

View File

@@ -3,7 +3,7 @@
<transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
<span v-if="item.redirect === 'noRedirect' || index == levelList.length - 1" class="no-redirect">{{ item.meta?.title }}</span>
<a v-else @click.prevent="handleLink(item)">{{ item.meta?.title }}</a>
<span class="no-redirect" v-else>{{ item.meta?.title }}</span>
</el-breadcrumb-item>
</transition-group>
</el-breadcrumb>

View File

@@ -221,7 +221,7 @@ function resetQuery() {
queryParams.value = {
pageNum: 1,
pageSize: 10,
houseuse: null,
buildingUse: null,
buildingId: null,
unitNo: null
};

View File

@@ -81,10 +81,7 @@ const dialog = ref({
const queryParams = ref({
pageNum: 1,
pageSize: 10,
buildingUse: null,
buildingId: null,
unitNo: null
pageSize: 10
});
const multipleTableRef = ref();
@@ -198,10 +195,7 @@ function handleRowClick(row: BillHouse) {
function resetQuery() {
queryParams.value = {
pageNum: 1,
pageSize: 10,
houseuse: null,
buildingId: null,
unitNo: null
pageSize: 10
};
getlist();
}

View File

@@ -0,0 +1,288 @@
<template>
<div class="license-plate-input">
<div class="plate_line">
<div
v-for="(item, index) in chars"
:key="index"
class="plate-item"
:class="{
active: activeIndex === index,
disabled: disabled,
error: hasError
}"
>
<input
ref="inputRefs"
v-model="chars[index]"
type="text"
maxlength="1"
:disabled="disabled"
@input="onInput(index)"
@keydown="onKeydown($event, index)"
@paste="onPaste"
@focus="activeIndex = index"
@blur="onBlur"
/>
</div>
</div>
<!-- 错误提示 Element Plus 原生完全一致 -->
<div v-if="errorMessage" class="plate-error">{{ errorMessage }}</div>
</div>
</template>
<script setup lang="ts">
import { LicensePlateValidator } from '@/utils/Reg';
import { ref, watch, nextTick } from 'vue';
const PROVINCES = [
'京',
'津',
'沪',
'渝',
'冀',
'豫',
'云',
'辽',
'黑',
'湘',
'皖',
'鲁',
'新',
'苏',
'浙',
'赣',
'鄂',
'桂',
'甘',
'晋',
'蒙',
'陕',
'吉',
'闽',
'贵',
'粤',
'青',
'藏',
'川',
'宁',
'琼'
];
const VALID_CHARS = /^[A-HJ-NP-Z0-9]$/i;
const props = defineProps<{
modelValue: string;
disabled?: boolean;
required?: boolean;
}>();
const emit = defineEmits<{
'update:modelValue': [value: string];
'change': [value: string];
}>();
const inputRefs = ref<HTMLInputElement[]>([]);
const activeIndex = ref(-1);
const chars = ref<string[]>(Array(8).fill(''));
const hasError = ref(false);
const errorMessage = ref('');
// 外部值同步
watch(
() => props.modelValue,
(val) => {
const currentValue = chars.value.join('').trim();
if (val !== currentValue) {
const newChars = Array(8).fill('');
if (val) {
val
.toUpperCase()
.split('')
.forEach((c, i) => {
if (i < 8) newChars[i] = c;
});
}
chars.value = newChars;
}
},
{ immediate: true }
);
// 内部值同步到外部
watch(
chars,
() => {
const value = chars.value.join('').trim();
emit('update:modelValue', value);
emit('change', value);
// 输入时清除错误
clearError();
},
{ deep: true }
);
function onInput(index: number) {
const char = chars.value[index].toUpperCase();
if (index === 0 && !PROVINCES.includes(char)) {
chars.value[index] = '';
return;
}
if (index > 0 && !VALID_CHARS.test(char)) {
chars.value[index] = '';
return;
}
chars.value[index] = char;
if (char && index < 7) {
nextTick(() => inputRefs.value[index + 1]?.focus());
}
}
function onKeydown(e: KeyboardEvent, index: number) {
if (e.key === 'Backspace' && !chars.value[index] && index > 0) {
e.preventDefault();
nextTick(() => {
inputRefs.value[index - 1]?.focus();
inputRefs.value[index - 1]?.select();
});
}
if (e.key === 'ArrowLeft' && index > 0) {
e.preventDefault();
inputRefs.value[index - 1]?.focus();
}
if (e.key === 'ArrowRight' && index < 7) {
e.preventDefault();
inputRefs.value[index + 1]?.focus();
}
}
function onPaste(e: ClipboardEvent) {
e.preventDefault();
const text = e.clipboardData?.getData('text')?.trim().toUpperCase() || '';
if (!text) return;
const newChars = Array(8).fill('');
text.split('').forEach((c, i) => {
if (i >= 8) return;
if (i === 0 && PROVINCES.includes(c)) newChars[i] = c;
if (i > 0 && VALID_CHARS.test(c)) newChars[i] = c;
});
chars.value = newChars;
const lastIndex = Math.min(text.length - 1, 6);
nextTick(() => inputRefs.value[lastIndex + 1]?.focus());
}
function onBlur() {
setTimeout(() => {
const hasFocus = inputRefs.value.some((input) => document.activeElement === input);
if (!hasFocus) {
activeIndex.value = -1;
}
}, 10);
}
// ✅ 手动验证方法(核心)
function validate(): { valid: boolean; message?: string } {
const value = chars.value.join('').trim();
// 必填验证
if (props.required && !value) {
hasError.value = true;
errorMessage.value = '请输入车牌号';
return { valid: false, message: errorMessage.value };
}
// 格式验证
if (value && !isValidPlate(value)) {
hasError.value = true;
errorMessage.value = '请输入正确的车牌号格式';
return { valid: false, message: errorMessage.value };
}
// 验证通过
clearError();
return { valid: true };
}
// 车牌格式验证(内置,不依赖外部工具)
function isValidPlate(plate: string): boolean {
return LicensePlateValidator.isValidPlate(plate);
}
// 清除错误
function clearError() {
hasError.value = false;
errorMessage.value = '';
}
// 暴露方法
defineExpose({
focus: () => nextTick(() => inputRefs.value[0]?.focus()),
clear: () => {
chars.value = Array(8).fill('');
},
validate,
clearError
});
</script>
<style scoped>
.license-plate-input {
display: flex;
flex-direction: column;
gap: 4px;
}
.plate_line {
display: flex;
align-items: center;
gap: 6px;
}
.plate-item {
width: 24px;
height: 24px;
line-height: 24px;
border: 1px solid #dcdfe6;
border-radius: 4px;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.plate-item.active {
border-color: #409eff;
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}
.plate-item.error {
border-color: #f56c6c;
}
.plate-item.disabled {
background-color: #f5f7fa;
cursor: not-allowed;
}
.plate-item input {
width: 100%;
height: 100%;
border: none;
text-align: center;
font-size: 15px;
font-weight: 500;
background: transparent;
outline: none;
}
.plate-error {
color: #f56c6c;
font-size: 12px;
line-height: 1.5;
margin-top: 2px;
}
</style>

View File

@@ -52,7 +52,7 @@
<script setup lang="ts">
import { propTypes } from '@/utils/propTypes';
import { FlowTaskVO, TaskOperationBo } from '@/api/workflow/task/types';
import UserSelect from '@/components/UserSelect';
import UserSelect from '@/components/UserSelect/index.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { getTask, taskOperation, currentTaskAllUser, terminationTask } from '@/api/workflow/task';
const props = defineProps({
@@ -91,7 +91,9 @@ const task = ref<FlowTaskVO>({
nodeRatio: undefined,
version: undefined,
applyNode: undefined,
buttonList: []
buttonList: [],
businessCode: '',
businessTitle: ''
});
const open = (taskId: string) => {

View File

@@ -152,7 +152,7 @@ import {
currentTaskAllUser,
getNextNodeList
} from '@/api/workflow/task';
import UserSelect from '@/components/UserSelect';
import UserSelect from '@/components/UserSelect.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { FlowCopyVo, FlowTaskVO, TaskOperationBo } from '@/api/workflow/task/types';