form.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="page page--divider">
  3. <view class="title">{{info.title}}</view>
  4. <!-- 单行输入框 -->
  5. <input type="text" v-model="value" :placeholder="placeholder" v-if="isText" focus />
  6. <!-- 多行输入框 -->
  7. <textarea v-model="value" :placeholder="placeholder" v-if="isLongtext" focus />
  8. <!-- 单选 -->
  9. <radio-group class="cell-wrapper" @change="radioChange" v-if="isRadio">
  10. <label class="cell" v-for="item in info.fields" :key="item.value">
  11. <view class="cell-hd">{{item.name}}</view>
  12. <view class="cell-hb"><radio :value="item.value" :checked="value === item.value" /></view>
  13. </label>
  14. </radio-group>
  15. <!-- 多选 -->
  16. <checkbox-group @change="checkboxChange" v-if="isCheckbox">
  17. <label v-for="item in info.fields" :key="item.value">
  18. <view>{{item.name}}</view>
  19. <view><checkbox :value="item.value" :checked="checkedMap[item.value]" /></view>
  20. </label>
  21. </checkbox-group>
  22. <!-- 帮助信息 -->
  23. <view v-if="info.help">{{info.help}}</view>
  24. <view class="widget">
  25. <view class="btn btn-error" @tap="handleSubmit">{{confirmText}}</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. function is(type) {
  31. return function () {
  32. return this.info.type === type;
  33. }
  34. }
  35. export default {
  36. data() {
  37. return {
  38. info: {},
  39. value: null,
  40. event: null,
  41. checkedMap: {},//多选使用
  42. };
  43. },
  44. computed: {
  45. },
  46. methods: {
  47. },
  48. onLoad(opts) {
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .page {
  54. padding-top: $uni-spacing-col-lg;
  55. }
  56. .title {
  57. padding: $uni-spacing-col-lg;
  58. padding-bottom: $uni-spacing-col-sm;
  59. color: #999;
  60. }
  61. input,
  62. textarea {
  63. background-color: #fff;
  64. font-size: 32upx;
  65. padding: $uni-spacing-col-lg;
  66. box-sizing: content-box;
  67. }
  68. textarea {
  69. width: 100%;
  70. box-sizing: border-box;
  71. }
  72. .widget {
  73. margin-top: $uni-spacing-col-lg;
  74. }
  75. </style>