accTencentAd.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <script setup lang="ts">
  2. import { EleBtnType } from '@/types/Button/buttonType'
  3. import type {
  4. OperationItem,
  5. Operations,
  6. } from '@/types/Tables/Operations/operations'
  7. import type {
  8. FilterInfo,
  9. TableInfoItem,
  10. BaseFieldItem,
  11. } from '@/types/Tables/table'
  12. import type { TablePaginationProps } from '@/types/Tables/pagination'
  13. import type { BaseMenu } from '@/types/Promotion/Menu'
  14. import type {
  15. AdvertiserData,
  16. BusinessManagerData,
  17. AgencyData,
  18. } from '@/types/Tables/tableData/tencentAcc'
  19. import type {
  20. AdvertiserFields,
  21. BusinessManagerFields,
  22. AgencyFields,
  23. } from '@/types/Tables/tableData/tencentAcc'
  24. import type {
  25. BaseTableInfo,
  26. BaseAllFieldsInfo,
  27. BaseAllFilterInfo,
  28. BaseAllFixedFiledsInfo,
  29. } from '@/types/Tables/tablePageData'
  30. import type { MenuTableReq } from '@/types/Tables/MenuTable/menuTableReq'
  31. import { TableFilterType } from '@/types/Tables/table'
  32. import { useRequest } from '@/hooks/useRequest'
  33. import { reactive } from 'vue'
  34. import MenuTable from '@/components/promotion/MenuTable.vue'
  35. // 表格信息
  36. interface TableInfo extends BaseTableInfo {
  37. advertiserTable: TableInfoItem<
  38. AdvertiserData,
  39. BaseFieldItem<AdvertiserFields>
  40. > // 广告主信息
  41. businessManagerTable: TableInfoItem<
  42. BusinessManagerData,
  43. BaseFieldItem<BusinessManagerFields>
  44. > // 业务经理信息
  45. agencyTable: TableInfoItem<AgencyData, BaseFieldItem<AgencyFields>> // 代理商信息
  46. }
  47. // 所有字段信息
  48. interface AllFieldsInfo extends BaseAllFieldsInfo {
  49. advertiserTable: AdvertiserFields[]
  50. businessManagerTable: BusinessManagerFields[]
  51. agencyTable: AgencyFields[]
  52. }
  53. // 上方查询表单字段
  54. interface AllFilterInfo extends BaseAllFilterInfo {
  55. advertiserTable: FilterInfo
  56. businessManagerTable: FilterInfo
  57. agencyTable: FilterInfo
  58. }
  59. // 固定字段
  60. interface AllFixedFiledsInfo extends BaseAllFixedFiledsInfo {
  61. advertiserTable: Array<string>
  62. businessManagerTable: Array<string>
  63. agencyTable: Array<string>
  64. }
  65. // 操作信息
  66. interface Operation extends Operations {
  67. advertiserTable: OperationItem[]
  68. businessManagerTable: OperationItem[]
  69. agencyTable: OperationItem[]
  70. }
  71. const { AllApi } = useRequest()
  72. // 所有子字段信息
  73. const AllFields: AllFieldsInfo = {
  74. advertiserTable: [
  75. { label: '账户余额', name: 'accountBalance', state: true, fixed: false },
  76. ],
  77. businessManagerTable: [
  78. { label: '项目', name: 'accountBalance', state: true, fixed: false },
  79. ],
  80. agencyTable: [
  81. { label: '代理', name: 'accountBalance', state: true, fixed: false },
  82. ],
  83. }
  84. // 广告主查询表单信息
  85. const advertiserFilterInfo: FilterInfo = {
  86. accMain: {
  87. label: '账号主体',
  88. name: 'accMain',
  89. type: TableFilterType.Select,
  90. value: 'all',
  91. options: [
  92. { label: '全部', value: 'all' },
  93. { label: '主体1', value: '1' },
  94. { label: '主体2', value: '2' },
  95. ],
  96. },
  97. }
  98. // 业务经理查询表单信息
  99. const businessManagerFilterInfo: FilterInfo = {
  100. search: {
  101. label: '搜索',
  102. name: 'search',
  103. type: TableFilterType.Search,
  104. value: 'name',
  105. options: [{ label: '名称', value: 'name' }],
  106. },
  107. }
  108. // 代理商查询表单信息
  109. const agencyFilterInfo: FilterInfo = {
  110. agencyProject: {
  111. label: '代理项目',
  112. name: 'agencyProject',
  113. type: TableFilterType.Select,
  114. value: 'name',
  115. options: [{ label: '名称', value: 'name' }],
  116. },
  117. }
  118. // 所有的查询表单信息
  119. const allFilters: AllFilterInfo = {
  120. advertiserTable: advertiserFilterInfo,
  121. businessManagerTable: businessManagerFilterInfo,
  122. agencyTable: agencyFilterInfo,
  123. }
  124. // 所有需要固定的字段
  125. const allFixedFileds: AllFixedFiledsInfo = {
  126. advertiserTable: ['accountName', 'action'],
  127. businessManagerTable: [],
  128. agencyTable: [],
  129. }
  130. // 所有的表格请求
  131. const tableReqInfo: MenuTableReq = {
  132. advertiserTable: {
  133. url: AllApi.mockAdTTAcc,
  134. config: {
  135. params: {},
  136. },
  137. },
  138. businessManagerTable: {
  139. url: AllApi.mockAdTTAcc,
  140. config: {
  141. params: {},
  142. },
  143. },
  144. agencyTable: {
  145. url: AllApi.mockAdTTAcc,
  146. config: {
  147. params: {},
  148. },
  149. },
  150. }
  151. // 所有表格需要排除的字段信息
  152. const allExcludeFields: {
  153. [key: string]: string[]
  154. } = {
  155. advertiserTable: ['accountBalance'],
  156. businessManagerTable: [],
  157. agencyTable: [],
  158. }
  159. // 表格信息
  160. const tableInfo = reactive<TableInfo>({
  161. advertiserTable: {
  162. data: [],
  163. fields: [
  164. {
  165. label: '基础',
  166. name: 'base1',
  167. value: [],
  168. children: AllFields['advertiserTable'],
  169. },
  170. ],
  171. tableSortedFields: [],
  172. filters: allFilters['advertiserTable'],
  173. fixedFields: allFixedFileds['advertiserTable'],
  174. },
  175. businessManagerTable: {
  176. data: [],
  177. fields: [
  178. {
  179. label: '基础',
  180. name: 'base2',
  181. value: [],
  182. children: AllFields['businessManagerTable'],
  183. },
  184. ],
  185. tableSortedFields: [],
  186. filters: allFilters['businessManagerTable'],
  187. fixedFields: allFixedFileds['businessManagerTable'],
  188. },
  189. agencyTable: {
  190. data: [],
  191. fields: [
  192. {
  193. label: '基础',
  194. name: 'base3',
  195. value: [],
  196. children: AllFields['agencyTable'],
  197. },
  198. ],
  199. tableSortedFields: [],
  200. filters: allFilters['agencyTable'],
  201. fixedFields: allFixedFileds['agencyTable'],
  202. },
  203. })
  204. // 自定义的操作字段
  205. const operations: Operation = {
  206. advertiserTable: [
  207. {
  208. label: '修改',
  209. type: EleBtnType.Primary,
  210. },
  211. {
  212. label: '删除',
  213. type: EleBtnType.Danger,
  214. },
  215. ],
  216. businessManagerTable: [],
  217. agencyTable: [],
  218. }
  219. // 导航
  220. const menuList: BaseMenu[] = [
  221. {
  222. name: 'advertiserTable',
  223. title: '广告主',
  224. },
  225. {
  226. name: 'businessManagerTable',
  227. title: '商务管家或业务单元',
  228. },
  229. {
  230. name: 'agencyTable',
  231. title: '代理商',
  232. },
  233. ]
  234. // 表格名
  235. const saveTableName = 'tencentAcc-tableInfo'
  236. // 分页配置
  237. const tablePaginationConfig = reactive<TablePaginationProps>({
  238. total: 0,
  239. pageSizeList: [10, 20, 40],
  240. })
  241. </script>
  242. <template>
  243. <MenuTable
  244. :menu-default-active="menuList[0].name"
  245. :menu-list="menuList"
  246. :operations="operations"
  247. :save-table-name="saveTableName"
  248. :table-info="tableInfo"
  249. :table-pagination-config="tablePaginationConfig"
  250. :table-req-info="tableReqInfo"
  251. :exclude-fields="allExcludeFields"
  252. >
  253. <template #operationDialog>
  254. <div>测试后</div>
  255. </template>
  256. </MenuTable>
  257. </template>
  258. <style scoped></style>