<template> 
 | 
  <div class="app-container"> 
 | 
  
 | 
    <el-row :gutter="10" class="mb8"> 
 | 
      <el-col :span="1.5"> 
 | 
        <el-button  
 | 
          type="info"  
 | 
          plain  
 | 
          icon="Upload"  
 | 
          @click="handleImport"  
 | 
          v-hasPermi="['weldSeam:weldSeam:importData']" 
 | 
          >导入</el-button> 
 | 
      </el-col> 
 | 
      <el-col :span="1.5"> 
 | 
        <el-button 
 | 
          type="warning" 
 | 
          plain 
 | 
          icon="Download" 
 | 
          @click="handleExport" 
 | 
          v-hasPermi="['weldSeam:weldSeam:export']" 
 | 
        >导出</el-button> 
 | 
      </el-col> 
 | 
      <right-toolbar :search="false" @queryTable="getList"></right-toolbar> 
 | 
    </el-row> 
 | 
  
 | 
    <HxlhTable 
 | 
        style="width: 100%" 
 | 
        :columns="columns" 
 | 
        :data="dataList" 
 | 
        :loading="loading" 
 | 
        :height="height" 
 | 
        @on-checkbox="handleCheckboxChange" 
 | 
    > 
 | 
      <template #buttons="{row}"> 
 | 
        <vxe-button mode="text" @click="viewEvent(row)">编辑</vxe-button> 
 | 
        <!-- <vxe-button mode="text" @row-click="viewEvent(row.year)">编辑</vxe-button> --> 
 | 
      </template> 
 | 
    </HxlhTable> 
 | 
  
 | 
    <!-- 导入对话框 --> 
 | 
    <el-dialog :title="upload.title" v-model="upload.open" width="90%" append-to-body @close="dialogCancel"> 
 | 
      <el-row :gutter="10"> 
 | 
        <el-col> 
 | 
          <div style="border-bottom: 1px solid #ccc;" > 
 | 
            <p>上传Excel文件,包含焊缝工单信息。系统将解析数据并保存到本地,用于关联到焊缝计划中。</p> 
 | 
          </div> 
 | 
        </el-col> 
 | 
        <el-col > 
 | 
          <div></div> 
 | 
        </el-col> 
 | 
      </el-row> 
 | 
      <el-row> 
 | 
        <el-col> 
 | 
          <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="true" drag> 
 | 
            <el-icon class="el-icon--upload"><upload-filled /></el-icon> 
 | 
            <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> 
 | 
            <template #tip> 
 | 
              <div class="el-upload__tip"> 
 | 
                <span>仅允许导入xls、xlsx格式文件。</span> 
 | 
              </div> 
 | 
            </template> 
 | 
          </el-upload> 
 | 
        </el-col> 
 | 
      </el-row> 
 | 
      <el-row> 
 | 
        <el-col style="margin-top: 20px;"> 
 | 
          <div v-show="isVisible"> 
 | 
            <el-alert icon="Check" :show-icon="true" title="焊缝工单数据已成功解析" type="success" :closable="false"/> 
 | 
          </div> 
 | 
          <div v-show="isError"> 
 | 
            <el-alert icon="Close" :show-icon="true" title="焊缝工单数据已解析失败" type="error" :closable="false"/> 
 | 
          </div> 
 | 
        </el-col> 
 | 
      </el-row> 
 | 
      <el-row v-show="isVisible"> 
 | 
        <el-col> 
 | 
          <div> 
 | 
            <h2>数据预览</h2> 
 | 
          </div> 
 | 
          <HxlhTable 
 | 
            style="width: 100%" 
 | 
            :columns="exampleColumns" 
 | 
            :data="exampleList" 
 | 
            :loading="loading" 
 | 
            :maxHeight="exampleHeight" 
 | 
          > 
 | 
          </HxlhTable> 
 | 
        </el-col> 
 | 
        <el-col> 
 | 
          <div style="text-align: right;"> 
 | 
            <h4>共上传<span style="color: blue;">{{ total }}</span>条焊缝工单数据</h4> 
 | 
          </div> 
 | 
        </el-col> 
 | 
      </el-row> 
 | 
      <template #footer> 
 | 
        <div class="dialog-footer"> 
 | 
          <el-button 
 | 
              type="success" 
 | 
              plain 
 | 
              icon="Check" 
 | 
              :disabled="planned" 
 | 
              @click="uploadParse" 
 | 
              v-hasPermi="['weldSeam:weldSeam:confirmWeldSeam']" 
 | 
            >确认上传</el-button> 
 | 
          <el-button @click="dialogCancel">取 消</el-button> 
 | 
        </div> 
 | 
      </template> 
 | 
    </el-dialog> 
 | 
  
 | 
    <!-- 添加或修改焊缝对话框 --> 
 | 
    <el-dialog :title="title" v-model="open" width="700px" append-to-body> 
 | 
      <el-form ref="weldSeamRef" :model="form" :rules="rules" label-width="150px"> 
 | 
        <el-form-item label="年份" prop="year"> 
 | 
          <el-input v-model="form.year" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="月份" prop="month"> 
 | 
          <el-input v-model="form.month" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="生产基地" prop="productionBase"> 
 | 
          <el-input v-model="form.productionBase" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="管路订单需求" prop="pipingOrderRequirement"> 
 | 
          <el-input v-model="form.pipingOrderRequirement" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="气柜订单需求" prop="gasOrderRequirement"> 
 | 
          <el-input v-model="form.gasOrderRequirement" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="管路预测需求" prop="pipingPredictionRequirement"> 
 | 
          <el-input v-model="form.pipingPredictionRequirement" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="气柜预测需求" prop="gasPredictionRequirement"> 
 | 
          <el-input v-model="form.gasPredictionRequirement" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="预留紧急订单产出" prop="reserveEmergencyOrderOutput"> 
 | 
          <el-input-number :min="0" v-model="form.reserveEmergencyOrderOutput" placeholder="请输预留紧急订单产出" style="width: 100%;"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="合计" prop="total"> 
 | 
          <el-input v-model="form.total" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="天数" prop="days"> 
 | 
          <el-input-number :min="0" v-model="form.days" placeholder="请输入天数" style="width: 100%;"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="需求日焊缝" prop="requirementDayWeldSeam"> 
 | 
          <el-input v-model="form.requirementDayWeldSeam" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="生产日焊缝" prop="productionDayWeldSeam"> 
 | 
          <el-input-number :min="0" v-model="form.productionDayWeldSeam" placeholder="请输生产日焊缝" style="width: 100%;"/> 
 | 
        </el-form-item> 
 | 
        <el-form-item label="是否满足" prop="isSatisfy"> 
 | 
          <el-input v-model="form.isSatisfy" :disabled="isDisabled"/> 
 | 
        </el-form-item> 
 | 
      </el-form> 
 | 
      <template #footer> 
 | 
        <div class="dialog-footer"> 
 | 
          <el-button type="primary" @click="submitForm">确 定</el-button> 
 | 
          <el-button @click="cancel">取 消</el-button> 
 | 
        </div> 
 | 
      </template> 
 | 
    </el-dialog> 
 | 
  </div> 
 | 
</template> 
 | 
  
 | 
<script setup name="WeldSeam"> 
 | 
import { listWeldSeam, getWeldSeam, delWeldSeam, addWeldSeam, updateWeldSeam ,examplePlan ,confirmWeldSeam ,query} from "@/api/mainPlan/weldSeam/weldSeam"; 
 | 
import { getToken } from "@/utils/auth"; 
 | 
import HxlhTable from '@/components/HxlhTable' 
 | 
import { ref } from "vue"; 
 | 
import * as XLSX from 'xlsx'; 
 | 
  
 | 
const { proxy } = getCurrentInstance(); 
 | 
  
 | 
const open = ref(false); 
 | 
const loading = ref(true); 
 | 
const ids = ref([]); 
 | 
const single = ref(true); 
 | 
const multiple = ref(true); 
 | 
const total = ref(0); 
 | 
const title = ref(""); 
 | 
const daterangeThisFeedbackDay = ref([]); 
 | 
const daterangeMaterialsRequirementDay = ref([]); 
 | 
const isVisible = ref(false); 
 | 
const isError = ref(false); 
 | 
const planned = ref(true); 
 | 
const height = ref(document.documentElement.clientHeight - 210 + "px;") 
 | 
const exampleHeight = ref("500px"); 
 | 
const uploadRef = ref(); 
 | 
const exampleList = ref([]); 
 | 
const batchNumber = ref(null); 
 | 
const dataList = ref([]); 
 | 
const isDisabled = ref(true); 
 | 
const headers = ref([]); 
 | 
const exportData = ref([]); 
 | 
  
 | 
/** 导入参数 */ 
 | 
const upload = reactive({ 
 | 
  // 是否显示弹出层(用户导入) 
 | 
  open: false, 
 | 
  // 弹出层标题(用户导入) 
 | 
  title: "", 
 | 
  // 是否禁用上传 
 | 
  isUploading: false, 
 | 
  // 是否更新已经存在的用户数据 
 | 
  updateSupport: 0, 
 | 
  // 设置上传的请求头部 
 | 
  headers: { Authorization: "Bearer " + getToken() ,local: import.meta.env.VITE_APP_LOCAL }, 
 | 
  // 上传的地址 
 | 
  url: import.meta.env.VITE_APP_BASE_API + "/aps/weldSeam/importData" 
 | 
}); 
 | 
  
 | 
// 表格配置  
 | 
const columns = ref([ 
 | 
  { type: 'seq', title: '序号', width: 60, fixed: 'left' }, 
 | 
  { 
 | 
    title: '年份', 
 | 
    field: 'year', 
 | 
    width: 100,  
 | 
    fixed: 'left' 
 | 
  }, 
 | 
  { 
 | 
    title: '月份', 
 | 
    field: 'month', 
 | 
    width: 80,  
 | 
    fixed: 'left' 
 | 
  }, 
 | 
  { 
 | 
    title: '生产基地', 
 | 
    field: 'productionBaseStr', 
 | 
    width: 150,  
 | 
    fixed: 'left', 
 | 
    type: 'html' 
 | 
  }, 
 | 
  { 
 | 
    title: '订单需求', 
 | 
    field: 'order', 
 | 
    children: [ 
 | 
      { field: 'pipingOrderRequirement', title: '管路', width: 140 }, 
 | 
      { field: 'gasOrderRequirement', title: '气柜', width: 120 }, 
 | 
    ], 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '预测需求', 
 | 
    field: 'info', 
 | 
    children: [ 
 | 
      { field: 'pipingPredictionRequirement', title: '管路', width: 140 }, 
 | 
      { field: 'gasPredictionRequirement', title: '气柜', width: 120 }, 
 | 
    ], 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '预留紧急订单产出', 
 | 
    field: 'reserveEmergencyOrderOutput', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '合计', 
 | 
    field: 'total', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '天数', 
 | 
    field: 'days', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '需求日焊缝', 
 | 
    field: 'requirementDayWeldSeam', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '生产日焊缝', 
 | 
    field: 'productionDayWeldSeam', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '是否满足', 
 | 
    field: 'isSatisfyStr', 
 | 
    width: 150, 
 | 
    type: 'html' 
 | 
  }, 
 | 
  { title: '操作', width: 100, fixed:"right", slots: { default: 'buttons' } } 
 | 
]); 
 | 
  
 | 
// 表格配置  
 | 
const exampleColumns = ref([ 
 | 
  { type: 'seq', title: '序号', width: 60 }, 
 | 
  { 
 | 
    title: '工单类型', 
 | 
    field: 'workOrderType', 
 | 
    width: 80, 
 | 
  }, 
 | 
  /* { 
 | 
    title: '周日', 
 | 
    field: 'weekDay', 
 | 
    width: 100, 
 | 
    formatter: (({ cellValue, row, column }) => { 
 | 
      if (cellValue) { 
 | 
        const weekDay = new Date(cellValue); 
 | 
        const year = weekDay.getFullYear(); 
 | 
        const month = String(weekDay.getMonth() + 1).padStart(2, '0'); 
 | 
        const day = String(weekDay.getDate()).padStart(2, '0'); 
 | 
        return `${month}-${day}`; 
 | 
      } 
 | 
      return ''; 
 | 
    }) 
 | 
  }, */ 
 | 
  { 
 | 
    title: '物料编码', 
 | 
    field: 'materialCode', 
 | 
    width: 160, 
 | 
  }, 
 | 
  { 
 | 
    title: '客户图号', 
 | 
    field: 'customerDrawingNumber', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '组织账号', 
 | 
    field: 'organizeNumber', 
 | 
    width: 200, 
 | 
  }, 
 | 
  { 
 | 
    title: '生产基地', 
 | 
    field: 'productionBase', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '分类(气柜/管路)', 
 | 
    field: 'classification', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '生产年份', 
 | 
    field: 'produceYear', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '生产月份', 
 | 
    field: 'produceMonth', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '生成数量', 
 | 
    field: 'productionQuantity', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '客户', 
 | 
    field: 'customer', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '单件焊缝', 
 | 
    field: 'singleWeldSeam', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '总焊缝', 
 | 
    field: 'totalWeldSeam', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '本次反馈日期', 
 | 
    field: 'thisFeedbackDay', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '物料需求日期', 
 | 
    field: 'materialsRequirementDay', 
 | 
    width: 100, 
 | 
  }, 
 | 
  { 
 | 
    title: '销售订单号', 
 | 
    field: 'saleOrderNo', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '销售订单行', 
 | 
    field: 'saleOrderLine', 
 | 
    width: 150, 
 | 
  }, 
 | 
  { 
 | 
    title: '主工单号', 
 | 
    field: 'mainWorkOrderNo', 
 | 
    width: 180, 
 | 
  }, 
 | 
  { 
 | 
    title: '上级工单号', 
 | 
    field: 'superiorWorkOrderNo', 
 | 
    width: 180, 
 | 
  }, 
 | 
  { 
 | 
    title: '工单号', 
 | 
    field: 'workOrderNo', 
 | 
    width: 180, 
 | 
  }, 
 | 
]); 
 | 
  
 | 
const data = reactive({ 
 | 
  form: {}, 
 | 
  queryParams: { 
 | 
    pageNum: 1, 
 | 
    pageSize: 10, 
 | 
    workOrderType: null, 
 | 
    materialCode: null, 
 | 
    customerDrawingNumber: null, 
 | 
    organizeNumber: null, 
 | 
    productionBase: null, 
 | 
    classification: null, 
 | 
    produceYear: null, 
 | 
    produceMonth: null, 
 | 
    productionQuantity: null, 
 | 
    customer: null, 
 | 
    singleWeldSeam: null, 
 | 
    totalWeldSeam: null, 
 | 
    thisFeedbackDay: null, 
 | 
    materialsRequirementDay: null, 
 | 
    saleOrderNo: null, 
 | 
    saleOrderLine: null, 
 | 
    mainWorkOrderNo: null, 
 | 
    superiorWorkOrderNo: null, 
 | 
    workOrderNo: null, 
 | 
    plant: null, 
 | 
    batchNumber: null 
 | 
  }, 
 | 
  rules: { 
 | 
    reserveEmergencyOrderOutput: [ 
 | 
      { 
 | 
        required: true, 
 | 
        message: '请输入预留紧急订单产出', 
 | 
        trigger: 'blur', 
 | 
      }, 
 | 
    ], 
 | 
    days: [ 
 | 
      { 
 | 
        required: true, 
 | 
        message: '请输入天数', 
 | 
        trigger: 'blur', 
 | 
      }, 
 | 
    ], 
 | 
    productionDayWeldSeam: [ 
 | 
      { 
 | 
        required: true, 
 | 
        message: '请输入预留紧急订单产出', 
 | 
        trigger: 'blur', 
 | 
      }, 
 | 
    ], 
 | 
  } 
 | 
}); 
 | 
  
 | 
const { queryParams, form, rules } = toRefs(data); 
 | 
  
 | 
/** 查询焊缝列表 */ 
 | 
function getList() { 
 | 
  loading.value = true; 
 | 
  query(queryParams.value).then(response => { 
 | 
    let responseData = response.rows; 
 | 
    // exportData.value = response.rows; 
 | 
    responseData.forEach(item=>{ 
 | 
      let data = []; 
 | 
      data.push(item.year); 
 | 
      data.push(item.month); 
 | 
      data.push(item.productionBase); 
 | 
      data.push(item.pipingOrderRequirement); 
 | 
      data.push(item.gasOrderRequirement); 
 | 
      data.push(item.pipingPredictionRequirement); 
 | 
      data.push(item.gasPredictionRequirement); 
 | 
      data.push(item.reserveEmergencyOrderOutput); 
 | 
      data.push(item.total); 
 | 
      data.push(item.days); 
 | 
      data.push(item.requirementDayWeldSeam); 
 | 
      data.push(item.productionDayWeldSeam); 
 | 
      data.push(item.isSatisfy); 
 | 
  
 | 
      item.productionBaseStr = item.isSatisfy === '否' ? `<div class='el-badge'><sup class="el-badge__content is-fixed is-dot" style="right: 2px; top: 2px;"></sup>${item.productionBase}</div>` : item.productionBase 
 | 
      item.isSatisfyStr = item.isSatisfy === '否' ? `<font color='red'>${item.isSatisfy}</font>` : item.isSatisfy 
 | 
      exportData.value.push(data); 
 | 
    }) 
 | 
    dataList.value = responseData; 
 | 
    loading.value = false; 
 | 
  }); 
 | 
} 
 | 
  
 | 
// 取消按钮 
 | 
function cancel() { 
 | 
  open.value = false; 
 | 
  reset(); 
 | 
} 
 | 
  
 | 
// 表单重置 
 | 
function reset() { 
 | 
  form.value = { 
 | 
    workOrderType: null, 
 | 
    materialCode: null, 
 | 
    customerDrawingNumber: null, 
 | 
    organizeNumber: null, 
 | 
    productionBase: null, 
 | 
    classification: null, 
 | 
    produceYear: null, 
 | 
    produceMonth: null, 
 | 
    productionQuantity: null, 
 | 
    customer: null, 
 | 
    singleWeldSeam: null, 
 | 
    totalWeldSeam: null, 
 | 
    thisFeedbackDay: null, 
 | 
    materialsRequirementDay: null, 
 | 
    saleOrderNo: null, 
 | 
    saleOrderLine: null, 
 | 
    mainWorkOrderNo: null, 
 | 
    superiorWorkOrderNo: null, 
 | 
    workOrderNo: null, 
 | 
    plant: null 
 | 
  }; 
 | 
  proxy.resetForm("weldSeamRef"); 
 | 
} 
 | 
  
 | 
/** 搜索按钮操作 */ 
 | 
function handleQuery() { 
 | 
  queryParams.value.pageNum = 1; 
 | 
  getList(); 
 | 
} 
 | 
  
 | 
/** 重置按钮操作 */ 
 | 
function resetQuery() { 
 | 
  daterangeThisFeedbackDay.value = []; 
 | 
  daterangeMaterialsRequirementDay.value = []; 
 | 
  proxy.resetForm("queryRef"); 
 | 
  handleQuery(); 
 | 
} 
 | 
  
 | 
// 多选框选中数据 
 | 
function handleSelectionChange(selection) { 
 | 
  ids.value = selection.map(item => item.id); 
 | 
  single.value = selection.length != 1; 
 | 
  multiple.value = !selection.length; 
 | 
} 
 | 
  
 | 
/** 新增按钮操作 */ 
 | 
function handleAdd() { 
 | 
  reset(); 
 | 
  open.value = true; 
 | 
  title.value = "添加焊缝"; 
 | 
} 
 | 
  
 | 
/** 修改按钮操作 */ 
 | 
function handleUpdate(row) { 
 | 
  reset(); 
 | 
  const _id = row.id || ids.value 
 | 
  getWeldSeam(_id).then(response => { 
 | 
    form.value = response.data; 
 | 
    open.value = true; 
 | 
    title.value = "修改焊缝"; 
 | 
  }); 
 | 
} 
 | 
  
 | 
/** 提交按钮 */ 
 | 
function submitForm() { 
 | 
  proxy.$refs["weldSeamRef"].validate(valid => { 
 | 
    if (valid) { 
 | 
      if (form.value.id != null) { 
 | 
        updateWeldSeam(form.value).then(response => { 
 | 
          proxy.$modal.msgSuccess("修改成功"); 
 | 
          open.value = false; 
 | 
          getList(); 
 | 
        }); 
 | 
      } else { 
 | 
        addWeldSeam(form.value).then(response => { 
 | 
          proxy.$modal.msgSuccess("新增成功"); 
 | 
          open.value = false; 
 | 
          getList(); 
 | 
        }); 
 | 
      } 
 | 
    } 
 | 
  }); 
 | 
} 
 | 
  
 | 
/** 删除按钮操作 */ 
 | 
function handleDelete(row) { 
 | 
  const _ids = row.id || ids.value; 
 | 
  proxy.$modal.confirm('是否确认删除焊缝编号为"' + _ids + '"的数据项?').then(function() { 
 | 
    return delWeldSeam(_ids); 
 | 
  }).then(() => { 
 | 
    getList(); 
 | 
    proxy.$modal.msgSuccess("删除成功"); 
 | 
  }).catch(() => {}); 
 | 
} 
 | 
  
 | 
/** 导入按钮操作 */ 
 | 
function handleImport() { 
 | 
  upload.title = "焊缝工单数据上传"; 
 | 
  upload.open = true; 
 | 
}; 
 | 
  
 | 
/** 导出按钮操作 */ 
 | 
function handleExport() { 
 | 
  const headersOne = ["年份","月份","生产基地","订单需求","","预测需求","","预留紧急订单产出","合计","天数","需求日焊缝","生产日焊缝","是否满足"] 
 | 
  const headersTwo = ["","","","管路","气柜","管路","气柜","","","","","",""] 
 | 
  headers.value.push(headersOne); 
 | 
  headers.value.push(headersTwo); 
 | 
   
 | 
  // 合并表头和数据 
 | 
  const finalData = [...headers.value, ...exportData.value]; 
 | 
  
 | 
  // 将数据转换为 worksheet 
 | 
  const ws = XLSX.utils.aoa_to_sheet(finalData); 
 | 
  
 | 
  // 合并单元格(如果需要) 
 | 
  ws['!merges'] = [ 
 | 
    { s: { r: 0, c: 0 }, e: { r: 1, c: 0 } }, 
 | 
    { s: { r: 0, c: 1 }, e: { r: 1, c: 1 } }, 
 | 
    { s: { r: 0, c: 2 }, e: { r: 1, c: 2 } }, 
 | 
    { s: { r: 0, c: 3 }, e: { r: 0, c: 4 } }, 
 | 
    { s: { r: 0, c: 5 }, e: { r: 0, c: 6 } }, 
 | 
    { s: { r: 0, c: 7 }, e: { r: 1, c: 7 } }, 
 | 
    { s: { r: 0, c: 8 }, e: { r: 1, c: 8 } }, 
 | 
    { s: { r: 0, c: 9 }, e: { r: 1, c: 9 } }, 
 | 
    { s: { r: 0, c: 10 }, e: { r: 1, c: 10 } }, 
 | 
    { s: { r: 0, c: 11 }, e: { r: 1, c: 11 } }, 
 | 
    { s: { r: 0, c: 12 }, e: { r: 1, c: 12 } }, 
 | 
  ]; 
 | 
  
 | 
  // ws['!merges'] = merges; 
 | 
  
 | 
  // 设置居中样式 
 | 
  const centerStyle = { alignment: { horizontal: 'center', vertical: 'center' } }; 
 | 
    const range = XLSX.utils.decode_range(ws['!ref']); 
 | 
    for (let R = range.s.r; R <= range.e.r; ++R) { 
 | 
        for (let C = range.s.c; C <= range.e.c; ++C) { 
 | 
            const cellAddress = XLSX.utils.encode_cell({ r: R, c: C }); 
 | 
            const cell = ws[cellAddress]; 
 | 
            if (cell) { 
 | 
                cell.s = centerStyle; 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
   
 | 
  // 创建 workbook 
 | 
  const wb = XLSX.utils.book_new(); 
 | 
  // 将 worksheet 添加到 workbook 中 
 | 
  XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); 
 | 
  // 导出文件 
 | 
  XLSX.writeFile(wb, `apsPartRouteStat_${new Date().getTime()}.xlsx`); 
 | 
} 
 | 
  
 | 
/** dialog取消 */ 
 | 
function dialogCancel(){ 
 | 
  if (uploadRef.value) { 
 | 
    uploadRef.value.clearFiles(); 
 | 
  } 
 | 
  isVisible.value = false; 
 | 
  isError.value = false; 
 | 
  planned.value = true; 
 | 
  upload.open = false; 
 | 
  upload.isUploading = false; 
 | 
} 
 | 
  
 | 
/**文件上传中处理 */ 
 | 
const handleFileUploadProgress = (event, file, fileList) => { 
 | 
  upload.isUploading = true; 
 | 
}; 
 | 
  
 | 
/** 文件上传成功处理 */ 
 | 
const handleFileSuccess = (response, file, fileList) => { 
 | 
  if(response.code == '200'){ 
 | 
    batchNumber.value = response.data; 
 | 
    isVisible.value = true; 
 | 
    planned.value = false; 
 | 
    isError.value = false; 
 | 
    getExampleList(); 
 | 
  }else{ 
 | 
    isError.value = true; 
 | 
    proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true }); 
 | 
  } 
 | 
  proxy.$refs["uploadRef"].handleRemove(file); 
 | 
  upload.isUploading = false; 
 | 
}; 
 | 
  
 | 
/** 上传并解析按钮操作 */ 
 | 
function uploadParse() { 
 | 
  queryParams.value.params = {}; 
 | 
  queryParams.value.params["batchNumber"] = batchNumber.value; 
 | 
  confirmWeldSeam(queryParams.value).then(response => { 
 | 
    exampleList.value = response.rows; 
 | 
    loading.value = false; 
 | 
    isVisible.value = false; 
 | 
    isError.value = false; 
 | 
    planned.value = true; 
 | 
    upload.open = false; 
 | 
    getList(); 
 | 
    ElMessage({ 
 | 
      message: '焊缝工单数据已成功上传和解析', 
 | 
      type: 'success', 
 | 
    }) 
 | 
  }); 
 | 
} 
 | 
  
 | 
/** 查询零件计划临时管理列表 */ 
 | 
function getExampleList() { 
 | 
  loading.value = true; 
 | 
  queryParams.value = {}; 
 | 
  queryParams.value.batchNumber = batchNumber.value; 
 | 
  examplePlan(queryParams.value).then(response => { 
 | 
    exampleList.value = response.rows; 
 | 
    total.value = response.total; 
 | 
    loading.value = false; 
 | 
  }); 
 | 
} 
 | 
  
 | 
function viewEvent(row){ 
 | 
  open.value = true; 
 | 
  title.value = "修改焊缝"; 
 | 
  form.value = {...row}; 
 | 
} 
 | 
  
 | 
getList(); 
 | 
</script> 
 |