crud.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import * as api from './api'
  2. import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud'
  3. import { inject, nextTick, ref } from 'vue'
  4. import { BaseColumn } from '/@/views/adManage/utils/commonTabColumn.js'
  5. export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  6. const pageRequest = async (query: UserPageQuery) => {
  7. return await api.GetList(query);
  8. };
  9. const editRequest = async ({ form, row }: EditReq) => {
  10. form.id = row.id;
  11. return await api.UpdateObj(form);
  12. };
  13. const delRequest = async ({ row }: DelReq) => {
  14. return await api.DelObj(row.id);
  15. };
  16. const addRequest = async ({ form }: AddReq) => {
  17. return await api.AddObj(form);
  18. };
  19. //权限判定
  20. const hasPermissions = inject('$hasPermissions');
  21. return {
  22. crudOptions: {
  23. table: {
  24. height: 600
  25. },
  26. container: {
  27. fixedHeight: false
  28. },
  29. actionbar: {
  30. show: true,
  31. buttons: {
  32. add: {
  33. show: false
  34. }
  35. }
  36. },
  37. search: {
  38. show: false
  39. },
  40. toolbar: {
  41. buttons: {
  42. search: {
  43. show: true
  44. },
  45. compact: {
  46. show: false
  47. }
  48. }
  49. },
  50. request: {
  51. pageRequest,
  52. addRequest,
  53. editRequest,
  54. delRequest,
  55. },
  56. rowHandle: {
  57. fixed: 'right',
  58. width: 80,
  59. buttons: {
  60. view: {
  61. show: false,
  62. },
  63. edit: {
  64. iconRight: 'Edit',
  65. type: 'text',
  66. text: null
  67. // show: hasPermissions('dictionary:Update'),
  68. },
  69. remove: {
  70. iconRight: 'Delete',
  71. type: 'text',
  72. text: null
  73. // show: hasPermissions('dictionary:Delete'),
  74. },
  75. },
  76. },
  77. columns: {
  78. keywordText: {
  79. title: '关键词'
  80. },
  81. matchType: {
  82. title: '匹配类型',
  83. type: 'dict-select',
  84. search: {
  85. show: true
  86. },
  87. dict: dict({
  88. data: [
  89. { value: 'BROAD', label: '广泛匹配' },
  90. { value: 'PHRASE', label: '词组匹配' },
  91. { value: 'EXACT', label: '精准匹配' },
  92. ]
  93. })
  94. },
  95. state: {
  96. title: '状态'
  97. },
  98. bid: {
  99. title: '出价'
  100. },
  101. "campaign": {
  102. title: '广告活动'
  103. },
  104. "adGroup": {
  105. title: '广告组'
  106. }
  107. }
  108. }
  109. }
  110. }