export function initFields(response) {
  const queryFormFields = []
  const tableColFields = []
  const dialogFormFields = []
  // console.log('response :>> ', response)
  const {
    data: {
      table_structure: { table_key, field },
    },
  } = response
  const tableKey = table_key
  Object.keys(field).forEach((k) => {
    const {
      type,
      label,
      field_type,
      tmf_filed_search_ext,
      display,
      tmf_form_hidden,
    } = field[k]
    // 作为过滤条件
    if (true) {
      queryFormFields.push({
        type: ['radio', 'checkbox'].includes(type) ? 'select' : type,
        label,
        value: k,
        option: field[k].option ?? [],
      })
    }
    // 作为表格内容显示
    if (true) {
      tableColFields.push({
        label,
        prop: k,
        option: field[k].option ?? [],
      })
    }
    // 作为表单控制
    if (true) {
      dialogFormFields.push({
        type: ['radio', 'checkbox'].includes(type) && field[k].option.length > 3 ? 'select' : type,
        label,
        value: k,
        option: field[k].option ?? [],
      })
    }
  })

  return {
    tableKey,
    queryFormFields,
    tableColFields,
    dialogFormFields,
  }
}
