import { CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud'
import { BaseColumn } from '/@/views/adManage/utils/commonTabColumn.js'
import { spCampaignPlacementEnum } from '/@/views/adManage/utils/enum'
import XEUtils from 'xe-utils'


export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
	const { fetchData } = context

	return {
		crudOptions: {
			table: {
			},
			container: {
        fixedHeight: false
      },
			actionbar: {
				show: false,
				buttons: {
					add: {
						show: false
					}
				}
			},
			search: {
				show: true,
				buttons: {
					search: {
						show: false
					},
					reset: {
						show: false
					}
				}
			},
			toolbar: {
        buttons: {
					search: {
						show: true
					},
					compact: {
						show: false
					},
					refresh: {
						click: async () => fetchData()
					}
				}
			},
			pagination: {
				show: false
			},
			rowHandle: {
        show: false
      },
			columns: {
        placement: {
          title: '广告位',
          column: {
            width: '200px',
						fixed: 'left',
						formatter({ value, row, index }){
								return XEUtils.find(spCampaignPlacementEnum, (item) => item.value === value).label
						}
          }
        },
				bidAdjustment: {
					title: '竞价调整'
				},
        ...BaseColumn
			}
		}
	}
}
