export function BaseFormMixin() {
  return {
    data() {
      return {
        form: {
          value: null,
          // onSubmit: (values) => {
          //   console.log('表单提交', values);
          // },
          onInput: val => {
            this.form.value = val
          },
        },
      }
    },
    methods: {
      /**
       * @description: 设置表单字段值
       * @param {*} formSchemas 表单字段
       * @param {*} formData 表单数据
       */
      setFieldsValue(formSchemas, formData) {
        this[formSchemas] = this[formSchemas].map((item) => ({
          ...item,
          value: typeof formData === 'object'
            ? formData[item.prop] || item.value
            : this[formData]?.[item.prop] || item.value,
        }))
      },
    },
  }
}

