Kaynağa Gözat

feat: combox修改

ljc 1 hafta önce
ebeveyn
işleme
8369a30113

+ 1 - 1
components/cwg-combox.vue

@@ -7,7 +7,7 @@
         </template>
         <template v-if="!disabled">
             <!-- 可搜索模式 -->
-            <uni-combox v-if="filterable" v-model="innerText" :candidates="textList" :clearable="clearable"
+            <uni-combox v-if="filterable" v-model="innerText" :candidates="textList" :clearable="clearable" :options="options"
                 :placeholder="placeholder" :disabled="disabled" @input="handleComboxChange" />
 
             <!-- 普通下拉模式 -->

+ 1 - 1
pages/login/index.vue

@@ -384,7 +384,7 @@ const countryOptions = computed(() => {
   return mock_options.value.map(item => ({
     text: item.enName,
     value: item.code,
-    disable: item.isOpenAccount == 0 || item.isOpenAccount === null ? true : false,
+    disable: (item.isOpenAccount == 0 || item.isOpenAccount === null) ? true : false,
   }))
 })
 

+ 28 - 6
uni_modules/uni-combox/components/uni-combox/uni-combox.vue

@@ -21,7 +21,7 @@
 				</view>
 				<view class="uni-combox__selector-item" v-for="(item, index) in filterCandidates" :key="index"
 					@click="onSelectorClick(index)">
-					<text>{{ item }}</text>
+					<text :class="{ 'uni-combox__selector__disabled': options[index].disable }">{{ item }}</text>
 				</view>
 			</scroll-view>
 		</view>
@@ -36,7 +36,8 @@
  * @property {String} label 左侧文字
  * @property {String} labelWidth 左侧内容宽度
  * @property {String} placeholder 输入框占位符
- * @property {Array} candidates 候选项列表
+ * @property {Array} candidates 候选项列表(只有text,展示用)
+ * @property {Array} options 候选项列表全部内容,
  * @property {String} emptyTips 筛选结果为空时显示的文字
  * @property {String} value 组合框的值
  */
@@ -52,6 +53,10 @@ export default {
 			type: Boolean,
 			default: true
 		},
+    disabled: {
+			type: Boolean,
+			default: false
+		},
 		label: {
 			type: String,
 			default: ''
@@ -70,6 +75,12 @@ export default {
 				return []
 			}
 		},
+    options: {
+			type: Array,
+			default() {
+				return []
+			}
+		},
 		emptyTips: {
 			type: String,
 			default: '无匹配项'
@@ -140,10 +151,16 @@ export default {
 			}, 153)
 		},
 		onSelectorClick(index) {
-			this.inputVal = this.filterCandidates[index]
-			this.showSelector = false
-			this.$emit('input', this.inputVal)
-			this.$emit('update:modelValue', this.inputVal)
+      // 添加disable判断,如果没有传入原来的值
+      const item = this.options[index]||{}
+
+      // console.log(item,'comboxitem')
+      if (!item.disable){
+        this.inputVal = this.filterCandidates[index]
+        this.showSelector = false
+        this.$emit('input', this.inputVal)
+        this.$emit('update:modelValue', this.inputVal)
+      }
 		},
 		onInput() {
 			setTimeout(() => {
@@ -227,6 +244,11 @@ export default {
 	/* #endif */
 }
 
+.uni-combox__selector__disabled{
+  opacity: 0.4;
+  cursor: default;
+}
+
 .uni-combox__selector-empty,
 .uni-combox__selector-item {
 	/* #ifndef APP-NVUE */