From 32b45ba618dffadd345e8e8fb64baf2ba459ae83 Mon Sep 17 00:00:00 2001
From: hailin <1356886193@qq.com>
Date: 星期三, 19 七月 2023 14:07:47 +0800
Subject: [PATCH] 标准库第二次提交,完成左侧bom

---
 src/views/standardLibrary/index.vue    |  218 ++++++++++++++++++++++++++++++++++++-----------------
 src/layout/components/Sidebar/Item.vue |    2 
 2 files changed, 148 insertions(+), 72 deletions(-)

diff --git a/src/layout/components/Sidebar/Item.vue b/src/layout/components/Sidebar/Item.vue
index 5bfc188..7785af0 100644
--- a/src/layout/components/Sidebar/Item.vue
+++ b/src/layout/components/Sidebar/Item.vue
@@ -21,7 +21,7 @@
     const vnodes = []
     // console.log(show)
     // if (!show) return
-    console.log(icon, title)
+    // console.log(icon, title)
     if (icon) {
       if (icon.includes('el-icon')) {
         vnodes.push(<i class={[icon, 'sub-el-icon']} />)
diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue
index e5d8274..a848a7a 100644
--- a/src/views/standardLibrary/index.vue
+++ b/src/views/standardLibrary/index.vue
@@ -54,65 +54,55 @@
               min-width="50"
             />
             <el-table-column
-              prop="name"
-              label="浜у搧鍚嶇О"
-              min-width="150"
+              v-for="(item,index) in tablespecifications"
+              :key="index"
+              :prop="item.prop"
+              :label="item.label"
+              :min-width="item.minWidth"
             />
-            <el-table-column
-              prop="username"
-              label="鏇存柊浜�"
-              min-width="100"
-            />
-            <el-table-column
-              prop="updateTime"
-              label="鏇存柊鏃堕棿"
-              min-width="150"
-            />
-            <el-table-column
-              prop="vel"
-              label="鐗堟湰"
-              min-width="100"
-            />
-            <el-table-column
-              prop="spe_state"
-              label="鐘舵��"
-              min-width="150"
-            >
-              <template slot-scope="scope">
-                <el-tag
-                  :type="scope.row.spe_state === 0 ? 'primary' : 'success'"
-                  disable-transitions
-                >{{ scope.row.spe_state === 0 ? '鏈悓鎰�' : '宸插悓鎰�' }}</el-tag>
-              </template>
-            </el-table-column>
-            <el-table-column
-              label="鎿嶄綔"
-              min-width="150"
-            >
-              <template slot-scope="scope">
-                <el-button
-                  type="text"
-                  size="small"
-                  :style="{marginRight:'8px'}"
-                  @click="specificationDetails(scope.row)"
-                >鏌ョ湅</el-button>
-                <el-popover
-                  v-model="scope.row.visible"
-                  placement="top"
-                  width="30"
-                >
-                  <div style="text-align: center; margin: 0">
-                    <div>
-                      <el-button size="mini" type="text">缂栬緫</el-button>
+            <template v-if="showTableCurrent===2">
+              <el-table-column
+                prop="spe_state"
+                label="鐘舵��"
+                min-width="150"
+              >
+                <template slot-scope="scope">
+                  <el-tag
+                    :type="scope.row.spe_state === 0 ? 'primary' : 'success'"
+                    disable-transitions
+                  >{{ scope.row.spe_state === 0 ? '鏈悓鎰�' : '宸插悓鎰�' }}</el-tag>
+                </template>
+              </el-table-column>
+              <el-table-column
+                label="鎿嶄綔"
+                min-width="150"
+              >
+                <template slot-scope="scope">
+                  <el-button
+                    type="text"
+                    size="small"
+                    :style="{marginRight:'8px'}"
+                    @click="specificationDetails(scope.row)"
+                  >鏌ョ湅</el-button>
+                  <el-popover
+                    v-model="scope.row.visible"
+                    placement="top"
+                    width="30"
+                  >
+                    <div style="text-align: center; margin: 0">
+                      <div>
+                        <el-button size="mini" type="text">缂栬緫</el-button>
+                      </div>
+                      <div>
+                        <el-button size="mini" type="text">鍋滅敤</el-button>
+                      </div>
                     </div>
-                    <div>
-                      <el-button size="mini" type="text">鍋滅敤</el-button>
-                    </div>
-                  </div>
-                  <el-button slot="reference" type="text"><i class="el-icon-more" /></el-button>
-                </el-popover>
-              </template>
-            </el-table-column>
+                    <el-button slot="reference" type="text"><i class="el-icon-more" /></el-button>
+                  </el-popover>
+                </template>
+              </el-table-column>
+            </template>
+
           </el-table>
           <div>
             <el-pagination
@@ -121,6 +111,8 @@
               :page-size="pageParams.pageNo"
               layout="total, sizes, prev, pager, next, jumper"
               :total="pageParams.total"
+              @size-change="handleSizeChange"
+              @current-change="handleCurrentChange"
             />
           </div>
         </div>
@@ -182,7 +174,10 @@
         pageNo: 1,
         pageSize: 10,
         total: 3
-      }
+      },
+      tablespecifications: [
+      ],
+      showTableCurrent: 0
     }
   },
   watch: {
@@ -192,47 +187,128 @@
   },
   created() {
     this.getStandardTree()
+    this.getAllStandard()
   },
   methods: {
     filterNode(value, data) {
       if (!value) return true
       return data.label.indexOf(value) !== -1
     },
+    // 鑾峰彇bom鏍戠殑鏍囧噯鏁版嵁
     async getStandardTree() {
       const { data: standard } = await getStandardsList()// 鑾峰彇鎵�鏈夋爣鍑�
-      console.log(standard)// 鑾峰彇鎵�鏈夋爣鍑�
+      // console.log(standard)// 鑾峰彇鎵�鏈夋爣鍑�
       this.standardTree = standard.map(item => {
         item.serialNumber = item.serialNumber?.map(childrenItem => ({ ...childrenItem, label: childrenItem.name }))
         return { ...item, label: item.name, children: item.serialNumber }
       })
-      console.log(this.standardTree)
+      // console.log(this.standardTree)
     },
+    // 鐐瑰嚮bom鏍戣妭鐐规柟娉�
     async nodeClick(data, node, element) {
       console.log(data)
-      console.log('children' in data)
+      // console.log('children' in data)
       if (!('children' in data)) {
-        console.log('鐐瑰嚮瀛愯妭鐐�', data)
-        const { data: { row, total }} = await getSpecificationsList({ serialNumberId: data.id, specificationsName: data.label, pageNo: 1, pageSize: 10 })
-        console.log(row)
-        this.tableData = row
-        this.pageParams.total = total
+        // console.log('鐐瑰嚮瀛愯妭鐐�', data)
+        await this.getSpecifications(data)
         return
       }
-      const { data: { row, total }} = await getSerialNumberList({ standardsId: data.id, ...this.pageParams })
-      // console.log('鐐瑰嚮鐖惰妭鐐�', serialNumberList)
-      this.tableData = row
-      this.pageParams.total = total
+      await this.getSerialNumber(data)
     },
     specificationDetails(row) {
       // 璺宠浆浜у搧瑙勬牸璇︽儏椤�
       console.log(row)
       this.$router.push(`/standardLibrary/SpecificationDetails/${row.id}`)
     },
+    // 鑾峰彇鎵�鏈夋爣鍑唗able
     async getAllStandard() {
-      console.log(this.pageParams)
+      // console.log(this.pageParams)
       const { data: { row, total }} = await getStandardsListOfPage({ ...this.pageParams })
+      console.log('寰楀埌鎵�鏈夋爣鍑�==>', row)
       this.pageParams.total = total
       this.tableData = row
+      this.tablespecifications = [
+        {
+          prop: 'name',
+          label: '鏍囧噯鍚嶇О',
+          minWidth: '150px'
+        },
+        {
+          prop: 'eng_name',
+          label: '鏍囧噯鑻辨枃鍚嶇О',
+          minWidth: '150px'
+        },
+        {
+          prop: 'createTime',
+          label: '鍒涘缓鏃堕棿',
+          minWidth: '150px'
+        }
+      ]
+      this.showTableCurrent = 0
+    },
+    // 鑾峰彇鏍囧噯涓嬪搴旂殑鎵�鏈夊瀷鍙�
+    async getSpecifications(data) {
+      const { data: { row, total }} = await getSpecificationsList({ serialNumberId: data.id, pageNo: 1, pageSize: 10 })
+      console.log(row)
+      this.tableData = row
+      this.pageParams.total = total
+      this.tablespecifications = [
+        {
+          prop: 'name',
+          label: '浜у搧鍚嶇О',
+          minWidth: '150px'
+        },
+        {
+          prop: 'username',
+          label: '鏇存柊浜�',
+          minWidth: '100px'
+        },
+        {
+          prop: 'updateTime',
+          label: '鏇存柊鏃堕棿',
+          minWidth: '150px'
+        },
+        {
+          prop: 'vel',
+          label: '鐗堟湰',
+          minWidth: '150px'
+        }
+      ]
+      this.showTableCurrent = 2
+    },
+    // 鑾峰彇瀵瑰簲鍨嬪彿涓嬬殑鎵�鏈夎鏍�
+    async getSerialNumber(data) {
+      const { data: { row, total }} = await getSerialNumberList({ standardsId: data.id, ...this.pageParams })
+      console.log('鐐瑰嚮鐖惰妭鐐�', row)// 鏍规嵁鏍囧噯鑾峰彇瀵瑰簲鏍囧噯涓嬬殑瑙勬牸
+      this.tableData = row
+      this.pageParams.total = total
+      this.tablespecifications = [
+        {
+          prop: 'name',
+          label: '鍨嬪彿鍚嶇О',
+          minWidth: '150px'
+        }
+      ]
+      this.showTableCurrent = 1
+    },
+    handleSizeChange(val) {
+      console.log(`姣忛〉 ${val} 鏉)
+      this.pageParams.pageSize = val
+      switch (this.showTableCurrent) {
+        case 0:
+          this.getAllStandard()
+          break
+        case 1:
+          this.getAllStandard()
+          break
+        case 2:
+          this.getAllStandard()
+          break
+      }
+    },
+    handleCurrentChange(val) {
+      console.log(`褰撳墠椤�: ${val}`)
+      this.pageParams.pageNo = val
     }
   }
 }

--
Gitblit v1.9.3