|
@@ -21,13 +21,18 @@
|
|
|
]"
|
|
|
@get-list="getList"
|
|
|
>
|
|
|
- <template #slotName="{ item }">
|
|
|
- {{ item.createTime }}
|
|
|
+ <template #versionSlot="{ item }">
|
|
|
+ <div
|
|
|
+ style="cursor: pointer; color: #409eff"
|
|
|
+ @click="hanldeOpenVer(item)"
|
|
|
+ >
|
|
|
+ v{{ item.versionNumber }}
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</byTable>
|
|
|
</div>
|
|
|
<el-dialog
|
|
|
- :title="modalType == 'add' ? '添加BOM' : '编辑BOM'"
|
|
|
+ :title="titleText"
|
|
|
v-model="dialogVisible"
|
|
|
width="800"
|
|
|
v-loading="loading"
|
|
@@ -41,7 +46,9 @@
|
|
|
>
|
|
|
<template #slot>
|
|
|
<div>
|
|
|
- <el-button type="primary" plain>添加物料/半成品</el-button>
|
|
|
+ <el-button type="primary" plain @click="openMaterial = true"
|
|
|
+ >添加物料/半成品</el-button
|
|
|
+ >
|
|
|
<el-button type="primary" plain> Excel导入</el-button>
|
|
|
<el-form
|
|
|
ref="tableForm"
|
|
@@ -50,19 +57,19 @@
|
|
|
label-width="0px"
|
|
|
style="margin-top: 15px"
|
|
|
>
|
|
|
- <el-table :data="formData.data.productList">
|
|
|
- <el-table-column prop="name" label="物料编码" />
|
|
|
- <el-table-column prop="state" label="物料名称" />
|
|
|
- <el-table-column prop="city" label="单位" />
|
|
|
- <el-table-column prop="num" label="数量" width="150">
|
|
|
+ <el-table :data="formData.data.bomDetailList">
|
|
|
+ <el-table-column prop="productCode" label="物料编码" />
|
|
|
+ <el-table-column prop="productName" label="物料名称" />
|
|
|
+ <el-table-column prop="productUnit" label="单位" />
|
|
|
+ <el-table-column prop="quantity" label="数量" width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'productList.' + $index + '.num'"
|
|
|
- :rules="rules.num"
|
|
|
+ :prop="'bomDetailList.' + $index + '.quantity'"
|
|
|
+ :rules="rules.quantity"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
<el-input-number
|
|
|
- v-model="row.num"
|
|
|
+ v-model="row.quantity"
|
|
|
:precision="2"
|
|
|
:controls="false"
|
|
|
:min="1"
|
|
@@ -73,12 +80,12 @@
|
|
|
<el-table-column prop="zip" label="成本" width="150">
|
|
|
<template #default="{ row, $index }">
|
|
|
<el-form-item
|
|
|
- :prop="'productList.' + $index + '.num'"
|
|
|
- :rules="rules.num"
|
|
|
+ :prop="'bomDetailList.' + $index + '.cost'"
|
|
|
+ :rules="rules.cost"
|
|
|
:inline-message="true"
|
|
|
>
|
|
|
<el-input-number
|
|
|
- v-model="row.aa"
|
|
|
+ v-model="row.cost"
|
|
|
:precision="2"
|
|
|
:controls="false"
|
|
|
:min="1"
|
|
@@ -87,8 +94,10 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="zip" label="操作" width="100">
|
|
|
- <template #default>
|
|
|
- <el-button type="primary" link>删除</el-button>
|
|
|
+ <template #default="{ $index }">
|
|
|
+ <el-button type="primary" link @click="handleRemove($index)"
|
|
|
+ >删除</el-button
|
|
|
+ >
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -97,12 +106,74 @@
|
|
|
</template>
|
|
|
</byForm>
|
|
|
<template #footer>
|
|
|
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
|
|
|
+ <div v-if="isShowBtns">
|
|
|
+ <el-button @click="dialogVisible = false" size="large"
|
|
|
+ >取 消</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm('byform')"
|
|
|
+ size="large"
|
|
|
+ :loading="submitLoading"
|
|
|
+ >
|
|
|
+ 确 定
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ v-model="openMaterial"
|
|
|
+ title="选择产品"
|
|
|
+ width="70%"
|
|
|
+ append-to-body
|
|
|
+ >
|
|
|
+ <SelectMaterial @handleSelect="handleSelect"></SelectMaterial>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="openMaterial = false">取消</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog v-model="openVersion" title="切换版本" width="30%">
|
|
|
+ <byForm
|
|
|
+ :formConfig="formConfig1"
|
|
|
+ :formOption="formOption"
|
|
|
+ v-model="formData.data1"
|
|
|
+ :rules="rules1"
|
|
|
+ ref="byform1"
|
|
|
+ >
|
|
|
+ <template #versionSlot>
|
|
|
+ <div>
|
|
|
+ <el-select
|
|
|
+ v-model="formData.data1.versionNumber"
|
|
|
+ placeholder="请选择版本号"
|
|
|
+ @change="changeRowData"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in versionData"
|
|
|
+ :label="'v' + item.versionNumber"
|
|
|
+ :value="item.versionNumber"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ link
|
|
|
+ style="margin-left: 10px"
|
|
|
+ @click="handleGetDetails"
|
|
|
+ v-if="formData.data1.versionNumber"
|
|
|
+ >查看</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </byForm>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="openVersion = false" size="large">取 消</el-button>
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
- @click="submitForm('byform')"
|
|
|
+ @click="handleChangeVer('byform1')"
|
|
|
size="large"
|
|
|
- :loading="submitLoading"
|
|
|
>
|
|
|
确 定
|
|
|
</el-button>
|
|
@@ -112,11 +183,13 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-/* eslint-disable vue/no-unused-components */
|
|
|
+/* eslint-disabled vue/no-unused-components */
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
import byTable from "@/components/byTable/index";
|
|
|
import byForm from "@/components/byForm/index";
|
|
|
-import { computed, defineComponent, ref } from "vue";
|
|
|
+import { computed, defineComponent, ref, watch, watchEffect } from "vue";
|
|
|
+import SelectMaterial from "@/components/product/SelectMaterial";
|
|
|
+
|
|
|
const loading = ref(false);
|
|
|
const submitLoading = ref(false);
|
|
|
const sourceList = ref({
|
|
@@ -128,15 +201,24 @@ const sourceList = ref({
|
|
|
},
|
|
|
});
|
|
|
let dialogVisible = ref(false);
|
|
|
+let openMaterial = ref(false);
|
|
|
+let openVersion = ref(false);
|
|
|
+let titleText = ref("");
|
|
|
let modalType = ref("add");
|
|
|
let rules = ref({
|
|
|
- type: [{ required: true, message: "请选择车间类型", trigger: "change" }],
|
|
|
- name: [{ required: true, message: "请输入车间名称", trigger: "blur" }],
|
|
|
- num: [{ required: true, message: "请输入数量", trigger: "blur" }],
|
|
|
+ productId: [{ required: true, message: "请选择产品", trigger: "change" }],
|
|
|
+ quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
|
|
|
+ cost: [{ required: true, message: "请输入成本", trigger: "blur" }],
|
|
|
personLiableId: [
|
|
|
{ required: true, message: "请选择负责人", trigger: "change" },
|
|
|
],
|
|
|
});
|
|
|
+let rules1 = ref({
|
|
|
+ versionNumber: [
|
|
|
+ { required: true, message: "请选择版本号", trigger: "change" },
|
|
|
+ ],
|
|
|
+});
|
|
|
+
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
const selectConfig = reactive([
|
|
|
// {
|
|
@@ -163,45 +245,52 @@ const config = computed(() => {
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "产品类型",
|
|
|
- prop: "name",
|
|
|
- width: 150,
|
|
|
+ prop: "productType",
|
|
|
+ width: 100,
|
|
|
+ },
|
|
|
+ render(productType) {
|
|
|
+ return productType ? "成品" : "半成品";
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "产品编码",
|
|
|
- prop: "name",
|
|
|
+ prop: "productCode",
|
|
|
width: 150,
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "产品名称",
|
|
|
- prop: "remarks",
|
|
|
+ prop: "productName",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "状态",
|
|
|
- prop: "remarks",
|
|
|
+ prop: "status",
|
|
|
+ },
|
|
|
+ render(status) {
|
|
|
+ return status === 1 ? "启用" : "禁用";
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "当前版本",
|
|
|
- prop: "remarks",
|
|
|
+ prop: "versionNumber",
|
|
|
+ slot: "versionSlot",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "最近维护人",
|
|
|
- prop: "remarks",
|
|
|
+ prop: "updateUserName",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
label: "最近维护时间",
|
|
|
- prop: "remarks",
|
|
|
+ prop: "updateTime",
|
|
|
},
|
|
|
},
|
|
|
// {
|
|
@@ -238,7 +327,7 @@ const config = computed(() => {
|
|
|
},
|
|
|
el: "button",
|
|
|
click() {
|
|
|
- getDtl(row);
|
|
|
+ getDtl(row, "add", true);
|
|
|
},
|
|
|
},
|
|
|
{
|
|
@@ -249,18 +338,39 @@ const config = computed(() => {
|
|
|
},
|
|
|
el: "button",
|
|
|
click() {
|
|
|
- getDtl(row);
|
|
|
+ getDtl(row, "edit");
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
attrs: {
|
|
|
- label: "禁用",
|
|
|
+ label: row.status === 1 ? "禁用" : "启用",
|
|
|
type: "primary",
|
|
|
text: true,
|
|
|
},
|
|
|
el: "button",
|
|
|
click() {
|
|
|
- getDtl(row);
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ `是否${row.status === 1 ? "禁用" : "启用"} ?`,
|
|
|
+ "提示",
|
|
|
+ {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ proxy.post("/bomInfo/detail", { id: row.id }).then((res) => {
|
|
|
+ res.bomDetailList = res.bomDetailVoList;
|
|
|
+ res.status = row.status ? 0 : 1;
|
|
|
+ formData.data = res;
|
|
|
+ proxy.post("/bomInfo/edit", formData.data).then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: "操作成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ getList();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
},
|
|
|
// {
|
|
@@ -304,7 +414,13 @@ const config = computed(() => {
|
|
|
|
|
|
let formData = reactive({
|
|
|
data: {
|
|
|
- type: "1",
|
|
|
+ productId: "",
|
|
|
+ addType: "1",
|
|
|
+ bomDetailList: [],
|
|
|
+ },
|
|
|
+ data1: {
|
|
|
+ productId: "",
|
|
|
+ versionNumber: "",
|
|
|
},
|
|
|
});
|
|
|
const formOption = reactive({
|
|
@@ -314,25 +430,64 @@ const formOption = reactive({
|
|
|
rules: [],
|
|
|
});
|
|
|
const byform = ref(null);
|
|
|
-const formConfig = computed(() => {
|
|
|
- return [
|
|
|
- {
|
|
|
- type: "select",
|
|
|
- prop: "name",
|
|
|
- label: "产品名称",
|
|
|
- required: true,
|
|
|
+const formConfig = reactive([
|
|
|
+ {
|
|
|
+ type: "select",
|
|
|
+ prop: "productId",
|
|
|
+ label: "产品名称",
|
|
|
+ required: true,
|
|
|
+ disabled: false,
|
|
|
+ isLoad: {
|
|
|
+ url: "/productInfo/page",
|
|
|
+ req: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ definition: "1",
|
|
|
+ },
|
|
|
+ labelKey: "name",
|
|
|
+ labelVal: "id",
|
|
|
+ method: "post",
|
|
|
+ resUrl: "rows",
|
|
|
},
|
|
|
- {
|
|
|
- type: "slot",
|
|
|
- slotName: "slot",
|
|
|
- label: "物料信息",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slot",
|
|
|
+ slotName: "slot",
|
|
|
+ label: "物料信息",
|
|
|
+ },
|
|
|
+]);
|
|
|
+
|
|
|
+const formConfig1 = reactive([
|
|
|
+ {
|
|
|
+ type: "select",
|
|
|
+ prop: "productId",
|
|
|
+ label: "产品名称",
|
|
|
+ required: true,
|
|
|
+ disabled: true,
|
|
|
+ isLoad: {
|
|
|
+ url: "/productInfo/page",
|
|
|
+ req: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ definition: "1",
|
|
|
+ },
|
|
|
+ labelKey: "name",
|
|
|
+ labelVal: "id",
|
|
|
+ method: "post",
|
|
|
+ resUrl: "rows",
|
|
|
},
|
|
|
- ];
|
|
|
-});
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "slot",
|
|
|
+ slotName: "versionSlot",
|
|
|
+ label: "切换版本",
|
|
|
+ required: true,
|
|
|
+ },
|
|
|
+]);
|
|
|
const getList = async (req) => {
|
|
|
sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
|
|
|
loading.value = true;
|
|
|
- proxy.post("/workshop/page", sourceList.value.pagination).then((message) => {
|
|
|
+ proxy.post("/bomInfo/page", sourceList.value.pagination).then((message) => {
|
|
|
console.log(message);
|
|
|
sourceList.value.data = message.rows;
|
|
|
sourceList.value.pagination.total = message.total;
|
|
@@ -343,20 +498,31 @@ const getList = async (req) => {
|
|
|
};
|
|
|
const openModal = () => {
|
|
|
dialogVisible.value = true;
|
|
|
+ titleText.value = "添加BOM";
|
|
|
modalType.value = "add";
|
|
|
- formData.data = {};
|
|
|
- formData.data.productList = [
|
|
|
- {
|
|
|
- num: "",
|
|
|
- },
|
|
|
- ];
|
|
|
+ formData.data = {
|
|
|
+ productId: "",
|
|
|
+ addType: "1",
|
|
|
+ bomDetailList: [],
|
|
|
+ };
|
|
|
+ formConfig[0].disabled = false;
|
|
|
};
|
|
|
const submitForm = () => {
|
|
|
- proxy.$refs.tableForm.validate((vaild) => {
|
|
|
- if (vaild) {
|
|
|
- byform.value.handleSubmit((valid) => {
|
|
|
+ byform.value.handleSubmit((valid) => {
|
|
|
+ if (!formData.data.bomDetailList.length > 0)
|
|
|
+ return ElMessage({
|
|
|
+ message: "请添加物料/半成品",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ proxy.$refs.tableForm.validate((vaild) => {
|
|
|
+ if (vaild) {
|
|
|
submitLoading.value = true;
|
|
|
- proxy.post("/workshop/" + modalType.value, formData.data).then(
|
|
|
+ formData.data.bomDetailList = formData.data.bomDetailList.map((x) => ({
|
|
|
+ productId: x.productId,
|
|
|
+ quantity: x.quantity,
|
|
|
+ cost: x.cost,
|
|
|
+ }));
|
|
|
+ proxy.post("/bomInfo/" + modalType.value, formData.data).then(
|
|
|
(res) => {
|
|
|
ElMessage({
|
|
|
message: modalType.value == "add" ? "添加成功" : "编辑成功",
|
|
@@ -371,22 +537,121 @@ const submitForm = () => {
|
|
|
submitLoading.value = false;
|
|
|
}
|
|
|
);
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+};
|
|
|
+const byform1 = ref(null);
|
|
|
+const handleChangeVer = () => {
|
|
|
+ if (formData.data1.versionNumber === "")
|
|
|
+ return ElMessage({
|
|
|
+ message: "请选择版本号",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ byform1.value.handleSubmit((valid) => {
|
|
|
+ submitLoading.value = true;
|
|
|
+ proxy.post("/bomInfo/editVersion", formData.data1).then(
|
|
|
+ (res) => {
|
|
|
+ ElMessage({
|
|
|
+ message: "切换成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ openVersion.value = false;
|
|
|
+ submitLoading.value = false;
|
|
|
+ getList();
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ submitLoading.value = false;
|
|
|
+ }
|
|
|
+ );
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const getDtl = (row) => {
|
|
|
- modalType.value = "edit";
|
|
|
- proxy.post("/workshop/detail", { id: row.id }).then((res) => {
|
|
|
- res.type = res.type + "";
|
|
|
- formData.data = res;
|
|
|
- console.log(formData);
|
|
|
+const getDtl = (row, type, isNew) => {
|
|
|
+ formConfig[0].disabled = true; //禁止修改产品信息
|
|
|
+ modalType.value = type;
|
|
|
+ proxy.post("/bomInfo/detail", { id: row.id }).then((res) => {
|
|
|
+ if (isNew) {
|
|
|
+ titleText.value = "新建版本";
|
|
|
+ formData.data = {
|
|
|
+ addType: "2", //2为新建版本
|
|
|
+ productId: res.productId,
|
|
|
+ bomDetailList: [],
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ titleText.value = openVersion.value ? "版本详情" : "编辑BOM";
|
|
|
+ res.bomDetailList = res.bomDetailVoList;
|
|
|
+ formData.data = res;
|
|
|
+ }
|
|
|
dialogVisible.value = true;
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-// getList();
|
|
|
+const handleSelect = (row) => {
|
|
|
+ const flag = formData.data.bomDetailList.some((x) => x.productId === row.id);
|
|
|
+ if (flag)
|
|
|
+ return ElMessage({
|
|
|
+ message: "该物料已选择",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ formData.data.bomDetailList.push({
|
|
|
+ productId: row.id,
|
|
|
+ productCode: row.code,
|
|
|
+ productName: row.name,
|
|
|
+ productUnit: row.unit,
|
|
|
+ quantity: null,
|
|
|
+ cost: null,
|
|
|
+ });
|
|
|
+ return ElMessage({
|
|
|
+ message: "选择成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleRemove = (index) => {
|
|
|
+ console.log(index, "as");
|
|
|
+ formData.data.bomDetailList.splice(index, 1);
|
|
|
+ return ElMessage({
|
|
|
+ message: "删除成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const versionData = ref([]);
|
|
|
+let isShowBtns = ref(true);
|
|
|
+let rowData = ref({});
|
|
|
+const hanldeOpenVer = (row) => {
|
|
|
+ formData.data1 = {
|
|
|
+ productId: "",
|
|
|
+ versionNumber: "",
|
|
|
+ };
|
|
|
+ rowData.value = row;
|
|
|
+ formData.data1.productId = row.productId;
|
|
|
+ proxy
|
|
|
+ .post("/bomInfo/getVersion", { productId: row.productId })
|
|
|
+ .then((res) => {
|
|
|
+ versionData.value = res;
|
|
|
+ formData.data1.versionNumber = res.filter(
|
|
|
+ (x) => x.currentVersion === 1
|
|
|
+ )[0].versionNumber;
|
|
|
+ openVersion.value = true;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleGetDetails = () => {
|
|
|
+ getDtl(rowData.value);
|
|
|
+};
|
|
|
+
|
|
|
+watchEffect(() => {
|
|
|
+ isShowBtns.value = openVersion.value ? false : true;
|
|
|
+ //监听是否是在切换版本中,如是隐藏提交添加弹窗的按钮模块
|
|
|
+});
|
|
|
+
|
|
|
+const changeRowData = (val) => {
|
|
|
+ const data = versionData.value.find((x) => x.versionNumber === val);
|
|
|
+ rowData.value = data ? data : {};
|
|
|
+};
|
|
|
+getList();
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|