From 8eb564d8a9bb62cdfac2fe65152389e3b74da02d Mon Sep 17 00:00:00 2001 From: hailin <1356886193@qq.com> Date: 星期二, 18 七月 2023 11:09:36 +0800 Subject: [PATCH] 标准库第一次编辑 --- src/views/standardLibrary/index.vue | 96 ++++++++++++++++++++++++++++++++--------------- 1 files changed, 65 insertions(+), 31 deletions(-) diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue index f589079..b55dc64 100644 --- a/src/views/standardLibrary/index.vue +++ b/src/views/standardLibrary/index.vue @@ -6,24 +6,25 @@ v-model="filterText" placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�" /> + <el-button type="text">鍏ㄩ儴</el-button> <el-tree ref="tree" class="filter-tree" - :data="data" + :data="standardTree" :props="defaultProps" default-expand-all :filter-node-method="filterNode" - > - </el-tree> + @node-click="nodeClick" + /> </div> <div class="library-table"> <div class="table-header"> <div class="search-bar"> - <el-form ref="form" inline="true" :model="searchData"> + <el-form ref="form" :inline="true" :model="searchData"> <el-form-item> <el-input - placeholder="璇疯緭鍏ヤ汉鍛樺悕绉�/鍘熸潗鏂欏悕绉�" v-model="searchData.keyword" + placeholder="璇疯緭鍏ヤ汉鍛樺悕绉�/鍘熸潗鏂欏悕绉�" > <i slot="prefix" class="el-input__icon el-icon-search" /> </el-input> @@ -100,14 +101,12 @@ </el-table> <div> <el-pagination - @size-change="handleSizeChange" - @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[100, 200, 300, 400]" :page-size="100" layout="total, sizes, prev, pager, next, jumper" - :total="400"> - </el-pagination> + :total="400" + /> </div> </div> </div> @@ -116,11 +115,13 @@ </template> <script> +import { getStandardsList, getSerialNumberList, getSpecificationsList } from '@/api/standardLibrary' export default { data() { return { + filterText: '', // 鏍囧噯搴揵om鏍� - data: [{ + standardTree: [{ id: 1, label: '涓�绾� 1', children: [{ @@ -153,7 +154,9 @@ vel: 'V1.0', spe_state: 1 } - ] + ], + currentPage: 1 + } }, watch: { @@ -161,10 +164,38 @@ this.$refs.tree.filter(val) } }, + created() { + this.getStandardTree() + }, methods: { filterNode(value, data) { if (!value) return true return data.label.indexOf(value) !== -1 + }, + async getStandardTree() { + const { data: standard } = await getStandardsList()// 鑾峰彇鎵�鏈夋爣鍑� + // console.log(standard)// 鑾峰彇鎵�鏈夋爣鍑� + for (const standardItem of standard) { + const { data: serialNumber } = await getSerialNumberList({ IdOrNameOfSerialNumber: standardItem.name, standardsId: standardItem.id }) + // console.log(children) //鎵�鏈夊瀷鍙� + // for (const serialNumberItem of serialNumber) { + // // const {data} = await getSpecificationsList({}) + // } + standardItem.children = serialNumber.map(item => ({ id: item.id, label: item.name })) + } + this.standardTree = standard.map(item => ({ ...item, label: item.name })) + console.log(this.standardTree)// 鑾峰彇鎵�鏈夋爣鍑� + }, + async nodeClick(data, node, element) { + // 鏁版嵁 鑺傜偣node瀵硅薄 鑺傜偣缁勪欢瀵硅薄 + // console.log(data, node, element) + // console.log(data.children && data.children?.length !== 0) + if (!data.children && data.children?.length !== 0) { + console.log('鐐瑰嚮瀛愯妭鐐�', data) + const res = await getSpecificationsList({ serialNumberId: data.id, specificationsName: data.label, pageNo: 1, pageSize: 10 }) + console.log(res) + } + console.log('鐐瑰嚮鐖惰妭鐐�') } } } @@ -188,27 +219,30 @@ flex: 2; margin-right: 12px; .el-tree { - margin-top: 12px; - ::v-deep .el-tree-node__content{ - height: 24px !important; - font-size: 14px; - display: inline-block !important; - padding: 2px; - color: #333; - } - ::v-deep .el-tree-node__content:hover{ - background: rgba(58,124,253,0.1) ; - // opacity: 0.31; - border-radius: 3px; - color: #333 !important; - } - ::v-deep .el-tree-node:focus>.el-tree-node__content{ - background: rgba(58,124,253,0.1) ; - // opacity: 0.31; - border-radius: 3px; - color: #333 !important; - } + // margin-top: 12px; } + // .el-tree { + // margin-top: 12px; + // ::v-deep .el-tree-node__content{ + // height: 24px !important; + // font-size: 14px; + // display: inline-block !important; + // padding: 2px; + // color: #333; + // } + // ::v-deep .el-tree-node__content:hover{ + // background: rgba(58,124,253,0.1) ; + // // opacity: 0.31; + // border-radius: 3px; + // color: #333 !important; + // } + // ::v-deep .el-tree-node:focus>.el-tree-node__content{ + // background: rgba(58,124,253,0.1) ; + // // opacity: 0.31; + // border-radius: 3px; + // color: #333 !important; + // } + // } } .library-table{ flex: 8; -- Gitblit v1.9.3