import * as api from './api' import { dict, UserPageQuery, AddReq, DelReq, EditReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud' import { inject, nextTick, ref } from 'vue' import { BaseColumn } from '/@/views/adManage/utils/commonTabColumn.js' export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: UserPageQuery) => { return await api.GetList(query); }; const editRequest = async ({ form, row }: EditReq) => { form.id = row.id; return await api.UpdateObj(form); }; const delRequest = async ({ row }: DelReq) => { return await api.DelObj(row.id); }; const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; //权限判定 const hasPermissions = inject('$hasPermissions'); return { crudOptions: { table: { height: 800 }, container: { fixedHeight: false }, actionbar: { show: true, buttons: { add: { show: false }, create: { text: '新建广告活动', type: "primary", show: true, click() { } } } }, search: { show: false }, toolbar: { buttons: { search: { show: true }, compact: { show: false } } }, request: { pageRequest, addRequest, editRequest, delRequest, }, rowHandle: { fixed: 'right', width: 80, buttons: { view: { show: false, }, edit: { iconRight: 'Edit', type: 'text', text: null // show: hasPermissions('dictionary:Update'), }, remove: { iconRight: 'Delete', type: 'text', text: null // show: hasPermissions('dictionary:Delete'), }, }, }, columns: { name: { title: '广告活动', column: { width: '150px' }, search: { show: true, component: { props: { clearable: true } } }, form: { rules: [{required: true, message:'必填项'}] } }, targetingType: { title: '投放类型', type: 'dict-select', search: { show: true }, dict: dict({ data: [ { value: 'AUTO', label: '自动' }, { value: 'MANUAL', label: '手动' }, ] }) }, state: { title: '状态' }, startDate: { title: '开始日期' }, endDate: { title: '结束日期' }, budget: { title: '预算' }, portfolio: { title: '广告组合' }, ...BaseColumn } } } }