最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue+el-select?多數(shù)據(jù)分頁搜索組件的實現(xiàn)

 更新時間:2024年12月18日 09:39:24   作者:5335ld  
本文主要介紹了vue+el-select?多數(shù)據(jù)分頁搜索組件的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

project.Vue

//子頁面1
<template>
	<div>
		<el-select  :value="defaultValue" :loading="loading" :multiple="multiple" :placeholder="placeholder"
			:allow-create="allowCreate"   :isConcatShowText="isConcatShowText" filterable remote clearable default-first-option :remote-method="remoteMethod"
			style="width: 100%;" @input="handleInput" @visible-change="visibleChange" @change="change"
			@clear="clearChange">
			<el-option v-for="(item, index) in optionsList" :key="'s' + index" :label="isConcatShowText==true?concatenatedLabel2(item):concatenatedLabel(item)"
				:value="item[valueString]">
				{{ concatenatedLabel(item) }}
			</el-option>
			<el-pagination class="select-pagination" @size-change="handleSizeChange"
				@current-change="handleCurrentChange" :current-page.sync="localCurrentPage" :page-size="pageSize"
				:total="total" layout="prev, pager, next, total"></el-pagination>
		</el-select>
	</div>
</template>

<script>
	export default {
		name: 'CustomSelect',
		props: {
			defaultValue: {
				type: [Number, String, Array],
				default: null
			},
			loading: {
				type: Boolean,
				default: false
			},
			拼接后 被選擇后輸入框是否顯示拼接的字符串
			isConcatShowText:{
				type: Boolean,
				default: false
			},
			multiple: {
				type: Boolean,
				default: false
			},
			placeholder: {
				type: String,
				default: 'Please select'
			},
			allowCreate: {
				type: Boolean,
				default: false
			},
			remoteMethod: {
				type: Function,
				default: null
			},
			optionsList: {
				type: Array,
				default: () => []
			},
			label: {
				type: String,
				default: 'label'
			},
			labelTwo: {
				type: String,
				default: ''
			},
			labelThree: {
				type: String,
				default: ''
			},
			labelFour: {
				type: String,
				default: ''
			},
			valueString: {
				type: String,
				default: 'value'
			},
			currentPage: {
				type: Number,
				default: 1
			},
			pageSize: {
				type: Number,
				default: 10
			},
			total: {
				type: Number,
				default: 0
			},
		},
		watch: {
			// 監(jiān)聽 prop 的變化,并更新本地數(shù)據(jù)屬性
			currentPage(newValue) {
				this.localCurrentPage = newValue;
			}
		},
		data() {
			return {
				localCurrentPage: 1
			}
		},
		methods: {
			handleInput(value) {
				this.$emit('input', value);
			},
			visibleChange(visible) {
				this.$emit('visible-change', visible);
			},
			change(value) {
				this.$emit('change', value);
			},
			clearChange() {
				this.$emit('clear');
			},
			handleSizeChange(size) {
				this.$emit('size-change', size);
			},
			handleCurrentChange(page) {
				this.$emit('current-change', page);
			},
			concatenatedLabel(item) {
				return [item[this.label], item[this.labelTwo], item[this.labelThree], item[this.labelFour]].filter(Boolean)
					.join(' || ');
			},
			concatenatedLabel2(item) {
				return item[this.label]
			}
		}
	};
</script>

<style scoped>
	.select-pagination {
		margin-top: 10px;
	}
</style>

projectParent.Vue

<template>
	<!-- 所有的項目 也可以單獨用這個頁面 -->
	<div>
		<!-- is-concat 是否拼接字符串 concat-symbol拼接字符  allowCreate是否允許創(chuàng)建條目 默認顯示多少條 是否多選  -->
		<projectSelect :defaultValue="selectedValue" :loading="isLoading" :multiple="isMultiple"
			:isConcatShowText="isConcatShowText" :placeholder="placeholder" :allowCreate="allowCreation"
			:remoteMethod="remoteFetch" :optionsList="options" label="projectCode" labelTwo="name" labelThree=""
			labelFour="" :valueString="valueString" :currentPage="currentPages" :pageSize="pageSize" :total="totalItems"
			@input="handleInput" @visible-change="handleVisibleChange" @change="handleChange" @clear="handleClear"
			@size-change="handleSizeChange" @current-change="handleCurrentChange" />
	</div>
</template>

<script>
	import projectSelect from './project.vue'; 
	//管理員查看往來單位
	import {
		listInfo
	} from "@/api/project/index.js"; //客戶
	export default {
		name: 'ParentComponent',
		components: {
			projectSelect
		},
		props: {
			index: {
				type: Number,
				default: 0
			},
			placeholder: {
				type: String,
				default: '請選擇'
			},
			valueString: {
				type: String,
				default: 'id'
			},
			selectedVal: {
				default: null
			}
		},
		watch: {
			selectedVal: {
				handler(val, oldVal) {
					this.selectedValue = val
				},
				immediate: true,//為要監(jiān)視的prop添加immediate屬性并設置為true,可以使得watch函數(shù)在組件創(chuàng)建時立即執(zhí)行一次
				deep: true
			}
		},
		data() {
			return {
				querySearch:null,
				isConcatShowText: true, //拼接后 被選擇后輸入框是否顯示拼接的字符串
				selectedValue: [], // 如果是多選,則為數(shù)組;否則為單個值
				isLoading: false,
				isMultiple: false, // 是否允許多選
				allowCreation: false, // 是否允許用戶創(chuàng)建新選項
				options: [], // 選項列表,應從服務器或本地獲取
				currentPages: 1, // 當前頁碼
				pageSize: 6, // 每頁顯示的數(shù)量
				totalItems: 0, // 總項目數(shù),用于分頁
			};
		},
		mounted() {
			this.remoteFetch()
		},
		methods: {
			remoteFetch(query) {
				if(query){
					this.querySearch=query
				}
				let that = this
				// 遠程獲取數(shù)據(jù)的函數(shù),根據(jù) query 參數(shù)進行搜索
				this.isLoading = true;
				// 假設 fetchData 是一個從服務器獲取數(shù)據(jù)的函數(shù)
				listInfo({
					isStop:0,//0否 1是 是否停用
					search: this.querySearch,
					pageSize: that.pageSize,
					pageNum: that.currentPages
				}).then(response => {
					//每次進入后  數(shù)據(jù)都是重新填充
					if (response.rows.length < 1) {
						this.selectedValue = []; // 清空已選值
					}
					that.options = response.rows;
					that.totalItems = response.total;
					this.isLoading = false;
				});
			},
			handleInput(value) {
				// 處理輸入事件,更新 selectedValue
				this.selectedValue = value;
				this.$emit('handleInput', value);
			},
			handleVisibleChange(visible) {
				// 處理下拉菜單的可見性變化
				this.currentPages = 1;
				this.remoteFetch(); // 可能需要重新獲取當前頁的數(shù)據(jù)
			},
			handleChange(value) {
				this.querySearch=null
				// 處理選項變化事件
				this.$emit('handlePageChange', value);
			},
			handleClear() {
				this.querySearch=null
				// 處理清除事件
				this.selectedValue = []; // 清空已選值
				this.$emit('clear', this.index);
				// this.$parent.productClear(this.index)
			},
			handleSizeChange(size) {
				// 處理每頁顯示數(shù)量變化事件
				this.pageSize = size;
				this.remoteFetch(this.querySearch); // 可能需要重新獲取當前頁的數(shù)據(jù)
			},
			handleCurrentChange(page) {
				// 處理當前頁碼變化事件
				this.currentPages = page;
				this.remoteFetch(this.querySearch); // 獲取當前頁的數(shù)據(jù)
			}
		},
		// 其他邏輯和生命周期鉤子...
	};
</script>

<style scoped>
	/* 父組件的樣式 */
</style>

最后在頁面引用(因為我很多頁面用到了,所以用了projectSelect 組件

<el-form>
   <el-form-item label="項目" prop="projectName">
			<project-select class="width100bfb" valueString="id" :selectedVal="form.projectName"   @clear='projectClear()' @handlePageChange="projectChange($event)" placeholder="請選擇項目" />
	</el-form-item>
</el-form>

<script>
import projectSelect from '@/views/components/elSelect/projectParent'
export default {
components: {
			projectSelect
		},
methods: {
/**項目列表change*/
			projectChange(val) {
				if (val) {
				//根據(jù)自己情況去調(diào)用接口
					//getProjectInfo(val).then(res => {
					//	this.form.projectName = res.data.name
						
					//})
				}
			},
		/*清除項目**/
			projectClear() {
			//根據(jù)自己情況去設置
				//this.form.projectName = null
			},
 }
}
</script>

到此這篇關于vue+el-select 多數(shù)據(jù)分頁搜索組件的實現(xiàn)的文章就介紹到這了,更多相關el-select 分頁搜索內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家! 

相關文章

  • vue3父子組件通信、兄弟組件實時通信方式

    vue3父子組件通信、兄弟組件實時通信方式

    這篇文章主要介紹了vue3父子組件通信、兄弟組件實時通信方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • 關于Vue的?Vuex的4個輔助函數(shù)

    關于Vue的?Vuex的4個輔助函數(shù)

    這篇文章主要介紹了關于Vue的?Vuex的4個輔助函數(shù),輔助函數(shù)的好處就是幫助我們簡化了獲取store中state、getter、mutation和action,下面我們一起來看看文章具體的舉例說明吧,需要的小伙伴也可以參考一下
    2021-12-12
  • vue 項目中使用websocket的正確姿勢

    vue 項目中使用websocket的正確姿勢

    這篇文章主要介紹了vue 項目中使用websocket的實例代碼,通過實例代碼給大家介紹了在utils下新建websocket.js文件的方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-01-01
  • 基于Vue+Element?Plus實現(xiàn)組件遞歸調(diào)用的詳細步驟

    基于Vue+Element?Plus實現(xiàn)組件遞歸調(diào)用的詳細步驟

    在前端開發(fā)中,遞歸是一種非常強大的編程技術,它允許函數(shù)或組件調(diào)用自身來解決問題,在Vue.js生態(tài)中,結合Element?Plus?UI庫,我們可以利用組件遞歸調(diào)用來構建復雜的樹形結構,本文將深入探討Vue3與?Element?Plus中組件遞歸調(diào)用的實現(xiàn)原理、詳細步驟、最佳實踐
    2025-07-07
  • Vue項目中如何安裝element組件

    Vue項目中如何安裝element組件

    這篇文章主要介紹了Vue項目中如何安裝element組件問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • VUE前端如何處理后端接口返回的圖片詳解

    VUE前端如何處理后端接口返回的圖片詳解

    在現(xiàn)代Web開發(fā)中,前端應用經(jīng)常需要從后端接口獲取圖片數(shù)據(jù),下面這篇文章主要介紹了VUE前端如何處理后端接口返回的圖片的相關資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下
    2024-09-09
  • 前端處理axios請求下載后端返回的文件流代碼實例

    前端處理axios請求下載后端返回的文件流代碼實例

    使用axios可以很方便地獲取后端返回的文件流數(shù)據(jù),并在前端直接在瀏覽器下載,這篇文章主要給大家介紹了關于前端處理axios請求下載后端返回的文件流的相關資料,需要的朋友可以參考下
    2024-07-07
  • vue-cli項目根據(jù)線上環(huán)境分別打出測試包和生產(chǎn)包

    vue-cli項目根據(jù)線上環(huán)境分別打出測試包和生產(chǎn)包

    這篇文章主要介紹了vue-cli項目根據(jù)線上環(huán)境打出測試包和生產(chǎn)包的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05
  • Vue中的單向數(shù)據(jù)流原則詳解

    Vue中的單向數(shù)據(jù)流原則詳解

    這篇文章主要介紹了Vue中的單向數(shù)據(jù)流原則,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • vue+Echart實現(xiàn)立體柱狀圖

    vue+Echart實現(xiàn)立體柱狀圖

    這篇文章主要為大家詳細介紹了vue+Echart實現(xiàn)立體柱狀圖,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-04-04

最新評論

泾川县| 偃师市| 应城市| 时尚| 隆林| 思茅市| 永清县| 尉氏县| 德钦县| 南木林县| 喀什市| 安远县| 阿瓦提县| 荆门市| 梁河县| 庆安县| 兴仁县| 吴旗县| 大兴区| 北票市| 寿宁县| 清丰县| 阳信县| 通渭县| 财经| 翼城县| 桃园市| 商都县| 和田市| 河北省| 普兰店市| 遵化市| 祁连县| 博白县| 兴宁市| 民和| 甘孜| 苍梧县| 江华| 即墨市| 定日县|