廖井涛
4 天以前 4955996ab044bc275ac78da3543b9d9f5ad7f8d9
north-glass-erp/northglass-erp/src/views/pp/replenish/PrintReplenishFlowCard.vue
@@ -14,16 +14,22 @@
import PrintCustomLabel from '@/components/pp/PrintRepairCustomLabel.vue'
import PrintCustomLabelSemi from '@/components/pp/PrintRepairCustomLabelSemi.vue'
import footSum from "@/hook/footSum"
import {Search} from "@element-plus/icons-vue";
import {Search, View} from "@element-plus/icons-vue";
import companyInfo from "@/stores/sd/companyInfo"
import {CircleCheck, Download, Printer} from "@element-plus/icons-vue/global";
import SortDetail from "@/components/pp/SelectSortDetailProcessCard.vue";
import {hiprint} from "vue-plugin-hiprint";
//import PrintCustomLabel from '@/components/pp/PrintCustomLabelDetails.vue'
import QueuePrinter from "@/hook/queue";
import PrintCustomLabelProject from "@/components/pp/PrintCustomLabelProject.vue";
import PrintProcessConsolidated from '@/components/pp/PrintConsolidatedReplenish.vue'
import {createTemplate} from "@/hook/createTemplateTag";
const company = companyInfo()
//语言获取
const {t} = useI18n()
let router = useRouter()
const dialogTableVisible = ref(false)
const dialogTableConsolidated = ref(false)
const dialogTableVisibleLabel = ref(false)
const dialogTableVisibleCustomLabel = ref(false)
const printVisible= ref(false)
@@ -32,8 +38,19 @@
const xGrid = ref(null)
const xGridDetail =ref(null)
const tags = ref([])
const tag = ref({
  id: null,
  name: null,
  type: 1,
  tagWidth: null,
  tagHeight: null,
  value: null,
  size: null
})
let hiprintTemplate = ref(null)
let lastList = ref([])
const getTableRow = (row,type) =>{
  switch (type) {
    case 'edit' : {
@@ -159,9 +176,13 @@
  id: 'childLabelSemi',
})
onMounted(async () => {
  await getTags();
  await hiprint.init();
})
//打印类型
const printType = ref('小片标签')
const printType = ref(t('replenish.label'))
//定义接收加载表头下拉数据
const titleSelectJson = ref({
@@ -207,6 +228,7 @@
const getWorkOrder = () => {
  let startTime = form.date1[0]
  let endTime = form.date1[1]
  gridOptions.loading=true
// 第一次加载查询
  request.post(`/Replenish/selectPrint/${startTime}/${endTime}`, filterData.value).then((res) => {
@@ -270,7 +292,6 @@
    showStatus: true
  },//表头参数
  columns: [
    {type: 'expand', fixed: "left", slots: {content: 'content'}, width: 50},
    // {title: t('basicData.operate'), width: 55, slots: { default: 'button_slot' },fixed:"left"},
    {type: 'checkbox', fixed: "left", title: t('basicData.check'), width: 80},
    {type: 'seq', fixed: "left", title: t('basicData.Number'), width: 50},
@@ -310,6 +331,7 @@
      filterMethod: filterChanged,
      width:110
    },
    {field: 'batch', width: 90, title: t('order.batch')},
    {
      field: 'order_number',
      title:  t('order.OrderNum'),
@@ -320,6 +342,8 @@
    },
    {field: 'technology_number', title: t('processCard.technologyNumber'), showOverflow: "ellipsis",
      width:90},
    {field: 'child_width', title: t('order.width'), width:90,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged,},
    {field: 'child_height', title: t('order.height'), width:90,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged,},
    {
      field: 'glassNumber',
      title: t('reportingWorks.glassNumber'),
@@ -329,24 +353,31 @@
      width:100
    },
    {field: 'glass_address', title: t('processCard.glassAddress'),
      width:110},
      width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'patch_num', title:  t('order.quantity'),
    width:70},
    {field: 'patch_area', title:  t('order.area'),width:80},
    {field: 'responsible_team', title:  t('reportingWorks.responsibleTeam'),width:110},
    {field: 'responsible_equipment', title:  t('reportingWorks.responsibleEquipment'),width:110},
    {field: 'responsible_personnel', title:  '责任信息',width:110},
    {field: 'patch_type', title:  t('reportingWorks.breakageType'),width:110},
    {field: 'patch_reason', title:  t('reportingWorks.breakageReason'),width:110},
    {field: 'patch_processes', title:  t('reportingWorks.responsibleProcess'),width:110},
    {field: 'product_name', title: t('order.product'),width:110},
    {field: 'glass_child', title: t('reportingWorks.glassChild'),width:110},
    {field: 'reporting_work_id', title: t('reportingWorks.reportingWorkId'),width:120},
    width:70,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'patch_area', title:  t('order.area'),width:80,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'responsible_team', title:  t('reportingWorks.responsibleTeam'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'responsible_equipment', title:  t('reportingWorks.responsibleEquipment'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'responsible_personnel', title:  t('rework.responsibilityInformation'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'patch_type', title:  t('reportingWorks.breakageType'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'patch_reason', title:  t('reportingWorks.breakageReason'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'patch_processes', title:  t('reportingWorks.responsibleProcess'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'product_name', title: t('order.product'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'glass_child', title: t('reportingWorks.glassChild'),width:110,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'reporting_work_id', title: t('reportingWorks.reportingWorkId'),width:120,filters: [{data: ''}],slots: {filter: 'num1_filter'}, filterMethod: filterChanged},
    {field: 'create_time', title: t('basicData.reportData'),width:120},
    {
      field: 'print_num',
      title: t('processCard.printStatus'),
       width: 120
    },
  ],//表头按钮
  toolbarConfig: {
    buttons: [
      {code: 'print', name: t('processCard.print'), status: 'primary'},
      {code: 'printConsolidated', name: t('processCard.mergePrinting'), status: 'primary'},
      {code: 'customLabel', name: t('processCard.customLabelPrinting'), status: 'primary'},
      {code: 'printLabel', name: t('processCard.labelPrinting'), status: 'primary'},
      {code: 'printLabel2', name: t('processCard.labelPrinting2'), status: 'primary'},
@@ -401,11 +432,37 @@
              technologyNumber+=selectRecords[i].technology_number
            }
          }
          printRow.value.list = JSON.stringify(selectRecords)
          printRow.value.printMergeVal=printMerge.value
          printRow.value.mergeTechnologyNumber=technologyNumber
          // router.push({path: '/main/processCard/printProcess', query: {printList: JSON.stringify(selectRecords),printMerge:printMergeVal}})
          dialogTableVisible.value=true
          break
        }
        case 'printConsolidated': {
          if(selectRecords===null ||selectRecords===''||selectRecords.length===0){
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            return
          }
          let id = ""
          let technologyNumber = ""
          for (let i = 0; i < selectRecords.length; i++) {
            if (i + 1 === selectRecords.length) {
              id += selectRecords[i].id
              technologyNumber+=selectRecords[i].technology_number
            } else {
              id += selectRecords[i].id + "|"
              technologyNumber+=selectRecords[i].technology_number
            }
          }
          printRow.value.list = JSON.stringify(selectRecords)
          printRow.value.printMergeVal=printMerge.value
          printRow.value.mergeTechnologyNumber=technologyNumber
          // router.push({path: '/main/processCard/printProcess', query: {printList: JSON.stringify(selectRecords),printMerge:printMergeVal}})
          dialogTableConsolidated.value=true
          break
        }
@@ -456,48 +513,17 @@
          break
        }
        case 'customLabel': {
          if(selectRecords===null ||selectRecords===''||selectRecords.length===0){
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
          if (tag.value.name == null || tag.value.name == '') {
            ElMessage.warning(t('replenish.printPatchesMsg1'))
            return
          }
          if (type===null||type===''||type===undefined){
            ElMessage.warning(t('processCard.pleaseSelectCustomPrintLabelStyle'))
            return
          }
          let id = ""
          for (let i = 0; i < selectRecords.length; i++) {
            if (i + 1 === selectRecords.length) {
              id += selectRecords[i].id
            } else {
              id += selectRecords[i].id + "|"
            }
          }
          if (lableTypes==1){
            labelRow.value.list=JSON.stringify(selectRecords)
            labelRow.value.faceOrientation=faceOrientation
            labelRow.value.type=type
            labelRow.value.lableType= lableTypes
            dialogTableVisibleLabel.value=true
            //router.push({path: '/main/processCard/PrintCustomLabel', query: {type:type,faceOrientation:faceOrientation,lableType:lableTypes,  printList: JSON.stringify(selectRecords)}})
          }
          else if (lableTypes==2) {
            labelRow.value.list=JSON.stringify(selectRecords)
            labelRow.value.faceOrientation=faceOrientation
            labelRow.value.type=type
            labelRow.value.lableType= lableTypes
            dialogTableVisibleCustomLabel.value=true
            //router.push({path: '/main/processCard/PrintCustomLabelSemi', query: {type:type,faceOrientation:faceOrientation,lableType:lableTypes,  printList: JSON.stringify(selectRecords)}})
          }else
          if (lableTypes==3) {
            router.push({path: '/main/processCard/PrintLabel1', query: {type:type,faceOrientation:faceOrientation,lableType:lableTypes,  printList: JSON.stringify(selectRecords)}})
          }
          labelRow.value.list = JSON.stringify(selectRecords)
          labelRow.value.type = tag.value.name
          labelRow.value.dataType = 3
          labelRow.value.lableType = 2
          labelRow.value.switch = true
          lastList.value = []
          dialogTableVisibleLabel.value = true
          break
        }
        case 'printLike': {
@@ -506,7 +532,7 @@
            return
          }
          if(printMerge.value===null ||printMerge.value===''){
            ElMessage.warning('请填入需要合并的层')
            ElMessage.warning(t('rework.msg1'))
            return
          }
@@ -673,12 +699,27 @@
  })
}
const changeTag = () => {
  hiprintTemplate.value = new hiprint.PrintTemplate({});
  hiprintTemplate.value.design("#hiprint-printTemplate1",{grid:true});
  const json = tag.value.value
  hiprintTemplate.value.update(json)
}
const getTags = () => {
  request.get('tagStyle/getTagList').then(res => {
    res.data.forEach(item => {
      item.value = JSON.parse(item.value)
    })
    tags.value = res.data
  })
}
// 监听打印完成事件
const printNumber = () =>{
  selectRecordsData.value.printList=selectRecords
  let printState=0
  request.post(`/processCard/updatePrintState/${printState}`, selectRecordsData.value).then((res) => {
  const $grid = xGrid.value
  selectRecords = $grid.getCheckboxRecords()
  request.post(`/Replenish/updatePrintNum`, selectRecords).then((res) => {
    if (res.code == 200 && res.data === true) {
    } else {
@@ -688,102 +729,122 @@
  })
}
const printOrder = (type) => {
  const list = tag.value.value
  list.panels[0].printElements.forEach(element => {
    element.options.fontFamily = 'Arial'
    if( element.options.field !== undefined){
      if(type===3 ){
        element.options.hideTitle = true
      }
    }
    if(type!==3){
      element.options.hideTitle = false
      if( element.options.field === undefined){
        element.options.hideTitle = true
      }
    }
  })
  //hiprintTemplate.value.update(list)
  let object =  JSON.parse(JSON.stringify(lastList.value))
  //判断是否为表格
  let columnsNum = null
  if(list.panels[0].printElements[0].options.field==='table'){
    object = {table:lastList.value}
    columnsNum = (list.panels[0].printElements[0].options.gridColumns || 1)
  }
  //判断是否有 嵌套自定义纸张
  if(tag.value.tagHeight && tag.value.tagWidth){
    const print =createTemplate(list,object,tag.value.tagWidth,tag.value.tagHeight)
    hiprintTemplate.value.update(print.template)
    object = print.printData
  }
  hiprintTemplate.value.print(object)
}
</script>
<template>
  <div class="main-div-customer">
    <el-date-picker
        v-model="form.date1"
        :end-placeholder="$t('basicData.endDate')"
        :start-placeholder="$t('basicData.startDate')"
        format="YYYY/MM/DD"
        type="daterange"
        value-format="YYYY-MM-DD"
  <div  style="width: 100%;height: 100%">
    <div class="head">
      <el-date-picker
          v-model="form.date1"
          :end-placeholder="$t('basicData.endDate')"
          :start-placeholder="$t('basicData.startDate')"
          format="YYYY/MM/DD"
          type="daterange"
          value-format="YYYY-MM-DD"
    />
    <el-button
        id="select"
        :icon="Search"
        type="primary" @click="getWorkOrder">{{ $t('basicData.search') }}
    </el-button>
    &nbsp;&nbsp;
<!--    <el-input clearable :placeholder="$t('processCard.mergePrinting')" v-model="printMerge" style="width: 90px"></el-input>-->
<!--    &nbsp;-->
    <label>{{$t('processCard.labelStyle')}}:</label>
    <el-select v-model="printType" clearable default-value="default_city" :placeholder="$t('processCard.pleaseSelect')" style="width: 120px">
      <el-option
          v-for="item in titleSelectJson['dataType']"
          :key="item.id"
          :label="item.name"
          :value="item.name"
      />
    </el-select>
    &nbsp;
    <el-select v-model="lableType" class="m-2" :placeholder="lableTypeOptions[0].label" style="width: 140px">
      <el-option
          v-for="item in filteredOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
      />
    </el-select>
    &nbsp;
    <el-select v-model="stateValue" class="m-2" :placeholder="$t('processCard.pleaseSelect')" clearable allow-create filterable style="width: 140px">
      <el-option
          v-for="item in stateOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
      />
    </el-select>
    <vxe-grid
        ref="xGrid"
        class="mytable-scrollbar"
        height="100%"
        v-bind="gridOptions"
        v-on="gridEvents"
      <el-button
          id="select"
          :icon="Search"
          type="primary" @click="getWorkOrder">{{ $t('basicData.search') }}
      </el-button>
      &nbsp;&nbsp;
      {{ $t('replenish.labelTemplate') }}
        <el-select v-model="tag" :placeholder="$t('replenish.listLabelTemplates')" style="width: 140px" @change="changeTag">
          <el-option
              v-for="(tag,index) in tags"
              :key="index"
              :label="tag.name"
              :value="tag"
          />
        </el-select>
    </div>
    <div class="main-table">
      <vxe-grid
          ref="xGrid"
          class="mytable-scrollbar"
          height="100%"
          v-bind="gridOptions"
          v-on="gridEvents"
    >
      <!--      @toolbar-button-click="toolbarButtonClickEvent"-->
      <!--      下拉显示所有信息插槽-->
      <template #content="{ row }">
        <ul class="expand-wrapper">
          <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
            <span style="font-weight: bold">{{ item.title + ':  ' }}</span>
            <span v-if="hasDecimal(item.field)">{{ row[item.field.split('.')[0]][item.field.split('.')[1]] }}</span>
            <span v-else>{{ row[item.field] }}</span>
      >
        <!--      @toolbar-button-click="toolbarButtonClickEvent"-->
        <!--      下拉显示所有信息插槽-->
        <template #content="{ row }">
          <ul class="expand-wrapper">
            <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
              <span style="font-weight: bold">{{ item.title + ':  ' }}</span>
              <span v-if="hasDecimal(item.field)">{{ row[item.field.split('.')[0]][item.field.split('.')[1]] }}</span>
              <span v-else>{{ row[item.field] }}</span>
          </li>
        </ul>
      </template>
            </li>
          </ul>
        </template>
      <!--左边固定显示的插槽-->
      <!--      v-if="userStore.user.permissions.indexOf('SelectProductionBasicData.edit') > -1"-->
      <template #button_slot="{ row }">
        <el-button @click="getTableRow(row,'edit')"
                   link
                   type="primary"
                   size="small">
          {{ $t('basicData.edit') }}
        </el-button>
        <!--左边固定显示的插槽-->
        <!--      v-if="userStore.user.permissions.indexOf('SelectProductionBasicData.edit') > -1"-->
        <template #button_slot="{ row }">
          <el-button @click="getTableRow(row,'edit')"
                     link
                     type="primary"
                     size="small">
            {{ $t('basicData.edit') }}
          </el-button>
      </template>
        </template>
      <template #num1_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <input type="text"
                   v-model="option.data"
                   @keyup.enter.native="$panel.confirmFilter()"
                   @input="changeFilterEvent($event, option, $panel)"/>
        <template #num1_filter="{ column, $panel }">
          <div>
            <div v-for="(option, index) in column.filters" :key="index">
              <input type="text"
                     v-model="option.data"
                     @keyup.enter.native="$panel.confirmFilter()"
                     @input="changeFilterEvent($event, option, $panel)"/>
            </div>
          </div>
        </div>
      </template>
        </template>
    </vxe-grid>
      </vxe-grid>
    </div>
    <el-dialog
        id="sizePrintCalrd"
        v-model="dialogTableVisible"
@@ -791,29 +852,25 @@
        destroy-on-close
        style="width: 75%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button v-print="printContent"   :icon="Printer" circle />
        <el-button v-print="printContent"   :icon="Printer" circle @click="printNumber"/>
      </template>
      <print-process id="child" :printList="printRow.list" :printMerge="printRow.printMergeVal" :printLike="printRow.like"
                     :mergeTechnologyNumber="printRow.mergeTechnologyNumber"
                     style="width: 100%;height: 100%" />
    </el-dialog>
    <!--    成品标签-->
    <el-dialog
        id="sizeCustom"
        v-model="dialogTableVisibleLabel"
        id="sizePrintCalrd"
        v-model="dialogTableConsolidated"
        :title="$t('processCard.print')"
        destroy-on-close
        :title="$t('processCard.printLabel')"
        style="width: 80%;height:75% ">
        style="width: 75%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button v-print="printContentLabel"   :icon="Printer" circle />
        <el-button v-print="printContent"   :icon="Printer" circle />
      </template>
      <print-custom-label id="childLabel"
                          :list="labelRow.list"
                          :faceOrientation="labelRow.faceOrientation"
                          :type="labelRow.type"
                          :lableType="labelRow.lableType"
                          style="width: 100%;height: 100%" />
      <print-process-consolidated id="child" :printList="printRow.list" :printMerge="printRow.printMergeVal" :printLike="printRow.like"
                     :mergeTechnologyNumber="printRow.mergeTechnologyNumber"
                     style="width: 100%;height: 100%" />
    </el-dialog>
    <!--   小片标签 -->
@@ -844,16 +901,57 @@
      <sort-detail id="child"  :processId="editRow.processId" :technologyNumber="editRow.technologyNumber" />
    </el-dialog>
    <el-dialog
        id="sizeCustom"
        v-model="dialogTableVisibleLabel"
        :title="$t('processCard.printLabel')"
        destroy-on-close
        style="width: 80%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-tooltip
            class="box-item"
            effect="dark"
            :content="$t('processCard.yesTitle')"
            placement="top"
        >
        <el-button :icon="Printer" circle @click="printOrder(1)"/>
        </el-tooltip>
        <el-tooltip
            class="box-item"
            effect="dark"
            :content="$t('processCard.noTitle')"
            placement="top"
        >
          <el-button @click="printOrder(3)">
            <i class="vxe-icon-print"></i>
          </el-button>
        </el-tooltip>
      </template>
      <print-custom-label id="childLabel"
                                  :detailType="labelRow.detailType"
                                  :faceOrientation="labelRow.faceOrientation"
                                  :lableType="labelRow.lableType"
                                  :lastList='lastList'
                                  :list="labelRow.list"
                                  :switch="labelRow.switch"
                                  :titleList="labelRow.titleList"
                                  :type="labelRow.type"
                                  style="width: 100%;height: 100%"/>
    </el-dialog>
  </div>
</template>
<style scoped>
.main-div-customer {
  width: 99%;
  height: 94%;
.head{
  width: 100%;
  height: 35px;
}
.main-table{
  width: 100%;
  height: calc(100% - 35px);
}
:deep(#sizeCheck .el-dialog__body){
  height: 90%;