form.wxml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!--components/form/form.wxml-->
  2. <wxs module="format">
  3. // wxs中不能写ES6的语法: 例如箭头函数
  4. function isHide(hide,arr) {
  5. var rs = true
  6. arr.forEach(function(e){
  7. hide.forEach(function(h){
  8. if (e.id === h.id) {
  9. e.force = false
  10. h.value.forEach(function(v){
  11. if (e.inputValue === v) {
  12. rs = false
  13. }
  14. })
  15. }
  16. })
  17. })
  18. return rs
  19. }
  20. // 需要导出函数, 导出只能使用CommonJs规范
  21. module.exports = {
  22. // 对象中也不能使用对象的增强写法
  23. isHide: isHide
  24. }
  25. </wxs>
  26. <view>
  27. <view wx:for="{{formLayoutData.formInfo}}" wx:key="{{index}}">
  28. <t-cell required="{{item.force}}" wx:if="{{item.type == 'cell'}}" title="{{item.label}}" note="{{item.inputValue}}" url="{{item.url}}" hover>
  29. </t-cell>
  30. <!-- 输入 -->
  31. <t-input
  32. wx:if="{{item.type == 'text'}}"
  33. value="{{item.inputValue}}"
  34. data-value="{{item.id}}"
  35. data-index="{{index}}"
  36. layout="horizontal"
  37. status="error"
  38. data-item="{{item}}"
  39. tips="{{item.errorMsg}}"
  40. placeholder="{{item.placeholder}}"
  41. align="right"
  42. bind:blur="onBlur"
  43. bind:clear="onClear"
  44. clearable>
  45. <view slot="label">
  46. {{item.label}} <text wx:if="{{item.force}}" style="color:#e34d59">*</text>
  47. </view>
  48. </t-input>
  49. <!-- 选择 -->
  50. <t-cell wx:if="{{item.type == 'picker'}}" required="{{item.force}}" note="{{item.inputValue == 1?'是':item.inputValue == 0?'请选择':item.inputValue}}" class="block" title="{{item.label}}" data-index="{{index}}" data-item="{{item}}" arrow hover bind:click="onPicker" >
  51. <text slot="description" class="t-class-description">{{item.errorMsg?item.errorMsg:''}}</text>
  52. </t-cell>
  53. <!-- 上传 -->
  54. <view wx:if="{{item.type == 'upload'}}" style="padding:10px">
  55. <view class="uploadPanel">
  56. 附件上传
  57. </view>
  58. <slot style="flex:1" name="attinfos"></slot>
  59. <upload id="upload"></upload>
  60. </view>
  61. <!-- 时间选择 -->
  62. <t-cell
  63. wx:if="{{item.type == 'datepicker'}}"
  64. title="{{item.label}}"
  65. hover
  66. note="{{item.inputValue}}"
  67. arrow
  68. data-item="{{item}}"
  69. data-index="{{index}}"
  70. data-mode="date"
  71. bindtap="showDatePicker"
  72. t-class="pannel-item"
  73. />
  74. <!-- 选择省市县 -->
  75. <t-cell required="{{item.force}}" wx:if="{{item.type == 'cascader'}}" title="{{item.label}}" data-index="{{index}}" note="{{item.inputValue}}" bind:click="showCascader">
  76. <text slot="description" class="t-class-description">{{item.errorMsg?item.errorMsg:''}}</text>
  77. </t-cell>
  78. <!-- 跳转链接 -->
  79. <t-cell required="{{item.force}}" wx:if="{{item.type == 'link' && format.isHide(item.hide,formLayoutData.formInfo)}}" title="{{item.label}}" note="{{item.inputValue}}" url="{{item.url}}" hover arrow>
  80. <text slot="description" class="t-class-description">{{item.errorMsg?item.errorMsg:''}}</text>
  81. </t-cell>
  82. </view>
  83. <view wx:if="{{!hideBtn}}" style="padding:30px">
  84. <t-button theme="primary" size="medium" disabled="{{disabledStatus}}" bind:tap="formSubmit" block>提 交</t-button>
  85. </view>
  86. <t-picker
  87. visible="{{pickerVisible}}"
  88. data-key="id"
  89. title="选择{{actPicker.label}}"
  90. cancelBtn="取消"
  91. confirmBtn="确认"
  92. bindconfirm="onPickerConfirm"
  93. bindchange="onPickerChange"
  94. >
  95. <t-picker-item options="{{actPicker.data}}"></t-picker-item>
  96. </t-picker>
  97. <t-date-time-picker
  98. title="选择日期"
  99. visible="{{dateVisible}}"
  100. mode="date"
  101. value="{{timePickerValue}}"
  102. format="YYYY-MM-DD"
  103. bindchange="onTimePickerConfirm"
  104. />
  105. <t-cascader
  106. visible="{{cascaderVisible}}"
  107. theme="step"
  108. options="{{options}}"
  109. value=''
  110. title="请选择地址"
  111. bind:change="onChange"
  112. ></t-cascader>
  113. </view>