activity-detail.vue.backup 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770
  1. <template>
  2. <view class="page-container">
  3. <!-- 页面滚动区域 -->
  4. <scroll-view class="page-scroll" scroll-y>
  5. <!-- 地块信息卡片 -->
  6. <view class="info-card">
  7. <view class="card-title">
  8. <text>地块信息</text>
  9. </view>
  10. <view class="info-item">
  11. <text class="info-label">地块名称</text>
  12. <text class="info-value">{{ formData.fieldName || '未知' }}</text>
  13. </view>
  14. <view class="info-item">
  15. <text class="info-label">作物名称</text>
  16. <text class="info-value">{{ formData.growCrops || '未知' }}</text>
  17. </view>
  18. <view class="info-item">
  19. <text class="info-label">负责人</text>
  20. <text class="info-value">{{ formData.manager || '未知' }}</text>
  21. </view>
  22. </view>
  23. <!-- 任务填写表单 -->
  24. <view class="form-card">
  25. <view class="card-title">
  26. <text>任务信息</text>
  27. </view>
  28. <!-- 任务名称 -->
  29. <view class="form-item">
  30. <view class="form-label required">任务名称</view>
  31. <input
  32. v-model="formData.taskName"
  33. placeholder="请输入任务名称,例如:水稻田施肥"
  34. :disabled="pageMode === 'view'"
  35. class="form-input"
  36. />
  37. </view>
  38. <!-- 任务类型 -->
  39. <view class="form-item" @click="pageMode !== 'view' && showTaskTypeSelector()">
  40. <view class="form-label required">任务类型</view>
  41. <view class="select-wrapper">
  42. <!-- <input
  43. :value="formData.typeName"
  44. :placeholder="dictLoading ? '加载中...' : '请选择任务类型'"
  45. readonly
  46. class="form-input select-input"
  47. /> -->
  48. <view class="form-input select-input">
  49. {{ formData.typeName || (dictLoading ? '加载中...' : '请选择任务类型') }}
  50. </view>
  51. <view v-if="pageMode !== 'view'" class="select-arrow">
  52. <text>▼</text>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 执行时间 -->
  57. <view class="form-item" @click="pageMode !== 'view' && selectExecuteTime()">
  58. <view class="form-label required">执行时间</view>
  59. <view class="select-wrapper">
  60. <!-- <input
  61. :value="formattedExecuteTime"
  62. placeholder="请选择任务计划时间"
  63. readonly
  64. class="form-input select-input"
  65. readonly
  66. /> -->
  67. <view class="form-input select-input">
  68. {{ formattedExecuteTime || '请选择任务计划时间' }}
  69. </view>
  70. <view v-if="pageMode !== 'view'" class="select-arrow">
  71. <text>选择</text>
  72. </view>
  73. </view>
  74. </view>
  75. <!-- 负责人选择 -->
  76. <view class="form-item" @click="pageMode !== 'view' && showUserSelector()">
  77. <view class="form-label required">负责人</view>
  78. <view class="select-wrapper">
  79. <!-- <input
  80. :value="formData.assigneeName"
  81. placeholder="请选择负责人"
  82. readonly
  83. class="form-input select-input"
  84. /> -->
  85. <view class="form-input select-input">
  86. {{ formData.assigneeName || '请选择负责人' }}
  87. </view>
  88. <view v-if="pageMode !== 'view'" class="select-arrow">
  89. <text>选择</text>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 任务说明 -->
  94. <view class="form-item">
  95. <view class="form-label">任务说明</view>
  96. <textarea
  97. v-model="formData.remark"
  98. placeholder="请输入任务要点,例如:每亩用肥20kg"
  99. :disabled="pageMode === 'view'"
  100. class="form-textarea"
  101. maxlength="200"
  102. ></textarea>
  103. <view class="char-count">{{ (formData.remark || '').length }}/200</view>
  104. </view>
  105. <!-- 任务完成情况 -->
  106. <view class="section-divider"></view>
  107. <view class="section-title">
  108. <text>任务完成情况</text>
  109. </view>
  110. <!-- 完成状态选择 - 新建和编辑模式 -->
  111. <view class="form-item" v-if="pageMode === 'create' || pageMode === 'edit'">
  112. <view class="form-label">完成状态</view>
  113. <view class="radio-group">
  114. <view
  115. class="radio-item"
  116. v-for="(item, index) in completionStatusOptions"
  117. :key="index"
  118. @click="selectCompletionStatus(item.value)"
  119. >
  120. <view class="radio-circle" :class="{'radio-checked': formData.completionStatus === item.value}">
  121. <view v-if="formData.completionStatus === item.value" class="radio-dot"></view>
  122. </view>
  123. <text class="radio-label">{{ item.label }}</text>
  124. </view>
  125. </view>
  126. </view>
  127. <!-- 查看模式显示完成状态 -->
  128. <view class="form-item" v-if="pageMode === 'view'">
  129. <view class="form-label">完成状态</view>
  130. <view class="status-completed">
  131. <text class="status-icon">✓</text>
  132. <text>已完成</text>
  133. </view>
  134. </view>
  135. <!-- 完成时间 -->
  136. <view class="form-item" v-if="formData.completionStatus === '1'">
  137. <view class="form-label" :class="{'required': (pageMode === 'create' || pageMode === 'edit') && formData.completionStatus === '1'}">完成时间</view>
  138. <view class="select-wrapper" @click="(pageMode === 'create' || pageMode === 'edit') && formData.completionStatus === '1' && selectCompletionTime()">
  139. <!-- <input
  140. :value="formattedCompletionTime"
  141. placeholder="请选择实际完成时间"
  142. readonly
  143. class="form-input select-input"
  144. /> -->
  145. <view class="form-input select-input">
  146. {{ formattedCompletionTime || '请选择实际完成时间' }}
  147. </view>
  148. <view v-if="(pageMode === 'create' || pageMode === 'edit') && formData.completionStatus === '1'" class="select-arrow">
  149. <text>选择</text>
  150. </view>
  151. </view>
  152. </view>
  153. <!-- 完成说明 -->
  154. <view class="form-item" v-if="formData.completionStatus === '1'">
  155. <view class="form-label" :class="{'required': (pageMode === 'create' || pageMode === 'edit') && formData.completionStatus === '1'}">完成说明</view>
  156. <textarea
  157. v-model="formData.completionDesc"
  158. placeholder="请输入完成说明,例如:已完成并拍照记录"
  159. :disabled="pageMode === 'view'"
  160. class="form-textarea"
  161. maxlength="300"
  162. ></textarea>
  163. <view class="char-count">{{ (formData.completionDesc || '').length }}/300</view>
  164. <view class="form-error" v-if="formErrors.completionDesc">
  165. {{ formErrors.completionDesc }}
  166. </view>
  167. </view>
  168. <!-- 现场图片 -->
  169. <view class="form-item" v-if="formData.completionStatus === '1'">
  170. <view class="form-label">现场图片</view>
  171. <!-- 新建和编辑模式 -->
  172. <view v-if="pageMode === 'create' || pageMode === 'edit'" class="image-upload">
  173. <view class="image-list">
  174. <view
  175. class="image-preview"
  176. v-for="(item, index) in formData.images"
  177. :key="index"
  178. @click="previewImage(item, index)"
  179. >
  180. <!-- <image :src="getImageUrl(item)" mode="aspectFill"/> -->
  181. <image :src="item.url" mode="aspectFill"/>
  182. <view class="delete-btn" @click.stop="deletePic(index)">
  183. <text>×</text>
  184. </view>
  185. </view>
  186. <view
  187. v-if="formData.images.length < 6"
  188. class="upload-btn"
  189. @click="chooseImage"
  190. >
  191. <text class="upload-icon">+</text>
  192. <text class="upload-text">添加图片</text>
  193. </view>
  194. </view>
  195. <view class="upload-tip">最多可上传6张图片</view>
  196. </view>
  197. <!-- 查看模式 -->
  198. <view v-else-if="pageMode === 'view' && formData.images && formData.images.length > 0" class="image-view">
  199. <view class="image-list">
  200. <view
  201. class="image-preview"
  202. v-for="(item, index) in formData.images"
  203. :key="index"
  204. @click="previewImage(item, index)"
  205. >
  206. <!-- <image :src="getImageUrl(item)" mode="aspectFill"/> -->
  207. <image :src="item.url" mode="aspectFill"/>
  208. </view>
  209. </view>
  210. </view>
  211. <!-- 无图片提示 -->
  212. <view v-else class="no-images">
  213. <text>暂无图片</text>
  214. </view>
  215. </view>
  216. </view>
  217. <!-- 底部占位 -->
  218. <view class="bottom-safe"></view>
  219. </scroll-view>
  220. <!-- 底部提交按钮 -->
  221. <view class="footer-safe" v-if="pageMode !== 'view'">
  222. <view class="footer-content">
  223. <button
  224. class="submit-button"
  225. :class="{'loading': isSubmitting}"
  226. @click="submitForm"
  227. :disabled="isSubmitting"
  228. >
  229. {{ isSubmitting ? '提交中...' : submitButtonText }}
  230. </button>
  231. </view>
  232. </view>
  233. <!-- 遮罩层 -->
  234. <view v-if="showTaskTypePicker || showDateTimeSelector || showUserPicker" class="picker-mask" @click="closePickers"></view>
  235. <!-- 任务类型选择弹窗 -->
  236. <view v-if="showTaskTypePicker" class="picker-popup">
  237. <view class="picker-header">
  238. <text class="picker-cancel" @click="showTaskTypePicker = false">取消</text>
  239. <text class="picker-title">选择任务类型</text>
  240. <text class="picker-confirm" @click="confirmTaskType">确定</text>
  241. </view>
  242. <view class="picker-content">
  243. <view v-if="dictLoading" class="picker-loading">
  244. <text>加载中...</text>
  245. </view>
  246. <view
  247. v-else
  248. class="picker-item"
  249. v-for="(item, index) in taskTypeOptions"
  250. :key="index"
  251. :class="{'selected': tempTaskTypeIndex === index}"
  252. @click="tempTaskTypeIndex = index"
  253. >
  254. <text>{{ item.dictLabel }}</text>
  255. <text v-if="tempTaskTypeIndex === index" class="check-mark">✓</text>
  256. </view>
  257. </view>
  258. </view>
  259. <!-- 用户选择弹窗 -->
  260. <view v-if="showUserPicker" class="picker-popup">
  261. <view class="picker-header">
  262. <text class="picker-cancel" @click="showUserPicker = false">取消</text>
  263. <text class="picker-title">选择负责人</text>
  264. <text class="picker-confirm" @click="confirmUser">确定</text>
  265. </view>
  266. <view class="picker-content">
  267. <view v-if="usersLoading" class="picker-loading">
  268. <text>加载中...</text>
  269. </view>
  270. <view v-else-if="userList.length === 0" class="picker-empty">
  271. <text>暂无可选负责人</text>
  272. </view>
  273. <view
  274. v-else
  275. class="picker-item"
  276. v-for="(user, index) in userList"
  277. :key="user.userId"
  278. :class="{'selected': tempUserIndex === index}"
  279. @click="tempUserIndex = index"
  280. >
  281. <text>{{ user.userName }}</text>
  282. <text v-if="tempUserIndex === index" class="check-mark">✓</text>
  283. </view>
  284. </view>
  285. </view>
  286. <!-- 日期时间选择弹窗 -->
  287. <view v-if="showDateTimeSelector" class="picker-popup datetime-picker">
  288. <view class="picker-header">
  289. <text class="picker-cancel" @click="cancelDateTime">取消</text>
  290. <text class="picker-title">选择时间</text>
  291. <text class="picker-confirm" @click="confirmDateTime">确定</text>
  292. </view>
  293. <view class="datetime-picker-content">
  294. <picker-view
  295. class="datetime-picker-view"
  296. :value="dateTimePickerValue"
  297. @change="onDateTimePickerChange"
  298. :indicator-style="'height: 80rpx;'"
  299. :mask-style="'background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6)), linear-gradient(0deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6));'"
  300. >
  301. <picker-view-column>
  302. <view class="picker-view-item" v-for="(item, index) in dateTimePickerRange[0]" :key="'year-'+index">
  303. <text class="picker-item-text">{{ item }}</text>
  304. </view>
  305. </picker-view-column>
  306. <picker-view-column>
  307. <view class="picker-view-item" v-for="(item, index) in dateTimePickerRange[1]" :key="'month-'+index">
  308. <text class="picker-item-text">{{ item }}</text>
  309. </view>
  310. </picker-view-column>
  311. <picker-view-column>
  312. <view class="picker-view-item" v-for="(item, index) in dateTimePickerRange[2]" :key="'day-'+index">
  313. <text class="picker-item-text">{{ item }}</text>
  314. </view>
  315. </picker-view-column>
  316. <picker-view-column>
  317. <view class="picker-view-item" v-for="(item, index) in dateTimePickerRange[3]" :key="'hour-'+index">
  318. <text class="picker-item-text">{{ item }}</text>
  319. </view>
  320. </picker-view-column>
  321. <picker-view-column>
  322. <view class="picker-view-item" v-for="(item, index) in dateTimePickerRange[4]" :key="'min-'+index">
  323. <text class="picker-item-text">{{ item }}</text>
  324. </view>
  325. </picker-view-column>
  326. </picker-view>
  327. </view>
  328. </view>
  329. </view>
  330. </template>
  331. <script setup>
  332. import { ref, reactive, computed, onMounted } from 'vue'
  333. import api from "@/config/api.js";
  334. import { getAgriculturalTasksById, addAgriculturalTask, updateAgriculturalTask } from '@/api/services/activity.js';
  335. import { getUsersByPlotId, getUserInfo } from '@/api/services/user.js';
  336. import { useDict } from '@/utils/composables/useDict';
  337. import storage from "@/utils/storage.js";
  338. // 使用字典组合式函数
  339. const { dictData, dictLoading, loadDict } = useDict(['task_type', 'task_status'])
  340. // 页面模式:create-新建, edit-编辑, view-查看
  341. const pageMode = ref('create')
  342. // 选择器显示状态
  343. const showTaskTypePicker = ref(false)
  344. const showDateTimeSelector = ref(false)
  345. const showUserPicker = ref(false)
  346. // 临时选择的任务类型索引
  347. const tempTaskTypeIndex = ref(0)
  348. const tempUserIndex = ref(0)
  349. // 时间选择器相关
  350. const currentTimeType = ref('')
  351. const dateTimePickerValue = ref([0, 0, 0, 0, 0])
  352. const dateTimePickerRange = ref([])
  353. // 表单数据
  354. const formData = reactive({
  355. // 任务ID,新建任务时为空
  356. id: '',
  357. // 地块基础信息
  358. plotId: '',
  359. fieldName: '',
  360. growCrops: '',
  361. manager: '',
  362. // 任务信息
  363. taskName: '',
  364. typeName: '',
  365. typeNameId: '',
  366. executeTime: new Date(),
  367. remark: '',
  368. // 完成情况
  369. taskStatus: '0',
  370. completionStatus: '0',
  371. completionTime: new Date(),
  372. completionDesc: '',
  373. images: [],
  374. taskImages: '',
  375. // 负责人信息
  376. assigneeId: '',
  377. assigneeName: '',
  378. // 创建人信息
  379. create_by: ''
  380. })
  381. // 完成状态选项
  382. const completionStatusOptions = [
  383. { label: '待完成', value: '0' },
  384. { label: '已完成', value: '1' }
  385. ]
  386. // 是否正在提交
  387. const isSubmitting = ref(false)
  388. // 表单验证错误
  389. const formErrors = reactive({
  390. completionDesc: ''
  391. })
  392. // 用户列表
  393. const userList = ref([])
  394. const usersLoading = ref(false)
  395. // 任务类型列表
  396. const taskStatusList = ref([])
  397. // 计算属性
  398. const pageTitle = computed(() => {
  399. switch (pageMode.value) {
  400. case 'create':
  401. return '新建农事任务'
  402. case 'edit':
  403. return '编辑农事任务'
  404. default:
  405. return '农事任务详情'
  406. }
  407. })
  408. const submitButtonText = computed(() => {
  409. switch (pageMode.value) {
  410. case 'create':
  411. return '创建任务'
  412. case 'edit':
  413. return '保存修改'
  414. default:
  415. return ''
  416. }
  417. })
  418. const formattedExecuteTime = computed(() => {
  419. return formatDateTime(formData.executeTime)
  420. })
  421. const formattedCompletionTime = computed(() => {
  422. return formatDateTime(formData.completionTime)
  423. })
  424. const taskTypeOptions = computed(() => {
  425. console.log("dictData:", dictData.value.task_type)
  426. return dictData.value.task_type
  427. })
  428. const taskTypeIndex = computed(() => {
  429. console.log("taskTypeOptions", taskTypeOptions.value)
  430. const index = taskTypeOptions.value.findIndex(item => item.dictValue === formData.typeNameId)
  431. console.log("查找:", index)
  432. return index >= 0 ? index : 0
  433. })
  434. // 初始化字典数据
  435. loadDict().then(() => {
  436. // 字典加载完成后,如果没有设置任务类型,则默认选择第一个
  437. if (!formData.typeName && dictData.value.task_type && dictData.value.task_type.length > 0) {
  438. const firstType = dictData.value.task_type[0]
  439. taskStatusList.value = dictData.value.task_type
  440. console.log("dictData", dictData.value.task_status[0].dictLabel)
  441. formData.typeName = firstType.dictLabel
  442. formData.typeNameId = firstType.dictValue
  443. }
  444. })
  445. // uni-app 生命周期
  446. const onLoad = (options) => {
  447. console.log('页面加载,接收参数:', options)
  448. // 设置页面模式
  449. if (options.mode) {
  450. pageMode.value = options.mode
  451. }
  452. // 设置地块基础信息
  453. formData.fieldName = decodeURIComponent(options.fieldName === 'undefined' ? '未选择地块' : options.fieldName)
  454. formData.growCrops = decodeURIComponent(options.growCrops === 'undefined' ? '未选择地块' : options.growCrops)
  455. formData.manager = decodeURIComponent(options.manager === 'undefined' ? '未选择地块' : options.manager)
  456. formData.plotId = parseInt(options.plotId || '1')
  457. formData.farmId = parseInt(options.farmId || '1')
  458. // 加载用户列表
  459. loadUserList(formData.farmId)
  460. // 如果是编辑或查看模式,获取任务详情
  461. if (options.id && options.id !== 'new') {
  462. formData.id = options.id
  463. loadTaskDetail(options.id)
  464. } else if (options.id === 'new') {
  465. // 加载当前登录用户
  466. loadAssigneeInfo()
  467. }
  468. // 设置导航栏标题
  469. uni.setNavigationBarTitle({
  470. title: pageTitle.value
  471. })
  472. // 初始化时间选择器数据
  473. initDateTimeRange()
  474. }
  475. // 方法定义
  476. // 跨端安全解析日期
  477. const normalizeToDate = (input) => {
  478. if (!input) return new Date()
  479. let dateObj = input
  480. if (typeof input === 'string') {
  481. // 兼容 iOS:将 2025-08-12 12:30:00 转为 2025/08/12 12:30:00
  482. dateObj = input.replace(/-/g, '/')
  483. }
  484. if (typeof input === 'number') {
  485. // 秒级时间戳转毫秒
  486. if (input.toString().length === 10) {
  487. dateObj = input * 1000
  488. }
  489. }
  490. const d = new Date(dateObj)
  491. return isNaN(d.getTime()) ? new Date() : d
  492. }
  493. // 加载任务详情
  494. const loadTaskDetail = (taskId) => {
  495. uni.showLoading({
  496. title: '加载中...',
  497. mask: true
  498. })
  499. getAgriculturalTasksById(taskId).then(res => {
  500. if (res.data.code === 200) {
  501. const taskDetail = res.data.data
  502. // 设置表单数据
  503. Object.assign(formData, {
  504. ...taskDetail,
  505. manager: formData.manager,
  506. completionStatus: taskDetail.taskStatus
  507. })
  508. // 转换任务类型值
  509. if (taskStatusList.value && taskStatusList.value.length > 0) {
  510. const typeDict = taskStatusList.value.find(item => item.dictValue === taskDetail.typeName.toString())
  511. if (typeDict) {
  512. formData.typeName = typeDict.dictLabel
  513. formData.typeNameId = typeDict.dictValue
  514. }
  515. }
  516. // 处理图片数据
  517. if (formData.taskImages) {
  518. try {
  519. const imageUrls = formData.taskImages.split(',')
  520. formData.images = imageUrls.filter(url => url && url.trim()).map(url => ({
  521. url: url.trim(),
  522. status: 'success'
  523. }))
  524. console.log('解析后的图片数据:', formData.images)
  525. } catch (e) {
  526. console.error('解析图片数据失败:', e)
  527. formData.images = []
  528. }
  529. } else {
  530. formData.images = []
  531. }
  532. console.log("formData.assigneeId", formData.assigneeId)
  533. console.log("!formData.assigneeName", formData.assigneeName)
  534. // 如果有负责人ID但没有负责人名称,获取负责人信息
  535. if (formData.assigneeId && !formData.assigneeName) {
  536. loadAssigneeInfo(formData.assigneeId)
  537. }
  538. uni.hideLoading();
  539. } else {
  540. uni.hideLoading();
  541. uni.showToast({
  542. title: res.data.msg || '获取任务详情失败',
  543. icon: 'none'
  544. });
  545. // 失败后返回上一页
  546. setTimeout(() => {
  547. uni.navigateBack();
  548. }, 1500);
  549. }
  550. }).catch(err => {
  551. console.error('获取任务详情失败:', err);
  552. uni.hideLoading();
  553. uni.showToast({
  554. title: '获取任务详情失败',
  555. icon: 'none'
  556. });
  557. // 失败后返回上一页
  558. setTimeout(() => {
  559. uni.navigateBack();
  560. }, 1500);
  561. });
  562. },
  563. // 加载负责人信息
  564. loadAssigneeInfo(userId) {
  565. getUserInfo(userId).then(res => {
  566. console.log("你是谁:",res);
  567. if (res.data.code === 200) {
  568. const userData = res.data.data;
  569. this.formData.assigneeName = userData.userName || '未知用户';
  570. this.formData.assigneeId = userData.userId;
  571. }
  572. }).catch(err => {
  573. console.error('获取负责人信息失败:', err);
  574. this.formData.assigneeName = '未知用户';
  575. });
  576. },
  577. // 加载用户列表
  578. loadUserList(farmId) {
  579. this.usersLoading = true;
  580. const params = {
  581. pageNum: 1,
  582. pageSize: 10,
  583. deptId: farmId
  584. }
  585. getUsersByPlotId(params).then(res => {
  586. console.log("加载用户:",res);
  587. if (res.data.code === 200) {
  588. this.userList = res.data.rows || [];
  589. // 设置默认选中第一个用户
  590. if (this.userList.length > 0 && !this.formData.assigneeId) {
  591. this.formData.assigneeId = this.userList[0].userId;
  592. this.formData.assigneeName = this.userList[0].userName;
  593. }
  594. } else {
  595. console.error('获取用户列表失败:', res.data.msg);
  596. uni.showToast({
  597. title: '获取用户列表失败',
  598. icon: 'none'
  599. });
  600. }
  601. }).catch(err => {
  602. console.error('获取用户列表失败:', err);
  603. uni.showToast({
  604. title: '获取用户列表失败',
  605. icon: 'none'
  606. });
  607. }).finally(() => {
  608. this.usersLoading = false;
  609. });
  610. },
  611. // 初始化时间选择器范围数据
  612. initDateTimeRange() {
  613. // 年份:从2020年开始显示10年
  614. const startYear = 2020;
  615. const years = [];
  616. for (let i = 0; i < 10; i++) {
  617. years.push((startYear + i) + '年');
  618. }
  619. // 月份:1-12月
  620. const months = [];
  621. for (let i = 1; i <= 12; i++) {
  622. months.push(i + '月');
  623. }
  624. // 日期:1-31日
  625. const days = [];
  626. for (let i = 1; i <= 31; i++) {
  627. days.push(i + '日');
  628. }
  629. // 小时:0-23时
  630. const hours = [];
  631. for (let i = 0; i <= 23; i++) {
  632. hours.push(i.toString().padStart(2, '0') + '时');
  633. }
  634. // 分钟:0-59分
  635. const minutes = [];
  636. for (let i = 0; i <= 59; i++) {
  637. minutes.push(i.toString().padStart(2, '0') + '分');
  638. }
  639. this.dateTimePickerRange = [years, months, days, hours, minutes];
  640. console.log('日期选择器范围:', {
  641. years: years.length,
  642. months: months.length,
  643. days: days.length,
  644. hours: hours.length,
  645. minutes: minutes.length
  646. });
  647. },
  648. // 初始化日期时间选择器
  649. initDateTimePicker(timestamp) {
  650. const date = this.normalizeToDate(timestamp);
  651. const currentYear = date.getFullYear();
  652. const currentMonth = date.getMonth() + 1; // 1-12
  653. const currentDate = date.getDate(); // 1-31
  654. const currentHour = date.getHours();
  655. const currentMinute = date.getMinutes();
  656. // 基准年份,用于计算索引
  657. const startYear = 2020;
  658. // 如果当前年份小于起始年份或大于结束年份,调整为合法范围内
  659. let yearIndex = currentYear - startYear;
  660. if (yearIndex < 0) yearIndex = 0;
  661. if (yearIndex >= 10) yearIndex = 9;
  662. console.log('初始化日期选择器:', {
  663. timestamp,
  664. year: currentYear,
  665. month: currentMonth,
  666. date: currentDate,
  667. hour: currentHour,
  668. minute: currentMinute,
  669. yearIndex
  670. });
  671. // 设置选择器的初始值
  672. this.dateTimePickerValue = [
  673. yearIndex, // 年份索引
  674. currentMonth - 1, // 月份索引(0-11)
  675. currentDate - 1, // 日期索引(0-30)
  676. currentHour, // 小时索引
  677. currentMinute // 分钟索引
  678. ];
  679. console.log('选择器初始值:', this.dateTimePickerValue);
  680. // 更新日期范围
  681. this.updateDaysRange();
  682. },
  683. // 更新日期范围(根据选择的年月)
  684. updateDaysRange() {
  685. const yearIndex = this.dateTimePickerValue[0];
  686. const monthIndex = this.dateTimePickerValue[1];
  687. // 计算实际年月
  688. const year = 2020 + yearIndex;
  689. const month = monthIndex + 1; // 索引为0-11,实际月份为1-12
  690. // 获取该月的天数
  691. const daysInMonth = new Date(year, month, 0).getDate();
  692. // 更新天数范围
  693. const days = [];
  694. for (let i = 1; i <= daysInMonth; i++) {
  695. days.push(i + '日');
  696. }
  697. // 更新日期列
  698. this.dateTimePickerRange[2] = days;
  699. // 如果当前选择的日期超过了该月的天数,调整为该月最后一天
  700. if (this.dateTimePickerValue[2] >= daysInMonth) {
  701. this.dateTimePickerValue[2] = daysInMonth - 1;
  702. }
  703. console.log('更新日期范围:', {
  704. year,
  705. month,
  706. daysInMonth,
  707. daysLength: days.length
  708. });
  709. },
  710. // 显示任务类型选择器
  711. showTaskTypeSelector() {
  712. this.tempTaskTypeIndex = this.taskTypeIndex;
  713. this.showTaskTypePicker = true;
  714. },
  715. // 确认任务类型选择
  716. confirmTaskType() {
  717. const selectedType = this.taskTypeOptions[this.tempTaskTypeIndex];
  718. console.log("选中:",selectedType);
  719. this.formData.typeName = selectedType.dictLabel;
  720. this.formData.typeNameId = selectedType.dictValue; // 设置typeNameId为dictValue值
  721. this.showTaskTypePicker = false;
  722. },
  723. // 选择执行时间
  724. selectExecuteTime() {
  725. this.currentTimeType = 'executeTime';
  726. this.initDateTimePicker(this.formData.executeTime);
  727. this.showDateTimeSelector = true;
  728. },
  729. // 选择完成时间
  730. selectCompletionTime() {
  731. this.currentTimeType = 'completionTime';
  732. this.initDateTimePicker(this.formData.completionTime);
  733. this.showDateTimeSelector = true;
  734. },
  735. // 日期时间选择器变更
  736. onDateTimePickerChange(e) {
  737. this.dateTimePickerValue = e.detail.value;
  738. // 当年月变更时,更新日期范围
  739. this.updateDaysRange();
  740. },
  741. // 确认时间选择
  742. confirmDateTime() {
  743. const values = this.dateTimePickerValue;
  744. // 计算实际日期时间
  745. const year = 2020 + values[0];
  746. const month = values[1] + 1; // 索引为0-11,实际月份为1-12
  747. const date = values[2] + 1; // 索引为0-30,实际日期为1-31
  748. const hour = values[3];
  749. const minute = values[4];
  750. console.log('确认日期时间:', {
  751. selectedValues: values,
  752. convertedDate: `${year}-${month}-${date} ${hour}:${minute}`
  753. });
  754. // 创建日期对象
  755. const selectedTime = new Date(year, month - 1, date, hour, minute).getTime();
  756. // 更新相应的表单字段
  757. if (this.currentTimeType === 'executeTime') {
  758. this.formData.executeTime = selectedTime;
  759. } else if (this.currentTimeType === 'completionTime') {
  760. this.formData.completionTime = selectedTime;
  761. }
  762. // 关闭选择器
  763. this.showDateTimeSelector = false;
  764. uni.showToast({
  765. title: '时间已设置',
  766. icon: 'success',
  767. duration: 1500
  768. });
  769. },
  770. // 取消时间选择
  771. cancelDateTime() {
  772. this.showDateTimeSelector = false;
  773. },
  774. // 显示用户选择器
  775. showUserSelector() {
  776. this.tempUserIndex = this.userList.findIndex(user => user.userId === this.formData.assigneeId);
  777. this.showUserPicker = true;
  778. },
  779. // 确认用户选择
  780. confirmUser() {
  781. const selectedUser = this.userList[this.tempUserIndex];
  782. this.formData.assigneeId = selectedUser.userId;
  783. this.formData.assigneeName = selectedUser.userName;
  784. this.showUserPicker = false;
  785. },
  786. // 关闭所有选择器
  787. closePickers() {
  788. this.showTaskTypePicker = false;
  789. this.showDateTimeSelector = false;
  790. this.showUserPicker = false;
  791. },
  792. // 选择完成状态
  793. selectCompletionStatus(value) {
  794. this.formData.completionStatus = value;
  795. this.formData.taskStatus = value; // 同时设置taskStatus字段
  796. if (value === '1') {
  797. this.formData.completionTime = new Date();
  798. }
  799. },
  800. // 格式化日期时间
  801. /**
  802. * 日期格式化工具(兼容 iOS 和安卓)
  803. * @param {string|number|Date} date - 日期对象 / 时间戳 / 日期字符串
  804. * @param {string} format - 格式模板,默认 'yyyy-MM-dd HH:mm:ss'
  805. * @returns {string} 格式化后的日期
  806. */
  807. formatDateTime(date, format = 'yyyy-MM-dd HH:mm') {
  808. if (!date) return '';
  809. // 如果是字符串,做 iOS 兼容(将 2025-08-12 替换为 2025/08/12)
  810. if (typeof date === 'string') {
  811. date = date.replace(/-/g, '/');
  812. }
  813. // 如果是数字(时间戳),判断是否是秒级
  814. if (typeof date === 'number') {
  815. if (date.toString().length === 10) {
  816. date *= 1000; // 秒转毫秒
  817. }
  818. }
  819. // 转换为 Date 对象
  820. date = new Date(date);
  821. if (isNaN(date.getTime())) return '';
  822. const map = {
  823. 'yyyy': date.getFullYear(),
  824. 'MM': String(date.getMonth() + 1).padStart(2, '0'),
  825. 'dd': String(date.getDate()).padStart(2, '0'),
  826. 'HH': String(date.getHours()).padStart(2, '0'),
  827. 'mm': String(date.getMinutes()).padStart(2, '0'),
  828. // 'ss': String(date.getSeconds()).padStart(2, '0')
  829. };
  830. return format.replace(/yyyy|MM|dd|HH|mm/g, match => map[match]);
  831. },
  832. // formatDateTime(timestamp) {
  833. // if (!timestamp) return '';
  834. // const date = parseDate(timestamp);
  835. // if (isNaN(date.getTime())) return '';
  836. // const year = date.getFullYear();
  837. // const month = String(date.getMonth() + 1).padStart(2, '0');
  838. // const day = String(date.getDate()).padStart(2, '0');
  839. // const hour = String(date.getHours()).padStart(2, '0');
  840. // const minute = String(date.getMinutes()).padStart(2, '0');
  841. // return `${year}-${month}-${day} ${hour}:${minute}`;
  842. // },
  843. // 选择图片
  844. chooseImage() {
  845. uni.chooseImage({
  846. count: 6 - this.formData.images.length,
  847. sizeType: ['original', 'compressed'],
  848. sourceType: ['album', 'camera'],
  849. success: (res) => {
  850. console.log('选择图片成功:', res);
  851. // 验证文件类型和大小
  852. const validFiles = [];
  853. const invalidFiles = [];
  854. const maxSize = 5 * 1024 * 1024; // 5MB 最大限制
  855. // 检查每个文件
  856. res.tempFiles.forEach((file, index) => {
  857. // 检查文件类型
  858. const isImage = /\.(jpg|jpeg|png|gif)$/i.test(file.name);
  859. // 检查文件大小
  860. const isValidSize = file.size <= maxSize;
  861. if (isImage && isValidSize) {
  862. validFiles.push(res.tempFilePaths[index]);
  863. } else {
  864. invalidFiles.push({
  865. path: file.path,
  866. size: file.size,
  867. reason: !isImage ? '文件格式不支持' : '文件大于5MB'
  868. });
  869. }
  870. });
  871. // 显示无效文件提示
  872. if (invalidFiles.length > 0) {
  873. uni.showToast({
  874. title: `${invalidFiles.length}个文件无效,请检查格式和大小`,
  875. icon: 'none',
  876. duration: 2000
  877. });
  878. }
  879. // 如果有有效文件,则上传
  880. if (validFiles.length > 0) {
  881. this.uploadImages(validFiles);
  882. }
  883. },
  884. fail: (err) => {
  885. console.error('选择图片失败:', err);
  886. uni.showToast({
  887. title: '选择图片失败',
  888. icon: 'none'
  889. });
  890. }
  891. });
  892. },
  893. // 上传图片到服务器
  894. uploadImages(tempFilePaths) {
  895. uni.showLoading({
  896. title: '上传中...',
  897. mask: true
  898. });
  899. // 上传成功的图片计数
  900. let successCount = 0;
  901. let failCount = 0;
  902. const totalFiles = tempFilePaths.length;
  903. const newImages = [];
  904. // 遍历处理每张图片
  905. tempFilePaths.forEach((path, index) => {
  906. // 调用上传API
  907. uni.uploadFile({
  908. // url: api.serve + '/base/tasks/uploadTaskImage',
  909. url: api.serve + '/file/upload',
  910. filePath: path,
  911. name: 'file', // 文件参数名称,需要与后端接口匹配
  912. formData: {
  913. type: 'task', // 标识文件类型,用于后端区分不同业务的文件
  914. // directory: '/opt/app/nongxiaoyu/uploadImage' // 指定保存目录
  915. },
  916. header: {
  917. 'Authorization': `Bearer ${storage.getAccessToken()}`
  918. },
  919. success: (res) => {
  920. try {
  921. const response = JSON.parse(res.data);
  922. uni.showToast({
  923. title: `返回: ${response.data}`,
  924. icon: 'none',
  925. });
  926. if (response.code === 200) {
  927. // 获取返回的URL
  928. const imageUrl = response.data.url;
  929. console.log('上传成功,返回的图片URL:', imageUrl);
  930. // 上传成功,将图片信息添加到数组
  931. newImages.push({
  932. url: imageUrl, // 保存原始URL,在显示时会通过getImageUrl方法处理
  933. path: path, // 保存本地路径用于预览
  934. status: 'success',
  935. fileName: response.data.fileName || '' // 保存文件名,如果后端返回的话
  936. });
  937. successCount++;
  938. } else {
  939. failCount++;
  940. console.error('上传失败:', response.msg);
  941. }
  942. } catch (e) {
  943. failCount++;
  944. uni.showToast({
  945. title: `解析响应失败: ${e}`,
  946. icon: 'none',
  947. });
  948. console.error('解析响应失败:', e);
  949. }
  950. },
  951. fail: (err) => {
  952. failCount++;
  953. console.error('上传请求失败:', err);
  954. uni.showToast({
  955. title: `上传请求失败: ${err}`,
  956. icon: 'none',
  957. });
  958. },
  959. complete: () => {
  960. // 当所有文件都已处理完成
  961. if (successCount + failCount === totalFiles) {
  962. if (newImages.length > 0) {
  963. // 将新上传的图片添加到已有图片列表
  964. this.formData.images = [...this.formData.images, ...newImages];
  965. console.log("this.formData.images",this.formData.images);
  966. // 更新taskImages字段,将图片URL用逗号连接
  967. this.formData.taskImages = this.formData.images.map(img => img.url).join(',');
  968. // 显示成功提示
  969. uni.hideLoading();
  970. uni.showToast({
  971. title: `成功上传${successCount}张图片`,
  972. icon: 'success'
  973. });
  974. } else {
  975. // 全部失败
  976. uni.showToast({
  977. title: `图片上传: ${newImages}`,
  978. icon: 'none',
  979. });
  980. uni.hideLoading();
  981. // uni.showToast({
  982. // title: '图片上传失败',
  983. // icon: 'none',
  984. // });
  985. }
  986. }
  987. }
  988. });
  989. });
  990. },
  991. // 删除图片
  992. deletePic(index) {
  993. uni.showModal({
  994. title: '确认删除',
  995. content: '确定要删除这张图片吗?',
  996. success: (res) => {
  997. if (res.confirm) {
  998. this.formData.images.splice(index, 1);
  999. // 更新taskImages字段
  1000. this.formData.taskImages = this.formData.images.map(img => img.url).join(',');
  1001. uni.showToast({
  1002. title: '已删除',
  1003. icon: 'none'
  1004. });
  1005. }
  1006. }
  1007. });
  1008. },
  1009. // 获取图片URL
  1010. getImageUrl(item) {
  1011. // 默认返回url或path
  1012. return api.upload + item.url;
  1013. },
  1014. // 预览图片
  1015. previewImage(item, index) {
  1016. // 获取所有图片的完整URL
  1017. // const urls = this.formData.images.map(file => this.getImageUrl(file));
  1018. const urls = this.formData.images.map(item => item.url);
  1019. uni.previewImage({
  1020. urls: urls,
  1021. current: index
  1022. });
  1023. },
  1024. // 表单验证
  1025. validateForm() {
  1026. // 重置错误信息
  1027. this.formErrors = {
  1028. completionDesc: ''
  1029. };
  1030. // 基本字段验证
  1031. if (!this.formData.taskName.trim()) {
  1032. uni.showToast({
  1033. title: '请输入任务名称',
  1034. icon: 'none'
  1035. });
  1036. return false;
  1037. }
  1038. if (!this.formData.typeName) {
  1039. uni.showToast({
  1040. title: '请选择任务类型',
  1041. icon: 'none'
  1042. });
  1043. return false;
  1044. }
  1045. // 验证负责人
  1046. if (!this.formData.assigneeId) {
  1047. uni.showToast({
  1048. title: '请选择负责人',
  1049. icon: 'none'
  1050. });
  1051. return false;
  1052. }
  1053. // 新建和编辑模式且已完成状态下的验证
  1054. if ((this.pageMode === 'create' || this.pageMode === 'edit') && this.formData.taskStatus === '1') {
  1055. // 验证完成说明
  1056. if (!this.formData.completionDesc.trim()) {
  1057. this.formErrors.completionDesc = '请填写完成说明';
  1058. uni.showToast({
  1059. title: '请填写完成说明',
  1060. icon: 'none'
  1061. });
  1062. return false;
  1063. }
  1064. // 验证是否上传了图片
  1065. if (!this.formData.images || this.formData.images.length === 0) {
  1066. uni.showToast({
  1067. title: '请上传至少一张现场图片',
  1068. icon: 'none'
  1069. });
  1070. return false;
  1071. }
  1072. }
  1073. return true;
  1074. },
  1075. // 提交表单
  1076. submitForm() {
  1077. if (!this.validateForm()) {
  1078. return;
  1079. }
  1080. this.isSubmitting = true;
  1081. // 构建提交数据
  1082. const submitData = {
  1083. // 如果是编辑模式,需要提供ID
  1084. ...(this.formData.id ? { id: this.formData.id } : {}),
  1085. farmId: this.formData.farmId,
  1086. plotId: this.formData.plotId,
  1087. fieldName: this.formData.fieldName,
  1088. growCrops: this.formData.growCrops,
  1089. taskName: this.formData.taskName,
  1090. taskImages: this.formData.taskImages,
  1091. typeName: this.formData.typeNameId,
  1092. taskStatus: this.formData.taskStatus,
  1093. executeTime: this.formatDateTime(this.formData.executeTime),
  1094. assigneeId: this.formData.assigneeId,
  1095. assigneeName:this.formData.assigneeName,
  1096. remark: this.formData.remark,
  1097. completionTime: this.formData.taskStatus === '1' ? this.formatDateTime(this.formData.completionTime) : null,
  1098. completionDesc: this.formData.taskStatus === '1' ? this.formData.completionDesc : null,
  1099. create_by: this.formData.create_by || null
  1100. };
  1101. console.log('提交数据:', submitData);
  1102. uni.showLoading({
  1103. title: '提交中...',
  1104. mask: true
  1105. });
  1106. // 根据模式决定是创建还是更新
  1107. const requestPromise = this.pageMode === 'create'
  1108. ? addAgriculturalTask(submitData)
  1109. : updateAgriculturalTask(submitData);
  1110. requestPromise.then(res => {
  1111. this.isSubmitting = false;
  1112. uni.hideLoading();
  1113. if (res.data.code === 200) {
  1114. const successMessage = this.pageMode === 'create' ? '任务创建成功' : '保存修改成功';
  1115. uni.showToast({
  1116. title: successMessage,
  1117. icon: 'success',
  1118. duration: 1500
  1119. });
  1120. setTimeout(() => {
  1121. uni.navigateBack();
  1122. }, 1500);
  1123. } else {
  1124. uni.showToast({
  1125. title: res.data.msg || '操作失败',
  1126. icon: 'none'
  1127. });
  1128. }
  1129. }).catch(err => {
  1130. console.error('提交表单失败:', err);
  1131. this.isSubmitting = false;
  1132. uni.hideLoading();
  1133. uni.showToast({
  1134. title: '操作失败,请稍后重试',
  1135. icon: 'none'
  1136. });
  1137. });
  1138. }
  1139. }
  1140. }
  1141. </script>
  1142. <style scoped>
  1143. .page-container {
  1144. height: 100vh;
  1145. background-color: #F5F5F5;
  1146. display: flex;
  1147. flex-direction: column;
  1148. }
  1149. .page-scroll {
  1150. flex: 1;
  1151. overflow: hidden;
  1152. }
  1153. /* 地块基础信息卡片 */
  1154. .info-card {
  1155. background: #F9F9F9;
  1156. margin: 24rpx;
  1157. padding: 24rpx;
  1158. border-radius: 8rpx;
  1159. border: 1rpx solid #E5E5E5;
  1160. }
  1161. .card-title {
  1162. font-size: 30rpx;
  1163. font-weight: 600;
  1164. color: #333333;
  1165. margin-bottom: 16rpx;
  1166. padding-bottom: 12rpx;
  1167. border-bottom: 1rpx solid #E5E5E5;
  1168. }
  1169. .info-item {
  1170. display: flex;
  1171. justify-content: space-between;
  1172. align-items: center;
  1173. margin-bottom: 12rpx;
  1174. padding: 8rpx 0;
  1175. }
  1176. .info-item:last-child {
  1177. margin-bottom: 0;
  1178. }
  1179. .info-label {
  1180. font-size: 28rpx;
  1181. color: #666666;
  1182. flex-shrink: 0;
  1183. }
  1184. .info-value {
  1185. font-size: 28rpx;
  1186. color: #333333;
  1187. font-weight: 500;
  1188. }
  1189. /* 任务填写表单 */
  1190. .form-card {
  1191. background: #FFFFFF;
  1192. margin: 0 24rpx 24rpx;
  1193. padding: 24rpx;
  1194. border-radius: 8rpx;
  1195. border: 1rpx solid #E5E5E5;
  1196. }
  1197. .section-divider {
  1198. height: 1rpx;
  1199. background: #F0F0F0;
  1200. margin: 32rpx 0 24rpx;
  1201. }
  1202. .section-title {
  1203. font-size: 30rpx;
  1204. font-weight: 600;
  1205. color: #333333;
  1206. margin-bottom: 16rpx;
  1207. padding-bottom: 12rpx;
  1208. border-bottom: 1rpx solid #F0F0F0;
  1209. }
  1210. .form-item {
  1211. margin-bottom: 24rpx;
  1212. }
  1213. .form-item:last-child {
  1214. margin-bottom: 0;
  1215. }
  1216. .form-label {
  1217. font-size: 28rpx;
  1218. color: #333333;
  1219. margin-bottom: 12rpx;
  1220. font-weight: 500;
  1221. }
  1222. .form-label.required::before {
  1223. content: '*';
  1224. color: #FF6B6B;
  1225. margin-right: 4rpx;
  1226. }
  1227. .form-input {
  1228. width: 100%;
  1229. line-height: 80rpx;
  1230. height: 80rpx;
  1231. background: #F8F8F8;
  1232. border: 1rpx solid #E5E5E5;
  1233. border-radius: 8rpx;
  1234. padding: 0 16rpx;
  1235. font-size: 28rpx;
  1236. color: #333333;
  1237. box-sizing: border-box;
  1238. }
  1239. .form-input:focus {
  1240. background: #FFFFFF;
  1241. border-color: #3BB44A;
  1242. }
  1243. .form-input::placeholder {
  1244. color: #CCCCCC;
  1245. }
  1246. .form-input:disabled {
  1247. background: #F8F8F8;
  1248. color: #999999;
  1249. }
  1250. .select-wrapper {
  1251. position: relative;
  1252. width: 100%;
  1253. }
  1254. .select-input {
  1255. cursor: pointer;
  1256. }
  1257. .select-arrow {
  1258. position: absolute;
  1259. right: 16rpx;
  1260. top: 50%;
  1261. transform: translateY(-50%);
  1262. color: #999999;
  1263. font-size: 20rpx;
  1264. pointer-events: none;
  1265. }
  1266. .form-textarea {
  1267. width: 100%;
  1268. min-height: 120rpx;
  1269. background: #F8F8F8;
  1270. border: 1rpx solid #E5E5E5;
  1271. border-radius: 8rpx;
  1272. padding: 16rpx;
  1273. font-size: 28rpx;
  1274. color: #333333;
  1275. box-sizing: border-box;
  1276. resize: none;
  1277. line-height: 1.5;
  1278. }
  1279. .form-textarea:focus {
  1280. background: #FFFFFF;
  1281. border-color: #3BB44A;
  1282. }
  1283. .form-textarea::placeholder {
  1284. color: #CCCCCC;
  1285. }
  1286. .form-textarea:disabled {
  1287. background: #F8F8F8;
  1288. color: #999999;
  1289. }
  1290. .char-count {
  1291. font-size: 24rpx;
  1292. color: #CCCCCC;
  1293. text-align: right;
  1294. margin-top: 8rpx;
  1295. }
  1296. .form-error {
  1297. font-size: 24rpx;
  1298. color: #FF6B6B;
  1299. margin-top: 8rpx;
  1300. }
  1301. /* 单选按钮样式 */
  1302. .radio-group {
  1303. display: flex;
  1304. gap: 32rpx;
  1305. }
  1306. .radio-item {
  1307. display: flex;
  1308. align-items: center;
  1309. cursor: pointer;
  1310. }
  1311. .radio-circle {
  1312. width: 32rpx;
  1313. height: 32rpx;
  1314. border: 2rpx solid #CCCCCC;
  1315. border-radius: 50%;
  1316. display: flex;
  1317. align-items: center;
  1318. justify-content: center;
  1319. margin-right: 8rpx;
  1320. }
  1321. .radio-circle.radio-checked {
  1322. border-color: #3BB44A;
  1323. background-color: #3BB44A;
  1324. }
  1325. .radio-dot {
  1326. width: 12rpx;
  1327. height: 12rpx;
  1328. background-color: #FFFFFF;
  1329. border-radius: 50%;
  1330. }
  1331. .radio-label {
  1332. font-size: 28rpx;
  1333. color: #333333;
  1334. }
  1335. /* 完成状态样式 */
  1336. .status-completed {
  1337. display: flex;
  1338. align-items: center;
  1339. color: #3BB44A;
  1340. font-size: 28rpx;
  1341. }
  1342. .status-icon {
  1343. width: 32rpx;
  1344. height: 32rpx;
  1345. background: #3BB44A;
  1346. color: #FFFFFF;
  1347. border-radius: 50%;
  1348. display: flex;
  1349. align-items: center;
  1350. justify-content: center;
  1351. margin-right: 8rpx;
  1352. font-size: 20rpx;
  1353. line-height: 1;
  1354. }
  1355. /* 图片上传样式 */
  1356. .image-upload, .image-view {
  1357. width: 100%;
  1358. }
  1359. .image-list {
  1360. display: flex;
  1361. flex-wrap: wrap;
  1362. gap: 16rpx;
  1363. }
  1364. .image-preview {
  1365. position: relative;
  1366. width: 160rpx;
  1367. height: 160rpx;
  1368. border-radius: 8rpx;
  1369. overflow: hidden;
  1370. background: #F5F5F5;
  1371. }
  1372. .image-preview image {
  1373. width: 100%;
  1374. height: 100%;
  1375. }
  1376. .delete-btn {
  1377. position: absolute;
  1378. top: -6rpx;
  1379. right: -6rpx;
  1380. width: 32rpx;
  1381. height: 32rpx;
  1382. background: rgba(0, 0, 0, 0.6);
  1383. color: #FFFFFF;
  1384. border-radius: 50%;
  1385. display: flex;
  1386. align-items: center;
  1387. justify-content: center;
  1388. font-size: 20rpx;
  1389. line-height: 1;
  1390. }
  1391. .upload-btn {
  1392. width: 160rpx;
  1393. height: 160rpx;
  1394. background: #F8F8F8;
  1395. border: 2rpx dashed #DDDDDD;
  1396. border-radius: 8rpx;
  1397. display: flex;
  1398. flex-direction: column;
  1399. align-items: center;
  1400. justify-content: center;
  1401. }
  1402. .upload-icon {
  1403. font-size: 32rpx;
  1404. margin-bottom: 8rpx;
  1405. color: #999999;
  1406. }
  1407. .upload-text {
  1408. font-size: 24rpx;
  1409. color: #999999;
  1410. }
  1411. .upload-tip {
  1412. font-size: 24rpx;
  1413. color: #999999;
  1414. margin-top: 12rpx;
  1415. }
  1416. .no-images {
  1417. padding: 40rpx 0;
  1418. text-align: center;
  1419. color: #CCCCCC;
  1420. font-size: 28rpx;
  1421. }
  1422. /* 底部安全区域 */
  1423. .bottom-safe {
  1424. height: 120rpx;
  1425. }
  1426. .footer-safe {
  1427. background: #FFFFFF;
  1428. border-top: 1rpx solid #E5E5E5;
  1429. padding-bottom: constant(safe-area-inset-bottom);
  1430. padding-bottom: env(safe-area-inset-bottom);
  1431. }
  1432. .footer-content {
  1433. padding: 24rpx;
  1434. }
  1435. .submit-button {
  1436. width: 100%;
  1437. height: 88rpx;
  1438. background: #3BB44A;
  1439. color: #FFFFFF;
  1440. border: none;
  1441. border-radius: 8rpx;
  1442. font-size: 32rpx;
  1443. font-weight: 600;
  1444. display: flex;
  1445. align-items: center;
  1446. justify-content: center;
  1447. }
  1448. .submit-button:active {
  1449. background: #2D8C3C;
  1450. }
  1451. .submit-button:disabled,
  1452. .submit-button.loading {
  1453. background: #CCCCCC;
  1454. }
  1455. /* 选择器弹窗样式 */
  1456. .picker-mask {
  1457. position: fixed;
  1458. top: 0;
  1459. left: 0;
  1460. width: 100%;
  1461. height: 100%;
  1462. background: rgba(0, 0, 0, 0.5);
  1463. z-index: 999;
  1464. }
  1465. .picker-popup {
  1466. position: fixed;
  1467. bottom: 0;
  1468. left: 0;
  1469. width: 100%;
  1470. background: #FFFFFF;
  1471. border-radius: 16rpx 16rpx 0 0;
  1472. z-index: 1000;
  1473. padding-bottom: constant(safe-area-inset-bottom);
  1474. padding-bottom: env(safe-area-inset-bottom);
  1475. }
  1476. .picker-header {
  1477. display: flex;
  1478. justify-content: space-between;
  1479. align-items: center;
  1480. padding: 24rpx;
  1481. border-bottom: 1rpx solid #E5E5E5;
  1482. }
  1483. .picker-cancel, .picker-confirm {
  1484. font-size: 30rpx;
  1485. color: #3BB44A;
  1486. }
  1487. .picker-title {
  1488. font-size: 32rpx;
  1489. font-weight: 600;
  1490. color: #333333;
  1491. }
  1492. .picker-content {
  1493. max-height: 400rpx;
  1494. overflow-y: auto;
  1495. }
  1496. .picker-item {
  1497. display: flex;
  1498. justify-content: space-between;
  1499. align-items: center;
  1500. padding: 24rpx;
  1501. border-bottom: 1rpx solid #F0F0F0;
  1502. font-size: 30rpx;
  1503. color: #333333;
  1504. }
  1505. .picker-item.selected {
  1506. color: #3BB44A;
  1507. }
  1508. .picker-item:last-child {
  1509. border-bottom: none;
  1510. }
  1511. .check-mark {
  1512. color: #3BB44A;
  1513. font-size: 28rpx;
  1514. }
  1515. /* 日期时间选择器样式 */
  1516. .datetime-picker {
  1517. height: 60vh;
  1518. }
  1519. .datetime-picker-content {
  1520. height: calc(100% - 100rpx);
  1521. padding: 0;
  1522. }
  1523. .datetime-picker-view {
  1524. width: 100%;
  1525. height: 100%;
  1526. }
  1527. .picker-view-item {
  1528. display: flex;
  1529. align-items: center;
  1530. justify-content: center;
  1531. height: 80rpx;
  1532. font-size: 32rpx;
  1533. color: #333333;
  1534. }
  1535. .picker-item-text {
  1536. font-size: 32rpx;
  1537. color: #333333;
  1538. line-height: 80rpx;
  1539. height: 80rpx;
  1540. text-align: center;
  1541. }
  1542. /* 添加加载中样式 */
  1543. .picker-loading {
  1544. display: flex;
  1545. justify-content: center;
  1546. align-items: center;
  1547. padding: 30rpx 0;
  1548. color: #999;
  1549. font-size: 28rpx;
  1550. }
  1551. .picker-empty {
  1552. padding: 30rpx 0;
  1553. text-align: center;
  1554. color: #CCCCCC;
  1555. font-size: 28rpx;
  1556. }
  1557. </style>