You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
750 lines
27 KiB
Vue
750 lines
27 KiB
Vue
<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>仅允许导入xls、xlsx格式文件。</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>
|