| | |
| | | import dayjs from 'dayjs'; |
| | | import { useStore } from 'vuex'; |
| | | import { getRegionTreeAll, getDeviceRegion, deptsByAreaCode } from '@/api/job/task'; |
| | | |
| | | const store = useStore(); |
| | | const userAreaCode = computed(() => store.getters.userInfo.detail.areaCode); |
| | | const selectedAreaCode = computed(() => store.state.user.selectedAreaCode); |
| | | const emit = defineEmits(['search']); |
| | | const treeProps = { |
| | | label: 'name', |
| | | value: 'id', |
| | |
| | | let deptData = ref([]); |
| | | // 从单机巢任务传参值 |
| | | const signDevice_sn = ref(''); |
| | | const handleDateChange = () => {}; |
| | | // 日期限制 |
| | | const handleDateChange = val => { |
| | | if (val && val.length === 2) { |
| | | const start = dayjs(val[0]); |
| | | const end = dayjs(val[1]); |
| | | const diff = end.diff(start, 'day'); |
| | | |
| | | if (diff > 31) { |
| | | ElMessage.warning('日期范围不能超过31天'); |
| | | dateRange.value = []; |
| | | return; |
| | | } |
| | | } |
| | | handleSearch(); |
| | | }; |
| | | // 部门下得机巢 |
| | | const requestDockInfo = () => { |
| | | getRegionTreeAll({ parentCode: userAreaCode.value }).then(res => { |
| | |
| | | }); |
| | | }; |
| | | // 搜索 |
| | | const handleSearch = () => {}; |
| | | const handleSearch = () => { |
| | | if (!dateRange.value) { |
| | | dateRange.value = []; |
| | | } |
| | | let params = { |
| | | ...searchForm, |
| | | start_date: dateRange.value.length |
| | | ? dayjs(dateRange?.value[0]).startOf('day').format(timeFormat) |
| | | : null, |
| | | end_date: dateRange.value.length |
| | | ? dayjs(dateRange?.value[1]).endOf('day').format(timeFormat) |
| | | : null, |
| | | }; |
| | | console.log('searchForm', params); |
| | | // 调用父组件方法 |
| | | emit('search', params); |
| | | }; |
| | | // 重置 |
| | | const handleReset = () => {}; |
| | | const handleReset = () => { |
| | | dateRange.value = []; |
| | | Object.keys(searchForm).forEach(key => { |
| | | searchForm[key] = ''; |
| | | }); |
| | | handleNodeClick({ id: userAreaCode.value }); |
| | | handleSearch(); |
| | | }; |
| | | onMounted(() => { |
| | | requestDockInfo(); |
| | | }); |