dy
2025-04-10 3a61bac8079ae9cad52ecd4ceda99d9105d18647
零件页面代码提交
已修改2个文件
453 ■■■■■ 文件已修改
src/api/partPlan/plan.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/partPlan/index.vue 435 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/partPlan/plan.js
@@ -42,3 +42,21 @@
    method: 'delete'
  })
}
// 查询零件计划管理列表
export function examplePlan(query) {
  return request({
    url: '/aps/partPlanTemp/list',
    method: 'get',
    params: query
  })
}
// 查询零件计划管理列表
export function confirmPart(data) {
  return request({
    url: '/aps/partPlan/confirmPart',
    method: 'post',
    data: data
  })
}
src/views/partPlan/index.vue
@@ -100,24 +100,117 @@
    </HxlhTable>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
      <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="false" 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 text-center">
            <div class="el-upload__tip">
              <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
            </div>
            <span>仅允许导入xls、xlsx格式文件。</span>
            <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
    <el-dialog :title="upload.title" v-model="upload.open" width="90%" append-to-body>
      <el-row :gutter="10">
        <el-col>
          <div style="border-bottom: 1px solid #ccc;" >
            <p>上传Excel文件,包含零件工单信息。系统将解析数据并保存到本地,用于关联到零件计划中。</p>
          </div>
        </template>
      </el-upload>
        </el-col>
        <el-col >
          <div></div>
        </el-col>
        <!-- <el-col>
          <div>
            <h2>Excel模板</h2>
            <h4>请下载并使用此模板填写工艺路线数据</h4>
          </div>
        </el-col> -->
      </el-row>
      <el-row :gutter="10" style="margin-top: 20px;">
        <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="Download"
            @click="importTemplate"
            v-hasPermi="['partPlan:add']"
          >下载Excel模板</el-button>
        </el-col> -->
        <!-- <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="Edit"
            @click="buildEexample"
            v-hasPermi="['partPlan:edit']"
          >生成示例数据</el-button>
        </el-col> -->
      </el-row>
      <!-- <el-row>
        <el-col>
          <div>
            <h2>文件上传</h2>
          </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">
                <!-- <div class="el-upload__tip">
                  <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
                </div> -->
                <span>仅允许导入xls、xlsx格式文件。</span>
                <!-- <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link> -->
              </div>
            </template>
          </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="['partPlan:edit']"
            >上传并解析</el-button>
          </div>
        </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"
            @on-checkbox="handleCheckboxChange"
          >
          </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="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="upload.open = false">取 消</el-button>
          <!-- <el-button type="primary" @click="submitFileForm">确 定</el-button> -->
          <el-button @click="dialogCancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
@@ -125,12 +218,15 @@
</template>
<script setup name="Plan">
import { listPlan, getPlan, delPlan, addPlan, updatePlan } from "@/api/partPlan/plan";
import { listPlan, examplePlan, confirmPart, addPlan, updatePlan } from "@/api/partPlan/plan";
import HxlhTable from '@/components/HxlhTable'
import { getToken } from "@/utils/auth";
import { ref } from "vue";
import { ElMessage } from 'element-plus'
const { proxy } = getCurrentInstance();
const exampleList = ref([]);
const planList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
@@ -138,8 +234,13 @@
const total = ref(0);
const daterangePlanStartDay = ref([]);
const daterangePlanEndDay = ref([]);
const vxeTable = ref(null);
const height = ref(document.documentElement.clientHeight - 260 + "px;")
const isVisible = ref(false);
const isError = ref(false);
const planned = ref(true);
const batchNumber = ref(null);
const exampleHeight = ref("500px");
const uploadRef = ref();
/*** 用户导入参数 */
const upload = reactive({
@@ -154,8 +255,193 @@
  // 设置上传的请求头部
  headers: { Authorization: "Bearer " + getToken() },
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
  url: import.meta.env.VITE_APP_BASE_API + "/aps/partPlan/importData"
});
// 表格配置
const exampleColumns = ref([
  { type: 'seq', title: '序号', width: 60 },
  {
    title: '主计划员',
    field: 'masterPlanner',
    width: 100,
  },
  {
    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: 'weekCycle',
    width: 80,
  },
  {
    title: '主件料号',
    field: 'mainPartNumber',
    width: 150,
  },
  {
    title: '主件图号',
    field: 'mainPartDrawingNumber',
    width: 150,
  },
  {
    title: '客户名称',
    field: 'customer',
    width: 200,
  },
  {
    title: '业务类型',
    field: 'businessType',
    width: 150,
  },
  {
    title: '单据号',
    field: 'documentNumber',
    width: 150,
  },
  {
    title: '需求分类',
    field: 'requirementType',
    width: 150,
  },
  {
    title: '单据状态',
    field: 'documentStatus',
    width: 100,
  },
  {
    title: '料号',
    field: 'itemNumber',
    width: 150,
  },
  {
    title: '图号',
    field: 'drawingNo',
    width: 150,
  },
  {
    title: '版本号',
    field: 'versionNumber',
    width: 100,
  },
  {
    title: '生产数量',
    field: 'productionQuantity',
    width: 100,
  },
  {
    title: '良品数量',
    field: 'goodProductsQuantity',
    width: 100,
  },
  {
    title: '工序号',
    field: 'processNumber',
    width: 150,
  },
  {
    title: '工作中心',
    field: 'workCenter',
    width: 150,
  },
  {
    title: '所属部门',
    field: 'department',
    width: 100,
  },
  {
    title: '计划开工日',
    field: 'planStartDay',
    width: 100,
  },
  {
    title: '计划完工日',
    field: 'planEndDay',
    width: 100,
  },
  {
    title: '备料料号',
    field: 'standbyNumber',
    width: 100,
  },
  {
    title: '备料名称',
    field: 'standbyName',
    width: 200,
  },
  {
    title: '备料库存',
    field: 'standbyStock',
    width: 100,
  },
  {
    title: '下道工序所属部门',
    field: 'nextProcessDeparment',
    width: 150,
  },
  {
    title: '是否挂起',
    field: 'isSuspended',
    width: 100,
  },
  {
    title: '外协标识',
    field: 'isOutsourcing',
    width: 100,
  },
  {
    title: '账套',
    field: 'account',
    width: 100,
  },
  {
    title: '上阶物料',
    field: 'advancedMaterials',
    width: 100,
  },
  {
    title: '上阶单据号',
    field: 'advancedDocumentNumber',
    width: 100,
  },
  {
    title: '上阶需求日期',
    field: 'advancedRequirementDay',
    width: 150,
  },
  {
    title: '计划齐套',
    field: 'isPlanComplete',
    width: 100,
  },
  {
    title: '库存齐套',
    field: 'isStockComplete',
    width: 100,
  },
  {
    title: '是否有折返工序',
    field: 'hasTurnback',
    width: 150,
  },
  {
    title: '风险标识',
    field: 'hasRisk',
    width: 100,
  },
]);
// 表格配置 
const columns = ref([
@@ -204,17 +490,17 @@
  {
    title: '业务类型',
    field: 'businessType',
    width: 100,
    width: 150,
  },
  {
    title: '单据号',
    field: 'documentNumber',
    width: 100,
    width: 150,
  },
  {
    title: '需求分类',
    field: 'requirementType',
    width: 100,
    width: 150,
  },
  {
    title: '单据状态',
@@ -224,12 +510,12 @@
  {
    title: '料号',
    field: 'itemNumber',
    width: 100,
    width: 150,
  },
  {
    title: '图号',
    field: 'drawingNo',
    width: 100,
    width: 150,
  },
  {
    title: '版本号',
@@ -249,12 +535,12 @@
  {
    title: '工序号',
    field: 'processNumber',
    width: 100,
    width: 150,
  },
  {
    title: '工作中心',
    field: 'workCenter',
    width: 100,
    width: 150,
  },
  {
    title: '所属部门',
@@ -279,7 +565,7 @@
  {
    title: '备料名称',
    field: 'standbyName',
    width: 100,
    width: 200,
  },
  {
    title: '备料库存',
@@ -289,7 +575,7 @@
  {
    title: '下道工序所属部门',
    field: 'nextProcessDeparment',
    width: 100,
    width: 150,
  },
  {
    title: '是否挂起',
@@ -319,7 +605,7 @@
  {
    title: '上阶需求日期',
    field: 'advancedRequirementDay',
    width: 100,
    width: 150,
  },
  {
    title: '计划齐套',
@@ -334,7 +620,7 @@
  {
    title: '是否有折返工序',
    field: 'hasTurnback',
    width: 100,
    width: 150,
  },
  {
    title: '风险标识',
@@ -345,14 +631,25 @@
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    documentNumber: null,
    customer: null,
    batchNumber: null,
  }
});
const { queryParams } = toRefs(data);
/** 查询零件计划临时管理列表 */
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 getList() {
@@ -368,7 +665,6 @@
  }
  listPlan(queryParams.value).then(response => {
    planList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
@@ -393,18 +689,18 @@
};
/** 批量修改计划开工日按钮操作 */
function plannedStart(row) {
function plannedStart() {
  
}
/** 批量修改计划完工日按钮操作 */
function plannedEnd(row) {
function plannedEnd() {
}
/** 导入按钮操作 */
function handleImport() {
  upload.title = "导入";
  upload.title = "零件工单数据上传";
  upload.open = true;
};
@@ -415,5 +711,72 @@
  }, `plan_${new Date().getTime()}.xlsx`)
}
/** 下载模板操作 */
function importTemplate() {
  proxy.download("system/user/importTemplate", {
  }, `user_template_${new Date().getTime()}.xlsx`);
};
/** buildEexample */
function buildEexample() {
  proxy.$refs["uploadRef"].submit();
};
/**文件上传中处理 */
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;
  confirmPart(queryParams.value).then(response => {
    exampleList.value = response.rows;
    loading.value = false;
    isVisible.value = false;
    isError.value = false;
    planned.value = true;
    upload.open = false;
    ElMessage({
      message: '零件工单数据已成功上传和解析',
      type: 'success',
    })
    getList();
  });
}
/** dialog取消 */
function dialogCancel(){
  if (uploadRef.value) {
    uploadRef.value.clearFiles();
  }
  isVisible.value = false;
  isError.value = false;
  planned.value = true;
  upload.open = false;
}
getList();
</script>
<style lang="css" scoped>
h4 {
  font-weight: bold;
}
</style>