fix(公共): 编译报错
This commit is contained in:
parent
aa81334f3f
commit
b4915df347
|
@ -16,7 +16,7 @@
|
|||
|
||||
import type { FormItem } from './types';
|
||||
import { FormRuleItem } from './types';
|
||||
import formCreate from '@form-create/arco-design';
|
||||
import formCreate, { Rule } from '@form-create/arco-design';
|
||||
|
||||
const formCreateStore = useFormCreateStore();
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
formCreateKey: FormCreateKeyEnum[keyof FormCreateKeyEnum]; // 唯一表单Key
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['update:form-rule']);
|
||||
// const emit = defineEmits(['update:form-rule']);
|
||||
|
||||
const formApi = ref<any>({});
|
||||
|
||||
|
@ -59,25 +59,27 @@
|
|||
// 获取当前列表里边所有包含cascade的item
|
||||
if (currentFormCreateRules) {
|
||||
const cascade = currentFormCreateRules
|
||||
.map((item: FormRuleItem) => item.link)
|
||||
.filter((item) => item)
|
||||
.map((item: Record<string, any>) => item.link)
|
||||
.filter((item: Record<string, any>) => item)
|
||||
.flatMap((flatItem: any) => flatItem);
|
||||
// 给所有的link上边关联的某个item 进行绑定监视
|
||||
return currentFormCreateRules.filter((item: FormRuleItem) => {
|
||||
return currentFormCreateRules.filter((item: Record<string, any>) => {
|
||||
return cascade.indexOf(item.field) > -1;
|
||||
});
|
||||
}
|
||||
});
|
||||
// 计算远程检索的表单项
|
||||
const getOptionsRequest = debounce((val: FormRuleItem) => {
|
||||
const getOptionsRequest = debounce((val: any) => {
|
||||
// 获取当前变化的一项 监视到被级联的表单项
|
||||
// 从所有的列表项里边获取所有的link到的那一项
|
||||
const totalFormList = formCreateStore.formCreateRuleMap.get(props.formCreateKey);
|
||||
if (totalFormList) {
|
||||
const resultItem = totalFormList.find(
|
||||
(item) => item.link && (item.link as string[]).indexOf(val.field as string) > -1
|
||||
(item: Record<string, any>) => item.link && (item.link as string[]).indexOf(val.field as string) > -1
|
||||
);
|
||||
if (resultItem) formCreateStore.getOptions(val, props.formCreateKey, resultItem, formApi.value);
|
||||
if (resultItem) {
|
||||
formCreateStore.getOptions(val, props.formCreateKey, resultItem as Rule, formApi.value);
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
|
||||
|
@ -86,7 +88,7 @@
|
|||
(val) => {
|
||||
// 监视当前改变请求获取当前方法下边的options 和获取多有的字段值
|
||||
if (val) {
|
||||
val.forEach(async (item) => {
|
||||
val.forEach(async (item: any) => {
|
||||
if (item.value) {
|
||||
await getOptionsRequest(item);
|
||||
}
|
||||
|
@ -100,7 +102,7 @@
|
|||
const formRules = ref<FormItem[]>([]);
|
||||
watch(
|
||||
() => props.formRule,
|
||||
(val) => {
|
||||
() => {
|
||||
formRules.value = props.formRule;
|
||||
formCreateStore.setInitFormCreate(props.formCreateKey, props.formRule);
|
||||
formCreateStore.initFormCreateFormRules(props.formCreateKey);
|
||||
|
@ -115,7 +117,7 @@
|
|||
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
() => {
|
||||
formRuleList.value = formCreateStore.formCreateRuleMap.get(props.formCreateKey) as FormRuleItem[];
|
||||
}
|
||||
);
|
||||
|
@ -125,7 +127,7 @@
|
|||
() => {
|
||||
// 处理数据格式更新
|
||||
const result = formRuleList.value.map((item: any) => {
|
||||
const type = props.formRule.find((it) => it.name === item.field)?.type;
|
||||
const type = props.formRule.find((it: any) => it.name === item.field)?.type;
|
||||
const formItemRule = {
|
||||
name: item.field,
|
||||
type,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { FieldRule } from '@arco-design/web-vue';
|
||||
|
||||
import { FormRule } from '@form-create/arco-design';
|
||||
import { Rule } from '@form-create/arco-design';
|
||||
|
||||
export type FormItemType =
|
||||
| 'INPUT'
|
||||
|
@ -30,9 +30,10 @@ export interface FormItemDefaultOptions {
|
|||
text: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export type FormRuleItem = FormRule & {
|
||||
// 内置formCreateRule所有配置的项
|
||||
export type FormRuleItem = Rule & {
|
||||
props: Record<string, any>;
|
||||
[key: string]: any;
|
||||
};
|
||||
// 表单配置项
|
||||
export interface FormItem {
|
||||
|
|
|
@ -7,8 +7,9 @@ import { useI18n } from '@/hooks/useI18n';
|
|||
|
||||
import { FormCreateKeyEnum } from '@/enums/formCreateEnum';
|
||||
|
||||
const { t } = useI18n();
|
||||
import type { Rule } from '@form-create/arco-design';
|
||||
|
||||
const { t } = useI18n();
|
||||
const useFormCreateStore = defineStore('form-create', {
|
||||
persist: false,
|
||||
state: (): {
|
||||
|
@ -104,17 +105,19 @@ const useFormCreateStore = defineStore('form-create', {
|
|||
async getOptions(
|
||||
val: FormRuleItem,
|
||||
key: FormCreateKeyEnum[keyof FormCreateKeyEnum],
|
||||
cascadeItem: FormRuleItem,
|
||||
cascadeItem: Rule,
|
||||
formValueApi: any
|
||||
) {
|
||||
const formValue = formValueApi.formData();
|
||||
// 设置自定义属性给到searchSelect
|
||||
const formCreateRuleArr = this.formCreateRuleMap.get(key);
|
||||
const formCreateItem = formCreateRuleArr?.find((items: FormRuleItem) => cascadeItem.field === items.field);
|
||||
if (formCreateItem) {
|
||||
const formCreateRuleArr = this.formCreateRuleMap.get(key) as Rule[];
|
||||
if (formCreateRuleArr) {
|
||||
const formCreateItem = formCreateRuleArr.find((item: Rule) => cascadeItem.field === item.field);
|
||||
if (formCreateItem && formCreateItem.props) {
|
||||
formCreateItem.props.keyword = val.value;
|
||||
formCreateItem.props.formValue = formValue;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
getters: {},
|
||||
|
|
Loading…
Reference in New Issue