student.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="teacher">
  3. <view class="one">
  4. <form @submit="formSubmit">
  5. <view class="value other" style="display: none;">
  6. <view class="title">id</view>
  7. <view class="label">
  8. <input name="_id" class="input" :value="form._id" placeholder="请输入id" />
  9. </view>
  10. </view>
  11. <view class="value icon">
  12. <view class="title">头像</view>
  13. <view class="label">
  14. <up-upload :fileList="form.icon" @afterRead="afterRead" @delete="deletePic" name="icon" multiple
  15. :maxCount="1"></up-upload>
  16. </view>
  17. </view>
  18. <view class="value other">
  19. <view class="title">昵称</view>
  20. <view class="label">
  21. <input name="nick_name" class="input" :value="form.nick_name" placeholder="请输入昵称" />
  22. <span v-if="errors.nick_name" class="error-message">{{ errors.nick_name }}</span>
  23. </view>
  24. </view>
  25. <view class="value other margin">
  26. <view class="title">性别</view>
  27. <view class="label">
  28. <up-radio-group v-model="form.gender" placement="row">
  29. <up-radio :customStyle="{marginRight: '16px'}" v-for="(item, index) in genderList"
  30. :key="index" :label="item.label" :name="item.value">
  31. </up-radio>
  32. </up-radio-group>
  33. <span v-if="errors.gender" class="error-message">{{ errors.gender }}</span>
  34. </view>
  35. </view>
  36. <view class="value other">
  37. <view class="title">年龄</view>
  38. <view class="label">
  39. <input name="age" class="input" :value="form.age" placeholder="请输入年龄" />
  40. <span v-if="errors.age" class="error-message">{{ errors.age }}</span>
  41. </view>
  42. </view>
  43. <view class="value other">
  44. <view class="title">手机号</view>
  45. <view class="label">
  46. <input name="phone" class="input" :value="form.phone" placeholder="请输入手机号" />
  47. <span v-if="errors.phone" class="error-message">{{ errors.phone }}</span>
  48. </view>
  49. </view>
  50. <view class="value other margin">
  51. <view class="title">年级</view>
  52. <view class="label">
  53. <picker @change="gradeChange" :range="gradeList" range-key='label'>
  54. <view class="picker">{{form.grade_name||'请选择年级'}}</view>
  55. </picker>
  56. </view>
  57. </view>
  58. <view class="brief other margin">
  59. <view class="title">家庭住址</view>
  60. <view class="label">
  61. <textarea name='address' :value="form.address" placeholder="请输入家庭住址" auto-height />
  62. </view>
  63. </view>
  64. <view class="button">
  65. <button type="warn" size="mini" form-type="submit">保存</button>
  66. </view>
  67. </form>
  68. </view>
  69. </view>
  70. </template>
  71. <script setup lang="ts">
  72. import { inject } from 'vue';
  73. const form = inject('form');
  74. const errors = inject('errors');
  75. // 字典表
  76. const genderList = inject('genderList')
  77. const gradeList = inject('gradeList')
  78. const deletePic = inject('deletePic');
  79. const afterRead = inject('afterRead');
  80. const formSubmit = inject('formSubmit');
  81. const gradeChange = inject('gradeChange');
  82. </script>
  83. <style lang="scss" scoped>
  84. .teacher {
  85. display: flex;
  86. flex-direction: column;
  87. background-color: var(--footColor);
  88. .one {
  89. .icon {
  90. padding: 2vw;
  91. }
  92. .margin {
  93. margin: 3vw 0 0 0;
  94. }
  95. .other {
  96. padding: 3vw 2vw;
  97. border-bottom: 1px solid var(--footColor);
  98. }
  99. .value {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: center;
  103. background-color: var(--mainColor);
  104. .label {
  105. text-align: right;
  106. .input {
  107. text-align: right;
  108. }
  109. .image {
  110. width: 15vw;
  111. height: 15vw;
  112. border-radius: 20vw;
  113. }
  114. .error-message {
  115. margin: 5px 0 0 0;
  116. color: var(--ff0Color);
  117. font-size: var(--font12Size);
  118. }
  119. }
  120. }
  121. .brief {
  122. background-color: var(--mainColor);
  123. .title {
  124. margin: 0 0 2vw 0;
  125. }
  126. }
  127. .button {
  128. margin: 2vw 0 0 0;
  129. text-align: center;
  130. button {
  131. color: var(--mainColor);
  132. background-color: var(--3c9Color);
  133. font-size: var(--font14Size);
  134. border-radius: 2vw;
  135. }
  136. }
  137. }
  138. }
  139. </style>