Procházet zdrojové kódy

📃添加 hide 字段,隐藏选项

cc12458 před 1 rokem
rodič
revize
3cb753e75a

+ 4 - 2
miniprogram/module/chats/components/message-select/message-select.ts

@@ -36,8 +36,9 @@ Component({
   },
   methods: {
     handleTop(event: HandleEvent) {
-      const { mark: { item, index } } = event;
+      const { mark: { item } } = event;
       if (!item || !this.data.active) return;
+      const index = this.data.options.findIndex(option=>option.id === item.id);
       const multiple = this.data.payload.multiple;
       const checked = !item.checked;
       const options = this._handle(this.data.options, item, index, multiple);
@@ -45,8 +46,9 @@ Component({
       if (checked && !multiple) { this.onSubmit(); }
     },
     handleSub(event: HandleEvent) {
-      const { mark: { item, index } } = event;
+      const { mark: { item } } = event;
       if (!item || !this.data.active) return;
+      const index = this.data.subOptions.findIndex(option=>option.id === item.id);
       const multiple = this.data.subMultiple;
       const checked = !item.checked;
       const subOptions = this._handle(this.data.subOptions, item, index, multiple);

+ 8 - 4
miniprogram/module/chats/components/message-select/message-select.wxml

@@ -16,6 +16,10 @@
     if (options.length) return ':' + options.join(' ');
     return ''
   }
+
+  module.exports.options = function (options) {
+    return options.filter(function (option) { return !option.hide })
+  }
 </wxs>
 <!--module/chats/components/message-select/message-select.wxml-->
 <view class="chat-card left">
@@ -25,8 +29,8 @@
   <view class="chat-card__content">
     <t-cell t-class="cell-border-gradient" title="{{payload.title}}"></t-cell>
     <scroll-view class="options-wrapper" type="custom" scroll-y style="height: {{_.maxHeight(options, itemHeight)}}px;" mark:type="options" bind:tap="handleTop">
-      <grid-builder list="{{options}}" cross-axis-count="3" cross-axis-gap="8" main-axis-gap="8" padding="{{[4,4,4,4]}}">
-        <view slot:item slot:index class="card {{_.getClassName(item)}}" style="height: {{itemHeight}}px;" mark:item="{{item}}" mark:index="{{index}}">
+      <grid-builder list="{{_.options(options)}}" cross-axis-count="3" cross-axis-gap="8" main-axis-gap="8" padding="{{[4,4,4,4]}}">
+        <view slot:item slot:index class="card {{_.getClassName(item)}}" style="height: {{itemHeight}}px;" mark:item="{{item}}">
           <t-icon wx:if="{{item.checked}}" name="check" t-class="card__icon" ariaHidden="{{true}}" />
           <text overflow="ellipsis" max-lines="2">{{item.name}}{{_.subName(item)}}</text>
         </view>
@@ -63,8 +67,8 @@
   </view>
   <view class="form-picker__content">
     <scroll-view class="options-wrapper" type="custom" scroll-y style="height: {{_.maxHeight(subOptions, itemHeight)}}px;" mark:type="sub" bind:tap="handleSub">
-      <grid-builder list="{{subOptions}}" cross-axis-count="3" cross-axis-gap="8" main-axis-gap="8" padding="{{[4,4,4,4]}}">
-        <view slot:item slot:index class="card {{_.getClassName(item)}}" style="height: {{itemHeight}}px;" mark:item="{{item}}" mark:index="{{index}}">
+      <grid-builder list="{{_.options(subOptions)}}" cross-axis-count="3" cross-axis-gap="8" main-axis-gap="8" padding="{{[4,4,4,4]}}">
+        <view slot:item slot:index class="card {{_.getClassName(item)}}" style="height: {{itemHeight}}px;" mark:item="{{item}}">
           <t-icon wx:if="{{item.checked}}" name="check" t-class="card__icon" ariaHidden="{{true}}" />
           <text overflow="ellipsis" max-lines="2">{{item.name}}{{_.subName(item)}}</text>
         </view>

+ 8 - 1
miniprogram/module/chats/components/questionnaire/questionnaire.ts

@@ -108,7 +108,14 @@ Component({
                 id: `${question.classify}.${question.id}.${index}`, type: 'select',
                 payload: {
                   title: question.title,
-                  options: question.options,
+                  options: question.options.map((item: AnyObject) => {
+                    if (Array.isArray(item.options)) {
+                      item.options = item.options.map(item => {
+                        return { ...item, hide: item.css === 'hide' }
+                      })
+                    }
+                    return { ...item, hide: item.css === 'hide' }
+                  }),
                   multiple: question.css === 'checkbox',
                   required: question.required
                 }