export function initFields(response) {
  const queryFormFields = []
  const tableColFields = []
  const dialogFormFields = []
  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 (tmf_filed_search_ext === '1') {
      queryFormFields.push({
        type,
        label,
        value: k,
        item: field[k],
      })
    }
    // 作为表格内容显示
    if (display === '1') {
      tableColFields.push({
        label,
        prop: k,
      })
    }
    // 作为表单控制
    if (tmf_form_hidden === '0') {
      dialogFormFields.push({
        type,
        label,
        value: k,
        item: field[k],
      })
    }
  })

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