廖井涛
2024-11-22 1c5bdd46d4d8b71fd3dc7bbfb2331d9281305ec4
north-glass-erp/northglass-erp/src/views/pp/processCard/PrintProjectDetails.vue
@@ -21,6 +21,9 @@
import companyInfo from "@/stores/sd/companyInfo"
import {CircleCheck, Download, Printer} from "@element-plus/icons-vue/global";
import TagStyleDesigner from "@/components/pp/TagStyleDesigner.vue";
import {hiprint} from "vue-plugin-hiprint";
import QueuePrinter from "@/hook/queue"
import TagStyleSet from "@/hook/tagStyleSet";
const company = companyInfo()
@@ -45,11 +48,15 @@
const xGrid = ref(null)
const xGridDetail = ref(null)
const tags = ref([])
const tagType = ref()
//排序
let editRow = ref({
  processId: null,
  technologyNumber: null,
  process:null
  process: null
})
//打印
@@ -65,107 +72,48 @@
  faceOrientation: null,//内外面
  type: null,//标签模板
  lableType: null,//标签类型
  dataType: null//标签类型
  dataType: null,//标签类型
  detailType: 0//是否是工程明细打印
})
const getTableRow = (row, type) => {
  switch (type) {
    case 'edit' : {
      editRow.value.processId = row.process_id
      editRow.value.technologyNumber = row.technology_number
      editRow.value.process = row.process
      printVisible.value = true
onMounted(async () => {
  await getTags();
  await hiprint.init();
})
let hiprintTemplate = ref()
      // router.push({path: '/sort-detail', query: {processId: row.process_id,technologyNumber:row.technology_number}})
      break
    }
  }
const changeTag = () => {
  hiprintTemplate.value = new hiprint.PrintTemplate({});
  const json = JSON.parse(tag.value.value)
  hiprintTemplate.value.update(json)
}
//筛选条件,有外键需要先定义明细里面的数据
let filterData = ref({
  orderGlassDetail: {
    productionId: '',
  },
  orderDetail: {
    orderId: '',
    productId: '',
    productName: '',
  }
const tag = ref({
  id: null,
  name: null,
  type: 1,
  tagWidth: null,
  tagHeight: null,
  value: null,
  size: null
})
//定义页面总页数
let pageTotal = ref('')
//定义数据返回结果
let produceList = ref([])
//定义数据返回结果
let produceDetailList = ref([])
//定义当前页数
let pageNum = $ref(1)
let pageState = null
//室内室外面
const stateValue = ref('')
const stateOptions = [
  {
    value: t('processCard.thisIsTheIndoorSurface'),
    label: t('processCard.thisIsTheIndoorSurface'),
  },
  {
    value: t('processCard.thisSideIsOutsideTheRoom'),
    label: t('processCard.thisSideIsOutsideTheRoom'),
  },
]
//标签类型
let filteredOptions = []
const lableType = ref('1')
const lableTypeOptions = [
  {
    value: '1',
    label: t('processCard.finishedProductLabel'),
  },
  /*  {
      value: '2',
      label: t('processCard.halfProductLabel'),
    },*/
  {
    value: `${company.printLabel.labelValue}`,
    label: `${company.printLabel.labelType}`,
  },
  {
    value: `${company.printLabel.labelValue3}`,
    label: `${company.printLabel.labelType3}`,
  },
]
let hidePrintLabels = company.printLabel.hideButton;
if (hidePrintLabels == 'true') {
  filteredOptions = lableTypeOptions.filter((option, index) => index !== 2);
} else {
  filteredOptions = lableTypeOptions;
}
//合片流程卡打印下拉选项
const printMerge = ref('')
const printMergeOptions = [{}]
const printContent = ref({
  id: 'child',
})
const printContentLabel = ref({
  id: 'childLabel',
})
const printContentLabelSemi = ref({
  id: 'childLabelSemi',
})
//打印类型
const printType = ref()
@@ -179,6 +127,12 @@
  printList: []
})
const getTags = () => {
  request.get('tagStyle/getTagList').then(res => {
    tags.value = res.data
  })
}
const {currentRoute} = useRouter()
const route = currentRoute.value
@@ -190,7 +144,6 @@
  if (res.code == 200) {
    xGrid.value.loadData(res.data.data)
    gridOptions.loading = false
    hideButton()
  } else {
    ElMessage.warning(res.msg)
  }
@@ -233,7 +186,7 @@
    useKey: true
  },
  filterConfig: {   //筛选配置项
    // remote: true
                    // remote: true
  },
  customConfig: {
    storage: true
@@ -272,13 +225,8 @@
  toolbarConfig: {
    buttons: [
      {code: 'printLabel3', name: t('processCard.finishedProductPrinting2'), status: 'primary'},
      // {code: 'printLike', name: "同配置打印", status: 'primary'},
      {code: 'printLabel3', name: t('basicData.print'), status: 'primary'},
    ],
    // import: false,
    // export: true,
    //print: true,
    zoom: true,
    custom: true
  },
@@ -298,273 +246,41 @@
      })
    ]
  },
})
const gridEvents = {
  toolbarButtonClick({code}) {
    const $grid = xGrid.value
    selectRecords = $grid.getCheckboxRecords()
    // selectRecords.forEach(obj => {
    //   delete obj.print_status;
    // });
    let type = printType.value
    let faceOrientation = stateValue.value
    let faceOrientation = ''
    let lableTypes = lableType.value
    let lableTitle = lableType.text
    if ($grid) {
      switch (code) {
        case 'print': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            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 + "|"
            }
          }
          printRow.value.list = JSON.stringify(selectRecords)
          printRow.value.printMergeVal = printMerge.value
          printRow.value.like = null
          // router.push({path: '/main/processCard/printProcess', query: {printList: JSON.stringify(selectRecords),printMerge:printMergeVal}})
          dialogTableVisible.value = true
          break
        }
        case 'printLabel': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            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 + "|"
            }
          }
          router.push({
            path: '/main/processCard/PrintLabel',
            query: {printList: JSON.stringify(selectRecords),printType:2}
          })
          break
        }
        case 'printLabel2': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            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 + "|"
            }
          }
          router.push({
            path: '/main/processCard/PrintCustomLabelSemi2',
            query: {printList: JSON.stringify(selectRecords),printType:2}
          })
          break
        }
        case 'sort': {
          const $table = xGridDetail.value
          let data = $table.getTableData().fullData
          let flowCardData = ref({
            flowCard: data,
          })
          for (let i = 0; i < flowCardData.value.flowCard.length; i++) {
            const regex = /^[1-9]\d*$/
            if (!regex.test(flowCardData.value.flowCard[i].sort)) {
              ElMessage.warning(t('basicData.msg.greater0'))
              return; // 如果有一个不是整数
            }
          }
          request.post("/processCard/printSort", flowCardData.value).then((res) => {
            if (res.code == 200) {
              ElMessage.success(t('processCard.sortingSuccessful'))
              router.push({
                path: '/main/processCard/PrintFlowCard',
                query: {orderId: orderId, random: Math.random()}
              })
              //location.reload();
            } else {
              ElMessage.warning(res.msg)
            }
          })
          break
        }
        case 'customLabel': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            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
            lastList.value = []
            if (company.label === 1) {
              dialogTableVisibleLabel.value = true
            } else if (company.label === 2) {
              router.push({
                path: '/main/processCard/PrintCustomLabelCZ',
                query: {
                  type: type,
                  faceOrientation: faceOrientation,
                  lableType: lableTypes,
                  printList: JSON.stringify(selectRecords),
                  printType:2
                }
              })
            }
          } else if (lableTypes == 2) {
            labelRow.value.list = JSON.stringify(selectRecords)
            labelRow.value.faceOrientation = faceOrientation
            labelRow.value.type = type
            labelRow.value.lableType = lableTypes
            lastList.value = []
            if (company.label === 1) {
              dialogTableVisibleCustomLabel.value = true
            } else if (company.label === 2) {
              router.push({
                path: '/main/processCard/PrintCustomLabelSemiCZ',
                query: {
                  type: type,
                  faceOrientation: faceOrientation,
                  lableType: lableTypes,
                  printList: JSON.stringify(selectRecords),
                  printType:2
                }
              })
            }
          } else if (lableTypes == 3) {
            router.push({
              path: '/main/processCard/PrintLabel1',
              query: {
                type: type,
                faceOrientation: faceOrientation,
                lableType: lableTypes,
                printList: JSON.stringify(selectRecords),
                printType:2
              }
            })
          }
          break
        }
        case 'printLike': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            return
          }
          if (printMerge.value === null || printMerge.value === '') {
            ElMessage.warning('请填入需要合并的层')
            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 + "|"
            }
          }
          printRow.value.list = JSON.stringify(selectRecords)
          printRow.value.printMergeVal = printMerge.value
          printRow.value.like = "1"
          // router.push({path: '/main/processCard/printProcess', query: {printList: JSON.stringify(selectRecords),printMerge:printMergeVal}})
          dialogTableVisible.value = true
          break
        }
        case 'printTest': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('searchOrder.msgList.checkOrder'))
            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 + "|"
            }
          }
          labelRow.value.list = JSON.stringify(selectRecords)
          labelRow.value.faceOrientation = faceOrientation
          labelRow.value.type = type
          labelRow.value.lableType = lableTypes
          titleStyleVisible.value = true
          break
        }
        case 'printLabel3': {
          if (selectRecords === null || selectRecords === '' || selectRecords.length === 0) {
            ElMessage.warning(t('请选择工程对应的版图号'))
            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 (tag.value.name == null || tag.value.name == '') {
            ElMessage.warning(t('请选择标签模板'))
            return
          }
          let name=company.companyName
          let name = company.companyName
          labelRow.value.list = JSON.stringify(selectRecords)
          if (name == '金华福喜天成玻璃有限公司'){
            labelRow.value.type = '成品标签'
            labelRow.value.dataType=3
          if (name == '新疆恒鑫玻璃科技有限公司') {
            labelRow.value.type = '恒鑫带数量'
            labelRow.value.dataType = 3
            dialogTableVisibleLabelXJTwo.value = true
          } else {
            labelRow.value.type = tag.value.name
            labelRow.value.dataType = 3
            labelRow.value.lableType = lableTypes
            labelRow.value.switch = true
            lastList.value = []
            dialogTableVisibleLabelProject.value = true
          }
          else {
            labelRow.value.type = '恒鑫带数量'
            labelRow.value.dataType=3
            dialogTableVisibleLabelXJTwo.value = true
          }
          break
        }
      }
@@ -573,44 +289,25 @@
}
const openedTable = () => {
  let detail = ref(produceDetailList.value)
  xGridDetail.value.reloadData(detail.value)
  addListener(xGridDetail.value, detailGridOptions)
}
const hideButton = () => {
  // 根据条件值 hidePrintLabels 过滤按钮数组
  gridOptions.toolbarConfig.buttons = gridOptions.toolbarConfig.buttons.filter(button => {
    // 这里根据 hidePrintLabels 的值决定是否隐藏 printLabel 和 printLabel2
    if (hidePrintLabels == 'true') {
      return button.code !== 'printLabel' && button.code !== 'printLabel2';
    } else {
      return true && button.code !== 'printLike' && button.code !== 'printLabel3'&& button.code !== 'printTest'; // 显示该按钮
    }
  })
}
// 监听打印完成事件
const printNumber = () => {
  selectRecordsData.value.printList = selectRecords
  let printState = 0
  request.post(`/processCard/updatePrintState/${printState}`, selectRecordsData.value).then((res) => {
    if (res.code == 200 && res.data === true) {
    } else {
      ElMessage.warning(t('basicData.msg.saveFail'))
    }
  })
const printObjectProcess = () => {
  hiprintTemplate.value.print(lastList.value)
}
</script>
<template>
  <div class="main-div-customer">
    <div>
      标签模板:
      <el-select v-model="tag" placeholder="标签模板列表" style="width: 140px" @change="changeTag">
        <el-option
            v-for="(tag,index) in tags"
            :key="index"
            :label="tag.name"
            :value="tag"
        />
      </el-select>
    </div>
    <vxe-grid
        ref="xGrid"
        class="mytable-scrollbar"
@@ -633,130 +330,19 @@
        </ul>
      </template>
      <!--左边固定显示的插槽-->
      <!--      v-if="userStore.user.permissions.indexOf('SelectProductionBasicData.edit') > -1"-->
      <template #button_slot="{ row }">
        <el-button link
                   size="small"
                   type="primary"
                   @click="getTableRow(row,'edit')">
          {{ $t('basicData.edit') }}
        </el-button>
      </template>
      <template #num1_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <input v-model="option.data"
                   type="text"
                   @keyup.enter.native="$panel.confirmFilter()"
                   @input="changeFilterEvent($event, option, $panel)"/>
                   @input="changeFilterEvent($event, option, $panel)"
                   @keyup.enter.native="$panel.confirmFilter()"/>
          </div>
        </div>
      </template>
    </vxe-grid>
    <!--  流程卡打印  -->
    <el-dialog
        id="sizePrintCalrd"
        v-model="dialogTableVisible"
        :title="$t('processCard.print')"
        destroy-on-close
        style="width: 75%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button v-print="printContent" :icon="Printer" circle @click="printNumber"/>
      </template>
      <print-process
          id="child"
          :printLike="printRow.like"
          :printList="printRow.list"
          :printMerge="printRow.printMergeVal"
          style="width: 100%;height: 100%"/>
    </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-button v-print="printContentLabel" :icon="Printer" circle/>
      </template>
      <print-custom-label id="childLabel"
                          :lastList = 'lastList'
                          :faceOrientation="labelRow.faceOrientation"
                          :lableType="labelRow.lableType"
                          :list="labelRow.list"
                          :type="labelRow.type"
                          style="width: 100%;height: 100%"/>
    </el-dialog>
    <!--   小片标签 -->
    <el-dialog
        id="sizeCustomSemi"
        v-model="dialogTableVisibleCustomLabel"
        :title="$t('processCard.labelStyle')"
        destroy-on-close
        style="width: 80%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button v-print="printContentLabelSemi" :icon="Printer" circle/>
      </template>
      <print-custom-label-semi id="childLabelSemi"
                               :faceOrientation="labelRow.faceOrientation"
                               :lableType="labelRow.lableType"
                               :list="labelRow.list"
                               :type="labelRow.type"
                               style="width: 100%;height: 100%"/>
    </el-dialog>
    <!--    排序-->
    <el-dialog
        id="sizeCheck"
        v-model="printVisible"
        :title="$t('processCard.processCardDetails')"
        destroy-on-close
        style="width: 80%;height:75% ">
      <sort-detail id="child" :processId="editRow.processId" :technologyNumber="editRow.technologyNumber" :process="editRow.process"/>
    </el-dialog>
    <!--   标签样式    -->
    <el-dialog
        id="titleStyle"
        :title="$t('processCard.labelStyle')"
        style="width: 90%;height:93%;margin-top: 3vh "
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        destroy-on-close
        v-model="titleStyleVisible">
      <!--      <tag-style style="width: 100%;height: 100%"/>-->
      <tag-style-designer style="width: 100%;height: 100%"
                          :faceOrientation="labelRow.faceOrientation"
                          :lableType="labelRow.lableType"
                          :list="labelRow.list"
                          :type="labelRow.type"/>
    </el-dialog>
    <!--    成品标签两列-->
    <el-dialog
        id="sizeCustom"
        v-model="dialogTableVisibleLabelXJ"
        :title="$t('processCard.printLabel')"
        destroy-on-close
        style="width: 80%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button v-print="printContentLabel" :icon="Printer" circle/>
      </template>
      <print-custom-label-x-j id="childLabel"
                              :faceOrientation="labelRow.faceOrientation"
                              :lableType="labelRow.lableType"
                              :list="labelRow.list"
                              :type="labelRow.type"
                              style="width: 100%;height: 100%"/>
    </el-dialog>
    <!--    成品标签两列新疆-->
    <el-dialog
@@ -769,12 +355,12 @@
        <el-button v-print="printContentLabel" :icon="Printer" circle/>
      </template>
      <print-custom-label-x-j-two id="childLabel"
                              :faceOrientation="labelRow.faceOrientation"
                              :lableType="labelRow.lableType"
                              :list="labelRow.list"
                              :type="labelRow.type"
                              :dataType="labelRow.dataType"
                              style="width: 100%;height: 100%"/>
                                  :dataType="labelRow.dataType"
                                  :faceOrientation="labelRow.faceOrientation"
                                  :lableType="labelRow.lableType"
                                  :list="labelRow.list"
                                  :type="labelRow.type"
                                  style="width: 100%;height: 100%"/>
    </el-dialog>
    <!--    成品标签工程打印-->
@@ -785,14 +371,20 @@
        destroy-on-close
        style="width: 80%;height:75% ">
      <template #header="{ close, titleId, titleClass }">
        <el-button v-print="printContentLabel" :icon="Printer" circle/>
        <el-button :icon="Printer" circle @click="printObjectProcess"/>
      </template>
      <print-custom-label-project id="childLabel"
                          :faceOrientation="labelRow.faceOrientation"
                          :lableType="labelRow.lableType"
                          :list="labelRow.list"
                          :type="labelRow.type"
                          style="width: 100%;height: 100%"/>
                                  :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>