فهرست منبع

修改BPOM逻辑

huang_an 1 سال پیش
والد
کامیت
93e92032a6

+ 3 - 3
src/views/material/BOMmanage/components/attribute.vue

@@ -205,18 +205,18 @@
         bomTypeOptions: [
           {
             label: 'PBOM',
-            value: '1'
+            value: 1
           },
           {
             label: 'MBOM',
-            value: '2'
+            value: 2
           }
         ]
       };
     },
     props: {
       attributeData: {
-        type: String,
+        type: Object,
         default: {}
       }
     }

+ 1 - 1
src/views/material/BOMmanage/components/baseInfo.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="baseInfo">
-    <el-form label-width="100px" ref="form" :model="form">
+    <el-form label-width="100px" ref="form" :model="dataInfo">
       <el-row>
         <el-col :span="6" label-width="100px">
           <el-form-item label="BOM编码" prop="type">

+ 23 - 14
src/views/material/BOMmanage/components/bomTreeDialog.vue

@@ -8,12 +8,7 @@
     append-to-body
     width="70%"
   >
-    <el-form
-      label-width="100px"
-      ref="form"
-      :model="attributeData"
-      :rules="rules"
-    >
+    <el-form label-width="100px" ref="form" :model="attributeData">
       <el-row>
         <el-col :span="12" label-width="100px">
           <el-form-item label="父级节点" prop="type">
@@ -151,7 +146,7 @@
         </el-col>
 
         <el-col :span="12" label-width="100px">
-          <el-form-item label="物料库路径" prop="name">
+          <el-form-item label="物料库路径" prop="materielPath">
             <el-input
               placeholder=""
               v-model="attributeData.materielPath"
@@ -160,17 +155,18 @@
         </el-col>
 
         <el-col :span="12" label-width="100px">
-          <el-form-item label="版本" prop="name">
+          <el-form-item label="版本" prop="versions">
             <el-input
-              disabled="true"
+              :disabled="versions"
               placeholder=""
+              @input="versionsChange"
               v-model="attributeData.versions"
             ></el-input>
           </el-form-item>
         </el-col>
 
         <el-col :span="24" label-width="100px">
-          <el-form-item label="备注" prop="name">
+          <el-form-item label="备注" prop="remake">
             <el-input
               placeholder=""
               v-model="attributeData.remake"
@@ -202,7 +198,10 @@
       return {
         visible: false,
         title: '添加节点',
-        attributeData: {},
+        versions: '',
+        attributeData: {
+          versions: ''
+        },
         bomTreeList: [],
         statusOptions: [
           {
@@ -217,11 +216,11 @@
         bomTypeOptions: [
           {
             label: 'PBOM',
-            value: '1'
+            value: 1
           },
           {
             label: 'MBOM',
-            value: '2'
+            value: 2
           }
         ]
       };
@@ -233,24 +232,34 @@
         this.attributeData.level = +data.level + 1;
       },
       save() {
+        if (!this.attributeData.parentId) {
+          this.attributeData.parentId = 0;
+          this.attributeData.level = 1;
+        }
         saveBomTreeList(this.attributeData).then((res) => {
           if (res.code == '0') {
             this.$message.success('保存成功');
-            this.$emit('reload');
+            this.$emit('reload', this.attributeData.versions);
             this.handleClose();
           }
         });
       },
+      versionsChange(versions) {
+        this.attributeData.versions = versions;
+        this.$forceUpdate();
+      },
       async open(type, versions, categoryId) {
         this.attributeData = {};
         this.attributeData.bomType = type;
         this.attributeData.categoryId = categoryId;
         this.attributeData.versions = versions;
+        this.versions = versions;
         const res = await getBomTreeList({
           categoryId,
           versions,
           bomType: type
         });
+        console.log(this.attributeData);
         this.bomTreeList = res.data;
         this.visible = true;
       },

+ 0 - 1
src/views/material/BOMmanage/components/user-search.vue

@@ -48,7 +48,6 @@
     </el-row>
   </el-form>
 </template>
-import control from '@/api/technology/control';
 <script>
   import control from '@/api/technology/control';
   export default {

+ 1 - 1
src/views/material/BOMmanage/components/workmanship.vue

@@ -278,7 +278,7 @@
             minWidth: 110
           },
           {
-            prop: 'name',
+            prop: 'versions',
             label: '版本',
             showOverflowTooltip: true,
             align: 'center',

+ 77 - 19
src/views/material/BOMmanage/details.vue

@@ -15,6 +15,7 @@
             >
               <el-radio-button :label="1">PBOM</el-radio-button>
               <el-radio-button :label="2">MBOM</el-radio-button>
+              <el-radio-button :label="3">ABOM</el-radio-button>
             </el-radio-group>
           </div>
 
@@ -45,7 +46,6 @@
                 size="mini"
                 icon="el-icon-plus"
                 @click="add"
-                v-if="currentNodeData.bomType == 2"
                 >新建</el-button
               >
               <el-button
@@ -79,7 +79,7 @@
                 v-if="currentNodeData.bomType == 1"
                 >转换MBOM</el-button
               >
-              <div class="back-btn">
+              <div v-if="!noBack" class="back-btn">
                 <el-button size="mini" icon="el-icon-back" @click="back"
                   >返回</el-button
                 >
@@ -90,14 +90,23 @@
               :dataInfo="currentNodeData"
               v-if="currentNodeData.bomType == 2"
             />
-            <el-tabs class="tab-box" type="border-card">
-              <el-tab-pane label="属性">
+            <el-tabs
+              v-model="activeName"
+              class="tab-box"
+              type="border-card"
+              @tab-click="handleClick"
+            >
+              <el-tab-pane label="属性" name="属性">
                 <attribute :attributeData="currentNodeData"></attribute>
               </el-tab-pane>
-              <el-tab-pane label="文档">
+              <el-tab-pane label="文档" name="文档">
                 <document></document>
               </el-tab-pane>
-              <el-tab-pane v-if="currentNodeData.level == 3" label="工艺">
+              <el-tab-pane
+                v-if="currentNodeData.children?.length < 1"
+                label="工艺"
+                name="工艺"
+              >
                 <workmanship
                   ref="workmanshipRef"
                   :taskParam="currentNodeData"
@@ -108,7 +117,7 @@
         </template>
       </ele-split-layout>
     </el-card>
-    <bomTreeDialog ref="bomTreeDialogRef" @reload="getTreeData" />
+    <bomTreeDialog ref="bomTreeDialogRef" @reload="bomTreeDialogReload" />
   </div>
 </template>
 
@@ -135,6 +144,7 @@
     },
     data() {
       return {
+        activeName: '属性',
         currentNodeData: {
           bomType: 1,
           children: []
@@ -152,15 +162,44 @@
         filterText: null,
         categoryId: 1,
         versions: null,
-        loadingInstance: null
+        loadingInstance: null,
+        noBack: false
       };
     },
     mounted() {
-      this.versions = this.$route.query.versions;
-      this.categoryId = this.$route.query.categoryId;
-      this.getTreeData();
+      this.initData();
+    },
+    activated() {
+      this.initData();
     },
     methods: {
+      bomTreeDialogReload(versions) {
+        this.versions = versions;
+        if (!this.$route.query.versions) {
+          this.$router.replace({
+            path: '/material/BOMmanage/details',
+            query: { categoryId: this.categoryId, versions: versions }
+          });
+        }
+        this.getTreeData();
+      },
+      initData() {
+        console.log('触发了!!!!');
+        this.versions = this.$route.query.versions;
+        this.categoryId = this.$route.query.categoryId;
+        this.noBack = this.$route.query.noBack;
+        (this.currentNodeData = {
+          bomType: 1,
+          children: []
+        }),
+          this.getTreeData();
+      },
+      handleClick(tab) {
+        console.log(tab);
+        if (tab.name === '工艺' && this.currentNodeData.children?.length < 1) {
+          this.$refs.workmanshipRef.reload();
+        }
+      },
       remove() {
         this.$confirm('是否确认删除?', '提示', {
           confirmButtonText: '确定',
@@ -226,12 +265,16 @@
           });
           this.treeLoading = false;
           if (res?.code === '0') {
-            this.treeList = res.data;
-            this.$nextTick(() => {
-              // 默认高亮第一个
-              this.$refs.treeRef.setCurrentKey(res.data[0].id);
-              this.handleNodeClick(res.data[0]);
-            });
+            if (res.data?.length > 0) {
+              this.treeList = res.data;
+              this.$nextTick(() => {
+                // 默认高亮第一个
+                this.$refs.treeRef.setCurrentKey(res.data[0].id);
+                this.handleNodeClick(res.data[0]);
+              });
+            } else {
+              this.treeList = [];
+            }
             return this.treeList;
           }
         } catch (error) {
@@ -242,8 +285,23 @@
       },
 
       handleNodeClick(data) {
-        console.log(data);
-        this.currentNodeData = data;
+        if (data) {
+          this.versions = data.versions;
+          this.currentNodeData = data;
+          if (
+            this.activeName == '工艺' &&
+            this.currentNodeData.children?.length < 1
+          ) {
+            this.$nextTick(() => {
+              this.$refs.workmanshipRef.reload();
+            });
+          }
+        } else {
+          this.currentNodeData = {
+            bomType: 1,
+            children: []
+          };
+        }
       }
     }
   };

+ 45 - 7
src/views/material/BOMmanage/index.vue

@@ -1,11 +1,16 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never">
-      <BOMSearch @search="reload" :statusOpt="statusOpt" />
+      <BOMSearch
+        @search="reload"
+        :statusOpt="statusOpt"
+        :categoryCode="where.categoryCode"
+      />
       <ele-pro-table
         ref="table"
         :columns="columns"
         :datasource="datasource"
+        :initLoad="false"
         class="dict-table"
         tool-class="ele-toolbar-actions"
       >
@@ -18,8 +23,8 @@
             >详情</el-link
           >
           <el-switch
-            :active-value="1"
-            :inactive-value="0"
+            :active-value="'1'"
+            :inactive-value="'0'"
             @change="openBom(row, $event)"
             v-model="row.status"
           >
@@ -102,11 +107,44 @@
           1: '已发布'
         },
         loading: false,
-        loadingInstance: null
+        loadingInstance: null,
+        where: {}
       };
     },
-
+    mounted() {
+      this.initData();
+    },
+    activated() {
+      this.initData();
+    },
     methods: {
+      initData() {
+        let { categoryId, code } = this.$route.query;
+        if (categoryId && code) {
+          this.where.categoryCode = code;
+          this.where.categoryId = categoryId;
+          getBomPageList({
+            status: 1,
+            categoryCode: this.where.categoryCode,
+            pageNum: 1,
+            size: 10
+          }).then((data) => {
+            console.log(data);
+            if (data.count > 1) {
+              this.$refs.table.setData(data.list || []);
+            } else {
+              this.handelDetail(
+                data.list[0]
+                  ? data.list[0]
+                  : { categoryId: this.where.categoryId },
+                true
+              );
+            }
+          });
+        } else {
+          this.reload();
+        }
+      },
       /* 启用关闭BOM */
       openBom(row, boolean) {
         this.loadingInstance = this.$loading({
@@ -128,10 +166,10 @@
           size: limit
         });
       },
-      handelDetail(row) {
+      handelDetail(row, noBack) {
         this.$router.push({
           path: '/material/BOMmanage/details',
-          query: { versions: row.versions, categoryId: row.categoryId }
+          query: { versions: row.versions, categoryId: row.categoryId, noBack }
         });
       },
       /* 刷新表格 */

+ 7 - 6
src/views/material/materialBOM/components/BOM-search.vue

@@ -75,14 +75,15 @@
 <script>
   export default {
     props: {
-      statusOpt: Object
+      statusOpt: Object,
+      categoryCode: String
     },
-    data () {
+    data() {
       // 默认表单数据
       const defaultWhere = {
         name: '',
         code: '',
-        categoryCode: '',
+        categoryCode: this.categoryCode,
         categoryName: '',
         status: ''
       };
@@ -94,17 +95,17 @@
     },
     computed: {
       // 是否开启响应式布局
-      styleResponsive () {
+      styleResponsive() {
         return this.$store.state.theme.styleResponsive;
       }
     },
     methods: {
       /* 搜索 */
-      search () {
+      search() {
         this.$emit('search', this.where);
       },
       /*  重置 */
-      reset () {
+      reset() {
         this.where = { ...this.defaultWhere };
         this.search();
       }

+ 18 - 0
src/views/material/product/components/index-data.vue

@@ -106,6 +106,15 @@
           工艺参数
         </el-link>
 
+        <el-link
+          type="primary"
+          v-if="row.isProduct == 1"
+          :underline="false"
+          @click="toBomManager(row)"
+        >
+          BOM管理
+        </el-link>
+
         <el-link
           type="primary"
           v-if="row.isProduct == 1"
@@ -347,6 +356,15 @@
     },
 
     methods: {
+      toBomManager(row) {
+        this.$router.push({
+          path: '/material/BOMmanage',
+          query: {
+            categoryId: row.id,
+            code: row.code
+          }
+        });
+      },
       successUpload(response) {
         this.isLoading = false;
       },