<template>
  <!--订单打印【弹窗】-->
  <el-dialog v-model="visibie" title="生产订单打印" style="width: 40%">
    <el-row>
      <el-form-item label="订单号:" prop="currentProcess" class="mab">
        <el-input v-model="form['gdbh']"  @keydown="cp_print_ProductValue" style="width: 200px" />
      </el-form-item>
    </el-row>
    <!-- <el-row>
      <el-form-item label="印件号:" prop="yjno" class="mab" label-width="70">
        <el-select v-model="form['yjno']" placeholder="请选择印件号" style="width: 120px;" @change="getmc">
          <el-option
              v-for="item in yjlist"
              :label="item.印件号"
              :value="item.印件号"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="终止工序号:" prop="currentProcess" class="mab" label-width="100">
        <el-select v-model="form['gxh']" placeholder="请选择工序号" style="width: 120px;">
          <el-option
              v-for="item in gxlist"
              :label="item.工序号"
              :value="item.工序号"
          />
        </el-select>
      </el-form-item>
    </el-row> -->
    <!-- <el-row>
      <el-form-item label="印件名称:" prop="currentProcess" class="mab" >
        <el-input v-model="form['yjmc']" placeholder="" style="width: 500px;" />
      </el-form-item>
    </el-row>
    <el-row>
      <el-form-item label="制单:" prop="currentProcess" class="mab" label-width="70">
        <el-input v-model="form['zd']" placeholder="" style="width: 500px;" />
      </el-form-item>
    </el-row>
    <el-row>
      <el-form-item label="审核:" prop="currentProcess" class="mab" label-width="70">
        <el-input v-model="form['sh']" placeholder="" style="width: 500px;"/>
      </el-form-item>
    </el-row> -->
    <div class="dialog-footer" style="text-align: right; margin-top: 30px;">
      <el-button @click="() => visibie = false">取消</el-button>
      <el-button type="primary"  @click="cp_print_handleConfirm">确认</el-button>
    </div>

  </el-dialog>
</template>

<script setup>
import { ref, reactive } from 'vue'
import {ElMessage} from "element-plus";
import {PrintCodeList, PrintJobOrder, ProcessCodeList} from "@/api/yunyin/yunying";
import {hiprint} from "vue-plugin-hiprint";

const visibie = ref(false)
const form = reactive({})
// const id = ref()
// const yjlist = ref([])
// const gxlist = ref([])



const open = (gongdanId) => {
  // console.log(gongdanId)
  if (gongdanId == null) {
    ElMessage({type: 'warning',message: '请选择具体的工单后，再操作此功能'});
  } else {
    form['gdbh'] = gongdanId;
    visibie.value = true;
  }
    
}

//工单打印回车
const cp_print_ProductValue = async (e) => {
  
}

//{"width":88.46074598983488,"title":" 颜色","field":"ys","checked":true,"columnId":"ys","fixed":false,"rowspan":1,"colspan":1},
                
//{ "width": 156.58838324924145, "title": "条码", "field": "barcode", "checked": true, "columnId": "barcode", "fixed": false, "rowspan": 1, "colspan": 1, "tableTextType": "barcode", "barcodeType": "code128", "barcodeWidth": 2, "barcodeHeight": 100, "text": true, "textPosition": "bottom", "textAlign": "center", "fontSize": 12 },

//json打印表格数据
const jsondata =
{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":357,"paperFooter":774,"printElements":[{"options":{"left":501,"top":13.5,"height":80,"width":80,"title":"二维码","qrcodeType":"qrcode","testData":"qrcode","right":579.5,"bottom":93.5,"vCenter":539.5,"hCenter":53.5,"qrCodeLevel":0,"coordinateSync":false,"widthHeightSync":false,"field":"ewm","hideTitle":true},"printElementType":{"title":"二维码","type":"qrcode"}},{"options":{"left":120,"top":35,"height":30,"width":350,"title":"浙江达成凯锐纺织服装有限公司","right":423.75,"bottom":54,"vCenter":290.25,"hCenter":45,"coordinateSync":false,"widthHeightSync":false,"fontSize":18,"fontWeight":"bold","letterSpacing":6,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":123,"top":64.5,"height":20,"width":350,"title":"ZHE JIANG REACHING KAYO TEXTILE & GARMENTS CO LTD","right":455.25,"bottom":45.75,"vCenter":288.75,"hCenter":38.25,"coordinateSync":false,"widthHeightSync":false,"fontSize":9.75,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":67.5,"top":98.5,"height":138,"width":9,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":580,"top":98.5,"height":204,"width":9,"right":594.99609375,"bottom":302.49609375,"vCenter":590.49609375,"hCenter":200.49609375,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":12,"top":98.5,"height":9,"width":569,"borderWidth":"0.75","coordinateSync":false,"widthHeightSync":false,"right":589.25,"bottom":117.75,"vCenter":294.25,"hCenter":113.25},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":229.5,"top":99,"height":101,"width":9,"right":237.75,"bottom":185.49374771118164,"vCenter":233.25,"hCenter":140.49374771118164,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":303,"top":99,"height":65,"width":9,"right":309,"bottom":164.49374771118164,"vCenter":304.5,"hCenter":134.49374771118164,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":12,"top":99,"height":202.5,"width":9,"right":21,"bottom":301.5,"vCenter":16.5,"hCenter":200.25,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":72,"top":100.5,"height":27,"width":150,"field":"ddh","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":222,"bottom":123,"vCenter":147,"hCenter":109.5,"title":"文本"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":237,"top":100.5,"height":27,"width":52,"title":"生产款号","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":291.25,"bottom":123,"vCenter":265.25,"hCenter":109.5,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":18.5,"top":101.5,"height":27,"width":47,"title":"订单号","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":48.75,"bottom":123,"vCenter":27,"hCenter":118.125,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":312,"top":102,"height":28,"width":271.5,"right":464.25,"bottom":125.5,"vCenter":389.25,"hCenter":111.5,"field":"sckh","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"qid":"ks_1","fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":130.5,"height":9,"width":569,"borderWidth":"0.75","right":586.75,"bottom":140.49375915527344,"vCenter":301.25,"hCenter":135.99375915527344,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":72,"top":132,"height":30,"width":150,"right":221.25,"bottom":158.25,"vCenter":146.25,"hCenter":143.25,"field":"kh","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":312,"top":133.5,"height":28,"width":271.5,"right":462,"bottom":157,"vCenter":387,"hCenter":143,"field":"lhrq","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"qid":"sckh_1","fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":237,"top":135,"height":27,"width":52,"title":"落货日期","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":354.75,"bottom":149.25,"vCenter":331.5,"hCenter":144.375,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":18,"top":135,"height":27,"width":47,"title":"客户","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":37.5,"bottom":153,"vCenter":24.75,"hCenter":148.125,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":163,"height":9,"width":569,"borderWidth":"0.75","right":590,"bottom":120.75,"vCenter":295,"hCenter":116.25,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":232.5,"top":166.5,"height":31,"width":349.5,"coordinateSync":false,"widthHeightSync":false,"fontSize":12,"fontWeight":"bold","textAlign":"left","qrCodeLevel":0,"lineHeight":12.75,"right":580.5,"bottom":189,"vCenter":408,"hCenter":175.5,"field":"bz","hideTitle":true,"textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":18,"top":168,"height":27,"width":47,"title":"款式","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":39.75,"bottom":183.75,"vCenter":25.5,"hCenter":177,"fontSize":12.75,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":72,"top":168,"height":30,"width":150,"right":284.7468795776367,"bottom":189.24375915527344,"vCenter":209.74687957763672,"hCenter":174.24375915527344,"field":"ks","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"qid":"kehu_1","fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":199.5,"height":9,"width":569,"borderWidth":"0.75","right":585.25,"bottom":223.5,"vCenter":299.75,"hCenter":219,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":18,"top":202.5,"height":27,"width":47,"title":"面料","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":40.5,"bottom":212.25,"vCenter":28.5,"hCenter":207.375,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":69,"top":204,"height":30,"width":511.5,"right":586.5,"bottom":225.75,"vCenter":330.75,"hCenter":210.75,"field":"ml","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"qid":"ks_1","fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":550,"top":236,"height":66,"width":9,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":12,"top":237,"height":9,"width":569,"borderWidth":"0.75","coordinateSync":false,"widthHeightSync":false,"right":584.5,"bottom":308.49375915527344,"vCenter":299,"hCenter":303.99375915527344},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":10.5,"top":238.5,"height":25,"width":504,"title":"色码分配表","right":506.25,"bottom":263.2500057220459,"vCenter":263.25,"hCenter":249.7500057220459,"coordinateSync":false,"widthHeightSync":false,"fontSize":12,"letterSpacing":5.25,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":549,"top":246,"height":38,"width":36,"title":"合计（件）","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":567.75,"bottom":283,"vCenter":551.25,"hCenter":263,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","lineHeight":15},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":350,"top":265.5,"height":36,"width":9,"right":234,"bottom":297.75,"vCenter":229.5,"hCenter":279.75,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":475,"top":265.5,"height":36,"width":9,"right":403.74609375,"bottom":297,"vCenter":399.24609375,"hCenter":279,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":450,"top":265.5,"height":36,"width":9,"right":386.49609375,"bottom":299.25,"vCenter":381.99609375,"hCenter":281.25,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":525,"top":265.5,"height":36,"width":9,"right":528.99609375,"bottom":302.25,"vCenter":524.49609375,"hCenter":284.25,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":13.5,"top":265.5,"height":9,"width":538,"borderWidth":"0.75","coordinateSync":false,"widthHeightSync":false,"right":544.5,"bottom":270.24374198913574,"vCenter":279,"hCenter":265.74374198913574},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":425,"top":266,"height":36,"width":9,"right":372.75,"bottom":301.5,"vCenter":368.25,"hCenter":283.5,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":400,"top":266,"height":36,"width":9,"right":336,"bottom":301.5,"vCenter":331.5,"hCenter":283.5,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":375,"top":266,"height":36,"width":9,"right":301.74609375,"bottom":303,"vCenter":297.24609375,"hCenter":285,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":501.5,"top":267,"height":36,"width":9,"right":471.75,"bottom":298.5,"vCenter":467.25,"hCenter":280.5,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":249,"top":271.5,"height":13,"width":26,"title":"尺码","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":131,"bottom":278.5,"vCenter":118,"hCenter":272,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":425,"top":274.5,"height":20,"width":25,"title":"10","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_3","right":401.25,"bottom":291.5,"vCenter":386.25,"hCenter":281.5},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":400,"top":274.5,"height":20,"width":25,"title":"8","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_2","right":423.75,"bottom":293,"vCenter":408.75,"hCenter":283},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":375,"top":275,"height":20,"width":25,"title":"6","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_6","right":327,"bottom":290,"vCenter":312,"hCenter":280},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":475,"top":275,"height":20,"width":25,"title":"14","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_4","right":193.5,"bottom":44.75,"vCenter":178.5,"hCenter":34.75},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":450,"top":275,"height":20,"width":25,"title":"12","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_1","right":437.25,"bottom":287.75,"vCenter":422.25,"hCenter":277.75},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":500,"top":275,"height":20,"width":25,"title":"16","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_5","right":493.5,"bottom":191,"vCenter":478.5,"hCenter":181},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":350,"top":275,"height":20,"width":25,"title":"4","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":525,"top":275,"height":20,"width":25,"title":"18","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"cm1_7","right":552,"bottom":294.5,"vCenter":537,"hCenter":284.5},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":275.5,"height":9,"width":340,"transform":186,"borderWidth":"0.75","coordinateSync":false,"widthHeightSync":false,"right":74.24999631369556,"bottom":273.00002797246907,"vCenter":44.249996313695554,"hCenter":268.50002797246907,"borderColor":"#000000"},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":46.5,"top":283.5,"height":13,"width":26,"title":"颜色","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":40.5,"bottom":301.2500057220459,"vCenter":27,"hCenter":291.2500057220459,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":301.5,"height":9,"width":568,"borderWidth":"0.75","coordinateSync":false,"widthHeightSync":false,"right":584.25,"bottom":306.0000057220459,"vCenter":298.5,"hCenter":301.5000057220459},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":12,"top":301.5,"height":57,"width":568.5,"field":"table","groupFieldsFormatter":"function(type,options,data){ return [\"name\"] }","qid":"table","coordinateSync":false,"widthHeightSync":false,"tableFooterRepeat":"no","tableHeaderRepeat":"none","maxRows":2,"tableBodyRowHeight":36,"right":583.5,"bottom":360.75,"vCenter":299.25,"hCenter":332.25,"columns":[[
{"width":88.46074598983488,"title":" 颜色","field":"ys","checked":true,"columnId":"ys","fixed":false,"rowspan":1,"colspan":1},
{"width":87.28599085617263,"title":"订单子编号","field":"ddzbh","checked":true,"columnId":"ddzbh","fixed":false,"rowspan":1,"colspan":1},
{ "width": 156.58838324924145, "title": "条码", "field": "barcode", "checked": true, "columnId": "barcode", "fixed": false, "rowspan": 1, "colspan": 1, "tableTextType": "barcode", "barcodeType": "code128", "barcodeWidth": 2, "barcodeHeight": 100, "text": true, "textPosition": "bottom", "textAlign": "center", "fontSize": 12 },
{"width":25.024758343082915,"title":"数量1","field":"sl1","checked":true,"columnId":"sl1","fixed":false,"rowspan":1,"colspan":1},{"width":25.034512395182652,"title":"数量2","field":"sl2","checked":true,"columnId":"sl2","fixed":false,"rowspan":1,"colspan":1},{"width":25.02219252634024,"title":"数量3","field":"sl3","checked":true,"columnId":"sl3","fixed":false,"rowspan":1,"colspan":1},{"width":25.021941008649204,"title":"数量4","field":"sl4","checked":true,"columnId":"sl4","fixed":false,"rowspan":1,"colspan":1},{"width":25.03354998562632,"title":"数量5","field":"sl5","checked":true,"columnId":"sl5","fixed":false,"rowspan":1,"colspan":1},{"width":27.025335866262424,"title":"数量6","field":"sl6","checked":true,"columnId":"sl6","fixed":false,"rowspan":1,"colspan":1},{"width":23.024360602094333,"title":"数量7","field":"sl7","checked":true,"columnId":"sl7","fixed":false,"rowspan":1,"colspan":1},{"width":26.021330551877316,"title":"数量8","field":"sl8","checked":true,"columnId":"sl8","fixed":false,"rowspan":1,"colspan":1},{"width":29.089528765741086,"title":"合计","field":"hj","checked":true,"columnId":"hj","fixed":false,"rowspan":1,"colspan":1}]]},"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":12,"top":351,"height":364,"width":12,"coordinateSync":false,"widthHeightSync":false,"right":24.75,"bottom":695.99609375,"vCenter":20.25,"hCenter":520.99609375},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":580,"top":357,"height":358,"width":9,"coordinateSync":false,"widthHeightSync":false,"right":588.75,"bottom":711,"vCenter":584.25,"hCenter":529.5},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":18,"top":376.5,"height":20,"width":40,"right":102.25,"bottom":394.25,"vCenter":82.25,"hCenter":384.25,"field":"yq","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0,"hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":402,"height":9,"width":569,"borderWidth":"0.75","coordinateSync":false,"widthHeightSync":false,"right":579.25,"bottom":396.75,"vCenter":293.75,"hCenter":392.25},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":18,"top":409.5,"height":20,"width":40,"right":103.75,"bottom":425.75,"vCenter":83.75,"hCenter":415.75,"field":"gx","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"yq_1","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":435.5,"height":9,"width":569,"borderWidth":"0.75","right":584.5,"bottom":469.5,"vCenter":299,"hCenter":465,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":67.5,"top":436.5,"height":43,"width":9,"right":76.5,"bottom":459.75,"vCenter":72,"hCenter":444.75,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":540,"top":436.5,"height":43,"width":9,"right":549,"bottom":474.25,"vCenter":544.5,"hCenter":452.75,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":76.5,"top":442.5,"height":30,"width":166.5,"coordinateSync":false,"widthHeightSync":false,"fontSize":12,"fontWeight":"bold","textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":199.5,"bottom":468.75,"vCenter":139.5,"hCenter":453.75,"field":"cy","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":541.5,"top":444,"height":28,"width":37.5,"field":"cys","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":582,"bottom":467.5,"vCenter":563.25,"hCenter":453.5,"qid":"zhj_1","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":21,"top":448.5,"height":20,"width":40,"title":"船样","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":58.75,"bottom":465.5,"vCenter":38.75,"hCenter":455.5},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":540,"top":477,"height":239,"width":9,"right":549,"bottom":504,"vCenter":544.5,"hCenter":490.5,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"竖线","type":"vline"}},{"options":{"left":12,"top":478.5,"height":9,"width":569,"borderWidth":"0.75","right":588.25,"bottom":489,"vCenter":302.75,"hCenter":484.5,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":102,"top":480,"height":232.5,"width":325.5,"right":426,"bottom":710.25,"vCenter":263.25,"hCenter":594,"field":"tupian","fit":"","coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"图片","type":"image"}},{"options":{"left":543,"top":684,"height":20,"width":37.5,"field":"zhj","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":579.75,"bottom":704,"vCenter":561,"hCenter":694,"qid":"hj_1","hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":12,"top":715,"height":9,"width":569,"borderWidth":"0.75","right":586,"bottom":723.75,"vCenter":300.5,"hCenter":719.25,"coordinateSync":false,"widthHeightSync":false},"printElementType":{"title":"横线","type":"hline"}},{"options":{"left":424.5,"top":724.5,"height":15,"width":40,"title":"日期：","right":463,"bottom":741,"vCenter":443,"hCenter":733.5,"coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":370.5,"top":724.5,"height":15,"width":40,"right":410.5,"bottom":738.75,"vCenter":390.5,"hCenter":731.25,"field":"sh","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0,"hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":468,"top":724.5,"height":15,"width":100,"right":567.25,"bottom":739.5,"vCenter":517.25,"hCenter":732,"field":"rq","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0,"hideTitle":true},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":330,"top":724.5,"height":15,"width":40,"title":"审核：","right":370,"bottom":739.5,"vCenter":350,"hCenter":732,"coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"left","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"这是更新后的元素","type":"text"}}],"paperNumberLeft":565.5,"paperNumberTop":819,"paperNumberContinue":true,"watermarkOptions":{"content":"vue-plugin-hiprint","rotate":25,"timestamp":true,"format":"YYYY-MM-DD HH:mm"},"panelLayoutOptions":{}}]}

hiprint.init()
const hiprintTemplate = new hiprint.PrintTemplate({ template: jsondata })
const _gdlx = ref('')
// 工单打印确认按钮
const cp_print_handleConfirm = async () => {
  let params = {};
  // params.workOrder = form['gdbh'];
  //调用打印接口【打印作业通知单】
  // const print_PrintJobOrder = await PrintJobOrder(params);
  // console.log(print_PrintJobOrder)
  // if(print_PrintJobOrder.data === null || print_PrintJobOrder.data === undefined || print_PrintJobOrder.data === ''){
  //   ElMessage({type: 'error',message: print_PrintJobOrder.msg});
  //   return false;
  // }

  const workOrderDetaildata = [
		{

      '颜色':'红色',
      '订单子编号':'2408001-1',
      'name':'2408001-1',
      '数量1':'10',
      '数量2':'20',
      '数量3':'30',
      '数量4':'20',
      '数量5':'50',
      '数量6':'40',
      '数量7':'70',
      '数量8':'50',
      '合计':'290',
		},
		{
      '颜色':'蓝色',  
      'name':'2408001-2',
      '订单子编号':'2408001-2',
      '数量1':'50',
      '数量2':'45',
      '数量3':'65',
      '数量4':'25',
      '数量5':'55',
      '数量6':'10',
      '数量7':'20',
      '数量8':'30',
      '合计':'300',
		},
	];

  // 获取当前日期
  const today = new Date();
  const year = today.getFullYear();
  const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始，需要补零
  const day = String(today.getDate()).padStart(2, '0');
  const hours = String(today.getHours()).padStart(2, '0');
  const minutes = String(today.getMinutes()).padStart(2, '0');
  const seconds = String(today.getSeconds()).padStart(2, '0');
  const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  const currentDates = `${year}-${month}-${day}`;

  const printdata  = {
    'ewm':form['gdbh'],
    "ddh":form['gdbh'],
    "sckh":'2401-1622款',
    "kh":'DC-7',
    "lhrq":'2024-07-16',
    "ks":'连衣裙',
    "bz": 'MA开头的挂装出货,其它折装。MA01单可增加2%，其它全部不可多不可少。',
    "ml":  '弹力涤布里布:假捻丝缎面',

  'table': workOrderDetaildata.map(item => ({
        'ys': item['颜色'],
        'ddzbh': item['订单子编号'],
        'barcode': item['name'],
        'sl1': item['数量1'],
        'sl2': item['数量2'],
        'sl3': item['数量3'],
        'sl4': item['数量4'],
        'sl5': item['数量5'],
        'sl6': item['数量6'],
        'sl7': item['数量7'],
        'sl8': item['数量8'],
        'hj': item['合计'],
      })),

    "yq":'',
    "gx":'',
    "cy":'8码/3件,10码1件',
    "cys":'4',
    "tupian": "http://xq.lhra.top/assets/img/yifu.png",
    "zhj":'594',
    "shr":'',
    "rq":currentDates,

  }
  console.log(printdata)
  hiprintTemplate.print(printdata);

  // hiprintTemplate.print(printdata);
  // cp_print_gdlist.value = false;
}

defineExpose({ open })
</script>

<style scoped>
:deep(.el-table td .cell) {
  line-height: 20px !important;
}
:deep(.el-tabs__header){
  margin-bottom: 0;
}
.search{
  margin-left: 0px !important;
  margin-right: 10px !important;
}
.bt{
  margin-left: 2px !important;
  padding: 3px !important;
  font-size: 12px;
}
.el-tabs__header{
  margin: 0px !important;
}
.gva-table-box{
  padding: 0px !important;
}
.el-pagination{
  margin-top: 0px !important;
}
.mab{
  margin-bottom: 5px;
}
</style>
