import { get, post } from "@/utils/request";

// 项目-表-字段下拉
export function getProModularField() {
  return get({
    url: "/api/v1/field/get-project-modular-field-drop",
  });
}

// 展示类型下拉
export function getShowTypeSelect() {
  return get({
    url: `/api/v1/modular/get-show-type-drop`,
  });
}

// 字段列表
export function getFieldOpts({ modularId, showTypeId }) {
  return get({
    url: "/api/v1/preview/get-preview-field",
    params: {
      modular_id: modularId,
      show_type_id: showTypeId,
    },
  });
}

// 预览
export function preview({ modularId, fieldIds, page, perPage, filter, showTypeId, xDataId, yDataId, isExport }) {
  return post({
    url: "api/v1/preview/view",
    data: {
      modular_id: modularId,
      field_ids: fieldIds,
      page,
      per_page: perPage,
      filter,
      show_type_id: showTypeId,
      x_data_id: xDataId,
      y_data_id: yDataId,
      is_export: isExport,
    },
  });
}

// 点击保存
export function saveView({ modularId, fieldIds, previewName, showTypeId, xDataId, yDataId }) {
  return post({
    url: "api/v1/preview/save",
    data: {
      modular_id: modularId,
      field_ids: fieldIds,
      preview_name: previewName,
      show_type_id: showTypeId,
      x_data_id: xDataId,
      y_data_id: yDataId,
    },
  });
}
