58 lines
1.8 KiB
Vue
58 lines
1.8 KiB
Vue
<template>
|
|
<div class="h-full bg-neutral-10 border border-neutral-300 rounded-xl ml-4 p-2 space-y-2">
|
|
<p class="h2 pl-2">{{ title }}</p>
|
|
<div class="h-[calc(100%_-_48px)]">
|
|
<p class="h2 pl-2 border-b mb-3">Sort</p>
|
|
<div class="flex flex-wrap justify-start content-start gap-4 px-2 overflow-y-auto scrollbar h-[calc(100%_-_52px)]">
|
|
<div class="flex items-center w-[166px]" v-for="(act, index) in sortData" :key="index">
|
|
<RadioButton v-model="selectedRadio" :inputId="index + act" :name="select" :value="act" @change="actRadioData" />
|
|
<label :for="index + act" class="ml-2 p-2 whitespace-nowrap break-keep text-ellipsis overflow-hidden">{{ act }}</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import sortNumEngZhtw from '@/module/sortNumEngZhtw.js';
|
|
|
|
export default {
|
|
props: ['title', 'select', 'data', 'category', 'task', 'isSubmit'],
|
|
data() {
|
|
return {
|
|
sortData: [],
|
|
localSelect: null,
|
|
selectedRadio: null,
|
|
}
|
|
},
|
|
watch: {
|
|
data: {
|
|
handler: function(newValue) {
|
|
this.sortData = sortNumEngZhtw(newValue)
|
|
},
|
|
immediate: true, // 立即執行一次排序
|
|
},
|
|
task: function(newValue) {
|
|
this.selectedRadio = newValue;
|
|
},
|
|
},
|
|
methods: {
|
|
actRadioData() {
|
|
this.localSelect = null;
|
|
this.$emitter.emit('actRadioData', {
|
|
category: this.category,
|
|
task: this.selectedRadio,
|
|
});
|
|
this.$emit('selected-task', this.selectedRadio);
|
|
}
|
|
},
|
|
created() {
|
|
sortNumEngZhtw(this.sortData);
|
|
this.localSelect = this.isSubmit ? this.select : null;
|
|
this.selectedRadio = this.localSelect;
|
|
this.$emitter.on('reset', (data) => {
|
|
this.selectedRadio = data;
|
|
});
|
|
},
|
|
}
|
|
</script>
|