From 57edffda445efc23fd17752dbb36fc1b91c0716a Mon Sep 17 00:00:00 2001 From: hailin <1356886193@qq.com> Date: 星期三, 19 七月 2023 14:41:41 +0800 Subject: [PATCH] 标准库第二次修改的bug补交 --- src/views/standardLibrary/index.vue | 303 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 214 insertions(+), 89 deletions(-) diff --git a/src/views/standardLibrary/index.vue b/src/views/standardLibrary/index.vue index b55dc64..10a4063 100644 --- a/src/views/standardLibrary/index.vue +++ b/src/views/standardLibrary/index.vue @@ -6,7 +6,7 @@ v-model="filterText" placeholder="杈撳叆鍏抽敭瀛楄繘琛岃繃婊�" /> - <el-button type="text">鍏ㄩ儴</el-button> + <el-button type="text" @click="getAllStandard">鍏ㄩ儴</el-button> <el-tree ref="tree" class="filter-tree" @@ -42,10 +42,10 @@ </div> <div class="table-box"> <el-table - ref="standardLibraryTable" + ref="tableData" :cell-style="{textAlign: 'center'}" :header-cell-style="{border:'0px',background:'#f5f7fa',color:'#606266',boxShadow: 'inset 0 1px 0 #ebeef5',textAlign: 'center'}" - :data="standardLibraryTable" + :data="tableData" style="width: 100%" > <el-table-column @@ -54,58 +54,65 @@ 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" - @click="handleClick(scope.row)" - >鏌ョ湅</el-button> - <el-button type="text" size="small"><i class="el-icon-more" /></el-button> - </template> - </el-table-column> + <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> + <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 - :current-page="currentPage" - :page-sizes="[100, 200, 300, 400]" - :page-size="100" + :current-page="pageParams.pageNo" + :page-sizes="[1, 2, 3, 4]" + :page-size="pageParams.pageNo" layout="total, sizes, prev, pager, next, jumper" - :total="400" + :total="pageParams.total" + @size-change="handleSizeChange" + @current-change="handleCurrentChange" /> </div> </div> @@ -115,28 +122,15 @@ </template> <script> -import { getStandardsList, getSerialNumberList, getSpecificationsList } from '@/api/standardLibrary' +import { getStandardsList, getSerialNumberList, getSpecificationsList, getStandardsListOfPage } from '@/api/standardLibrary' export default { data() { return { + visible: false, filterText: '', // 鏍囧噯搴揵om鏍� - standardTree: [{ - id: 1, - label: '涓�绾� 1', - children: [{ - id: 4, - label: '浜岀骇 1-1', - children: [{ - id: 9, - label: '涓夌骇 1-1-1' - }, { - id: 10, - label: '涓夌骇 1-1-2' - }] - }] - }], - // 榛樿鍊� + standardTree: [], + // bom鐨�,榛樿鍊� defaultProps: { children: 'children', label: 'label' @@ -145,18 +139,49 @@ searchData: { keyword: '' }, - standardLibraryTable: [ + tableData: [ { id: 2, name: 'AB', updateTime: '2023-07-12 00:00:12', username: '灏忓皬', vel: 'V1.0', - spe_state: 1 + spe_state: 1, + visible: false + }, + { + id: 3, + name: 'AB', + updateTime: '2023-07-12 00:00:12', + username: '灏忓皬', + vel: 'V1.0', + spe_state: 1, + visible: false + + }, + { + id: 4, + name: 'AB', + updateTime: '2023-07-12 00:00:12', + username: '灏忓皬', + vel: 'V1.0', + spe_state: 1, + visible: false + } ], - currentPage: 1 - + // 鍒嗛〉鍙傛暟 + pageParams: { + pageNo: 1, + pageSize: 1, + total: 3 + }, + tablespecifications: [ + ], + // 閫変腑鑺傜偣瀵瑰簲鐨勮〃鏍� 0 鏄爣鍑嗚〃 1鏄瀷鍙疯〃 2瑙勬牸琛� + showTableCurrent: 0, + // 閫変腑鐨勮妭鐐规暟鎹� + selectNode: {} } }, watch: { @@ -166,42 +191,142 @@ }, 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)// 鑾峰彇鎵�鏈夋爣鍑� - 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)// 鑾峰彇鎵�鏈夋爣鍑� + 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) }, + // 鐐瑰嚮bom鏍戣妭鐐规柟娉� 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(data) + // console.log('children' in data) + if (!('children' in data)) { + // console.log('鐐瑰嚮瀛愯妭鐐�', data) + this.selectNode = data + await this.getSpecifications(data) + return } - console.log('鐐瑰嚮鐖惰妭鐐�') + this.selectNode = data + await this.getSerialNumber(data) + }, + specificationDetails(row) { + // 璺宠浆浜у搧瑙勬牸璇︽儏椤� + console.log(row) + this.$router.push(`/standardLibrary/SpecificationDetails/${row.id}`) + }, + // 鑾峰彇鎵�鏈夋爣鍑唗able + async getAllStandard() { + // 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 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 + }, + // 鑾峰彇鏍囧噯涓嬪搴旂殑鎵�鏈夊瀷鍙� + async getSpecifications(data) { + const { data: { row, total }} = await getSpecificationsList({ serialNumberId: data.id, ...this.pageParams }) + 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 + }, + // 鍒嗛〉鏉′欢鏀瑰彉鏃跺垽鏂渶瑕佸垎椤垫煡璇㈢殑鏂规硶 + judgment() { + switch (this.showTableCurrent) { + case 0: + this.getAllStandard() + break + case 1: + this.getSerialNumber(this.selectNode) + break + case 2: + this.getSpecifications(this.selectNode) + break + } + }, + handleSizeChange(val) { + console.log(`姣忛〉 ${val} 鏉) + this.pageParams.pageSize = val + this.judgment() + }, + handleCurrentChange(val) { + console.log(`褰撳墠椤�: ${val}`) + this.pageParams.pageNo = val + this.judgment() } } } </script> <style lang="scss" scoped> + .standard-library-main{ width: 100%; height: 100%; -- Gitblit v1.9.3