| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"> |
| | | <el-form-item label="生产数量" prop="productionQuantity"> |
| | | <el-input |
| | | v-model="queryParams.productionQuantity" |
| | | placeholder="请输入生产数量" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="标准工时" prop="standardTime"> |
| | | <el-input |
| | | v-model="queryParams.standardTime" |
| | | placeholder="请输入标准工时" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="工序总工时" prop="processTotalTime"> |
| | | <el-input |
| | | v-model="queryParams.processTotalTime" |
| | | placeholder="请输入工序总工时" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="设计工时" prop="designTimes"> |
| | | <el-input |
| | | v-model="queryParams.designTimes" |
| | | placeholder="请输入设计工时" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | /> |
| | | </el-form-item> |
| | | <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-form> |
| | | |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="handleAdd" |
| | | v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:add']" |
| | | >新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | icon="Edit" |
| | | :disabled="single" |
| | | @click="handleUpdate" |
| | | v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:edit']" |
| | | >修改</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="danger" |
| | | plain |
| | | icon="Delete" |
| | | :disabled="multiple" |
| | | @click="handleDelete" |
| | | v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:remove']" |
| | | >删除</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="Download" |
| | | @click="handleExport" |
| | | v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:export']" |
| | | v-hasPermi="['apsPartRouteStat:apsPartRouteStat:export']" |
| | | >导出</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | |
| | | <el-table v-loading="loading" :data="ApsPartRouteStatList" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <el-table-column label="工单号" align="center" prop="workOrderNo" /> |
| | | <el-table-column label="工序号" align="center" prop="roadProcessNumber" /> |
| | | <el-table-column label="当前工序号" align="center" prop="currentProcessNumber" /> |
| | | <el-table-column label="生产数量" align="center" prop="productionQuantity" /> |
| | | <el-table-column label="标准工时" align="center" prop="standardTime" /> |
| | | <el-table-column label="工序总工时" align="center" prop="processTotalTime" /> |
| | | <el-table-column label="计划开工日" align="center" prop="processPlanStartDay" /> |
| | | <el-table-column label="设计工时" align="center" prop="designTimes" /> |
| | | <el-table-column label="批次号" align="center" prop="batchNumber" /> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:edit']">修改</el-button> |
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['ApsPartRouteStat:ApsPartRouteStat:remove']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <pagination |
| | | v-show="total>0" |
| | | :total="total" |
| | | v-model:page="queryParams.pageNum" |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <!-- 添加或修改零件统计表对话框 --> |
| | | <el-dialog :title="title" v-model="open" width="500px" append-to-body> |
| | | <el-form ref="ApsPartRouteStatRef" :model="form" :rules="rules" label-width="80px"> |
| | | <el-form-item label="生产数量" prop="productionQuantity"> |
| | | <el-input v-model="form.productionQuantity" placeholder="请输入生产数量" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准工时" prop="standardTime"> |
| | | <el-input v-model="form.standardTime" placeholder="请输入标准工时" /> |
| | | </el-form-item> |
| | | <el-form-item label="工序总工时" prop="processTotalTime"> |
| | | <el-input v-model="form.processTotalTime" placeholder="请输入工序总工时" /> |
| | | </el-form-item> |
| | | <el-form-item label="设计工时" prop="designTimes"> |
| | | <el-input v-model="form.designTimes" placeholder="请输入设计工时" /> |
| | | </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> |
| | | <vxe-grid ref="gridRef" v-bind="gridOptions"></vxe-grid> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup name="ApsPartRouteStat"> |
| | | import { listApsPartRouteStat, getApsPartRouteStat, delApsPartRouteStat, addApsPartRouteStat, updateApsPartRouteStat } from "@/api/ApsPartRouteStat/ApsPartRouteStat"; |
| | | <script setup name="apsPartRouteStat"> |
| | | import { query } from "@/api/apsPartRouteStat/apsPartRouteStat"; |
| | | import { ref } from "vue"; |
| | | import * as XLSX from 'xlsx'; |
| | | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const ApsPartRouteStatList = ref([]); |
| | | const open = ref(false); |
| | | const loading = ref(true); |
| | | const showSearch = ref(true); |
| | | const ids = ref([]); |
| | | const single = ref(true); |
| | | const multiple = ref(true); |
| | | const total = ref(0); |
| | | const title = ref(""); |
| | | const gridRef = ref(); |
| | | const height = ref(document.documentElement.clientHeight - 130 + "px;") |
| | | const headers = ref([]); |
| | | const exportData = ref([]); |
| | | |
| | | const data = reactive({ |
| | | form: {}, |
| | | queryParams: { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | workOrderNo: null, |
| | | roadProcessNumber: null, |
| | | currentProcessNumber: null, |
| | | productionQuantity: null, |
| | | standardTime: null, |
| | | processTotalTime: null, |
| | | processPlanStartDay: null, |
| | | designTimes: null, |
| | | batchNumber: null |
| | | const gridOptions = reactive({ |
| | | border: true, |
| | | loading: false, |
| | | showOverflow: true, |
| | | showHeaderOverflow: true, |
| | | showFooterOverflow: true, |
| | | height: height, |
| | | columnConfig: { |
| | | resizable: true |
| | | }, |
| | | rules: { |
| | | roadProcessNumber: [ |
| | | { required: true, message: "工序号不能为空", trigger: "blur" } |
| | | ], |
| | | processPlanStartDay: [ |
| | | { required: true, message: "计划开工日不能为空", trigger: "blur" } |
| | | ], |
| | | scrollX: { |
| | | enabled: true, |
| | | gt: 0, |
| | | threshold: 50 |
| | | }, |
| | | scrollY: { |
| | | enabled: true, |
| | | gt: 0, |
| | | threshold: 50 |
| | | } |
| | | }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | let rowKey = 0 |
| | | let colKey = 0 |
| | | let tableColumn = [] |
| | | let tableData = [] |
| | | let merges = []; |
| | | |
| | | /** 查询零件统计表列表 */ |
| | | function getList() { |
| | | loading.value = true; |
| | | listApsPartRouteStat(queryParams.value).then(response => { |
| | | ApsPartRouteStatList.value = response.rows; |
| | | total.value = response.total; |
| | | loading.value = false; |
| | | }); |
| | | } |
| | | query().then(response => { |
| | | if(response.code == '200'){ |
| | | loading.value = true; |
| | | const colList = [] |
| | | let headersOne = [] |
| | | let headersTwo = [] |
| | | headersOne.push('日期'); |
| | | headersTwo.push('资源组'); |
| | | colList.push({ |
| | | field: 'dateCol', |
| | | title: '日期', |
| | | children: [ |
| | | { field: `resourceName`, title: '资源组', width: 100}, |
| | | ], |
| | | width: 160 |
| | | }) |
| | | response.planTitle.forEach(item => { |
| | | headersOne.push(item); |
| | | headersOne.push(''); |
| | | headersOne.push(''); |
| | | headersTwo.push('设计工时'); |
| | | headersTwo.push('需求工时'); |
| | | headersTwo.push('产能负荷'); |
| | | colKey++ |
| | | colList.push({ |
| | | field: `dateColTime${colKey}`, |
| | | title: item, |
| | | children: [ |
| | | { field: `designTimes${colKey}`, title: '设计工时', width: 100}, |
| | | { field: `requireTimes${colKey}`, title: '需求工时', width: 100}, |
| | | { field: `capacityLoad${colKey}`, title: '产能负荷', width: 100}, |
| | | ], |
| | | width: 160 |
| | | }) |
| | | }); |
| | | |
| | | // 取消按钮 |
| | | function cancel() { |
| | | open.value = false; |
| | | reset(); |
| | | } |
| | | headers.value.push(headersOne); |
| | | headers.value.push(headersTwo); |
| | | |
| | | // 表单重置 |
| | | function reset() { |
| | | form.value = { |
| | | id: null, |
| | | workOrderNo: null, |
| | | roadProcessNumber: null, |
| | | currentProcessNumber: null, |
| | | productionQuantity: null, |
| | | standardTime: null, |
| | | processTotalTime: null, |
| | | processPlanStartDay: null, |
| | | designTimes: null, |
| | | delFlag: null, |
| | | createBy: null, |
| | | batchNumber: null |
| | | }; |
| | | proxy.resetForm("ApsPartRouteStatRef"); |
| | | } |
| | | const columnList = [...tableColumn, ...colList] |
| | | const dataList = [] |
| | | let startCol = 1; |
| | | |
| | | /** 搜索按钮操作 */ |
| | | function handleQuery() { |
| | | queryParams.value.pageNum = 1; |
| | | getList(); |
| | | } |
| | | |
| | | /** 重置按钮操作 */ |
| | | function resetQuery() { |
| | | 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 |
| | | getApsPartRouteStat(_id).then(response => { |
| | | form.value = response.data; |
| | | open.value = true; |
| | | title.value = "修改零件统计表"; |
| | | }); |
| | | } |
| | | |
| | | /** 提交按钮 */ |
| | | function submitForm() { |
| | | proxy.$refs["ApsPartRouteStatRef"].validate(valid => { |
| | | if (valid) { |
| | | if (form.value.id != null) { |
| | | updateApsPartRouteStat(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("修改成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | } else { |
| | | addApsPartRouteStat(form.value).then(response => { |
| | | proxy.$modal.msgSuccess("新增成功"); |
| | | open.value = false; |
| | | getList(); |
| | | }); |
| | | //获取map |
| | | response.planTable.forEach(mapItem => { |
| | | rowKey++ |
| | | let lastCol = startCol + 2; |
| | | merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c: lastCol} }); |
| | | startCol = lastCol + 1; |
| | | let data = []; |
| | | const item = { |
| | | id: `${rowKey}` |
| | | } |
| | | for (const [key, listValue] of Object.entries(mapItem)) { |
| | | data.push(key); |
| | | item[`resourceName`] = key; |
| | | let tableKey = 0; |
| | | listValue.forEach(listItem => { |
| | | tableKey++ |
| | | item[`designTimes${tableKey}`] = listItem.designTimes; |
| | | item[`requireTimes${tableKey}`] = listItem.requireTimes; |
| | | item[`capacityLoad${tableKey}`] = listItem.capacityLoad; |
| | | data.push(listItem.designTimes); |
| | | data.push(listItem.requireTimes); |
| | | data.push(listItem.capacityLoad); |
| | | }); |
| | | } |
| | | exportData.value.push(data); |
| | | dataList.push(item); |
| | | }); |
| | | |
| | | const $grid = gridRef.value |
| | | if ($grid) { |
| | | tableColumn = columnList |
| | | tableData = [...tableData, ...dataList] |
| | | $grid.loadColumn(tableColumn) |
| | | $grid.loadData(tableData) |
| | | gridOptions.loading = false |
| | | } |
| | | |
| | | loading.value = false; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | function handleDelete(row) { |
| | | const _ids = row.id || ids.value; |
| | | proxy.$modal.confirm('是否确认删除零件统计表编号为"' + _ids + '"的数据项?').then(function() { |
| | | return delApsPartRouteStat(_ids); |
| | | }).then(() => { |
| | | getList(); |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | }).catch(() => {}); |
| | | } |
| | | |
| | | /** 导出按钮操作 */ |
| | | function handleExport() { |
| | | proxy.download('ApsPartRouteStat/ApsPartRouteStat/export', { |
| | | ...queryParams.value |
| | | }, `ApsPartRouteStat_${new Date().getTime()}.xlsx`) |
| | | |
| | | // 合并表头和数据 |
| | | const finalData = [...headers.value, ...exportData.value]; |
| | | |
| | | // 将数据转换为 worksheet |
| | | const ws = XLSX.utils.aoa_to_sheet(finalData); |
| | | |
| | | // 合并单元格(如果需要) |
| | | /* ws['!merges'] = [ |
| | | { s: { r: 0, c: 1 }, e: { r: 0, c: 3 } }, |
| | | { s: { r: 0, c: 0 }, e: { r: 0, c: 0 } } |
| | | ]; */ |
| | | |
| | | ws['!merges'] = merges; |
| | | |
| | | // 创建 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`); |
| | | } |
| | | |
| | | getList(); |