From ffd461f541b355d2d5124a0735d9c6fd557d21a5 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期四, 10 八月 2023 13:13:06 +0800
Subject: [PATCH] Crunchy-08/10中午

---
 src/components/view/standard.vue |   74 ++++++++++++++++++++++++++++++-------
 1 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/src/components/view/standard.vue b/src/components/view/standard.vue
index 0ee0fae..3a9c15a 100644
--- a/src/components/view/standard.vue
+++ b/src/components/view/standard.vue
@@ -12,7 +12,7 @@
     margin-bottom: 10px;
     padding: 0 20px;
   }
-  
+
   .standard .title *{
     font-size: 16px;
   }
@@ -89,7 +89,7 @@
   .standard .title .el-button * {
     font-size: 14px;
   }
-  
+
   .standard .title .el-button--default{
     color: #004EA2;
   }
@@ -111,7 +111,7 @@
       <el-row>
         <el-col :span="12" style="line-height: 32px;">鏍囧噯BOM</el-col>
         <el-col :span="12" style="text-align: right;">
-          <el-button type="primary" icon="el-icon-plus" style="background: #004EA2;">鏂板</el-button>
+          <el-button type="primary" icon="el-icon-plus" style="background: #004EA2;" @click="bomAddModelVisible= true">鏂板</el-button>
           <el-button icon="el-icon-edit-outline">淇敼</el-button>
           <el-button icon="el-icon-delete">鍒犻櫎</el-button>
         </el-col>
@@ -136,18 +136,32 @@
         <div class="choose">
           <span>绫诲瀷锛�</span>
           <el-select v-model="tableType" size="small" placeholder="璇烽�夋嫨" style="width: 224px;margin-right: 52px;">
-            <el-option value="宸ヨ壓鏂囦欢"></el-option>
-            <el-option value="鎶�鏈寚鏍�"></el-option>
+            <el-option :value="0" label="宸ヨ壓鏂囦欢"></el-option>
+            <el-option :value="1" label="鎶�鏈寚鏍�"></el-option>
           </el-select>
-          <span>{{tableType=='鎶�鏈寚鏍�'?'椤圭洰锛�':'宸ヨ壓鍚嶇О锛�'}}</span>
+          <span>{{tableType==1?'椤圭洰锛�':'宸ヨ壓鍚嶇О锛�'}}</span>
           <el-input v-model="searchName" size="small" placeholder="璇疯緭鍏�" style="width: 224px;margin-right: 24px;" clearable></el-input>
-          <el-button size="mini"><span>閲� 缃�</span></el-button>
-          <el-button size="mini" type="primary" style="background: #004EA2;"><span>鏌� 璇�</span></el-button>
+          <el-button size="mini" @click="()=>{searchName='';selectProductTableData()}"><span>閲� 缃�</span></el-button>
+          <el-button size="mini" type="primary" style="background: #004EA2;" @click="selectProductTableData"><span>鏌� 璇�</span></el-button>
         </div>
         <div class="table">
-          <technology></technology>
+          <technology v-if="tableData.length!==0" :tableType="tableType" :tableData="tableData"></technology>
         </div>
       </div>
+    </div>
+    <div class="bom-add-model">
+      <el-dialog
+        title="BOM鏂板"
+        :visible.sync="bomAddModelVisible"
+        width="30%">
+        <el-form>
+
+        </el-form>
+        <span slot="footer" class="dialog-footer">
+          <el-button @click="bomAddModelVisible = false">鍙� 娑�</el-button>
+          <el-button type="primary" @click="bomAddModelVisible = false">纭� 瀹�</el-button>
+        </span>
+      </el-dialog>
     </div>
   </div>
 </template>
@@ -158,6 +172,7 @@
     components: {technology},
     data() {
       return {
+        // BOM鏍戞暟鎹粨鏋�
         list: [{
           id: 0,
           name: "鍘熸潗鏂�",
@@ -175,13 +190,23 @@
           children: []
         }],
         search: null,
-        tableType: "鎶�鏈寚鏍�",
-        searchName: ""
+        // 琛ㄦ牸绫诲瀷 1锛氭妧鏈寚鏍囷紝0锛氬伐鑹鸿矾绾�
+        tableType: 1,
+        // 鏌ヨ鏉′欢-鍚嶇О
+        searchName: "",
+        // 鐐瑰嚮閫変腑鏍戣妭鐐�
+        checkTreeNode: {},
+        tableData:[],
+        // 鎺у埗bom鏂板妯℃�佹鏄惁鏄剧ず
+        bomAddModelVisible: false
       }
     },
     watch: {
       search(val) {
         this.$refs.tree.filter(val);
+      },
+      tableType(val){
+        this.selectProductTableData()
       }
     },
     mounted() {
@@ -189,7 +214,9 @@
     },
     methods: {
       handleNodeClick(data) {
-        console.log(data);
+        this.checkTreeNode = data
+        // this.selectMaterialTree()
+        this.selectProductTableData()
       },
       filterNode(value, data) {
         if (!value) return true;
@@ -221,10 +248,29 @@
           this.$nextTick().then(() => {
           const firstNode = document.querySelector('.el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node')
           firstNode.click()
-          // console.log(firstNode)
           })
         })
-        
+
+      },
+      async selectProductTableData() {
+        switch (this.tableType) {
+          case 0:
+        const {data:technologyList} = await this.$axios.get(this.$api.url.selectTechnologyByMaterial,{params:{specificationId:this.checkTreeNode.id,technologyName:this.searchName}})
+        this.tableData = technologyList
+            break;
+          case 1:
+        const {data:productList} = await this.$axios.get(this.$api.url.selectProductByMaterial,{params:{specifications:this.checkTreeNode.id,project:this.searchName}})
+        productList.forEach((item,index)=>{
+          item.name = item.father
+          item.index = index+1
+          item.id = item.father
+          if(item.children.length===1){
+            productList[index] = {...item.children[0],index: index+1,name:item.father}
+          }
+        })
+        this.tableData = productList
+            break;
+        }
       }
     }
   }

--
Gitblit v1.9.3