crud.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import * as api from './api'
  2. import {AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery} from '@fast-crud/fast-crud'
  3. import {inject} from 'vue'
  4. import {SbBaseColumn} from '/@/views/adManage/utils/commonTabColumn.js'
  5. import {parseQueryParams} from '/@/views/adManage/utils/tools.js'
  6. import XEUtils from 'xe-utils'
  7. export const createCrudOptions = function ({crudExpose, context}: CreateCrudOptionsProps): CreateCrudOptionsRet {
  8. const pageRequest = async (query: UserPageQuery) => {
  9. const params = parseQueryParams(context.value)
  10. XEUtils.assign(query, params)
  11. return await api.GetList(query)
  12. }
  13. const editRequest = async ({form, row}: EditReq) => {
  14. form.id = row.id
  15. return await api.UpdateObj(form)
  16. }
  17. const delRequest = async ({row}: DelReq) => {
  18. return await api.DelObj(row.id)
  19. }
  20. const addRequest = async ({form}: AddReq) => {
  21. return await api.AddObj(form)
  22. }
  23. //权限判定
  24. const hasPermissions = inject('$hasPermissions')
  25. return {
  26. crudOptions: {
  27. table: {
  28. height: 800,
  29. headerCellStyle: {
  30. backgroundColor: '#f6f7fa', // 直接设置背景颜色
  31. height: '20px',
  32. borderRight: 'none',
  33. },
  34. cellStyle: {
  35. border: 'none',
  36. borderBottom: '0.5px solid #ddd',
  37. },
  38. showSummary: true,
  39. stripe: false
  40. },
  41. container: {
  42. fixedHeight: false
  43. },
  44. actionbar: {
  45. show: false,
  46. buttons: {
  47. add: {
  48. show: false
  49. },
  50. }
  51. },
  52. search: {
  53. show: false
  54. },
  55. toolbar: {
  56. buttons: {
  57. search: {
  58. show: true
  59. },
  60. compact: {
  61. show: false
  62. }
  63. }
  64. },
  65. request: {
  66. pageRequest,
  67. addRequest,
  68. editRequest,
  69. delRequest,
  70. },
  71. rowHandle: {
  72. fixed: 'right',
  73. width: 100,
  74. align: 'center',
  75. buttons: {
  76. view: {
  77. show: false,
  78. },
  79. edit: {
  80. iconRight: 'Edit',
  81. type: 'text',
  82. text: null
  83. // show: hasPermissions('dictionary:Update'),
  84. },
  85. remove: {
  86. show: false
  87. // iconRight: 'Delete',
  88. // type: 'text',
  89. // text: null
  90. // show: hasPermissions('dictionary:Delete'),
  91. },
  92. },
  93. },
  94. columns: {
  95. id: {
  96. title: 'ID',
  97. column: {
  98. show: false
  99. },
  100. form: {
  101. show: false
  102. }
  103. },
  104. resolvedExpression_value:{
  105. title: '商品和分类',
  106. column: {
  107. fixed: 'left',
  108. width: 250,
  109. sortable: true
  110. },
  111. },
  112. state: {
  113. title: '状态',
  114. column: {
  115. width: '90px',
  116. align: 'center',
  117. sortable: true,
  118. },
  119. type: 'dict-select',
  120. search: {
  121. show: true
  122. },
  123. dict: dict({
  124. data: [
  125. {value: 'paused', label: '已暂停', color: 'warning'},
  126. {value: 'enabled', label: '投放中', color: 'success'},
  127. ]
  128. })
  129. },
  130. campaignName: {
  131. title: '广告活动名称',
  132. column: {
  133. width: 180,
  134. }
  135. },
  136. adGroupName: {
  137. title: '广告组名称',
  138. column: {
  139. width: 180,
  140. }
  141. },
  142. ASIN: {
  143. title: 'ASIN',
  144. column: {
  145. align: 'left',
  146. width: 130,
  147. }
  148. },
  149. suggestedBid: {
  150. title: '建议竞价',
  151. column: {
  152. width: 130,
  153. align: 'right'
  154. }
  155. },
  156. bid: {
  157. title: '出价',
  158. column: {
  159. width: 80,
  160. align: 'left',
  161. sortable: true,
  162. formatter: (row) => {
  163. return '$' + row.value
  164. }
  165. }
  166. },
  167. suggestedBid_lower: {
  168. column: {
  169. show: false,
  170. }
  171. },
  172. suggestedBid_upper: {
  173. column: {
  174. show: false,
  175. }
  176. },
  177. ...SbBaseColumn
  178. }
  179. }
  180. }
  181. }