base.js 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. define(['table'], function (Table) {
  2. return {
  3. api: {
  4. getCustomFields: function (fields, table) {
  5. var result = [];
  6. $.each(fields, function (i, j) {
  7. if (j.type === 'editor') {
  8. return true;
  9. }
  10. var param = {field: j.field, title: j.title, table: table, operate: (j.type === 'number' ? '=' : 'like'), formatter: Table.api.formatter.content, class: 'autocontent'};
  11. //如果是图片,加上formatter
  12. if (j.type === 'image' || j.type === 'images') {
  13. param.events = Table.api.events.image;
  14. param.formatter = Table.api.formatter.images;
  15. } else if (j.type === 'file' || j.type === 'files') {
  16. param.formatter = Table.api.formatter.files;
  17. } else if (j.type === 'radio' || j.type === 'checkbox' || j.type === 'select' || j.type === 'selects') {
  18. param.formatter = Table.api.formatter.label;
  19. param.extend = j.content;
  20. param.searchList = j.content;
  21. } else {
  22. param.formatter = Table.api.formatter.content;
  23. param.classname = 'autocontent';
  24. }
  25. result.push(param);
  26. });
  27. return result;
  28. }
  29. }
  30. }
  31. });