vue-plugin-hiprint】动态表格相关

【hiprint】hiprint的使用方法(附使用案例)hiprint 表格数据传输问题解决办法 hiprint打印table数据无法传输解决办法事件起因:问题描述: 事件起因: 因为前两天要弄一个a4纸的打印功能(嵌入在网页里面),结果前两天因为弄这个搞得挺恼火的,到笔者终于解决了这个问题后,特此来说明一下这个问题,以便后来者能够吸取经验教训 问题描述: 我所创建的一个空的vue项目,后面在这个里面加入hiprint进行数据的打印 阅读详情

官网:http://hiprint.io/docs/table

一、如何合并表格列/行?

rowsColumnsMerge

1、实现第一种情况 合并 每 2 行 的 第 1 列

// 行/列 合并函数
{
  rowsColumnsMerge:function (data, row, colIndex, rowIndex) {
    console.log('data', data);
    console.log('row', row);
    console.log('colIndex', colIndex);
    console.log('rowIndex', rowIndex);
    // 返回一个数组,参数一为行(rowspan)合并数,参数二为列(colspan)合并数, 被合并的行或者列值设为0
    if (rowIndex%2 == 0) { // 0、2、4 行
      if (colIndex == 0) { // 1列
        // 设置合并的 行/列 数量
        return [2, 1]
      }
      return [1, 1]
    } else {
      // 1、3 行
      if (colIndex == 0) { // 1列
         // 被合并的 行/列 设置为 0
        return [0, 1]
      }
      return [1, 1]
    }
  }
}

2、实现第二种情况 合并 每行 的 前 2 列

// 行/列 合并函数
{
  rowsColumnsMerge:function (data, row, colIndex, rowIndex) {
    console.log('data', data);
    console.log('row', row);
    console.log('colIndex', colIndex);
    console.log('rowIndex', rowIndex);
    // 返回一个数组,参数一为行(rowspan)合并数,参数二为列(colspan)合并数, 被合并的行或者列值设为0
    if (colIndex == 0) { // 第1列
      return [1, 2]
    } else if (colIndex == 1) { // 第2列
      return [1, 0]
    } else {
      return [1, 1]
    }
  }
}

二、表格分栏显示?

gridColumns

同样的表格结构,想左边显示一个,右边显示一个。这种情况,仅需设置2个参数即可:

  1. 一行多组(gridColumns)

  2. 一行多组间隔 (gridColumnsGutter)

如看效果图:

三、表格自动补全/最大行数限制?

有时分栏显示了,数据总是少那么一两行,不够美观。怎么办呢?

自动补全功能是将剩余位置填满空白行。 最大行数功能就是每页限制填充的数据行数。

看效果:

四、表格分页多余空白问题?

这种情况主要原因是:分页计算的 tr 高度 与实际渲染的 tr 高度不一致导致的。

那么为什么高度不一致呢? 原因有大概有几种情况:

  1. 表格行内的元素/文本自动换行导致

  2. 样式污染导致

  3. 计算机分辨率设置了缩放导致

具体原因具体分析。如果是第 1 种,可以尝试固定表体行高。如图:

第 2 种,就需要自行检查,有没有全局 tr/td 这种固定高度,边距之类的全局样式。

第 3 种,检查计算机是否有缩放配置。

最终原因都是因为计算高度与渲染高度不一致导致的。

五、表格列渲染二维码/图片?

一些特殊场景,就有这种情况。设置也非常简单,如下图:

注意:图片中的单元格高度仅针对字段类型为二维码、条形码、图片才起作用。

六、表格列自定义渲染?

二维码、图片这些的已经满足不了的情况,就可以使用单元格渲染函数来自行处理,渲染的样式。 比如我们要想渲染一个进度条的效果:

效果如下:

七、表格脚/聚合函数?

footerFormatter:表格脚格式化函数,定义分组尾部显示信息,可以放置写统计信息。。该函数需要四个参数:
options:打印元素的选项值。
rows
data
currentPageGridRowsData:当前页数据

groupFooterFormatter:分组脚格式化函数,定义分组尾部显示信息,可以放置写统计信息。。该函数需要二个参数:
groupData:分组信息。
options:打印元素的选项值。

gridColumnsFooterFormatter:多组表格脚格式化函数,定义分组尾部显示信息,可以放置写统计信息。。该函数需要四个参数:
options:打印元素的选项值。
rows
data
currentPageRowsData:当前页数据

早期版本没有聚合函数的时候,只有自定义表格脚函数。原理同自定义渲染一样,返回tr中的td 即可。

有了聚合函数,一些简单的场景,就不需要那么麻烦了,设置这几个参数即可搞定。如下图:

这个函数是设置在表格列对象的。可以设置计数、合计、平均值、最大值、最小值、仅文本。同时也可以设置对齐方式,是否显示标题、转大小数字、合并等等。

注意:聚合函数优先于表格脚函数。可同时设置。合并列,需要将其后续的合并设置为0。

表格脚函数返回 tr td 标签即可。如:

八、表格分组头/脚格式化函数?

这个功能是3个函数关联使用。大概场景就是根据多个字段分组,然后给每个组,渲染显示一个头/脚统计行。如图:分组字段、头/脚函数

其中分组字段函数返回的就是分组依据,一个字段名数组。

九、多组表格脚函数?

这个功能,同的甚少。主要是用于 27 点中的 表格分栏显示。首先我们随便写写测试看看效果:

十、表格行特殊样式?

rowStyler

表格列样式函数,返回样式对象来自定义该 tr元素的样式,例如 {'background':'red'} 。该函数需要二个参数:
value:字段的值。
options:打印元素的选项值。

譬如当这一行某个值,大于等于某个值的时候,想特殊显示的场景。那么就可以使用行样式函数。又或者,每一行自定义样式,斑马条纹等等情况。

补充一个常用函数

renderFormatter 是 vue-plugin-hiprint 中用于自定义表格列内容渲染格式的函数,允许开发者完全控制表格单元格的HTML内容生成。
主要用途
自定义内容展示:根据数据动态生成表格单元格的HTML内容
复杂布局:在一个单元格内展示多行文本、颜色、样式等复杂信息
数据格式化:对原始数据进行处理后再展示

在表格列配置中使用:

{
      "options": {
        "left": 25.5,
        "top": 380,
        "height": 72,
        "width": 541.5,
        "field": "ntable",
        "right": 567,
        "bottom": 399.75,
        "vCenter": 297.75,
        "hCenter": 363.75,
        "fontSize": 9,
        "rowsColumnsMerge": "(row,col,colIndex,rowIndex,tableData,printData)=>{ const mergeFields=['executeOrgNames']; if(!mergeFields.includes(col.field) || !printData?.noAppointmentSpanValues || !tableData || tableData.length === 0) {\n    return [1,1];\n  } if(mergeFields.includes(col.field)&&printData?.noAppointmentSpanValues){const currentKey='noapp_'+row.executeOrgNames || '';const isFirstRowInGroup=rowIndex===0||(tableData[rowIndex-1].executeOrgNames!==row.executeOrgNames);if(isFirstRowInGroup){const spanValue = printData.noAppointmentSpanValues[currentKey] || 1; return [spanValue, 1]; }else{return[0,1];}}else{return[1,1];}}",
        "columns": [
          [{
            "width": 160,
            "title": "地点",
            "field": "executeOrgNames",
            "checked": true,
            "columnId": "executeOrgNames",
            "rowspan": 1,
            "colspan": 1,
            "fixed": false
          },{
            "width": 211.5,
            "title": "项目名称",
            "field": "projectNames",
            "checked": true,
            "columnId": "projectNames",
            "rowspan": 1,
            "colspan": 1,
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectNames+\"</div><div style='margin-bottom:5px;color:#777777'>\"+row.projectMainDescribes+\"</div>\";}",
            "fixed": false
          }, {
            "width": 170,
            "title": "注意事项",
            "field": "projectCautions",
            "checked": true,
            "columnId": "projectCautions",
            "rowspan": 1,
            "colspan": 1,
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectCautions+\"</div>\";}",
            "fixed": false
          }]
        ]
      },

groupFormatter

功能概述
主要作用:自定义表格分组的显示格式
使用场景:当表格数据按特定字段分组时,控制分组头部的展示内容
参数说明
value: 分组字段的值
rows: 该分组包含的所有数据行
field: 分组依据的字段名

groupFormatter: function(value, rows, field) {
  // 自定义分组头部显示内容
  return `<div class="custom-group-header">${value} (${rows.length}项)</div>`;
}

groupFieldsFormatter

功能概述
主要作用:格式化分组字段的显示内容
使用场景:对分组字段的值进行特殊处理或格式化
参数说明
value: 分组字段的原始值
row: 当前行数据
field: 分组字段名

groupFieldsFormatter: function(value, row, field) {
  // 对分组字段值进行格式化处理
  return `分组: ${value}`;
}

组合使用

{
      "options": {
        "left": 25.5,
        "top": 185.5,
        "height": 72,
        "width": 541.5,
        "field": "table",
        "groupFieldsFormatter": "function(type,options,data){ return [\"timeInterval\"];}",
        "coordinateSync": false,
        "widthHeightSync": false,
        "groupFormatter": "function(colTotal,tableData,printData,groupData,options){return\"<tr style='border: none!important;'><td colspan='4'>\"+groupData.rows[0].path+\"</td></tr>\";}",
        "right": 567,
        "bottom": 282.75,
        "vCenter": 296.25,
        "hCenter": 246.75,
        "fontSize": 9,
        "columns": [
          [{
            "width": 209.90625,
            "title": "检查/治疗顺序-项目名称",
            "field": "projectNames",
            "checked": true,
            "columnId": "projectNames",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1,
            "align": "left",
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectNames+\"</div><div style='margin-bottom:5px;color:#777'>\"+row.projectMainDescribes+\"</div>\";}"
          }, {
            "width": 116.17275000000001,
            "title": "注意事项",
            "field": "projectCautions",
            "checked": true,
            "columnId": "projectCautions",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1,
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectCautions+\"</div>\";}"
          }, {
            "width": 118.13174999999997,
            "title": "预约时间",
            "field": "appDates",
            "checked": true,
            "columnId": "appDates",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1
          }, {
            "width": 97.28925000000004,
            "title": "执行科室",
            "field": "executeOrgNames",
            "checked": true,
            "columnId": "executeOrgNames",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1
          }]
        ]
      },

应用场景
1. 数据分组展示
在指引单打印中按执行机构或预约时间进行分组
为每个分组添加自定义头部信息
2. 格式化需求
对分组标题进行样式化处理
添加统计信息(如该组包含的项目数量)
3. 用户体验优化
使分组信息更清晰易读
提供更丰富的分组展示效果
配置位置
这两个选项通常在 HIPRINT_CONFIG.table.supportOptions 中定义
位于表格的"高级"选项卡中
与 rowsColumnsMerge 等功能配合使用,实现复杂的表格展示效

<template>
  <div>
    <div v-if="showStatus">
      <x-card v-if="hasPerm('admin:project:guide-order:page')">
        <div slot="content" class="table-page-search-wrapper">
          <a-form layout="inline">
            <a-row :gutter="48">
              <a-col :md="6" :sm="24">
                <a-form-item label="预约日期">
                  <a-range-picker @change="appOnChange" v-model="appointmentDate" />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="诊疗号">
                  <a-input v-model="queryParam.patientNo" allow-clear placeholder="请输入门诊号/病历号" :max-length="20"/>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="患者姓名">
                  <a-input v-model="queryParam.patientName" allow-clear placeholder="请输入患者姓名" />
                </a-form-item>
              </a-col>
              <a-col v-if="advanced" :md="6" :sm="24">
                <a-form-item label="行动状态">
                  <a-select v-model="queryParam.patientActionStatus" placeholder="请选择行动状态">
                    <a-select-option
                      v-for="(item,index) in $options.filters['dictData']('patient_action_status')"
                      :key="index"
                      :value="item.code">{{ item.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col v-if="advanced" :md="6" :sm="24">
                <a-form-item label="状态">
                  <a-select v-model="queryParam.orderStatus" placeholder="请选择状态">
                    <a-select-option
                      v-for="(item,index) in $options.filters['dictData']('project_guide_order_status')"
                      :key="index"
                      :value="item.code">{{ item.name }}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col v-if="advanced" :md="6" :sm="24">
                <a-form-item label="提交科室">
                  <a-tree-select
                    v-model="queryParam.orgId"
                    show-search
                    tree-node-filter-prop="title"
                    :treeData="orgTree"
                    allowClear
                    placeholder="请选择科室"
                    ref="orgTree">
                  </a-tree-select>
                </a-form-item>
              </a-col>
              <a-col v-if="advanced" :md="6" :sm="24">
                <a-form-item label="提交人">
                  <a-input v-model="queryParam.submitUserName" allow-clear placeholder="请输入提交人" />
                </a-form-item>
              </a-col>
              <a-col v-if="advanced" :md="6" :sm="24">
                <a-form-item label="提交时间">
                  <a-range-picker @change="onChange" v-model="submitDate" />
                </a-form-item>
              </a-col>
              <a-col :md="5" :sm="24">
                <span class="table-page-search-submitButtons" :style="{ float: 'right', overflow: 'hidden' } || {} ">
                  <a-button type="primary" @click="query">查询</a-button>
                  <a-button style="margin-left: 8px" @click="reset">重置</a-button>
                  <a @click="toggleAdvanced" style="margin-left: 8px">
                    {{ advanced ? '收起' : '展开' }}
                    <a-icon :type="advanced ? 'up' : 'down'" />
                  </a>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
      </x-card>
      <div style="width: 100%;box-sizing: border-box;padding: 20px;background-color: #fff;">
        <s-table
          ref="table"
          :columns="columns"
          :data="loadData"
          :alert="false"
          v-if="hasPerm('admin:project:guide-order:page')"
          :scroll="{ x: 1500}">
          <span slot="patientBaseInfo" slot-scope="text, record">
            {{ record.patientName }} {{ $options.filters['dictTypeDataMate']('sex', record.patientSex) }}
            {{ record.patientAge + '岁' }}
          </span>
          <span slot="appointmentTime" slot-scope="text, record">
            {{ record.appointmentDate }} {{ record.appointmentStartTime }}-{{ record.appointmentEndTime }}
          </span>
          <span slot="projectNumInfo" slot-scope="text, record">
            <!-- 总数(预约项目数量/非预约项目数量) -->
            {{ record.projectNum }} ({{ record.projectAppointmentNum }}/{{ record.projectNoAppointmentNum }})
          </span>
          <span slot="action" slot-scope="text, record">
            <a @click="showDayin(record)" v-if="hasPerm('admin:project:guide-order-detail:list')" style="margin-right: 10px;">详情</a>
            <a @click="cancelOrderStatus(record)" v-if="hasPerm('admin:project:guide-order:invalid') && record.orderStatus === 1">作废</a>
          </span>
        </s-table>
      </div>
    </div>
    <!--  详情  -->
    <!--    <detail ref="detail"></detail>-->
    <!--  打印  -->
    <start-preview ref="startPreview" @orderPrint="orderPrint" :guideOrderStatus="guideOrderStatus" id="printable-area"/>
  </div>
</template>

<script>
import {
  getOrgTree,
  getguideOrderPage,
  getGuideOrderInvalid, getGuideOrderDetail
} from '../../api/appointmentManage'
  import moment from 'moment'
  import {
    STable,
    XCard,
    XDown
  } from '@/components'
import startPreview from './preview.vue'
import mb from './md.json'
import invalidmd from './invalidmd.json'
import { combiTemplate } from './template.js'
import guide from './guide'
import { hiPrintPlugin } from 'vue-plugin-hiprint'
// 在调用 hiprint 打印前处理数据:合并相同地点的行
// function mergeRowsByLocation(data) {
//   const result = []
//   let currentLocation = null
//   let mergedRow = null
//   data.forEach(row => {
//     if (row.executeOrgNames === currentLocation) {
//       console.log('row.executeOrgNames === currentLocation')
//       // 相同地点:更新当前合并行
//       mergedRow.projectName += `<span style="display:inline-block; width:350px; height:5px; border-bottom:1px solid #000;"><br>${row.projectName}</span>`
//       mergedRow.projectCautions += row.projectCautions ? `<span style="display:inline-block; width:200px; height:8px; border-bottom:1px solid #000;"><br>${row.projectCautions}</span>` : `<span style="display:inline-block; width:200px; height:10px; border-bottom:1px solid #000;"><br> &nbsp;` + `<span style="color: #fff;">&nbsp;</span>`
//       console.log('mergedRow:', mergedRow)
//     } else {
//       console.log('else')
//       // 新地点:添加前一个合并行(如果有)
//       if (mergedRow) {
//         console.log('else mergedRow:', mergedRow)
//         mergedRow.projectName = `<span style="display:inline-block; width:350px; height:5px; border-bottom:1px solid #000;"><br>${mergedRow.projectName}</span>`
//         mergedRow.projectCautions = mergedRow.projectCautions ? `<span style="display:inline-block; width:200px; height:8px; border-bottom:1px solid #000;"><br>${mergedRow.projectCautions}</span>` : `<span style="display:inline-block; width:200px; height:10px; border-bottom:1px solid #000;"><br> &nbsp;` + `<span style="color: #fff;">&nbsp;</span>`
//         result.push(mergedRow)
//       }
//       // 初始化新行
//       row.projectCautions = row.projectCautions !== null && row.projectCautions !== undefined ? `${row.projectCautions}-123` : `<span style="color: #000;">&nbsp;321</span>`
//       console.log('else row:', row)
//       mergedRow = { ...row, _isMerged: true }
//       currentLocation = row.executeOrgNames
//     }
//   })
//   // 添加最后一个合并行
//   if (mergedRow) {
//     result.push(mergedRow)
//   }
//   console.log('result:', result)
//   return result
// }
// 自定义排序函数
function compareDates(a, b) {
  const dateA = new Date(a.appDate)
  const dateB = new Date(b.appDate)
  // 比较两个日期
  return dateA - dateB
}
// 判断上午or下午
function isAMorPM(dateTimeString) {
  // 将字符串转换为日期对象
  const dateTime = new Date(dateTimeString)
  // 获取小时数
  const hours = dateTime.getHours()
  // 根据小时数返回上午或下午
  return hours < 12 ? 'morning' : 'afternoon'
}
export default {
    components: {
      guide,
      startPreview,
      // detail,
      XCard,
      STable,
      XDown
    },
    data() {
      return {
        guideOrderStatus: 1,
        // 打印数据
        printDetail: {},
        appointmentProjects: [],
        noAppointmentProjects: [],

        printData: {},
        newMb: Object,

        showStatus: true,
        advanced: false,
        orgId: '',
        appointmentDate: [],
        submitDate: [],
        orgTree: [],
        queryParam: {
          appointmentDateStart: '',
          appointmentDateEnd: '',
          patientNo: '',
          patientName: '',
          patientActionStatus: undefined,
          orderStatus: undefined,
          orgId: undefined,
          submitUserName: '',
          startSubmitDate: '',
          endSubmitDate: ''
        },
        // 表头
        columns: [{
            title: '指引单编号',
            width: '160px',
            dataIndex: 'guideNo'
          },
          {
            title: '类型', // 门诊、住院、体检、
            width: '80px',
            dataIndex: 'serviceType',
            customRender: (serviceType) => this.$options.filters['dictTypeDataMate']('service_type', serviceType)
          },
          {
            title: '诊疗号',
            width: '140px',
            dataIndex: 'patientNo'
          },
          {
            title: '患者姓名',
            width: '160px',
            dataIndex: 'patientBaseInfo',
            scopedSlots: {
              customRender: 'patientBaseInfo'
            }
          },
          {
            title: '会员身份',
            width: '140px',
            dataIndex: 'patientLevel',
            customRender: (patientLevel) => this.$options.filters['dictTypeDataMate']('resident_level', patientLevel)
          },
          {
            title: '行动状态',
            width: '100px',
            dataIndex: 'patientActionStatus',
            customRender: (patientActionStatus) =>
              this.$options.filters['dictTypeDataMate']('patient_action_status', patientActionStatus)
          },
          {
            title: '预约日期',
            width: '120px',
            dataIndex: 'appointmentDate'
          },
          {
            title: '项目数量',
            width: '120px',
            dataIndex: 'projectNumInfo',
            scopedSlots: {
              customRender: 'projectNumInfo'
            }
          },
          {
            title: '提交科室',
            width: '160px',
            dataIndex: 'orgName'
          },
          {
            title: '提交人',
            width: '140px',
            dataIndex: 'submitUserName'
          },
          {
            title: '提交时间',
            width: '180px',
            dataIndex: 'submitTime',
            scopedSlots: {
              customRender: 'submitTime'
            }
          },
          {
            title: '状态',
            width: '80px',
            dataIndex: 'orderStatus',
            customRender: (orderStatus) =>
              this.$options.filters['dictTypeDataMate']('project_guide_order_status', orderStatus)
          }
        ],
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          const queryParam = this.queryParam
          return getguideOrderPage(Object.assign(parameter, queryParam)).then((
            res) => {
            return res.data
          }).catch(error => {
            this.$message.error('搜索关键词中含有特殊字符')
          })
        }
      }
    },
    created() {
      if (this.hasPerm('admin:project:guide-order-detail:list')) {
        this.columns.push({
          title: '操作',
          width: '100px',
          dataIndex: 'action',
          fixed: 'right',
          scopedSlots: {
            customRender: 'action'
          }
        })
      }
    },
    async mounted() {
      const OrgTree = await getOrgTree()
      this.orgTree = OrgTree.data
    },
    watch: {
      '$route'(to, from) {
        // 当路由变化时,检查是否需要刷新数据
        if (to.query.refresh) {
          this.query()
        }
      }
    },
    methods: {
      showPages() {
        this.showStatus = true
      },
      /**
       * 查询
       */
      query() {
        console.log('query')
        this.$refs.table.refresh(true)
      },
      goDetail(record) {
        // this.showStatus = false
        // this.$router.push('/appointment/guide/detail1?id=' + e.id)
        this.$refs.detail.show(record)
      },
      // 调用作废API
      cancelOrderStatus(e) {
        this.$confirm({
          title: '确认作废该指引单,作废后患者端不可查?',
          // content: '作废后不可恢复',
          onOk: async () => {
            const formData = {
              id: e.id
            }
            const res = await getGuideOrderInvalid(formData)
            if (res.code !== 200) {
              this.$message.error(res.message)
              return false
            }
            this.$message.success('作废成功')
            e.orderStatus = 0
            this.$refs.table.refresh(false)
          }
        })
      },
      // 预约日期选择回调
      appOnChange(e) {
        if (e.length > 0) {
          this.queryParam.appointmentDateStart = moment(e[0]).format('YYYY-MM-DD')
          this.queryParam.appointmentDateEnd = moment(e[1]).format('YYYY-MM-DD')
        } else {
          this.queryParam.appointmentDateStart = ''
          this.queryParam.appointmentDateEnd = ''
        }
      },
      // 提交日期选择回调
      onChange(e) {
        if (e.length > 0) {
          this.queryParam.startSubmitDate = moment(e[0]).format('YYYY-MM-DD')
          this.queryParam.endSubmitDate = moment(e[1]).format('YYYY-MM-DD')
        } else {
          this.queryParam.startSubmitDate = ''
          this.queryParam.endSubmitDate = ''
        }
      },
      toggleAdvanced() {
        this.advanced = !this.advanced
      },
      /**
       * 重置
       */
      reset() {
        this.appointmentDate = []
        this.submitDate = []
        this.queryParam = {
          appointmentDateStart: '',
          appointmentDateEnd: '',
          patientNo: '',
          patientName: '',
          patientActionStatus: undefined,
          orderStatus: undefined,
          orgId: undefined,
          submitUserName: '',
          startSubmitDate: '',
          endSubmitDate: ''
        }
        this.$refs.table.refresh(true)
      },
      async showDayin(e) {
        // this.guideOrderData = {}
        // this.guideOrderData = e
        this.guideOrderStatus = e.orderStatus
        this.getDetail(e)
        // const res = await guideOrderPrint({
        //   id: e.id
        // })
        // this.printDetail = res.data
        // this.orderPrint('preview')
      },
      // 指引单详情
      async getDetail(e) {
        const res = await getGuideOrderDetail({
          guideOrderId: e.id
        })
        // this.detail = res.data
        this.printDetail = res.data
        this.noAppointmentProjects = res.data.noAppointmentProjects
        this.appointmentProjects = res.data.appointmentProjects
        this.orderPrint('preview')
      },
      generateSpanValues(data) {
        const spanValues = {}

        // 按照预约时间和地点分组统计合并行数
        const groupCounts = {}
        data.forEach((row, index) => {
          const key = `${row.appointmentDate}_${row.appointmentStartTime}_${row.appointmentEndTime}_${row.executeOrgNames}`
          if (!groupCounts[key]) {
            groupCounts[key] = []
          }
          groupCounts[key].push(index)
        })

        // 为每组的第一个元素设置合并行数
        Object.keys(groupCounts).forEach(key => {
          const indices = groupCounts[key]
          spanValues[key] = indices.length
        })
        console.log('spanValues1', spanValues)
        return spanValues
      },
      generateNoAppointmentSpanValues(data) {
        const spanValues = {}

        // 按照地点分组统计合并行数(用于免预约项目)
        const groupCounts = {}
        data.forEach((row, index) => {
          // 确保 executeOrgNames 不为空
          const executeOrgNames = row.executeOrgNames || ''
          const key = `noapp_${executeOrgNames}` // 添加前缀避免键冲突
          if (!groupCounts[key]) {
            groupCounts[key] = []
          }
          groupCounts[key].push(index)
        })

        // 为每组的第一个元素设置合并行数
        Object.keys(groupCounts).forEach(key => {
          const indices = groupCounts[key]
          spanValues[key] = indices.length
        })
        console.log('spanValues2', spanValues)
        return spanValues
      },
      orderPrint(status) {
        // 预览
        if (status === 'preview') {
          // 深拷贝数据
          const mbData = this.guideOrderStatus === 1 ? JSON.parse(JSON.stringify(mb)) : JSON.parse(JSON.stringify(invalidmd))
          const that = this
          const detail = this.printDetail
          console.log('this.printDetail', this.printDetail)
          const printAppointmentProjects = detail.appointmentProjects
          const printNoAppointmentProjects = detail.noAppointmentProjects
          // 处理预约项目数据
          const appData = printAppointmentProjects.map(function(item, index) {
            item.appDate = item.appointmentDate + ' ' + item.appointmentStartTime
            if (item.appointmentStartTime && item.appointmentEndTime) {
              item.appDates = item.appointmentStartTime + ' - ' + item.appointmentEndTime
            }
            const projectMainDescribes = JSON.parse(JSON.stringify(item.projectMainDescribe))
            item.projectMainDescribes = item.projectMainDescribe && detail.serviceType === 1 ? '病情摘要:' + projectMainDescribes : ''
            const executeOrgNames = JSON.parse(JSON.stringify(item.executeOrgName))
            // item.executeOrgNames = executeOrgNames + '(' + item.executeOrgAddress + ')'
            const deskName = item.deskName !== null && item.deskName !== undefined ? ' | ' + item.deskName : ''
            const address = item.deskAddress !== null && item.deskAddress !== undefined ? '(' + item.deskAddress + ')' : ''
            item.executeOrgNames = executeOrgNames + deskName + address
            item.projectCautions = item.projectCautions || ''
            return item
          })
          const appArrAM = []
          const appArrPM = []
          const appArr = appData.sort(compareDates).map(function(item, index) {
            item.timeInterval = item.appointmentDate + isAMorPM(item.appDate)
            item.interval = isAMorPM(item.appDate)
            item.interval == 'morning' ? appArrAM.push(item) : appArrPM.push(item)
            return item
          })
          console.log('appArrAM====', appArrAM)
          console.log('appArrPM====', appArrPM)
          // 上午 下午区分开
          appArrAM.map(function(item, index) {
            const i = index + 1
            const projectNames = JSON.parse(JSON.stringify(item.projectName))
            item.projectNames = i + '、' + projectNames
          })
          appArrPM.map(function(item, index) {
            const i = index + 1
            const projectNames = JSON.parse(JSON.stringify(item.projectName))
            item.projectNames = i + '、' + projectNames
          })

          // 在处理 noAppointmentProjects 之前添加排序逻辑
          const sortedNoAppointmentProjects = [...printNoAppointmentProjects].sort((a, b) => {
            // 按 executeOrgNames 排序,确保相同地点的项目连续排列
            const executeOrgAddressA = a.executeOrgAddress !== null && a.executeOrgAddress !== undefined ? ' | ' + a.executeOrgAddress : ''
            const executeOrgAddressB = b.executeOrgAddress !== null && b.executeOrgAddress !== undefined ? ' | ' + b.executeOrgAddress : ''
            const nameA = (a.executeOrgName && typeof a.executeOrgName === 'string') ? a.executeOrgName + executeOrgAddressA : ''
            const nameB = (b.executeOrgName && typeof b.executeOrgName === 'string') ? b.executeOrgName + executeOrgAddressB : ''
            return nameA.localeCompare(nameB)
          })

          const noAppointmentProjects = sortedNoAppointmentProjects.map(function(item, index) {
            item.timeInterval = '1'
            const projectMainDescribes = JSON.parse(JSON.stringify(item.projectMainDescribe))
            item.projectMainDescribes = item.projectMainDescribe && detail.serviceType === 1 ? '病情摘要:' + projectMainDescribes : ''
            const executeOrgNames = JSON.parse(JSON.stringify(item.executeOrgName))
            const executeOrgAddress = item.executeOrgAddress !== null && item.executeOrgAddress !== undefined ? ' | ' + item.executeOrgAddress : ''
            item.executeOrgNames = executeOrgNames + executeOrgAddress
            item.projectCautions = item.projectCautions || ''
            const i = index + 1
            const projectNames = JSON.parse(JSON.stringify(item.projectName))
            item.projectNames = i + '、' + projectNames
            // item.projectNames = `<span style="font-size: 8pt; display:inline-block; width:14px; height:14px; border-radius:50%; border: 1px solid #000; color:#000; text-align:center; line-height:11px; margin-right:5px; ">${i}</span>` + projectNames
            return item
          })

          const patientLevel = detail.patientLevel !== null && detail.patientLevel !== undefined ? this.$options.filters['dictTypeDataMate']('resident_level', detail.patientLevel) : ''
          // 身份证号显示前三后三,中间*隐藏
          let patientCardId = ''
          if (detail.patientCardId !== null && detail.patientCardId !== undefined) {
            const idCard = detail.patientCardId
            if (!idCard || idCard.length < 7) {
              return idCard
            }
            patientCardId = idCard.substring(0, 3) + '*'.repeat(idCard.length - 6) + idCard.substring(idCard.length - 3)
          }
          const spanValues = this.generateSpanValues(appArr)
          const noAppointmentSpanValues = this.generateNoAppointmentSpanValues(noAppointmentProjects)
          // 组装数据
          const printData = {
            // 条形码
            guideNo: detail.guideNo,
            // 公众号二维码
            qrcode1: 'https://wit120.medmap.com.cn/',
            // 指引单二维码
            qrcode2: process.env.VUE_APP_FMS_BASE_URL + `/project/appointment/guide?guideOrderId=${detail.id}`,
            titleName: detail.appointmentDate ? detail.appointmentDate + ' 检查(治疗)指引单' : '' + ' 检查(治疗)指引单',
            // patientName: detail.patientName + ' ' + this.$options.filters['dictTypeDataMate']('sex', detail.patientSex) + ' ' + detail.patientAge + '岁 ' + ' ' + '<span style="background-color: #D0D0D0;">' + patientLevel + '</span>',
            patientName: detail.patientName + ' ' + this.$options.filters['dictTypeDataMate']('sex', detail.patientSex) + ' ' + detail.patientAge + '岁 ' + ' ' + patientLevel,
            patientCardId: patientCardId,
            patientActionStatus: this.$options.filters['dictTypeDataMate']('patient_action_status', detail.patientActionStatus),
            patientNo: detail.patientNo,
            serviceType: this.$options.filters['dictTypeDataMate']('service_type', detail.serviceType),
            orgName: detail.orgName,
            table: appArr, // 全部
            tableam: appArrAM, // 上午
            tablepm: appArrPM, // 下午
            ntable: noAppointmentProjects,
            // 添加合并信息
            spanValues: spanValues,
            noAppointmentSpanValues: noAppointmentSpanValues
          }
          if (appArr.length === 0) {
            mbData.panels[0].printElements[12] = {}
            mbData.panels[0].printElements[13] = {}
            mbData.panels[0].printElements[14] = {}
            // 免预约 调整布局上移
            if (mbData.panels[0].printElements[15] && mbData.panels[0].printElements[15].options) {
              mbData.panels[0].printElements[15].options.top = 170
            }
            if (mbData.panels[0].printElements[16] && mbData.panels[0].printElements[16].options) {
              mbData.panels[0].printElements[16].options.top = 190
            }
          }
          if (appArrAM.length === 0 && appArrPM.length > 0) {
            mbData.panels[0].printElements[13] = {}
            // 下午和免预约 调整布局上移
            if (mbData.panels[0].printElements[14] && mbData.panels[0].printElements[14].options) {
              mbData.panels[0].printElements[14].options.top = 190
            }
            if (mbData.panels[0].printElements[15] && mbData.panels[0].printElements[15].options) {
              mbData.panels[0].printElements[15].options.top = 280
            }
            if (mbData.panels[0].printElements[16] && mbData.panels[0].printElements[16].options) {
              mbData.panels[0].printElements[16].options.top = 300
            }
          }
          if (appArrPM.length === 0 && appArrAM.length > 0) {
            mbData.panels[0].printElements[14] = {}
            // 免预约调整布局上移
            if (mbData.panels[0].printElements[15] && mbData.panels[0].printElements[15].options) {
              mbData.panels[0].printElements[15].options.top = 280
            }
            if (mbData.panels[0].printElements[16] && mbData.panels[0].printElements[16].options) {
              mbData.panels[0].printElements[16].options.top = 300
            }
          }
          if (noAppointmentProjects.length === 0) {
            // 如果不存在免预约项目.则隐藏对应表头和表格
            mbData.panels[0].printElements[15] = {}
            mbData.panels[0].printElements[16] = {}
          }

          // 调用打印
          const newMb = combiTemplate(mbData, printAppointmentProjects, printNoAppointmentProjects)
          this.newMb = newMb
          console.log('newMb:', newMb)
          const hiprintTemplate = new hiprint.PrintTemplate({
            template: newMb
          })
          console.log('==============printData预览数据=============')
          console.log(printData)
          console.log('==============printData预览数据=============')
          this.printData = printData
          const html = hiprintTemplate.getHtml(printData)
          this.$refs.startPreview.showModal(html)
          // // 预览
          // if (status === 'preview') {
          //   this.printData = printData
          //   const html = hiprintTemplate.getHtml(printData)
          //   // this.showGuide = true
          //   this.$refs.startPreview.showModal(html)
          // }
        }
        // 打印
        if (status === 'print') {
          this.comfirmPrint()
          // hiprintTemplate.print(printData)
        }
      },
      // 打印
      comfirmPrint() {
        console.log('this.newMb:', this.newMb)
        const hiprintTemplate = new hiprint.PrintTemplate({
          template: this.newMb
        })
        console.log('==============comfirmPrintData=============')
        console.log(this.printData)
        console.log('==============comfirmPrintData=============')
        hiprintTemplate.print(this.printData)
      }
    }
  }
</script>
<style scoped>
</style>
{
  "panels": [{
    "index": 0,
    "name": 1,
    "height": 297,
    "width": 210,
    "paperHeader": 170,
    "paperFooter": 650.5,
    "printElements": [{
      "options": {
        "left": 408,
        "top": 18,
        "height": 25,
        "width": 160,
        "field": "guideNo",
        "textAlign": "center",
        "testData": "XS888888888",
        "fontSize": 8.25,
        "lineHeight": 18,
        "textType": "barcode",
        "title": "条形码",
        "right": 572.5,
        "bottom": 94,
        "vCenter": 492.5,
        "hCenter": 81.5,
        "coordinateSync": false,
        "widthHeightSync": false,
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "条形码",
        "type": "text"
      }
    },{
      "options": {
        "left":470,
        "top":56,
        "height":74,
        "width":82,
        "right":561,
        "bottom":200,
        "vCenter":519.75,
        "hCenter":165
      },
      "printElementType":{
        "title": "",
        "type": "text"
      }
    },{
      "options": {
        "left": 25.5,
        "top": 25.5,
        "height": 30,
        "width": 30,
        "right": 55.5,
        "bottom": 55.5,
        "vCenter": 40.5,
        "hCenter": 40.5,
        "src": "http://admin.ish.medmap.com.cn/img/logo.d73793ce.png",
        "fit": "",
        "coordinateSync": false,
        "widthHeightSync": false
      },
      "printElementType": {
        "title": "图片",
        "type": "image"
      }
    }, {
      "options": {
        "left": 58.5,
        "top": 31.5,
        "height": 9.75,
        "width": 138,
        "title": "青岛内分泌糖尿病医院",
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "fontWeight": "600",
        "qrCodeLevel": 0,
        "right": 196.5,
        "bottom": 40.5,
        "vCenter": 127.5,
        "hCenter": 35.625
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 57,
        "top": 43.5,
        "height": 9.75,
        "width": 187.5,
        "title": "Qingdao Endocrine and Diabetes Hospital",
        "right": 183,
        "bottom": 56.25,
        "vCenter": 123,
        "hCenter": 51.375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 228,
        "top": 90,
        "height": 9.75,
        "width": 200,
        "field": "titleName",
        "fontWeight": "bold",
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 12,
        "qrCodeLevel": 0,
        "right": 363,
        "bottom": 98.25,
        "vCenter": 295.5,
        "hCenter": 93.375
      },
      "printElementType": {
        "title": "",
        "type": "text"
      }
    },{
      "options": {
        "left": 28.5,
        "top": 120,
        "height": 9.75,
        "width": 140,
        "title": "患者",
        "field": "patientName",
        "right": 148.5,
        "bottom": 152.25,
        "vCenter": 88.5,
        "hCenter": 147.375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 217.5,
        "top": 120,
        "height": 9.75,
        "width": 140,
        "title": "证件号",
        "field": "patientCardId",
        "right": 337.74609375,
        "bottom": 152.49609375,
        "vCenter": 277.74609375,
        "hCenter": 147.62109375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 408,
        "top": 120,
        "height": 9.75,
        "width": 120,
        "title": "行动状态",
        "field": "patientActionStatus",
        "right": 528,
        "bottom": 151.5,
        "vCenter": 468,
        "hCenter": 146.625,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 142,
        "height": 9.75,
        "width": 140,
        "title": "诊疗号",
        "field": "patientNo",
        "right": 148.5,
        "bottom": 173.25,
        "vCenter": 88.5,
        "hCenter": 168.375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 217.5,
        "top": 142,
        "height": 9.75,
        "width": 140,
        "title": "类型",
        "field": "serviceType",
        "right": 337.5,
        "bottom": 167.25,
        "vCenter": 277.5,
        "hCenter": 162.375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 408,
        "top": 142,
        "height": 9.75,
        "width": 120,
        "title": "科室",
        "field": "orgName",
        "right": 529.74609375,
        "bottom": 171.24609375,
        "vCenter": 469.74609375,
        "hCenter": 166.37109375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 25.5,
        "top": 170.5,
        "height": 9.75,
        "width": 168.5,
        "title": "<span style='font-weight: bold;'>| 预约项目</span>(请按预约时间提前候诊)",
        "coordinateSync": false,
        "color": "#333333",
        "widthHeightSync": false,
        "fontSize": 9,
        "qrCodeLevel": 0,
        "right": 173.25,
        "bottom": 204.75,
        "vCenter": 99,
        "hCenter": 199.875
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    },
    {
      "options": {
        "left": 25.5,
        "top": 190.5,
        "height": 72,
        "width": 541.5,
        "field": "tableam",
        "right": 567,
        "bottom": 282.75,
        "vCenter": 296.25,
        "hCenter": 246.75,
        "fontSize": 9,
        "rowsColumnsMerge": "(row,col,colIndex,rowIndex,tableData,printData)=>{const mergeFields=['appDates','executeOrgNames'];if(mergeFields.includes(col.field)&&printData?.spanValues){const currentKey=row.appointmentDate+'_'+row.appointmentStartTime+'_'+row.appointmentEndTime+'_'+row.executeOrgNames;const isFirstRowInGroup=rowIndex===0||(tableData[rowIndex-1].appointmentDate!==row.appointmentDate)||(tableData[rowIndex-1].appointmentStartTime!==row.appointmentStartTime)||(tableData[rowIndex-1].appointmentEndTime!==row.appointmentEndTime)||(tableData[rowIndex-1].executeOrgNames!==row.executeOrgNames);if(isFirstRowInGroup){return[printData.spanValues[currentKey]||1,1];}else{return[0,1];}}else{return[1,1];}}",
        "columns": [
          [{
            "width": 541.5,
            "title": "<div style='font-weight: bold; text-align: center;'>上午</div>",
            "colspan": 4,
            "rowspan": 1,
            "checked": true,
            "align": "center",
            "titleAlign": "center",
            "headerStyle": "font-weight: bold; text-align: center;",
            "titleStyle": "font-weight: bold; text-align: center;"
          }],
          [{
            "width": 75,
            "title": "预约时间",
            "field": "appDates",
            "checked": true,
            "columnId": "appDates",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1
          }, {
            "width": 110,
            "title": "地点",
            "field": "executeOrgNames",
            "checked": true,
            "columnId": "executeOrgNames",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1
          }, {
            "width": 207,
            "title": "项目名称",
            "field": "projectNames",
            "checked": true,
            "columnId": "projectNames",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1,
            "align": "left",
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectNames+\"</div><div style='margin-bottom:5px;color:#777'>\"+row.projectMainDescribes+\"</div>\";}"
          }, {
            "width": 150,
            "title": "注意事项",
            "field": "projectCautions",
            "checked": true,
            "columnId": "projectCautions",
            "fixed": false,
            "rowspan": 1,
            "colspan": 1,
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectCautions+\"</div>\";}"
          }]
        ]
      },
      "printElementType": {
        "title": "表格",
        "type": "table",
        "editable": true,
        "columnDisplayEditable": true,
        "columnDisplayIndexEditable": true,
        "columnTitleEditable": true,
        "columnResizable": true,
        "columnAlignEditable": true,
        "isEnableEditField": true,
        "isEnableContextMenu": true,
        "isEnableInsertRow": true,
        "isEnableDeleteRow": true,
        "isEnableInsertColumn": true,
        "isEnableDeleteColumn": true,
        "isEnableMergeCell": true
      }
    }, {
        "options": {
          "left": 25.5,
          "top": 275,
          "height": 72,
          "width": 541.5,
          "field": "tablepm",
          "right": 567,
          "bottom": 282.75,
          "vCenter": 296.25,
          "hCenter": 246.75,
          "fontSize": 9,
          "rowsColumnsMerge": "(row,col,colIndex,rowIndex,tableData,printData)=>{const mergeFields=['appDates','executeOrgNames'];if(mergeFields.includes(col.field)&&printData?.spanValues){const currentKey=row.appointmentDate+'_'+row.appointmentStartTime+'_'+row.appointmentEndTime+'_'+row.executeOrgNames;const isFirstRowInGroup=rowIndex===0||(tableData[rowIndex-1].appointmentDate!==row.appointmentDate)||(tableData[rowIndex-1].appointmentStartTime!==row.appointmentStartTime)||(tableData[rowIndex-1].appointmentEndTime!==row.appointmentEndTime)||(tableData[rowIndex-1].executeOrgNames!==row.executeOrgNames);if(isFirstRowInGroup){return[printData.spanValues[currentKey]||1,1];}else{return[0,1];}}else{return[1,1];}}",
          "columns": [
            [{
              "width": 541.5,
              "title": "<div style='font-weight: bold; text-align: center;'>下午</div>",
              "colspan": 4,
              "rowspan": 1,
              "checked": true,
              "align": "center",
              "titleAlign": "center",
              "headerStyle": "font-weight: bold; text-align: center;",
              "titleStyle": "font-weight: bold; text-align: center;"
            }],
            [{
              "width": 75,
              "title": "预约时间",
              "field": "appDates",
              "checked": true,
              "columnId": "appDates",
              "fixed": false,
              "rowspan": 1,
              "colspan": 1
            }, {
              "width": 110,
              "title": "地点",
              "field": "executeOrgNames",
              "checked": true,
              "columnId": "executeOrgNames",
              "fixed": false,
              "rowspan": 1,
              "colspan": 1
            }, {
              "width": 207,
              "title": "项目名称",
              "field": "projectNames",
              "checked": true,
              "columnId": "projectNames",
              "fixed": false,
              "rowspan": 1,
              "colspan": 1,
              "align": "left",
              "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectNames+\"</div><div style='margin-bottom:5px;color:#777'>\"+row.projectMainDescribes+\"</div>\";}"
            }, {
              "width": 150,
              "title": "注意事项",
              "field": "projectCautions",
              "checked": true,
              "columnId": "projectCautions",
              "fixed": false,
              "rowspan": 1,
              "colspan": 1,
              "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectCautions+\"</div>\";}"
            }]
          ]
        },
        "printElementType": {
          "title": "表格",
          "type": "table",
          "editable": true,
          "columnDisplayEditable": true,
          "columnDisplayIndexEditable": true,
          "columnTitleEditable": true,
          "columnResizable": true,
          "columnAlignEditable": true,
          "isEnableEditField": true,
          "isEnableContextMenu": true,
          "isEnableInsertRow": true,
          "isEnableDeleteRow": true,
          "isEnableInsertColumn": true,
          "isEnableDeleteColumn": true,
          "isEnableMergeCell": true
        }
      }, {
      "options": {
        "left": 25.5,
        "top": 360,
        "height": 9.75,
        "width": 168.5,
        "title": "<span style='font-weight: bold;'>| 免预约项目</span>(随到随做)",
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 9,
        "color": "#333333",
        "qrCodeLevel": 0,
        "right": 177,
        "bottom": 321.75,
        "vCenter": 102.75,
        "hCenter": 316.875
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 25.5,
        "top": 380,
        "height": 72,
        "width": 541.5,
        "field": "ntable",
        "right": 567,
        "bottom": 399.75,
        "vCenter": 297.75,
        "hCenter": 363.75,
        "fontSize": 9,
        "rowsColumnsMerge": "(row,col,colIndex,rowIndex,tableData,printData)=>{ const mergeFields=['executeOrgNames']; if(!mergeFields.includes(col.field) || !printData?.noAppointmentSpanValues || !tableData || tableData.length === 0) {\n    return [1,1];\n  } if(mergeFields.includes(col.field)&&printData?.noAppointmentSpanValues){const currentKey='noapp_'+row.executeOrgNames || '';const isFirstRowInGroup=rowIndex===0||(tableData[rowIndex-1].executeOrgNames!==row.executeOrgNames);if(isFirstRowInGroup){const spanValue = printData.noAppointmentSpanValues[currentKey] || 1; return [spanValue, 1]; }else{return[0,1];}}else{return[1,1];}}",
        "columns": [
          [{
            "width": 160,
            "title": "地点",
            "field": "executeOrgNames",
            "checked": true,
            "columnId": "executeOrgNames",
            "rowspan": 1,
            "colspan": 1,
            "fixed": false
          },{
            "width": 211.5,
            "title": "项目名称",
            "field": "projectNames",
            "checked": true,
            "columnId": "projectNames",
            "rowspan": 1,
            "colspan": 1,
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectNames+\"</div><div style='margin-bottom:5px;color:#777777'>\"+row.projectMainDescribes+\"</div>\";}",
            "fixed": false
          }, {
            "width": 170,
            "title": "注意事项",
            "field": "projectCautions",
            "checked": true,
            "columnId": "projectCautions",
            "rowspan": 1,
            "colspan": 1,
            "renderFormatter": "function (value, row, colIndex, options, rowIndex) { return \"<div style='margin-top:5px; margin-bottom:5px;'>\"+row.projectCautions+\"</div>\";}",
            "fixed": false
          }]
        ]
      },
      "printElementType": {
        "title": "表格",
        "type": "table",
        "editable": true,
        "columnDisplayEditable": true,
        "columnDisplayIndexEditable": true,
        "columnTitleEditable": true,
        "columnResizable": true,
        "columnAlignEditable": true,
        "isEnableEditField": true,
        "isEnableContextMenu": true,
        "isEnableInsertRow": true,
        "isEnableDeleteRow": true,
        "isEnableInsertColumn": true,
        "isEnableDeleteColumn": true,
        "isEnableMergeCell": true
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 676.5,
        "height": 144,
        "width": 120,
        "title": "友情提示:",
        "right": 149.25,
        "bottom": 656.25,
        "vCenter": 89.25,
        "hCenter": 651.375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 693,
        "height": 9.75,
        "width": 411,
        "title": "1、本次预约是为了合理安排您的检查,请您按照预约时间,提前10分钟到达指定的候诊区报到,报到完成后,请耐心在候诊区静候,等待叫号;",
        "right": 439.5,
        "bottom": 672.75,
        "vCenter": 234,
        "hCenter": 667.875,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 719.5,
        "height": 9.75,
        "width": 411,
        "title": "2、为避免医疗资源浪费,预约成功后您若因故不能前往,请提前告知医护人员取消并为您重新预约;",
        "right": 438.75,
        "bottom": 690.75,
        "vCenter": 233.25,
        "hCenter": 685.875,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 736,
        "height": 9.75,
        "width": 415.5,
        "title": "3、检查或治疗完毕后,指引单将由报到处工作人员回收,感谢您的理解与配合;",
        "right": 445.5,
        "bottom": 707.25,
        "vCenter": 237.75,
        "hCenter": 702.375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 752.5,
        "height": 9.75,
        "width": 415.5,
        "title": "4、特殊情况请结合临床安排;",
        "right": 442.5,
        "bottom": 723.75,
        "vCenter": 234.75,
        "hCenter": 718.875,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    },{
      "options": {
        "left": 499.5,
        "top": 681.5,
        "height": 60,
        "width": 60,
        "field": "qrcode2",
        "testData": "XS888888888",
        "fontSize": 12,
        "lineHeight": 18,
        "textType": "qrcode",
        "title": "二维码",
        "coordinateSync": false,
        "widthHeightSync": false,
        "qrCodeLevel": 0,
        "right": 556.5,
        "bottom": 793.5,
        "vCenter": 526.5,
        "hCenter": 763.5
      },
      "printElementType": {
        "title": "二维码",
        "type": "text"
      }
    }, {
      "options": {
        "left": 498,
        "top": 747.5,
        "height": 9.75,
        "width": 66,
        "right": 562.74609375,
        "bottom": 803.49609375,
        "vCenter": 529.74609375,
        "hCenter": 798.62109375,
        "title": "扫码查看指引单",
        "coordinateSync": false,
        "widthHeightSync": false,
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    },{
      "options": {
        "left": 28.5,
        "top": 770,
        "height": 9,
        "width": 541.5
      },
      "printElementType": {
        "title": "横线",
        "type": "hline"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 779,
        "height": 9.75,
        "width": 541.5,
        "title": "青岛内分泌糖尿病医院 <img src='http://admin.ish.medmap.com.cn/img/printaddress.png' style='width:16px;height:16px;vertical-align:middle;;margin-left:5px;' />青岛市市北区合肥路760号",
        "right": 440.49609375,
        "bottom": 767.49609375,
        "vCenter": 234.99609375,
        "hCenter": 762.62109375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }, {
      "options": {
        "left": 28.5,
        "top": 795.5,
        "height": 9.75,
        "width": 541.5,
        "title": "Qingdao Endocrine and Diabetes Hospital  <img src='http://admin.ish.medmap.com.cn/img/printaddress.png' style='width:21px;height:16px;vertical-align:middle;padding-left:5px;' />760 Hefei Road,Shibei District Qingdao",
        "right": 440.49609375,
        "bottom": 785.49609375,
        "vCenter": 234.99609375,
        "hCenter": 780.62109375,
        "coordinateSync": false,
        "widthHeightSync": false,
        "fontSize": 8,
        "color": "#333333",
        "qrCodeLevel": 0
      },
      "printElementType": {
        "title": "文本",
        "type": "text"
      }
    }],
    "paperNumberLeft": 565.5,
    "paperNumberTop": 819,
    "panelLayoutOptions":{}
  }]
}

具体参考一下地址:

https://gitee.com/CcSimple/vue-plugin-hiprint/tree/main#https://gitee.com/link?target=https%3A%2F%2Fwww.ibujian.cn%2Fsvp%2F

https://gitee.com/gcloudrabbit/vue-plugin-hiprint/blob/main/src/demo/templates/template-files/template7.js

https://mdnice.com/writing/3501919cc06445599f1a12653e804233

https://blog.csdn.net/gitblog_00007/article/details/155990800

https://segmentfault.com/q/1010000045536766

【开源打印组件】vue-plugin-hiprint初体验 本文介绍对vue-plugin-hiprint部分重要代码的解析,这是一个很好的开源插件,能够自己自定义打印模板,通过后端传来的数据进行渲染打印,官方也提供了许多的api供开发者使用。界面采用了antdesign。实现了免预览的直接打印。 阅读详情

相关推荐

别再手动调打印格式了!用Vue3 + vue-plugin-hiprint,10分钟搞定一个拖拽式打印设计器

本文介绍如何利用Vue3和vue-plugin-hiprint快速构建拖拽式打印设计器,解决传统打印开发中的效率低、维护难等问题。通过10分钟集成指南和实战案例,帮助开发者实现企业级打印模板系统,提升开发效率和用户体验。

weixin_33739523的博客 162

vue 使用hiprint

6.如果有问题,可参考 gitee 的 vue-plugin-hiprint-start 也看一看hiprint 官网。5.新建一个页面,下面只是demo。3.解压放到public 目录下。废话不多,代码来一波。到此,已经可以使用了。

weixin_42556273的博客 2025

Globus科研大文件传输:从零配置到批量下载与自动化的完整指南

科研数据处理中,大文件传输与批量下载是常见的技术难点。传统HTTP协议在面对GB级乃至TB级数据时常常出现卡顿、断连,而FTP与rsync在跨机构网络环境中又受限于安全策略。分布式文件传输系统通过调度两端代理实现点对点可靠传输,兼顾安全授权与传输效率,成为科研数据分发的关键基础设施。Globus作为该领域的典型代表,以Endpoint和Collection抽象管理存储位置,通过Transfer Task任务队列实现断点续传与批量同步,支持Web面板、CLI和Python SDK自动化调用。其应用场景覆盖公开

weixin_33585822的博客 306

vue-plugin-hiprint打印插件

vue-plugin-hiprint打印插件

weixin_45765215的博客 2002

别再让C盘爆红了!手把手教你将Anaconda虚拟环境迁移到其他盘(附权限问题解决)

本文详细指导如何将Anaconda虚拟环境从C盘迁移到其他驱动器,解决C盘空间不足问题。通过conda config命令和直接修改.condarc配置文件两种方法,确保环境迁移顺利进行,同时提供权限问题解决方案和长期维护技巧,帮助用户高效管理虚拟环境。

weixin_42525289的博客 427

CANoe.DiVa的应用——生成测试用例过程流程详解(一)

Diva 生成用例过程

LOVE135149的博客 7937

10个vue-plugin-hiprint高级特性,让你的打印功能提升一个档次

vue-plugin-hiprint是一款专为Vue2/Vue3打造的强大打印插件,提供打印设计、可视化设计器、报表设计等核心功能,帮助开发者轻松实现专业级打印需求。无论是企业报表、物流单据还是各类业务表单,这款插件都能让你的打印功能体验提升到新高度。 ## 1. 可视化拖拽设计器,零代码创建打印模板 🎨 vue-plugin-hiprint提供了直观的拖拽式设计界面,让你无需编写代码就能快

gitblog_00935的博客 694

关于在线excel插件Univer笔记教程

univer在线excel插件确实是够强大,但也存在不少bug,用户用起来是真的很爽,和本地的wps差不多,但真正的开发起来是真的费劲。由于文档提供的信息不足,我们很多功能只能去看他们插件里的源代码,然后一点点测试,一点点尝试研究。此文章可省去五天的研究成本

guiplan 5836

如何快速掌握vue-plugin-hiprint:面向初学者的完整可视化打印设计教程

vue-plugin-hiprint是一款专为Vue2和Vue3开发的可视化打印设计插件,它通过直观的拖拽界面让开发者和普通用户都能轻松创建专业的打印模板。无论是制作订单表单、报表还是商品标签,这款工具都能帮助你快速完成设计并实现高质量的打印输出,大幅提升打印功能开发效率。 ## 引言与项目概述:重新定义Vue项目打印体验 在传统的Web开发中,打印功能往往是最容易被忽视但又最复杂的功能之一。

gitblog_00995的博客 105

【AutoSAR CAN】04 - 如何使用Davinci Configurator Pro工具配置CAN的波特率

改参数为Tx Arbitration start delay value ,可用于延迟仲裁过程的起始点,用来补偿CAN收发器及线路的传输延迟,以优化传输性能。有关详细信息,请参阅硬件手册。该参数指定采样点模式,即选择多少个采样点的数量,如果选择了每比特三个样本选项,则该点标记第三个样本的位置;我们要配置CAN的波特率,其实就是要弄明白 CAN 控制器的位时序即可,具体的理论部分和EB的配置部门可参考文章《该参数表示传播延迟有多少个时间单位Tq,即上文中的Propagation delay/PROGSEG。.

2615

innovus:Clock Gating Check设置与报告

看图后发现,在设置clock gating check之前报告也会有clock gating check的值,这个就是因为timing library中会像reg一样定 library setup time值,如下图。我们常用set_clock_gating_check -setup去过约束Place阶段reg2cgate的时序,以防CTS后由于tree不平导致的时序违例。我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 1031

10分钟精通Vue可视化打印:vue-plugin-hiprint实战全解析

还在为Vue项目中的打印需求而烦恼吗?传统的打印方案往往面临样式错乱、功能单一、用户体验差等痛点。vue-plugin-hiprint作为专业的Vue打印插件,通过可视化设计器和拖拽式操作,彻底解决了这些难题。本文将带你从零开始,全面掌握这款强大的可视化打印工具。 ## 核心优势解析:为什么选择vue-plugin-hiprint **可视化拖拽设计**:告别复杂的代码配置,通过直观的拖拽操作

gitblog_00007的博客 1007

PyTorch生成式人工智能(25)——基于Transformer实现机器翻译

不同于循环神经网络 (RNN) 按顺序处理数据,Transformer 以并行的方式处理输入数据(例如句子)。这种并行处理提高了效率,但并未使其能够识别输入的顺序。为了解决这个问题,Transformer 向输入的词嵌入中添加了位置编码。这些位置编码是分配给输入序列中每个位置的独特向量,其维度与输入词嵌入对齐。本节将以英语到法语的翻译为例,通过介绍如何训练 Transformer 模型将英语句子转换为法语,深入理解 Transformer 的架构及自注意力机制的运作方式。

盼小辉丶的博客 3010

15分钟掌握vue-plugin-hiprint:企业级可视化打印设计的终极解决方案

在当今企业级应用开发中,打印功能往往是业务系统不可或缺的重要组成部分,然而传统的Web打印方案常常面临样式不一致、布局复杂、维护困难等痛点。vue-plugin-hiprint作为一款基于hiprint 2.5.4深度优化的Vue打印插件,通过可视化拖拽设计、所见即所得的编辑体验,彻底解决了Web打印的诸多难题,为Vue2.x/Vue3.x项目提供了完整的打印解决方案。 ## 痛点分析与解决方案

gitblog_00286的博客 955

数据分享|1961-2017年中国0.25°×0.25° 逐日地表水文数据集(VIC-CN05.1)

其中,全球径流中心(University of New Hampshire and Global Runoff Data Centre, UNH/GRDC)的复合产流场集成了观测的河道径流和水量平衡模式模拟的地表和地下径流,常被用来评估模拟的径流。在长白山、海北灌丛和千烟洲通量站,模拟与观测的逐月潜热通量的平均NSE为0.61。VIC-CN05.1受益于较准确的大气驱动场、先进的地表水文参数化方案以及更真实丰富的土壤信息,可作为中国水文气象研究的参照数据,用于陆面模式的评估和长期的趋势分析等。

J_Giser的博客 1847

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

15分钟掌握vue-plugin-hiprint:可视化打印设计的终极解决方案

还在为Vue项目中的打印功能而烦恼吗?vue-plugin-hiprint作为一款基于hiprint 2.5.4的Vue打印插件,为你提供了完整的可视化打印设计解决方案。支持Vue2.x和Vue3.x版本,通过拖拽设计、可视化编辑、报表设计等核心功能,让打印功能开发变得前所未有的简单。无论你是需要生成简单的标签、复杂的业务单据,还是批量打印任务,这个工具库都能轻松应对。 ## 为什么需要可视化打

gitblog_00524的博客 683

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

vue-plugin-hiprint开发效率提升秘籍

最近在开发一个需要打印功能的Vue项目时,偶然发现了vue-plugin-hiprint这个好用的插件。不用操心环境配置,代码修改后立即能看到效果,还可以一键部署分享给其他人测试。整个过程非常流畅,平台已经预置了Vue开发环境,省去了本地配置的麻烦。最棒的是可以即时预览效果,边改边看。如果你也在为Vue项目的打印功能发愁,不妨试试这个组合,相信会大幅提升你的开发效率。这些工作通常要花费我至少2-3天时间,而且还经常遇到各种奇怪的bug。使用这个插件后,同样的打印功能开发时间缩短到了半天以内。

EmeraldWolf23的博客 839

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

5个高效使用vue-plugin-hiprint的终极技巧

vue-plugin-hiprint是一个专为Vue.js项目打造的可视化打印插件,基于hiprint 2.5.4核心库开发,为前端开发者提供了完整的web端打印解决方案。无论你是需要实现简单的单据打印,还是复杂的报表设计,这个插件都能满足你的需求。 ## 项目亮点与核心价值 🎯 **零依赖设计**:插件本身不依赖任何第三方UI库,可以无缝集成到各种Vue项目中 ✨ **可视化编辑**:通

gitblog_00525的博客 1096

vue-plugin-hiprint:Vue 项目可视化打印与打印模板设计的完整实战指南

本文围绕 vue-plugin-hiprint 的官方 README 展开,覆盖从 npm 安装、`print-lock.css` 打印样式配置,到拖拽式设计器、纯代码模式建模板、全局插件注册、jQuery/uniapp 环境引入的完整落地路径;并结合仓库源码(`src/index.js`、`src/hiprint/hiprint.bundle.js`、`src/hiprint/hiprint.c

gitblog_00565的博客 216

终极指南:快速掌握Vue可视化打印插件vue-plugin-hiprint

想要为你的Vue项目添加专业级的可视化打印功能吗?vue-plugin-hiprint正是你需要的完美解决方案!这个基于jQuery的强大打印插件,支持Vue2和Vue3,让你轻松实现拖拽式打印设计、报表生成和可视化编辑,为你的应用增添打印新能力。 ## 项目亮点速览 🚀 **拖拽式设计**:无需代码,通过简单拖拽即可完成复杂模板设计 🎯 **可视化编辑**:所见即所得的设计界面,实时预览

gitblog_00058的博客 457

Vue项目实战:5分钟搞定vue-plugin-hiprint打印模板自定义(附避坑指南)

本文详细介绍了如何在Vue项目中快速集成和使用vue-plugin-hiprint打印组件,实现高效的打印模板自定义。通过5分钟的实战教程,开发者可以掌握从安装配置到模板设计的全流程,并获取常见问题的避坑指南,提升开发效率。

kiwi8的博客 189

vue-plugin-hiprint使用教程【2】

/ 文件名:printProvider.ts// 移除 旧的 customModule "元素"类型, 以避免重复// 这里不可用defaultModule,以为已经被插件占用了,如果用了,会导致与默认的provider冲突// 添加 customModule "元素"类型// 如果使用 hiprint.PrintElementTypeManager.build('.hiprintEpContainer2', "customModule") 这里会渲染这个 "常规" 分组名称。

一名业余前端的博客 1万+

Vue可视化打印终极指南:hiprint插件5分钟快速上手

还在为Vue项目中的复杂打印需求而头疼吗?传统的前端打印方案往往需要编写大量CSS样式代码,调试过程繁琐且效果难以保证。vue-plugin-hiprint的出现彻底改变了这一现状,让专业级的可视化打印设计变得简单易用。作为一款专为Vue2/Vue3设计的打印插件,它通过拖拽式操作实现零代码设计体验,从简单的标签打印到复杂的企业报表都能轻松应对。 ## 痛点解析:为什么你需要专业的打印解决方案?

gitblog_00702的博客 244

Vue可视化打印设计利器:hiprint插件全面解析与实战应用

还在为Vue项目中的复杂打印需求而烦恼吗?🤔 传统的打印方案往往需要编写大量CSS样式代码,调试过程繁琐且效果难以保证。而vue-plugin-hiprint的出现,彻底革新了前端打印开发模式,让专业级的打印设计变得触手可及! ## 🎯 为什么选择hiprint作为你的打印解决方案? **技术优势深度剖析**: - **零代码设计体验**:通过拖拽式操作,无需编写任何CSS即可创建精美打印

gitblog_00600的博客 399

Vue可视化打印终极指南:从零构建专业级报表系统

vue-plugin-hiprint是一款专为Vue2/Vue3打造的强大打印插件,提供可视化设计器、报表设计、元素编辑等全方位打印解决方案,帮助开发者快速实现专业级打印功能。无论是简单的单据打印还是复杂的报表设计,这款插件都能满足你的需求。 ## 为什么选择vue-plugin-hiprint? 在Web开发中,打印功能往往是一个棘手的问题。传统的打印方案要么功能简单,无法满足复杂报表需求,

gitblog_00403的博客 470
上一篇: 微信出现config:invalid signature错误排查
下一篇: webstrom打开多个项目,webstrom常用快捷键
LittleSunny~
博客等级 码龄9年 1粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值