refactor ConformanceTimeRrange created

This commit is contained in:
Cindy Chang
2024-07-22 15:31:46 +08:00
parent 5230a3a99b
commit 54f0d29c99

View File

@@ -229,100 +229,91 @@ export default {
},
created() {
this.$emitter.on('actRadioData', (data) => {
switch (data.category) {
const category = data.category;
const task = data.task;
const handleDoubleSelection = (startKey, endKey, timeKey, durationType) => {
this[startKey] = task;
this[timeKey] = { min: 0, max: 0 };
if (this[endKey]) {
this[timeKey] = this.getDurationTime(this[durationType], 'double', task, this[endKey]);
}
};
const handleSingleSelection = (key, timeKey, durationType) => {
this[timeKey] = this.getDurationTime(this[durationType], 'single', task);
};
switch (category) {
// Activity duration
case 'cfmDur':
this.timeDuration = this.getDurationTime(this.conformanceAllTasks, 'act', data.task);
break;
this.timeDuration = this.getDurationTime(this.conformanceAllTasks, 'act', task);
break;
// Processing time
case 'cfmPtEteStart':
this.timeCfmPtEteStart = this.getDurationTime(this.cfmPtEteStart, 'single', data.task);
break;
handleSingleSelection('cfmPtEteStart', 'timeCfmPtEteStart', 'cfmPtEteStart');
break;
case 'cfmPtEteEnd':
this.timeCfmPtEteEnd = this.getDurationTime(this.cfmPtEteEnd, 'single', data.task);
break;
handleSingleSelection('cfmPtEteEnd', 'timeCfmPtEteEnd', 'cfmPtEteEnd');
break;
case 'cfmPtEteSEStart':
this.selectCfmPtEteSEStart = data.task;
this.timeCfmPtEteSE = {min: 0, max: 0};
if(this.selectCfmPtEteSEEnd) this.timeCfmPtEteSE = this.getDurationTime(this.cfmPtEteSE, 'double', data.task, this.selectCfmPtEteSEEnd);
break;
handleDoubleSelection('selectCfmPtEteSEStart', 'selectCfmPtEteSEEnd', 'timeCfmPtEteSE', 'cfmPtEteSE');
break;
case 'cfmPtEteSEEnd':
this.selectCfmPtEteSEEnd = data.task;
this.timeCfmPtEteSE = {min: 0, max: 0};
if(this.selectCfmPtEteSEStart) this.timeCfmPtEteSE = this.getDurationTime(this.cfmPtEteSE, 'double', this.selectCfmPtEteSEStart, data.task);
break;
handleDoubleSelection('selectCfmPtEteSEEnd', 'selectCfmPtEteSEStart', 'timeCfmPtEteSE', 'cfmPtEteSE');
break;
case 'cfmPtPStart':
this.timeCfmPtPStart = this.getDurationTime(this.cfmPtPStart, 'single', data.task);
break;
handleSingleSelection('cfmPtPStart', 'timeCfmPtPStart', 'cfmPtPStart');
break;
case 'cfmPtPEnd':
this.timeCfmPtPEnd = this.getDurationTime(this.cfmPtPEnd, 'single', data.task);
break;
handleSingleSelection('cfmPtPEnd', 'timeCfmPtPEnd', 'cfmPtPEnd');
break;
case 'cfmPtPSEStart':
this.selectCfmPtPSEStart = data.task;
this.timeCfmPtPSE = {min: 0, max: 0};
if(this.selectCfmPtPSEEnd) {
this.timeCfmPtPSE = this.getDurationTime(this.cfmPtPSE, 'double', data.task, this.selectCfmPtPSEEnd);
}
break;
handleDoubleSelection('selectCfmPtPSEStart', 'selectCfmPtPSEEnd', 'timeCfmPtPSE', 'cfmPtPSE');
break;
case 'cfmPtPSEEnd':
this.selectCfmPtPSEEnd = data.task;
this.timeCfmPtPSE = {min: 0, max: 0};
if(this.selectCfmPtPSEStart) {
this.timeCfmPtPSE = this.getDurationTime(this.cfmPtPSE, 'double', this.selectCfmPtPSEStart, data.task);
}
break;
handleDoubleSelection('selectCfmPtPSEEnd', 'selectCfmPtPSEStart', 'timeCfmPtPSE', 'cfmPtPSE');
break;
// Waiting time
case 'cfmWtEteStart':
this.timeCfmWtEteStart = this.getDurationTime(this.cfmWtEteStart, 'single', data.task);
break;
handleSingleSelection('cfmWtEteStart', 'timeCfmWtEteStart', 'cfmWtEteStart');
break;
case 'cfmWtEteEnd':
this.timeCfmWtEteEnd = this.getDurationTime(this.cfmWtEteEnd, 'single', data.task);
break;
handleSingleSelection('cfmWtEteEnd', 'timeCfmWtEteEnd', 'cfmWtEteEnd');
break;
case 'cfmWtEteSEStart':
this.selectCfmWtEteSEStart = data.task;
this.timeCfmWtEteSE = {min: 0, max: 0};
if(this.selectCfmWtEteSEEnd) this.timeCfmWtEteSE = this.getDurationTime(this.cfmWtEteSE, 'double', data.task, this.selectCfmWtEteSEEnd);
break;
handleDoubleSelection('selectCfmWtEteSEStart', 'selectCfmWtEteSEEnd', 'timeCfmWtEteSE', 'cfmWtEteSE');
break;
case 'cfmWtEteSEEnd':
this.selectCfmWtEteSEEnd = data.task;
this.timeCfmWtEteSE = {min: 0, max: 0};
if(this.selectCfmWtEteSEStart) this.timeCfmWtEteSE = this.getDurationTime(this.cfmWtEteSE, 'double', this.selectCfmWtEteSEStart, data.task);
break;
handleDoubleSelection('selectCfmWtEteSEEnd', 'selectCfmWtEteSEStart', 'timeCfmWtEteSE', 'cfmWtEteSE');
break;
case 'cfmWtPStart':
this.timeCfmWtPStart = this.getDurationTime(this.cfmWtPStart, 'single', data.task);
break;
handleSingleSelection('cfmWtPStart', 'timeCfmWtPStart', 'cfmWtPStart');
break;
case 'cfmWtPEnd':
this.timeCfmWtPEnd = this.getDurationTime(this.cfmWtPEnd, 'single', data.task);
break;
handleSingleSelection('cfmWtPEnd', 'timeCfmWtPEnd', 'cfmWtPEnd');
break;
case 'cfmWtPSEStart':
this.selectCfmWtPSEStart = data.task;
this.timeCfmWtPSE = {min: 0, max: 0};
if(this.selectCfmWtPSEEnd) this.timeCfmWtPSE = this.getDurationTime(this.cfmWtPSE, 'double', data.task, this.selectCfmWtPSEEnd);
break;
handleDoubleSelection('selectCfmWtPSEStart', 'selectCfmWtPSEEnd', 'timeCfmWtPSE', 'cfmWtPSE');
break;
case 'cfmWtPSEEnd':
this.selectCfmWtPSEEnd = data.task;
this.timeCfmWtPSE = {min: 0, max: 0};
if(this.selectCfmWtPSEStart) this.timeCfmWtPSE = this.getDurationTime(this.cfmWtPSE, 'double', this.selectCfmWtPSEStart, data.task);
break;
handleDoubleSelection('selectCfmWtPSEEnd', 'selectCfmWtPSEStart', 'timeCfmWtPSE', 'cfmWtPSE');
break;
// Cycle time
case 'cfmCtEteStart':
this.timeCfmCtEteStart = this.getDurationTime(this.cfmPtEteStart, 'single', data.task);
break;
handleSingleSelection('cfmCtEteStart', 'timeCfmCtEteStart', 'cfmCtEteStart');
break;
case 'cfmCtEteEnd':
this.timeCfmCtEteEnd = this.getDurationTime(this.cfmCtEteEnd, 'single', data.task);
break;
handleSingleSelection('cfmCtEteEnd', 'timeCfmCtEteEnd', 'cfmCtEteEnd');
break;
case 'cfmCtEteSEStart':
this.selectCfmCtEteSEStart = data.task;
this.timeCfmCtEteSEE = {min: 0, max: 0};
if(this.selectCfmCtEteSEEnd) this.timeCfmCtEteSE = this.getDurationTime(this.cfmCtEteSE, 'double', data.task, this.selectCfmCtEteSEEnd);
break;
handleDoubleSelection('selectCfmCtEteSEStart', 'selectCfmCtEteSEEnd', 'timeCfmCtEteSE', 'cfmCtEteSE');
break;
case 'cfmCtEteSEEnd':
this.selectCfmCtEteSEEnd = data.task;
this.timeCfmCtEteSEE = {min: 0, max: 0};
if(this.selectCfmCtEteSEStart) this.timeCfmCtEteSE = this.getDurationTime(this.cfmCtEteSE, 'double', this.selectCfmCtEteSEStart, data.task);
break;
handleDoubleSelection('selectCfmCtEteSEEnd', 'selectCfmCtEteSEStart', 'timeCfmCtEteSE', 'cfmCtEteSE');
break;
default:
break;
break;
};
});
this.$emitter.on('reset', (data) => {