【新增】试卷任务前端

This commit is contained in:
YOHO\20373
2025-04-23 17:12:26 +08:00
committed by 陆光LG
parent cb6f4c1ea5
commit 7a89a0a822
77 changed files with 13188 additions and 1 deletions

View File

@@ -113,6 +113,11 @@ export enum DICT_TYPE {
TERMINAL = 'terminal', // 终端
DATE_INTERVAL = 'date_interval', // 数据间隔
TASK_TYPE="task_type",//试卷任务模式
SYS_STATUS="sys_common_status_other",//通用状态
EXAM_QUE_DIFF="exam_que_difficulty",//题型难度
SYS_YES_NO="sys_yes_no",
// ========== SYSTEM 模块 ==========
SYSTEM_USER_SEX = 'system_user_sex',
SYSTEM_MENU_TYPE = 'system_menu_type',

View File

@@ -0,0 +1,55 @@
import { reactive } from 'vue';
import { cloneDeep, set as setValue } from 'lodash-es';
/**
* 表单数据hook
* @param initValue 初始值
*/
export function useFormData(init) {
let initValue = init == null ? {} : cloneDeep(init);
/** 表单数据 */
const form = reactive(init == null ? {} : { ...init });
/** 重置为初始值 */
const resetFields = (field, excludes) => {
const keys = Object.keys(form);
if (typeof field === 'string' && field) {
if (keys.includes(field)) {
form[field] = cloneDeep(initValue[field]);
}
return;
}
keys.forEach((key) => {
if (!excludes || !excludes.includes(key)) {
form[key] = cloneDeep(initValue[key]);
}
});
};
/** 赋值不改变字段 */
const assignFields = (data, excludes) => {
if (excludes === true) {
initValue = data == null ? {} : cloneDeep(data);
}
Object.keys(form).forEach((key) => {
if (!excludes || excludes === true || !excludes.includes(key)) {
form[key] = data?.[key];
}
});
};
/** 赋值某字段 */
const setFieldValue = (field, value) => {
//form[field] = value;
setValue(form, field, value);
};
const result = [form, resetFields, assignFields, setFieldValue];
// 支持对象解构以兼容旧版
Object.assign(result, {
form,
resetFields,
assignFields
});
return result;
}