task.js 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { defineStore } from 'pinia';
  2. import { clone, cloneDeep } from 'lodash-es';
  3. // 默认任务信息
  4. const defaulTaskFormInfo = {
  5. name: '',
  6. typeId: '',
  7. planTime: '',
  8. phoneList: [{ phone: null, name: null, gender: null }],
  9. callUserTestId:'',
  10. callPlatform: ''
  11. };
  12. const task = defineStore({
  13. id: 'task',
  14. state: () => ({
  15. taskFormInfo: uni.getStorageSync('taskFormInfo')||cloneDeep(defaulTaskFormInfo), // 任务信息
  16. }),
  17. actions: {
  18. // 更新任务信息
  19. async updateTaskFormInfo(taskFormData) {
  20. this.taskFormInfo = Object.assign(this.taskFormInfo,taskFormData)
  21. uni.setStorageSync('taskFormInfo', this.taskFormInfo)
  22. return this.taskFormInfo
  23. },
  24. // 重置默认数据
  25. resetTaskData() {
  26. this.taskFormInfo = cloneDeep(defaulTaskFormInfo)
  27. uni.setStorageSync('taskFormInfo', this.taskFormInfo)
  28. },
  29. },
  30. persist: {
  31. enabled: true,
  32. strategies: [
  33. {
  34. key: 'task-store',
  35. },
  36. ],
  37. },
  38. });
  39. export default task;