廖井涛
2024-06-26 c46cb6a71c35f38c7f23a2d01ad686f46a3d0e0b
north-glass-erp/northglass-erp/src/views/pp/processCard/PrintFlowCard.vue
@@ -1,165 +1,647 @@
<script setup>
import {ArrowLeftBold} from "@element-plus/icons-vue";
import {useRouter} from "vue-router";
import {reactive} from "vue";
const router = useRouter()
let flag = $ref(true)
function intoCreateProduct(){
  if(flag){
    router.push('/main/processCard/SelectPrintFlowCard')
  }else {
    router.push('/main/processCard/SelectPrintFlowCard')
import request from "@/utils/request"
import deepClone from "@/utils/deepClone"
import {ElDatePicker, ElMessage} from "element-plus"
import {nextTick, onMounted, onUnmounted, reactive, ref, watch} from "vue"
import {useRouter} from 'vue-router'
import {useI18n} from 'vue-i18n'
import {changeFilterEvent, filterChanged} from "@/hook"
import {VXETable} from "vxe-table";
import {addListener, toolbarButtonClickEvent} from "@/hook/mouseMove";
import PrintProcess from '@/views/pp/processCard/PrintProcess.vue'
import PrintLabel from '@/views/pp/processCard/PrintLabel.vue'
import PrintCustomLabel from '@/views/pp/processCard/PrintCustomLabel.vue'
import footSum from "@/hook/footSum"
//语言获取
const {t} = useI18n()
let router = useRouter()
const dialogTableVisible = ref(false)
const dialogTableVisibleLabel = ref(false)
const dialogTableVisibleCustomLabel = ref(false)
const printVisible= ref(false)
let selectRecords = ref(null)
const xGrid = ref(null)
const xGridDetail =ref(null)
const getTableRow = (row,type) =>{
  switch (type) {
    case 'edit' :{
      request.post(`/processCard/printFlowCardDetails/${row.process_id}/${row.technology_number}`,filterData.value).then((res) => {
        if (res.code == 200) {
          produceDetailList.value = (res.data.data)
          printVisible.value=true
        } else {
          ElMessage.warning(res.msg)
        }
      })
      break
    }
  }
  flag=!flag
}
function openPrint() {
  this.$router.push('/page');
}
const form = reactive({
  name: '',
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
//筛选条件,有外键需要先定义明细里面的数据
let filterData = ref({
  orderGlassDetail: {
    productionId: '',
  },
  orderDetail: {
    orderId: '',
    productId: '',
    productName: '',
  }
})
const tableData = [
//定义页面总页数
let pageTotal = ref('')
//定义数据返回结果
let produceList = ref([])
//定义数据返回结果
let produceDetailList = ref([])
//定义当前页数
let pageNum = $ref(1)
let pageState = null
//室内室外面
const stateValue = ref('')
const stateOptions = [
  {
    salesOrderNo: 'NG231201',
    productionOrderNo:'NG231201A',
    processCard: 'NG231201A01',
    customerName:'西安高科幕墙门窗有限公司',
    entryName:'银隆广场',
    sliceMarking:'(外)',
    marking:'1',
    pieces:'16',
    area:'24.14',
    productName: '10mm超白UD60平钢(外)+12Ar(结)+10mm超白平钢(内)',
    singlePieceName: '10mm超白UD60平钢(外)',
    floorNumber: '16-BSGB05',
    divider: '普形',
    splittingTime: '2023-01-11',
    notes: '',
    value: t('processCard.thisIsTheIndoorSurface'),
    label: t('processCard.thisIsTheIndoorSurface'),
  },
  {
    salesOrderNo: 'NG231201',
    productionOrderNo:'NG231201A',
    processCard: 'NG231201A01',
    customerName:'西安高科幕墙门窗有限公司',
    entryName:'银隆广场',
    sliceMarking:'(内)',
    marking:'2',
    pieces:'16',
    area:'24.14',
    productName: '10mm超白UD60平钢(外)+12Ar(结)+10mm超白平钢(内)',
    singlePieceName: '10mm超白平钢(内)',
    floorNumber: '16-BSGB05',
    divider: '普形',
    splittingTime: '2023-01-11',
    notes: '',
    value: t('processCard.thisSideIsOutsideTheRoom'),
    label: t('processCard.thisSideIsOutsideTheRoom'),
  },
  {
    salesOrderNo: 'NG231201',
    productionOrderNo:'NG231201A',
    processCard: 'NG231201A02',
    customerName:'西安高科幕墙门窗有限公司',
    entryName:'银隆广场',
    sliceMarking:'(外)',
    marking:'1',
    pieces:'6',
    area:'24.14',
    productName: '10mm超白UD60平钢(外)+12Ar(结)+10mm超白平钢(内)',
    singlePieceName: '10mm超白UD60平钢(外)',
    floorNumber: '16-BSGB05',
    divider: '普形',
    splittingTime: '2023-01-11',
    notes: '',
  },
  {
    salesOrderNo: 'NG231201',
    productionOrderNo:'NG231201A',
    processCard: 'NG231201A02',
    customerName:'西安高科幕墙门窗有限公司',
    entryName:'银隆广场',
    sliceMarking:'(内)',
    marking:'2',
    pieces:'6',
    area:'24.14',
      productName: '10mm超白UD60平钢(外)+12Ar(结)+10mm超白平钢(内)',
    singlePieceName: '10mm超白平钢(内)',
    floorNumber: '16-BSGB05',
    divider: '普形',
    splittingTime: '2023-01-11',
    notes: '',
  },
  function openNewWindow() {
    window.open('/main/processCard/PrintProcess');
  }
]
//室内室外面
const lableType = ref('1')
const lableTypeOptions = [
  {
    value: '1',
    label: t('processCard.finishedProductLabel'),
  },
  {
    value: '2',
    label: t('processCard.halfProductLabel'),
  },
]
//合片流程卡打印下拉选项
const printMerge = ref('')
const printMergeOptions=[{}]
//打印类型
const printType = ref()
//定义接收加载表头下拉数据
const titleSelectJson = ref({
  dataType: [],
})
const {currentRoute} = useRouter()
const route = currentRoute.value
let orderId = route.query.orderId
// 第一次加载查询
request.post(`/processCard/selectPrint/${orderId}`, filterData.value).then((res) => {
  if (res.code == 200) {
    produceList = produceList.value.concat(deepClone(res.data.data))
    titleSelectJson.value.dataType = res.data.type
    xGrid.value.reloadData(produceList)
    gridOptions.loading = false
  } else {
    ElMessage.warning(res.msg)
  }
})
//表尾求和
const sumNum = (list, field) => {
  let count = 0
  list.forEach(item => {
    count += Number(item[field])
  })
  return count.toFixed(2)
}
const hasDecimal = (value) => {
  const regex = /\./; // 定义正则表达式,查找小数点
  return regex.test(value); // 返回true/false
}
const gridOptions = reactive({
  loading: true,
  border: "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 30},//鼠标移动或选择高亮
  id: 'demo_1',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollX: {enabled: true},
  scrollY: {enabled: true, gt: 0},//开启虚拟滚动
  showOverflow: true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
                    // remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    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},
    {
      field: 'order_id',
      title: t('order.orderId'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'process_id',
      title: t('processCard.processId'),
      showOverflow: "ellipsis",
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'customer_name',
      title: t('customer.customerName'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'project',
      title:  t('order.project'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {field: 'technology_number', title: t('processCard.technologyNumber'), showOverflow: "ellipsis"},
    {field: 'glass_address', title: t('processCard.glassAddress'),},
    {field: 'quantity', title:  t('order.quantity'),},
    {field: 'total_area', title:  t('order.area'),},
    {field: 'product_name', title: t('order.product'),},
    {field: 'glass_child', title: t('reportingWorks.glassChild'),},
    {field: 'founder', title: t('processCard.founder'),},
    {field: 'splitFrame_time', title: t('processCard.splitFrameTime'),},
  ],//表头按钮
  toolbarConfig: {
    buttons: [
      {code: 'print', name: t('processCard.print'), status: 'primary'},
      {code: 'customLabel', name: t('processCard.customLabelPrinting'), status: 'primary'},
    ],
    // import: false,
    // export: true,
    //print: true,
    zoom: true,
    custom: true
  },
  data: null,//表格数据
  //脚部求和
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return t('basicData.total')
        }
        const List = ["quantity",'total_area',]
        if (List.includes(column.field)) {
          return footSum(data, column.field)
        }
        return ''
      })
    ]
  }
})
const gridEvents = {
  toolbarButtonClick ({ code}) {
    const $grid = xGrid.value
    selectRecords = $grid.getCheckboxRecords()
    let type=printType.value
    let faceOrientation=stateValue.value
    let lableTypes=lableType.value
    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 + "|"
            }
          }
          router.push({path: '/main/processCard/printProcess', query: {printList: JSON.stringify(selectRecords),printMerge:printMerge.value}})
          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)}})
          break
        }
        case 'sort': {
          const $table = xGridDetail.value
          let data = $table.getTableData().fullData
          let flowCardData = ref({
            flowCard: data,
          })
          request.post("/processCard/printSort", flowCardData.value).then((res) => {
            if (res.code == 200) {
              ElMessage.success(t('processCard.sortingSuccessful'))
              //router.push('/main/processCard/SplittingDetails?orderId=${orderId}')
              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){
            router.push({path: '/main/processCard/PrintCustomLabel', query: {type:type,faceOrientation:faceOrientation,lableType:lableTypes,  printList: JSON.stringify(selectRecords)}})
          }
          else {
            router.push({path: '/main/processCard/PrintCustomLabelSemi', query: {type:type,faceOrientation:faceOrientation,lableType:lableTypes,  printList: JSON.stringify(selectRecords)}})
          }
          break
        }
      }
    }
  },
}
const detailGridOptions = reactive({
  border: "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 30},//鼠标移动或选择高亮
  id: 'demo_1',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollX: {enabled: true},
  scrollY: {enabled: true, gt: 0},//开启虚拟滚动
  showOverflow: true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
                    // remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },//表头参数
  columns: [
    {type: 'expand', fixed: "left", slots: {content: 'content'}, width: 50},
    {type: 'seq', fixed: "left", title: t('basicData.Number'), width: 50},
    {
      field: 'sort',
      width: 80,
      editRender: {name: 'input', attrs: {placeholder: ''}},
      title: t('processCard.sorting'),
    },
    {
      field: 'process_id',
      title: t('processCard.processId'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'order_number',
      title: t('order.OrderNum'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'technology_number',
      title: t('processCard.technologyNumber'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'glass_address',
      title: t('processCard.glassAddress'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'quantity',
      title: t('order.quantity'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'child_width',
      title: t('order.width'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'child_height',
      title: t('order.height'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'area',
      title: t('order.area'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
  ],//表头按钮
  toolbarConfig: {
    buttons: [
      {code: 'sort', name: t('processCard.sorting'), status: 'primary'},
    ],
    // import: false,
    // export: true,
    //print: true,
    zoom: true,
    custom: true
  },
  data: null,//表格数据
  //脚部求和
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return t('basicData.total')
        }
        const List = ["quantity",'area',]
        if (List.includes(column.field)) {
          return footSum(data, column.field)
        }
        return ''
      })
    ]
  }
})
const openedTable = () => {
  let detail =ref(produceDetailList.value)
  xGridDetail.value.reloadData(detail.value)
}
</script>
<template>
  <div>
    <div class="header">
  <div class="main-div-customer">
    <el-input clearable placeholder="合并打印" 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 lableTypeOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
      />
    </el-select>
    &nbsp;
    <el-select v-model="stateValue" class="m-2" placeholder='' 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="600px"
        max-height="100%"
        v-bind="gridOptions"
        v-on="gridEvents"
      <a href="/main/processCard/PrintProcess" target="_blank">打开新标签</a>
      <el-button type="primary">打印流程卡</el-button>
      <el-button type="primary">打印标签</el-button>
      &nbsp;&nbsp;
      <select class="stnw"  style="width: 100px" >
        <option label="室内面" value="option1"></option>
        <option label="室外面" value="option2"></option>
      </select>
      <select class="stnw"  style="width: 100px" >
        <option label="成品标签" value="option1"></option>
        <option label="单片标签" value="option2"></option>
      </select>
    </div>
    <el-table :data="tableData" border style="width: 100%" height="100%">
      <el-table-column sortable prop="salesOrderNo" label="销售单号" width="120" />
      <el-table-column sortable prop="productionOrderNo" label="生产订单号" width="120" />
      <el-table-column sortable prop="processCard" label="流程卡号" width="120" />
      <el-table-column prop="customerName" label="客户名称" width="120" :show-overflow-tooltip='true'/>
      <el-table-column prop="entryName" label="项目名称" width="120" :show-overflow-tooltip='true'/>
      <el-table-column prop="sliceMarking" label="片标记" :show-overflow-tooltip='true' width="70" />
      <el-table-column prop="marking" label="标记" width="55" />
      <el-table-column prop="pieces" label="片数" width="65" />
      <el-table-column prop="area" label="面积" width="65" />
      <el-table-column prop="productName" label="产品名称" width="120" :show-overflow-tooltip='true'/>
      <el-table-column prop="singlePieceName" label="单片名称" width="120" :show-overflow-tooltip='true'/>
      <el-table-column prop="floorNumber" label="楼层编号" width="120" />
      <el-table-column prop="divider" label="分架员" width="75" />
      <el-table-column prop="splittingTime" label="分架时间" width="120" />
      <el-table-column prop="notes" label="备注" :show-overflow-tooltip='true' width="350" />
    </el-table><!-- <h1>{{msg}}</h1> -->
    >
      <!--      @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>
      <!--左边固定显示的插槽-->
<!--      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 #num1_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <input type="text"
                   v-model="option.data"
                   @input="changeFilterEvent($event, option, $panel)"/>
          </div>
        </div>
      </template>
    </vxe-grid>
    <el-dialog
        v-model="dialogTableVisible"
        destroy-on-close
        :title="$t('processCard.print')"
        style="width: 80%;height:75% ">
      <PrintProcess :printList="selectRecords"
                    style="width: 100%;height: 100%" />
    </el-dialog>
    <el-dialog
        v-model="dialogTableVisibleLabel"
        destroy-on-close
        :title="$t('processCard.printLabel')"
        style="width: 80%;height:75% ">
      <PrintLabel :printList="selectRecords"
                  style="width: 100%;height: 100%" />
    </el-dialog>
    <el-dialog
        v-model="dialogTableVisibleCustomLabel"
        destroy-on-close
        :title="$t('processCard.labelStyle')"
        style="width: 80%;height:75% ">
      <PrintLabel :printList="selectRecords"
                  style="width: 100%;height: 100%" />
    </el-dialog>
    <el-dialog
        @opened="openedTable"
        v-model="printVisible"
        :title="$t('processCard.processCardDetails')"
        :close-on-click-modal="false"
        :close-on-press-escape="false"
        style="width: 80%;height:75% ">
      <vxe-grid
          ref="xGridDetail"
          class="mytable-scrollbar"
          max-height="100%"
          height="600px"
          size="small"
          v-bind="detailGridOptions"
          v-on="gridEvents">
        <template #content="{ row }">
          <ul class="expand-wrapper">
            <li v-for="(item,index) in detailGridOptions.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>
        <template #num1_filter="{ column, $panel }">
          <div>
            <div v-for="(option, index) in column.filters" :key="index">
              <input type="text"
                     v-model="option.data"
                     @input="changeFilterEvent($event, option, $panel)"/>
            </div>
          </div>
        </template>
      </vxe-grid>
    </el-dialog>
  </div>
</template>
<style scoped>
.common-layout{
.main-div-customer {
  width: 99%;
  height: 100%;
}
.el-aside{
  height: 100%;
}
.el-main{
  height: 100%;
  text-align: center;
}
.stnw{
  height: 33px;
  width: 80px;
  background-color: #409eff;
  color: white;
  border: none;
  border-radius: 5px;
}
</style>