mirror of
				https://github.com/bufanyun/hotgo.git
				synced 2025-11-04 16:23:43 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
@{.import}
 | 
						|
 | 
						|
@{.const}
 | 
						|
 | 
						|
export class State {
 | 
						|
@{range .stateItems}
 | 
						|
  public @{.Name} = @{if and .DataType (or
 | 
						|
      (eq .DataType "varchar")
 | 
						|
      (eq .DataType "char")
 | 
						|
      (eq .DataType "text")
 | 
						|
      (eq .DataType "json")
 | 
						|
      (eq .DataType "date")
 | 
						|
      (eq .DataType "datetime")
 | 
						|
    )}'@{.DefaultValue}'@{else}@{.DefaultValue}@{end};//@{.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 function loadOptions() {
 | 
						|
  dict.loadOptions(@{ToTSArray .options.DictOps.Types});
 | 
						|
}
 | 
						|
@{end}
 | 
						|
 | 
						|
@{ if eq .options.Step.IsTreeTable true }
 | 
						|
// 关系树选项
 | 
						|
export const treeOption = ref([]);
 | 
						|
 | 
						|
// 加载关系树选项
 | 
						|
export function loadTreeOption() {
 | 
						|
  TreeOption().then((res) => {
 | 
						|
    treeOption.value = res;
 | 
						|
  });
 | 
						|
}
 | 
						|
@{end}
 | 
						|
 |