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

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

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

project.Vue

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

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

最后在頁(yè)面引用(因?yàn)槲液芏囗?yè)面用到了,所以用了projectSelect 組件

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

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

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

相關(guān)文章

  • vue3父子組件通信、兄弟組件實(shí)時(shí)通信方式

    vue3父子組件通信、兄弟組件實(shí)時(shí)通信方式

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

    關(guān)于Vue的?Vuex的4個(gè)輔助函數(shù)

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

    vue 項(xiàng)目中使用websocket的正確姿勢(shì)

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

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

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

    Vue項(xiàng)目中如何安裝element組件

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

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

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

    前端處理axios請(qǐng)求下載后端返回的文件流代碼實(shí)例

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

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

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

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

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

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

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

最新評(píng)論

连云港市| 临桂县| 武山县| 册亨县| 娱乐| 沁源县| 景宁| 天柱县| 磴口县| 洛扎县| 湘阴县| 五常市| 新津县| 西吉县| 临猗县| 宜丰县| 荔浦县| 衡山县| 襄城县| 松滋市| 鹰潭市| 霍邱县| 金门县| 庐江县| 长岛县| 沭阳县| 崇文区| 泾阳县| 榆中县| 澄迈县| 汤阴县| 济宁市| 康马县| 镶黄旗| 沁阳市| 耿马| 日土县| 萍乡市| 玛沁县| 射洪县| 淄博市|