import { hiprint } from"vue-plugin-hiprint";

export const providers = function (ops) {

  console.log(' hiprint', hiprint)
  var addElementTypes = function (context) {
    context.removePrintElementTypes("DKModule");
    context.addPrintElementTypes(
      "DKModule",
      [
        new hiprint.PrintElementTypeGroup("基础", [
          {
            tid: "DKModule.text",
            title: "",
            data: "",
            type: "text",
            options: {
              color:'#000000',
              fontSize:10.5,
              height:17,
              textContentVerticalAlign: "middle",
              contentPaddingLeft:3
            }
          },
          {
            tid: "DKModule.image",
            title: "图片",
            data: "/img/dklogo.9404478a.png",
            type: "image"
          },
          {
            tid: "DKModule.table",
            field: "table",
            title: "表格",
            type: "table",
            columns: [
              [
                {
                  title: "",
                  field: "",
                  width: 100
                },
                {
                  title: "",
                  field: "",
                  width: 100
                }
              ]
            ],
            editable: true,
            columnDisplayEditable: true,//列显示是否能编辑
            columnDisplayIndexEditable: true,//列顺序显示是否能编辑
            columnTitleEditable: true,//列标题是否能编辑
            columnResizable: true, //列宽是否能调整
            columnAlignEditable: true,//列对齐是否调整
            isEnableEditField: true, //编辑字段
            isEnableContextMenu: true, //开启右键菜单 默认true
            isEnableInsertRow: true, //插入行
            isEnableDeleteRow: true, //删除行
            isEnableInsertColumn: true, //插入列
            isEnableDeleteColumn: true, //删除列
            isEnableMergeCell: true, //合并单元格
          },
          {
            tid: 'DKModule.date', title: '日期', data: '2020-01-01', type: 'text',
            options: {
              field: 'date',
              testData: '2020-01-01',
              height: 16,
              fontSize: 6.75,
              fontWeight: "700",
              textAlign: "left",
              textContentVerticalAlign: "middle"
            }
          },
          {
            tid: 'DKModule.barcode', title: '条形码', data: 'XS888888888', type: 'text',
            options: {
              // field: 'barcode',
              testData: 'XS888888888',
              height: 32,
              fontSize: 10,
              lineHeight: 18,
              textAlign: "center",
              textType: "barcode"
            }
          },
          {
            tid: 'DKModule.qrcode', title: '二维码', data: 'XS888888888', type: 'text',
            options: {
              fields:[
                {text: '名称', field: 'NAME'},
                {text: '数量', field: 'SL'}
              ],
              // field: 'qrcode',
              testData: 'XS888888888',
              height: 48,
              width: 48,
              fontSize: 12,
              lineHeight: 18,
              textType: "qrcode"
            }
          },
        ]),

        new hiprint.PrintElementTypeGroup("辅助", [
          {
            tid: 'DKModule.hline',
            title: '横线',
            type: 'hline'
          },
          {
            tid: 'DKModule.vline',
            title: '竖线',
            type: 'vline'
          },
          {
            tid: 'DKModule.rect',
            title: '矩形',
            type: 'rect'
          },
          {
            tid: 'DKModule.oval',
            title: '圆形',
            type: 'oval'
          }
        ])
      ]
    );
  };
  return {
    addElementTypes: addElementTypes
  };
};
export default providers()

