|
@@ -1,41 +1,45 @@
|
|
|
<template>
|
|
|
<div class="mainContentBox">
|
|
|
+ <!--{{dataDetail}}-->
|
|
|
+ <!--{{dicts}}-->
|
|
|
+ <div class="detail">
|
|
|
+ <div class="title-detail">物料名称:{{dataDetail.materialCode}}</div>
|
|
|
+ <div class="title-detail">物料编码:{{dataDetail.materialName}}</div>
|
|
|
+ <div class="title-detail">物料属性:{{dataDetail.attributeDictLabel}}</div>
|
|
|
+ </div>
|
|
|
<avue-crud
|
|
|
ref="crudRef"
|
|
|
v-model:search="search"
|
|
|
v-model="form"
|
|
|
:data="data"
|
|
|
:option="option"
|
|
|
- v-model:page="page"
|
|
|
@row-update="updateRow"
|
|
|
@row-del="deleteRow"
|
|
|
@search-change="searchChange"
|
|
|
@search-reset="resetChange"
|
|
|
- @size-change="dataBomList"
|
|
|
- @current-change="dataBomList"
|
|
|
@selection-change="selectionChange"
|
|
|
>
|
|
|
<template #menu-left="{ size }">
|
|
|
<el-button
|
|
|
- type="danger"
|
|
|
+ type="primary"
|
|
|
icon="el-icon-plus"
|
|
|
@click="openMaterial"
|
|
|
>新增</el-button
|
|
|
></template>
|
|
|
- <template #menu="{row,index,type}">
|
|
|
- <el-button @click="binding(row)"
|
|
|
- icon="el-icon-link"
|
|
|
- text
|
|
|
- type="primary"
|
|
|
- >BOM</el-button>
|
|
|
- </template>
|
|
|
+
|
|
|
<CommonTable
|
|
|
ref="ctableRef"
|
|
|
- tableTitle="绑定子项"
|
|
|
+ tableTitle="物料选择"
|
|
|
tableType="BOM"
|
|
|
@selected-sure="onSelectedFinish"
|
|
|
/>
|
|
|
+ <template #footer>
|
|
|
+ <div class="detail-footer">
|
|
|
+ <el-button type="primary" @click="onSelected"> 保存 </el-button>
|
|
|
+ <el-button @click="routeBack">取消</el-button>
|
|
|
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
<template #menu-right="{}">
|
|
|
<el-dropdown split-button
|
|
|
>导入
|
|
@@ -52,17 +56,11 @@
|
|
|
</el-dropdown-menu>
|
|
|
</template>
|
|
|
</el-dropdown>
|
|
|
- <el-button
|
|
|
- class="ml-3"
|
|
|
- @click="exportData('/api/v1/plan/order/export')"
|
|
|
- >
|
|
|
- <template #icon> <i-ep-download /> </template>导出
|
|
|
- </el-button>
|
|
|
</template>
|
|
|
</avue-crud>
|
|
|
<CommonTable
|
|
|
ref="ctableRef"
|
|
|
- tableTitle="绑定子项"
|
|
|
+ tableTitle="BOM添加"
|
|
|
tableType="MARTERIAL"
|
|
|
@selected-sure="onSelectedFinish"
|
|
|
/>
|
|
@@ -78,30 +76,33 @@ import { useCommonStoreHook, useDictionaryStoreHook } from "../../../store/index
|
|
|
import {
|
|
|
getList,
|
|
|
} from "@/api/bom";
|
|
|
+import {
|
|
|
+ getMaterialDetails,
|
|
|
+} from "@/api/material";
|
|
|
+
|
|
|
+import {
|
|
|
+ batchAddBom,
|
|
|
+} from "@/api/bom";
|
|
|
const { isShowTable, tableType } = toRefs(useCommonStoreHook());
|
|
|
// 数据字典相关
|
|
|
const { dicts } = useDictionaryStoreHook();
|
|
|
const router = useRouter();
|
|
|
const route = useRoute();
|
|
|
+
|
|
|
+const dataDetail=ref({});
|
|
|
const test = () => {
|
|
|
isShowTable.value = true;
|
|
|
tableType.value = tableType.value == 1 ? 2 : 1;
|
|
|
};
|
|
|
-
|
|
|
const openMaterial=()=>{
|
|
|
if (ctableRef.value) {
|
|
|
ctableRef.value.startSelect();
|
|
|
}
|
|
|
}
|
|
|
const formData=ref({});
|
|
|
-const dataBomList=()=>{
|
|
|
- formData.materialCode=route.params.materialCode;
|
|
|
- getList(formData).then((data: any) => {
|
|
|
- ElMessage({
|
|
|
- message: data.msg,
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- });
|
|
|
+const dataBomLists=()=>{
|
|
|
+ search.value.materialCode=route.value.materialCode;
|
|
|
+ dataNoPageList();
|
|
|
}
|
|
|
|
|
|
const ctableRef = ref(null);
|
|
@@ -111,16 +112,47 @@ const binding = (row) => {
|
|
|
ctableRef.value.startSelect();
|
|
|
}
|
|
|
};
|
|
|
-const dialog = reactive({
|
|
|
- title: "绑定子项",
|
|
|
- visible: false,
|
|
|
-});
|
|
|
+const onSelected=()=>{
|
|
|
+ for(var i=0;i<data.value.length;i++){
|
|
|
+ if(data.value[i].bomMaterialNumber<=0){
|
|
|
+ ElMessage({
|
|
|
+ message: data.value[i].bomMaterialName+"数量不能为0",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(data.value.length===0){
|
|
|
+ ElMessage({
|
|
|
+ message: "物料记录不能为空!",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ batchAddBom(data.value).then(
|
|
|
+ (data: any)=>{
|
|
|
+ if(data.code==="200") {
|
|
|
+ ElMessage({
|
|
|
+ message: data.msg,
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ router.back();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ElMessage({
|
|
|
+ message: data.msg,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+}
|
|
|
// 传入一个url,后面不带/
|
|
|
const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
|
|
|
useCrud({
|
|
|
src: "/api/v1/base/materialBom",
|
|
|
});
|
|
|
-const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
|
|
|
+const { dataNoPageList,createRow, updateRow, deleteRow, searchChange, resetChange } =
|
|
|
Methords; //增删改查
|
|
|
const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
|
|
|
const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
|
|
@@ -136,16 +168,10 @@ const crudRef = ref(null); //crudRef.value 获取avue-crud对象
|
|
|
|
|
|
onMounted(() => {
|
|
|
// console.log("crudRef", crudRef)
|
|
|
- formData.materialCode=route.params.materialCode;
|
|
|
- getList(formData).then((data: any) => {
|
|
|
- ElMessage({
|
|
|
- message: data.msg,
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- // 上传完成后的刷新操作
|
|
|
- page.currentPage = 1;
|
|
|
- dataList();
|
|
|
- });
|
|
|
+ search.value.materialCode=route.params.materialCode;
|
|
|
+ queryMaterialDetail();
|
|
|
+ dataNoPageList();
|
|
|
+
|
|
|
});
|
|
|
|
|
|
/**
|
|
@@ -154,8 +180,7 @@ onMounted(() => {
|
|
|
const uploadRef = ref(null);
|
|
|
const uploadFinished = () => {
|
|
|
// 上传完成后的刷新操作
|
|
|
- page.currentPage = 1;
|
|
|
- dataList();
|
|
|
+ dataNoPageList();
|
|
|
};
|
|
|
const importExcelData = () => {
|
|
|
if (uploadRef.value) {
|
|
@@ -166,20 +191,70 @@ const importExcelData = () => {
|
|
|
// 设置表格列或者其他自定义的option
|
|
|
option.value = Object.assign(option.value, {
|
|
|
selection: true,
|
|
|
+ addBtn: false,
|
|
|
+ viewBtn: false,
|
|
|
+ editBtn:false,
|
|
|
+ saveBtn:false,
|
|
|
+ cellBtn: true,
|
|
|
column: columns,
|
|
|
});
|
|
|
-
|
|
|
+const routeBack =()=>{
|
|
|
+ router.back();
|
|
|
+}
|
|
|
const onSelectedFinish = (selectedValue) => {
|
|
|
- /* formData.id=selectedValue.id;
|
|
|
- formData.parentId=factory.value.id;
|
|
|
- updateWorkShop(formData).then((data: any) => {
|
|
|
- ElMessage({
|
|
|
- message: data.msg,
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- // 上传完成后的刷新操作
|
|
|
- page.currentPage = 1;
|
|
|
- dataList();
|
|
|
- });*/
|
|
|
+ for(var i=0;i<data.value.length;i++){
|
|
|
+ if(data.value[i].bomMaterialCode===selectedValue.materialCode){
|
|
|
+ ElMessage({
|
|
|
+ message: data.value[i].bomMaterialName+"已经添加过了",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const bom=ref({
|
|
|
+ materialCode:route.params.materialCode,
|
|
|
+ bomMaterialCode:selectedValue.materialCode,
|
|
|
+ bomMaterialName:selectedValue.materialName,
|
|
|
+ bomMaterialAttribute:selectedValue.attributeDictValue,
|
|
|
+ bomMaterialNumber:0,
|
|
|
+ $cellEdit:true,
|
|
|
+ });
|
|
|
+ data.value.push(bom.value);
|
|
|
+};
|
|
|
+const queryMaterialDetail = () => {
|
|
|
+ getMaterialDetails(route.params.materialCode).then(
|
|
|
+
|
|
|
+ ({ data }) => {
|
|
|
+ dataDetail.value=data;
|
|
|
+ dicts.material_properties;
|
|
|
+ for(var i=0;i<dicts.material_properties.length;i++){
|
|
|
+ if(data.attributeDictValue===dicts.material_properties[i].dictValue){
|
|
|
+ dataDetail.value.attributeDictLabel=dicts.material_properties[i].dictLabel;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ );
|
|
|
};
|
|
|
</script>
|
|
|
+<style type="text/css">
|
|
|
+ .title-detail{
|
|
|
+ width: 30%;
|
|
|
+ height: 50px;
|
|
|
+ line-height: 50px;
|
|
|
+ margin: 25px 20px 25px 0;
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ .detail{
|
|
|
+ margin: 0 auto;
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ .avue-crud{
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ .detail-footer{
|
|
|
+ float: right;
|
|
|
+ margin-top:15px;
|
|
|
+ }
|
|
|
+
|
|
|
+</style>
|