فهرست منبع

1、修改dk-number-input组件
2、dk-form增加tip

zhoux 2 سال پیش
والد
کامیت
86866e6b6f

+ 2 - 1
components/dkbase/dk-cell/dk-cell.wxml

@@ -1,5 +1,6 @@
 <view id="totalView" class="total_class" style="--height--:{{errorMessage?('calc(' + height +' + 30rpx)' ):height}};--left--:{{left}};--center--:{{center?center:(title?'left':'center')}}">
-  <view class="title_class" wx:if="{{title}}" style="--titleColor--:{{titleColor==''?contentColor:titleColor}};--fontSize--:{{fontSize + 'px'}};--fontWeight--:{{fontWeight}};--titleWidth--:{{titleWid?titleWid:''}}">{{title}}</view>
+  <view class="title_class" wx:if="{{title}}" style="--titleColor--:{{titleColor==''?contentColor:titleColor}};--fontSize--:{{fontSize + 'px'}};--fontWeight--:{{fontWeight}};--titleWidth--:{{titleWid?titleWid:''}}">{{title}} </view>
+ 
   <!--placeholder-->
   <view wx:if="{{placeholder && !displayValue}}" class="{{contentRight?'content_class':'content_left_class'}}" style="--contentColor--:{{placeholderColor}};--fontSize--:{{(contentFontSize==0?fontSize:contentFontSize) + 'px'}};--titleWidth--:{{titleWid?titleWid :titleWidth + 'px'}};--fontWeight--:{{contentFontWeight==''?fontWeight:contentFontWeight}};--spaceWidth--:{{title?spaceWidth:''}}">{{placeholder}}</view>
   <!--错误提示信息-->

+ 15 - 0
components/dkbase/dk-form/dk-form.js

@@ -127,6 +127,21 @@ Component({
    */
   methods: {
     /**
+     * @desc   : 显示tip
+     * @author : 周兴
+     * @date   : 2024/4/25 11:46
+     */
+    showTip(e){
+      let item = e.currentTarget.dataset.item
+      if(item.tip){
+        wx.showToast({
+          title: item.tip,
+          icon: 'none',
+          duration: 2000
+        })
+      }
+    },
+    /**
      * @desc   : 打开下拉
      * @author : 周兴
      * @date   : 2024/1/26 11:46

+ 3 - 1
components/dkbase/dk-form/dk-form.wxml

@@ -5,6 +5,7 @@
     <view wx:for="{{contentObj[card]}}" wx:for-item="item" data-item="{{item}}" wx:key="index">
       <!--文本框-->
       <van-field wx:if="{{item.type=='str' && !item.hide}}"required="{{item.required?true:false }}"  data-key="{{item.code}}" data-item="{{item}}" data-index="{{index}}" data-card="{{card}}" value="{{ form[item.code]}}" input-align="left" label="{{item.title?item.title:$t[item.code]}}" placeholder="{{wxmlUtil.setPlaceholder($t,item.title?item.title:item.code)}}" autosize border="{{ false }}" clearable readonly="{{!!item.readonly}}" input-class="dk-cell-value-class" maxlength="{{item.maxlength?item.maxlength:50}}" right-icon="{{item.rightIcon}}" bind:change="changeField" bind:clear="clearField" errorMessage="{{item.errMsg}}">
+        <van-icon slot="label-icon" name="question-o" data-item="{{item}}" catchtap="showTip" />
       </van-field>
       <!--单选下拉-->
       <van-field wx:if="{{item.type=='drop' && !item.hide}}"required="{{item.required?true:false }}"  data-name="{{item.name}}" data-key="{{item.code}}" data-item="{{item}}" data-index="{{index}}" data-card="{{card}}" value="{{ form[item.name]}}" input-align="left" label="{{item.title?item.title:$t[item.code]}}" placeholder="{{wxmlUtil.setPlaceholder($t,item.title?item.title:item.code)}}" is-link catchtap="open" autosize border="{{ false }}" readonly="{{true}}" input-class="dk-cell-value-class" data-type='{{item.dropType}}' errorMessage="{{item.errMsg}}">
@@ -71,10 +72,11 @@
       <!--联系电话-->
       <dk-number-phone-input wx:if="{{item.type=='phone' && !item.hide}}" data-key="{{item.code}}" data-item="{{item}}" data-index="{{index}}" data-card="{{card}}" required="{{item.required?true:false }}" clearable rightIcon="phone" model:value="{{ form[item.code]}}" bind:changeField="changePhone" bind:clear="clearField" bind:changeFieldblur="changePhoneblur" errorMessage="{{item.errMsg}}" id="{{item.code}}" label="{{item.title?item.title:$t[item.code]}}" placeholder="{{wxmlUtil.setPlaceholder($t,item.code)}}"></dk-number-phone-input>
       <!--数字类-->
-      <dk-number-input wx:if="{{item.type=='number' && !item.hide}}" sign="{{(item.sign || item.sign == '')?item.sign:'¥'}}" digits="{{(item.digits || item.digits == 0)?item.digits:2}}" fontSize="14" left="30rpx" data-key="{{item.code}}" data-item="{{item}}" data-index="{{index}}" data-card="{{card}}" center="left" placeholder="{{wxmlUtil.setPlaceholder($t,item.title?item.title:item.code)}}" errorMessage="{{item.errMsg}}" titleValue="{{item.title?item.title:$t[item.code]}}" negative="{{item.negative}}" inputColor="#CAA977" titleFontWeight="{{item.required?'bold':'normal'}}" titleColor="{{item.required?'#E4002B':'#95A8CB'}}" readonly="{{!!item.readonly}}"  inputValue="{{form[item.code]}}" bind:triggerBindValue="changeNumberField"></dk-number-input>
+      <dk-number-input wx:if="{{item.type=='number' && !item.hide}}" sign="{{(item.sign || item.sign == '')?item.sign:'¥'}}" digits="{{(item.digits || item.digits == 0)?item.digits:2}}" fontSize="14" left="30rpx" data-key="{{item.code}}" data-item="{{item}}" data-index="{{index}}" data-card="{{card}}" center="left" placeholder="{{wxmlUtil.setPlaceholder($t,item.title?item.title:item.code)}}" errorMessage="{{item.errMsg}}" titleValue="{{item.title?item.title:$t[item.code]}}" negative="{{item.negative}}" inputColor="#CAA977" titleFontWeight="normal" titleColor="#95A8CB" readonly="{{!!item.readonly}}"  required="{{item.required}}" tip="{{item.tip}}" inputValue="{{form[item.code]}}" bind:triggerBindValue="changeNumberField"></dk-number-input>
 
       <!--备注-->
       <van-field wx:if="{{item.type=='textarea' && !item.hide}}" rows="{{item.rows}}" show-word-limit="{{item.showWordLimit}}" type="textarea"required="{{item.required?true:false }}"  data-key="{{item.code}}" data-item="{{item}}" data-index="{{index}}" data-card="{{card}}" value="{{ form[item.code]}}" input-align="left" label="{{item.title?item.title:$t[item.code]}}" placeholder="{{wxmlUtil.setPlaceholder($t,item.title?item.title:item.code)}}" autosize border="{{ false }}" readonly="{{!!item.readonly}}" input-class="dk-cell-value-class {{item.rows ?  'input-rows-class' : ''}}" maxlength="{{item.maxlength?item.maxlength:500}}" right-icon="{{item.rightIcon}}" bind:change="changeField" errorMessage="{{item.errMsg}}">
+        <van-icon wx:if="{{item.tip}}" slot="label-icon" name="question-o" data-item="{{item}}" catchtap="showTip" />
       </van-field>
       <!--附件-->
       <view style="display:flex;width:100%;margin: 1vw; padding-top: 20rpx;" wx:if="{{item.type=='uploader'}}">

+ 1 - 1
components/dkbase/dk-list-report/dk-list-report.js

@@ -177,7 +177,7 @@ Component({
         wx.showToast({
           title: item.tip,
           icon: 'none',
-          duration: 4000
+          duration: 2000
         })
       }
     },

+ 21 - 0
components/dkbase/dk-number-input/dk-number-input.js

@@ -160,6 +160,12 @@ Component({
      */
     errorMessage: {
       type: String,
+    },
+    /**
+     * 提示信息
+     */
+    tip:{
+      type:String,
     }
   },
 
@@ -174,6 +180,21 @@ Component({
    * 组件的方法列表
    */
   methods: {
+     /**
+     * @desc   : 显示tip
+     * @author : 周兴
+     * @date   : 2024/4/25 11:46
+     */
+    showTip(){
+      let tip = this.data.tip
+      if(tip){
+        wx.showToast({
+          title: tip,
+          icon: 'none',
+          duration: 2000
+        })
+      }
+    },
     /**
     * @desc : 光标进入选中
     * @author : 周兴

+ 8 - 4
components/dkbase/dk-number-input/dk-number-input.wxml

@@ -1,9 +1,13 @@
 <view>
-  <view wx:if="{{!focus || disabled}}" style="padding-top: 20rpx; padding-bottom: 20rpx;">
-    <view wx:if="{{required}}" style="position: absolute;left: {{requiredLeft}};color: #DB3333;">*
+  <view wx:if="{{!focus || disabled}}">
+    <!-- <view wx:if="{{required}}" style="position: absolute;left: {{requiredLeft}};color: #DB3333;">*
     </view>
     <dk-cell height="48rpx" left="{{left}}" signSize="{{signSize}}" fontWeight="{{titleFontWeight}}" fontSize="{{fontSize}}" tail="{{percentSignFlag ? '%' : ''}}" percentSignFlag="{{percentSignFlag}}" contentColor="{{inputColor}}" amount="{{sign?true:false }}" contentFontWeight="{{fontWeight}}" contentRight="{{contentRight}}" center="{{center=='right'?'flex-end':center}}" title="{{titleValue}}" content="{{(inputValue || inputValue == 0)?inputValue:null}}" titleWid="{{titleWidth}}" catchtap="handleInput" titleColor="{{titleColor}}" placeholder="{{placeholder}}" errorMessage="{{errorMessage}}">
-    </dk-cell>
+    </dk-cell> -->
+    <van-field label-class="nomal-label" required="{{required?true:false }}" input-align="{{left}}" label="{{titleValue}}" placeholder="{{(inputValue || inputValue == 0)?'':placeholder}}" data-type='name' readonly="{{true}}" autosize border="{{ false }}" errorMessage="{{errorMessage}}" catchtap="handleInput">
+      <van-icon wx:if="{{tip}}" slot="label-icon" name="question-o" catchtap="showTip" />
+      <dk-cell slot="inputbefor" contentRight="{{contentRight}}" left="0" height="30rpx" contentFontSize="14" contentColor="{{inputColor}}" contentFontWeight="{{fontWeight}}" content="{{(inputValue || inputValue == 0)?inputValue:null}}"></dk-cell>
+    </van-field>
   </view>
 
   <!-- <view wx:else class="input-class" style="--center--:{{center}}">
@@ -15,7 +19,7 @@
   </view> -->
   <!--文本框-->
   <view wx:else style="padding-top: 2rpx; padding-bottom: 2rpx;">
-    <van-field required ="{{required}}" label-class="input-title-class" style="--color--:{{titleColor}};--fontSize--:{{fontSize + 'px'}};--width--:{{titleWidth}};--fontWeight--:{{titleFontWeight}}" value="{{inputValue?inputValue:undefined}}" input-align="left" label="{{titleValue}}" placeholder="{{placeholder}}" autosize auto-focus clearable border="{{ false }}" input-class="dk-cell-value-class" type="text" inputMode="decimal" bind:focus="bindFocus" bind:change="bindInput" bind:blur="bindBlur">
+    <van-field required="{{required}}" label-class="input-title-class" style="--color--:{{titleColor}};--fontSize--:{{fontSize + 'px'}};--width--:{{titleWidth}};--fontWeight--:{{titleFontWeight}}" value="{{inputValue?inputValue:undefined}}" input-align="left" label="{{titleValue}}" placeholder="{{placeholder}}" autosize auto-focus clearable border="{{ false }}" input-class="dk-cell-value-class" type="text" inputMode="decimal" bind:focus="bindFocus" bind:change="bindInput" bind:blur="bindBlur">
     </van-field>
   </view>
 </view>

+ 2 - 1
dist/field/index.wxml

@@ -4,8 +4,9 @@
 <van-cell size="{{ size }}" icon="{{ leftIcon }}" center="{{ center }}" border="{{ border }}" is-link="{{ isLink }}" required="{{ required }}" clickable="{{ clickable }}" title-width="{{ titleWidth }}" title-style="margin-right: 12px;" custom-style="{{ customStyle }}" arrow-direction="{{ arrowDirection }}" custom-class="van-field" title-class="label-class">
   <slot name="left-icon" slot="icon" />
   <view wx:if="{{ label }}" class="label-class {{ utils.bem('field__label', { disabled }) }}" catchtap="toCopy" slot="title">
-    {{ label }}
+    {{ label }}  <slot name="label-icon" slot="icon" />
   </view>
+
   <slot wx:else name="label" slot="title" />
   <view class="{{ utils.bem('field__body', [type]) }}">
     <textarea wx:if="{{ type === 'textarea' }}" class="input-class {{ utils.bem('field__input', [inputAlign, type, { disabled, error }]) }}" fixed="{{ fixed }}" focus="{{ focus }}" cursor="{{ cursor }}" value="{{ innerValue }}" auto-focus="{{ autoFocus }}" disabled="{{ disabled || readonly }}" maxlength="{{ maxlength }}" placeholder="{{ placeholder }}" placeholder-style="{{ placeholderStyle }}" placeholder-class="{{ utils.bem('field__placeholder', { error, disabled }) }}" auto-height="{{ !!autosize }}" style="{{ computed.inputStyle(autosize) }}" cursor-spacing="{{ cursorSpacing }}" adjust-position="{{ adjustPosition }}" show-confirm-bar="{{ showConfirmBar }}" hold-keyboard="{{ holdKeyboard }}" selection-end="{{ selectionEnd }}" selection-start="{{ selectionStart }}" disable-default-padding="{{ disableDefaultPadding }}" bindinput="onInput" bindblur="onBlur" bindfocus="onFocus" bindconfirm="onConfirm" bindlinechange="onLineChange" bindkeyboardheightchange="onKeyboardHeightChange">