field.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. export function initFields(response) {
  2. const queryFormFields = []
  3. const tableColFields = []
  4. const dialogFormFields = []
  5. // console.log('response :>> ', response)
  6. const {
  7. data: {
  8. table_structure: { table_key, field },
  9. },
  10. } = response
  11. const tableKey = table_key
  12. Object.keys(field).forEach((k) => {
  13. const {
  14. type,
  15. label,
  16. field_type,
  17. tmf_filed_search_ext,
  18. display,
  19. tmf_form_hidden,
  20. } = field[k]
  21. // 作为过滤条件
  22. if (true) {
  23. queryFormFields.push({
  24. type: ['radio', 'checkbox'].includes(type) ? 'select' : type,
  25. label,
  26. value: k,
  27. option: field[k].option ?? [],
  28. })
  29. }
  30. // 作为表格内容显示
  31. if (true) {
  32. tableColFields.push({
  33. label,
  34. prop: k,
  35. option: field[k].option ?? [],
  36. })
  37. }
  38. // 作为表单控制
  39. if (true) {
  40. dialogFormFields.push({
  41. type: ['radio', 'checkbox'].includes(type) && field[k].option.length > 3 ? 'select' : type,
  42. label,
  43. value: k,
  44. option: field[k].option ?? [],
  45. })
  46. }
  47. })
  48. return {
  49. tableKey,
  50. queryFormFields,
  51. tableColFields,
  52. dialogFormFields,
  53. }
  54. }