CD配唱片
2025-05-08 e3e17a37d85f50bace525ed019ee0cd8d39143eb
src/views/basicData/processRoute/index.vue
@@ -1,23 +1,27 @@
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="90px">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <el-row :gutter="20">
        <el-col
        :span="6">
      <el-form-item label="集成日期" style="width: 308px">
        <el-date-picker
          v-model="daterangeIntegrationDay"
          value-format="YYYY-MM-DD HH:mm:ss"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
        <el-col :span="6">
          <el-form-item label="集成日期" style="width: 308px">
            <el-date-picker
              v-model="daterangeIntegrationDay"
              value-format="YYYY-MM-DD HH:mm:ss"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col
        :span="6">
      <el-form-item label="料号" prop="itemNo">
        <el-col :span="6">
          <el-form-item label="料号" prop="itemNo">
            <el-input
              v-model="queryParams.itemNo"
              placeholder="请输入料号"
@@ -26,26 +30,27 @@
            />
          </el-form-item>
        </el-col>
        <el-col
          :span="12"
          style="text-align: right;">
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
        <el-col :span="12" style="text-align: right">
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
    </el-row>
      </el-row>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="Upload"
          @click="handleImport"
        <el-button
          type="info"
          plain
          icon="Upload"
          @click="handleImport"
          v-hasPermi="['processRoute:processRoute:importData']"
          >导入</el-button>
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
@@ -54,39 +59,69 @@
          icon="Download"
          @click="handleExport"
          v-hasPermi="['processRoute:processRoute:export']"
        >导出</el-button>
          >导出</el-button
        >
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <HxlhTable
        style="width: 100%"
        :columns="columns"
        :data="processRouteList"
        :loading="loading"
        :height="height"
        @on-checkbox="handleCheckboxChange"
      style="width: 100%"
      :columns="columns"
      :showOverflow="true"
      :virtualYConfig="virtualYConfig"
      :data="processRouteList"
      :loading="loading"
      :height="height"
      @bottomAutoLoadMore="handleAutoLoadMore"
      @on-checkbox="handleCheckboxChange"
    >
      <template #rowIndex="{ rowIndex }">
        {{ rowIndex }}
      </template>
    </HxlhTable>
  <!-- 用户导入对话框 -->
  <el-dialog :title="upload.title" v-model="upload.open" width="90%" append-to-body>
    <!-- 用户导入对话框 -->
    <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 style="border-bottom: 1px solid #ccc">
            <p>
              上传Excel文件,包含工艺路线信息。系统将解析数据并保存到本地,用于关联到零件计划中。
            </p>
          </div>
        </el-col>
        <el-col >
        <el-col>
          <div></div>
        </el-col>
      </el-row>
      <el-row :gutter="10" style="margin-top: 20px;">
      </el-row>
      <el-row :gutter="10" style="margin-top: 20px"> </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-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>
            <div class="el-upload__text">
              将文件拖到此处,或<em>点击上传</em>
            </div>
            <template #tip>
              <div class="el-upload__tip">
                <span>仅允许导入xls、xlsx格式文件。</span>
@@ -95,27 +130,25 @@
          </el-upload>
        </el-col>
      </el-row>
      <el-row style="margin-top: 20px;">
        <el-col>
          <div>
            <el-button
              type="success"
              plain
              icon="Check"
              :disabled="planned"
              @click="uploadParse"
              v-hasPermi="['processRoute:processRoute:confirmProcessRoute']"
            >上传并解析</el-button>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col style="margin-top: 20px;">
        <el-col style="margin-top: 20px">
          <div v-show="isVisible">
            <el-alert icon="Check" :show-icon="true" title="工艺路线数据已成功解析" type="success" :closable="false"/>
            <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"/>
            <el-alert
              icon="Close"
              :show-icon="true"
              title="工艺路线数据已解析失败"
              type="error"
              :closable="false"
            />
          </div>
        </el-col>
      </el-row>
@@ -135,13 +168,25 @@
          </HxlhTable>
        </el-col>
        <el-col>
          <div style="text-align: right;">
            <h4>共上传<span style="color: blue;">{{ total }}</span>条工艺路线数据</h4>
          <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="['processRoute:processRoute:confirmProcessRoute']"
            >确认上传</el-button
          >
          <el-button @click="dialogCancel">取 消</el-button>
        </div>
      </template>
@@ -150,11 +195,20 @@
</template>
<script setup name="ProcessRoute">
import { listProcessRoute, getProcessRoute, delProcessRoute, addProcessRoute, updateProcessRoute,processRouteTempList,confirmProcessRoute } from "@/api/basicData/processRoute";
import HxlhTable from '@/components/HxlhTable'
import {
  listProcessRoute,
  getProcessRoute,
  delProcessRoute,
  addProcessRoute,
  updateProcessRoute,
  processRouteTempList,
  confirmProcessRoute,
} from "@/api/basicData/processRoute";
import { throttle } from "@/utils/throttle";
import HxlhTable from "@/components/HxlhTable";
import { getToken } from "@/utils/auth";
import { ref } from "vue";
import { ElMessage } from 'element-plus'
// import { ElMessage } from "element-plus";
const { proxy } = getCurrentInstance();
const processRouteList = ref([]);
@@ -168,7 +222,7 @@
const title = ref("");
const daterangeIntegrationDay = ref([]);
//弹窗相关
const height = ref(document.documentElement.clientHeight - 260 + "px;")
const height = ref(document.documentElement.clientHeight - 230 + "px;");
const isVisible = ref(false);
const isError = ref(false);
const planned = ref(true);
@@ -176,6 +230,11 @@
const exampleHeight = ref("500px");
const uploadRef = ref();
const exampleList = ref([]);
const virtualYConfig = {
  enabled: true,
  gt: 0,
  threshold: 50,
};
/*** 用户导入参数 */
const upload = reactive({
  // 是否显示弹出层(用户导入)
@@ -189,153 +248,154 @@
  // 设置上传的请求头部
  headers: { Authorization: "Bearer " + getToken() },
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/aps/processRoute/importData"
  url: import.meta.env.VITE_APP_BASE_API + "/aps/processRoute/importData",
});
// 表格配置-列表
// 表格配置-列表
const columns = ref([
  { type: 'checkbox', width: 60, align:"center"},
  { type: 'seq', title: '序号', width: 60 },
  { type: "checkbox", width: 60, align: "center" },
  { type: "seq", title: "序号", width: 60 },
  {
    title: '料号',
    field: 'itemNo',
    title: "料号",
    field: "itemNo",
    width: 150,
    align:"center",
    align: "center",
  },
  {
    title: '工单号',
    field: 'workOrderNo',
    title: "工单号",
    field: "workOrderNo",
    width: 150,
    align:"center",
    align: "center",
  },
  {
    title: '工序序号',
    field: 'processNumber',
    title: "工序序号",
    field: "processNumber",
    width: 100,
    align:"center",
    align: "center",
  },
  {
    title: '工序名称',
    field: 'processName',
    title: "工序名称",
    field: "processName",
    width: 150,
    align:"center",
    align: "center",
  },
  {
    title: '工序计划开始日期',
    field: 'processPlanStartDay',
    title: "工序计划开始日期",
    field: "processPlanStartDay",
    width: 200,
    align:"center",
    align: "center",
  },
  {
    title: '工序计划结束日期',
    field: 'processPlanEndDay',
    title: "工序计划结束日期",
    field: "processPlanEndDay",
    width: 200,
    align:"center",
    align: "center",
  },
  {
    title: '未开工数量',
    field: 'notStartWorkCount',
    title: "未开工数量",
    field: "notStartWorkCount",
    width: 90,
    align:"center",
    align: "center",
  },
  {
    title: '已完成数量',
    field: 'completedCount',
    title: "已完成数量",
    field: "completedCount",
    width: 90,
    align:"center",
    align: "center",
  },
  {
    title: '废弃数量',
    field: 'discardCount',
    title: "废弃数量",
    field: "discardCount",
    width: 90,
    align:"center",
    align: "center",
  },
  {
    title: '标准工时',
    field: 'standardTime',
    title: "标准工时",
    field: "standardTime",
    width: 90,
    align:"center",
    align: "center",
  },
  {
    title: '工序排序',
    field: 'processOrder',
    title: "工序排序",
    field: "processOrder",
    width: 90,
    align:"center",
    align: "center",
  },
  {
    title: '集成日期',
    field: 'integrationDay',
    title: "集成日期",
    field: "integrationDay",
    width: 160,
    align:"center",
  }
    align: "center",
  },
]);
// 表格配置-弹窗
const exampleColumns = ref([
  { type: 'seq', title: '序号', width: 60 },
  { type: "seq", title: "序号", width: 60, slots: { default: "rowIndex" } },
  {
    title: '料号',
    field: 'itemNo',
    title: "料号",
    field: "itemNo",
    width: 150,
    align:"center",
    align: "center",
  },
  {
    title: '工单号',
    field: 'workOrderNo',
    title: "工单号",
    field: "workOrderNo",
    width: 150,
    align:"center",
    align: "center",
  },
  {
    title: '工序序号',
    field: 'processNumber',
    title: "工序序号",
    field: "processNumber",
    width: 85,
    align:"center",
    align: "center",
  },
  {
    title: '工序名称',
    field: 'processName',
    title: "工序名称",
    field: "processName",
    width: 150,
    align:"center",
    align: "center",
  },
  {
    title: '工序计划开始日期',
    field: 'processPlanStartDay',
    title: "工序计划开始日期",
    field: "processPlanStartDay",
    width: 200,
    align:"center",
    align: "center",
  },
  {
    title: '工序计划结束日期',
    field: 'processPlanEndDay',
    title: "工序计划结束日期",
    field: "processPlanEndDay",
    width: 200,
    align:"center",
    align: "center",
  },
  {
    title: '未开工数量',
    field: 'notStartWorkCount',
    title: "未开工数量",
    field: "notStartWorkCount",
    width: 140,
    align:"center",
    align: "center",
  },
  {
    title: '已完成数量',
    field: 'completedCount',
    title: "已完成数量",
    field: "completedCount",
    width: 140,
    align:"center",
    align: "center",
  },
  {
    title: '废弃数量',
    field: 'discardCount',
    title: "废弃数量",
    field: "discardCount",
    width: 140,
    align:"center",
    align: "center",
  },
  {
    title: '标准工时',
    field: 'standardTime',
    title: "标准工时",
    field: "standardTime",
    width: 140,
    align:"center",
    align: "center",
  },
  {
    title: '工序排序',
    field: 'processOrder',
    title: "工序排序",
    field: "processOrder",
    width: 140,
    align:"center",
    align: "center",
  },
  // {
  //   title: '集成日期',
@@ -344,35 +404,64 @@
  //   align:"center",
  // }
]);
const hasMore = ref(true);
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    pageSize: 100,
    itemNo: null,
    integrationDay: null,
  },
  rules: {
  }
  rules: {},
});
const { queryParams, form, rules } = toRefs(data);
/** 查询工艺路线列表 */
function getList() {
async function getList() {
  loading.value = true;
  queryParams.value.params = {};
  if (null != daterangeIntegrationDay && '' != daterangeIntegrationDay) {
    queryParams.value.params["beginIntegrationDay"] = daterangeIntegrationDay.value[0];
    queryParams.value.params["endIntegrationDay"] = daterangeIntegrationDay.value[1];
  if (null != daterangeIntegrationDay && "" != daterangeIntegrationDay) {
    queryParams.value.params["beginIntegrationDay"] =
      daterangeIntegrationDay.value[0];
    queryParams.value.params["endIntegrationDay"] =
      daterangeIntegrationDay.value[1];
  }
  listProcessRoute(queryParams.value).then(response => {
    processRouteList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
  const response = await listProcessRoute(queryParams.value);
  // processRouteList.value = response.rows;
  if (processRouteList.value.length < queryParams.value.pageSize) {
    hasMore.value = false;
    processRouteList.value = response.rows;
  } else {
    processRouteList.value = [...processRouteList.value, ...response.rows];
  }
  // total.value = response.total;
  loading.value = false;
}
// async function loadData() {
//   try {
//     const response = await fetch(`https://api.example.com/products?page=${this.page}&limit=${this.pageSize}`);
//     const data = await response.json();
//     if (data.length < this.pageSize) {
//       this.hasMore = false;
//     }
//     this.products.push(...data);
//     this.page++;
//   } catch (error) {
//     console.error('Error fetching data:', error);
//   }
// }
const throttledScroll = throttle(() => {
  queryParams.value.pageNum++;
  getList();
  console.log("1111")
}, 200);
function handleAutoLoadMore() {
  throttledScroll()
}
// 取消按钮
function cancel() {
  open.value = false;
@@ -401,7 +490,7 @@
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null
    updateTime: null,
  };
  proxy.resetForm("processRouteRef");
}
@@ -421,7 +510,7 @@
// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
@@ -436,8 +525,8 @@
/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _id = row.id || ids.value
  getProcessRoute(_id).then(response => {
  const _id = row.id || ids.value;
  getProcessRoute(_id).then((response) => {
    form.value = response.data;
    open.value = true;
    title.value = "修改工艺路线";
@@ -446,16 +535,16 @@
/** 提交按钮 */
function submitForm() {
  proxy.$refs["processRouteRef"].validate(valid => {
  proxy.$refs["processRouteRef"].validate((valid) => {
    if (valid) {
      if (form.value.id != null) {
        updateProcessRoute(form.value).then(response => {
        updateProcessRoute(form.value).then((response) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addProcessRoute(form.value).then(response => {
        addProcessRoute(form.value).then((response) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
@@ -468,25 +557,32 @@
/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal.confirm('是否确认删除工艺路线编号为"' + _ids + '"的数据项?').then(function() {
    return delProcessRoute(_ids);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
  proxy.$modal
    .confirm('是否确认删除工艺路线编号为"' + _ids + '"的数据项?')
    .then(function () {
      return delProcessRoute(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
/** 导入按钮操作 */
function handleImport() {
  upload.title = "工艺路线数据上传";
  upload.open = true;
};
}
/** 导出按钮操作 */
function handleExport() {
  proxy.download('aps/processRoute/export', {
    ...queryParams.value
  }, `processRoute_${new Date().getTime()}.xlsx`)
  proxy.download(
    "aps/processRoute/export",
    {
      ...queryParams.value,
    },
    `processRoute_${new Date().getTime()}.xlsx`
  );
}
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
@@ -495,15 +591,21 @@
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
  if(response.code == '200'){
  if (response.code == "200") {
    batchNumber.value = response.data;
    isVisible.value = true;
    planned.value = false;
    isError.value = false;
    getExampleList();
  }else{
  } 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.$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;
@@ -513,7 +615,7 @@
  loading.value = true;
  queryParams.value = {};
  queryParams.value.batchNumber = batchNumber.value;
  processRouteTempList(queryParams.value).then(response => {
  processRouteTempList(queryParams.value).then((response) => {
    exampleList.value = response.rows;
    total.value = response.total;
    loading.value = false;
@@ -523,7 +625,7 @@
function uploadParse() {
  queryParams.value.params = {};
  queryParams.value.params["batchNumber"] = batchNumber.value;
  confirmProcessRoute(queryParams.value).then(response => {
  confirmProcessRoute(queryParams.value).then((response) => {
    exampleList.value = response.rows;
    loading.value = false;
    isVisible.value = false;
@@ -531,15 +633,15 @@
    planned.value = true;
    upload.open = false;
    ElMessage({
      message: '工艺路线数据已成功上传和解析',
      type: 'success',
    })
      message: "工艺路线数据已成功上传和解析",
      type: "success",
    });
    getList();
  });
}
/** dialog取消 */
function dialogCancel(){
function dialogCancel() {
  if (uploadRef.value) {
    uploadRef.value.clearFiles();
  }
@@ -547,6 +649,7 @@
  isError.value = false;
  planned.value = true;
  upload.open = false;
  upload.isUploading = false;
}
getList();
</script>