70 lines
2.0 KiB
JavaScript
70 lines
2.0 KiB
JavaScript
import { defineStore } from "pinia";
|
||
import moment from 'moment';
|
||
|
||
export default defineStore('conformanceInputStore', {
|
||
state: () => ({
|
||
inputDataToSave: {
|
||
inputStart: null, // 有待釐清,start 是活動的開始,還是時間的開始?
|
||
inputEnd: null,
|
||
min: null,
|
||
max: null,
|
||
type: null,
|
||
task: null,
|
||
},
|
||
activityRadioData: {
|
||
category: null,
|
||
task: ['', ''],
|
||
},
|
||
}),
|
||
getters: {
|
||
},
|
||
actions: {
|
||
/** UNUSED
|
||
* Set input activity radio data
|
||
* @param {object} actRadioData
|
||
*/
|
||
setActivityRadioStartEndData(actRadioData) {
|
||
this.activityRadioData = actRadioData;
|
||
},
|
||
/**
|
||
* Sets the activity radio global state for either the start ('From') or end ('To') of a task.
|
||
* We arrange in this way because backend needs us to communicate in this way.
|
||
* @param {object} actRadioData
|
||
* @param {string} fromToStr 'From' or 'To'
|
||
*/
|
||
setActivityRadioStartEndData(actRadioData, fromToStr){
|
||
switch(fromToStr) {
|
||
case 'From':
|
||
this.activityRadioData.task[0] = actRadioData;
|
||
break;
|
||
case 'To':
|
||
this.activityRadioData.task[this.activityRadioData.task.length - 1] = actRadioData;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
},
|
||
/**
|
||
* UNUSED
|
||
* Temporarily set conformance input data which is probably fed to backend later.
|
||
* @param {object} userInputObj
|
||
*/
|
||
setConformanceUserInput(userInputObj){
|
||
this.inputDataToSave = {...userInputObj};
|
||
},
|
||
/** UNUSED
|
||
* Set the starting time of time range to be saved later
|
||
* @param {string} startStr
|
||
*/
|
||
setConformanceInputStart(startStr){
|
||
this.inputDataToSave.inputStart = moment(startStr).format('YYYY-MM-DDTHH:mm:ss');
|
||
},
|
||
/** UNUSED
|
||
* Set the ending time of time range to be saved later
|
||
* @param {string} startStr
|
||
*/
|
||
setConformanceInputEnd(endStr){
|
||
this.inputDataToSave.inputEnd = moment(endStr).format('YYYY-MM-DDTHH:mm:ss');
|
||
},
|
||
},
|
||
}) |