廖井涛
2024-05-28 f866d4c98e2f69a8f4ba6a12bf492b02e734d488
north-glass-erp/northglass-erp/src/views/pp/report/ProcessToBeCompleted.vue
@@ -273,9 +273,12 @@
    // buttons: [{
    //
    // }],
    import: false,
    export: true,
    print: true,
    slots: {
      tools: 'toolbar_buttons'
    },
    // import: false,
    // export: true,
    // print: true,
    zoom: true,
    custom: true
  },
@@ -297,7 +300,57 @@
  }
})
 function exportExcel(url, fileName,date) {
  let processes = value.value
  let inputVal = form.orderId
  if (inputVal == '') {
    inputVal = null
  }
  let inputProject = form.project
  if (inputProject == '') {
    inputProject = null
  }
  if(date===null){
    ElMessage.warning("请先选择日期")
    return
  }
  if(processes===null){
    ElMessage.warning("请先选择工序")
    return
  }
  const date1 = new Date(date[0]);
  const date2 = new Date(date[1]);
  const timeDiff = Math.abs(date2.getTime() - date1.getTime());
  const daysDiff = timeDiff / (1000 * 3600 * 24);
  if(Math.floor(daysDiff)>180){
    ElMessage.warning("导出的筛选时间不能超过180天")
    return
  }
   let dataMp = ref({
     date: date,
     processes: processes,
     orderId: inputVal,
     project: inputProject
   })
  request.post(url,dataMp.value,{responseType :'blob'}).then(res => {
    const blob = new Blob([res])
    if ('download' in document.createElement('a')) { // 非IE下载
      const elink = document.createElement('a')
      elink.download = `${fileName}.xlsx`
      elink.style.display = 'none'
      elink.href = URL.createObjectURL(blob)
      document.body.appendChild(elink)
      elink.click()
      URL.revokeObjectURL(elink.href) // 释放URL 对象
      document.body.removeChild(elink)
    } else { // IE10+下载
      navigator.msSaveBlob(blob, fileName)
    }
  })
}
</script>
@@ -359,6 +412,14 @@
        <el-button link size="small" type="primary" @click="getTableRow(row,'delete')">删除</el-button>
      </template>
      <template #toolbar_buttons>
        <vxe-button style="margin-right: 0.5rem"
                    @click="exportExcel('/report/exportProcessToBeCompleted',
                                          '工序待完成报表',
                                          form.date1)">
          导出</vxe-button>
      </template>
      <template #num1_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">