// 自定义设计元素
import { hiprint } from "@/utils/hiprint";

export const aProvider: any = function (ops: any) {
  const addElementTypes = function (context: any) {
    context.removePrintElementTypes("aProviderModule");
    context.addPrintElementTypes("aProviderModule", [
      new hiprint.PrintElementTypeGroup("表格/其他", [
        {
          tid: "aProviderModule.table",
          title: "订单数据",
          type: "table",
          options: {
            field: "table",
            fields: [
              { text: "名称", field: "NAME" },
              { text: "数量", field: "SL" },
              { text: "规格", field: "GG" },
              { text: "条码", field: "TM" },
              { text: "单价", field: "DJ" },
              { text: "金额", field: "JE" },
              { text: "备注", field: "DETAIL" }
            ]
          },
          editable: true,
          columnDisplayEditable: true, //列显示是否能编辑
          columnDisplayIndexEditable: true, //列顺序显示是否能编辑
          columnTitleEditable: true, //列标题是否能编辑
          columnResizable: true, //列宽是否能调整
          columnAlignEditable: true, //列对齐是否调整
          columns: [
            [
              { title: "名称", align: "center", field: "NAME", width: 100 },
              { title: "数量", align: "center", field: "SL", width: 100 },
              { title: "条码", align: "center", field: "TM", width: 100 },
              { title: "规格", align: "center", field: "GG", width: 100 },
              { title: "单价", align: "center", field: "DJ", width: 100 },
              { title: "金额", align: "center", field: "JE", width: 100 },
              { title: "备注", align: "center", field: "DETAIL", width: 100 }
            ]
          ],
          footerFormatter: function (options: any, rows: any, data: any, currentPageGridRowsData: any) {
            if (data && data["totalCap"]) {
              return `<td style="padding:0 10px" colspan="100">${"应收金额大写: " + data["totalCap"]}</td>`;
            }
            return '<td style="padding:0 10px" colspan="100">应收金额大写: </td>';
          }
        }
      ])
    ]);
  };
  return { addElementTypes };
};

// type: 1供货商 2经销商
export default [
  {
    key: "default",
    name: "默认设计",
    value: "defaultProviderModule",
    type: 1,
    f: null
  },
  {
    key: "custom",
    name: "自定义设计",
    value: "aProviderModule",
    type: 1,
    f: aProvider()
  }
];
