formview.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="ground-wrap">
  3. <uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData">
  4. <uni-forms-item label="任务名称" required name="name" label-width=100>
  5. <uni-easyinput v-model="valiFormData.name" placeholder="请输入任务名称" />
  6. </uni-forms-item>
  7. <uni-forms-item label="目标仓库" required label-width=100>
  8. <uni-data-select v-model="valiFormData.warehouse" :localdata="range" @change="change"></uni-data-select>
  9. </uni-forms-item>
  10. <uni-forms-item label="日期时间" required label-width=100>
  11. <uni-datetime-picker type="datetime" return-type="timestamp" v-model="valiFormData.datetimesingle" />
  12. </uni-forms-item>
  13. </uni-forms>
  14. <button type="primary" @click="submit('valiForm')">提交</button>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. valiFormData: {
  22. name: '',
  23. datetimesingle: '',
  24. warehouse: '',
  25. },
  26. range: [{
  27. value: 0,
  28. text: "篮球"
  29. },
  30. {
  31. value: 1,
  32. text: "足球"
  33. },
  34. {
  35. value: 2,
  36. text: "游泳"
  37. },
  38. ],
  39. rules: {
  40. name: {
  41. rules: [{
  42. required: true,
  43. errorMessage: '任务名称不能为空'
  44. }]
  45. },
  46. },
  47. }
  48. },
  49. onLoad() {
  50. },
  51. methods: {
  52. submit(ref) {
  53. this.$refs[ref].validate().then(res => {
  54. console.log('success', res);
  55. uni.showToast({
  56. title: `校验通过`
  57. })
  58. }).catch(err => {
  59. console.log('err', err);
  60. })
  61. },
  62. }
  63. }
  64. </script>
  65. <style>
  66. .ground-wrap {
  67. width: 100%;
  68. height: 100%;
  69. padding: 20rpx;
  70. box-sizing: border-box;
  71. }
  72. uni-page-body {
  73. width: 100%;
  74. height: 100%;
  75. }
  76. </style>