taskEdit.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <template>
  2. <uni-forms ref="taskForm" :modelValue="taskFormData" :label-width="250" label-position="top" :rules="taskFormRules">
  3. <!-- 基本描述 -->
  4. <uni-section title="基本描述" padding="16px" type="line">
  5. <uni-forms-item label="任务名称" required name="taskName">
  6. <uni-easyinput v-model="taskFormData.taskName" placeholder="请输入任务名称" />
  7. </uni-forms-item>
  8. <uni-forms-item label="规则描述" name="description">
  9. <uni-easyinput type="textarea" v-model="taskFormData.description" placeholder="请输入任务描述" />
  10. </uni-forms-item>
  11. </uni-section>
  12. <!-- 显示配置 -->
  13. <uni-section title="显示配置" padding="16px" type="line">
  14. <uni-forms-item label="显示顺序" required name="displayOrder">
  15. <uni-easyinput v-model="taskFormData.displayOrder" placeholder="显示顺序" type="number" />
  16. </uni-forms-item>
  17. <uni-forms-item label="开始显示时间" required name="displayTime">
  18. <picker mode="time" :value="taskFormData.displayTime" @change="displayTimeChange">
  19. <view class="pick-box">{{ taskFormData.displayTime }}</view>
  20. </picker>
  21. </uni-forms-item>
  22. </uni-section>
  23. <!-- 重复配置 -->
  24. <uni-section title="重复配置" padding="16px" type="line">
  25. <uni-forms-item label="重复周期类型" required name="repeatCategory">
  26. <uni-data-select :localdata="repeatCategorySelectedData"
  27. v-model="taskFormData.repeatCategory"></uni-data-select>
  28. </uni-forms-item>
  29. <uni-forms-item label="自定义重复日" required name="repeatCustomDay"
  30. v-if="taskFormData.repeatCategory == REPEAT_CATEGORY.CUSTOM">
  31. <uni-data-checkbox multiple :localdata="repeatCustomDaySelectedData"
  32. v-model="taskFormData.repeatCustomDay"></uni-data-checkbox>
  33. </uni-forms-item>
  34. </uni-section>
  35. <!-- 打卡配置 -->
  36. <uni-section title="打卡配置" padding="16px" type="line">
  37. <uni-forms-item label="打卡方式" required name="punchInMethod">
  38. <uni-data-select :localdata="punchInMethodSelectedData" v-model="taskFormData.punchInMethod"></uni-data-select>
  39. </uni-forms-item>
  40. <uni-forms-item label="判断规则" required name="compareRule"
  41. v-if="taskFormData.punchInMethod == PUNCH_IN_METHOD.COUNT || taskFormData.punchInMethod == PUNCH_IN_METHOD.TIMING">
  42. <uni-data-select :localdata="compareRuleSelectedData" v-model="taskFormData.compareRule"></uni-data-select>
  43. </uni-forms-item>
  44. <uni-forms-item label="数值" required name="countTrack" v-if="taskFormData.punchInMethod == PUNCH_IN_METHOD.COUNT">
  45. <uni-easyinput v-model="taskFormData.countTrack" placeholder="请输入目标数值" type="digit" />
  46. </uni-forms-item>
  47. <uni-forms-item label="时间" required name="timeTrack" v-if="taskFormData.punchInMethod == PUNCH_IN_METHOD.TIMING">
  48. <picker mode="time" :value="taskFormData.timeTrack" @change="timeChange">
  49. <view class="pick-box">{{ taskFormData.timeTrack }}</view>
  50. </picker>
  51. </uni-forms-item>
  52. </uni-section>
  53. <!-- 积分配置 -->
  54. <uni-section title="积分配置" padding="16px" type="line">
  55. <uni-forms-item label="奖励积分(基本)" required name="points">
  56. <uni-easyinput v-model="taskFormData.points" placeholder="请输入奖励积分(基本)" type="number" />
  57. </uni-forms-item>
  58. <uni-forms-item label="额外奖励方式" required name="extraMethod">
  59. <uni-data-select :localdata="extraMethodSelectedData" v-model="taskFormData.extraMethod"></uni-data-select>
  60. </uni-forms-item>
  61. <uni-forms-item label="额外的时间间隔(单位:分钟)" required name="extraTimeStep"
  62. v-if="taskFormData.extraMethod != EXTRA_METHOD.NONE && taskFormData.punchInMethod == PUNCH_IN_METHOD.TIMING">
  63. <uni-easyinput v-model="taskFormData.extraTimeStep" placeholder="额外的时间间隔(单位:分钟)" type="number" />
  64. </uni-forms-item>
  65. <uni-forms-item label="奖励的积分(额外)" required name="extraPoints"
  66. v-if="taskFormData.extraMethod == EXTRA_METHOD.FIXED">
  67. <uni-easyinput v-model="taskFormData.extraPoints" placeholder="奖励的积分(额外)" type="number" />
  68. </uni-forms-item>
  69. <uni-forms-item label="积分区间" required :rules="[{ 'required': true, errorMessage: '起始值必填' }]"
  70. :name="['taskExtList', index, 'extraPoints', 'value']" v-if="taskFormData.extraMethod == EXTRA_METHOD.INTERVAL">
  71. <template v-for="(item, index) in taskFormData.taskExtList" :key="item.id">
  72. <view class="extra-box">
  73. <view class="extra-box-item">
  74. <uni-easyinput v-model="taskFormData.taskExtList[index].initialValue.value" placeholder="请输入起始值" />
  75. </view>
  76. <view class="extra-box-item">
  77. <uni-easyinput v-model="taskFormData.taskExtList[index].extraPoints.value" placeholder="请输入奖励积分" />
  78. </view>
  79. <button class="button extra-box-btn" size="mini" type="default" @click="deleteTaskExt(item.id)">删除</button>
  80. </view>
  81. </template>
  82. </uni-forms-item>
  83. <button type="primary" size="mini" @click="addTaskExt()"
  84. v-if="taskFormData.extraMethod == EXTRA_METHOD.INTERVAL">新增拓展信息</button>
  85. </uni-section>
  86. <!-- 节假日配置 -->
  87. <uni-section title="节假日配置" padding="16px" type="line">
  88. <uni-forms-item label="节假日双倍" required name="holidayStatus">
  89. <uni-data-select v-model="taskFormData.holidayStatus"
  90. :localdata="commonEnabledStatusSelectedData"></uni-data-select>
  91. </uni-forms-item>
  92. <uni-forms-item label="数值(节假日)" required name="holidayCountTrack"
  93. v-if="taskFormData.holidayStatus == COMMON_ENABLED_STATUS.ENABLED && taskFormData.punchInMethod == PUNCH_IN_METHOD.COUNT">
  94. <uni-easyinput v-model="taskFormData.holidayCountTrack" placeholder="请输入目标数值" type="digit" />
  95. </uni-forms-item>
  96. <uni-forms-item label="时间(节假日)" required name="holidayTimeTrack"
  97. v-if="taskFormData.holidayStatus == COMMON_ENABLED_STATUS.ENABLED && taskFormData.punchInMethod == PUNCH_IN_METHOD.TIMING">
  98. <picker mode="time" :value="taskFormData.holidayTimeTrack" @change="holidayTimeChange">
  99. <view class="pick-box">{{ taskFormData.holidayTimeTrack }}</view>
  100. </picker>
  101. </uni-forms-item>
  102. </uni-section>
  103. <!-- 全勤配置 -->
  104. <uni-section title="全勤配置" padding="16px" type="line">
  105. <uni-forms-item label="全勤双倍" required name="fullAttendanceStatus">
  106. <uni-data-select v-model="taskFormData.fullAttendanceStatus"
  107. :localdata="commonEnabledStatusSelectedData"></uni-data-select>
  108. </uni-forms-item>
  109. <uni-forms-item label="全勤周期" required name="fullAttendancePeriod"
  110. v-if="taskFormData.fullAttendanceStatus == COMMON_ENABLED_STATUS.ENABLED">
  111. <uni-data-select :localdata="fullAttendancePeriodSelectedData"
  112. v-model="taskFormData.fullAttendancePeriod"></uni-data-select>
  113. </uni-forms-item>
  114. <uni-forms-item label="容错次数" required name="fullAttendancefaulttoleranceCnt"
  115. v-if="taskFormData.fullAttendanceStatus == COMMON_ENABLED_STATUS.ENABLED">
  116. <uni-easyinput v-model="taskFormData.fullAttendancefaulttoleranceCnt" placeholder="请输入目标数值" type="digit" />
  117. </uni-forms-item>
  118. </uni-section>
  119. <!-- 连续规则配置 -->
  120. <uni-section title="连续规则配置" padding="16px" type="line">
  121. <uni-forms-item label="是否启用连续规则" required name="continueStatus">
  122. <uni-data-select :localdata="commonEnabledStatusSelectedData"
  123. v-model="taskFormData.continueStatus"></uni-data-select>
  124. </uni-forms-item>
  125. <uni-forms-item label="宽限期(单位:天)" required name="graceDay"
  126. v-if="taskFormData.continueStatus == COMMON_ENABLED_STATUS.ENABLED">
  127. <uni-easyinput v-model="taskFormData.graceDay" placeholder="宽限期(单位:天)" type="number" />
  128. </uni-forms-item>
  129. <uni-forms-item label="连续中断次数" required name="continueInterruptedCount"
  130. v-if="taskFormData.continueStatus == COMMON_ENABLED_STATUS.ENABLED">
  131. <uni-easyinput v-model="taskFormData.continueInterruptedCount" placeholder="连续中断次数" type="number" />
  132. </uni-forms-item>
  133. <uni-forms-item label="惩罚天数(单位:天)" required name="penaltyDay"
  134. v-if="taskFormData.continueStatus == COMMON_ENABLED_STATUS.ENABLED">
  135. <uni-easyinput v-model="taskFormData.penaltyDay" placeholder="惩罚天数(单位:天)" type="number" />
  136. </uni-forms-item>
  137. </uni-section>
  138. <!-- 任务整体配置 -->
  139. <uni-section title="任务整体配置" padding="16px" type="line">
  140. <uni-forms-item label="任务自动归档时间(结束)" name="endDate">
  141. <uni-datetime-picker type="date" return-type="date" v-model="taskFormData.endDate" />
  142. </uni-forms-item>
  143. <uni-forms-item label="是否启用自动打卡" required name="autoStatus">
  144. <uni-data-select :localdata="commonEnabledStatusSelectedData"
  145. v-model="taskFormData.autoStatus"></uni-data-select>
  146. </uni-forms-item>
  147. <uni-forms-item label="是否启用任务积分计算" required name="taskPointsStatus">
  148. <uni-data-select :localdata="commonEnabledStatusSelectedData"
  149. v-model="taskFormData.taskPointsStatus"></uni-data-select>
  150. </uni-forms-item>
  151. <uni-forms-item label="积分区间" required :rules="[{ 'required': true, errorMessage: '起始值必填' }]"
  152. :name="['continueTaskExtList', index, 'extraPoints', 'value']"
  153. v-if="taskFormData.taskPointsStatus == COMMON_ENABLED_STATUS.ENABLED">
  154. <template v-for="(item, index) in taskFormData.continueTaskExtList" :key="item.id">
  155. <view class="extra-box">
  156. <view class="extra-box-item">
  157. <uni-easyinput v-model="taskFormData.continueTaskExtList[index].initialValue.value"
  158. placeholder="请输入起始值" />
  159. </view>
  160. <view class="extra-box-item">
  161. <uni-easyinput v-model="taskFormData.continueTaskExtList[index].extraPoints.value"
  162. placeholder="请输入奖励积分" />
  163. </view>
  164. <button class="button extra-box-btn" size="mini" type="default"
  165. @click="deleteContinueTaskExt(item.id)">删除</button>
  166. </view>
  167. </template>
  168. </uni-forms-item>
  169. <button type="primary" size="mini" @click="addContinueTaskExt()"
  170. v-if="taskFormData.taskPointsStatus == COMMON_ENABLED_STATUS.ENABLED">新增拓展信息</button>
  171. </uni-section>
  172. <!-- 按钮组 -->
  173. <view class="button-container">
  174. <button type="default" style="width:300rpx;" @click="cancel()">取消</button>
  175. <button type="primary" style="color:#ffffff;backgroundColor:#2A82E4;width:300rpx;" @click="saveTask()">保存</button>
  176. </view>
  177. </uni-forms>
  178. </template>
  179. <script setup>
  180. import { ref } from 'vue';
  181. import { onLoad } from '@dcloudio/uni-app';
  182. import { punchInApi } from '@/apis/apis';
  183. import { PUNCH_IN_METHOD, COMMON_ENABLED_STATUS, COMPARE_RULE, EXTRA_METHOD, REPEAT_CATEGORY } from '@/common/enums';
  184. // 组件
  185. /**
  186. * 打卡任务表单
  187. */
  188. const taskForm = ref(null);
  189. // 属性
  190. /**
  191. * 打卡任务表单数据
  192. */
  193. const taskFormData = ref({
  194. "repeatCategory": REPEAT_CATEGORY.EVERYDAY,
  195. "punchInMethod": PUNCH_IN_METHOD.SINGLE,
  196. "extraMethod": EXTRA_METHOD.NONE,
  197. "holidayStatus": COMMON_ENABLED_STATUS.DISABLED,
  198. "fullAttendanceStatus": COMMON_ENABLED_STATUS.DISABLED,
  199. "continueStatus": COMMON_ENABLED_STATUS.DISABLED,
  200. "autoStatus": COMMON_ENABLED_STATUS.DISABLED,
  201. "taskPointsStatus": COMMON_ENABLED_STATUS.DISABLED,
  202. "taskExtList": [],
  203. "continueTaskExtList": []
  204. });
  205. /**
  206. * 打卡任务表单规则
  207. */
  208. const taskFormRules = ref({
  209. taskName: {
  210. rules: [{
  211. required: true,
  212. errorMessage: '任务名称不能为空'
  213. },
  214. {
  215. minLength: 2,
  216. maxLength: 30,
  217. errorMessage: '长度在 {minLength} 到 {maxLength} 个字符',
  218. }]
  219. },
  220. description: {
  221. rules: [{
  222. maxLength: 100,
  223. errorMessage: '描述不能超过 {maxLength} 个字符'
  224. }]
  225. },
  226. displayOrder: {
  227. rules: [{
  228. required: true,
  229. errorMessage: '显示顺序不能为空'
  230. }, {
  231. format: 'number',
  232. errorMessage: "请输入有效数字"
  233. }, {
  234. minimum: 1,
  235. errorMessage: "最小值{minimum}"
  236. }]
  237. },
  238. displayTime: {
  239. rules: [{
  240. required: true,
  241. errorMessage: '显示时间不能为空'
  242. }]
  243. },
  244. repeatCategory: {
  245. rules: [{
  246. required: true,
  247. errorMessage: '重复类型不能为空'
  248. }]
  249. },
  250. punchInMethod: {
  251. rules: [{
  252. required: true,
  253. errorMessage: '打卡方式不能为空'
  254. }]
  255. },
  256. compareRule: {
  257. rules: [{
  258. required: true,
  259. errorMessage: '比较规则不能为空'
  260. }]
  261. },
  262. countTrack: {
  263. rules: [{
  264. required: true,
  265. errorMessage: '数值不能为空'
  266. }, {
  267. format: 'number',
  268. errorMessage: "请输入有效数字"
  269. }, {
  270. minimum: 1,
  271. errorMessage: "最小值{minimum}"
  272. }]
  273. },
  274. timeTrack: {
  275. rules: [{
  276. required: true,
  277. errorMessage: '数值不能为空'
  278. }]
  279. },
  280. points: {
  281. rules: [{
  282. required: true,
  283. errorMessage: '奖励积分不能为空'
  284. }, {
  285. format: 'number',
  286. errorMessage: "请输入有效数字"
  287. }, {
  288. minimum: 1,
  289. errorMessage: "最小值{minimum}"
  290. }]
  291. },
  292. extraMethod: {
  293. rules: [{
  294. required: true,
  295. errorMessage: '额外奖励方式不能为空'
  296. }]
  297. },
  298. extraTimeStep: {
  299. rules: [{
  300. required: true,
  301. errorMessage: '额外的时间间隔方式不能为空'
  302. }, {
  303. format: 'number',
  304. errorMessage: "请输入有效数字"
  305. }, {
  306. minimum: 1,
  307. errorMessage: "最小值{minimum}"
  308. }]
  309. },
  310. extraPoints: {
  311. rules: [{
  312. required: true,
  313. errorMessage: '奖励的积分(额外)不能为空'
  314. }, {
  315. format: 'number',
  316. errorMessage: "请输入有效数字"
  317. }, {
  318. minimum: 1,
  319. errorMessage: "最小值{minimum}"
  320. }]
  321. },
  322. taskExtList: {
  323. rules: [{
  324. required: true,
  325. errorMessage: '积分区间不能为空'
  326. }]
  327. },
  328. holidayStatus: {
  329. rules: [{
  330. required: true,
  331. errorMessage: '节假日双倍不能为空'
  332. }]
  333. },
  334. holidayCountTrack: {
  335. rules: [{
  336. required: true,
  337. errorMessage: '数值不能为空'
  338. }, {
  339. format: 'number',
  340. errorMessage: "请输入有效数字"
  341. }, {
  342. minimum: 1,
  343. errorMessage: "最小值{minimum}"
  344. }]
  345. },
  346. holidayTimeTrack: {
  347. rules: [{
  348. required: true,
  349. errorMessage: '时间不能为空'
  350. }]
  351. },
  352. fullAttendanceStatus: {
  353. rules: [{
  354. required: true,
  355. errorMessage: '全勤奖励不能为空'
  356. }]
  357. },
  358. fullAttendancePeriod: {
  359. rules: [{
  360. required: true,
  361. errorMessage: '全勤周期不能为空'
  362. }]
  363. },
  364. fullAttendancefaulttoleranceCnt: {
  365. rules: [{
  366. required: true,
  367. errorMessage: '数值不能为空'
  368. }, {
  369. format: 'number',
  370. errorMessage: "请输入有效数字"
  371. }, {
  372. minimum: 1,
  373. errorMessage: "最小值{minimum}"
  374. }]
  375. },
  376. continueStatus: {
  377. rules: [{
  378. required: true,
  379. errorMessage: '是否启用连续规则不能为空'
  380. }]
  381. },
  382. graceDay: {
  383. rules: [{
  384. required: true,
  385. errorMessage: '数值不能为空'
  386. }, {
  387. format: 'number',
  388. errorMessage: "请输入有效数字"
  389. }, {
  390. minimum: 1,
  391. errorMessage: "最小值{minimum}"
  392. }]
  393. },
  394. continueInterruptedCount: {
  395. rules: [{
  396. required: true,
  397. errorMessage: '数值不能为空'
  398. }, {
  399. format: 'number',
  400. errorMessage: "请输入有效数字"
  401. }, {
  402. minimum: 1,
  403. errorMessage: "最小值{minimum}"
  404. }]
  405. },
  406. penaltyDay: {
  407. rules: [{
  408. required: true,
  409. errorMessage: '数值不能为空'
  410. }, {
  411. format: 'number',
  412. errorMessage: "请输入有效数字"
  413. }, {
  414. minimum: 1,
  415. errorMessage: "最小值{minimum}"
  416. }]
  417. },
  418. autoStatus: {
  419. rules: [{
  420. required: true,
  421. errorMessage: '是否启用自动打卡不能为空'
  422. }]
  423. },
  424. taskPointsStatus: {
  425. rules: [{
  426. required: true,
  427. errorMessage: '是否启用任务积分计算不能为空'
  428. }]
  429. },
  430. continueTaskPointsStatus: {
  431. rules: [{
  432. required: true,
  433. errorMessage: '是否启用任务积分计算不能为空'
  434. }]
  435. }
  436. });
  437. /**
  438. * 通用启用状态 下拉选择数据
  439. */
  440. const commonEnabledStatusSelectedData = ref([{
  441. "text": "启用",
  442. "value": 'ENABLED'
  443. }, {
  444. "text": "禁用",
  445. "value": 'DISABLED'
  446. }]);
  447. /**
  448. * 打卡方式 下拉选择数据
  449. */
  450. const punchInMethodSelectedData = ref([{
  451. "text": "单次打卡",
  452. "value": 'SINGLE'
  453. }, {
  454. "text": "计数",
  455. "value": 'COUNT'
  456. }, {
  457. "text": "计时",
  458. "value": 'TIMING'
  459. }]);
  460. /**
  461. * 比较规则 下拉选择数据
  462. */
  463. const compareRuleSelectedData = ref([{
  464. "text": "大于等于",
  465. "value": 'GTE'
  466. }, {
  467. "text": "小于等于",
  468. "value": 'LTE'
  469. }]);
  470. /**
  471. * 全勤周期 下拉选择数据
  472. */
  473. const fullAttendancePeriodSelectedData = ref([{
  474. "text": "周",
  475. "value": 'WEEK'
  476. }, {
  477. "text": "月",
  478. "value": 'MONTH'
  479. }]);
  480. /**
  481. * 重复周期类型 下拉选择数据
  482. */
  483. const repeatCategorySelectedData = ref([{
  484. "text": "每日",
  485. "value": 'EVERYDAY'
  486. }, {
  487. "text": "法定工作日",
  488. "value": 'WORKDAY'
  489. }, {
  490. "text": "法定节假日(含周末)",
  491. "value": 'HOLIDAY'
  492. }, {
  493. "text": "自定义(周一至周日)",
  494. "value": 'CUSTOM'
  495. }]);
  496. /**
  497. * 自定义重复日 下拉选择数据
  498. */
  499. const repeatCustomDaySelectedData = ref([{
  500. "text": "周一",
  501. "value": '1'
  502. }, {
  503. "text": "周二",
  504. "value": '2'
  505. }, {
  506. "text": "周三",
  507. "value": '3'
  508. }, {
  509. "text": "周四",
  510. "value": '4'
  511. }, {
  512. "text": "周五",
  513. "value": '5'
  514. }, {
  515. "text": "周六",
  516. "value": '6'
  517. }, {
  518. "text": "周日",
  519. "value": '7'
  520. }]);
  521. /**
  522. * 额外奖励方式 下拉选择数据
  523. */
  524. const extraMethodSelectedData = ref([{
  525. "text": "无",
  526. "value": 'NONE'
  527. }, {
  528. "text": "固定",
  529. "value": 'FIXED'
  530. }, {
  531. "text": "区间",
  532. "value": 'INTERVAL'
  533. }]);
  534. // 方法
  535. /**
  536. * 时间选择监听
  537. */
  538. const timeChange = (e) => {
  539. taskFormData.value.timeTrack = e.detail.value;
  540. }
  541. /**
  542. * 显示时间 时间选择监听
  543. */
  544. const displayTimeChange = (e) => {
  545. taskFormData.value.displayTIme = e.detail.value;
  546. }
  547. /**
  548. * 节假日时间 时间选择监听
  549. */
  550. const holidayTimeChange = (e) => {
  551. taskFormData.value.holidayTimeTrack = e.detail.value;
  552. }
  553. /**
  554. * 新增任务拓展信息
  555. */
  556. const addTaskExt = () => {
  557. taskFormData.value.taskExtList.push({
  558. id: Date.now(),
  559. "initialValue": {
  560. label: '起始值',
  561. value: ''
  562. },
  563. "extraPoints": {
  564. label: '奖励的积分(额外)',
  565. value: ''
  566. }
  567. })
  568. }
  569. /**
  570. * 删除任务拓展信息
  571. */
  572. const deleteTaskExt = (id) => {
  573. let index = taskFormData.value.taskExtList.findIndex(v => v.id === id)
  574. taskFormData.value.taskExtList.splice(index, 1)
  575. }
  576. /**
  577. * 新增任务拓展信息
  578. */
  579. const addContinueTaskExt = () => {
  580. taskFormData.value.continueTaskExtList.push({
  581. id: Date.now(),
  582. "initialValue": {
  583. label: '起始值',
  584. value: ''
  585. },
  586. "extraPoints": {
  587. label: '奖励的积分(额外)',
  588. value: ''
  589. }
  590. })
  591. }
  592. /**
  593. * 删除任务拓展信息
  594. */
  595. const deleteContinueTaskExt = (id) => {
  596. let index = taskFormData.value.continueTaskExtList.findIndex(v => v.id === id)
  597. taskFormData.value.continueTaskExtList.splice(index, 1)
  598. }
  599. /**
  600. * 保存打卡任务
  601. */
  602. const saveTask = () => {
  603. taskForm.value.validate(['id']).then(() => {
  604. return punchInApi.saveTask(taskFormData.value)
  605. }).then(datt => {
  606. uni.showToast({
  607. title: '保存成功',
  608. icon: 'success',
  609. duration: 2000
  610. });
  611. setTimeout(() => {
  612. uni.navigateBack();
  613. }, 2000);
  614. }).catch(err => {
  615. console.log('表单错误信息:', err);
  616. uni.showModal({
  617. title: "保存失败",
  618. content: "请检查表单项是否已正确填写",
  619. showCancel: false
  620. });
  621. });
  622. }
  623. /**
  624. * 后退
  625. */
  626. const cancel = () => {
  627. uni.navigateBack();
  628. }
  629. onLoad(async (e) => {
  630. if (e.id) {
  631. const res = await punchInApi.queryTask({ "id": e.id });
  632. taskFormData.value = res;
  633. }
  634. });
  635. </script>
  636. <style lang="scss" scoped>
  637. .extra-box {
  638. display: flex;
  639. .extra-box-item {
  640. flex: 1;
  641. }
  642. }
  643. .pick-box {
  644. display: flex;
  645. box-sizing: border-box;
  646. flex-direction: row;
  647. align-items: center;
  648. border: 1px solid #dcdfe6;
  649. border-radius: 4px;
  650. width: auto;
  651. position: relative;
  652. overflow: hidden;
  653. flex: 1;
  654. line-height: 1;
  655. font-size: 14px;
  656. height: 35px;
  657. padding-left: 10px;
  658. }
  659. .button-container {
  660. background-color: #FFFFFF;
  661. display: flex;
  662. /* 使用Flexbox布局 */
  663. justify-content: space-between;
  664. /* 按钮之间的空间分布 */
  665. padding: 20rpx;
  666. /* 容器两侧的空白填充 */
  667. }
  668. </style>