ts/src/views/Gantt/components/MainGantt2/index.jsx

85 lines
2.2 KiB
React
Raw Normal View History

2025-03-12 01:13:41 +00:00
import { useRouter } from 'vue-router'
2025-03-11 00:53:58 +00:00
import {
NDatePicker,
NRadioButton,
NRadioGroup,
NButton,
NSelect,
} from 'naive-ui'
import GanttCom from '../Gantt'
2025-03-12 01:13:41 +00:00
import { getDDList } from '@/api/Gantt/gantt'
2025-03-11 00:53:58 +00:00
import { onBeforeMount } from 'vue'
export default defineComponent({
setup() {
2025-03-12 01:13:41 +00:00
const range = ref([new Date('2000-01-01 00:00:00').getTime(), Date.now()])
2025-03-11 00:53:58 +00:00
const value = ref('year')
const types = ref([])
const router = useRouter()
const editEvent = () => {
console.log(router)
router.push('/gantt/mainEdit')
}
2025-03-12 01:13:41 +00:00
onBeforeMount(async () => {
2025-03-11 00:53:58 +00:00
await getDDOptions()
})
const ddOptions = ref([])
2025-03-12 01:13:41 +00:00
async function getDDOptions() {
const { code, data } = await getDDList()
if (code === 200) {
2025-03-11 00:53:58 +00:00
ddOptions.value = data.list
2025-03-12 01:13:41 +00:00
types.value = ddOptions.value.map(item => item.id)
2025-03-11 00:53:58 +00:00
}
2025-03-12 01:13:41 +00:00
}
2025-03-11 00:53:58 +00:00
const ganttRef = ref(null)
2025-03-12 01:13:41 +00:00
function searchGanttData() {
2025-03-11 00:53:58 +00:00
// console.log(ganttRef);
2025-03-12 01:13:41 +00:00
renderMainTask(document.querySelector('#tableContainer'), {
2025-03-11 00:53:58 +00:00
ids: types.value,
2025-03-12 01:13:41 +00:00
startTime: range.value[0],
endTime: range.value[1],
2025-03-11 00:53:58 +00:00
})
}
return () => (
<>
<div class="flex gap-2">
<NDatePicker
v-model:value={range.value}
2025-03-12 01:13:41 +00:00
type="datetimerange"
2025-03-11 00:53:58 +00:00
clearable
/>
{/* <NRadioGroup v-model:value={value.value} name="radiobuttongroup">
<NRadioButton value="hour" label="日" />
<NRadioButton value="day" label="月" />
</NRadioGroup> */}
<NSelect
v-model:value={types.value}
multiple
options={ddOptions.value}
2025-03-12 01:13:41 +00:00
label-field="name"
2025-03-11 00:53:58 +00:00
clearable
2025-03-12 01:13:41 +00:00
value-field="id"
2025-03-11 00:53:58 +00:00
></NSelect>
{/* <NButton class="ml-auto" type="primary" onClick={editEvent}>
编辑事件
</NButton> */}
<NButton class="ml-auto" type="primary" onClick={searchGanttData}>
搜索
</NButton>
</div>
2025-03-12 01:13:41 +00:00
<GanttCom
ref={ganttRef}
scale={value.value}
dateRange={range.value}
types={types.value}
/>
2025-03-11 00:53:58 +00:00
</>
)
},
})