From 6e367e4dc24da9085fc93556ee3a778119adebd9 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期一, 11 九月 2023 12:46:22 +0800
Subject: [PATCH] 	modified:   src/components/view/standard-table/material.vue 	new file:   src/components/view/standard-table/target.vue 	modified:   src/components/view/standard-table/technology.vue 	modified:   src/components/view/standard.vue

---
 src/components/view/standard.vue |   80 ++++++++++++++++++++++++++++------------
 1 files changed, 56 insertions(+), 24 deletions(-)

diff --git a/src/components/view/standard.vue b/src/components/view/standard.vue
index 0923393..d040ac1 100644
--- a/src/components/view/standard.vue
+++ b/src/components/view/standard.vue
@@ -20,7 +20,7 @@
           node-key="id" :filter-node-method="filterNode" @node-click="handleNodeClick" highlight-current>
           <div class="custom-tree-node" slot-scope="{ node, data }">
             <span><i :class="`node_i ${data.code != '[5]' ? 'el-icon-folder-opened' : 'el-icon-tickets'}`"></i>
-              {{ data.name }}</span>
+              {{ data.code }}{{ data.name }}</span>
             <el-button type="text" size="mini" @click.stop="remove(node, data)">
               <i class="el-icon-delete"></i>
             </el-button>
@@ -52,24 +52,16 @@
               璇�</span></el-button>
         </div>
 
-        <div v-if="this.typeselect == 0">
+        <div class="contentTable" v-if="this.typeselect == 0">
           <technology  :tableType="tableType" :tableData="tableData"></technology>
         </div>
         <div v-if="this.typeselect == 1">
-          鎶�鏈寚鏍�
+          <target :tableType="tableType" :tableData="tableData"></target>
         </div>
         <div v-if="this.typeselect == 2">
           <material  :tableType="tableType" :tableData="tableData"></material>
         </div>
-        <div v-if="this.typeselect == 3">
-          鐢熶骇宸ヨ壓
-        </div>
-        <!-- <div class="table">
-          <technology v-if="tableData.length !== 0" :tableType="tableType" :tableData="tableData"></technology>
-        </div> -->
-        <!-- <div class="table">
-          <technology v-if="tableData.length !== 0" :tableType="tableType" :tableData="tableData"></technology>
-        </div> -->
+        <div v-if="this.typeselect == 3">鐢熶骇宸ヨ壓</div>
       </div>
     </div>
 
@@ -91,9 +83,9 @@
 <script>
 import technology from "./standard-table/technology.vue"
 import material from "./standard-table/material.vue"
+import target from "./standard-table/target.vue"
 export default {
-  components: { technology,material },
-
+  components: { technology,material,target },
   data() {
     return {
       // BOM鏍戞暟鎹粨鏋�
@@ -104,7 +96,6 @@
       checkTreeNode: {},// 鐐瑰嚮閫変腑鏍戣妭鐐�
       tableData: [],
       bomAddModelVisible: false,// 鎺у埗bom鏂板妯℃�佹鏄惁鏄剧ず
-      list: [],
       typeselect: 0,
       returntree: {
         id:28,
@@ -124,8 +115,8 @@
   //   }
   // },
   mounted() {
+    this.tableType=0
     this.selectMaterialTree()
-    // this.selectAll()
     this.selectVersion()
   },
   methods: {
@@ -160,7 +151,6 @@
     TYPE(val) {//绫诲瀷.鏁版嵁
       console.log(val);
       this.typeselect = val
-
       // console.log(this.typeselect);
       this.selectVersion()
     },
@@ -168,8 +158,8 @@
       console.log(val);
       this.returntree = val
     },
-    selectVersion() {//鐗堟湰
-      this.$axios.get(this.$api.url.selectVersion, {
+    async selectVersion() {//鐗堟湰
+      let v=await this.$axios.get(this.$api.url.selectVersion, {
         params: {
           specificationsId: this.returntree.id,
           type: this.typeselect,
@@ -179,12 +169,16 @@
         this.version = this.verdata.map(el => {
           return el = `v${el}`
         })
-        console.log(this.verdata);
+        // console.log("鐗堟湰");
+        return this.verdata[0]
       })
+      this.character=v
+      this.VER="v"+v
+      console.log(this.character);
+      this.selectAll()
     },
     //鍙充晶鏁版嵁
     selectAll() {
-      console.log(this.$axios.get(this.$api.url.selectAll));
       this.$axios.get(this.$api.url.selectAll, {
         params: {
           specificationsId: this.returntree.id,//tree鐨勭偣鍑诲弽棣�
@@ -192,9 +186,19 @@
           version: this.character,//鐗堟湰
         }
       }).then(res => {
-        console.log(res.data);
-        this.tableData = res.data
+        let arr = res.data;
+        this.formatData(arr)
+        this.tableData = arr;
       })
+    },
+    formatData(data){
+      let arr = data;
+      for(var i=0;i<arr.length;i++){
+            arr[i].rowId = Math.random();
+            if(arr[i].children != undefined){
+              this.formatData(arr[i].children);
+            }
+        }
     },
     verevent(val) {
       console.log(val);
@@ -208,7 +212,7 @@
     },
     //浜旂骇鏍�
     selectMaterialTree() {
-      this.$axios.get(this.$api.url.selectTreeByMaterial).then(res => {
+      this.$axios.get(this.$api.url.selectTreeByMaterial).then( res => {
         this.list = res.data
         this.list.forEach((el, idx, arr) => {
           if (idx == 0) {
@@ -219,8 +223,33 @@
           }
         })
         this.selectDataList()
+        // 榛樿绗竴涓簲绾ц妭鐐规悳绱紝鏂板閰嶇疆椤�
+        const treeOptions = JSON.parse(JSON.stringify(this.list));
+        this.getDefault(treeOptions, 0);
+        this.formTypeOptions = treeOptions;
+        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 .el-tree-node__children .el-tree-node"
+          );
+          try {
+            firstNode.click();
+          } catch (e) {
+            //TODO handle the exception
+          }
+        });
       })
     },
+    getDefault(arr, index) {
+			for (const item of arr) {
+				if (item.children && item.children.length > 0) {
+					// 鏈夊瓙鑺傜偣
+					this.getDefault(item.children, index + 1);
+					if (index === 2) {
+						item.children = null;
+					}
+				}
+			}
+		},
     filterNode(value, data) {
       if (!value) return true;
       return data.label.indexOf(value) !== -1;
@@ -269,6 +298,9 @@
 <style scoped>
 .standard {}
 
+.standard .contentTable{
+}
+
 .standard .title .el-button {
   height: 32px;
   border: 1px solid rgba(190, 190, 190, 0.44);

--
Gitblit v1.9.3