import { ElMessage } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' /** * 检查列表 * @param list 要检查的表格数据 * @param columns // 表头信息 * @param tableTitle // 表格名称 */ export function useCheckList(list: { [key: string]: string }[], columns: TableColumn, tableTitle = '') { for (let index = 0; index < list.length; index++) { const item = list[index] for (const prop of columns) { // 检查必填 if (prop.required && !item[prop.value]) { ElMessage.warning(`请先完善${tableTitle}第${index + 1}行中${prop.text}`) return false } // 验证正则 if (prop.reg && typeof prop.reg === 'function') { if (!prop.reg(item[prop.value])) { ElMessage.warning(`${tableTitle}第${index + 1}行中${prop.text}输入不合法`) return false } } } } return true }