From 2f2be05b8caedd31bfd9d68110ea8c1267971f03 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Fri, 07 Mar 2025 12:22:37 +0800 Subject: [PATCH] 知识库,优化文案 --- forms/select/CSelect.vue | 58 ++++++++++++++++++++++++++-------------------------------- 1 files changed, 26 insertions(+), 32 deletions(-) diff --git a/forms/select/CSelect.vue b/forms/select/CSelect.vue index 570c3b0..5183bb9 100644 --- a/forms/select/CSelect.vue +++ b/forms/select/CSelect.vue @@ -6,7 +6,7 @@ <template> <view class="c-select" - :class="readOnly ? 'read-only':''" + :class="readOnly?'read-only':''" > <!-- 下拉选择模式 --> <view @@ -43,8 +43,8 @@ </view> <!-- 跳转页面模式 --> <view - v-else-if="selectByPage.length > 5" - @tap="evt => onGoToSelectorPage()" + v-else-if="selectByPage.length > 5 || selectByPage === 'on'" + @tap="evt => onGoSelectorPage()" > <AtInput :name="itemRes.name" @@ -53,7 +53,7 @@ :disabled="itemRes.disabled" :error="itemRes.error" :placeholder="placeholder" - :value="choose.name" + :value="choose.name || selected" > <view v-show="!readOnly" @@ -67,7 +67,6 @@ <script> import Taro from '@tarojs/taro'; import { AtInput } from 'taro-ui-vue'; -import { $pagePoster } from '@components/common/PagePoster'; import './cSelect.scss'; export default { @@ -82,15 +81,15 @@ options: Array, // 占位提示 placeholder: String, - // 开启选择菜单跳转选择页面模式,并指定功能页面 - selectByPage: String, - // 页面模式下,选择完成后的回调 - onSelectFromPage: Function, // 只读模式 readOnly: { type: Boolean, default: false, }, + // 开启选择菜单跳转选择页面模式,值为 'on' + selectByPage: String, + // 页面跳转on模式下,发起选择的回调 + onOpenSelectorPage: Function, }, data() { return { @@ -125,32 +124,27 @@ }, methods: { handleChange(evt) { - const item = this.options[evt.value]; - this.itemRes.onChange(item[this.optionKey]); - }, - onGoToSelectorPage() { - let url = this.selectByPage; - if (this.selectByPage.indexOf('?') > 0) { - url += '&mode=CSelect'; + if (typeof this.optionKey === 'undefined') { + this.itemRes.onChange(); } else { - url += '?mode=CSelect'; + const item = this.options[evt.value]; + this.itemRes.onChange(item[this.optionKey]); } - if (this._eventor) { - // 销毁上次事件收发器 - this._eventor.destroy(); - } - this._eventor = $pagePoster.createEventor(); - this._eventor.on('@linked', () => { - this._eventor.emit('lastValue', this.choose.value); - }); - this._eventor.on('selected', data => { - this.choose.name = data.name; - this.choose.value = data.value; - this.itemRes.onChange(data.value); - this.onSelectFromPage && this.onSelectFromPage(data.value); - }); - Taro.navigateTo({ url: url + '&eventorId=' + this._eventor.id }); }, + onGoSelectorPage() { + if (this.selectByPage === 'on') { + this.onOpenSelectorPage && this.onOpenSelectorPage(); + return; + } + // 页面跳转URL模式已废弃 + console.warn('CSelect:警告,url跳转已废弃,无法再使用!'); + }, + }, + mounted() { + if (this.selectByPage && this.selectByPage !== 'on') { + // 页面跳转URL模式已废弃 + console.warn('CSelect:警告,url跳转已废弃,无法再使用!'); + } }, }; </script> \ No newline at end of file -- Gitblit v1.9.1