activity-detail.vue 50 KB

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