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.

1199 lines
39 KiB
Vue

2 years ago
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="计划工厂编码" prop="planFactoryCode" label-width="100px">
<el-input
v-model="queryParams.planFactoryCode"
placeholder="请输入计划工厂编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="订单号" prop="orderCode">
<el-input
v-model="queryParams.orderCode"
placeholder="请输入订单号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物料号" prop="prodCode">
<el-input
v-model="queryParams.prodCode"
placeholder="请输入物料号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物料名称" prop="prodDesc">
<el-input
v-model="queryParams.prodDesc"
placeholder="请输入物料名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="拆分状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择拆分状态" clearable>
<el-option
v-for="dict in dict.type.order_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<!-- <el-form-item label-width="100px" label="计划生产日期" prop="planProDate">-->
<!-- <el-date-picker clearable-->
<!-- v-model="queryParams.planProDate"-->
<!-- type="date"-->
<!-- value-format="yyyy-MM-dd"-->
<!-- placeholder="选择计划生产日期"-->
<!-- >-->
<!-- </el-date-picker>-->
<!-- </el-form-item>-->
<el-form-item label-width="100px" label="计划生产日期" prop="productDateArray">
<el-date-picker
v-model="queryParams.planDateArray"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
</el-form-item>
<el-form-item label="订单类型" prop="status">
<el-select v-model="queryParams.orderType" placeholder="请选择订单类型" clearable>
<el-option
v-for="dict in dict.type.product_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
2 years ago
<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>
2 years ago
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="dialogVisible = true"
v-hasPermi="['mes:pro:order:add']"
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
2 years ago
@click="handleSyncSAP"
v-hasPermi="['mes:pro:order:add']"
>SAP同步
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['mes:pro:order:import']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['mes:pro:order:export']"
>导出
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
2 years ago
<el-table
v-if="refreshTable"
v-loading="loading"
:data="orderList"
row-key="orderCode"
2 years ago
style="width: 100%"
max-height="480"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
2 years ago
<el-table-column width="150" label="订单号" align="center" prop="orderCode"/>
<el-table-column width="180" label="物料号" align="center" prop="prodCode"/>
<el-table-column width="200" label="物料名称" align="center" prop="prodDesc"/>
<el-table-column width="90" label="订单数量" align="center" prop="quantity"/>
<el-table-column width="70" label="单位" align="center" prop="unit"/>
<el-table-column label="任务清单" align="center" prop="workerOrder"/>
<el-table-column width="120" label="计划生产日期" align="center" prop="planProDate">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.planProDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column width="120" label="计划完成日期" align="center" prop="planComplete">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.planComplete, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="订单状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.order_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column width="100" align="center" label="计划工厂编码" prop="planFactoryCode"/>
<el-table-column label="订单类型" align="center" prop="orderType"/>
<el-table-column label="产品类型" align="center" prop="prodType">
<template slot-scope="scope">
<dict-tag :options="dict.type.product_type" :value="scope.row.prodType"/>
</template>
</el-table-column>
<el-table-column width="120" label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.planComplete, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column width="120" label="更新时间" align="center" prop="updateTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.planComplete, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width " fixed="right">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-plus"
@click="splitBtn(scope.row)"
v-hasPermi="['mes:pro:order:edit']"
v-if="scope.row.parentOrder == 0"
>拆分
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 用户导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
: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
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<!-- <div class="el-upload__tip" slot="tip">-->
<!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的订单数据-->
<!-- </div>-->
<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="dialogVisible" width="900px" append-to-body :before-close="handleClose">
<el-form ref="form" :model="form" :rules="addrules" label-width="80px">
<!-- 第一行 -->
<el-row>
<!-- 第一列 -->
<el-col :offset="1" :span="8">
<el-form-item label-width="100px" label="物料号" prop="prodCode">
<el-input v-model="form.prodCode" placeholder="请输入物料号"/>
</el-form-item>
</el-col>
<!-- 第二列 -->
<el-col :offset="2" :span="8">
<el-form-item label-width="100px" label="计划生产日期" prop="planProDate">
<el-date-picker clearable
v-model="form.planProDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择计划生产日期"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<!-- 第二行 -->
<el-row>
<!-- 第一列 -->
<el-col :offset="1" :span="8">
<el-form-item label-width="100px" label="物料名称" prop="prodDesc">
<el-input v-model="form.prodDesc" placeholder="请输入物料名称"/>
</el-form-item>
</el-col>
<!-- 第二列 -->
<el-col :offset="2" :span="8">
<el-form-item label-width="100px" label="计划完成日期" prop="planComplete">
<el-date-picker clearable
v-model="form.planComplete"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择计划完成日期"
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<!-- 第三行 -->
<el-row>
<!-- 第一列 -->
<el-col :offset="1" :span="8">
<el-form-item label-width="100px" label="订单数量" prop="quantity">
<el-input @change="addQuantity" type="number" v-model="form.quantity" placeholder="请输入订单数量"/>
</el-form-item>
</el-col>
<!-- 第二列 -->
<el-col :offset="2" :span="9">
<el-form-item label-width="100px" label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="请输入单位"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :offset="1" :span="8">
<el-form-item label-width="100px" label="产品类型" prop="prodType">
<el-select v-model="form.prodType" placeholder="请选择产品类型">
<el-option
v-for="dict in dict.type.product_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</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="title" :visible.sync="splitOpen" width="1000px" append-to-body>
<!-- 拆分头pro -->
<el-table
border
v-if="refreshProTable"
v-loading="proLoading"
:data="productData"
row-key="orderCode"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column width="60" align="center" label="序号" type="index"></el-table-column>
<el-table-column width="150" label="订单编号" prop="orderCode"/>
<el-table-column width="380" label="产品名称" align="center" prop="prodDesc"/>
<el-table-column width="60" label="单位" align="center" prop="unit"/>
<el-table-column width="130" label="产品数量" align="center" prop="quantity"/>
<el-table-column label="已拆分数量" align="center" prop="quantitySplit"/>
<el-table-column label="拆分数量" align="center" prop="atrr1"/>
</el-table>
<el-form class="my-margin" :model="splitForm" ref="dynamicForm" label-width="80px">
<!-- 编辑框 -->
<!-- 第一行 -->
<el-row>
<!-- 选择产线 -->
<el-col :span="6">
<el-form-item label="选择机型:">
<el-select size="small" v-model="splitForm.prodLineCode" placeholder="请选择成型机">
<el-option v-for="item in proline" :key="item.key" :label="item.label" :value="item.key"></el-option>
</el-select>
</el-form-item>
</el-col>
<!-- 拆分数量 -->
<el-col :offset="2" :span="7">
<el-form-item size="small" label="拆分数量:">
<el-input required type="number" @input="splitNumChange" v-model="splitForm.splitNum"></el-input>
</el-form-item>
</el-col>
<!-- 工单日期 -->
<el-col :offset="1" :span="5">
<el-form-item size="small" label="工单日期: ">
<el-date-picker @change="checkDate" v-model="splitForm.productDate" type="date" placeholder="选择日期"
></el-date-picker>
</el-form-item>
</el-col>
</el-row>
<!-- 第二行 -->
<el-row>
<el-col :span="6">
<!-- 选择班次 -->
<el-form-item size="small" label="选择班次:" class="my-select my-first">
<el-select v-model="splitForm.shiftId" placeholder="请选择班次">
<el-option v-for="item in workShift" :key="item.shiftId" :label="item.shiftDesc"
:value="item.shiftId"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :offset="2" :span="6">
<!-- 选择工艺 -->
<el-form-item size="small" label="选择工艺:" class="my-select my-first">
<el-select v-model="splitForm.routeCode" placeholder="请选择工艺">
<el-option v-for="item in routes" :key="item.routeCode" :label="item.routeName"
:value="item.routeCode"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<!-- 第三行 -->
<el-row v-for="(item, index) in formFields" :key="index">
<!-- 批次编号 -->
<el-col :span="7">
<el-form-item size="small" label="批次编号">
<el-input @blur="batchCodeChange" v-model="item.batchCode"></el-input>
</el-form-item>
</el-col>
<!-- 批次数量 -->
<el-col :offset="1" :span="4">
<el-form-item size="small" label="批次数量">
<el-input required @input="inBatch" type="number" v-model="item.batchQuantity"></el-input>
</el-form-item>
</el-col>
<!-- 操作 -->
<el-col :offset="1" :span="4">
<el-button size="small" v-if="formFields.length > 1" @click="removeField(index)" type="danger">
</el-button>
<el-button size="small" v-if="index === formFields.length - 1" @click="addField" type="primary">
</el-button>
</el-col>
</el-row>
</el-form>
<!-- 拆分尾 -->
<el-table
border
:data="splitData"
v-if="refreshWorkerTable"
v-loading="workerLoading"
row-key="workorderCode"
style="width: 100%"
max-height="240"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column width="60" align="center" label="序号" type="index"></el-table-column>
<el-table-column width="200" align="center" prop="workorderCode" label="工单号"></el-table-column>
<el-table-column width="100" align="center" prop="productDate" label="工单日期"></el-table-column>
<el-table-column width="100" align="center" prop="prodLineCode" label="成型机"></el-table-column>
<el-table-column width="80" align="center" prop="quantitySplit" label="数量"></el-table-column>
<el-table-column width="60" label="单位" align="center" prop="unit"/>
<el-table-column width="90" label="工艺编码" align="center" prop="routeCode"/>
<el-table-column width="90" label="班次" align="center" prop="shiftDesc"/>
<el-table-column align="center" prop="batchCodeList" label="批次号"></el-table-column>
</el-table>
<!-- 测试 -->
<!-- 操作按钮 -->
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="batchBtn"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
2 years ago
</template>
<script>
import {
getWorkOrderList,
getOrderList,
subSplitOrder,
getprodLineShift,
listOrder,
getOrder,
delOrder,
addOrder,
updateOrder,
syncSAP
} from '@/api/plan/order'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import moment from 'moment'
import { getToken } from "@/utils/auth"
export default {
name: 'Order',
dicts: ['product_type', 'order_status'],
components: {
Treeselect
},
data() {
return {
// 导入数据
upload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: {poolName: localStorage.getItem("USER_POOL_NAME_CURRENT"), Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/plan/order/importData"
},
// 工艺list
routes: [],
// 表单参数
form: {},
// 新增模块
dialogVisible: false,
//以下为新内容
productList: [],
//工单遮罩层
workerLoading: false,
//工单重新渲染表格
refreshWorkerTable: true,
//订单遮罩层
proLoading: true,
//订单重新渲染表格
refreshProTable: true,
//拆分头pro
productData: [],
//拆分下部分
splitData: [],
//选择产线list表
proline: [],
//
splitnum: null,
// 班次
workShift: [],
// 批次
formFields: [{
batchCode: '',
batchQuantity: ''
}],
// 遮罩层
loading: true,
// 显示搜索条件
showSearch: true,
// 订单表格数据
orderList: [],
// 订单树选项
orderOptions: [],
// 弹出层标题
title: '',
// 是否显示弹出层
splitOpen: false,
// 是否展开,默认全部展开
isExpandAll: true,
// 重新渲染表格状态
refreshTable: true,
// 查询参数
queryParams: {
planDateArray: [],
planFactoryCode: null,
orderType: null,
orderCode: null,
prodCode: null,
prodDesc: null,
quantity: null,
unit: null,
workerOrder: null,
planProDate: null,
planComplete: null,
atrr1: null,
atrr2: null,
atrr3: null,
status: null,
parentOrder: null,
prodType: null
},
// 拆分表单参数
splitForm: {
id: null,
prodLineCode: null,
splitNum: null,
productDate: null,
shiftId: null,
routeCode: null,
formFields: []
},
// 表单校验
rules: {},
addrules: {}
}
},
created() {
// 初始化
this.loading = true
this.queryParams.status = 'o0'
this.queryParams.planDateArray = [new Date(), new Date()]
this.queryParams.planDateStart = moment(this.queryParams.planDateArray[0]).format('YYYY-MM-DD')
this.queryParams.planDateEnd = moment(this.queryParams.planDateArray[1]).format('YYYY-MM-DD')
listOrder(this.queryParams).then(response => {
this.orderList = this.handleTree(response.data, 'orderCode', 'parentOrder')
this.loading = false
})
},
methods: {
// 新增-订单数量改变
addQuantity(num){
if (num<=0){
this.form.quantity = 1;
this.$message({
message:"数量不能小于1",
type:"warning"
})
}
},
/** 导入按钮操作 */
handleImport() {
this.upload.title = "订单信息导入";
this.upload.open = true;
},
// 文件上传中处理
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();
},
/** 下载模板操作 */
importTemplate() {
this.download('/plan/order/importTemplate', {
}, `order_example_template_${new Date().getTime()}.xlsx`)
},
/** 导出按钮操作 */
handleExport() {
this.download('/plan/order/export', {
...this.queryParams
}, `order_${new Date().getTime()}.xlsx`)
},
/** 拆分按钮操作 */
splitBtn(row) {
//数据初始化
function setAtrr1(row) {
row.atrr1 = 0
if (row.children !== undefined) {
for (let i = 0; i < row.children.length; i++) {
setAtrr1(row.children[i])
}
}
}
setAtrr1(row)
// 在获取到新的数据后执行以下代码
this.proLoading = true // 设置加载状态为true表示正在加载
// 发送请求或执行异步操作获取最新的数据
//重置表单
this.resetBatch()
//将数据放入到productData中
this.productData.push(row)
//存放id
this.splitForm.id = row.id
this.refreshProTable = false // 先将refreshProTable设置为false隐藏表格
this.$nextTick(() => {
// 使用$nextTick来等待DOM更新完成
this.refreshProTable = true // 立即将refreshProTable设置为true显示表格
this.proLoading = false // 设置加载状态为false表示加载完成
})
//初始化日期为默认今天
this.splitForm.productDate = new Date()
//获取成型机和班次
getprodLineShift(row.orderType).then(response => {
this.proline = response.data.lines
this.workShift = response.data.shifts
this.routes = response.data.routes
})
this.workerLoading = true // 设置加载状态为true表示正在加载
// 获取工单
getWorkOrderList(row.id).then(response => {
var data = response.data
this.splitData = data
this.refreshWorkerTable = false // 先将refreshProTable设置为false隐藏表格
this.$nextTick(() => {
// 使用$nextTick来等待DOM更新完成
this.refreshWorkerTable = true // 立即将refreshProTable设置为true显示表格
this.workerLoading = false // 设置加载状态为false表示加载完成
})
})
this.splitOpen = true
this.title = '拆分'
},
/** 拆分数量方法 */
splitNumChange(e) {
//不能为负数
if (e <= 0) {
e = 1
this.splitForm.splitNum = 1
} else {
// 获取最大值,拆分数量不得超过最大值
let max = Number(this.productData[0].quantity) - Number(this.productData[0].quantitySplit)
// 超过最大值,给用户提醒
if (e > max) {
this.$message({
message: '最大值不能超过' + max + '!',
type: 'warning'
})
this.splitForm.splitNum = max
}
//前端数据同步
// 在获取到新的数据后执行以下代码
this.proLoading = true // 设置加载状态为true表示正在加载
var num = this.productData[0].quantity;
// 递归操作动态显示拆分数量
function setAtrr1(data, splitNum) {
if (data.children !== undefined) {
for (let i = 0; i < data.children.length; i++) {
data.children[i].atrr1 = splitNum * (data.children[i].quantity / num)
setAtrr1(data.children[i], splitNum)
}
}
}
this.productData[0].atrr1 = this.splitForm.splitNum
setAtrr1(this.productData[0], this.splitForm.splitNum)
this.refreshProTable = false // 先将refreshProTable设置为false隐藏表格
this.$nextTick(() => {
// 使用$nextTick来等待DOM更新完成
this.refreshProTable = true // 立即将refreshProTable设置为true显示表格
this.proLoading = false // 设置加载状态为false表示加载完成
})
}
this.product = this.productData[0]
},
// 判空、空串
checkNull(entity) {
if (entity !== undefined && entity !== '' && entity !== null) {
return 1
}
return 0
},
/** 确认关闭 */
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
this.reset()
done()
})
.catch(_ => {
})
},
/** 新增-提交按钮 */
submitForm() {
// 表单校验
if (this.checkNull(this.form.prodCode) == 0) {
this.$message({
message: '物料号不能为空!',
type: 'warning'
})
return
}
if (this.checkNull(this.form.planProDate) == 0) {
this.$message({
message: '请选择计划生产日期!',
type: 'warning'
})
return
}
if (this.checkNull(this.form.planComplete) == 0) {
this.$message({
message: '请选择计划完成日期!',
type: 'warning'
})
return
}
if (this.checkNull(this.form.prodDesc) == 0) {
this.$message({
message: '物料名称不能为空!',
type: 'warning'
})
return
}
if (this.checkNull(this.form.quantity) == 0) {
this.$message({
message: '请填写订单数量!',
type: 'warning'
})
return
}
if (this.checkNull(this.form.unit) == 0) {
this.$message({
message: '请填写单位!',
type: 'warning'
})
return
}
if (this.checkNull(this.form.prodType) == 0) {
this.$message({
message: '请选择产品类型!',
type: 'warning'
})
return
}
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateOrder(this.form).then(response => {
this.$modal.msgSuccess('修改成功')
this.dialogVisible = false
this.reset()
this.getList()
})
} else {
addOrder(this.form).then(response => {
this.$modal.msgSuccess('新增成功')
this.dialogVisible = false
this.reset()
this.getList()
})
}
}
})
},
/** 检验批次编码是否重复 */
batchCodeChange(e) {
if (this.formFields.length > 1) {
for (let i = 0; i < this.formFields.length - 1; i++) {
if (this.formFields[this.formFields.length - 1].batchCode == this.formFields[i].batchCode) {
this.$message({
message: '批次号不能重复!',
type: 'warning'
})
this.formFields = [{
batchCode: '',
batchQuantity: ''
}]
return
}
}
}
},
/** 校验日期 */
checkDate(e) {
var now = new Date()
if (e < now) {
e = now
this.splitForm.productDate = now
this.$message({
message:"工单日期不能早于今天",
type:"warning"
})
}
},
/** 拆分提交按钮 */
batchBtn() {
// 判断数据不能为空
if (this.splitForm.splitNum == null) {
this.$message({
message: '拆分数量不能为空!',
type: 'warning'
})
return
}
if (this.splitForm.shiftId == null) {
this.$message({
message: '班次信息不能为空!',
type: 'warning'
})
return
}
if (this.splitForm.prodLineCode == null) {
this.$message({
message: '请选择机型!',
type: 'warning'
})
return
}
if (this.splitForm.routeCode == null) {
this.$message({
message: '请选择工艺信息!',
type: 'warning'
})
return
}
if (this.splitForm.productDate == null) {
this.$message({
message: '请选择工单日期!!',
type: 'warning'
})
return
}
// 判断如果拆分数量不等于拆分批次数量之和
let sum = 0
for (let i = 0; i < this.formFields.length; i++) {
sum = Number(sum) + Number(this.formFields[i].batchQuantity)
if (this.formFields[i].batchQuantity == '' || this.formFields[i].batchQuantity == null || this.formFields[i].batchCode == null || this.formFields[i].batchCode == '') {
this.$message({
message: '批次数据不能为空',
type: 'warning'
})
return
}
}
if (sum != this.productData[0].atrr1) {
this.$message({
message: '批次数量之和不等于拆分数量',
type: 'warning'
})
return
}
//整理订单传入到后端
this.splitForm.formFields = this.formFields
//整理数据往后端发送
//下面是请求处理
const data = {
formFields: this.formFields,
prodLineCode: this.splitForm.prodLineCode,
productDate: this.splitForm.productDate,
shiftId: this.splitForm.shiftId,
splitNum: this.splitForm.splitNum,
product: this.productData[0],
routeCode: this.splitForm.routeCode
}
let check = 1
subSplitOrder(data).then(response => {
if (response.code == 500) {
check = 0
this.$modal.msgError(response.msg)
return
}
this.$modal.msgSuccess('提交成功')
})
let id = this.productData[0].id
// 清除缓存
this.splitForm = {
id: null,
prodLineCode: null,
splitNum: null,
productDate: null,
shiftId: null,
formFields: []
}
this.formFields = [{
batchCode: '',
batchQuantity: ''
}]
// 获取该订单下的最新工单列表
getWorkOrderList(id).then(response => {
if (response.code == 500) {
this.$modal.msgError(response.msg)
}
// 设置最新数据
this.splitData = response.data
// 在获取到新的数据后执行以下代码
this.workerLoading = true // 设置加载状态为true表示正在加载
this.refreshWorkerTable = false // 先将refreshProTable设置为false隐藏表格
this.$nextTick(() => {
// 使用$nextTick来等待DOM更新完成
this.refreshWorkerTable = true // 立即将refreshProTable设置为true显示表格
this.workerLoading = false // 设置加载状态为false表示加载完成
})
})
if (check) {
setTimeout(() => {
this.getList()
// 等待1秒后执行的代码
this.splitOpen = false
}, 500)
}
},
/** 动态添加表单 */
addField() {
//如果批次数量大于等于拆分数量则不允许拆分
let sum = 0
for (let i = 0; i < this.formFields.length; i++) {
sum += Number(this.formFields[i].batchQuantity)
}
if (sum >= this.productData[0].atrr1) {
this.$message({
message: '无法添加!您的批次数量已满!',
type: 'warning'
})
return
}
this.formFields.push({ batchCode: '', batchQuantity: '' })
//自动填充
this.formFields[this.formFields.length - 1].batchQuantity = Number(this.productData[0].atrr1) - Number(sum)
},
/** 动态删除表单 */
removeField(index) {
this.formFields.splice(index, 1)
},
/** 查询订单列表 */
getList() {
this.loading = true
if (this.queryParams.planDateArray != null) {
this.queryParams.planDateStart = moment(this.queryParams.planDateArray[0]).format('YYYY-MM-DD')
this.queryParams.planDateEnd = moment(this.queryParams.planDateArray[1]).format('YYYY-MM-DD')
}
listOrder(this.queryParams).then(response => {
this.orderList = this.handleTree(response.data, 'orderCode', 'parentOrder')
this.loading = false
})
},
/** 转换订单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children
}
return {
id: node.orderCode,
label: node.orderCode,
children: node.children
}
},
// 取消按钮
cancel() {
this.dialogVisible = false;
this.splitOpen = false;
this.reset();
},
/** 查询订单下拉树结构 */
getTreeselect() {
listOrder().then(response => {
this.orderOptions = []
const data = { orderCode: 0, orderCode: '顶级节点', children: [] }
data.children = this.handleTree(response.data, 'orderCode', 'parentOrder')
this.orderOptions.push(data)
})
},
// 表单重置
reset() {
this.form = {
id: null,
planFactoryCode: null,
orderType: null,
orderCode: null,
prodCode: null,
prodDesc: null,
quantity: null,
unit: null,
workerOrder: null,
planProDate: null,
planComplete: null,
atrr1: null,
atrr2: null,
atrr3: null,
status: null,
parentOrder: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
prodType: null
}
this.resetForm('form')
},
/** 拆分表单重置 */
resetBatch() {
this.splitForm = {
id: null,
prodLineCode: null,
splitNum: null,
productDate: null,
shiftId: null,
formFields: []
}
this.splitData = []
this.productData = []
this.proline = []
this.splitnum = null
this.workShift = []
this.formFields = [{
batchCode: '',
batchQuantity: ''
}]
},
/** 搜索按钮操作 */
handleQuery() {
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
planDateArray: [],
planFactoryCode: null,
orderType: null,
orderCode: null,
prodCode: null,
prodDesc: null,
quantity: null,
unit: null,
workerOrder: null,
planProDate: null,
planComplete: null,
atrr1: null,
atrr2: null,
atrr3: null,
status: null,
parentOrder: null,
prodType: null
}
this.handleQuery()
},
/** 拆分按钮操作 */
handleAdd(row) {
this.reset()
this.getTreeselect()
if (row != null && row.orderCode) {
this.splitForm.parentOrder = row.orderCode
} else {
this.splitForm.parentOrder = 0
}
this.splitOpen = true
this.title = '拆分'
},
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false
this.isExpandAll = !this.isExpandAll
this.$nextTick(() => {
this.refreshTable = true
})
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
this.getTreeselect()
if (row != null) {
this.splitForm.parentOrder = row.orderCode
}
getOrder(row.id).then(response => {
this.splitForm = response.data
this.splitOpen = true
this.title = '修改订单'
})
},
/** 填写批次数量 */
inBatch(e) {
//不能为负数
if (e <= 0) {
this.formFields[this.formFields.length - 1].batchQuantity = 1
}
//逻辑判断
let sum = 0
for (let i = 0; i < this.formFields.length; i++) {
sum += Number(this.formFields[i].batchQuantity)
}
//如果超过拆分数量,提示并清空当前输入
if (sum > this.productData[0].atrr1) {
this.$message({
message: '你的批次数量总和不能超过拆分数量!',
type: 'warning'
})
this.formFields[this.formFields.length - 1].batchQuantity = Number(this.productData[0].atrr1) - Number(Number(sum) - Number(e))
}
//如果拆分数量为空
if (this.productData[0].atrr1 == '' || this.productData[0].atrr1 == null) {
this.formFields[this.formFields.length - 1].batchQuantity = ''
}
},
/** SAP同步按钮操作 */
handleSyncSAP() {
this.$modal.confirm('是否确认SAP同步操作步骤').then(function() {
return syncSAP()
}).then(() => {
this.getList()
this.$modal.msgSuccess('同步成功')
}).catch(() => {
})
}
}
2 years ago
}
2 years ago
</script>
<style>
.el-row {
margin: 0;
padding: 0;
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf;
}
.bg-purple {
background: #d3dce6;
}
.bg-purple-light {
background: #e5e9f2;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
.my-margin {
margin-top: 40px;
margin-bottom: 10px;
}
</style>