import { FormItem, FormConfig } from '@/components/form-render/form-render-types'
import { TreeDataNode } from 'ant-design-vue/es/vc-tree-select/interface'

export const config: FormConfig = {
	layout: 'horizontal',
	colon: true,
	hideRequiredMark: false,
	labelAlign: 'right',
	scrollToFirstError: false,
	validateOnRuleChange: true,
	labelCol: {
		span: 4,
		offset: 0,
	},
}

export const formItems = (types: TreeDataNode[]): FormItem[] => [
	{
		group: 'form',
		type: 'input',
		config: {
			autoLink: true,
			hasFeedback: false,
			label: '物料名称',
			name: 'name',
			required: true,
		},
		properties: {
			size: 'default',
			type: 'text',
			allowClear: false,
			bordered: true,
			showCount: false,
			placeholder: '请输入物料名称',
		},
		rules: [],
	},

	{
		type: 'tree-select',
		group: 'form',
		config: {
			autoLink: true,
			hasFeedback: false,
			label: '物料类型',
			name: 'type',
			required: true,
			extra: '',
			help: '',
			htmlFor: 'sgsg',
		},
		properties: {
			size: 'default',
			treeData: types,
			placeholder: '请选择物料类型',
		},
		rules: [],
	},
	{
		type: 'input',
		group: 'form',
		config: {
			autoLink: true,
			hasFeedback: false,
			label: '物料型号',
			name: 'spec',
			required: true,
		},
		properties: {
			size: 'default',
			controls: true,
			placeholder: '请填写物料型号',
		},
		rules: [],
	},
	{
		type: 'input-number',
		group: 'form',
		config: {
			autoLink: true,
			hasFeedback: false,
			label: '价格',
			name: 'price',
			required: true,
		},
		properties: {
			size: 'default',
			controls: true,
			placeholder: '请填写价格',
		},
		rules: [],
	},

	{
		type: 'switch',
		group: 'form',
		config: {
			autoLink: true,
			hasFeedback: false,
			label: '是否赋码',
			name: 'assignRule',
			required: true,
		},
		properties: {
			size: 'default',
		},
		rules: [],
	},
	{
		type: 'input',
		group: 'form',
		config: {
			autoLink: true,
			hasFeedback: false,
			label: '备注',
			name: 'description',
			required: false,
		},
		properties: {
			size: 'default',
			controls: true,
			placeholder: '',
		},
		rules: [],
	},
]
