通過vue實現左側樹狀右側的組件

隨著后臺管理項目的開發,左側樹狀,右側則為列表的需求越來越多,還有就是拆分該數組,只展示其中一個對象等需求。廢話不多說,直接上代碼

<template><div><el-row :gutter="20"><el-col :span="6" :xs="24"><div class="head-container"><el-inputv-model="deptName"placeholder="請輸入名稱"clearablesize="small"prefix-icon="el-icon-search"style="margin-bottom: 20px"/></div><div class="head-container"><el-tree:data="deptOptions":props="defaultProps":expand-on-click-node="false":filter-node-method="filterNode"ref="tree"node-key="id"default-expand-allhighlight-current@node-click="handleNodeClick"/></div></el-col><!--用戶數據--><el-col :span="18" :xs="24"><el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"><el-form-item label="用戶名稱" prop="userName"><el-inputv-model="queryParams.userName"placeholder="請輸入用戶名稱"clearablestyle="width: 150px"@keyup.enter.native="handleQuery"/></el-form-item><el-form-item label="手機號碼" prop="phonenumber"><el-inputv-model="queryParams.phonenumber"placeholder="請輸入手機號碼"clearablestyle="width: 150px"@keyup.enter.native="handleQuery"/></el-form-item><el-form-item><el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button><el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button></el-form-item></el-form><el-table v-show="checkType === 'multiple'" ref="dataTable" v-loading="loading" :row-key="getRowKey" :data="userList" @selection-change="handleMultipleUserSelect"><el-table-column type="selection" :reserve-selection="true" width="50" align="center" /><el-table-column label="用戶編號" align="center" key="id" prop="id" v-if="columns[0].visible" /><el-table-column label="登錄賬號" align="center" key="username" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" /><el-table-column label="用戶姓名" align="center" key="realName" prop="realName" v-if="columns[2].visible" :show-overflow-tooltip="true" /><!-- <el-table-column label="部門" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" /> --><el-table-column label="手機號碼" align="center" key="phone" prop="phone" v-if="columns[4].visible" width="120" /></el-table><el-table v-show="checkType === 'single'" v-loading="loading" :data="userList" @current-change="handleSingleUserSelect"><el-table-column  width="55" align="center" ><template slot-scope="scope"><el-radio v-model="radioSelected" :label="scope.row.id">{{''}}</el-radio></template></el-table-column><el-table-column label="用戶編號" align="center" key="id" prop="id" v-if="columns[0].visible" /><el-table-column label="登錄賬號" align="center" key="username" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" /><el-table-column label="用戶姓名" align="center" key="realName" prop="realName" v-if="columns[2].visible" :show-overflow-tooltip="true" /><el-table-column label="部門" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" /><el-table-column label="手機號碼" align="center" key="phone" prop="phone" v-if="columns[4].visible" width="120" /></el-table><el-table v-show="checkType === 'department'" v-loading="loading" :data="userList" @current-change="handleSingleUserSelect"><el-table-column  width="55" align="center" ></el-table-column><el-table-column label="用戶編號" align="center" key="id" prop="id" v-if="columns[0].visible" /><el-table-column label="登錄賬號" align="center" key="username" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" /><el-table-column label="用戶姓名" align="center" key="realName" prop="realName" v-if="columns[2].visible" :show-overflow-tooltip="true" /><el-table-column label="部門" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" /><el-table-column label="手機號碼" align="center" key="phone" prop="phone" v-if="columns[4].visible" width="120" /></el-table><paginationv-show="total>0":total="total":page-sizes="[5,10]":page.sync="queryParams.pageNum":limit.sync="queryParams.pageSize"@pagination="getList"/></el-col></el-row></div>
</template><script>
import { listUser, deptTreeSelect } from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {StrUtil} from "@/util/StrUtil";export default {name: "FlowUser",dicts: ['sys_normal_disable', 'sys_user_sex'],components: { Treeselect },// 接受父組件的值props: {// 回顯數據傳值selectValues: {type: Number | String | Array,default: null,required: false},// 表格類型checkType: {type: String,default: 'multiple',required: true},},data() {return {// 遮罩層loading: true,// 選中數組ids: [],// 非單個禁用single: true,// 非多個禁用multiple: true,// 顯示搜索條件showSearch: true,// 總條數total: 0,// 用戶表格數據userList: [],// 彈出層標題title: "",// 部門樹選項deptOptions: undefined,// 是否顯示彈出層open: false,// 部門名稱deptName: undefined,// 表單參數form: {},defaultProps: {children: "children",label: "label"},// 查詢參數queryParams: {pageNum: 1,pageSize: 5,userName: undefined,phonenumber: undefined,status: undefined,deptId:''},// 列信息columns: [{ key: 0, label: `用戶編號`, visible: true },{ key: 1, label: `用戶名稱`, visible: true },{ key: 2, label: `用戶昵稱`, visible: true },{ key: 3, label: `部門`, visible: true },{ key: 4, label: `手機號碼`, visible: true },{ key: 5, label: `狀態`, visible: true },{ key: 6, label: `創建時間`, visible: true }],radioSelected: null, // 單選框傳值selectUserList: [] // 回顯數據傳值};},watch: {deptName(val) {this.$refs.tree.filter(val);},selectValues: {handler(newVal) {if(!newVal){this.radioSelected = null}if (StrUtil.isNotBlank(newVal)) {if (!newVal instanceof Number) {this.radioSelected = newValthis.selectValues = newVal}else{this.selectUserList = newVal;}}},immediate: true},userList: {handler(newVal) {if (StrUtil.isNotBlank(newVal)  && this.selectUserList.length > 0) {this.$nextTick(() => {this.$refs.dataTable.clearSelection();this.selectUserList.split(',').forEach(key => {this.$refs.dataTable.toggleRowSelection(newVal.find(item => key == item.userId), true)});});}},immediate: true, // 立即生效deep: true  //監聽對象或數組的時候,要用到深度監聽}},created() {this.getDeptTree();this.getList();},methods: {/** 查詢用戶列表 */getList() {// this.loading = true;console.log(this.queryParams,'1222222212')listUser(this.queryParams).then(response => {console.log(response);this.userList = response.data.data.records;this.total = response.data.data.total;});this.loading = false;},/** 查詢部門下拉樹結構 */getDeptTree() {deptTreeSelect().then(response => {let  childrenList =[]if( response.data.data[0]!=undefined){if(response.data.data[0].children != undefined){response.data.data[0].children.map(item =>{childrenList = response.data.data[0].children.filter(item => item.label === '銷售部');})}}response.data.data[0].children.length = 0response.data.data[0].children = childrenListthis.queryParams.deptId = response.data.data[0].children[0].idthis.deptOptions = response.data.datathis.loading = true;listUser(this.queryParams).then(response => {this.userList = response.data.data.records;this.total = response.data.data.total;});this.loading = false;});},// 保存選中的數據id,row-key就是要指定一個key標識這一行的數據getRowKey (row) {return row.id},// 篩選節點filterNode(value, data) {if (!value) return true;return data.label.indexOf(value) !== -1;},// 節點單擊事件handleNodeClick(data) {if(this.checkType == 'department'){this.$emit('chosedepart',data)}this.queryParams.deptId = data.id;this.handleQuery();},// 多選框選中數據handleMultipleUserSelect(selection) {this.$emit('handleUserSelect', selection);},// 單選框選中數據handleSingleUserSelect(selection) {this.radioSelected = selection.id;//點擊當前行時,radio同樣有選中效果this.$emit('handleUserSelect', selection);},/** 搜索按鈕操作 */handleQuery() {this.queryParams.pageNum = 1;this.getList();},/** 重置按鈕操作 */resetQuery() {this.dateRange = [];this.queryParams.deptId = undefined;this.queryParams.userName = ''this.queryParams.phone = ''this.$refs.tree.setCurrentKey(null);this.getList();},}
};
</script>
<style>
/*隱藏radio展示的label及本身自帶的樣式*/
/*.el-radio__label{*/
/*  display:none;*/
/*}*/
</style>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/715277.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/715277.shtml
英文地址,請注明出處:http://en.pswp.cn/news/715277.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

(四)優化函數,學習速率與反向傳播算法--九五小龐

多層感知器 梯度下降算法 梯度的輸出向量表明了在每個位置損失函數增長最快的方向&#xff0c;可將它視為表示了在函數的每個位置向那個方向移動函數值可以增長。 曲線對應于損失函數。點表示權值的當前值&#xff0c;即現在所在的位置。梯度用箭頭表示&#xff0c;表明為了增…

GEE入門篇|圖像處理(三):閾值處理、掩膜和重新映射圖像

閾值處理、掩膜和重新映射圖像 本章前一節討論了如何使用波段運算來操作圖像&#xff0c; 這些方法通過組合圖像內的波段來創建新的連續值。 本期內容使用邏輯運算符對波段或索引值進行分類&#xff0c;以創建分類圖像。 1.實現閾值 實現閾值使用數字&#xff08;閾值&#xf…

PXE網絡啟動實戰(第一篇 啟動WinPE)

免責聲明:文中有一些圖片來源自網絡,如有版權請通知我刪除,謝謝! 目錄 一、無盤站 二、PXE啟動 三、PXE啟動原理 四、啟動WinPE 1、服務器準備 2、客戶端 3、TFTP服務 4、WinPE選擇 5、具體操作: 預告 一、無盤站 網絡啟動最早用于無盤系統,那時的電腦只配備軟…

【python量化】多種Transformer模型用于股價預測(Autoformer, FEDformer和PatchTST等)_neuralforecast

寫在前面 在本文中&#xff0c;我們利用Nixtla的NeuralForecast框架&#xff0c;實現多種基于Transformer的時序預測模型&#xff0c;包括&#xff1a;Transformer, Informer, Autoformer, FEDformer和PatchTST模型&#xff0c;并且實現將它們應用于股票價格預測的簡單例子。 …

Libero集成開發環境中Identify應用與提高

Libero集成開發環境中Identify應用與提高 Identify的安裝

小米手機相冊閃退

環境&#xff1a; HyperOS 1.0 小米手機分身 處理步驟&#xff1a; 1&#xff09;清理相冊緩存&#xff1a;設置->應用設置->相冊->清理數據->清除緩存&#xff08;注意&#xff1a;別點清理全部數據&#xff1b;這個方法對我沒用&#xff09;。 2&#xff09;卸…

操作系統原理與實驗——實驗三優先級進程調度

實驗指南 運行環境&#xff1a; Dev c 算法思想&#xff1a; 本實驗是模擬進程調度中的優先級算法&#xff0c;在先來先服務算法的基礎上&#xff0c;只需對就緒隊列到達時間進行一次排序。第一個到達的進程首先進入CPU&#xff0c;將其從就緒隊列中出隊后。若此后隊首的進程的…

多租戶 TransmittableThreadLocal 線程安全問題

在一個多租戶項目中&#xff0c;用戶登錄時,會在自定義請求頭攔截器AsyncHandlerInterceptor將該用戶的userId,cstNo等用戶信息設置到TransmittableThreadLocal中,在后續代碼中使用.代碼如下: HeaderInterceptor 請求頭攔截器 public class HeaderInterceptor implements Asyn…

阿里云國際云服務器全局流量分析功能詳細介紹

進行全局流量分析時&#xff0c;內網DNS解析會作為一個整體模塊&#xff0c;其他模塊的邊緣虛框顏色會置灰&#xff0c;示意作為一個整體進行全局分析&#xff0c;左側Region可以展開/匯總&#xff0c;也可以單獨選中某個Region模塊進行分析&#xff08;這時其他Region的流量線…

【Java面試題】Redis的用途

以下是一些常見的用途 1.緩存 Redis 可以用作緩存系統&#xff0c;&#xff0c;將頻繁訪問的數據存儲在內存中&#xff0c;從而加快數據訪問速度&#xff0c;減少對數據庫的訪問壓力。 2.消息隊列 Redis 支持發布/訂閱模式和列表數據結構&#xff0c;可以用作消息隊列系統的…

道可云元宇宙每日資訊|廈門首個元宇宙辦稅大廳啟用

道可云元宇宙每日簡報&#xff08;2024年3月1日&#xff09;訊&#xff0c;今日元宇宙新鮮事有&#xff1a; 中國軍號元宇宙發布會即將舉行 近日&#xff0c;解放軍新聞傳播中心中國軍號即將正式上線。中國軍號元宇宙發布會也將在“云端”與您見面。全方位展現解放軍新聞傳播…

加密與安全_探索簽名算法

文章目錄 概述應用常用數字簽名算法CodeDSA簽名ECDSA簽名小結 概述 在非對稱加密中&#xff0c;使用私鑰加密、公鑰解密確實是可行的&#xff0c;而且有著特定的應用場景&#xff0c;即數字簽名。 數字簽名的主要目的是確保消息的完整性、真實性和不可否認性。通過使用私鑰加…

云服務器購買教程

在購買云服務器之前&#xff0c;建議仔細評估自身需求和預算&#xff0c;并與多個云服務提供商進行比較&#xff0c;以確保選擇到最適合的解決方案。購買云服務器的具體步驟可能因所選云服務提供商而異。以下以實際操作的方式介紹如何購買一款云服務器。 云服務器購買常見問題…

【數倉】zookeeper軟件安裝及集群配置

相關文章 【數倉】基本概念、知識普及、核心技術【數倉】數據分層概念以及相關邏輯【數倉】Hadoop軟件安裝及使用&#xff08;集群配置&#xff09;【數倉】Hadoop集群配置常用參數說明 一、環境準備 準備3臺虛擬機 Hadoop131&#xff1a;192.168.56.131Hadoop132&#xff…

【Spring連載】使用Spring Data訪問 MongoDB----對象映射之基于類型的轉換器

【Spring連載】使用Spring Data訪問 MongoDB----對象映射之基于類型的轉換器 一、自定義轉換二、轉換器消歧(Disambiguation)三、基于類型的轉換器3.1 寫轉換3.2 讀轉換3.3 注冊轉換器 一、自定義轉換 下面的Spring Converter實現示例將String對象轉換為自定義Email值對象: R…

藍橋杯_定時器的綜合應用實例

一 工程 代碼 在單片機訓練平臺上&#xff0c;利用定時器T0&#xff0c;數碼管模塊和2個獨立按鍵&#xff08;J5的2&#xff0c;3短接&#xff09;&#xff0c;設計一個秒表&#xff0c;具有清零&#xff0c;暫停&#xff0c;啟動功能。 顯示模式&#xff1a;分-秒-0.05秒&…

Linux進程——信號詳解(上)

文章目錄 信號入門生活角度的信號技術應用角度的信號用kill -l命令可以察看系統定義的信號列表信號處理常見方式概述 產生信號通過鍵盤進行信號的產生&#xff0c;ctrlc向前臺發送2號信號通過系統調用異常軟件條件 信號入門 生活角度的信號 你在網上買了很多件商品&#xff0…

前端面試練習24.3.2-3.3

HTMLCSS部分 一.說一說HTML的語義化 在我看來&#xff0c;它的語義化其實是為了便于機器來看的&#xff0c;當然&#xff0c;程序員在使用語義化標簽時也可以使得代碼更加易讀&#xff0c;對于用戶來說&#xff0c;這樣有利于構建良好的網頁結構&#xff0c;可以在優化用戶體…

vue3項目中如何一個vue組件中的一個div里面的圖片鋪滿整個屏幕樣式如何設置

在Vue 3項目中&#xff0c;要使一個div內的圖片鋪滿整個屏幕&#xff0c;你需要確保幾個關鍵點&#xff1a;div元素和圖片元素的樣式設置正確&#xff0c;以及確保它們能夠覆蓋整個視口&#xff08;viewport&#xff09;。以下是一個簡單的步驟和代碼示例&#xff0c;幫助你實現…

代碼隨想錄算法訓練營第四八天 | 買股票

目錄 只買賣一次可買賣多次 LeetCode 121. 買賣股票的最佳時機 LeetCode 122. 買賣股票的最佳時機II 只買賣一次 給定一個數組 prices &#xff0c;它的第 i 個元素 prices[i] 表示一支給定股票第 i 天的價格。 你只能選擇 某一天 買入這只股票&#xff0c;并選擇在 未來的某…