From c4aef9b623635d49cf87308bfb874f4141c9d448 Mon Sep 17 00:00:00 2001 From: wk Date: 星期四, 25 七月 2024 10:00:32 +0800 Subject: [PATCH] feat:门卫样式 --- uni_modules/niceui-data-select-input/components/niceui-data-select-input/niceui-data-select-input.vue | 143 +++++++++++++++++++++++++++++------------------ 1 files changed, 87 insertions(+), 56 deletions(-) diff --git a/uni_modules/niceui-data-select-input/components/niceui-data-select-input/niceui-data-select-input.vue b/uni_modules/niceui-data-select-input/components/niceui-data-select-input/niceui-data-select-input.vue index 701fec8..393a0b1 100644 --- a/uni_modules/niceui-data-select-input/components/niceui-data-select-input/niceui-data-select-input.vue +++ b/uni_modules/niceui-data-select-input/components/niceui-data-select-input/niceui-data-select-input.vue @@ -1,29 +1,58 @@ <template> <view class="uni-stat__select"> - <span v-if="label" class="uni-label-text hide-on-phone">{{label + '锛�'}}</span> - <view class="uni-stat-box" :class="{'uni-stat__actived': current}"> - <view class="uni-select" :class="{'uni-select--disabled':disabled}"> + <span v-if="label" + class="uni-label-text hide-on-phone">{{label + '锛�'}}</span> + <view class="uni-stat-box" + :class="{'uni-stat__actived': current}"> + <view class="uni-select" + :class="{'uni-select--disabled':disabled}"> <view class="uni-select__input-box"> - <input class="uni-select__input-text" v-if="!multiple" v-model="current" @click="toggleSelector" @input="inputEnter" :placeholder="typePlaceholder"></input> + <input class="uni-select__input-text" + v-if="!multiple" + v-model="current" + @click="toggleSelector" + @input="inputEnter" + :placeholder="typePlaceholder" + readonly + :disabled="true"></input> <!-- <view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view> --> - <input class="uni-select__input-text" v-if="multiple" v-model="current" @click="toggleSelector" @input="inputEnter" :placeholder="typePlaceholder"></input> - <view v-if="current && clear && !disabled" @click.stop="clearVal" > - <uni-icons type="clear" color="#c0c4cc" size="24"/> + <input class="uni-select__input-text" + v-if="multiple" + v-model="current" + @click="toggleSelector" + @input="inputEnter" + :placeholder="typePlaceholder"></input> + <view v-if="current && clear && !disabled" + @click.stop="clearVal"> + <uni-icons type="clear" + color="#c0c4cc" + size="24" /> </view> <view v-else> - <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" /> + <uni-icons :type="showSelector? 'top' : 'bottom'" + size="14" + color="#999" /> </view> </view> - <view class="uni-select--mask" v-if="showSelector" @click="toggleSelector" /> - <view class="uni-select__selector" v-if="showSelector"> + <view class="uni-select--mask" + v-if="showSelector" + @click="toggleSelector" /> + <view class="uni-select__selector" + v-if="showSelector"> <view class="uni-popper__arrow"></view> - <scroll-view scroll-y="true" class="uni-select__selector-scroll"> - <view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0"> + <scroll-view scroll-y="true" + class="uni-select__selector-scroll"> + <view class="uni-select__selector-empty" + v-if="mixinDatacomResData.length === 0"> <text>{{emptyTips}}</text> </view> - <view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index" + <view v-else + class="uni-select__selector-item" + v-for="(item,index) in mixinDatacomResData" + :key="index" @click="change(item)"> - <text :class="{'uni-select__selector__disabled': item.disable,'active':currentArr.includes(item.text)}">{{formatItemName(item)}}</text> + <text + :class="{'uni-select__selector__disabled': item.disable,'active':currentArr.includes(item.text)}">{{formatItemName(item)}}</text> </view> </scroll-view> </view> @@ -107,8 +136,8 @@ apps: [], channels: [], cacheKey: "uni-data-select-lastSelectedValue", - tempData:[], - currentArr:[], + tempData: [], + currentArr: [], }; }, created() { @@ -132,7 +161,7 @@ common + placeholder : common }, - valueCom(){ + valueCom() { // #ifdef VUE3 return this.modelValue; // #endif @@ -163,27 +192,25 @@ } }, methods: { - inputEnter(v){ + inputEnter(v) { console.log(v); let val = v.detail.value - if(val){ - const arr = this.mixinDatacomResData.filter(d=>d.text.indexOf(val)>-1) - if(arr.length>0){ + if (val) { + const arr = this.mixinDatacomResData.filter(d => d.text.indexOf(val) > -1) + if (arr.length > 0) { this.mixinDatacomResData = JSON.parse(JSON.stringify(arr)) - }else{ + } else { this.mixinDatacomResData = [] - this.mixinDatacomResData.push( - { value: val, text: val} - ) + this.mixinDatacomResData.push({ value: val, text: val }) this.tempData = this.mixinDatacomResData this.current = val } - }else{ + } else { this.initDefVal() } - + }, - debounce(fn, time = 100){ + debounce(fn, time = 100) { let timer = null return function(...args) { if (timer) clearTimeout(timer) @@ -193,11 +220,11 @@ } }, // 鎵ц鏁版嵁搴撴煡璇� - query(){ + query() { this.mixinDatacomEasyGet(); }, // 鐩戝惉鏌ヨ鏉′欢鍙樻洿浜嬩欢 - onMixinDatacomPropsChange(){ + onMixinDatacomPropsChange() { if (this.collection) { this.debounceGet(); } @@ -220,22 +247,22 @@ } defValue = defItem } - if (defValue || defValue === 0) { - this.emit(defValue) - } + if (defValue || defValue === 0) { + this.emit(defValue) + } } const def = this.mixinDatacomResData.find(item => item.value === defValue) this.current = def ? this.formatItemName(def) : '' - if(this.current==''){ - if(this.mixinDatacomResData.length==1){ + if (this.current == '') { + if (this.mixinDatacomResData.length == 1) { this.current = this.formatItemName(this.mixinDatacomResData[0]) } } - if(this.multiple){ - if(this.currentArr.length>0){ + if (this.multiple) { + if (this.currentArr.length > 0) { this.current = this.currentArr.join(',') } - + } }, @@ -257,7 +284,7 @@ clearVal() { this.current = '' - if(this.multiple) this.currentArr=[] + if (this.multiple) this.currentArr = [] this.emit('') if (this.collection) { this.removeCache() @@ -265,17 +292,17 @@ }, change(item) { if (!item.disable) { - if(!this.multiple){ + if (!this.multiple) { this.showSelector = false this.current = this.formatItemName(item) this.emit(item.value) - }else{ - if(!this.currentArr.includes(item.text)){ + } else { + if (!this.currentArr.includes(item.text)) { this.currentArr.push(this.formatItemName(item)) - }else{ - this.currentArr.forEach((it,index)=>{ - if(it==this.formatItemName(item)){ - this.currentArr.splice(index,1) + } else { + this.currentArr.forEach((it, index) => { + if (it == this.formatItemName(item)) { + this.currentArr.splice(index, 1) } }) } @@ -314,7 +341,7 @@ let str = ""; str = this.format; for (let key in item) { - str = str.replace(new RegExp(`{${key}}`,"g"),item[key]); + str = str.replace(new RegExp(`{${key}}`, "g"), item[key]); } return str; } else { @@ -328,26 +355,26 @@ } }, // 鑾峰彇褰撳墠鍔犺浇鐨勬暟鎹� - getLoadData(){ + getLoadData() { return this.mixinDatacomResData; }, // 鑾峰彇褰撳墠缂撳瓨key - getCurrentCacheKey(){ + getCurrentCacheKey() { return this.collection; }, // 鑾峰彇缂撳瓨 - getCache(name=this.getCurrentCacheKey()){ + getCache(name = this.getCurrentCacheKey()) { let cacheData = uni.getStorageSync(this.cacheKey) || {}; return cacheData[name]; }, // 璁剧疆缂撳瓨 - setCache(value, name=this.getCurrentCacheKey()){ + setCache(value, name = this.getCurrentCacheKey()) { let cacheData = uni.getStorageSync(this.cacheKey) || {}; cacheData[name] = value; uni.setStorageSync(this.cacheKey, cacheData); }, // 鍒犻櫎缂撳瓨 - removeCache(name=this.getCurrentCacheKey()){ + removeCache(name = this.getCurrentCacheKey()) { let cacheData = uni.getStorageSync(this.cacheKey) || {}; delete cacheData[name]; uni.setStorageSync(this.cacheKey, cacheData); @@ -446,9 +473,11 @@ flex-direction: row; align-items: center; } + ::v-deep uni-input { font-size: 14px; } + .uni-select__input { flex: 1; font-size: 14px; @@ -490,11 +519,13 @@ max-height: 600px; } } + /* #endif */ - .active{ - color:#2979ff; + .active { + color: #2979ff; } + .uni-select__selector-empty, .uni-select__selector-item { /* #ifndef APP-NVUE */ @@ -554,7 +585,7 @@ } .uni-select__input-text { - // width: 280px; + // width: 280px; width: 100%; color: $uni-main-color; white-space: nowrap; @@ -576,4 +607,4 @@ left: 0; z-index: 2; } -</style> +</style> \ No newline at end of file -- Gitblit v1.9.1