feat(production): 添加周排产计划和子件物料周需求功能

- 新增周排产计划页面,支持年第周、周一日期、编码、订单号等查询条件
- 实现周排产计划的增删改查功能,包含每日计划量的编辑
- 添加批量保存修改功能,支持同时更新多条记录
- 实现批量填充功能,可对选中的行和列进行统一数值填充
- 添加导入导出功能,支持Excel文件的数据导入和导出
- 新增子件物料周需求页面,支持物料编码和描述的查询
- 实现子件物料周需求的增删改查功能,包含周一到周日的需求量编辑
- 添加权限控制,不同操作需要相应的权限验证
- 实现表格列的显示隐藏控制,支持自定义列显示
- 添加合计计算功能,自动计算每周计划量和需求量的总计
master
zangch@mesnac.com 4 months ago
parent d49e29012b
commit 14e57d7099

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询周排产计划列表
export function listPlan(query) {
return request({
url: '/production/plan/list',
method: 'get',
params: query
})
}
// 查询周排产计划详细
export function getPlan(id) {
return request({
url: '/production/plan/' + id,
method: 'get'
})
}
// 新增周排产计划
export function addPlan(data) {
return request({
url: '/production/plan',
method: 'post',
data: data
})
}
// 修改周排产计划
export function updatePlan(data) {
return request({
url: '/production/plan',
method: 'put',
data: data
})
}
// 删除周排产计划
export function delPlan(id) {
return request({
url: '/production/plan/' + id,
method: 'delete'
})
}
// 批量更新周排产计划
export function batchUpdatePlan(data) {
return request({
url: '/production/plan/batchUpdate',
method: 'put',
data: data
})
}

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询子件物料周需求列表
export function listReq(query) {
return request({
url: '/production/req/list',
method: 'get',
params: query
})
}
// 查询子件物料周需求详细
export function getReq(id) {
return request({
url: '/production/req/' + id,
method: 'get'
})
}
// 新增子件物料周需求
export function addReq(data) {
return request({
url: '/production/req',
method: 'post',
data: data
})
}
// 修改子件物料周需求
export function updateReq(data) {
return request({
url: '/production/req',
method: 'put',
data: data
})
}
// 删除子件物料周需求
export function delReq(id) {
return request({
url: '/production/req/' + id,
method: 'delete'
})
}
// 批量更新子件物料周需求
export function batchUpdateReq(data) {
return request({
url: '/production/req/batchUpdate',
method: 'put',
data: data
})
}

@ -0,0 +1,749 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="年第周" prop="yearWeek">
<el-input
v-model="queryParams.yearWeek"
placeholder="如202501"
clearable
style="width: 120px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="周一日期" prop="weekStartDate">
<el-date-picker clearable
v-model="queryParams.weekStartDate"
type="date"
value-format="yyyy-MM-dd"
style="width: 150px"
:picker-options="mondayPickerOptions"
placeholder="选择周一日期">
</el-date-picker>
</el-form-item>
<el-form-item label="编码" prop="itemCode">
<el-input
v-model="queryParams.itemCode"
placeholder="请输入编码"
clearable
style="width: 130px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="订单号" prop="orderNo">
<el-input
v-model="queryParams.orderNo"
placeholder="请输入订单号"
clearable
style="width: 130px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="工厂" prop="plantCode">
<el-input
v-model="queryParams.plantCode"
placeholder="请输入工厂"
clearable
style="width: 100px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @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="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['production:plan:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['production:plan:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['production:plan:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['production:plan:import']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="openExportDialog"
v-hasPermi="['production:plan:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-check"
size="mini"
:disabled="!hasChanges"
@click="handleBatchSave"
v-hasPermi="['production:plan:edit']"
>保存修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-document-copy"
size="mini"
:disabled="multiple"
@click="openBatchFillDialog"
v-hasPermi="['production:plan:edit']"
>批量填充</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="年第周" align="center" prop="yearWeek" width="90" v-if="columns[0].visible"/>
<el-table-column label="周一日期" align="center" prop="weekStartDate" width="110" v-if="columns[1].visible">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.weekStartDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="序号" align="center" prop="seqNo" width="60" v-if="columns[2].visible"/>
<el-table-column label="编码" align="center" prop="itemCode" width="110" v-if="columns[3].visible"/>
<el-table-column label="描述" align="center" prop="itemDesc" min-width="150" :show-overflow-tooltip="true" v-if="columns[4].visible"/>
<el-table-column label="工厂" align="center" prop="plantCode" width="70" v-if="columns[5].visible"/>
<el-table-column label="订单号" align="center" prop="orderNo" width="90" v-if="columns[6].visible"/>
<el-table-column label="行号" align="center" prop="orderLineNo" width="60" v-if="columns[7].visible"/>
<el-table-column label="1日" align="center" width="80" v-if="columns[8].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD1" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="2日" align="center" width="80" v-if="columns[9].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD2" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="3日" align="center" width="80" v-if="columns[10].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD3" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="4日" align="center" width="80" v-if="columns[11].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD4" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="5日" align="center" width="80" v-if="columns[12].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD5" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="6日" align="center" width="80" v-if="columns[13].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD6" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="7日" align="center" width="80" v-if="columns[14].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.planD7" :min="0" :precision="0" :controls="false" size="mini" style="width: 60px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周合计" align="center" width="80" v-if="columns[15].visible">
<template slot-scope="scope">
<span>{{ calcRowTotal(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['production:plan:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['production:plan:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改周排产计划对话框 -->
<el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="90px">
<el-row>
<el-col :span="8">
<el-form-item label="年第周" prop="yearWeek">
<el-input v-model="form.yearWeek" placeholder="如202501" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="周一日期" prop="weekStartDate">
<el-date-picker clearable
v-model="form.weekStartDate"
type="date"
value-format="yyyy-MM-dd"
style="width: 100%"
placeholder="选择周一日期">
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="序号" prop="seqNo">
<el-input-number v-model="form.seqNo" :min="1" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="编码" prop="itemCode">
<el-input v-model="form.itemCode" placeholder="请输入编码" />
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="描述" prop="itemDesc">
<el-input v-model="form.itemDesc" placeholder="请输入描述" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="工厂" prop="plantCode">
<el-input v-model="form.plantCode" placeholder="请输入工厂" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="订单号" prop="orderNo">
<el-input v-model="form.orderNo" placeholder="请输入订单号" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="行号" prop="orderLineNo">
<el-input v-model="form.orderLineNo" placeholder="请输入行号" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">每日计划量</el-divider>
<el-row>
<el-col :span="6">
<el-form-item label="1日" prop="planD1" label-width="40px">
<el-input-number v-model="form.planD1" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="2日" prop="planD2" label-width="40px">
<el-input-number v-model="form.planD2" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="3日" prop="planD3" label-width="40px">
<el-input-number v-model="form.planD3" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="4日" prop="planD4" label-width="40px">
<el-input-number v-model="form.planD4" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<el-form-item label="5日" prop="planD5" label-width="40px">
<el-input-number v-model="form.planD5" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="6日" prop="planD6" label-width="40px">
<el-input-number v-model="form.planD6" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="7日" prop="planD7" label-width="40px">
<el-input-number v-model="form.planD7" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="合计" label-width="40px">
<el-input :value="weekTotal" disabled style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="450px" append-to-body>
<el-form label-width="100px">
<el-form-item label="周一日期" required>
<el-date-picker
v-model="upload.weekStartDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="mondayPickerOptions"
placeholder="请选择周一日期"
style="width: 100%"
/>
</el-form-item>
</el-form>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url"
:data="{ weekStartDate: upload.weekStartDate }"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
<!-- 导出对话框 -->
<el-dialog title="导出周排产计划" :visible.sync="exportOpen" width="450px" append-to-body>
<el-form label-width="100px">
<el-form-item label="开始周一" required>
<el-date-picker
v-model="exportParams.startDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="mondayPickerOptions"
placeholder="选择开始周一日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="结束周一" required>
<el-date-picker
v-model="exportParams.endDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="mondayPickerOptions"
placeholder="选择结束周一日期"
style="width: 100%"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleExport"> </el-button>
<el-button @click="exportOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 批量填充对话框 -->
<el-dialog title="批量填充" :visible.sync="batchFillOpen" width="400px" append-to-body>
<el-form label-width="100px">
<el-form-item label="已选行数">
<span class="el-tag el-tag--info">{{ selectedRows.length }} </span>
</el-form-item>
<el-form-item label="填充列" required>
<el-checkbox-group v-model="batchFill.columns">
<el-checkbox label="planD1">1</el-checkbox>
<el-checkbox label="planD2">2</el-checkbox>
<el-checkbox label="planD3">3</el-checkbox>
<el-checkbox label="planD4">4</el-checkbox>
<el-checkbox label="planD5">5</el-checkbox>
<el-checkbox label="planD6">6</el-checkbox>
<el-checkbox label="planD7">7</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="填充数值" required>
<el-input-number v-model="batchFill.value" :min="0" :precision="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleBatchFill"> </el-button>
<el-button @click="batchFillOpen = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listPlan, getPlan, delPlan, addPlan, updatePlan, batchUpdatePlan } from "@/api/production/plan";
import { getToken } from "@/utils/auth";
export default {
name: "Plan",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
planList: [],
// ID
changedIds: new Set(),
//
title: "",
//
open: false,
//
exportOpen: false,
//
exportParams: {
startDate: null,
endDate: null
},
//
batchFillOpen: false,
//
batchFill: {
columns: [],
value: 0
},
//
selectedRows: [],
//
mondayPickerOptions: {
disabledDate(time) {
return time.getDay() !== 1;
}
},
//
queryParams: {
pageNum: 1,
pageSize: 10,
yearWeek: null,
weekStartDate: null,
itemCode: null,
orderNo: null,
plantCode: null
},
//
form: {},
//
rules: {
yearWeek: [
{ required: true, message: "年第周不能为空", trigger: "blur" }
],
weekStartDate: [
{ required: true, message: "周一日期不能为空", trigger: "blur" }
],
itemCode: [
{ required: true, message: "编码不能为空", trigger: "blur" }
],
},
//
upload: {
open: false,
title: "周排产计划导入",
isUploading: false,
weekStartDate: null,
headers: { Authorization: "Bearer " + getToken() },
url: process.env.VUE_APP_BASE_API + "/production/plan/importData"
},
columns: [
{ key: 0, label: `年第周`, visible: true },
{ key: 1, label: `周一日期`, visible: true },
{ key: 2, label: `序号`, visible: true },
{ key: 3, label: `编码`, visible: true },
{ key: 4, label: `描述`, visible: true },
{ key: 5, label: `工厂`, visible: true },
{ key: 6, label: `订单号`, visible: true },
{ key: 7, label: `行号`, visible: true },
{ key: 8, label: `1日`, visible: true },
{ key: 9, label: `2日`, visible: true },
{ key: 10, label: `3日`, visible: true },
{ key: 11, label: `4日`, visible: true },
{ key: 12, label: `5日`, visible: true },
{ key: 13, label: `6日`, visible: true },
{ key: 14, label: `7日`, visible: true },
{ key: 15, label: `周合计`, visible: true },
]
};
},
computed: {
weekTotal() {
return (this.form.planD1 || 0) + (this.form.planD2 || 0) + (this.form.planD3 || 0) +
(this.form.planD4 || 0) + (this.form.planD5 || 0) + (this.form.planD6 || 0) +
(this.form.planD7 || 0);
},
hasChanges() {
return this.changedIds.size > 0;
}
},
created() {
this.getList();
},
methods: {
/** 查询周排产计划列表 */
getList() {
this.loading = true;
this.changedIds = new Set();
listPlan(this.queryParams).then(response => {
this.planList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 标记行已修改 */
markChanged(row) {
// Vue 2 Set
const newSet = new Set(this.changedIds);
newSet.add(row.id);
this.changedIds = newSet;
},
/** 计算行合计 */
calcRowTotal(row) {
return (Number(row.planD1) || 0) + (Number(row.planD2) || 0) + (Number(row.planD3) || 0) +
(Number(row.planD4) || 0) + (Number(row.planD5) || 0) + (Number(row.planD6) || 0) +
(Number(row.planD7) || 0);
},
/** 批量保存修改 */
handleBatchSave() {
const changedRows = this.planList.filter(row => this.changedIds.has(row.id));
if (changedRows.length === 0) {
this.$modal.msgWarning("没有需要保存的修改");
return;
}
this.$modal.confirm('是否确认保存 ' + changedRows.length + ' 条修改的数据?').then(() => {
batchUpdatePlan(changedRows).then(response => {
this.$modal.msgSuccess(response.msg);
this.changedIds = new Set();
this.getList();
});
}).catch(() => {});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
yearWeek: null,
weekStartDate: null,
seqNo: 1,
itemCode: null,
itemDesc: null,
plantCode: null,
orderNo: null,
orderLineNo: null,
planD1: 0,
planD2: 0,
planD3: 0,
planD4: 0,
planD5: 0,
planD6: 0,
planD7: 0
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.selectedRows = selection
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 打开批量填充对话框 */
openBatchFillDialog() {
if (this.selectedRows.length === 0) {
this.$modal.msgWarning("请先选择要填充的行");
return;
}
this.batchFill.columns = [];
this.batchFill.value = 0;
this.batchFillOpen = true;
},
/** 执行批量填充 */
handleBatchFill() {
if (this.batchFill.columns.length === 0) {
this.$modal.msgWarning("请选择要填充的列");
return;
}
//
this.selectedRows.forEach(row => {
this.batchFill.columns.forEach(col => {
row[col] = this.batchFill.value;
});
this.markChanged(row);
});
this.batchFillOpen = false;
this.$modal.msgSuccess(`已填充 ${this.selectedRows.length} 行数据`);
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加周排产计划";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getPlan(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改周排产计划";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updatePlan(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addPlan(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除周排产计划编号为"' + ids + '"的数据项?').then(function() {
return delPlan(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 打开导出对话框 */
openExportDialog() {
this.exportParams.startDate = null;
this.exportParams.endDate = null;
this.exportOpen = true;
},
/** 导出按钮操作 */
handleExport() {
if (!this.exportParams.startDate || !this.exportParams.endDate) {
this.$modal.msgWarning("请选择导出的时间范围");
return;
}
if (this.exportParams.startDate > this.exportParams.endDate) {
this.$modal.msgWarning("开始日期不能大于结束日期");
return;
}
this.exportOpen = false;
this.download('production/plan/export', {
...this.queryParams,
'params[beginWeekStartDate]': this.exportParams.startDate,
'params[endWeekStartDate]': this.exportParams.endDate
}, `周排产计划_${new Date().getTime()}.xlsx`)
},
/** 导入按钮操作 */
handleImport() {
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
this.download('production/plan/importTemplate', {}, `周排产计划模板_${new Date().getTime()}.xlsx`)
},
/** 文件上传中处理 */
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
/** 文件上传成功处理 */
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
/** 提交上传文件 */
submitFileForm() {
this.$refs.upload.submit();
}
}
};
</script>
<style scoped>
.changed-cell ::v-deep .el-input__inner {
background-color: #fffbe6 !important;
border-color: #faad14 !important;
}
</style>

@ -0,0 +1,705 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
<el-form-item label="年第周" prop="yearWeek">
<el-input
v-model="queryParams.yearWeek"
placeholder="如202501"
clearable
style="width: 120px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="周一日期" prop="weekStartDate">
<el-date-picker clearable
v-model="queryParams.weekStartDate"
type="date"
value-format="yyyy-MM-dd"
style="width: 150px"
:picker-options="mondayPickerOptions"
placeholder="选择周一日期">
</el-date-picker>
</el-form-item>
<el-form-item label="物料编码" prop="itemCode">
<el-input
v-model="queryParams.itemCode"
placeholder="请输入物料编码"
clearable
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物料描述" prop="itemDesc">
<el-input
v-model="queryParams.itemDesc"
placeholder="请输入物料描述"
clearable
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @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="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['production:req:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['production:req:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['production:req:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['production:req:import']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="openExportDialog"
v-hasPermi="['production:req:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-check"
size="mini"
:disabled="!hasChanges"
@click="handleBatchSave"
v-hasPermi="['production:req:edit']"
>保存修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-document-copy"
size="mini"
:disabled="multiple"
@click="openBatchFillDialog"
v-hasPermi="['production:req:edit']"
>批量填充</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="reqList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="年第周" align="center" prop="yearWeek" width="90" v-if="columns[0].visible"/>
<el-table-column label="周一日期" align="center" prop="weekStartDate" width="110" v-if="columns[1].visible">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.weekStartDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="物料编码" align="center" prop="itemCode" width="120" v-if="columns[2].visible"/>
<el-table-column label="物料描述" align="center" prop="itemDesc" min-width="180" :show-overflow-tooltip="true" v-if="columns[3].visible"/>
<el-table-column label="周一" align="center" width="90" v-if="columns[4].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqMon" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周二" align="center" width="90" v-if="columns[5].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqTue" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周三" align="center" width="90" v-if="columns[6].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqWed" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周四" align="center" width="90" v-if="columns[7].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqThu" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周五" align="center" width="90" v-if="columns[8].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqFri" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周六" align="center" width="90" v-if="columns[9].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqSat" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周日" align="center" width="90" v-if="columns[10].visible">
<template slot-scope="scope">
<el-input-number v-model="scope.row.reqSun" :min="0" :precision="0" :controls="false" size="mini" style="width: 70px" :class="{'changed-cell': changedIds.has(scope.row.id)}" @change="markChanged(scope.row)" />
</template>
</el-table-column>
<el-table-column label="周合计" align="center" width="80" v-if="columns[11].visible">
<template slot-scope="scope">
<span>{{ calcRowTotal(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['production:req:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['production:req:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改子件物料周需求对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="年第周" prop="yearWeek">
<el-input v-model="form.yearWeek" placeholder="如202501" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="周一日期" prop="weekStartDate">
<el-date-picker clearable
v-model="form.weekStartDate"
type="date"
value-format="yyyy-MM-dd"
style="width: 100%"
placeholder="选择周一日期">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="物料编码" prop="itemCode">
<el-input v-model="form.itemCode" placeholder="请输入物料编码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料描述" prop="itemDesc">
<el-input v-model="form.itemDesc" placeholder="请输入物料描述" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">每日需求量</el-divider>
<el-row>
<el-col :span="6">
<el-form-item label="周一" prop="reqMon" label-width="50px">
<el-input-number v-model="form.reqMon" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="周二" prop="reqTue" label-width="50px">
<el-input-number v-model="form.reqTue" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="周三" prop="reqWed" label-width="50px">
<el-input-number v-model="form.reqWed" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="周四" prop="reqThu" label-width="50px">
<el-input-number v-model="form.reqThu" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<el-form-item label="周五" prop="reqFri" label-width="50px">
<el-input-number v-model="form.reqFri" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="周六" prop="reqSat" label-width="50px">
<el-input-number v-model="form.reqSat" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="周日" prop="reqSun" label-width="50px">
<el-input-number v-model="form.reqSun" :min="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="合计" label-width="50px">
<el-input :value="weekTotal" disabled style="width: 100%" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="450px" append-to-body>
<el-form label-width="100px">
<el-form-item label="周一日期" required>
<el-date-picker
v-model="upload.weekStartDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="mondayPickerOptions"
placeholder="请选择周一日期"
style="width: 100%"
/>
</el-form-item>
</el-form>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url"
:data="{ weekStartDate: upload.weekStartDate }"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
<!-- 导出对话框 -->
<el-dialog title="导出子件物料周需求" :visible.sync="exportOpen" width="450px" append-to-body>
<el-form label-width="100px">
<el-form-item label="开始周一" required>
<el-date-picker
v-model="exportParams.startDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="mondayPickerOptions"
placeholder="选择开始周一日期"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="结束周一" required>
<el-date-picker
v-model="exportParams.endDate"
type="date"
value-format="yyyy-MM-dd"
:picker-options="mondayPickerOptions"
placeholder="选择结束周一日期"
style="width: 100%"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleExport"> </el-button>
<el-button @click="exportOpen = false"> </el-button>
</div>
</el-dialog>
<!-- 批量填充对话框 -->
<el-dialog title="批量填充" :visiblse.sync="batchFillOpen" width="400px" append-to-body>
<el-form label-width="100px">
<el-form-item label="已选行数">
<span class="el-tag el-tag--info">{{ selectedRows.length }} </span>
</el-form-item>
<el-form-item label="填充列" required>
<el-checkbox-group v-model="batchFill.columns">
<el-checkbox label="reqMon">周一</el-checkbox>
<el-checkbox label="reqTue">周二</el-checkbox>
<el-checkbox label="reqWed">周三</el-checkbox>
<el-checkbox label="reqThu">周四</el-checkbox>
<el-checkbox label="reqFri">周五</el-checkbox>
<el-checkbox label="reqSat">周六</el-checkbox>
<el-checkbox label="reqSun">周日</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="填充数值" required>
<el-input-number v-model="batchFill.value" :min="0" :precision="0" controls-position="right" style="width: 100%" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleBatchFill"> </el-button>
<el-button @click="batchFillOpen = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listReq, getReq, delReq, addReq, updateReq, batchUpdateReq } from "@/api/production/req";
import { getToken } from "@/utils/auth";
export default {
name: "Req",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
reqList: [],
// ID
changedIds: new Set(),
//
title: "",
//
open: false,
//
exportOpen: false,
//
exportParams: {
startDate: null,
endDate: null
},
//
batchFillOpen: false,
//
batchFill: {
columns: [],
value: 0
},
//
selectedRows: [],
//
mondayPickerOptions: {
disabledDate(time) {
return time.getDay() !== 1;
}
},
//
queryParams: {
pageNum: 1,
pageSize: 10,
yearWeek: null,
weekStartDate: null,
itemCode: null,
itemDesc: null
},
//
form: {},
//
rules: {
yearWeek: [
{ required: true, message: "年第周不能为空", trigger: "blur" }
],
weekStartDate: [
{ required: true, message: "周一日期不能为空", trigger: "blur" }
],
itemCode: [
{ required: true, message: "物料编码不能为空", trigger: "blur" }
],
},
//
upload: {
open: false,
title: "子件物料周需求导入",
isUploading: false,
weekStartDate: null,
headers: { Authorization: "Bearer " + getToken() },
url: process.env.VUE_APP_BASE_API + "/production/req/importData"
},
columns: [
{ key: 0, label: `年第周`, visible: true },
{ key: 1, label: `周一日期`, visible: true },
{ key: 2, label: `物料编码`, visible: true },
{ key: 3, label: `物料描述`, visible: true },
{ key: 4, label: `周一`, visible: true },
{ key: 5, label: `周二`, visible: true },
{ key: 6, label: `周三`, visible: true },
{ key: 7, label: `周四`, visible: true },
{ key: 8, label: `周五`, visible: true },
{ key: 9, label: `周六`, visible: true },
{ key: 10, label: `周日`, visible: true },
{ key: 11, label: `周合计`, visible: true },
]
};
},
computed: {
weekTotal() {
return (this.form.reqMon || 0) + (this.form.reqTue || 0) + (this.form.reqWed || 0) +
(this.form.reqThu || 0) + (this.form.reqFri || 0) + (this.form.reqSat || 0) +
(this.form.reqSun || 0);
},
hasChanges() {
return this.changedIds.size > 0;
}
},
created() {
this.getList();
},
methods: {
/** 查询子件物料周需求列表 */
getList() {
this.loading = true;
this.changedIds = new Set();
listReq(this.queryParams).then(response => {
this.reqList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 标记行已修改 */
markChanged(row) {
// Vue 2 Set
const newSet = new Set(this.changedIds);
newSet.add(row.id);
this.changedIds = newSet;
},
/** 计算行合计 */
calcRowTotal(row) {
return (Number(row.reqMon) || 0) + (Number(row.reqTue) || 0) + (Number(row.reqWed) || 0) +
(Number(row.reqThu) || 0) + (Number(row.reqFri) || 0) + (Number(row.reqSat) || 0) +
(Number(row.reqSun) || 0);
},
/** 批量保存修改 */
handleBatchSave() {
const changedRows = this.reqList.filter(row => this.changedIds.has(row.id));
if (changedRows.length === 0) {
this.$modal.msgWarning("没有需要保存的修改");
return;
}
this.$modal.confirm('是否确认保存 ' + changedRows.length + ' 条修改的数据?').then(() => {
batchUpdateReq(changedRows).then(response => {
this.$modal.msgSuccess(response.msg);
this.changedIds = new Set();
this.getList();
});
}).catch(() => {});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
yearWeek: null,
weekStartDate: null,
itemCode: null,
itemDesc: null,
reqMon: 0,
reqTue: 0,
reqWed: 0,
reqThu: 0,
reqFri: 0,
reqSat: 0,
reqSun: 0
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.selectedRows = selection
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 打开批量填充对话框 */
openBatchFillDialog() {
if (this.selectedRows.length === 0) {
this.$modal.msgWarning("请先选择要填充的行");
return;
}
this.batchFill.columns = [];
this.batchFill.value = 0;
this.batchFillOpen = true;
},
/** 执行批量填充 */
handleBatchFill() {
if (this.batchFill.columns.length === 0) {
this.$modal.msgWarning("请选择要填充的列");
return;
}
//
this.selectedRows.forEach(row => {
this.batchFill.columns.forEach(col => {
row[col] = this.batchFill.value;
});
this.markChanged(row);
});
this.batchFillOpen = false;
this.$modal.msgSuccess(`已填充 ${this.selectedRows.length} 行数据`);
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加子件物料周需求";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getReq(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改子件物料周需求";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateReq(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addReq(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除子件物料周需求编号为"' + ids + '"的数据项?').then(function() {
return delReq(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 打开导出对话框 */
openExportDialog() {
this.exportParams.startDate = null;
this.exportParams.endDate = null;
this.exportOpen = true;
},
/** 导出按钮操作 */
handleExport() {
if (!this.exportParams.startDate || !this.exportParams.endDate) {
this.$modal.msgWarning("请选择导出的时间范围");
return;
}
if (this.exportParams.startDate > this.exportParams.endDate) {
this.$modal.msgWarning("开始日期不能大于结束日期");
return;
}
this.exportOpen = false;
this.download('production/req/export', {
...this.queryParams,
'params[beginWeekStartDate]': this.exportParams.startDate,
'params[endWeekStartDate]': this.exportParams.endDate
}, `子件物料周需求_${new Date().getTime()}.xlsx`)
},
/** 导入按钮操作 */
handleImport() {
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
this.download('production/req/importTemplate', {}, `子件物料周需求模板_${new Date().getTime()}.xlsx`)
},
/** 文件上传中处理 */
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
/** 文件上传成功处理 */
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
/** 提交上传文件 */
submitFileForm() {
this.$refs.upload.submit();
}
}
};
</script>
<style scoped>
.changed-cell ::v-deep .el-input__inner {
background-color: #fffbe6 !important;
border-color: #faad14 !important;
}
</style>
Loading…
Cancel
Save