✨ feat: 生产管理初步重构
This commit is contained in:
86
klp-ui/src/views/work/task/components/OrderSelect.vue
Normal file
86
klp-ui/src/views/work/task/components/OrderSelect.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<el-select
|
||||
v-model="selectedValue"
|
||||
placeholder="请选择或搜索订单"
|
||||
clearable
|
||||
filterable
|
||||
remote
|
||||
:remote-method="handleRemoteSearch"
|
||||
:loading="loading"
|
||||
@change="handleSelectChange"
|
||||
style="width: 100%"
|
||||
>
|
||||
<!-- 下拉选项 -->
|
||||
<el-option
|
||||
v-for="item in orderList"
|
||||
:key="item.orderId"
|
||||
:label="item.orderCode"
|
||||
:value="item.orderId"
|
||||
/>
|
||||
|
||||
<!-- 无数据提示 -->
|
||||
<el-option
|
||||
v-if="orderList.length === 0 && !loading"
|
||||
value=""
|
||||
disabled
|
||||
>
|
||||
暂无匹配订单
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listOrder } from '@/api/wms/order'
|
||||
import { debounce } from 'lodash' // 引入防抖函数
|
||||
|
||||
export default {
|
||||
name: 'OrderSelect',
|
||||
data() {
|
||||
return {
|
||||
orderList: [],
|
||||
loading: false,
|
||||
queryParams: {
|
||||
orderCode: undefined,
|
||||
pageNum: 1,
|
||||
pageSize: 20
|
||||
},
|
||||
selectedValue: undefined
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 初始化加载订单列表
|
||||
this.getList()
|
||||
|
||||
// 初始化防抖搜索方法(300ms延迟)
|
||||
this.debouncedSearch = debounce(this.getList, 300)
|
||||
},
|
||||
methods: {
|
||||
// 远程搜索方法
|
||||
handleRemoteSearch(query) {
|
||||
this.queryParams.orderCode = query
|
||||
this.queryParams.pageNum = 1 // 重置页码
|
||||
this.debouncedSearch() // 使用防抖搜索
|
||||
},
|
||||
|
||||
// 获取订单列表
|
||||
getList() {
|
||||
this.loading = true
|
||||
listOrder(this.queryParams).then(res => {
|
||||
this.orderList = res.rows || []
|
||||
this.loading = false
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
this.orderList = []
|
||||
})
|
||||
},
|
||||
|
||||
// 选择变化时触发
|
||||
handleSelectChange(orderId) {
|
||||
// 找到选中的完整订单项
|
||||
const selectedItem = this.orderList.find(item => item.orderId === orderId)
|
||||
// 通过onchange事件返回完整订单项
|
||||
this.$emit('change', selectedItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
371
klp-ui/src/views/work/task/index.vue
Normal file
371
klp-ui/src/views/work/task/index.vue
Normal file
@@ -0,0 +1,371 @@
|
||||
<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="productSpecGroupId">
|
||||
<el-input
|
||||
v-model="queryParams.productSpecGroupId"
|
||||
placeholder="请输入产品规范组ID"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="制造规范" prop="manufacturingSpecId">
|
||||
<el-input
|
||||
v-model="queryParams.manufacturingSpecId"
|
||||
placeholder="请输入制造规范ID"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单" prop="orderId">
|
||||
<el-input
|
||||
v-model="queryParams.orderId"
|
||||
placeholder="请输入订单ID"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划名称" prop="planName">
|
||||
<el-input
|
||||
v-model="queryParams.planName"
|
||||
placeholder="请输入计划名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划编号" prop="planCode">
|
||||
<el-input
|
||||
v-model="queryParams.planCode"
|
||||
placeholder="请输入计划编号"
|
||||
clearable
|
||||
@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="handleCreateFromOrder"
|
||||
>从订单创建</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="productionTaskList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="主键" align="center" prop="taskId" v-if="true"/>
|
||||
<el-table-column label="产品规范组ID" align="center" prop="productSpecGroupId" />
|
||||
<el-table-column label="制造规范ID" align="center" prop="manufacturingSpecId" />
|
||||
<el-table-column label="订单ID" align="center" prop="orderId" />
|
||||
<el-table-column label="订单明细ID" align="center" prop="orderItemId" />
|
||||
<el-table-column label="计划名称" align="center" prop="planName" />
|
||||
<el-table-column label="计划编号" align="center" prop="planCode" />
|
||||
<el-table-column label="状态" align="center" prop="status" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</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="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="产品规范组" prop="productSpecGroupId">
|
||||
<el-input v-model="form.productSpecGroupId" placeholder="请输入产品规范组" />
|
||||
</el-form-item>
|
||||
<el-form-item label="制造规范" prop="manufacturingSpecId">
|
||||
<el-input v-model="form.manufacturingSpecId" placeholder="请输入制造规范" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="订单" prop="orderId">
|
||||
<el-input v-model="form.orderId" placeholder="请输入订单" />
|
||||
</el-form-item>
|
||||
<el-form-item label="订单明细" prop="orderItemId">
|
||||
<OrderSelect v-model="form.orderId" @change="handleOrderChange" />
|
||||
</el-form-item> -->
|
||||
<el-form-item label="计划名称" prop="planName">
|
||||
<el-input v-model="form.planName" placeholder="请输入计划名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="计划编号" prop="planCode">
|
||||
<el-input v-model="form.planCode" placeholder="请输入计划编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog title="从订单创建生产任务" :visible.sync="detailDialogVisible" width="500px" append-to-body>
|
||||
<CreateByOrder @create="handleConfirmCreate" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProductionTask, getProductionTask, delProductionTask, addProductionTask, updateProductionTask } from "@/api/work/productionTask";
|
||||
import CreateByOrder from "./panels/createByOrder.vue";
|
||||
|
||||
export default {
|
||||
name: "ProductionTask",
|
||||
components: {
|
||||
CreateByOrder
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 按钮loading
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 生产任务表格数据
|
||||
productionTaskList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
productSpecGroupId: undefined,
|
||||
manufacturingSpecId: undefined,
|
||||
orderId: undefined,
|
||||
orderItemId: undefined,
|
||||
planName: undefined,
|
||||
planCode: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
productSpecGroupId: [
|
||||
{ required: true, message: "产品规范组ID不能为空", trigger: "blur" }
|
||||
],
|
||||
manufacturingSpecId: [
|
||||
{ required: true, message: "制造规范ID不能为空", trigger: "blur" }
|
||||
],
|
||||
},
|
||||
detailDialogVisible: false,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询生产任务列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProductionTask(this.queryParams).then(response => {
|
||||
this.productionTaskList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
taskId: undefined,
|
||||
productSpecGroupId: undefined,
|
||||
manufacturingSpecId: undefined,
|
||||
orderId: undefined,
|
||||
orderItemId: undefined,
|
||||
planName: undefined,
|
||||
planCode: undefined,
|
||||
status: undefined,
|
||||
remark: undefined,
|
||||
createBy: undefined,
|
||||
createTime: undefined,
|
||||
updateBy: undefined,
|
||||
updateTime: undefined,
|
||||
delFlag: undefined
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.taskId)
|
||||
this.single = selection.length!==1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加生产任务";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.loading = true;
|
||||
this.reset();
|
||||
const taskId = row.taskId || this.ids
|
||||
getProductionTask(taskId).then(response => {
|
||||
this.loading = false;
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改生产任务";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
if (this.form.taskId != null) {
|
||||
updateProductionTask(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
} else {
|
||||
addProductionTask(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const taskIds = row.taskId || this.ids;
|
||||
this.$modal.confirm('是否确认删除生产任务编号为"' + taskIds + '"的数据项?').then(() => {
|
||||
this.loading = true;
|
||||
return delProductionTask(taskIds);
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('klp/productionTask/export', {
|
||||
...this.queryParams
|
||||
}, `productionTask_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
handleCreateFromOrder() {
|
||||
this.reset();
|
||||
this.detailDialogVisible = true;
|
||||
},
|
||||
handleConfirmCreate(orderItems) {
|
||||
console.log(orderItems);
|
||||
Promise.all(orderItems.map(item => {
|
||||
return addProductionTask({
|
||||
productSpecGroupId: item.productSpecGroupId,
|
||||
manufacturingSpecIds: item.manufacturingSpecIds,
|
||||
orderId: item.orderId,
|
||||
orderItemId: item.orderItemId,
|
||||
});
|
||||
})).then(res => {
|
||||
this.$modal.msgSuccess("创建成功");
|
||||
this.detailDialogVisible = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
83
klp-ui/src/views/work/task/panels/createByOrder.vue
Normal file
83
klp-ui/src/views/work/task/panels/createByOrder.vue
Normal file
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row style="margin-bottom: 10px;">
|
||||
<el-col :span="12">
|
||||
<OrderSelect @change="handleOrderChange" />
|
||||
</el-col>
|
||||
<el-col :span="12" style="text-align: right;">
|
||||
<el-button type="primary" @click="handleCreate">确认创建</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table :data="orderItems" style="width: 100%;">
|
||||
<el-table-column label="产品">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo :productId="scope.row.productId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="handleSpec(scope.row)">查看规格</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="制造规格">
|
||||
<template slot-scope="scope">
|
||||
<MSpecSelect v-model="scope.row.manufacturingSpecIds" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-dialog title="产品规范" :visible.sync="specDialogVisible" width="600px" append-to-body>
|
||||
<ProductSpec v-if="form.groupId" :groupId="form.groupId" :readonly="false"/>
|
||||
<div v-else>
|
||||
暂无产品规格
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrderSelect from "../components/OrderSelect";
|
||||
import { listOrderDetail } from "@/api/wms/orderDetail";
|
||||
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
|
||||
import MSpecSelect from "@/views/work/components/MSpecSelect";
|
||||
import ProductSpec from "@/views/wms/order/panels/spec.vue";
|
||||
|
||||
export default {
|
||||
name: 'CreateByOrder',
|
||||
components: {
|
||||
OrderSelect,
|
||||
ProductInfo,
|
||||
MSpecSelect,
|
||||
ProductSpec
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
order: null,
|
||||
orderItems: [],
|
||||
specDialogVisible: false,
|
||||
form: {
|
||||
groupId: undefined
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleOrderChange(order) {
|
||||
this.order = order;
|
||||
listOrderDetail({
|
||||
orderId: order.orderId
|
||||
}).then(res => {
|
||||
this.orderItems = res.rows
|
||||
})
|
||||
},
|
||||
handleCreate() {
|
||||
console.log(this.orderItems);
|
||||
this.$emit('create', this.orderItems);
|
||||
},
|
||||
handleSpec(row) {
|
||||
this.specDialogVisible = true;
|
||||
this.form = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user