mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-02-03 02:54:41 +08:00
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
@{.import}
|
|
|
|
export class State {@{range .stateItems}
|
|
public @{.Name} = @{.DefaultValue}; // @{.Dc}@{end}
|
|
|
|
constructor(state?: Partial<State>) {
|
|
if (state) {
|
|
Object.assign(this, state);
|
|
}
|
|
}
|
|
}
|
|
|
|
export function newState(state: State | Record<string, any> | null): State {
|
|
if (state !== null) {
|
|
if (state instanceof State) {
|
|
return cloneDeep(state);
|
|
}
|
|
return new State(state);
|
|
}
|
|
return new State();
|
|
}
|
|
|
|
// 表单验证规则
|
|
@{ if eq .options.Step.HasRules true }@{.rules}@{end}
|
|
|
|
// 表格搜索表单
|
|
@{ if eq .options.Step.HasSearchForm true }@{.formSchema}@{end}
|
|
|
|
// 表格列
|
|
@{.columns}
|
|
|
|
@{ if eq .dictOptions.Has true }
|
|
// 字典数据选项
|
|
export const options = ref({
|
|
@{range .options.DictOps.Types} @{.}: [] as Option[],
|
|
@{end}});
|
|
|
|
// 加载字典数据选项
|
|
export function loadOptions() {
|
|
Dicts({
|
|
types: @{ToTSArray .options.DictOps.Types},
|
|
}).then((res) => {
|
|
options.value = res;
|
|
for (const item of schemas.value) {
|
|
switch (item.field) {@{range .options.DictOps.Schemas}
|
|
case '@{.Field}':
|
|
item.componentProps.options = options.value.@{.Type};
|
|
break;@{end}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
@{end}
|
|
|
|
@{ if eq .options.Step.IsTreeTable true }
|
|
// 关系树选项
|
|
export const treeOption = ref([]);
|
|
|
|
// 加载关系树选项
|
|
export function loadTreeOption() {
|
|
TreeOption().then((res) => {
|
|
treeOption.value = res;
|
|
});
|
|
}
|
|
@{end}
|
|
|