index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="page_submit" :style="{paddingTop: statusBarHeight + 200 + 'rpx', paddingBottom: safeAreaBottom + 100 + 'rpx' }">
  3. <notice-header
  4. :title="isEdit ? '编辑任务' : '新建任务'"
  5. mode="submit"
  6. :showSave="true"
  7. @save="handleSave">
  8. </notice-header>
  9. <view class="form_container">
  10. <scroll-view scroll-y class="form_scroll">
  11. <view class="form_section">
  12. <view class="section_title">基本信息</view>
  13. <view class="form_item">
  14. <text class="form_label">任务标题</text>
  15. <input class="form_input" v-model="formData.title" placeholder="请输入任务标题" />
  16. </view>
  17. <view class="form_item">
  18. <text class="form_label">学年</text>
  19. <picker mode="selector" :range="academicYearOptions" :value="academicYearIndex" @change="handleAcademicYearChange">
  20. <view class="picker_item">
  21. <text>{{ academicYearOptions[academicYearIndex] }}</text>
  22. <uni-icons type="down" size="16" color="#999999"></uni-icons>
  23. </view>
  24. </picker>
  25. </view>
  26. <view class="form_item">
  27. <text class="form_label">归属分类</text>
  28. <picker mode="selector" :range="categoryOptions" :value="categoryIndex" @change="handleCategoryChange">
  29. <view class="picker_item">
  30. <text>{{ categoryOptions[categoryIndex] }}</text>
  31. <uni-icons type="down" size="16" color="#999999"></uni-icons>
  32. </view>
  33. </picker>
  34. </view>
  35. <view class="form_item">
  36. <text class="form_label">材料类目</text>
  37. <picker mode="selector" :range="materialTypeOptions" :value="materialTypeIndex" @change="handleMaterialTypeChange">
  38. <view class="picker_item">
  39. <text>{{ materialTypeOptions[materialTypeIndex] }}</text>
  40. <uni-icons type="down" size="16" color="#999999"></uni-icons>
  41. </view>
  42. </picker>
  43. </view>
  44. </view>
  45. <view class="form_section">
  46. <view class="section_title">时间设置</view>
  47. <view class="form_item">
  48. <text class="form_label">开始日期</text>
  49. <picker mode="date" :value="formData.startDate" @change="handleStartDateChange">
  50. <view class="picker_item">
  51. <text>{{ formData.startDate || '请选择开始日期' }}</text>
  52. <uni-icons type="down" size="16" color="#999999"></uni-icons>
  53. </view>
  54. </picker>
  55. </view>
  56. <view class="form_item">
  57. <text class="form_label">截止日期</text>
  58. <picker mode="date" :value="formData.deadline" @change="handleDeadlineChange">
  59. <view class="picker_item">
  60. <text>{{ formData.deadline || '请选择截止日期' }}</text>
  61. <uni-icons type="down" size="16" color="#999999"></uni-icons>
  62. </view>
  63. </picker>
  64. </view>
  65. </view>
  66. <view class="form_section">
  67. <view class="section_title">任务描述</view>
  68. <textarea
  69. class="form_textarea"
  70. v-model="formData.description"
  71. placeholder="请输入任务描述"
  72. placeholder-class="textarea_placeholder"
  73. maxlength="500"
  74. ></textarea>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </view>
  79. </template>
  80. <script setup>
  81. import { ref, computed, onMounted } from 'vue';
  82. import { onLoad } from '@dcloudio/uni-app';
  83. import NoticeHeader from '@/components/notice-header.vue';
  84. import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
  85. import { useSafeArea } from '@/common/safeArea';
  86. const { statusBarHeight, safeAreaBottom, initSafeArea } = useSafeArea();
  87. const taskId = ref(null);
  88. const isEdit = computed(() => !!taskId.value);
  89. const academicYearOptions = ['2025-2026学年', '2024-2025学年', '2023-2024学年'];
  90. const categoryOptions = ['全部分类', '日常教学', '考试测评', '教研活动'];
  91. const materialTypeOptions = ['全部类目', '教案', '课件', '试卷', '作业'];
  92. const academicYearIndex = ref(0);
  93. const categoryIndex = ref(0);
  94. const materialTypeIndex = ref(0);
  95. const formData = ref({
  96. title: '',
  97. startDate: '',
  98. deadline: '',
  99. description: ''
  100. });
  101. onLoad((options) => {
  102. if (options && options.id) {
  103. taskId.value = options.id;
  104. loadTaskDetail(options.id);
  105. }
  106. });
  107. onMounted(() => {
  108. initSafeArea();
  109. });
  110. const loadTaskDetail = (id) => {
  111. // 模拟加载任务详情
  112. formData.value = {
  113. title: '2025年秋季学期教案材料收集',
  114. startDate: '2025-07-28',
  115. deadline: '2025-08-15',
  116. description: '请各位教师按时提交本学期的教案材料'
  117. };
  118. };
  119. const handleAcademicYearChange = (e) => {
  120. academicYearIndex.value = e.detail.value;
  121. };
  122. const handleCategoryChange = (e) => {
  123. categoryIndex.value = e.detail.value;
  124. };
  125. const handleMaterialTypeChange = (e) => {
  126. materialTypeIndex.value = e.detail.value;
  127. };
  128. const handleStartDateChange = (e) => {
  129. formData.value.startDate = e.detail.value;
  130. };
  131. const handleDeadlineChange = (e) => {
  132. formData.value.deadline = e.detail.value;
  133. };
  134. const handleSave = () => {
  135. if (!formData.value.title) {
  136. uni.showToast({ title: '请输入任务标题', icon: 'none' });
  137. return;
  138. }
  139. uni.showModal({
  140. title: '提示',
  141. content: isEdit.value ? '确定要保存修改吗?' : '确定要创建任务吗?',
  142. success: (res) => {
  143. if (res.confirm) {
  144. uni.showToast({
  145. title: isEdit.value ? '保存成功' : '创建成功',
  146. icon: 'success'
  147. });
  148. setTimeout(() => {
  149. uni.navigateBack();
  150. }, 1500);
  151. }
  152. }
  153. });
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. .page_submit {
  158. min-height: 100vh;
  159. background-color: #F5F7FA;
  160. }
  161. .form_container {
  162. flex: 1;
  163. padding: 24rpx;
  164. }
  165. .form_scroll {
  166. height: 100%;
  167. }
  168. .form_section {
  169. background-color: #FFFFFF;
  170. border-radius: 16rpx;
  171. padding: 24rpx;
  172. margin-bottom: 24rpx;
  173. .section_title {
  174. font-size: 30rpx;
  175. font-weight: 600;
  176. color: #333333;
  177. margin-bottom: 24rpx;
  178. }
  179. }
  180. .form_item {
  181. display: flex;
  182. align-items: center;
  183. padding: 24rpx 0;
  184. border-bottom: 1rpx solid #EBEEF5;
  185. &:last-child {
  186. border-bottom: none;
  187. }
  188. .form_label {
  189. width: 180rpx;
  190. font-size: 28rpx;
  191. color: #666666;
  192. }
  193. .form_input {
  194. flex: 1;
  195. font-size: 28rpx;
  196. color: #333333;
  197. text-align: right;
  198. }
  199. .picker_item {
  200. flex: 1;
  201. display: flex;
  202. align-items: center;
  203. justify-content: flex-end;
  204. font-size: 28rpx;
  205. color: #333333;
  206. gap: 8rpx;
  207. }
  208. }
  209. .form_textarea {
  210. width: 100%;
  211. min-height: 200rpx;
  212. font-size: 28rpx;
  213. color: #333333;
  214. padding: 16rpx;
  215. background-color: #F9FAFF;
  216. border-radius: 12rpx;
  217. box-sizing: border-box;
  218. }
  219. .textarea_placeholder {
  220. color: #999999;
  221. font-size: 28rpx;
  222. }
  223. </style>