next step record and create / retrieve a task record
This commit is contained in:
@@ -56,6 +56,23 @@ export const useTaskRecordStore = defineStore('task-record-store', {
|
|||||||
|
|
||||||
stepRecord.end = params.end
|
stepRecord.end = params.end
|
||||||
},
|
},
|
||||||
|
nextStepRecord(params: {
|
||||||
|
recordId: string
|
||||||
|
currentStepId: string
|
||||||
|
nextStepId: string
|
||||||
|
tick: ISODate
|
||||||
|
}) {
|
||||||
|
this.endStepRecord({
|
||||||
|
recordId: params.recordId,
|
||||||
|
stepId: params.currentStepId,
|
||||||
|
end: params.tick
|
||||||
|
})
|
||||||
|
this.startStepRecord({
|
||||||
|
recordId: params.recordId,
|
||||||
|
stepId: params.nextStepId,
|
||||||
|
start: params.tick
|
||||||
|
})
|
||||||
|
},
|
||||||
addProblemToStepRecord(recordId: string, stepId: string, problem: string) {
|
addProblemToStepRecord(recordId: string, stepId: string, problem: string) {
|
||||||
const stepRecord = this.getStepRecord(recordId, stepId)
|
const stepRecord = this.getStepRecord(recordId, stepId)
|
||||||
|
|
||||||
@@ -73,6 +90,23 @@ export const useTaskRecordStore = defineStore('task-record-store', {
|
|||||||
TaskRecord.fromRecordable(this.records[recordId])
|
TaskRecord.fromRecordable(this.records[recordId])
|
||||||
) ?? []
|
) ?? []
|
||||||
},
|
},
|
||||||
|
createAndRetriveTaskRecord() {
|
||||||
|
return (taskId: string, recordId: string): TaskRecord => {
|
||||||
|
const hasTaskRecord = this.taskRecordMaps[taskId]?.some(
|
||||||
|
(rId) => rId === recordId
|
||||||
|
)
|
||||||
|
|
||||||
|
if (hasTaskRecord) {
|
||||||
|
return TaskRecord.fromRecordable(this.records[recordId])
|
||||||
|
}
|
||||||
|
|
||||||
|
const newTaskRecord = new TaskRecord(recordId, taskId)
|
||||||
|
this.taskRecordMaps[taskId]?.push(recordId)
|
||||||
|
this.records[recordId] = newTaskRecord
|
||||||
|
|
||||||
|
return newTaskRecord
|
||||||
|
}
|
||||||
|
},
|
||||||
getStepRecord() {
|
getStepRecord() {
|
||||||
return (recordId: string, stepId: string): StepRecordable | null =>
|
return (recordId: string, stepId: string): StepRecordable | null =>
|
||||||
this.records?.[recordId]?.stepRecords[stepId] ?? null
|
this.records?.[recordId]?.stepRecords[stepId] ?? null
|
||||||
|
|||||||
Reference in New Issue
Block a user